Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Friends

OLSR Class Reference

Routing agent which implements OLSR protocol following RFC 3626. More...

#include <OLSR.h>

Inheritance diagram for OLSR:
Agent Agent Connector Connector NsObject NsObject Handler Handler

List of all members.

Public Member Functions

 OLSR (nsaddr_t)
 Creates necessary timers, binds TCL-available variables and do some more initializations.
int command (int, const char *const *)
 Interface with TCL interpreter.
void recv (Packet *, Handler *)
 This function is called whenever a packet is received. It identifies the type of the received packet and process it accordingly.
void mac_failed (Packet *)
 Drops a given packet because it couldn't be delivered to the corresponding destination by the MAC layer. This may cause a neighbor loss, and appropiate actions are then taken.
 OLSR (nsaddr_t)
int command (int, const char *const *)
void recv (Packet *, Handler *)
void mac_failed (Packet *)

Static Public Member Functions

static double emf_to_seconds (u_int8_t)
 Converts a number of seconds in the mantissa/exponent format to a decimal number.
static u_int8_t seconds_to_emf (double)
 Converts a decimal number of seconds to the mantissa/exponent format.
static int node_id (nsaddr_t)
 Returns the identifier of a node given the address of the attached OLSR agent.
static double emf_to_seconds (u_int8_t)
static u_int8_t seconds_to_emf (double)
static int node_id (nsaddr_t)

Protected Member Functions

u_int16_t pkt_seq ()
 Increments packet sequence number and returns the new value.
u_int16_t msg_seq ()
 Increments message sequence number and returns the new value.
nsaddr_t & ra_addr ()
int & hello_ival ()
int & tc_ival ()
int & mid_ival ()
int & willingness ()
int & use_mac ()
linkset_t & linkset ()
mprset_t & mprset ()
mprselset_t & mprselset ()
nbset_t & nbset ()
nb2hopset_t & nb2hopset ()
topologyset_t & topologyset ()
dupset_t & dupset ()
ifaceassocset_t & ifaceassocset ()
void recv_olsr (Packet *)
 Processes an incoming OLSR packet following RFC 3626 specification.
void mpr_computation ()
 Computates MPR set of a node following RFC 3626 hints.
void rtable_computation ()
 Creates the routing table of the node following RFC 3626 hints.
void process_hello (OLSR_msg &, nsaddr_t, nsaddr_t)
 Processes a HELLO message following RFC 3626 specification.
void process_tc (OLSR_msg &, nsaddr_t)
 Processes a TC message following RFC 3626 specification.
void process_mid (OLSR_msg &, nsaddr_t)
 Processes a MID message following RFC 3626 specification.
void forward_default (Packet *, OLSR_msg &, OLSR_dup_tuple *, nsaddr_t)
 OLSR's default forwarding algorithm.
void forward_data (Packet *)
 Forwards a data packet to the appropiate next hop indicated by the routing table.
void enque_msg (OLSR_msg &, double)
 Enques an OLSR message which will be sent with a delay of (0, delay].
void send_hello ()
 Creates a new OLSR HELLO message which is buffered to be sent later on.
void send_tc ()
 Creates a new OLSR TC message which is buffered to be sent later on.
void send_mid ()
 Creates a new OLSR MID message which is buffered to be sent later on.
void send_pkt ()
 Creates as many OLSR packets as needed in order to send all buffered OLSR messages.
void link_sensing (OLSR_msg &, nsaddr_t, nsaddr_t)
 Updates Link Set according to a new received HELLO message (following RFC 3626 specification). Neighbor Set is also updated if needed.
void populate_nbset (OLSR_msg &)
 Updates the Neighbor Set according to the information contained in a new received HELLO message (following RFC 3626).
void populate_nb2hopset (OLSR_msg &)
 Updates the 2-hop Neighbor Set according to the information contained in a new received HELLO message (following RFC 3626).
void populate_mprselset (OLSR_msg &)
 Updates the MPR Selector Set according to the information contained in a new received HELLO message (following RFC 3626).
void set_hello_timer ()
 Schedule the timer used for sending HELLO messages.
void set_tc_timer ()
 Schedule the timer used for sending TC messages.
void set_mid_timer ()
 Schedule the timer used for sending MID messages.
void nb_loss (OLSR_link_tuple *)
 Performs all actions needed when a neighbor loss occurs.
