ns3::olsr::RoutingTable Class Reference

Defines rtable_t as a map of OLSR_rt_entry, whose key is the destination address. More...

#include <olsr-routing-table.h>

Inheritance diagram for ns3::olsr::RoutingTable:
Inheritance graph
[legend]
Collaboration diagram for ns3::olsr::RoutingTable:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 RoutingTable ()
void SetIpv4 (Ptr< Ipv4 > ipv4)
void SetMainAddress (Ipv4Address mainAddress)
 ~RoutingTable ()
void Clear ()
 Clears the routing table and frees the memory assigned to each one of its entries.
uint32_t GetSize () const
std::vector< RoutingTableEntryGetEntries () const
void RemoveEntry (const Ipv4Address &dest)
 Deletes the entry whose destination address is given.
void AddEntry (const Ipv4Address &dest, const Ipv4Address &next, uint32_t interface, uint32_t distance)
 Adds a new entry into the routing table.
void AddEntry (const Ipv4Address &dest, const Ipv4Address &next, const Ipv4Address &interfaceAddress, uint32_t distance)
bool Lookup (const Ipv4Address &dest, RoutingTableEntry &outEntry) const
 Looks up an entry for the specified destination address.
bool FindSendEntry (const RoutingTableEntry &entry, RoutingTableEntry &outEntry) const
 Finds the appropiate entry which must be used in order to forward a data packet to a next hop (given a destination).
virtual bool RequestRoute (uint32_t ifIndex, const Ipv4Header &ipHeader, Ptr< Packet > packet, RouteReplyCallback routeReply)
 Request that a packet be routed.
virtual bool RequestIfIndex (Ipv4Address destination, uint32_t &ifIndex)
 Synchronously check to see if we can determine the interface index that will be used if a packet is sent to this destination.

Private Member Functions

void DoDispose ()

Private Attributes

std::map< Ipv4Address,
RoutingTableEntry
m_table
 Data structure for the routing table.
Ptr< Ipv4m_ipv4
Ipv4Address m_mainAddress

Detailed Description

Defines rtable_t as a map of OLSR_rt_entry, whose key is the destination address.

The routing table is thus defined as pairs: [dest address, entry]. Each element of the pair can be accesed via "first" and "second" members. This class is a representation of the OLSR's Routing Table.

Definition at line 61 of file olsr-routing-table.h.


Constructor & Destructor Documentation

ns3::olsr::RoutingTable::RoutingTable (  )  [inline]

Definition at line 76 of file olsr-routing-table.h.

ns3::olsr::RoutingTable::~RoutingTable (  )  [inline]

Definition at line 81 of file olsr-routing-table.h.


Member Function Documentation

void ns3::olsr::RoutingTable::AddEntry ( const Ipv4Address dest,
const Ipv4Address next,
const Ipv4Address interfaceAddress,
uint32_t  distance 
)

Definition at line 200 of file olsr-routing-table.cc.

References AddEntry(), m_ipv4, m_mainAddress, NS_ASSERT, and NS_LOG_FUNCTION.

void ns3::olsr::RoutingTable::AddEntry ( const Ipv4Address dest,
const Ipv4Address next,
uint32_t  interface,
uint32_t  distance 
)

Adds a new entry into the routing table.

If an entry for the given destination existed, it is deleted and freed.

Parameters:
dest address of the destination node.
next address of the next hop node.
iface address of the local interface.
dist distance to the destination node.

Definition at line 181 of file olsr-routing-table.cc.

References ns3::olsr::RoutingTableEntry::destAddr, ns3::olsr::RoutingTableEntry::distance, ns3::olsr::RoutingTableEntry::interface, m_mainAddress, m_table, ns3::olsr::RoutingTableEntry::nextAddr, NS_ASSERT, and NS_LOG_FUNCTION.

Referenced by AddEntry(), and ns3::olsr::OlsrRoutingTableTest::RunTests().

void ns3::olsr::RoutingTable::Clear ( void   ) 

Clears the routing table and frees the memory assigned to each one of its entries.

Definition at line 41 of file olsr-routing-table.cc.

References m_table, and NS_LOG_FUNCTION_NOARGS.

void ns3::olsr::RoutingTable::DoDispose ( void   )  [inline, private, virtual]

This method is called by Object::Dispose or by the object's destructor, whichever comes first.

Subclasses are expected to implement their real destruction code in an overriden version of this method and chain up to their parent's implementation once they are done. i.e., for simplicity, the destructor of every subclass should be empty and its content should be moved to the associated DoDispose method.

Reimplemented from ns3::Object.

Definition at line 68 of file olsr-routing-table.h.

References m_ipv4.

bool ns3::olsr::RoutingTable::FindSendEntry ( const RoutingTableEntry entry,
RoutingTableEntry outEntry 
) const

Finds the appropiate entry which must be used in order to forward a data packet to a next hop (given a destination).

Imagine a routing table like this: [A,B] [B,C] [C,C]; being each pair of the form [dest addr,next-hop addr]. In this case, if this function is invoked with [A,B] then pair [C,C] is returned because C is the next hop that must be used to forward a data packet destined to A. That is, C is a neighbor of this node, but B isn't. This function finds the appropiate neighbor for forwarding a packet.

Parameters:
entry the routing table entry which indicates the destination node we are interested in.
Returns:
the appropiate routing table entry which indicates the next hop which must be used for forwarding a data packet, or NULL if there is no such entry.

Definition at line 94 of file olsr-routing-table.cc.

References ns3::olsr::RoutingTableEntry::destAddr, Lookup(), and ns3::olsr::RoutingTableEntry::nextAddr.

Referenced by RequestIfIndex(), RequestRoute(), and ns3::olsr::OlsrRoutingTableTest::RunTests().

