Typically, multiple routing protocols are supported in user space and coordinate to write a single forwarding table in the kernel. Presently in ns-3, the implementation allows for multiple routing protocols to build/keep their own routing state, and the IPv4 implementation will query each one of these routing protocols (in some order determined by the simulation author) until a route is found. This may better faciliate the integration of disparate routing approaches that may be difficult to coordinate the writing to a single table, and on-demand routing approaches where packets must be cached.
void
Ipv4L3Protocol::Lookup (Ipv4Header const &ipHeader,
Packet packet,
Ipv4RoutingProtocol::RouteReplyCallback routeReply)
{
for (Ipv4RoutingProtocolList::const_iterator rprotoIter = m_routingProtocols.begin ();
rprotoIter != m_routingProtocols.end (); rprotoIter++)
{
if ((*rprotoIter).second->RequestRoute (ipHeader, packet, routeReply))
return;
}
// No route found
routeReply (false, Ipv4Route (), packet, ipHeader);
}