void add_dup_tuple (OLSR_dup_tuple *)
 Adds a duplicate tuple to the Duplicate Set.
void rm_dup_tuple (OLSR_dup_tuple *)
 Removes a duplicate tuple from the Duplicate Set.
void add_link_tuple (OLSR_link_tuple *, u_int8_t)
 Adds a link tuple to the Link Set (and an associated neighbor tuple to the Neighbor Set).
void rm_link_tuple (OLSR_link_tuple *)
 Removes a link tuple from the Link Set.
void updated_link_tuple (OLSR_link_tuple *)
 This function is invoked when a link tuple is updated. Its aim is to also update the corresponding neighbor tuple if it is needed.
void add_nb_tuple (OLSR_nb_tuple *)
 Adds a neighbor tuple to the Neighbor Set.
void rm_nb_tuple (OLSR_nb_tuple *)
 Removes a neighbor tuple from the Neighbor Set.
void add_nb2hop_tuple (OLSR_nb2hop_tuple *)
 Adds a 2-hop neighbor tuple to the 2-hop Neighbor Set.
void rm_nb2hop_tuple (OLSR_nb2hop_tuple *)
 Removes a 2-hop neighbor tuple from the 2-hop Neighbor Set.
void add_mprsel_tuple (OLSR_mprsel_tuple *)
 Adds an MPR selector tuple to the MPR Selector Set.
void rm_mprsel_tuple (OLSR_mprsel_tuple *)
 Removes an MPR selector tuple from the MPR Selector Set.
void add_topology_tuple (OLSR_topology_tuple *)
 Adds a topology tuple to the Topology Set.
void rm_topology_tuple (OLSR_topology_tuple *)
 Removes a topology tuple from the Topology Set.
void add_ifaceassoc_tuple (OLSR_iface_assoc_tuple *)
 Adds an interface association tuple to the Interface Association Set.
void rm_ifaceassoc_tuple (OLSR_iface_assoc_tuple *)
 Removes an interface association tuple from the Interface Association Set.
nsaddr_t get_main_addr (nsaddr_t)
 Gets the main address associated with a given interface address.
int degree (OLSR_nb_tuple *)
 This auxiliary function (defined in RFC 3626) is used for calculating the MPR Set.
u_int16_t pkt_seq ()
 Increments packet sequence number and returns the new value.
u_int16_t msg_seq ()
 Increments message sequence number and returns the new value.
nsaddr_t & ra_addr ()
int & hello_ival ()
int & tc_ival ()
int & mid_ival ()
int & willingness ()
int & use_mac ()
linkset_t & linkset ()
mprset_t & mprset ()
mprselset_t & mprselset ()
nbset_t & nbset ()
nb2hopset_t & nb2hopset ()
topologyset_t & topologyset ()
dupset_t & dupset ()
ifaceassocset_t & ifaceassocset ()
void recv_olsr (Packet *)
void recv_cdswl_pkt (Packet *)
void mpr_computation ()
void rtable_computation ()
void rtable_computation_h ()
 Creates the routing table of the node following RFC 3626 hints. Link state route calculation, single source, from "this" node. Added by YPC - 20090314.
void process_hello (OLSR_msg &, nsaddr_t, nsaddr_t)
void process_tc (OLSR_msg &, nsaddr_t)
void process_mid (OLSR_msg &, nsaddr_t)
void process_cdswl_hello (Packet *)
void forward_default (Packet *, OLSR_msg &, OLSR_dup_tuple *, nsaddr_t)
void forward_data (Packet *)
void enque_msg (OLSR_msg &, double)
void send_hello ()
void send_tc ()
void send_mid ()
void send_pkt ()
void send_cdswl_pkt (int pkt_type, int pkt_subtype=0)
void reset_cdswl_pkt_timer ()
void link_sensing (OLSR_msg &, nsaddr_t, nsaddr_t)
void populate_nbset (OLSR_msg &)
void populate_nb2hopset (OLSR_msg &)
void populate_mprselset (OLSR_msg &)
void set_hello_timer ()
void set_tc_timer ()
void set_mid_timer ()
void nb_loss (OLSR_link_tuple *)
void add_dup_tuple (OLSR_dup_tuple *)
void rm_dup_tuple (OLSR_dup_tuple *)
void add_link_tuple (OLSR_link_tuple *, u_int8_t)
void rm_link_tuple (OLSR_link_tuple *)
void updated_link_tuple (OLSR_link_tuple *)
void add_nb_tuple (OLSR_nb_tuple *)
void rm_nb_tuple (OLSR_nb_tuple *)
void add_nb2hop_tuple (OLSR_nb2hop_tuple *)
void rm_nb2hop_tuple (OLSR_nb2hop_tuple *)
void add_mprsel_tuple (OLSR_mprsel_tuple *)
void rm_mprsel_tuple (OLSR_mprsel_tuple *)
void add_topology_tuple (OLSR_topology_tuple *)
void rm_topology_tuple (OLSR_topology_tuple *)
void add_ifaceassoc_tuple (OLSR_iface_assoc_tuple *)
void rm_ifaceassoc_tuple (OLSR_iface_assoc_tuple *)
nsaddr_t get_main_addr (nsaddr_t)
int degree (OLSR_nb_tuple *)

