N-sim
Emulation and simulation of
Wireless Sensor Networks



   Home


   Project Page


   Download


   CVS



   Installation


   Configuration


   Plug-ins




 Hosted by
SourceForge.net Logo

/home/brennan/n-sim/Vaike/linux/system-addons/networking/mesh_neighbor.c File Reference

WSN mesh network neighbors. More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <net/route.h>
#include <errno.h>
#include <syslog.h>
#include <netdb.h>
#include <math.h>
#include "mesh_neighbor.h"
#include "sensor_self.h"

Go to the source code of this file.

Defines

#define MESH_N_DISCOVERY_PORT   652
#define HELLO_LEN   ((sizeof(double)*3) + 32)
#define HELLO_INTERVAL   180

Functions

unsigned int mac_to_id (char *addr)
void init_n_entry (self_t *self, neighbor_entry_t *entry)
neighbor_entry_tnew_n_entry (self_t *self)
int add_n_entry (self_t *self, unsigned int id, neighbor_entry_t *entry)
int remove_n_entry (self_t *self, unsigned int id, neighbor_entry_t *entry)
neighbor_entry_tretrieve_n_entry (self_t *self, unsigned int id)
neighbor_entry_titerate_n_entries (self_t *self)
unsigned int num_n_entries (self_t *self)
void empty_n_entries (self_t *self)
neighbor_entry_tneighbor_by_position (self_t *self, double bearing, double distance)
neighbor_entry_tneighbor_by_ip (self_t *self, struct sockaddr_in *ip)
int neighbor_address (self_t *self, char *addr, double bearing, double distance)
int neighbor_position (self_t *self, double *bearing, double *distance, char *addr)
int find_neighbors (self_t *self)
int neighbor_discovery (self_t *self)


Detailed Description

WSN mesh network neighbors.

Revision
1.1

Original Author: Sean M. Brennan <brennan@lanl.gov>

Author
sean_m_brennan

Created: August 1, 2007

Date
2008/02/03 22:00:48

Definition in file mesh_neighbor.c.


Define Documentation

#define HELLO_INTERVAL   180
 

Definition at line 56 of file mesh_neighbor.c.

Referenced by neighbor_discovery().

#define HELLO_LEN   ((sizeof(double)*3) + 32)
 

We borrow the IANA assigned HELLO port * http://www.iana.org/assignments/port-numbers

Definition at line 55 of file mesh_neighbor.c.

Referenced by find_neighbors(), and neighbor_discovery().

#define MESH_N_DISCOVERY_PORT   652
 

Definition at line 51 of file mesh_neighbor.c.

Referenced by find_neighbors(), and neighbor_discovery().


Function Documentation

int add_n_entry self_t self,
unsigned int  id,
neighbor_entry_t entry
 

Definition at line 82 of file mesh_neighbor.c.

References avl_insert(), _self::neighbors, and _neighbor_entry::node_id.

Referenced by neighbor_discovery().

void empty_n_entries self_t self  ) 
 

Definition at line 130 of file mesh_neighbor.c.

References destroy_avltree(), iterate_n_entries(), _self::neighbors, and avltree::root.

int find_neighbors self_t self  ) 
 

Definition at line 200 of file mesh_neighbor.c.

References _self::altitude, _self::broadcast, he, HELLO_LEN, _self::interface, _self::latitude, _self::longitude, _self::mac_addr, MESH_N_DISCOVERY_PORT, mesh_sendmsg(), and mesh_socket().

Referenced by neighbor_discovery().

void init_n_entry self_t self,
neighbor_entry_t entry
 

Definition at line 65 of file mesh_neighbor.c.

References _neighbor_entry::alt, _neighbor_entry::lat, _neighbor_entry::lon, _self::mac_addr, mac_to_id(), and _neighbor_entry::node_id.

Referenced by new_n_entry().

neighbor_entry_t* iterate_n_entries self_t self  ) 
 

Definition at line 110 of file mesh_neighbor.c.

References avl_find_min(), _self::n_iter, and _self::neighbors.

Referenced by empty_n_entries(), neighbor_by_ip(), and neighbor_by_position().

unsigned int mac_to_id char *  addr  ) 
 

Definition at line 59 of file mesh_neighbor.c.

Referenced by init_n_entry(), neighbor_discovery(), and neighbor_position().

int neighbor_address self_t self,
char *  addr,
double  bearing,
double  distance
 

Definition at line 172 of file mesh_neighbor.c.

Referenced by mesh_link_energy(), mesh_link_goodput(), mesh_link_reliability(), and mesh_sendto_nextdoor().

neighbor_entry_t* neighbor_by_ip self_t self,
struct sockaddr_in *  ip
 

Definition at line 158 of file mesh_neighbor.c.

References _neighbor_entry::ip, and iterate_n_entries().

Referenced by mesh_recv_nextdoor().

neighbor_entry_t* neighbor_by_position self_t self,
double  bearing,
double  distance
 

Definition at line 143 of file mesh_neighbor.c.

References _neighbor_entry::bearing, _neighbor_entry::distance, and iterate_n_entries().

Referenced by mesh_send_nextdoor(), and neighbor_address().

int neighbor_discovery self_t self  ) 
 

Definition at line 273 of file mesh_neighbor.c.

References add_n_entry(), _self::altitude, error, find_neighbors(), HELLO_INTERVAL, HELLO_LEN, _self::interface, _self::latitude, _self::longitude, mac_to_id(), memcpy, MESH_N_COMM_PORT, MESH_N_DISCOVERY_PORT, mesh_socket(), new_n_entry(), and timed_recv().

Referenced by discover_neighbors().

int neighbor_position self_t self,
double *  bearing,
double *  distance,
char *  addr
 

Definition at line 185 of file mesh_neighbor.c.

Referenced by mesh_recvfrom_nextdoor().

neighbor_entry_t* new_n_entry self_t self  ) 
 

Definition at line 74 of file mesh_neighbor.c.

References init_n_entry().

Referenced by neighbor_discovery().

unsigned int num_n_entries self_t self  ) 
 

Definition at line 124 of file mesh_neighbor.c.

References avl_size(), and _self::neighbors.

int remove_n_entry self_t self,
unsigned int  id,
neighbor_entry_t entry
 

Definition at line 94 of file mesh_neighbor.c.

References avl_delete(), and _self::neighbors.

neighbor_entry_t* retrieve_n_entry self_t self,
unsigned int  id
 

Definition at line 104 of file mesh_neighbor.c.

References avl_retrieve(), and _self::neighbors.

Referenced by neighbor_position().


© 2007, Los Alamos National Security, LLC.