Routing agent which implements OLSR protocol following RFC 3626. More...
#include <OLSR.h>
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 | |
PortClassifier * | dmux_ |
For passing packets up to agents. | |
Trace * | logtarget_ |
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 |
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.
OLSR::OLSR | ( | nsaddr_t | id | ) |
Creates necessary timers, binds TCL-available variables and do some more initializations.
id | Identifier for the OLSR agent. It will be used as the address of this routing agent. |
void OLSR::add_dup_tuple | ( | OLSR_dup_tuple * | tuple | ) | [protected] |
Adds a duplicate tuple to the Duplicate Set.
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.
tuple | the interface association tuple to be added. |
void OLSR::add_link_tuple | ( | OLSR_link_tuple * | tuple, | |
u_int8_t | willingness | |||
) | [protected] |
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.
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.
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.
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.
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.
argc | Number of arguments. | |
argv | Arguments. |
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.
tuple | the neighbor tuple which has the main address of the node we are going to calculate its degree to. |
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.
olsr_format | number of seconds in mantissa/exponent format. |
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.
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.
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.
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.
iface_addr | the interface 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.
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.
p | the packet which couldn't be delivered by the MAC layer. |
void OLSR::nb_loss | ( | OLSR_link_tuple * | tuple | ) | [protected] |
int OLSR::node_id | ( | nsaddr_t | addr | ) | [static] |
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).
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).
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).
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.
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.
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.
msg | the OLSR message which contains the TC message. | |
sender_iface | the address of the interface where the message was sent from. |
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.
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.
p | received packet. |
void OLSR::rm_dup_tuple | ( | OLSR_dup_tuple * | tuple | ) | [protected] |
Removes a duplicate tuple from the Duplicate Set.
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.
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.
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.
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.
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.
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.
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.
seconds | decimal number of seconds we want to convert. |
void OLSR::send_mid | ( | ) | [protected] |
Creates a new OLSR MID message which is buffered to be sent later on.
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).
s1 | a sequence number. | |
s2 | a sequence number. |
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.
tuple | the link tuple which has been updated. |