Base class for IPv4 routing protocols. More...
#include <ipv4.h>
Public Types | |
typedef Callback< void, bool, const Ipv4Route &, Ptr< Packet > , const Ipv4Header & > | RouteReplyCallback |
Callback to be invoked when route discovery is completed. | |
Public Member Functions | |
virtual bool | RequestRoute (uint32_t ifIndex, const Ipv4Header &ipHeader, Ptr< Packet > packet, RouteReplyCallback routeReply)=0 |
Request that a packet be routed. | |
virtual bool | RequestIfIndex (Ipv4Address destination, uint32_t &ifIndex)=0 |
Synchronously check to see if we can determine the interface index that will be used if a packet is sent to this destination. |
Base class for IPv4 routing protocols.
This class represents the interface between the IPv4 routing core and a specific IPv4 routing protocol. The interface is asynchronous (callback based) in order to support reactive routing protocols (e.g. AODV).
typedef Callback<void, bool, const Ipv4Route&, Ptr<Packet>, const Ipv4Header&> ns3::Ipv4RoutingProtocol::RouteReplyCallback |
Callback to be invoked when route discovery is completed.
bool | flag indicating whether a route was actually found; when this is false, the Ipv4Route parameter is ignored | |
Ipv4Route | the route found | |
Packet | the packet for which a route was requested; can be modified by the routing protocol | |
Ipv4Header | the IP header supplied to the route request method (possibly modified in case a new routing header is inserted and consequently the protocol type has to change). |
virtual bool ns3::Ipv4RoutingProtocol::RequestIfIndex | ( | Ipv4Address | destination, | |
uint32_t & | ifIndex | |||
) | [pure 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. |
Implemented in ns3::Ipv4StaticRouting.
virtual bool ns3::Ipv4RoutingProtocol::RequestRoute | ( | uint32_t | ifIndex, | |
const Ipv4Header & | ipHeader, | |||
Ptr< Packet > | packet, | |||
RouteReplyCallback | routeReply | |||
) | [pure 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.
Implemented in ns3::Ipv4StaticRouting.