|
|
TopologyManager (Olsr& olsr, EventLoop& eventloop,
FaceManager& fm, Neighborhood& nh)
| TopologyManager |
~TopologyManager ()
| ~TopologyManager |
inline RouteManager* route_manager ()
| route_manager |
void set_route_manager (RouteManager* rm)
| set_route_manager |
void update_tc_entry (const IPv4& dest_addr,
const IPv4& origin_addr,
const uint16_t distance,
const uint16_t ansn,
const TimeVal& vtime,
bool& is_created)
throw(BadTopologyEntry) | update_tc_entry |
Update or create a topology entry in the TC database.
Parameters:
dest_addr | the destination of the topology entry. |
origin_addr | the origin of the topology entry. |
distance | the distance in hops from this node to the origin, calculated from the message hop count. |
ansn | the advertised sequence number of the topology entry. |
vtime | the time for which this topology entry remains valid. |
is_created | a boolean which is set to true if a new entry has been created. @throw BadTopologyEntry if the entry could not be created. |
OlsrTypes::TopologyID add_tc_entry (const IPv4& dest_addr,
const IPv4& origin_addr,
const uint16_t distance,
const uint16_t ansn,
const TimeVal& expiry_time)
throw(BadTopologyEntry) | add_tc_entry |
Add a topology entry to the database.
Parameters:
dest_addr | the destination of the new topology entry. |
origin_addr | the origin of the new topology entry. |
distance | the distance in hops from this node to the origin, calculated from the message hop count. |
ansn | the advertised sequence number of the topology entry. |
expiry_time | the time for which this topology entry remains valid. |
bool delete_tc_entry (const OlsrTypes::TopologyID tcid)
| delete_tc_entry |
Delete a topology entry by ID. It must be removed from last-hop and destination maps.
Parameters:
tcid | the ID of the toplogy entry to delete. |
Returns: true if the topology entry was deleted, false if it could not be found.
void clear_tc_entries ()
| clear_tc_entries |
bool apply_tc_ansn (const uint16_t ansn, const IPv4& origin_addr)
| apply_tc_ansn |
Apply the Advertised Neighbor Sequence Number in the given TC message to the Topology Set. Section 9.5: TC Message Processing, 2-3.
Parameters:
ansn | the ANSN to apply. |
origin_addr | the origin of the TC message containing @param ansn |
Returns: true if the provided ANSN is valid and has been applied, otherwise false if the message is stale and should be rejected.
OlsrTypes::TopologyID get_topologyid (const IPv4& dest_addr,
const IPv4& lasthop_addr)
throw(BadTopologyEntry) | get_topologyid |
Return a topology entry ID given its destination and origin.
Note: This is not declared 'const' due to the undeclared mutability of map::operator[].
Parameters:
dest_addr | the destination of the TC entry to look up. |
lasthop_addr | the origin of the TC entry to look up. |
Returns: the topology ID. @throw BadTopologyEntry if the entry could not be found.
const TopologyEntry* get_topology_entry_by_id (
const OlsrTypes::TopologyID tcid)
throw(BadTopologyEntry) | get_topology_entry_by_id |
[const]
Get a pointer to a topology entry given its ID.
Used by the XRL layer.
Parameters:
tcid | the ID of the TC entry to look up. |
Returns: the MID pointer. @throw BadTopologyEntry if the entry could not be found.
void get_topology_list (list<OlsrTypes::TopologyID>& tclist)
| get_topology_list |
[const]
Fill out a list of all topology entry IDs.
Used by the XRL layer.
Parameters:
tclist | the list to fill out. |
vector<IPv4> get_tc_neighbor_set (const IPv4& origin_addr, uint16_t& ansn)
throw(BadTopologyEntry) | get_tc_neighbor_set |
Retrieve the Advertised Neighbor Set (ANS) for a given OLSR peer. Typically used by protocol simulator.
Given the address of a node in the topology, retrieve the addresses from all TC entries originated by that node. Assumes that the "all entries for origin have same ANSN" invariant holds.
TODO: Also return the per-link ETX information.
Parameters:
origin_addr | the originating node to look up in the TC database. |
ansn | the sequence number of origin_addr's neighbor set. @throw BadTopologyEntry if origin_addr was not found. |
uint16_t get_tc_distance (const IPv4& origin_addr, const IPv4& dest_addr)
throw(BadTopologyEntry) | get_tc_distance |
size_t get_tc_lasthop_count_by_dest (const IPv4& dest_addr)
| get_tc_lasthop_count_by_dest |
Count the number of TC entries which point to a given destination. Used by protocol simulator.
Parameters:
dest_addr | the TC destination. |
Returns: The number of TC entries pointing to dest_addr.
size_t tc_node_count ()
| tc_node_count |
[const]
Calculate the number of unique OLSR nodes with TC entries in this node's TC database.
Returns: the number of unique main addresses in the TC lasthop map.
void update_mid_entry (const IPv4& main_addr, const IPv4& iface_addr,
const uint16_t distance, const TimeVal& vtime,
bool& is_mid_created)
throw(BadMidEntry) | update_mid_entry |
Update a Multiple Interface Declaration (MID) entry.
The entry will be created if it does not exist.
Parameters:
main_addr | the main address of the node originating the MID entry. |
iface_addr | the interface address of the MID entry. |
distance | the distance in hops of the origin of the MIS message being processed. |
vtime | the time for which the MID entry remains valid. |
is_mid_created | set to true if a new MID entry was created. @throw BadMidEntry if the entry could not be created or updated. |
void add_mid_entry (const IPv4& main_addr, const IPv4& iface_addr,
const uint16_t distance, const TimeVal& vtime)
throw(BadMidEntry) | add_mid_entry |
Create a new entry in the MID database.
TODO Find the next available ID if already taken, as the range may recycle quickly in large, dynamically changing topologies.
Parameters:
main_addr | the main address of the node originating the MID entry. |
iface_addr | the interface address of the MID entry. |
distance | the distance in hops of the origin of the MIS message being processed. |
vtime | the time for which the MID entry remains valid. @throw BadMidEntry if the entry could not be created or updated. |
bool delete_mid_entry (const OlsrTypes::MidEntryID mid_id)
| delete_mid_entry |
Delete a MID entry by ID.
Parameters:
mid_id | the ID of the MID entry to delete. |
Returns: true if the MID entry was deleted.
void clear_mid_entries ()
| clear_mid_entries |
vector<IPv4> get_mid_addresses (const IPv4& main_addr)
| get_mid_addresses |
Given the main address of an OLSR node, return a vector containing all other interface addresses for it, as learned via the MID part of the OLSR protocol.
Parameters:
main_addr | the main address to look up |
Returns: a vector of protocol addresses, which may be empty.
uint16_t get_mid_address_distance (const IPv4& main_addr,
const IPv4& iface_addr)
throw(BadMidEntry) | get_mid_address_distance |
Look up the most recently seen distance of a MID entry, given its origin and interface address.
Internal method. Stubbed out if DETAILED_DEBUG is not defined.
Parameters:
main_addr | the main address of the OLSR node to look up. |
iface_addr | the interface address of the OLSR node to look up. @throw BadMidEntry if the entry could not be found. |
IPv4 get_main_addr_of_mid (const IPv4& mid_addr)
throw(BadMidEntry) | get_main_addr_of_mid |
Given an address possibly corresponding to a MID entry, return the main address to which it would map.
Used by the protocol simulator. Requires a linear search of MID space, returns first match, there should be no other matches; no invariant.
Parameters:
mid_addr | the interface address to look up. |
Returns: the main address of the node with the given interface address. @throw BadMidEntry if mid_addr was not found.
size_t mid_node_count ()
| mid_node_count |
[const]
Count the number of unique OLSR main addresses in this node's MID database.
Returns: the number of OLSR main addresses in _mid_addr.
const MidEntry* get_mid_entry_by_id (
const OlsrTypes::MidEntryID midid)
throw(BadTopologyEntry) | get_mid_entry_by_id |
[const]
Get a pointer to a MID entry given its ID.
Used by the XRL layer.
Parameters:
midid | the ID of the MID entry to look up. |
Returns: the MID entry pointer. @throw BadTopologyEntry if the entry could not be found.
void get_mid_list (list<OlsrTypes::MidEntryID>& midlist)
| get_mid_list |
[const]
Fill out a list of all MID entry IDs.
Used by the XRL layer.
Parameters:
midlist | the list to fill out. |
void push_topology ()
| push_topology |
Push topology set to the RouteManager for SPT computation. Section 10: Route computation.
In ascending order, we push the rest of the known network topology, starting with the TC entries which would have been originated by two-hop neighbors. If we encounter incomplete TC information for the network topology, that is, there are no known nodes at a particular distance, we stop pushing topology to RouteManager.
TODO: Use ETX measurements for edge choice.
bool event_receive_tc (Message* msg,
const IPv4& remote_addr, const IPv4& local_addr)
| event_receive_tc |
Callback method to: process an incoming TC message. Section 9.5: TC Message Processing.
Parameters:
msg | Pointer to a message which is derived from TcMessage. |
remote_addr | The source address of the packet containing msg. |
local_addr | The address of the interface where this packet was received. |
Returns: true if this function consumed msg.
void event_tc_dead (OlsrTypes::TopologyID tcid)
| event_tc_dead |
Callback method to: delete an expiring TopologyEntry.
Parameters:
tcid | the ID of the expiring TopologyEntry. |
bool event_receive_mid (Message* msg,
const IPv4& remote_addr, const IPv4& local_addr)
| event_receive_mid |
Callback method to: process an incoming MID message. Section 5.4: MID Message Processing.
Parameters:
msg | the message to process. |
remote_addr | the source address of the Packet containing msg |
local_addr | the address of the interface where @param msg was received. |
Returns: true if this method consumed @param msg
void event_mid_dead (const OlsrTypes::MidEntryID mid_id)
| event_mid_dead |
Callback method to: delete a dying MidEntry.
void update_tc_distance (TopologyEntry* tc, uint16_t distance)
| update_tc_distance |
[protected]
Internal method to: update a TC entry's distance.
It is necessary to maintain an insertion sort collation order in the TcDistanceMap as it is used for route calculation.
Parameters:
tc | pointer to the TopologyEntry to update. |
distance | the new distance of the TopologyEntry. |
void assert_tc_distance_is_unique (const OlsrTypes::TopologyID tcid)
throw(BadTopologyEntry) | assert_tc_distance_is_unique |
[protected]
Internal method to: assert that a TC's distance is unique.
Verify that the given TopologyID appears once, and only once, in the _tc_distances array used for route computation. Stubbed out if DETAILED_DEBUG is not defined.
Parameters:
tcid | the topology entry ID to verify. @throw BadTopologyEntry if tcid appears more than once in _tc_distances. |
void assert_tc_ansn_is_identical (const IPv4& origin_addr)
throw(BadTopologyEntry) | assert_tc_ansn_is_identical |
[protected]
Internal method to: assert that the ANSNs for all TC entries originated by the node origin_addr are identical.
A full linear search of the TC record space is performed. Stubbed out if DETAILED_DEBUG is not defined.
TODO: Eliminate this function by refactoring the data structures; we SHOULD be able to check if the last ANSN from origin was empty, currently we don't do that.
Parameters:
origin_addr | the node for which to verify the ANSNs. @throw BadTopologyEntry if the ANSNs for origin_addr are not identical. |