1.1 --- a/doc/manual/routing.texi Thu Oct 01 14:12:56 2009 -0700
1.2 +++ b/doc/manual/routing.texi Thu Oct 01 21:51:03 2009 -0700
1.3 @@ -280,6 +280,11 @@
1.4 and the OLSR "main interface" can be set with the SetMainInterface()
1.5 command. A number of protocol constants are defined in olsr-agent-impl.cc.
1.6
1.7 +Presently, OLSR is limited to use with an Ipv4ListRouting object, and
1.8 +does not respond to dynamic changes to a device's IP address or link up/down
1.9 +notifications; i.e. the topology changes are due to loss/gain of connectivity
1.10 +over a wireless channel.
1.11 +
1.12 @node Multicast routing
1.13 @section Multicast routing
1.14
2.1 --- a/src/routing/global-routing/ipv4-global-routing.cc Thu Oct 01 14:12:56 2009 -0700
2.2 +++ b/src/routing/global-routing/ipv4-global-routing.cc Thu Oct 01 21:51:03 2009 -0700
2.3 @@ -361,26 +361,76 @@
2.4 }
2.5
2.6 bool
2.7 -Ipv4GlobalRouting::RouteInput (Ptr<const Packet> p, const Ipv4Header &ipHeader, Ptr<const NetDevice> idev, UnicastForwardCallback ucb, MulticastForwardCallback mcb,
2.8 +Ipv4GlobalRouting::RouteInput (Ptr<const Packet> p, const Ipv4Header &header, Ptr<const NetDevice> idev, UnicastForwardCallback ucb, MulticastForwardCallback mcb,
2.9 LocalDeliverCallback lcb, ErrorCallback ecb)
2.10 {
2.11
2.12 - NS_LOG_FUNCTION (this << p << ipHeader << ipHeader.GetSource () << ipHeader.GetDestination () << idev);
2.13 + NS_LOG_FUNCTION (this << p << header << header.GetSource () << header.GetDestination () << idev);
2.14 + // Check if input device supports IP
2.15 + NS_ASSERT (m_ipv4->GetInterfaceForDevice (idev) >= 0);
2.16 + uint32_t iif = m_ipv4->GetInterfaceForDevice (idev);
2.17
2.18 - if (ipHeader.GetDestination ().IsMulticast ())
2.19 + if (header.GetDestination ().IsMulticast ())
2.20 {
2.21 NS_LOG_LOGIC ("Multicast destination-- returning false");
2.22 return false; // Let other routing protocols try to handle this
2.23 }
2.24
2.25 -// This is a unicast packet. Check to see if we have a route for it.
2.26 -//
2.27 - NS_LOG_LOGIC ("Unicast destination- looking up");
2.28 - Ptr<Ipv4Route> rtentry = LookupGlobal (ipHeader.GetDestination ());
2.29 + if (header.GetDestination ().IsBroadcast ())
2.30 + {
2.31 + NS_LOG_LOGIC ("For me (Ipv4Addr broadcast address)");
2.32 + // TODO: Local Deliver for broadcast
2.33 + // TODO: Forward broadcast
2.34 + }
2.35 +
2.36 + // TODO: Configurable option to enable RFC 1222 Strong End System Model
2.37 + // Right now, we will be permissive and allow a source to send us
2.38 + // a packet to one of our other interface addresses; that is, the
2.39 + // destination unicast address does not match one of the iif addresses,
2.40 + // but we check our other interfaces. This could be an option
2.41 + // (to remove the outer loop immediately below and just check iif).
2.42 + for (uint32_t j = 0; j < m_ipv4->GetNInterfaces (); j++)
2.43 + {
2.44 + for (uint32_t i = 0; i < m_ipv4->GetNAddresses (j); i++)
2.45 + {
2.46 + Ipv4InterfaceAddress iaddr = m_ipv4->GetAddress (j, i);
2.47 + Ipv4Address addr = iaddr.GetLocal ();
2.48 + if (addr.IsEqual (header.GetDestination ()))
2.49 + {
2.50 + if (j == iif)
2.51 + {
2.52 + NS_LOG_LOGIC ("For me (destination " << addr << " match)");
2.53 + }
2.54 + else
2.55 + {
2.56 + NS_LOG_LOGIC ("For me (destination " << addr << " match) on another interface " << header.GetDestination ());
2.57 + }
2.58 + lcb (p, header, iif);
2.59 + return true;
2.60 + }
2.61 + if (header.GetDestination ().IsEqual (iaddr.GetBroadcast ()))
2.62 + {
2.63 + NS_LOG_LOGIC ("For me (interface broadcast address)");
2.64 + lcb (p, header, iif);
2.65 + return true;
2.66 + }
2.67 + NS_LOG_LOGIC ("Address "<< addr << " not a match");
2.68 + }
2.69 + }
2.70 + // Check if input device supports IP forwarding
2.71 + if (m_ipv4->IsForwarding (iif) == false)
2.72 + {
2.73 + NS_LOG_LOGIC ("Forwarding disabled for this interface");
2.74 + ecb (p, header, Socket::ERROR_NOROUTETOHOST);
2.75 + return false;
2.76 + }
2.77 + // Next, try to find a route
2.78 + NS_LOG_LOGIC ("Unicast destination- looking up global route");
2.79 + Ptr<Ipv4Route> rtentry = LookupGlobal (header.GetDestination ());
2.80 if (rtentry != 0)
2.81 {
2.82 NS_LOG_LOGIC ("Found unicast destination- calling unicast callback");
2.83 - ucb (rtentry, p, ipHeader);
2.84 + ucb (rtentry, p, header);
2.85 return true;
2.86 }
2.87 else
3.1 --- a/src/routing/static-routing/ipv4-static-routing.cc Thu Oct 01 14:12:56 2009 -0700
3.2 +++ b/src/routing/static-routing/ipv4-static-routing.cc Thu Oct 01 21:51:03 2009 -0700
3.3 @@ -444,8 +444,6 @@
3.4 return rtentry;
3.5 }
3.6
3.7 -// XXX this method not robust enough to work outside of ListRouting context
3.8 -// because it will not perform local delivery
3.9 bool
3.10 Ipv4StaticRouting::RouteInput (Ptr<const Packet> p, const Ipv4Header &ipHeader, Ptr<const NetDevice> idev,
3.11 UnicastForwardCallback ucb, MulticastForwardCallback mcb,
3.12 @@ -453,6 +451,13 @@
3.13 {
3.14 NS_LOG_FUNCTION (this << p << ipHeader << ipHeader.GetSource () << ipHeader.GetDestination () << idev);
3.15
3.16 + NS_ASSERT (m_ipv4 != 0);
3.17 + // Check if input device supports IP
3.18 + NS_ASSERT (m_ipv4->GetInterfaceForDevice (idev) >= 0);
3.19 + uint32_t iif = m_ipv4->GetInterfaceForDevice (idev);
3.20 +
3.21 + // Multicast recognition; handle local delivery here
3.22 + //
3.23 if (ipHeader.GetDestination ().IsMulticast ())
3.24 {
3.25 NS_LOG_LOGIC ("Multicast destination");
3.26 @@ -471,10 +476,56 @@
3.27 return false; // Let other routing protocols try to handle this
3.28 }
3.29 }
3.30 -//
3.31 -// This is a unicast packet. Check to see if we have a route for it.
3.32 -//
3.33 + if (ipHeader.GetDestination ().IsBroadcast ())
3.34 + {
3.35 + NS_LOG_LOGIC ("For me (Ipv4Addr broadcast address)");
3.36 + // TODO: Local Deliver for broadcast
3.37 + // TODO: Forward broadcast
3.38 + }
3.39 +
3.40 NS_LOG_LOGIC ("Unicast destination");
3.41 + // TODO: Configurable option to enable RFC 1222 Strong End System Model
3.42 + // Right now, we will be permissive and allow a source to send us
3.43 + // a packet to one of our other interface addresses; that is, the
3.44 + // destination unicast address does not match one of the iif addresses,
3.45 + // but we check our other interfaces. This could be an option
3.46 + // (to remove the outer loop immediately below and just check iif).
3.47 + for (uint32_t j = 0; j < m_ipv4->GetNInterfaces (); j++)
3.48 + {
3.49 + for (uint32_t i = 0; i < m_ipv4->GetNAddresses (j); i++)
3.50 + {
3.51 + Ipv4InterfaceAddress iaddr = m_ipv4->GetAddress (j, i);
3.52 + Ipv4Address addr = iaddr.GetLocal ();
3.53 + if (addr.IsEqual (ipHeader.GetDestination ()))
3.54 + {
3.55 + if (j == iif)
3.56 + {
3.57 + NS_LOG_LOGIC ("For me (destination " << addr << " match)");
3.58 + }
3.59 + else
3.60 + {
3.61 + NS_LOG_LOGIC ("For me (destination " << addr << " match) on another interface " << ipHeader.GetDestination ());
3.62 + }
3.63 + lcb (p, ipHeader, iif);
3.64 + return true;
3.65 + }
3.66 + if (ipHeader.GetDestination ().IsEqual (iaddr.GetBroadcast ()))
3.67 + {
3.68 + NS_LOG_LOGIC ("For me (interface broadcast address)");
3.69 + lcb (p, ipHeader, iif);
3.70 + return true;
3.71 + }
3.72 + NS_LOG_LOGIC ("Address "<< addr << " not a match");
3.73 + }
3.74 + }
3.75 + // Check if input device supports IP forwarding
3.76 + if (m_ipv4->IsForwarding (iif) == false)
3.77 + {
3.78 + NS_LOG_LOGIC ("Forwarding disabled for this interface");
3.79 + ecb (p, ipHeader, Socket::ERROR_NOROUTETOHOST);
3.80 + return false;
3.81 + }
3.82 + // Next, try to find a route
3.83 Ptr<Ipv4Route> rtentry = LookupStatic (ipHeader.GetDestination ());
3.84 if (rtentry != 0)
3.85 {
4.1 --- a/src/routing/static-routing/ipv4-static-routing.h Thu Oct 01 14:12:56 2009 -0700
4.2 +++ b/src/routing/static-routing/ipv4-static-routing.h Thu Oct 01 21:51:03 2009 -0700
4.3 @@ -55,9 +55,8 @@
4.4 * This class provides a basic set of methods for inserting static
4.5 * unicast and multicast routes into the Ipv4 routing system.
4.6 * This particular protocol is designed to be inserted into an
4.7 - * Ipv4ListRouting protocol and at present cannot be inserted as the
4.8 - * only routing protocol into Ipv4 (i.e. it must be added to an
4.9 - * Ipv4ListRouting).
4.10 + * Ipv4ListRouting protocol but can be used also as a standalone
4.11 + * protocol.
4.12 *
4.13 * The Ipv4StaticRouting class inherits from the abstract base class
4.14 * Ipv4RoutingProtocol that defines the interface methods that a routing
5.1 --- a/src/routing/static-routing/ipv6-static-routing.cc Thu Oct 01 14:12:56 2009 -0700
5.2 +++ b/src/routing/static-routing/ipv6-static-routing.cc Thu Oct 01 21:51:03 2009 -0700
5.3 @@ -514,23 +514,28 @@
5.4 return rtentry;
5.5 }
5.6
5.7 -bool Ipv6StaticRouting::RouteInput (Ptr<const Packet> p, const Ipv6Header &ipHeader, Ptr<const NetDevice> idev,
5.8 +bool Ipv6StaticRouting::RouteInput (Ptr<const Packet> p, const Ipv6Header &header, Ptr<const NetDevice> idev,
5.9 UnicastForwardCallback ucb, MulticastForwardCallback mcb,
5.10 LocalDeliverCallback lcb, ErrorCallback ecb)
5.11 {
5.12 - NS_LOG_FUNCTION (this << p << ipHeader << ipHeader.GetSourceAddress () << ipHeader.GetDestinationAddress () << idev);
5.13 + NS_LOG_FUNCTION (this << p << header << header.GetSourceAddress () << header.GetDestinationAddress () << idev);
5.14 + NS_ASSERT (m_ipv6 != 0);
5.15 + // Check if input device supports IP
5.16 + NS_ASSERT (m_ipv6->GetInterfaceForDevice (idev) >= 0);
5.17 + uint32_t iif = m_ipv6->GetInterfaceForDevice (idev);
5.18 + Ipv6Address dst = header.GetDestinationAddress ();
5.19
5.20 - if (ipHeader.GetDestinationAddress ().IsMulticast ())
5.21 + if (dst.IsMulticast ())
5.22 {
5.23 NS_LOG_LOGIC ("Multicast destination");
5.24 - Ptr<Ipv6MulticastRoute> mrtentry = LookupStatic (ipHeader.GetSourceAddress (),
5.25 - ipHeader.GetDestinationAddress ()
5.26 + Ptr<Ipv6MulticastRoute> mrtentry = LookupStatic (header.GetSourceAddress (),
5.27 + header.GetDestinationAddress ()
5.28 , m_ipv6->GetInterfaceForDevice (idev));
5.29
5.30 if (mrtentry)
5.31 {
5.32 NS_LOG_LOGIC ("Multicast route found");
5.33 - mcb (mrtentry, p, ipHeader); // multicast forwarding callback
5.34 + mcb (mrtentry, p, header); // multicast forwarding callback
5.35 return true;
5.36 }
5.37 else
5.38 @@ -539,16 +544,50 @@
5.39 return false; // Let other routing protocols try to handle this
5.40 }
5.41 }
5.42 - //
5.43 - // This is a unicast packet. Check to see if we have a route for it.
5.44 - //
5.45 +
5.46 + // TODO: Configurable option to enable RFC 1222 Strong End System Model
5.47 + // Right now, we will be permissive and allow a source to send us
5.48 + // a packet to one of our other interface addresses; that is, the
5.49 + // destination unicast address does not match one of the iif addresses,
5.50 + // but we check our other interfaces. This could be an option
5.51 + // (to remove the outer loop immediately below and just check iif).
5.52 + for (uint32_t j = 0; j < m_ipv6->GetNInterfaces (); j++)
5.53 + {
5.54 + for (uint32_t i = 0; i < m_ipv6->GetNAddresses (j); i++)
5.55 + {
5.56 + Ipv6InterfaceAddress iaddr = m_ipv6->GetAddress (j, i);
5.57 + Ipv6Address addr = iaddr.GetAddress ();
5.58 + if (addr.IsEqual (header.GetDestinationAddress ()))
5.59 + {
5.60 + if (j == iif)
5.61 + {
5.62 + NS_LOG_LOGIC ("For me (destination " << addr << " match)");
5.63 + }
5.64 + else
5.65 + {
5.66 + NS_LOG_LOGIC ("For me (destination " << addr << " match) on another interface " << header.GetDestinationAddress ());
5.67 + }
5.68 + lcb (p, header, iif);
5.69 + return true;
5.70 + }
5.71 + NS_LOG_LOGIC ("Address "<< addr << " not a match");
5.72 + }
5.73 + }
5.74 + // Check if input device supports IP forwarding
5.75 + if (m_ipv6->IsForwarding (iif) == false)
5.76 + {
5.77 + NS_LOG_LOGIC ("Forwarding disabled for this interface");
5.78 + ecb (p, header, Socket::ERROR_NOROUTETOHOST);
5.79 + return false;
5.80 + }
5.81 + // Next, try to find a route
5.82 NS_LOG_LOGIC ("Unicast destination");
5.83 - Ptr<Ipv6Route> rtentry = LookupStatic (ipHeader.GetDestinationAddress ());
5.84 + Ptr<Ipv6Route> rtentry = LookupStatic (header.GetDestinationAddress ());
5.85
5.86 if (rtentry != 0)
5.87 {
5.88 NS_LOG_LOGIC ("Found unicast destination- calling unicast callback");
5.89 - ucb (rtentry, p, ipHeader); // unicast forwarding callback
5.90 + ucb (rtentry, p, header); // unicast forwarding callback
5.91 return true;
5.92 }
5.93 else