Static Protected Member Functions

static bool seq_num_bigger_than (u_int16_t, u_int16_t)
 Determines which sequence number is bigger (as it is defined in RFC 3626).
static bool seq_num_bigger_than (u_int16_t, u_int16_t)

Protected Attributes

PortClassifierdmux_
 For passing packets up to agents.
Tracelogtarget_
 For logging.
OLSR_HelloTimer hello_timer_
 Timer for sending HELLO messages.
OLSR_TcTimer tc_timer_
 Timer for sending TC messages.
OLSR_MidTimer mid_timer_
 Timer for sending MID messages.
CDSWL_PktTimer cdswl_timer_

Friends

class OLSR_HelloTimer
class OLSR_TcTimer
class OLSR_MidTimer
class OLSR_DupTupleTimer
class OLSR_LinkTupleTimer
class OLSR_Nb2hopTupleTimer
class OLSR_MprSelTupleTimer
class OLSR_TopologyTupleTimer
class OLSR_IfaceAssocTupleTimer
class OLSR_MsgTimer
class CDSWL_PktTimer

Detailed Description

Routing agent which implements OLSR protocol following RFC 3626.

Interacts with TCL interface through command() method. It implements all functionalities related to sending and receiving packets and managing internal state.


Constructor & Destructor Documentation

OLSR::OLSR ( nsaddr_t  id  ) 

Creates necessary timers, binds TCL-available variables and do some more initializations.

Parameters:
id Identifier for the OLSR agent. It will be used as the address of this routing agent.

Member Function Documentation

void OLSR::add_dup_tuple ( OLSR_dup_tuple tuple  )  [protected]

Adds a duplicate tuple to the Duplicate Set.

Parameters:
tuple the duplicate tuple to be added.
void OLSR::add_ifaceassoc_tuple ( OLSR_iface_assoc_tuple tuple  )  [protected]

Adds an interface association tuple to the Interface Association Set.

Parameters:
tuple the interface association tuple to be added.
void OLSR::add_link_tuple ( OLSR_link_tuple tuple,
u_int8_t  willingness 
) [protected]

Adds a link tuple to the Link Set (and an associated neighbor tuple to the Neighbor Set).

Parameters:
tuple the link tuple to be added.
willingness willingness of the node which is going to be inserted in the Neighbor Set.
void OLSR::add_mprsel_tuple ( OLSR_mprsel_tuple tuple  )  [protected]

Adds an MPR selector tuple to the MPR Selector Set.

Advertised Neighbor Sequence Number (ANSN) is also updated.

Parameters:
tuple the MPR selector tuple to be added.
void OLSR::add_nb2hop_tuple ( OLSR_nb2hop_tuple tuple  )  [protected]

Adds a 2-hop neighbor tuple to the 2-hop Neighbor Set.

Parameters:
tuple the 2-hop neighbor tuple to be added.
void OLSR::add_nb_tuple ( OLSR_nb_tuple tuple  )  [protected]

Adds a neighbor tuple to the Neighbor Set.

Parameters:
tuple the neighbor tuple to be added.
void OLSR::add_topology_tuple ( OLSR_topology_tuple tuple  )  [protected]

Adds a topology tuple to the Topology Set.

Parameters:
tuple the topology tuple to be added.
int OLSR::command ( int  argc,
const char *const *  argv 
) [virtual]

Interface with TCL interpreter.

