Defines rtable_t as a map of OLSR_rt_entry, whose key is the destination address. More...
#include <olsr-routing-table.h>
Public Member Functions | |
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. |
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.
void ns3::olsr::RoutingTable::DoDispose | ( | ) | [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.
virtual 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.
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. |
Implements ns3::Ipv4RoutingProtocol.
virtual bool ns3::olsr::RoutingTable::RequestRoute | ( | uint32_t | ifIndex, | |
const Ipv4Header & | ipHeader, | |||
Ptr< Packet > | packet, | |||
RouteReplyCallback | routeReply | |||
) | [virtual] |
Request that a packet be routed.
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 |
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.