# HG changeset patch # User Tom Henderson # Date 1336368596 25200 # Node ID 8d84b96e26bf6a3f84eb11c29b4850782cb97736 # Parent 2da1fab73114820ee52df0443287ab8a809c70b8 Update DSR code to ns-3-dev diff -r 2da1fab73114 -r 8d84b96e26bf src/dsr/doc/dsr.rst --- a/src/dsr/doc/dsr.rst Sun May 06 20:52:24 2012 -0700 +++ b/src/dsr/doc/dsr.rst Sun May 06 22:29:56 2012 -0700 @@ -16,7 +16,7 @@ This model implements the base specification of the Dynamic Source Routing (DSR) protocol. Implementation is based on RFC4728. - Class dsr::DsrRouting implements all functionality of service packet exchange and inherits Ipv4L4Protocol. + Class dsr::DsrRouting implements all functionality of service packet exchange and inherits IpL4Protocol. Class dsr::DsrOptions implements functionality of packet processing and talk to DsrRouting to send/receive packets diff -r 2da1fab73114 -r 8d84b96e26bf src/dsr/model/dsr-options.cc --- a/src/dsr/model/dsr-options.cc Sun May 06 20:52:24 2012 -0700 +++ b/src/dsr/model/dsr-options.cc Sun May 06 22:29:56 2012 -0700 @@ -55,7 +55,7 @@ #include "ns3/ipv4-address.h" #include "ns3/ipv4-route.h" #include "ns3/icmpv4-l4-protocol.h" -#include "ns3/ipv4-l4-protocol.h" +#include "ns3/ip-l4-protocol.h" #include "dsr-option-header.h" #include "dsr-options.h" @@ -475,7 +475,6 @@ NS_LOG_FUNCTION (this << packet << dsrP << ipv4Address << source << ipv4Header << (uint32_t)protocol << isPromisc); // Fields from IP header Ipv4Address srcAddress = ipv4Header.GetSource (); - Ipv4Address destAddress = ipv4Header.GetDestination (); /* * \ when the ip source address is equal to the address of our own, this is request packet originated * \ by the node itself, discard it @@ -492,8 +491,6 @@ Ptr node = GetNodeWithAddress (ipv4Address); Ptr dsr = node->GetObject (); - // Set the isError boolean value as false - bool isError = false; Ptr p = packet->Copy (); // The packet here doesn't contain the fixed size dsr header /* * \brief Get the number of routers' address field before removing the header @@ -862,7 +859,6 @@ } else { - isError = true; dsr->DeleteAllRoutesIncludeLink (errorSrc, unreachNode, ipv4Address); DsrOptionRerrUnreachHeader newUnreach; diff -r 2da1fab73114 -r 8d84b96e26bf src/dsr/model/dsr-options.h --- a/src/dsr/model/dsr-options.h Sun May 06 20:52:24 2012 -0700 +++ b/src/dsr/model/dsr-options.h Sun May 06 22:29:56 2012 -0700 @@ -39,7 +39,6 @@ #include "ns3/packet.h" #include "ns3/callback.h" #include "ns3/ptr.h" -#include "ns3/ipv4-l4-protocol.h" #include "ns3/udp-l4-protocol.h" #include "ns3/ipv4.h" #include "ns3/ipv4-route.h" diff -r 2da1fab73114 -r 8d84b96e26bf src/dsr/model/dsr-rcache.cc --- a/src/dsr/model/dsr-rcache.cc Sun May 06 20:52:24 2012 -0700 +++ b/src/dsr/model/dsr-rcache.cc Sun May 06 22:29:56 2012 -0700 @@ -984,7 +984,6 @@ /* * Save the new route cache along with the destination address in map */ - std::pair >::iterator, bool> result = m_sortedRoutes.insert (std::make_pair (dst, rtVector)); } else diff -r 2da1fab73114 -r 8d84b96e26bf src/dsr/model/dsr-routing.cc --- a/src/dsr/model/dsr-routing.cc Sun May 06 20:52:24 2012 -0700 +++ b/src/dsr/model/dsr-routing.cc Sun May 06 22:29:56 2012 -0700 @@ -54,7 +54,6 @@ #include "ns3/ipv4-address.h" #include "ns3/ipv4-header.h" #include "ns3/ipv4-l3-protocol.h" -#include "ns3/ipv4-l4-protocol.h" #include "ns3/ipv4-route.h" #include "ns3/trace-source-accessor.h" #include "ns3/random-variable.h" @@ -103,7 +102,7 @@ TypeId DsrRouting::GetTypeId () { static TypeId tid = TypeId ("ns3::dsr::DsrRouting") - .SetParent () + .SetParent () .AddConstructor () .AddAttribute ("RouteCache", "The route cache for saving routes from route discovery process.", PointerValue (0), @@ -443,7 +442,7 @@ } } } - Ipv4L4Protocol::DoDispose (); + IpL4Protocol::DoDispose (); } void @@ -724,7 +723,6 @@ if (findRoute && (salvage < m_maxSalvageCount)) { // Need to salvage the packet instead of discard it - Ipv4Address source = nodeList.front (); std::vector nodeList = salvageRoute.GetVector (); DsrOptionSRHeader newSR; newSR.SetNodesAddress (nodeList); @@ -1029,9 +1027,8 @@ uint8_t *data = new uint8_t[size]; p->CopyData (data, size); uint8_t optionType = 0; - uint8_t optionLength = 0; + optionType = *(data); - optionType = *(data); Ptr dsrOption; if (optionType == 96) // This is the source route option @@ -1047,7 +1044,7 @@ " and destination IP " << ipv4Header.GetDestination () << " and packet : " << *dsrPacket); bool isPromisc = true; // Set the boolean value isPromisc as true - optionLength = dsrOption->Process (p, dsrPacket, m_mainAddress, source, ipv4Header, nextHeader, isPromisc); + dsrOption->Process (p, dsrPacket, m_mainAddress, source, ipv4Header, nextHeader, isPromisc); return true; } } @@ -2059,9 +2056,6 @@ uint8_t protocol) { NS_LOG_FUNCTION (this << onlyPassive << (uint32_t)protocol); - Ipv4Address nextHop = mb.GetNextHop (); - Ipv4Address source = mb.GetSrc (); - Ipv4Address dst = mb.GetDst (); PassiveKey passiveKey; passiveKey.m_ackId = 0; @@ -2091,8 +2085,6 @@ // The new entry will be used for retransmission NetworkKey networkKey; Ipv4Address nextHop = mb.GetNextHop (); - Ipv4Address source = mb.GetSrc (); - Ipv4Address dst = mb.GetDst (); NS_LOG_DEBUG ("is the first retry or not " << isFirst); if (isFirst) { @@ -2185,7 +2177,6 @@ NS_LOG_FUNCTION (this << onlyPassive << (uint32_t)protocol); Ipv4Address nextHop = mb.GetNextHop (); Ipv4Address source = mb.GetSrc (); - Ipv4Address dst = mb.GetDst (); Ptr packet = mb.GetPacket (); SetRoute (nextHop, m_mainAddress); Ptr p = packet->Copy (); @@ -2459,7 +2450,6 @@ { NS_LOG_INFO ("No route found, initiate route error request"); Ptr packet = Create (); - Ipv4Address unreachAddress = rerr.GetUnreachNode (); Ipv4Address originalDst = rerr.GetOriginalDst (); // Create an empty route ptr Ptr route = 0; @@ -2910,7 +2900,7 @@ } } -enum Ipv4L4Protocol::RxStatus +enum IpL4Protocol::RxStatus DsrRouting::Receive (Ptr p, Ipv4Header const &ip, Ptr incomingInterface) @@ -3037,7 +3027,7 @@ // / Get the next header uint8_t nextHeader = dsrRoutingHeader.GetNextHeader (); Ptr l3proto = m_node->GetObject (); - Ptr nextProto = l3proto->GetProtocol (nextHeader); + Ptr nextProto = l3proto->GetProtocol (nextHeader); if (nextProto != 0) { // we need to make a copy in the unlikely event we hit the @@ -3045,18 +3035,18 @@ // Here we can use the packet that has been get off whole DSR header NS_LOG_DEBUG ("The packet size here " << copy->GetSize()); NS_LOG_DEBUG ("The packet received " << *copy); - enum Ipv4L4Protocol::RxStatus status = + enum IpL4Protocol::RxStatus status = nextProto->Receive (copy, ip, incomingInterface); NS_LOG_DEBUG ("The receive status " << status); switch (status) { - case Ipv4L4Protocol::RX_OK: + case IpL4Protocol::RX_OK: // fall through - case Ipv4L4Protocol::RX_ENDPOINT_CLOSED: + case IpL4Protocol::RX_ENDPOINT_CLOSED: // fall through - case Ipv4L4Protocol::RX_CSUM_FAILED: + case IpL4Protocol::RX_CSUM_FAILED: break; - case Ipv4L4Protocol::RX_ENDPOINT_UNREACH: + case IpL4Protocol::RX_ENDPOINT_UNREACH: if (ip.GetDestination ().IsBroadcast () == true || ip.GetDestination ().IsMulticast () == true) { @@ -3094,7 +3084,17 @@ */ // SendError (rerrUnsupportHeader, 0, protocol); // Send the error packet } - return Ipv4L4Protocol::RX_OK; + return IpL4Protocol::RX_OK; +} + +enum IpL4Protocol::RxStatus +DsrRouting::Receive (Ptr p, + Ipv6Address &src, + Ipv6Address &dst, + Ptr incomingInterface) +{ + NS_LOG_FUNCTION (this << p << src << dst << incomingInterface); + return IpL4Protocol::RX_ENDPOINT_UNREACH; } void @@ -3103,12 +3103,26 @@ m_downTarget = callback; } -Ipv4L4Protocol::DownTargetCallback +void +DsrRouting::SetDownTarget6 (DownTargetCallback6 callback) +{ + NS_FATAL_ERROR ("Unimplemented"); +} + + +IpL4Protocol::DownTargetCallback DsrRouting::GetDownTarget (void) const { return m_downTarget; } +IpL4Protocol::DownTargetCallback6 +DsrRouting::GetDownTarget6 (void) const +{ + NS_FATAL_ERROR ("Unimplemented"); + return MakeNullCallback, Ipv6Address, Ipv6Address, uint8_t, Ptr > (); +} + void DsrRouting::Insert (Ptr option) { m_options.push_back (option); diff -r 2da1fab73114 -r 8d84b96e26bf src/dsr/model/dsr-routing.h --- a/src/dsr/model/dsr-routing.h Sun May 06 20:52:24 2012 -0700 +++ b/src/dsr/model/dsr-routing.h Sun May 06 22:29:56 2012 -0700 @@ -46,7 +46,7 @@ #include "ns3/buffer.h" #include "ns3/packet.h" #include "ns3/ipv4.h" -#include "ns3/ipv4-l4-protocol.h" +#include "ns3/ip-l4-protocol.h" #include "ns3/ipv4-l3-protocol.h" #include "ns3/icmpv4-l4-protocol.h" #include "ns3/ipv4-interface.h" @@ -90,7 +90,7 @@ * \class DsrRouting * \brief Dsr Routing base */ -class DsrRouting : public Ipv4L4Protocol +class DsrRouting : public IpL4Protocol { public: /** @@ -401,12 +401,28 @@ * Called from lower-level layers to send the packet up * in the stack. */ - virtual enum Ipv4L4Protocol::RxStatus Receive (Ptr p, + virtual enum IpL4Protocol::RxStatus Receive (Ptr p, Ipv4Header const &header, Ptr incomingInterface); - void SetDownTarget (Ipv4L4Protocol::DownTargetCallback callback); - Ipv4L4Protocol::DownTargetCallback GetDownTarget (void) const; + /** + * \param p packet to forward up + * \param src source IPv6 address + * \param dst destination IPv6 address + * \param incomingInterface the Ipv6Interface on which the packet arrived + * + * Called from lower-level layers to send the packet up + * in the stack. Not implemented (IPv6). + */ + virtual enum IpL4Protocol::RxStatus Receive (Ptr p, + Ipv6Address &src, + Ipv6Address &dst, + Ptr incomingInterface); + + void SetDownTarget (IpL4Protocol::DownTargetCallback callback); + void SetDownTarget6 (IpL4Protocol::DownTargetCallback6 callback); + IpL4Protocol::DownTargetCallback GetDownTarget (void) const; + IpL4Protocol::DownTargetCallback6 GetDownTarget6 (void) const; /** * \brief Get the extension number. * \return extension number @@ -497,7 +513,7 @@ uint8_t segsLeft; // / The segment left value from SR header - Ipv4L4Protocol::DownTargetCallback m_downTarget; // The callback for down layer + IpL4Protocol::DownTargetCallback m_downTarget; // The callback for down layer uint32_t m_maxNetworkSize; // / Maximum network queue size diff -r 2da1fab73114 -r 8d84b96e26bf src/dsr/model/dsr-rsendbuff.cc --- a/src/dsr/model/dsr-rsendbuff.cc Sun May 06 20:52:24 2012 -0700 +++ b/src/dsr/model/dsr-rsendbuff.cc Sun May 06 22:29:56 2012 -0700 @@ -84,7 +84,6 @@ { NS_LOG_FUNCTION (this << dst); Purge (); - const Ipv4Address addr = dst; /* * Drop the packet with destination address dst */ diff -r 2da1fab73114 -r 8d84b96e26bf src/dsr/wscript --- a/src/dsr/wscript Sun May 06 20:52:24 2012 -0700 +++ b/src/dsr/wscript Sun May 06 22:29:56 2012 -0700 @@ -45,4 +45,4 @@ if (bld.env['ENABLE_EXAMPLES']): bld.add_subdirs('examples') - bld.ns3_python_bindings() + #bld.ns3_python_bindings()