From your TCL scripts or shell you can invoke commands on this OLSR routing agent thanks to this function. Currently you can call "start", "print_rtable", "print_linkset", "print_nbset", "print_nb2hopset", "print_mprset", "print_mprselset" and "print_topologyset" commands.

Parameters:
argc Number of arguments.
argv Arguments.
Returns:
TCL_OK or TCL_ERROR.

Reimplemented from Agent.

int OLSR::degree ( OLSR_nb_tuple tuple  )  [protected]

This auxiliary function (defined in RFC 3626) is used for calculating the MPR Set.

Parameters:
tuple the neighbor tuple which has the main address of the node we are going to calculate its degree to.
Returns:
the degree of the node.
double OLSR::emf_to_seconds ( u_int8_t  olsr_format  )  [static]

Converts a number of seconds in the mantissa/exponent format to a decimal number.

Parameters:
olsr_format number of seconds in mantissa/exponent format.
Returns:
the decimal number of seconds.
void OLSR::enque_msg ( OLSR_msg msg,
double  delay 
) [protected]

Enques an OLSR message which will be sent with a delay of (0, delay].

This buffering system is used in order to piggyback several OLSR messages in a same OLSR packet.

Parameters:
msg the OLSR message which must be sent.
delay maximum delay the OLSR message is going to be buffered.
void OLSR::forward_data ( Packet p  )  [protected]

Forwards a data packet to the appropiate next hop indicated by the routing table.

Parameters:
p the packet which must be forwarded.
void OLSR::forward_default ( Packet p,
OLSR_msg msg,
OLSR_dup_tuple dup_tuple,
nsaddr_t  local_iface 
) [protected]

OLSR's default forwarding algorithm.

See RFC 3626 for details.

Parameters:
p the OLSR packet which has been received.
msg the OLSR message which must be forwarded.
dup_tuple NULL if the message has never been considered for forwarding, or a duplicate tuple in other case.
local_iface the address of the interface where the message was received from.
nsaddr_t OLSR::get_main_addr ( nsaddr_t  iface_addr  )  [protected]

Gets the main address associated with a given interface address.

Parameters:
iface_addr the interface address.
Returns:
the corresponding main address.
void OLSR::link_sensing ( OLSR_msg msg,
nsaddr_t  receiver_iface,
nsaddr_t  sender_iface 
) [protected]

Updates Link Set according to a new received HELLO message (following RFC 3626 specification). Neighbor Set is also updated if needed.

Parameters:
msg the OLSR message which contains the HELLO message.
receiver_iface the address of the interface where the message was received from.
sender_iface the address of the interface where the message was sent from.
void OLSR::mac_failed ( Packet p  ) 

Drops a given packet because it couldn't be delivered to the corresponding destination by the MAC layer. This may cause a neighbor loss, and appropiate actions are then taken.

Parameters:
p the packet which couldn't be delivered by the MAC layer.
void OLSR::nb_loss ( OLSR_link_tuple tuple  )  [protected]

Performs all actions needed when a neighbor loss occurs.

Neighbor Set, 2-hop Neighbor Set, MPR Set and MPR Selector Set are updated.

Parameters:
tuple link tuple with the information of the link to the neighbor which has been lost.
int OLSR::node_id ( nsaddr_t  addr  )  [static]

Returns the identifier of a node given the address of the attached OLSR agent.

Parameters:
addr the address of the OLSR routing agent.
Returns:
the identifier of the node.
void OLSR::populate_mprselset ( OLSR_msg msg  )  [protected]

Updates the MPR Selector Set according to the information contained in a new received HELLO message (following RFC 3626).

Parameters:
msg the OLSR message which contains the HELLO message.
void OLSR::populate_nb2hopset ( OLSR_msg msg  )  [protected]

Updates the 2-hop Neighbor Set according to the information contained in a new received HELLO message (following RFC 3626).

Parameters:
msg the OLSR message which contains the HELLO message.
void OLSR::populate_nbset ( OLSR_msg msg  )  [protected]

Updates the Neighbor Set according to the information contained in a new received HELLO message (following RFC 3626).

Parameters:
msg the OLSR message which contains the HELLO message.
void OLSR::process_hello ( OLSR_msg msg,
nsaddr_t  receiver_iface,
nsaddr_t  sender_iface 
) [protected]

Processes a HELLO message following RFC 3626 specification.