std::vector< RoutingTableEntry > ns3::olsr::RoutingTable::GetEntries (  )  const

Definition at line 236 of file olsr-routing-table.cc.

References m_table.

uint32_t ns3::olsr::RoutingTable::GetSize ( void   )  const [inline]

Definition at line 84 of file olsr-routing-table.h.

References m_table.

bool ns3::olsr::RoutingTable::Lookup ( const Ipv4Address dest,
RoutingTableEntry outEntry 
) const

Looks up an entry for the specified destination address.

Parameters:
dest destination address.
outEntry output parameter to hold the routing entry result, if fuond
Returns:
true if found, false if not found

Definition at line 64 of file olsr-routing-table.cc.

References m_table.

Referenced by FindSendEntry(), RequestIfIndex(), RequestRoute(), and ns3::olsr::OlsrRoutingTableTest::RunTests().

void ns3::olsr::RoutingTable::RemoveEntry ( const Ipv4Address dest  ) 

Deletes the entry whose destination address is given.

Parameters:
dest address of the destination node.

Definition at line 52 of file olsr-routing-table.cc.

References m_table.

Referenced by ns3::olsr::OlsrRoutingTableTest::RunTests().

bool ns3::olsr::RoutingTable::RequestIfIndex ( Ipv4Address  destination,
uint32_t &  ifIndex 
) [virtual]

Synchronously check to see if we can determine the interface index that will be used if a packet is sent to this destination.

This method addresses a problem in the IP stack where a destination address must be present and checksummed into the IP header before the actual interface over which the packet is sent can be determined. The answer is to implement a known and intentional cross-layer violation. This is the endpoint of a call chain that started up quite high in the stack (sockets) and has found its way down to the Ipv4L3Protocol which is consulting the routing protocols for what they would do if presented with a packet of the given destination.

Note that the a single interface index is returned. This means that if the destination address is a multicast, and an explicit route is present that includeds multiple output interfaces, that route cannot be used.

If there are multiple paths out of the node, the resolution is performed by Ipv4L3Protocol::GetIfIndexforDestination which has access to more contextual information that is useful for making a determination.

Parameters:
destination The Ipv4Address if the destination of a hypothetical packet. This may be a multicast group address.
ifIndex A reference to the interface index over which a packet sent to this destination would be sent.
Returns:
Returns true if a route is found to the destination that involves a single output interface index, otherwise false.
See also:
Ipv4StaticRouting
Ipv4RoutingProtocol
Ipv4L3Protocol

Implements ns3::Ipv4RoutingProtocol.

Definition at line 151 of file olsr-routing-table.cc.

References FindSendEntry(), ns3::olsr::RoutingTableEntry::interface, Lookup(), and NS_FATAL_ERROR.

bool ns3::olsr::RoutingTable::RequestRoute ( uint32_t  ifIndex,
const Ipv4Header ipHeader,
Ptr< Packet packet,
RouteReplyCallback  routeReply 
) [virtual]

Request that a packet be routed.

Parameters:
ifIndex The interface index on which the packet was received.
ipHeader IP header of the packet
packet packet that is being sent or forwarded
routeReply callback that will receive the route reply
Returns:
true if the routing protocol should be able to get the route, false otherwise.

This method is called whenever a node's IPv4 forwarding engine needs to lookup a route for a given packet and IP header.

The routing protocol implementation may determine immediately it should not be handling this particular the route request. For instance, a routing protocol may decline to search for routes for certain classes of addresses, like link-local. In this case, RequestRoute() should return false and the routeReply callback must not be invoked.

If the routing protocol implementation assumes that it can provide the requested route, then it should return true, and the routeReply callback must be invoked, either immediately before returning true (synchronously), or in the future (asynchronous). The routing protocol may use any information available in the IP header and packet as routing key, although most routing protocols use only the destination address (as given by ipHeader.GetDestination ()). The routing protocol is also allowed to add a new header to the packet, which will appear immediately after the IP header, although most routing do not insert any extra header.

Multicast routing is expected to be supported in this method. If a multicast route is encountered, all routes to a given multicast destination will be serviced by cloning the packet and calling the route reply callback once for each outgoing interface in the route.

Implements ns3::Ipv4RoutingProtocol.

Definition at line 108 of file olsr-routing-table.cc.

References ns3::Ipv4Route::CreateHostRouteTo(), FindSendEntry(), ns3::Ipv4Header::GetDestination(), ns3::olsr::RoutingTableEntry::interface, Lookup(), m_mainAddress, m_table, ns3::olsr::RoutingTableEntry::nextAddr, NS_FATAL_ERROR, and NS_LOG_DEBUG.

void ns3::olsr::RoutingTable::SetIpv4 ( Ptr< Ipv4 ipv4  ) 

Definition at line 230 of file olsr-routing-table.cc.

References m_ipv4.

void ns3::olsr::RoutingTable::SetMainAddress ( Ipv4Address  mainAddress  ) 

Definition at line 224 of file olsr-routing-table.cc.

References m_mainAddress.


Member Data Documentation

Definition at line 64 of file olsr-routing-table.h.

Referenced by AddEntry(), DoDispose(), and SetIpv4().

Definition at line 66 of file olsr-routing-table.h.

Referenced by AddEntry(), RequestRoute(), and SetMainAddress().

Data structure for the routing table.

Definition at line 63 of file olsr-routing-table.h.

Referenced by AddEntry(), Clear(), GetEntries(), GetSize(), Lookup(), RemoveEntry(), and RequestRoute().


The documentation for this class was generated from the following files:
Generated on Thu Dec 3 14:12:23 2009 for NS-3 by  doxygen 1.6.3