Link sensing and population of the Neighbor Set, 2-hop Neighbor Set and MPR Selector Set are performed.

Parameters:
msg the OLSR message which contains the HELLO message.
receiver_iface the address of the interface where the message was received from.
sender_iface the address of the interface where the message was sent from.
void OLSR::process_mid ( OLSR_msg msg,
nsaddr_t  sender_iface 
) [protected]

Processes a MID message following RFC 3626 specification.

The Interface Association Set is updated (if needed) with the information of the received MID message.

Parameters:
msg the OLSR message which contains the MID message.
sender_iface the address of the interface where the message was sent from.
void OLSR::process_tc ( OLSR_msg msg,
nsaddr_t  sender_iface 
) [protected]

Processes a TC message following RFC 3626 specification.

The Topology Set is updated (if needed) with the information of the received TC message.

Parameters:
msg the OLSR message which contains the TC message.
sender_iface the address of the interface where the message was sent from.
void OLSR::recv ( Packet p,
Handler h 
) [virtual]

This function is called whenever a packet is received. It identifies the type of the received packet and process it accordingly.

If it is an OLSR packet then it is processed. In other case, if it is a data packet then it is forwarded.

Parameters:
p the received packet.
h a handler (not used).

Reimplemented from Agent.

void OLSR::recv_olsr ( Packet p  )  [protected]

Processes an incoming OLSR packet following RFC 3626 specification.

Parameters:
p received packet.
void OLSR::rm_dup_tuple ( OLSR_dup_tuple tuple  )  [protected]

Removes a duplicate tuple from the Duplicate Set.

Parameters:
tuple the duplicate tuple to be removed.
void OLSR::rm_ifaceassoc_tuple ( OLSR_iface_assoc_tuple tuple  )  [protected]

Removes an interface association tuple from the Interface Association Set.

Parameters:
tuple the interface association tuple to be removed.
void OLSR::rm_link_tuple ( OLSR_link_tuple tuple  )  [protected]

Removes a link tuple from the Link Set.

Parameters:
tuple the link tuple to be removed.
void OLSR::rm_mprsel_tuple ( OLSR_mprsel_tuple tuple  )  [protected]

Removes an MPR selector tuple from the MPR Selector Set.

Advertised Neighbor Sequence Number (ANSN) is also updated.

Parameters:
tuple the MPR selector tuple to be removed.
void OLSR::rm_nb2hop_tuple ( OLSR_nb2hop_tuple tuple  )  [protected]

Removes a 2-hop neighbor tuple from the 2-hop Neighbor Set.

Parameters:
tuple the 2-hop neighbor tuple to be removed.
void OLSR::rm_nb_tuple ( OLSR_nb_tuple tuple  )  [protected]

Removes a neighbor tuple from the Neighbor Set.

Parameters:
tuple the neighbor tuple to be removed.
void OLSR::rm_topology_tuple ( OLSR_topology_tuple tuple  )  [protected]

Removes a topology tuple from the Topology Set.

Parameters:
tuple the topology tuple to be removed.
u_int8_t OLSR::seconds_to_emf ( double  seconds  )  [static]

Converts a decimal number of seconds to the mantissa/exponent format.

Parameters:
seconds decimal number of seconds we want to convert.
Returns:
the number of seconds in mantissa/exponent format.
void OLSR::send_mid (  )  [protected]

Creates a new OLSR MID message which is buffered to be sent later on.

Warning:
This message is never invoked because there is no support for multiple interfaces.
void OLSR::send_pkt (  )  [protected]

Creates as many OLSR packets as needed in order to send all buffered OLSR messages.

Maximum number of messages which can be contained in an OLSR packet is dictated by OLSR_MAX_MSGS constant.

bool OLSR::seq_num_bigger_than ( u_int16_t  s1,
u_int16_t  s2 
) [static, protected]

Determines which sequence number is bigger (as it is defined in RFC 3626).

Parameters:
s1 a sequence number.
s2 a sequence number.
Returns:
true if s1 > s2, false in other case.
void OLSR::updated_link_tuple ( OLSR_link_tuple tuple  )  [protected]

This function is invoked when a link tuple is updated. Its aim is to also update the corresponding neighbor tuple if it is needed.

Parameters:
tuple the link tuple which has been updated.

The documentation for this class was generated from the following files: