diff --git a/src/aodv/examples/aodv.cc b/src/aodv/examples/aodv.cc index 0f3f30cec..0fcd5ec63 100644 --- a/src/aodv/examples/aodv.cc +++ b/src/aodv/examples/aodv.cc @@ -52,7 +52,7 @@ public: void Run (); /// Report results void Report (std::ostream & os); - + private: ///\name parameters //\{ @@ -67,14 +67,14 @@ private: /// Print routes if true bool printRoutes; //\} - + ///\name network //\{ NodeContainer nodes; NetDeviceContainer devices; Ipv4InterfaceContainer interfaces; //\} - + private: void CreateNodes (); void CreateDevices (); @@ -85,9 +85,9 @@ private: int main (int argc, char **argv) { AodvExample test; - if (! test.Configure(argc, argv)) + if (!test.Configure(argc, argv)) NS_FATAL_ERROR ("Configuration failed. Aborted."); - + test.Run (); test.Report (std::cout); return 0; @@ -108,16 +108,16 @@ AodvExample::Configure (int argc, char **argv) { // Enable AODV logs by default. Comment this if too noisy // LogComponentEnable("AodvRoutingProtocol", LOG_LEVEL_ALL); - + SeedManager::SetSeed(12345); CommandLine cmd; - + cmd.AddValue ("pcap", "Write PCAP traces.", pcap); cmd.AddValue ("printRoutes", "Print routing table dumps.", printRoutes); cmd.AddValue ("size", "Number of nodes.", size); cmd.AddValue ("time", "Simulation time, s.", totalTime); cmd.AddValue ("step", "Grid step, m", step); - + cmd.Parse (argc, argv); return true; } @@ -130,9 +130,9 @@ AodvExample::Run () CreateDevices (); InstallInternetStack (); InstallApplications (); - + std::cout << "Starting simulation for " << totalTime << " s ...\n"; - + Simulator::Stop (Seconds (totalTime)); Simulator::Run (); Simulator::Destroy (); @@ -150,20 +150,20 @@ AodvExample::CreateNodes () nodes.Create (size); // Name nodes for (uint32_t i = 0; i < size; ++i) - { - std::ostringstream os; - os << "node-" << i; - Names::Add (os.str (), nodes.Get (i)); - } + { + std::ostringstream os; + os << "node-" << i; + Names::Add (os.str (), nodes.Get (i)); + } // Create static grid MobilityHelper mobility; mobility.SetPositionAllocator ("ns3::GridPositionAllocator", - "MinX", DoubleValue (0.0), - "MinY", DoubleValue (0.0), - "DeltaX", DoubleValue (step), - "DeltaY", DoubleValue (0), - "GridWidth", UintegerValue (size), - "LayoutType", StringValue ("RowFirst")); + "MinX", DoubleValue (0.0), + "MinY", DoubleValue (0.0), + "DeltaX", DoubleValue (step), + "DeltaY", DoubleValue (0), + "GridWidth", UintegerValue (size), + "LayoutType", StringValue ("RowFirst")); mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); mobility.Install (nodes); } @@ -179,7 +179,7 @@ AodvExample::CreateDevices () WifiHelper wifi = WifiHelper::Default (); wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", "DataMode", StringValue ("OfdmRate6Mbps"), "RtsCtsThreshold", UintegerValue (0)); devices = wifi.Install (wifiPhy, wifiMac, nodes); - + if (pcap) { wifiPhy.EnablePcapAll (std::string ("aodv")); @@ -210,11 +210,11 @@ AodvExample::InstallApplications () { V4PingHelper ping (interfaces.GetAddress (size - 1)); ping.SetAttribute ("Verbose", BooleanValue (true)); - + ApplicationContainer p = ping.Install (nodes.Get (0)); p.Start (Seconds (0)); p.Stop (Seconds (totalTime) - Seconds(0.001)); - + // move node away Ptr node = nodes.Get (size/2); Ptr mob = node->GetObject (); diff --git a/src/aodv/helper/aodv-helper.h b/src/aodv/helper/aodv-helper.h index 3a9e663b0..c5cf9d16d 100644 --- a/src/aodv/helper/aodv-helper.h +++ b/src/aodv/helper/aodv-helper.h @@ -61,7 +61,7 @@ public: * This method controls the attributes of ns3::aodv::RoutingProtocol */ void Set (std::string name, const AttributeValue &value); - + private: ObjectFactory m_agentFactory; }; diff --git a/src/aodv/model/aodv-id-cache.cc b/src/aodv/model/aodv-id-cache.cc index 8924e84b6..fae34e976 100644 --- a/src/aodv/model/aodv-id-cache.cc +++ b/src/aodv/model/aodv-id-cache.cc @@ -37,19 +37,19 @@ IdCache::IsDuplicate (Ipv4Address addr, uint32_t id) { Purge (); for (std::vector::const_iterator i = m_idCache.begin (); - i != m_idCache.end (); ++i) + i != m_idCache.end (); ++i) if (i->m_context == addr && i->m_id == id) return true; struct UniqueId uniqueId = - { addr, id, m_lifetime + Simulator::Now () }; - m_idCache.push_back (uniqueId); + { addr, id, m_lifetime + Simulator::Now () }; + m_idCache.push_back (uniqueId); return false; } void IdCache::Purge () { m_idCache.erase (remove_if (m_idCache.begin (), m_idCache.end (), - IsExpired ()), m_idCache.end ()); + IsExpired ()), m_idCache.end ()); } uint32_t @@ -59,4 +59,5 @@ IdCache::GetSize () return m_idCache.size (); } -}} +} +} diff --git a/src/aodv/model/aodv-id-cache.h b/src/aodv/model/aodv-id-cache.h index 5330af007..0471d7dfe 100644 --- a/src/aodv/model/aodv-id-cache.h +++ b/src/aodv/model/aodv-id-cache.h @@ -46,7 +46,7 @@ class IdCache { public: /// c-tor - IdCache (Time lifetime): m_lifetime (lifetime) {} + IdCache (Time lifetime) : m_lifetime (lifetime) {} /// Check that entry (addr, id) exists in cache. Add entry, if it doesn't exist. bool IsDuplicate (Ipv4Address addr, uint32_t id); /// Remove all expired entries diff --git a/src/aodv/model/aodv-neighbor.cc b/src/aodv/model/aodv-neighbor.cc index 0816bb82b..a9320b907 100644 --- a/src/aodv/model/aodv-neighbor.cc +++ b/src/aodv/model/aodv-neighbor.cc @@ -41,7 +41,7 @@ Neighbors::Neighbors (Time delay) : { m_ntimer.SetDelay(delay); m_ntimer.SetFunction(&Neighbors::Purge, this); - m_txErrorCallback = MakeCallback (& Neighbors::ProcessTxError, this); + m_txErrorCallback = MakeCallback (&Neighbors::ProcessTxError, this); } bool @@ -49,7 +49,7 @@ Neighbors::IsNeighbor (Ipv4Address addr) { Purge (); for (std::vector::const_iterator i = m_nb.begin (); - i != m_nb.end (); ++i) + i != m_nb.end (); ++i) { if (i->m_neighborAddress == addr) return true; @@ -62,7 +62,7 @@ Neighbors::GetExpireTime (Ipv4Address addr) { Purge (); for (std::vector::const_iterator i = m_nb.begin (); i - != m_nb.end (); ++i) + != m_nb.end (); ++i) { if (i->m_neighborAddress == addr) return (i->m_expireTime - Simulator::Now ()); @@ -77,7 +77,7 @@ Neighbors::Update (Ipv4Address addr, Time expire) if (i->m_neighborAddress == addr) { i->m_expireTime - = std::max (expire + Simulator::Now (), i->m_expireTime); + = std::max (expire + Simulator::Now (), i->m_expireTime); if (i->m_hardwareAddress == Mac48Address ()) i->m_hardwareAddress = LookupMacAddress (i->m_neighborAddress); return; @@ -144,7 +144,7 @@ Neighbors::LookupMacAddress (Ipv4Address addr) { Mac48Address hwaddr; for (std::vector >::const_iterator i = m_arp.begin (); - i != m_arp.end (); ++i) + i != m_arp.end (); ++i) { ArpCache::Entry * entry = (*i)->Lookup (addr); if (entry != 0 && entry->IsAlive () && !entry->IsExpired ()) diff --git a/src/aodv/model/aodv-neighbor.h b/src/aodv/model/aodv-neighbor.h index 7709ffc68..28748cc6a 100644 --- a/src/aodv/model/aodv-neighbor.h +++ b/src/aodv/model/aodv-neighbor.h @@ -58,7 +58,7 @@ public: Mac48Address m_hardwareAddress; Time m_expireTime; bool close; - + Neighbor (Ipv4Address ip, Mac48Address mac, Time t) : m_neighborAddress (ip), m_hardwareAddress (mac), m_expireTime (t), close (false) @@ -77,7 +77,7 @@ public: void ScheduleTimer (); /// Remove all entries void Clear () { m_nb.clear (); } - + /// Add ARP cache to be used to allow layer 2 notifications processing void AddArpCache (Ptr); /// Don't use given ARP cache any more (interface is down) @@ -101,7 +101,7 @@ private: std::vector m_nb; /// list of ARP cached to be used for layer 2 notifications processing std::vector > m_arp; - + /// Find MAC address by IP using list of ARP caches Mac48Address LookupMacAddress (Ipv4Address); /// Process layer 2 TX error notification diff --git a/src/aodv/model/aodv-packet.cc b/src/aodv/model/aodv-packet.cc index d67cff599..d752d3b1f 100644 --- a/src/aodv/model/aodv-packet.cc +++ b/src/aodv/model/aodv-packet.cc @@ -45,9 +45,9 @@ TypeId TypeHeader::GetTypeId () { static TypeId tid = TypeId ("ns3::aodv::TypeHeader") - .SetParent
() - .AddConstructor () - ; + .SetParent
() + .AddConstructor () + ; return tid; } @@ -141,8 +141,8 @@ operator<< (std::ostream & os, TypeHeader const & h) //----------------------------------------------------------------------------- RreqHeader::RreqHeader (uint8_t flags, uint8_t reserved, uint8_t hopCount, uint32_t requestID, Ipv4Address dst, uint32_t dstSeqNo, Ipv4Address origin, uint32_t originSeqNo) : - m_flags (flags), m_reserved (reserved), m_hopCount (hopCount), m_requestID (requestID), m_dst(dst), - m_dstSeqNo (dstSeqNo), m_origin(origin), m_originSeqNo (originSeqNo) + m_flags (flags), m_reserved (reserved), m_hopCount (hopCount), m_requestID (requestID), m_dst(dst), + m_dstSeqNo (dstSeqNo), m_origin(origin), m_originSeqNo (originSeqNo) { } @@ -152,9 +152,9 @@ TypeId RreqHeader::GetTypeId () { static TypeId tid = TypeId ("ns3::aodv::RreqHeader") - .SetParent
() - .AddConstructor () - ; + .SetParent
() + .AddConstructor () + ; return tid; } @@ -205,11 +205,11 @@ void RreqHeader::Print (std::ostream &os) const { os << "RREQ ID " << m_requestID << " destination: ipv4 " << m_dst - << " sequence number " << m_dstSeqNo << " source: ipv4 " - << m_origin << " sequence number " << m_originSeqNo - << " flags:" << " Gratuitous RREP " << (*this).GetGratiousRrep () - << " Destination only " << (*this).GetDestinationOnly () - << " Unknown sequence number " << (*this).GetUnknownSeqno (); + << " sequence number " << m_dstSeqNo << " source: ipv4 " + << m_origin << " sequence number " << m_originSeqNo + << " flags:" << " Gratuitous RREP " << (*this).GetGratiousRrep () + << " Destination only " << (*this).GetDestinationOnly () + << " Unknown sequence number " << (*this).GetUnknownSeqno (); } std::ostream & @@ -279,8 +279,8 @@ RreqHeader::operator== (RreqHeader const & o) const RrepHeader::RrepHeader (uint8_t prefixSize, uint8_t hopCount, Ipv4Address dst, uint32_t dstSeqNo, Ipv4Address origin, Time lifeTime) : - m_flags (0), m_prefixSize (prefixSize), m_hopCount (hopCount), - m_dst (dst), m_dstSeqNo (dstSeqNo), m_origin (origin) + m_flags (0), m_prefixSize (prefixSize), m_hopCount (hopCount), + m_dst (dst), m_dstSeqNo (dstSeqNo), m_origin (origin) { m_lifeTime = uint32_t (lifeTime.GetMilliSeconds ()); } @@ -291,9 +291,9 @@ TypeId RrepHeader::GetTypeId () { static TypeId tid = TypeId ("ns3::aodv::RrepHeader") - .SetParent
() - .AddConstructor () - ; + .SetParent
() + .AddConstructor () + ; return tid; } @@ -348,7 +348,7 @@ RrepHeader::Print (std::ostream &os) const os << " prefix size " << m_prefixSize; } os << " source ipv4 " << m_origin << " lifetime " << m_lifeTime - << " acknowledgment required flag " << (*this).GetAckRequired (); + << " acknowledgment required flag " << (*this).GetAckRequired (); } void @@ -432,9 +432,9 @@ TypeId RrepAckHeader::GetTypeId () { static TypeId tid = TypeId ("ns3::aodv::RrepAckHeader") - .SetParent
() - .AddConstructor () - ; + .SetParent
() + .AddConstructor () + ; return tid; } @@ -498,9 +498,9 @@ TypeId RerrHeader::GetTypeId () { static TypeId tid = TypeId ("ns3::aodv::RerrHeader") - .SetParent
() - .AddConstructor () - ; + .SetParent
() + .AddConstructor () + ; return tid; } diff --git a/src/aodv/model/aodv-packet.h b/src/aodv/model/aodv-packet.h index 73ef4fa9c..5cc181a6a 100644 --- a/src/aodv/model/aodv-packet.h +++ b/src/aodv/model/aodv-packet.h @@ -104,9 +104,9 @@ class RreqHeader : public Header public: /// c-tor RreqHeader (uint8_t flags = 0, uint8_t reserved = 0, uint8_t hopCount = 0, - uint32_t requestID = 0, Ipv4Address dst = Ipv4Address (), - uint32_t dstSeqNo = 0, Ipv4Address origin = Ipv4Address (), - uint32_t originSeqNo = 0); + uint32_t requestID = 0, Ipv4Address dst = Ipv4Address (), + uint32_t dstSeqNo = 0, Ipv4Address origin = Ipv4Address (), + uint32_t originSeqNo = 0); ///\name Header serialization/deserialization //\{ @@ -182,8 +182,8 @@ class RrepHeader : public Header public: /// c-tor RrepHeader (uint8_t prefixSize = 0, uint8_t hopCount = 0, Ipv4Address dst = - Ipv4Address (), uint32_t dstSeqNo = 0, Ipv4Address origin = - Ipv4Address (), Time lifetime = MilliSeconds (0)); + Ipv4Address (), uint32_t dstSeqNo = 0, Ipv4Address origin = + Ipv4Address (), Time lifetime = MilliSeconds (0)); ///\name Header serialization/deserialization //\{ static TypeId GetTypeId (); @@ -221,12 +221,12 @@ public: bool operator== (RrepHeader const & o) const; private: - uint8_t m_flags; ///< A - acknowledgment required flag - uint8_t m_prefixSize; ///< Prefix Size - uint8_t m_hopCount; ///< Hop Count + uint8_t m_flags; ///< A - acknowledgment required flag + uint8_t m_prefixSize; ///< Prefix Size + uint8_t m_hopCount; ///< Hop Count Ipv4Address m_dst; ///< Destination IP Address uint32_t m_dstSeqNo; ///< Destination Sequence Number - Ipv4Address m_origin; ///< Source IP Address + Ipv4Address m_origin; ///< Source IP Address uint32_t m_lifeTime; ///< Lifetime (in milliseconds) }; diff --git a/src/aodv/model/aodv-routing-protocol.cc b/src/aodv/model/aodv-routing-protocol.cc index 4a2fcf5ef..87b6500aa 100644 --- a/src/aodv/model/aodv-routing-protocol.cc +++ b/src/aodv/model/aodv-routing-protocol.cc @@ -57,7 +57,7 @@ struct DeferredRouteOutputTag : public Tag { /// Positive if output device is fixed in RouteOutput int32_t oif; - + DeferredRouteOutputTag (int32_t o = -1) : Tag(), oif (o) {} static TypeId GetTypeId () @@ -65,27 +65,27 @@ struct DeferredRouteOutputTag : public Tag static TypeId tid = TypeId ("ns3::aodv::DeferredRouteOutputTag").SetParent (); return tid; } - + TypeId GetInstanceTypeId () const { return GetTypeId (); } - + uint32_t GetSerializedSize () const { return sizeof(int32_t); } - + void Serialize (TagBuffer i) const { i.WriteU32 (oif); } - + void Deserialize (TagBuffer i) { oif = i.ReadU32 (); } - + void Print (std::ostream &os) const { os << "DeferredRouteOutputTag: output interface = " << oif; @@ -137,102 +137,102 @@ TypeId RoutingProtocol::GetTypeId (void) { static TypeId tid = TypeId ("ns3::aodv::RoutingProtocol") - .SetParent () - .AddConstructor () - .AddAttribute ("HelloInterval", "HELLO messages emission interval.", - TimeValue (Seconds (1)), - MakeTimeAccessor (&RoutingProtocol::HelloInterval), - MakeTimeChecker ()) - .AddAttribute ("RreqRetries", "Maximum number of retransmissions of RREQ to discover a route", - UintegerValue (2), - MakeUintegerAccessor (&RoutingProtocol::RreqRetries), - MakeUintegerChecker ()) - .AddAttribute ("RreqRateLimit", "Maximum number of RREQ per second.", - UintegerValue (10), - MakeUintegerAccessor (&RoutingProtocol::RreqRateLimit), - MakeUintegerChecker ()) - .AddAttribute ("RerrRateLimit", "Maximum number of RERR per second.", - UintegerValue (10), - MakeUintegerAccessor (&RoutingProtocol::RerrRateLimit), - MakeUintegerChecker ()) - .AddAttribute ("NodeTraversalTime", "Conservative estimate of the average one hop traversal time for packets and should include " - "queuing delays, interrupt processing times and transfer times.", - TimeValue (MilliSeconds (40)), - MakeTimeAccessor (&RoutingProtocol::NodeTraversalTime), - MakeTimeChecker ()) - .AddAttribute ("NextHopWait", "Period of our waiting for the neighbour's RREP_ACK = 10 ms + NodeTraversalTime", - TimeValue (MilliSeconds (50)), - MakeTimeAccessor (&RoutingProtocol::NextHopWait), - MakeTimeChecker ()) - .AddAttribute ("ActiveRouteTimeout", "Period of time during which the route is considered to be valid", - TimeValue (Seconds (3)), - MakeTimeAccessor (&RoutingProtocol::ActiveRouteTimeout), - MakeTimeChecker ()) - .AddAttribute ("MyRouteTimeout", "Value of lifetime field in RREP generating by this node = 2 * max(ActiveRouteTimeout, PathDiscoveryTime)", - TimeValue (Seconds (11.2)), - MakeTimeAccessor (&RoutingProtocol::MyRouteTimeout), - MakeTimeChecker ()) - .AddAttribute ("BlackListTimeout", "Time for which the node is put into the blacklist = RreqRetries * NetTraversalTime", - TimeValue (Seconds (5.6)), - MakeTimeAccessor (&RoutingProtocol::BlackListTimeout), - MakeTimeChecker ()) - .AddAttribute ("DeletePeriod", "DeletePeriod is intended to provide an upper bound on the time for which an upstream node A " - "can have a neighbor B as an active next hop for destination D, while B has invalidated the route to D." - " = 5 * max (HelloInterval, ActiveRouteTimeout)", - TimeValue (Seconds (15)), - MakeTimeAccessor (&RoutingProtocol::DeletePeriod), - MakeTimeChecker ()) - .AddAttribute ("TimeoutBuffer", "Its purpose is to provide a buffer for the timeout so that if the RREP is delayed" - " due to congestion, a timeout is less likely to occur while the RREP is still en route back to the source.", - UintegerValue (2), - MakeUintegerAccessor (&RoutingProtocol::TimeoutBuffer), - MakeUintegerChecker ()) - .AddAttribute ("NetDiameter", "Net diameter measures the maximum possible number of hops between two nodes in the network", - UintegerValue (35), - MakeUintegerAccessor (&RoutingProtocol::NetDiameter), - MakeUintegerChecker ()) - .AddAttribute ("NetTraversalTime", "Estimate of the average net traversal time = 2 * NodeTraversalTime * NetDiameter", - TimeValue (Seconds (2.8)), - MakeTimeAccessor (&RoutingProtocol::NetTraversalTime), - MakeTimeChecker ()) - .AddAttribute ("PathDiscoveryTime", "Estimate of maximum time needed to find route in network = 2 * NetTraversalTime", - TimeValue (Seconds (5.6)), - MakeTimeAccessor (&RoutingProtocol::PathDiscoveryTime), - MakeTimeChecker ()) - .AddAttribute ("MaxQueueLen", "Maximum number of packets that we allow a routing protocol to buffer.", - UintegerValue (64), - MakeUintegerAccessor (&RoutingProtocol::SetMaxQueueLen, - &RoutingProtocol::GetMaxQueueLen), - MakeUintegerChecker ()) - .AddAttribute ("MaxQueueTime", "Maximum time packets can be queued (in seconds)", - TimeValue (Seconds (30)), - MakeTimeAccessor (&RoutingProtocol::SetMaxQueueTime, - &RoutingProtocol::GetMaxQueueTime), - MakeTimeChecker ()) - .AddAttribute ("AllowedHelloLoss", "Number of hello messages which may be loss for valid link.", - UintegerValue (2), - MakeUintegerAccessor (&RoutingProtocol::AllowedHelloLoss), - MakeUintegerChecker ()) - .AddAttribute ("GratuitousReply", "Indicates whether a gratuitous RREP should be unicast to the node originated route discovery.", - BooleanValue (true), - MakeBooleanAccessor (&RoutingProtocol::SetGratuitousReplyFlag, - &RoutingProtocol::GetGratuitousReplyFlag), - MakeBooleanChecker ()) - .AddAttribute ("DestinationOnly", "Indicates only the destination may respond to this RREQ.", - BooleanValue (false), - MakeBooleanAccessor (&RoutingProtocol::SetDesinationOnlyFlag, - &RoutingProtocol::GetDesinationOnlyFlag), - MakeBooleanChecker ()) - .AddAttribute ("EnableHello", "Indicates whether a hello messages enable.", - BooleanValue (true), - MakeBooleanAccessor (&RoutingProtocol::SetHelloEnable, - &RoutingProtocol::GetHelloEnable), - MakeBooleanChecker ()) - .AddAttribute ("EnableBroadcast", "Indicates whether a broadcast data packets forwarding enable.", - BooleanValue (true), - MakeBooleanAccessor (&RoutingProtocol::SetBroadcastEnable, - &RoutingProtocol::GetBroadcastEnable), - MakeBooleanChecker ()) + .SetParent () + .AddConstructor () + .AddAttribute ("HelloInterval", "HELLO messages emission interval.", + TimeValue (Seconds (1)), + MakeTimeAccessor (&RoutingProtocol::HelloInterval), + MakeTimeChecker ()) + .AddAttribute ("RreqRetries", "Maximum number of retransmissions of RREQ to discover a route", + UintegerValue (2), + MakeUintegerAccessor (&RoutingProtocol::RreqRetries), + MakeUintegerChecker ()) + .AddAttribute ("RreqRateLimit", "Maximum number of RREQ per second.", + UintegerValue (10), + MakeUintegerAccessor (&RoutingProtocol::RreqRateLimit), + MakeUintegerChecker ()) + .AddAttribute ("RerrRateLimit", "Maximum number of RERR per second.", + UintegerValue (10), + MakeUintegerAccessor (&RoutingProtocol::RerrRateLimit), + MakeUintegerChecker ()) + .AddAttribute ("NodeTraversalTime", "Conservative estimate of the average one hop traversal time for packets and should include " + "queuing delays, interrupt processing times and transfer times.", + TimeValue (MilliSeconds (40)), + MakeTimeAccessor (&RoutingProtocol::NodeTraversalTime), + MakeTimeChecker ()) + .AddAttribute ("NextHopWait", "Period of our waiting for the neighbour's RREP_ACK = 10 ms + NodeTraversalTime", + TimeValue (MilliSeconds (50)), + MakeTimeAccessor (&RoutingProtocol::NextHopWait), + MakeTimeChecker ()) + .AddAttribute ("ActiveRouteTimeout", "Period of time during which the route is considered to be valid", + TimeValue (Seconds (3)), + MakeTimeAccessor (&RoutingProtocol::ActiveRouteTimeout), + MakeTimeChecker ()) + .AddAttribute ("MyRouteTimeout", "Value of lifetime field in RREP generating by this node = 2 * max(ActiveRouteTimeout, PathDiscoveryTime)", + TimeValue (Seconds (11.2)), + MakeTimeAccessor (&RoutingProtocol::MyRouteTimeout), + MakeTimeChecker ()) + .AddAttribute ("BlackListTimeout", "Time for which the node is put into the blacklist = RreqRetries * NetTraversalTime", + TimeValue (Seconds (5.6)), + MakeTimeAccessor (&RoutingProtocol::BlackListTimeout), + MakeTimeChecker ()) + .AddAttribute ("DeletePeriod", "DeletePeriod is intended to provide an upper bound on the time for which an upstream node A " + "can have a neighbor B as an active next hop for destination D, while B has invalidated the route to D." + " = 5 * max (HelloInterval, ActiveRouteTimeout)", + TimeValue (Seconds (15)), + MakeTimeAccessor (&RoutingProtocol::DeletePeriod), + MakeTimeChecker ()) + .AddAttribute ("TimeoutBuffer", "Its purpose is to provide a buffer for the timeout so that if the RREP is delayed" + " due to congestion, a timeout is less likely to occur while the RREP is still en route back to the source.", + UintegerValue (2), + MakeUintegerAccessor (&RoutingProtocol::TimeoutBuffer), + MakeUintegerChecker ()) + .AddAttribute ("NetDiameter", "Net diameter measures the maximum possible number of hops between two nodes in the network", + UintegerValue (35), + MakeUintegerAccessor (&RoutingProtocol::NetDiameter), + MakeUintegerChecker ()) + .AddAttribute ("NetTraversalTime", "Estimate of the average net traversal time = 2 * NodeTraversalTime * NetDiameter", + TimeValue (Seconds (2.8)), + MakeTimeAccessor (&RoutingProtocol::NetTraversalTime), + MakeTimeChecker ()) + .AddAttribute ("PathDiscoveryTime", "Estimate of maximum time needed to find route in network = 2 * NetTraversalTime", + TimeValue (Seconds (5.6)), + MakeTimeAccessor (&RoutingProtocol::PathDiscoveryTime), + MakeTimeChecker ()) + .AddAttribute ("MaxQueueLen", "Maximum number of packets that we allow a routing protocol to buffer.", + UintegerValue (64), + MakeUintegerAccessor (&RoutingProtocol::SetMaxQueueLen, + &RoutingProtocol::GetMaxQueueLen), + MakeUintegerChecker ()) + .AddAttribute ("MaxQueueTime", "Maximum time packets can be queued (in seconds)", + TimeValue (Seconds (30)), + MakeTimeAccessor (&RoutingProtocol::SetMaxQueueTime, + &RoutingProtocol::GetMaxQueueTime), + MakeTimeChecker ()) + .AddAttribute ("AllowedHelloLoss", "Number of hello messages which may be loss for valid link.", + UintegerValue (2), + MakeUintegerAccessor (&RoutingProtocol::AllowedHelloLoss), + MakeUintegerChecker ()) + .AddAttribute ("GratuitousReply", "Indicates whether a gratuitous RREP should be unicast to the node originated route discovery.", + BooleanValue (true), + MakeBooleanAccessor (&RoutingProtocol::SetGratuitousReplyFlag, + &RoutingProtocol::GetGratuitousReplyFlag), + MakeBooleanChecker ()) + .AddAttribute ("DestinationOnly", "Indicates only the destination may respond to this RREQ.", + BooleanValue (false), + MakeBooleanAccessor (&RoutingProtocol::SetDesinationOnlyFlag, + &RoutingProtocol::GetDesinationOnlyFlag), + MakeBooleanChecker ()) + .AddAttribute ("EnableHello", "Indicates whether a hello messages enable.", + BooleanValue (true), + MakeBooleanAccessor (&RoutingProtocol::SetHelloEnable, + &RoutingProtocol::GetHelloEnable), + MakeBooleanChecker ()) + .AddAttribute ("EnableBroadcast", "Indicates whether a broadcast data packets forwarding enable.", + BooleanValue (true), + MakeBooleanAccessor (&RoutingProtocol::SetBroadcastEnable, + &RoutingProtocol::GetBroadcastEnable), + MakeBooleanChecker ()) ; return tid; } @@ -240,8 +240,8 @@ RoutingProtocol::GetTypeId (void) void RoutingProtocol::SetMaxQueueLen (uint32_t len) { - MaxQueueLen = len; - m_queue.SetMaxQueueLen (len); + MaxQueueLen = len; + m_queue.SetMaxQueueLen (len); } void RoutingProtocol::SetMaxQueueTime (Time t) @@ -258,8 +258,8 @@ void RoutingProtocol::DoDispose () { m_ipv4 = 0; - for (std::map , Ipv4InterfaceAddress>::iterator iter = - m_socketAddresses.begin (); iter != m_socketAddresses.end (); iter++) + for (std::map, Ipv4InterfaceAddress>::iterator iter = + m_socketAddresses.begin (); iter != m_socketAddresses.end (); iter++) { iter->first->Close (); } @@ -283,21 +283,21 @@ RoutingProtocol::Start () m_nb.ScheduleTimer (); } m_rreqRateLimitTimer.SetFunction (&RoutingProtocol::RreqRateLimitTimerExpire, - this); + this); m_rreqRateLimitTimer.Schedule (Seconds (1)); m_rerrRateLimitTimer.SetFunction (&RoutingProtocol::RerrRateLimitTimerExpire, - this); + this); m_rerrRateLimitTimer.Schedule (Seconds (1)); } Ptr RoutingProtocol::RouteOutput (Ptr p, const Ipv4Header &header, - Ptr oif, Socket::SocketErrno &sockerr) + Ptr oif, Socket::SocketErrno &sockerr) { - NS_LOG_FUNCTION (this << header << (oif? oif->GetIfIndex () : 0)); - if (! p) + NS_LOG_FUNCTION (this << header << (oif ? oif->GetIfIndex () : 0)); + if (!p) { return LoopbackRoute (header, oif); // later } @@ -333,7 +333,7 @@ RoutingProtocol::RouteOutput (Ptr p, const Ipv4Header &header, // routed to loopback, received from loopback and passed to RouteInput (see below) uint32_t iif = (oif ? m_ipv4->GetInterfaceForDevice (oif) : -1); DeferredRouteOutputTag tag (iif); - if (! p->PeekPacketTag (tag)) + if (!p->PeekPacketTag (tag)) { p->AddPacketTag (tag); } @@ -342,7 +342,7 @@ RoutingProtocol::RouteOutput (Ptr p, const Ipv4Header &header, void RoutingProtocol::DeferredRouteOutput (Ptr p, const Ipv4Header & header, - UnicastForwardCallback ucb, ErrorCallback ecb) + UnicastForwardCallback ucb, ErrorCallback ecb) { NS_LOG_FUNCTION (this << p << header); NS_ASSERT (p != 0 && p != Ptr ()); @@ -364,8 +364,8 @@ RoutingProtocol::DeferredRouteOutput (Ptr p, const Ipv4Header & he bool RoutingProtocol::RouteInput (Ptr p, const Ipv4Header &header, - Ptr idev, UnicastForwardCallback ucb, - MulticastForwardCallback mcb, LocalDeliverCallback lcb, ErrorCallback ecb) + Ptr idev, UnicastForwardCallback ucb, + MulticastForwardCallback mcb, LocalDeliverCallback lcb, ErrorCallback ecb) { NS_LOG_FUNCTION (this << p->GetUid() << header.GetDestination() << idev->GetAddress()); if (m_socketAddresses.empty ()) @@ -381,7 +381,7 @@ RoutingProtocol::RouteInput (Ptr p, const Ipv4Header &header, Ipv4Address dst = header.GetDestination (); Ipv4Address origin = header.GetSource (); - + // Deferred route request if (idev == m_lo) { @@ -392,7 +392,7 @@ RoutingProtocol::RouteInput (Ptr p, const Ipv4Header &header, return true; } } - + // Duplicate of own packet if (IsMyOwnAddress (origin)) return true; @@ -404,8 +404,8 @@ RoutingProtocol::RouteInput (Ptr p, const Ipv4Header &header, } // Broadcast local delivery/forwarding - for (std::map , Ipv4InterfaceAddress>::const_iterator j = - m_socketAddresses.begin (); j != m_socketAddresses.end (); ++j) + for (std::map, Ipv4InterfaceAddress>::const_iterator j = + m_socketAddresses.begin (); j != m_socketAddresses.end (); ++j) { Ipv4InterfaceAddress iface = j->second; if (m_ipv4->GetInterfaceForAddress (iface.GetLocal ()) == iif) @@ -454,7 +454,7 @@ RoutingProtocol::RouteInput (Ptr p, const Ipv4Header &header, return true; } } - + // Unicast local delivery if (m_ipv4->IsDestinationAddress (dst, iif)) { @@ -484,7 +484,7 @@ RoutingProtocol::RouteInput (Ptr p, const Ipv4Header &header, bool RoutingProtocol::Forwarding (Ptr p, const Ipv4Header & header, - UnicastForwardCallback ucb, ErrorCallback ecb) + UnicastForwardCallback ucb, ErrorCallback ecb) { NS_LOG_FUNCTION (this); Ipv4Address dst = header.GetDestination (); @@ -543,7 +543,7 @@ RoutingProtocol::SetIpv4 (Ptr ipv4) { NS_ASSERT (ipv4 != 0); NS_ASSERT (m_ipv4 == 0); - + if (EnableHello) { m_htimer.SetFunction (&RoutingProtocol::HelloTimerExpire, this); @@ -551,18 +551,18 @@ RoutingProtocol::SetIpv4 (Ptr ipv4) } m_ipv4 = ipv4; - + // Create lo route. It is asserted that the only one interface up for now is loopback NS_ASSERT (m_ipv4->GetNInterfaces () == 1 && m_ipv4->GetAddress (0, 0).GetLocal () == Ipv4Address ("127.0.0.1")); m_lo = m_ipv4->GetNetDevice (0); NS_ASSERT (m_lo != 0); // Remember lo route - RoutingTableEntry rt (/*device=*/m_lo, /*dst=*/Ipv4Address::GetLoopback (), /*know seqno=*/true, /*seqno=*/0, - /*iface=*/Ipv4InterfaceAddress (Ipv4Address::GetLoopback (), Ipv4Mask ("255.0.0.0")), - /*hops=*/1, /*next hop=*/Ipv4Address::GetLoopback (), - /*lifetime=*/Simulator::GetMaximumSimulationTime ()); + RoutingTableEntry rt (/*device=*/ m_lo, /*dst=*/ Ipv4Address::GetLoopback (), /*know seqno=*/ true, /*seqno=*/ 0, + /*iface=*/ Ipv4InterfaceAddress (Ipv4Address::GetLoopback (), Ipv4Mask ("255.0.0.0")), + /*hops=*/ 1, /*next hop=*/ Ipv4Address::GetLoopback (), + /*lifetime=*/ Simulator::GetMaximumSimulationTime ()); m_routingTable.AddRoute (rt); - + Simulator::ScheduleNow (&RoutingProtocol::Start, this); } @@ -581,7 +581,7 @@ RoutingProtocol::NotifyInterfaceUp (uint32_t i) // Create a socket to listen only on this interface Ptr socket = Socket::CreateSocket (GetObject (), - UdpSocketFactory::GetTypeId ()); + UdpSocketFactory::GetTypeId ()); NS_ASSERT (socket != 0); socket->SetRecvCallback (MakeCallback (&RoutingProtocol::RecvAodv, this)); socket->BindToNetDevice (l3->GetNetDevice (i)); @@ -592,10 +592,10 @@ RoutingProtocol::NotifyInterfaceUp (uint32_t i) // Add local broadcast record to the routing table Ptr dev = m_ipv4->GetNetDevice (m_ipv4->GetInterfaceForAddress (iface.GetLocal ())); - RoutingTableEntry rt (/*device=*/dev, /*dst=*/iface.GetBroadcast (), /*know seqno=*/true, /*seqno=*/0, /*iface=*/iface, - /*hops=*/1, /*next hop=*/iface.GetBroadcast (), /*lifetime=*/Simulator::GetMaximumSimulationTime ()); + RoutingTableEntry rt (/*device=*/ dev, /*dst=*/ iface.GetBroadcast (), /*know seqno=*/ true, /*seqno=*/ 0, /*iface=*/ iface, + /*hops=*/ 1, /*next hop=*/ iface.GetBroadcast (), /*lifetime=*/ Simulator::GetMaximumSimulationTime ()); m_routingTable.AddRoute (rt); - + // Allow neighbor manager use this interface for layer 2 feedback if possible Ptr wifi = dev->GetObject (); if (wifi == 0) @@ -603,7 +603,7 @@ RoutingProtocol::NotifyInterfaceUp (uint32_t i) Ptr mac = wifi->GetMac (); if (mac == 0) return; - + mac->TraceConnectWithoutContext ("TxErrHeader", m_nb.GetTxErrorCallback ()); m_nb.AddArpCache (l3->GetInterface (i)->GetArpCache ()); } @@ -623,11 +623,11 @@ RoutingProtocol::NotifyInterfaceDown (uint32_t i) if (mac != 0) { mac->TraceDisconnectWithoutContext ("TxErrHeader", - m_nb.GetTxErrorCallback ()); + m_nb.GetTxErrorCallback ()); m_nb.DelArpCache (l3->GetInterface (i)->GetArpCache ()); } } - + // Close socket Ptr socket = FindSocketWithInterfaceAddress (m_ipv4->GetAddress (i, 0)); NS_ASSERT (socket); @@ -661,7 +661,7 @@ RoutingProtocol::NotifyAddAddress (uint32_t i, Ipv4InterfaceAddress address) return; // Create a socket to listen only on this interface Ptr socket = Socket::CreateSocket (GetObject (), - UdpSocketFactory::GetTypeId ()); + UdpSocketFactory::GetTypeId ()); NS_ASSERT (socket != 0); socket->SetRecvCallback (MakeCallback (&RoutingProtocol::RecvAodv,this)); socket->BindToNetDevice (l3->GetNetDevice (i)); @@ -673,9 +673,9 @@ RoutingProtocol::NotifyAddAddress (uint32_t i, Ipv4InterfaceAddress address) // Add local broadcast record to the routing table Ptr dev = m_ipv4->GetNetDevice ( m_ipv4->GetInterfaceForAddress (iface.GetLocal ())); - RoutingTableEntry rt (/*device=*/dev, /*dst=*/iface.GetBroadcast (), /*know seqno=*/true, - /*seqno=*/0, /*iface=*/iface, /*hops=*/1, - /*next hop=*/iface.GetBroadcast (), /*lifetime=*/Simulator::GetMaximumSimulationTime ()); + RoutingTableEntry rt (/*device=*/ dev, /*dst=*/ iface.GetBroadcast (), /*know seqno=*/ true, + /*seqno=*/ 0, /*iface=*/ iface, /*hops=*/ 1, + /*next hop=*/ iface.GetBroadcast (), /*lifetime=*/ Simulator::GetMaximumSimulationTime ()); m_routingTable.AddRoute (rt); } } @@ -700,7 +700,7 @@ RoutingProtocol::NotifyRemoveAddress (uint32_t i, Ipv4InterfaceAddress address) Ipv4InterfaceAddress iface = l3->GetAddress (i, 0); // Create a socket to listen only on this interface Ptr socket = Socket::CreateSocket (GetObject (), - UdpSocketFactory::GetTypeId ()); + UdpSocketFactory::GetTypeId ()); NS_ASSERT (socket != 0); socket->SetRecvCallback (MakeCallback (&RoutingProtocol::RecvAodv, this)); // Bind to any IP address so that broadcasts can be received @@ -710,8 +710,8 @@ RoutingProtocol::NotifyRemoveAddress (uint32_t i, Ipv4InterfaceAddress address) // Add local broadcast record to the routing table Ptr dev = m_ipv4->GetNetDevice (m_ipv4->GetInterfaceForAddress (iface.GetLocal ())); - RoutingTableEntry rt (/*device=*/dev, /*dst=*/iface.GetBroadcast (), /*know seqno=*/true, /*seqno=*/0, /*iface=*/iface, - /*hops=*/1, /*next hop=*/iface.GetBroadcast (), /*lifetime=*/Simulator::GetMaximumSimulationTime ()); + RoutingTableEntry rt (/*device=*/ dev, /*dst=*/ iface.GetBroadcast (), /*know seqno=*/ true, /*seqno=*/ 0, /*iface=*/ iface, + /*hops=*/ 1, /*next hop=*/ iface.GetBroadcast (), /*lifetime=*/ Simulator::GetMaximumSimulationTime ()); m_routingTable.AddRoute (rt); } if (m_socketAddresses.empty ()) @@ -733,8 +733,8 @@ bool RoutingProtocol::IsMyOwnAddress (Ipv4Address src) { NS_LOG_FUNCTION (this << src); - for (std::map , Ipv4InterfaceAddress>::const_iterator j = - m_socketAddresses.begin (); j != m_socketAddresses.end (); ++j) + for (std::map, Ipv4InterfaceAddress>::const_iterator j = + m_socketAddresses.begin (); j != m_socketAddresses.end (); ++j) { Ipv4InterfaceAddress iface = j->second; if (src == iface.GetLocal ()) @@ -768,7 +768,7 @@ RoutingProtocol::LoopbackRoute (const Ipv4Header & hdr, Ptr oif) cons // If RouteOutput() caller specified an outgoing interface, that // further constrains the selection of source address // - std::map , Ipv4InterfaceAddress>::const_iterator j = m_socketAddresses.begin (); + std::map, Ipv4InterfaceAddress>::const_iterator j = m_socketAddresses.begin (); if (oif) { // Iterate to find an address on the oif device @@ -801,7 +801,7 @@ RoutingProtocol::SendRequest (Ipv4Address dst) if (m_rreqCount == RreqRateLimit) { Simulator::Schedule (m_rreqRateLimitTimer.GetDelayLeft () + MicroSeconds (100), - &RoutingProtocol::SendRequest, this, dst); + &RoutingProtocol::SendRequest, this, dst); return; } else @@ -825,9 +825,9 @@ RoutingProtocol::SendRequest (Ipv4Address dst) { rreqHeader.SetUnknownSeqno (true); Ptr dev = 0; - RoutingTableEntry newEntry (/*device=*/dev, /*dst=*/dst, /*validSeqNo=*/false, /*seqno=*/0, - /*iface=*/Ipv4InterfaceAddress(),/*hop=*/0, - /*nextHop=*/Ipv4Address(), /*lifeTime=*/Seconds(0)); + RoutingTableEntry newEntry (/*device=*/ dev, /*dst=*/ dst, /*validSeqNo=*/ false, /*seqno=*/ 0, + /*iface=*/ Ipv4InterfaceAddress(),/*hop=*/ 0, + /*nextHop=*/ Ipv4Address(), /*lifeTime=*/ Seconds(0)); newEntry.SetFlag (IN_SEARCH); m_routingTable.AddRoute (newEntry); } @@ -844,8 +844,8 @@ RoutingProtocol::SendRequest (Ipv4Address dst) rreqHeader.SetHopCount (0); // Send RREQ as subnet directed broadcast from each interface used by aodv - for (std::map , Ipv4InterfaceAddress>::const_iterator j = - m_socketAddresses.begin (); j != m_socketAddresses.end (); ++j) + for (std::map, Ipv4InterfaceAddress>::const_iterator j = + m_socketAddresses.begin (); j != m_socketAddresses.end (); ++j) { Ptr socket = j->first; Ipv4InterfaceAddress iface = j->second; @@ -967,9 +967,9 @@ RoutingProtocol::UpdateRouteToNeighbor (Ipv4Address sender, Ipv4Address receiver if (!m_routingTable.LookupRoute (sender, toNeighbor)) { Ptr dev = m_ipv4->GetNetDevice (m_ipv4->GetInterfaceForAddress (receiver)); - RoutingTableEntry newEntry (/*device=*/dev, /*dst=*/sender, /*know seqno=*/false, /*seqno=*/0, - /*iface=*/m_ipv4->GetAddress (m_ipv4->GetInterfaceForAddress (receiver), 0), - /*hops=*/1, /*next hop=*/sender, /*lifetime=*/ActiveRouteTimeout); + RoutingTableEntry newEntry (/*device=*/ dev, /*dst=*/ sender, /*know seqno=*/ false, /*seqno=*/ 0, + /*iface=*/ m_ipv4->GetAddress (m_ipv4->GetInterfaceForAddress (receiver), 0), + /*hops=*/ 1, /*next hop=*/ sender, /*lifetime=*/ ActiveRouteTimeout); m_routingTable.AddRoute (newEntry); } else @@ -981,9 +981,9 @@ RoutingProtocol::UpdateRouteToNeighbor (Ipv4Address sender, Ipv4Address receiver } else { - RoutingTableEntry newEntry (/*device=*/dev, /*dst=*/sender, /*know seqno=*/false, /*seqno=*/0, - /*iface=*/m_ipv4->GetAddress (m_ipv4->GetInterfaceForAddress (receiver), 0), - /*hops=*/1, /*next hop=*/sender, /*lifetime=*/std::max (ActiveRouteTimeout, toNeighbor.GetLifeTime ())); + RoutingTableEntry newEntry (/*device=*/ dev, /*dst=*/ sender, /*know seqno=*/ false, /*seqno=*/ 0, + /*iface=*/ m_ipv4->GetAddress (m_ipv4->GetInterfaceForAddress (receiver), 0), + /*hops=*/ 1, /*next hop=*/ sender, /*lifetime=*/ std::max (ActiveRouteTimeout, toNeighbor.GetLifeTime ())); m_routingTable.Update (newEntry); } } @@ -1035,9 +1035,9 @@ RoutingProtocol::RecvRequest (Ptr p, Ipv4Address receiver, Ipv4Address s if (!m_routingTable.LookupRoute (origin, toOrigin)) { Ptr dev = m_ipv4->GetNetDevice (m_ipv4->GetInterfaceForAddress (receiver)); - RoutingTableEntry newEntry (/*device=*/dev, /*dst=*/origin, /*validSeno=*/true, /*seqNo=*/rreqHeader.GetOriginSeqno (), - /*iface=*/m_ipv4->GetAddress (m_ipv4->GetInterfaceForAddress (receiver), 0), /*hops=*/hop, - /*nextHop*/src, /*timeLife=*/Time ((2 * NetTraversalTime - 2 * hop * NodeTraversalTime))); + RoutingTableEntry newEntry (/*device=*/ dev, /*dst=*/ origin, /*validSeno=*/ true, /*seqNo=*/ rreqHeader.GetOriginSeqno (), + /*iface=*/ m_ipv4->GetAddress (m_ipv4->GetInterfaceForAddress (receiver), 0), /*hops=*/ hop, + /*nextHop*/ src, /*timeLife=*/ Time ((2 * NetTraversalTime - 2 * hop * NodeTraversalTime))); m_routingTable.AddRoute (newEntry); } else @@ -1104,8 +1104,8 @@ RoutingProtocol::RecvRequest (Ptr p, Ipv4Address receiver, Ipv4Address s } } - for (std::map , Ipv4InterfaceAddress>::const_iterator j = - m_socketAddresses.begin (); j != m_socketAddresses.end (); ++j) + for (std::map, Ipv4InterfaceAddress>::const_iterator j = + m_socketAddresses.begin (); j != m_socketAddresses.end (); ++j) { Ptr socket = j->first; Ipv4InterfaceAddress iface = j->second; @@ -1143,8 +1143,8 @@ RoutingProtocol::SendReply (RreqHeader const & rreqHeader, RoutingTableEntry con */ if (!rreqHeader.GetUnknownSeqno () && (rreqHeader.GetDstSeqno () == m_seqNo + 1)) m_seqNo++; - RrepHeader rrepHeader ( /*prefixSize=*/0, /*hops=*/0, /*dst=*/rreqHeader.GetDst (), - /*dstSeqNo=*/m_seqNo, /*origin=*/toOrigin.GetDestination (), /*lifeTime=*/MyRouteTimeout); + RrepHeader rrepHeader ( /*prefixSize=*/ 0, /*hops=*/ 0, /*dst=*/ rreqHeader.GetDst (), + /*dstSeqNo=*/ m_seqNo, /*origin=*/ toOrigin.GetDestination (), /*lifeTime=*/ MyRouteTimeout); Ptr packet = Create (); packet->AddHeader (rrepHeader); TypeHeader tHeader (AODVTYPE_RREP); @@ -1158,8 +1158,8 @@ void RoutingProtocol::SendReplyByIntermediateNode (RoutingTableEntry & toDst, RoutingTableEntry & toOrigin, bool gratRep) { NS_LOG_FUNCTION (this); - RrepHeader rrepHeader (/*prefix size=*/0, /*hops=*/toDst.GetHop (), /*dst=*/toDst.GetDestination (), /*dst seqno=*/toDst.GetSeqNo (), - /*origin=*/toOrigin.GetDestination (), /*lifetime=*/toDst.GetLifeTime ()); + RrepHeader rrepHeader (/*prefix size=*/ 0, /*hops=*/ toDst.GetHop (), /*dst=*/ toDst.GetDestination (), /*dst seqno=*/ toDst.GetSeqNo (), + /*origin=*/ toOrigin.GetDestination (), /*lifetime=*/ toDst.GetLifeTime ()); /* If the node we received a RREQ for is a neighbor we are * probably facing a unidirectional link... Better request a RREP-ack */ @@ -1188,9 +1188,9 @@ RoutingProtocol::SendReplyByIntermediateNode (RoutingTableEntry & toDst, Routing // Generating gratuitous RREPs if (gratRep) { - RrepHeader gratRepHeader (/*prefix size=*/0, /*hops=*/toOrigin.GetHop (), /*dst=*/toOrigin.GetDestination (), - /*dst seqno=*/toOrigin.GetSeqNo (), /*origin=*/toDst.GetDestination (), - /*lifetime=*/toOrigin.GetLifeTime ()); + RrepHeader gratRepHeader (/*prefix size=*/ 0, /*hops=*/ toOrigin.GetHop (), /*dst=*/ toOrigin.GetDestination (), + /*dst seqno=*/ toOrigin.GetSeqNo (), /*origin=*/ toDst.GetDestination (), + /*lifetime=*/ toOrigin.GetLifeTime ()); Ptr packetToDst = Create (); packetToDst->AddHeader (gratRepHeader); TypeHeader type (AODVTYPE_RREP); @@ -1248,9 +1248,9 @@ RoutingProtocol::RecvReply (Ptr p, Ipv4Address receiver, Ipv4Address sen * - and the destination sequence number is the Destination Sequence Number in the RREP message. */ Ptr dev = m_ipv4->GetNetDevice (m_ipv4->GetInterfaceForAddress (receiver)); - RoutingTableEntry newEntry (/*device=*/dev, /*dst=*/dst, /*validSeqNo=*/true, /*seqno=*/rrepHeader.GetDstSeqno (), - /*iface=*/m_ipv4->GetAddress (m_ipv4->GetInterfaceForAddress (receiver), 0),/*hop=*/hop, - /*nextHop=*/sender, /*lifeTime=*/rrepHeader.GetLifeTime ()); + RoutingTableEntry newEntry (/*device=*/ dev, /*dst=*/ dst, /*validSeqNo=*/ true, /*seqno=*/ rrepHeader.GetDstSeqno (), + /*iface=*/ m_ipv4->GetAddress (m_ipv4->GetInterfaceForAddress (receiver), 0),/*hop=*/ hop, + /*nextHop=*/ sender, /*lifeTime=*/ rrepHeader.GetLifeTime ()); RoutingTableEntry toDst; if (m_routingTable.LookupRoute (dst, toDst)) { @@ -1308,7 +1308,7 @@ RoutingProtocol::RecvReply (Ptr p, Ipv4Address receiver, Ipv4Address sen } RoutingTableEntry toOrigin; - if (! m_routingTable.LookupRoute (rrepHeader.GetOrigin (), toOrigin) || toOrigin.GetFlag () == IN_SEARCH) + if (!m_routingTable.LookupRoute (rrepHeader.GetOrigin (), toOrigin) || toOrigin.GetFlag () == IN_SEARCH) { return; // Impossible! drop. } @@ -1334,7 +1334,7 @@ RoutingProtocol::RecvReply (Ptr p, Ipv4Address receiver, Ipv4Address sen toNextHopToOrigin.InsertPrecursor (toDst.GetNextHop ()); m_routingTable.Update (toNextHopToOrigin); } - + Ptr packet = Create (); packet->AddHeader (rrepHeader); TypeHeader tHeader (AODVTYPE_RREP); @@ -1370,9 +1370,9 @@ RoutingProtocol::ProcessHello (RrepHeader const & rrepHeader, Ipv4Address receiv if (!m_routingTable.LookupRoute (rrepHeader.GetDst (), toNeighbor)) { Ptr dev = m_ipv4->GetNetDevice (m_ipv4->GetInterfaceForAddress (receiver)); - RoutingTableEntry newEntry (/*device=*/dev, /*dst=*/rrepHeader.GetDst (), /*validSeqNo=*/true, /*seqno=*/rrepHeader.GetDstSeqno (), - /*iface=*/m_ipv4->GetAddress (m_ipv4->GetInterfaceForAddress (receiver), 0), - /*hop=*/1, /*nextHop=*/rrepHeader.GetDst (), /*lifeTime=*/rrepHeader.GetLifeTime ()); + RoutingTableEntry newEntry (/*device=*/ dev, /*dst=*/ rrepHeader.GetDst (), /*validSeqNo=*/ true, /*seqno=*/ rrepHeader.GetDstSeqno (), + /*iface=*/ m_ipv4->GetAddress (m_ipv4->GetInterfaceForAddress (receiver), 0), + /*hop=*/ 1, /*nextHop=*/ rrepHeader.GetDst (), /*lifeTime=*/ rrepHeader.GetLifeTime ()); m_routingTable.AddRoute (newEntry); } else @@ -1408,7 +1408,7 @@ RoutingProtocol::RecvError (Ptr p, Ipv4Address src ) else { for (std::map::const_iterator i = - dstWithNextHopSrc.begin (); i != dstWithNextHopSrc.end (); ++i) + dstWithNextHopSrc.begin (); i != dstWithNextHopSrc.end (); ++i) { if (i->first == un.first) { @@ -1420,7 +1420,7 @@ RoutingProtocol::RecvError (Ptr p, Ipv4Address src ) std::vector precursors; for (std::map::const_iterator i = unreachable.begin (); - i != unreachable.end ();) + i != unreachable.end ();) { if (!rerrHeader.AddUnDestination (i->first, i->second)) { @@ -1533,12 +1533,12 @@ RoutingProtocol::SendHello () * Hop Count 0 * Lifetime AllowedHelloLoss * HelloInterval */ - for (std::map , Ipv4InterfaceAddress>::const_iterator j = m_socketAddresses.begin (); j != m_socketAddresses.end (); ++j) + for (std::map, Ipv4InterfaceAddress>::const_iterator j = m_socketAddresses.begin (); j != m_socketAddresses.end (); ++j) { Ptr socket = j->first; Ipv4InterfaceAddress iface = j->second; - RrepHeader helloHeader (/*prefix size=*/0, /*hops=*/0, /*dst=*/iface.GetLocal (), /*dst seqno=*/m_seqNo, - /*origin=*/iface.GetLocal (),/*lifetime=*/Time (AllowedHelloLoss * HelloInterval)); + RrepHeader helloHeader (/*prefix size=*/ 0, /*hops=*/ 0, /*dst=*/ iface.GetLocal (), /*dst seqno=*/ m_seqNo, + /*origin=*/ iface.GetLocal (),/*lifetime=*/ Time (AllowedHelloLoss * HelloInterval)); Ptr packet = Create (); packet->AddHeader (helloHeader); TypeHeader tHeader (AODVTYPE_RREP); @@ -1596,7 +1596,7 @@ RoutingProtocol::SendRerrWhenBreaksLinkToNextHop (Ipv4Address nextHop) rerrHeader.AddUnDestination (nextHop, toNextHop.GetSeqNo ()); m_routingTable.GetListOfDestinationWithNextHop (nextHop, unreachable); for (std::map::const_iterator i = unreachable.begin (); i - != unreachable.end ();) + != unreachable.end ();) { if (!rerrHeader.AddUnDestination (i->first, i->second)) { @@ -1630,7 +1630,7 @@ RoutingProtocol::SendRerrWhenBreaksLinkToNextHop (Ipv4Address nextHop) void RoutingProtocol::SendRerrWhenNoRouteToForward (Ipv4Address dst, - uint32_t dstSeqNo, Ipv4Address origin) + uint32_t dstSeqNo, Ipv4Address origin) { NS_LOG_FUNCTION (this); // A node SHOULD NOT originate more than RERR_RATELIMIT RERR messages per second. @@ -1640,8 +1640,8 @@ RoutingProtocol::SendRerrWhenNoRouteToForward (Ipv4Address dst, NS_ASSERT (m_rerrRateLimitTimer.IsRunning ()); // discard the packet and return NS_LOG_LOGIC ("RerrRateLimit reached at " << Simulator::Now ().GetSeconds () << " with timer delay left " - << m_rerrRateLimitTimer.GetDelayLeft ().GetSeconds () - << "; suppressing RERR"); + << m_rerrRateLimitTimer.GetDelayLeft ().GetSeconds () + << "; suppressing RERR"); return; } RerrHeader rerrHeader; @@ -1657,11 +1657,11 @@ RoutingProtocol::SendRerrWhenNoRouteToForward (Ipv4Address dst, NS_ASSERT (socket); NS_LOG_LOGIC ("Unicast RERR to the source of the data transmission"); socket->SendTo (packet, 0, InetSocketAddress (toOrigin.GetNextHop (), AODV_PORT)); - } + } else { - for (std::map , Ipv4InterfaceAddress>::const_iterator i = - m_socketAddresses.begin (); i != m_socketAddresses.end (); ++i) + for (std::map, Ipv4InterfaceAddress>::const_iterator i = + m_socketAddresses.begin (); i != m_socketAddresses.end (); ++i) { Ptr socket = i->first; Ipv4InterfaceAddress iface = i->second; @@ -1699,8 +1699,8 @@ RoutingProtocol::SendRerrMessage (Ptr packet, std::vector p NS_ASSERT (m_rerrRateLimitTimer.IsRunning ()); // discard the packet and return NS_LOG_LOGIC ("RerrRateLimit reached at " << Simulator::Now ().GetSeconds () << " with timer delay left " - << m_rerrRateLimitTimer.GetDelayLeft ().GetSeconds () - << "; suppressing RERR"); + << m_rerrRateLimitTimer.GetDelayLeft ().GetSeconds () + << "; suppressing RERR"); return; } // If there is only one precursor, RERR SHOULD be unicast toward that precursor @@ -1726,7 +1726,7 @@ RoutingProtocol::SendRerrMessage (Ptr packet, std::vector p if (m_routingTable.LookupValidRoute (*i, toPrecursor) && std::find (ifaces.begin (), ifaces.end (), toPrecursor.GetInterface ()) == ifaces.end ()) { - ifaces.push_back (toPrecursor.GetInterface ()); + ifaces.push_back (toPrecursor.GetInterface ()); } } @@ -1754,8 +1754,8 @@ Ptr RoutingProtocol::FindSocketWithInterfaceAddress (Ipv4InterfaceAddress addr ) const { NS_LOG_FUNCTION (this << addr); - for (std::map , Ipv4InterfaceAddress>::const_iterator j = - m_socketAddresses.begin (); j != m_socketAddresses.end (); ++j) + for (std::map, Ipv4InterfaceAddress>::const_iterator j = + m_socketAddresses.begin (); j != m_socketAddresses.end (); ++j) { Ptr socket = j->first; Ipv4InterfaceAddress iface = j->second; diff --git a/src/aodv/model/aodv-routing-protocol.h b/src/aodv/model/aodv-routing-protocol.h index 25a17af41..f9ba43a08 100644 --- a/src/aodv/model/aodv-routing-protocol.h +++ b/src/aodv/model/aodv-routing-protocol.h @@ -64,8 +64,8 @@ public: //\{ Ptr RouteOutput (Ptr p, const Ipv4Header &header, Ptr oif, Socket::SocketErrno &sockerr); bool RouteInput (Ptr p, const Ipv4Header &header, Ptr idev, - UnicastForwardCallback ucb, MulticastForwardCallback mcb, - LocalDeliverCallback lcb, ErrorCallback ecb); + UnicastForwardCallback ucb, MulticastForwardCallback mcb, + LocalDeliverCallback lcb, ErrorCallback ecb); virtual void NotifyInterfaceUp (uint32_t interface); virtual void NotifyInterfaceDown (uint32_t interface); virtual void NotifyAddAddress (uint32_t interface, Ipv4InterfaceAddress address); @@ -73,7 +73,7 @@ public: virtual void SetIpv4 (Ptr ipv4); virtual void PrintRoutingTable (Ptr stream) const; //\} - + ///\name Handle protocol parameters //\{ Time GetMaxQueueTime () const { return MaxQueueTime; } @@ -137,7 +137,7 @@ private: std::map< Ptr, Ipv4InterfaceAddress > m_socketAddresses; /// Loopback device used to defer RREQ until packet will be fully formed Ptr m_lo; - + /// Routing table RoutingTable m_routingTable; /// A "drop-front" queue used by the routing layer to buffer packets to which it does not have a route. @@ -190,7 +190,7 @@ private: void ProcessHello (RrepHeader const & rrepHeader, Ipv4Address receiverIfaceAddr); /// Create loopback route for given header Ptr LoopbackRoute (const Ipv4Header & header, Ptr oif) const; - + ///\name Receive control packets //\{ /// Receive and process control packet @@ -198,13 +198,13 @@ private: /// Receive RREQ void RecvRequest (Ptr p, Ipv4Address receiver, Ipv4Address src); /// Receive RREP - void RecvReply (Ptr p, Ipv4Address my ,Ipv4Address src); + void RecvReply (Ptr p, Ipv4Address my,Ipv4Address src); /// Receive RREP_ACK void RecvReplyAck (Ipv4Address neighbor); /// Receive RERR from node with address src void RecvError (Ptr p, Ipv4Address src); //\} - + ///\name Send //\{ /// Forward packet from route request queue @@ -235,7 +235,7 @@ private: */ void SendRerrWhenNoRouteToForward (Ipv4Address dst, uint32_t dstSeqNo, Ipv4Address origin); //\} - + /// Hello timer Timer m_htimer; /// Schedule next send of hello message diff --git a/src/aodv/model/aodv-rqueue.cc b/src/aodv/model/aodv-rqueue.cc index bc3c742b3..dd8b1ae25 100644 --- a/src/aodv/model/aodv-rqueue.cc +++ b/src/aodv/model/aodv-rqueue.cc @@ -50,7 +50,7 @@ RequestQueue::Enqueue (QueueEntry & entry) { Purge (); for (std::vector::const_iterator i = m_queue.begin (); i - != m_queue.end (); ++i) + != m_queue.end (); ++i) { if ((i->GetPacket ()->GetUid () == entry.GetPacket ()->GetUid ()) && (i->GetIpv4Header ().GetDestination () @@ -73,7 +73,7 @@ RequestQueue::DropPacketWithDst (Ipv4Address dst) NS_LOG_FUNCTION (this << dst); Purge (); for (std::vector::iterator i = m_queue.begin (); i - != m_queue.end (); ++i) + != m_queue.end (); ++i) { if (IsEqual (*i, dst)) { @@ -81,7 +81,7 @@ RequestQueue::DropPacketWithDst (Ipv4Address dst) } } m_queue.erase (std::remove_if (m_queue.begin (), m_queue.end (), - std::bind2nd (std::ptr_fun (RequestQueue::IsEqual), dst)), m_queue.end ()); + std::bind2nd (std::ptr_fun (RequestQueue::IsEqual), dst)), m_queue.end ()); } bool @@ -104,7 +104,7 @@ bool RequestQueue::Find (Ipv4Address dst) { for (std::vector::const_iterator i = m_queue.begin (); i - != m_queue.end (); ++i) + != m_queue.end (); ++i) { if (i->GetIpv4Header ().GetDestination () == dst) return true; @@ -126,7 +126,7 @@ RequestQueue::Purge () { IsExpired pred; for (std::vector::iterator i = m_queue.begin (); i - != m_queue.end (); ++i) + != m_queue.end (); ++i) { if (pred (*i)) { @@ -134,7 +134,7 @@ RequestQueue::Purge () } } m_queue.erase (std::remove_if (m_queue.begin (), m_queue.end (), pred), - m_queue.end ()); + m_queue.end ()); } void @@ -142,7 +142,7 @@ RequestQueue::Drop (QueueEntry en, std::string reason) { NS_LOG_LOGIC (reason << en.GetPacket ()->GetUid () << " " << en.GetIpv4Header ().GetDestination ()); en.GetErrorCallback () (en.GetPacket (), en.GetIpv4Header (), - Socket::ERROR_NOROUTETOHOST); + Socket::ERROR_NOROUTETOHOST); return; } diff --git a/src/aodv/model/aodv-rqueue.h b/src/aodv/model/aodv-rqueue.h index 645168268..a7e165a04 100644 --- a/src/aodv/model/aodv-rqueue.h +++ b/src/aodv/model/aodv-rqueue.h @@ -49,8 +49,8 @@ public: QueueEntry (Ptr pa = 0, Ipv4Header const & h = Ipv4Header (), UnicastForwardCallback ucb = UnicastForwardCallback (), ErrorCallback ecb = ErrorCallback (), Time exp = Simulator::Now ()) : - m_packet (pa), m_header (h), m_ucb (ucb), m_ecb (ecb), - m_expire (exp + Simulator::Now ()) + m_packet (pa), m_header (h), m_ucb (ucb), m_ecb (ecb), + m_expire (exp + Simulator::Now ()) {} /** @@ -132,6 +132,7 @@ private: }; -}} +} +} #endif /* AODV_RQUEUE_H */ diff --git a/src/aodv/model/aodv-rtable.cc b/src/aodv/model/aodv-rtable.cc index f4a96d677..a10e0ca5b 100644 --- a/src/aodv/model/aodv-rtable.cc +++ b/src/aodv/model/aodv-rtable.cc @@ -45,10 +45,10 @@ namespace aodv RoutingTableEntry::RoutingTableEntry (Ptr dev, Ipv4Address dst, bool vSeqNo, uint32_t seqNo, Ipv4InterfaceAddress iface, uint16_t hops, Ipv4Address nextHop, Time lifetime) : - m_ackTimer (Timer::CANCEL_ON_DESTROY), - m_validSeqNo (vSeqNo), m_seqNo (seqNo), m_hops (hops), - m_lifeTime (lifetime + Simulator::Now ()), m_iface (iface), m_flag (VALID), - m_reqCount (0), m_blackListState (false), m_blackListTimeout (Simulator::Now ()) + m_ackTimer (Timer::CANCEL_ON_DESTROY), + m_validSeqNo (vSeqNo), m_seqNo (seqNo), m_hops (hops), + m_lifeTime (lifetime + Simulator::Now ()), m_iface (iface), m_flag (VALID), + m_reqCount (0), m_blackListState (false), m_blackListTimeout (Simulator::Now ()) { m_ipv4Route = Create (); m_ipv4Route->SetDestination (dst); @@ -79,7 +79,7 @@ RoutingTableEntry::LookupPrecursor (Ipv4Address id) { NS_LOG_FUNCTION (this << id); for (std::vector::const_iterator i = m_precursorList.begin (); i - != m_precursorList.end (); ++i) + != m_precursorList.end (); ++i) { if (*i == id) { @@ -96,7 +96,7 @@ RoutingTableEntry::DeletePrecursor (Ipv4Address id) { NS_LOG_FUNCTION (this << id); std::vector::iterator i = std::remove (m_precursorList.begin (), - m_precursorList.end (), id); + m_precursorList.end (), id); if (i == m_precursorList.end ()) { NS_LOG_LOGIC ("Precursor " << id << " not found"); @@ -130,11 +130,11 @@ RoutingTableEntry::GetPrecursors (std::vector & prec) const if (IsPrecursorListEmpty ()) return; for (std::vector::const_iterator i = m_precursorList.begin (); i - != m_precursorList.end (); ++i) + != m_precursorList.end (); ++i) { bool result = true; for (std::vector::const_iterator j = prec.begin (); j - != prec.end (); ++j) + != prec.end (); ++j) { if (*j == *i) result = false; @@ -181,8 +181,8 @@ RoutingTableEntry::Print (Ptr stream) const } *os << "\t"; *os << std::setiosflags (std::ios::fixed) << - std::setiosflags (std::ios::left) << std::setprecision (2) << - std::setw (14) << (m_lifeTime - Simulator::Now ()).GetSeconds (); + std::setiosflags (std::ios::left) << std::setprecision (2) << + std::setw (14) << (m_lifeTime - Simulator::Now ()).GetSeconds (); *os << "\t" << m_hops << "\n"; } @@ -206,12 +206,12 @@ RoutingTable::LookupRoute (Ipv4Address id, RoutingTableEntry & rt) return false; } std::map::const_iterator i = - m_ipv4AddressEntry.find (id); + m_ipv4AddressEntry.find (id); if (i == m_ipv4AddressEntry.end ()) - { - NS_LOG_LOGIC ("Route to " << id << " not found"); - return false; - } + { + NS_LOG_LOGIC ("Route to " << id << " not found"); + return false; + } rt = i->second; NS_LOG_LOGIC ("Route to " << id << " found"); return true; @@ -221,7 +221,7 @@ bool RoutingTable::LookupValidRoute (Ipv4Address id, RoutingTableEntry & rt) { NS_LOG_FUNCTION (this << id); - if (! LookupRoute (id, rt)) + if (!LookupRoute (id, rt)) { NS_LOG_LOGIC ("Route to " << id << " not found"); return false; @@ -252,7 +252,7 @@ RoutingTable::AddRoute (RoutingTableEntry & rt) if (rt.GetFlag () != IN_SEARCH) rt.SetRreqCnt (0); std::pair::iterator, bool> result = - m_ipv4AddressEntry.insert (std::make_pair (rt.GetDestination (), rt)); + m_ipv4AddressEntry.insert (std::make_pair (rt.GetDestination (), rt)); return result.second; } @@ -261,7 +261,7 @@ RoutingTable::Update (RoutingTableEntry & rt) { NS_LOG_FUNCTION (this); std::map::iterator i = - m_ipv4AddressEntry.find (rt.GetDestination ()); + m_ipv4AddressEntry.find (rt.GetDestination ()); if (i == m_ipv4AddressEntry.end ()) { NS_LOG_LOGIC ("Route update to " << rt.GetDestination () << " fails; not found"); @@ -281,7 +281,7 @@ RoutingTable::SetEntryState (Ipv4Address id, RouteFlags state) { NS_LOG_FUNCTION (this); std::map::iterator i = - m_ipv4AddressEntry.find (id); + m_ipv4AddressEntry.find (id); if (i == m_ipv4AddressEntry.end ()) { NS_LOG_LOGIC ("Route set entry state to " << id << " fails; not found"); @@ -300,7 +300,7 @@ RoutingTable::GetListOfDestinationWithNextHop (Ipv4Address nextHop, std::map::const_iterator i = - m_ipv4AddressEntry.begin (); i != m_ipv4AddressEntry.end (); ++i) + m_ipv4AddressEntry.begin (); i != m_ipv4AddressEntry.end (); ++i) { if (i->second.GetNextHop () == nextHop) { @@ -316,10 +316,10 @@ RoutingTable::InvalidateRoutesWithDst (const std::map & u NS_LOG_FUNCTION (this); Purge (); for (std::map::iterator i = - m_ipv4AddressEntry.begin (); i != m_ipv4AddressEntry.end (); ++i) + m_ipv4AddressEntry.begin (); i != m_ipv4AddressEntry.end (); ++i) { for (std::map::const_iterator j = - unreachable.begin (); j != unreachable.end (); ++j) + unreachable.begin (); j != unreachable.end (); ++j) { if ((i->first == j->first) && (i->second.GetFlag () == VALID)) { @@ -337,7 +337,7 @@ RoutingTable::DeleteAllRoutesFromInterface (Ipv4InterfaceAddress iface) if (m_ipv4AddressEntry.empty ()) return; for (std::map::iterator i = - m_ipv4AddressEntry.begin (); i != m_ipv4AddressEntry.end ();) + m_ipv4AddressEntry.begin (); i != m_ipv4AddressEntry.end ();) { if (i->second.GetInterface () == iface) { @@ -357,7 +357,7 @@ RoutingTable::Purge () if (m_ipv4AddressEntry.empty ()) return; for (std::map::iterator i = - m_ipv4AddressEntry.begin (); i != m_ipv4AddressEntry.end ();) + m_ipv4AddressEntry.begin (); i != m_ipv4AddressEntry.end ();) { if (i->second.GetLifeTime () < Seconds (0)) { @@ -390,7 +390,7 @@ RoutingTable::Purge (std::map &table) const if (table.empty ()) return; for (std::map::iterator i = - table.begin (); i != table.end ();) + table.begin (); i != table.end ();) { if (i->second.GetLifeTime () < Seconds (0)) { @@ -421,7 +421,7 @@ RoutingTable::MarkLinkAsUnidirectional (Ipv4Address neighbor, Time blacklistTime { NS_LOG_FUNCTION (this << neighbor << blacklistTimeout.GetSeconds ()); std::map::iterator i = - m_ipv4AddressEntry.find (neighbor); + m_ipv4AddressEntry.find (neighbor); if (i == m_ipv4AddressEntry.end ()) { NS_LOG_LOGIC ("Mark link unidirectional to " << neighbor << " fails; not found"); @@ -440,9 +440,9 @@ RoutingTable::Print (Ptr stream) const std::map table = m_ipv4AddressEntry; Purge (table); *stream->GetStream () << "\nAODV Routing table\n" - << "Destination\tGateway\t\tInterface\tFlag\tExpire\t\tHops\n"; + << "Destination\tGateway\t\tInterface\tFlag\tExpire\t\tHops\n"; for (std::map::const_iterator i = - table.begin (); i != table.end (); ++i) + table.begin (); i != table.end (); ++i) { i->second.Print (stream); } diff --git a/src/aodv/model/aodv-rtable.h b/src/aodv/model/aodv-rtable.h index c2899d681..89b0251a3 100644 --- a/src/aodv/model/aodv-rtable.h +++ b/src/aodv/model/aodv-rtable.h @@ -61,11 +61,11 @@ class RoutingTableEntry public: /// c-to RoutingTableEntry (Ptr dev = 0,Ipv4Address dst = Ipv4Address(), bool vSeqNo = false, uint32_t m_seqNo = 0, - Ipv4InterfaceAddress iface = Ipv4InterfaceAddress(), uint16_t hops = 0, - Ipv4Address nextHop = Ipv4Address(), Time lifetime = Simulator::Now()); + Ipv4InterfaceAddress iface = Ipv4InterfaceAddress(), uint16_t hops = 0, + Ipv4Address nextHop = Ipv4Address(), Time lifetime = Simulator::Now()); ~RoutingTableEntry (); - + ///\name Precursors management //\{ /** @@ -104,7 +104,7 @@ public: ///\name Fields //\{ Ipv4Address GetDestination () const { return m_ipv4Route->GetDestination(); } - Ptr GetRoute () const { return m_ipv4Route; } + Ptr GetRoute () const { return m_ipv4Route; } void SetRoute (Ptr r) { m_ipv4Route = r; } void SetNextHop (Ipv4Address nextHop) { m_ipv4Route->SetGateway(nextHop); } Ipv4Address GetNextHop () const { return m_ipv4Route->GetGateway(); } @@ -117,7 +117,7 @@ public: void SetSeqNo (uint32_t sn) { m_seqNo = sn; } uint32_t GetSeqNo () const { return m_seqNo; } void SetHop (uint16_t hop) { m_hops = hop; } - uint16_t GetHop () const {return m_hops; } + uint16_t GetHop () const { return m_hops; } void SetLifeTime (Time lt) { m_lifeTime = lt + Simulator::Now(); } Time GetLifeTime () const { return m_lifeTime - Simulator::Now(); } void SetFlag (RouteFlags flag) { m_flag = flag; } @@ -253,6 +253,7 @@ private: void Purge (std::map &table) const; }; -}} +} +} #endif /* AODV_RTABLE_H */ diff --git a/src/aodv/test/aodv-id-cache-test-suite.cc b/src/aodv/test/aodv-id-cache-test-suite.cc index 8c2bbd719..b0fd2da15 100644 --- a/src/aodv/test/aodv-id-cache-test-suite.cc +++ b/src/aodv/test/aodv-id-cache-test-suite.cc @@ -99,4 +99,5 @@ public: } } g_idCacheTestSuite; -}} +} +} diff --git a/src/aodv/test/aodv-regression.cc b/src/aodv/test/aodv-regression.cc index f97b84403..ee620dd1c 100644 --- a/src/aodv/test/aodv-regression.cc +++ b/src/aodv/test/aodv-regression.cc @@ -94,10 +94,10 @@ ChainRegressionTest::DoRun () { SeedManager::SetSeed(12345); Config::SetDefault ("ns3::ArpCache::AliveTimeout", TimeValue (m_arpAliveTimeout)); - + CreateNodes (); CreateDevices (); - + // At m_time / 3 move central node away and see what will happen Ptr node = m_nodes->Get (m_size / 2); Ptr mob = node->GetObject (); @@ -106,9 +106,9 @@ ChainRegressionTest::DoRun () Simulator::Stop (m_time); Simulator::Run (); Simulator::Destroy (); - + if (!WRITE_VECTORS) CheckResults (); - + delete m_nodes, m_nodes = 0; } @@ -119,12 +119,12 @@ ChainRegressionTest::CreateNodes () m_nodes->Create (m_size); MobilityHelper mobility; mobility.SetPositionAllocator ("ns3::GridPositionAllocator", - "MinX", DoubleValue (0.0), - "MinY", DoubleValue (0.0), - "DeltaX", DoubleValue (m_step), - "DeltaY", DoubleValue (0), - "GridWidth", UintegerValue (m_size), - "LayoutType", StringValue ("RowFirst")); + "MinX", DoubleValue (0.0), + "MinY", DoubleValue (0.0), + "DeltaX", DoubleValue (m_step), + "DeltaY", DoubleValue (0), + "GridWidth", UintegerValue (m_size), + "LayoutType", StringValue ("RowFirst")); mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); mobility.Install (*m_nodes); } @@ -138,12 +138,12 @@ ChainRegressionTest::CreateDevices () YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default (); YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default (); wifiPhy.SetChannel (wifiChannel.Create ()); - // This test suite output was originally based on YansErrorRateModel + // This test suite output was originally based on YansErrorRateModel wifiPhy.SetErrorRateModel ("ns3::YansErrorRateModel"); WifiHelper wifi = WifiHelper::Default (); wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", "DataMode", StringValue ("OfdmRate6Mbps"), "RtsCtsThreshold", StringValue ("2200")); NetDeviceContainer devices = wifi.Install (wifiPhy, wifiMac, *m_nodes); - + // 2. Setup TCP/IP & AODV AodvHelper aodv; // Use default parameters here InternetStackHelper internetStack; @@ -152,14 +152,14 @@ ChainRegressionTest::CreateDevices () Ipv4AddressHelper address; address.SetBase ("10.1.1.0", "255.255.255.0"); Ipv4InterfaceContainer interfaces = address.Assign (devices); - + // 3. Setup ping V4PingHelper ping (interfaces.GetAddress (m_size - 1)); ping.SetAttribute ("Verbose", BooleanValue (false)); // don't need verbose ping in regression test ApplicationContainer p = ping.Install (m_nodes->Get (0)); p.Start (Seconds (0)); p.Stop (m_time); - + // 4. write PCAP std::string prefix = (WRITE_VECTORS ? NS_TEST_SOURCEDIR : GetTempDir ()) + m_prefix; wifiPhy.EnablePcapAll (prefix); @@ -174,11 +174,11 @@ ChainRegressionTest::CheckResults () // File naming conventions are hard-coded here. os1 << NS_TEST_SOURCEDIR << m_prefix << "-" << i << "-0.pcap"; os2 << GetTempDir () << m_prefix << "-" << i << "-0.pcap"; - + uint32_t sec(0), usec(0); bool diff = PcapFile::Diff (os1.str(), os2.str(), sec, usec); NS_TEST_EXPECT_MSG_EQ (diff, false, "PCAP traces " << os1.str() << " and " << os2.str() - << " differ starting from " << sec << " s " << usec << " us"); + << " differ starting from " << sec << " s " << usec << " us"); } } diff --git a/src/aodv/test/aodv-regression.h b/src/aodv/test/aodv-regression.h index 63dad5330..09f615f05 100644 --- a/src/aodv/test/aodv-regression.h +++ b/src/aodv/test/aodv-regression.h @@ -163,12 +163,12 @@ public: * \param arpAliveTimeout ARP alive timeout, this is used to check that ARP and routing do not interfere */ ChainRegressionTest (const char * const prefix, Time time = Seconds (10), uint32_t size = 5, Time arpAliveTimeout = Seconds (120)); - ~ChainRegressionTest (); - + ~ChainRegressionTest (); + private: /// XXX It is important to have pointers here NodeContainer * m_nodes; - + /// PCAP file names prefix const std::string m_prefix; /// Total simulation time @@ -179,7 +179,7 @@ private: const double m_step; /// ARP alive timeout const Time m_arpAliveTimeout; - + /// Create test topology void CreateNodes (); /// Create devices, install TCP/IP stack and applications diff --git a/src/aodv/test/aodv-test-suite.cc b/src/aodv/test/aodv-test-suite.cc index 68cfe0b5d..997382836 100644 --- a/src/aodv/test/aodv-test-suite.cc +++ b/src/aodv/test/aodv-test-suite.cc @@ -93,7 +93,7 @@ NeighborTest::DoRun () Simulator::Schedule (Seconds (30), &NeighborTest::CheckTimeout3, this); Simulator::Run (); Simulator::Destroy (); - } +} //----------------------------------------------------------------------------- struct TypeHeaderTest : public TestCase { @@ -123,8 +123,8 @@ struct RreqHeaderTest : public TestCase } virtual void DoRun () { - RreqHeader h (/*flags*/0, /*reserved*/0, /*hopCount*/6, /*requestID*/1, /*dst*/Ipv4Address ("1.2.3.4"), - /*dstSeqNo*/40, /*origin*/Ipv4Address ("4.3.2.1"), /*originSeqNo*/10); + RreqHeader h (/*flags*/ 0, /*reserved*/ 0, /*hopCount*/ 6, /*requestID*/ 1, /*dst*/ Ipv4Address ("1.2.3.4"), + /*dstSeqNo*/ 40, /*origin*/ Ipv4Address ("4.3.2.1"), /*originSeqNo*/ 10); NS_TEST_EXPECT_MSG_EQ (h.GetGratiousRrep (), false, "trivial"); NS_TEST_EXPECT_MSG_EQ (h.GetDestinationOnly (), false, "trivial"); NS_TEST_EXPECT_MSG_EQ (h.GetHopCount (), 6, "trivial"); @@ -159,7 +159,7 @@ struct RreqHeaderTest : public TestCase uint32_t bytes = p->RemoveHeader (h2); NS_TEST_EXPECT_MSG_EQ (bytes, 23, "RREP is 23 bytes long"); NS_TEST_EXPECT_MSG_EQ (h, h2, "Round trip serialization works"); - + } }; //----------------------------------------------------------------------------- @@ -169,8 +169,8 @@ struct RrepHeaderTest : public TestCase RrepHeaderTest () : TestCase ("AODV RREP") {} virtual void DoRun () { - RrepHeader h (/*prefixSize*/0, /*hopCount*/12, /*dst*/Ipv4Address ("1.2.3.4"), /*dstSeqNo*/2, - /*origin*/Ipv4Address ("4.3.2.1"), /*lifetime*/Seconds (3)); + RrepHeader h (/*prefixSize*/ 0, /*hopCount*/ 12, /*dst*/ Ipv4Address ("1.2.3.4"), /*dstSeqNo*/ 2, + /*origin*/ Ipv4Address ("4.3.2.1"), /*lifetime*/ Seconds (3)); NS_TEST_EXPECT_MSG_EQ (h.GetPrefixSize (), 0, "trivial"); NS_TEST_EXPECT_MSG_EQ (h.GetHopCount (), 12, "trivial"); NS_TEST_EXPECT_MSG_EQ (h.GetDst (), Ipv4Address ("1.2.3.4"), "trivial"); @@ -396,8 +396,8 @@ struct AodvRtableEntryTest : public TestCase { Ptr dev; Ipv4InterfaceAddress iface; - RoutingTableEntry rt (/*output device*/dev, /*dst*/Ipv4Address("1.2.3.4"), /*validSeqNo*/true, /*seqNo*/10, - /*interface*/iface, /*hop*/5, /*next hop*/Ipv4Address("3.3.3.3"), /*lifetime*/Seconds(10)); + RoutingTableEntry rt (/*output device*/ dev, /*dst*/ Ipv4Address("1.2.3.4"), /*validSeqNo*/ true, /*seqNo*/ 10, + /*interface*/ iface, /*hop*/ 5, /*next hop*/ Ipv4Address("3.3.3.3"), /*lifetime*/ Seconds(10)); NS_TEST_EXPECT_MSG_EQ (rt.GetOutputDevice (), dev, "trivial"); NS_TEST_EXPECT_MSG_EQ (rt.GetDestination (), Ipv4Address ("1.2.3.4"), "trivial"); NS_TEST_EXPECT_MSG_EQ (rt.GetValidSeqNo (), true, "trivial"); @@ -479,12 +479,12 @@ struct AodvRtableTest : public TestCase NS_TEST_EXPECT_MSG_EQ (rtable.GetBadLinkLifetime (), Seconds (1), "trivial"); Ptr dev; Ipv4InterfaceAddress iface; - RoutingTableEntry rt (/*output device*/dev, /*dst*/Ipv4Address("1.2.3.4"), /*validSeqNo*/true, /*seqNo*/10, - /*interface*/iface, /*hop*/5, /*next hop*/Ipv4Address("1.1.1.1"), /*lifetime*/Seconds(10)); + RoutingTableEntry rt (/*output device*/ dev, /*dst*/ Ipv4Address("1.2.3.4"), /*validSeqNo*/ true, /*seqNo*/ 10, + /*interface*/ iface, /*hop*/ 5, /*next hop*/ Ipv4Address("1.1.1.1"), /*lifetime*/ Seconds(10)); NS_TEST_EXPECT_MSG_EQ (rtable.AddRoute (rt), true, "trivial"); NS_TEST_EXPECT_MSG_EQ (rtable.AddRoute (rt), false, "trivial"); - RoutingTableEntry rt2 (/*output device*/dev, /*dst*/Ipv4Address("4.3.2.1"), /*validSeqNo*/false, /*seqNo*/0, - /*interface*/iface, /*hop*/15, /*next hop*/Ipv4Address("1.1.1.1"), /*lifetime*/Seconds(1)); + RoutingTableEntry rt2 (/*output device*/ dev, /*dst*/ Ipv4Address("4.3.2.1"), /*validSeqNo*/ false, /*seqNo*/ 0, + /*interface*/ iface, /*hop*/ 15, /*next hop*/ Ipv4Address("1.1.1.1"), /*lifetime*/ Seconds(1)); NS_TEST_EXPECT_MSG_EQ (rtable.AddRoute (rt2), true, "trivial"); NS_TEST_EXPECT_MSG_EQ (rtable.LookupRoute (rt2.GetDestination (), rt), true, "trivial"); NS_TEST_EXPECT_MSG_EQ (rt2.GetDestination (), rt.GetDestination (), "trivial"); @@ -497,8 +497,8 @@ struct AodvRtableTest : public TestCase NS_TEST_EXPECT_MSG_EQ (rtable.SetEntryState (Ipv4Address ("10.0.0.1"), INVALID), false, "trivial"); NS_TEST_EXPECT_MSG_EQ (rtable.SetEntryState (Ipv4Address ("1.2.3.4"), IN_SEARCH), true, "trivial"); NS_TEST_EXPECT_MSG_EQ (rtable.DeleteRoute (Ipv4Address ("5.5.5.5")), false, "trivial"); - RoutingTableEntry rt4 (/*output device*/dev, /*dst*/Ipv4Address ("5.5.5.5"), /*validSeqNo*/false, /*seqNo*/0, - /*interface*/iface, /*hop*/15, /*next hop*/Ipv4Address ("1.1.1.1"), /*lifetime*/Seconds (-10)); + RoutingTableEntry rt4 (/*output device*/ dev, /*dst*/ Ipv4Address ("5.5.5.5"), /*validSeqNo*/ false, /*seqNo*/ 0, + /*interface*/ iface, /*hop*/ 15, /*next hop*/ Ipv4Address ("1.1.1.1"), /*lifetime*/ Seconds (-10)); NS_TEST_EXPECT_MSG_EQ (rtable.AddRoute (rt4), true, "trivial"); NS_TEST_EXPECT_MSG_EQ (rtable.SetEntryState (Ipv4Address ("5.5.5.5"), INVALID), true, "trivial"); NS_TEST_EXPECT_MSG_EQ (rtable.LookupRoute (Ipv4Address ("5.5.5.5"), rt), false, "trivial"); @@ -538,4 +538,5 @@ public: } } g_aodvTestSuite; -}} +} +} diff --git a/src/aodv/test/bug-772.cc b/src/aodv/test/bug-772.cc index f63271162..de274b81d 100644 --- a/src/aodv/test/bug-772.cc +++ b/src/aodv/test/bug-772.cc @@ -74,16 +74,16 @@ void Bug772ChainTest::DoRun () { SeedManager::SetSeed(12345); - + CreateNodes (); CreateDevices (); - + Simulator::Stop (m_time); Simulator::Run (); Simulator::Destroy (); - + if (!WRITE_VECTORS) CheckResults (); - + delete m_nodes, m_nodes = 0; } @@ -94,12 +94,12 @@ Bug772ChainTest::CreateNodes () m_nodes->Create (m_size); MobilityHelper mobility; mobility.SetPositionAllocator ("ns3::GridPositionAllocator", - "MinX", DoubleValue (0.0), - "MinY", DoubleValue (0.0), - "DeltaX", DoubleValue (m_step), - "DeltaY", DoubleValue (0), - "GridWidth", UintegerValue (m_size), - "LayoutType", StringValue ("RowFirst")); + "MinX", DoubleValue (0.0), + "MinY", DoubleValue (0.0), + "DeltaX", DoubleValue (m_step), + "DeltaY", DoubleValue (0), + "GridWidth", UintegerValue (m_size), + "LayoutType", StringValue ("RowFirst")); mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); mobility.Install (*m_nodes); } @@ -111,14 +111,14 @@ Bug772ChainTest::CreateDevices () NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default (); wifiMac.SetType ("ns3::AdhocWifiMac"); YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default (); - // This test suite output was originally based on YansErrorRateModel - wifiPhy.SetErrorRateModel ("ns3::YansErrorRateModel"); + // This test suite output was originally based on YansErrorRateModel + wifiPhy.SetErrorRateModel ("ns3::YansErrorRateModel"); YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default (); wifiPhy.SetChannel (wifiChannel.Create ()); WifiHelper wifi = WifiHelper::Default (); wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", "DataMode", StringValue ("OfdmRate6Mbps"), "RtsCtsThreshold", StringValue ("2200")); NetDeviceContainer devices = wifi.Install (wifiPhy, wifiMac, *m_nodes); - + // 2. Setup TCP/IP & AODV AodvHelper aodv; // Use default parameters here InternetStackHelper internetStack; @@ -127,7 +127,7 @@ Bug772ChainTest::CreateDevices () Ipv4AddressHelper address; address.SetBase ("10.1.1.0", "255.255.255.0"); Ipv4InterfaceContainer interfaces = address.Assign (devices); - + // 3. Setup UDP source and sink uint16_t port = 9; // Discard port (RFC 863) OnOffHelper onoff (m_proto, Address (InetSocketAddress (interfaces.GetAddress (m_size-1), port))); @@ -141,7 +141,7 @@ Bug772ChainTest::CreateDevices () PacketSinkHelper sink (m_proto, Address (InetSocketAddress (Ipv4Address::GetAny (), port))); app = sink.Install (m_nodes->Get (m_size - 1)); app.Start (Seconds (0.0)); - + // 4. write PCAP on the first and last nodes only std::string prefix = (WRITE_VECTORS ? NS_TEST_SOURCEDIR : GetTempDir ()) + m_prefix; wifiPhy.EnablePcap (prefix, devices.Get (0)); @@ -157,11 +157,11 @@ Bug772ChainTest::CheckResults () // File naming conventions are hard-coded here. os1 << NS_TEST_SOURCEDIR << m_prefix << "-" << i << "-0.pcap"; os2 << GetTempDir () << m_prefix << "-" << i << "-0.pcap"; - + uint32_t sec(0), usec(0); bool diff = PcapFile::Diff (os1.str(), os2.str(), sec, usec); NS_TEST_EXPECT_MSG_EQ (diff, false, "PCAP traces " << os1.str() << " and " << os2.str() - << " differ starting from " << sec << " s " << usec << " us"); + << " differ starting from " << sec << " s " << usec << " us"); } } diff --git a/src/aodv/test/bug-772.h b/src/aodv/test/bug-772.h index 9fd8b0c2f..f98993ecc 100644 --- a/src/aodv/test/bug-772.h +++ b/src/aodv/test/bug-772.h @@ -47,12 +47,12 @@ public: * \param time Simulation time */ Bug772ChainTest (const char * const prefix, const char * const proto, Time time, uint32_t size); - ~Bug772ChainTest (); - + ~Bug772ChainTest (); + private: /// XXX It is important to have pointers here NodeContainer * m_nodes; - + /// PCAP file names prefix const std::string m_prefix; /// Socket factory TID @@ -63,7 +63,7 @@ private: const uint32_t m_size; /// Chain step, meters const double m_step; - + /// Create test topology void CreateNodes (); /// Create devices, install TCP/IP stack and applications diff --git a/src/aodv/test/loopback.cc b/src/aodv/test/loopback.cc index 85176d42a..b07755890 100644 --- a/src/aodv/test/loopback.cc +++ b/src/aodv/test/loopback.cc @@ -51,7 +51,7 @@ static uint32_t g_count (0); static void PingRtt (std::string context, Time rtt) { - g_count ++; + g_count++; } void @@ -80,7 +80,7 @@ LoopbackTestCase::DoRun () Ipv4AddressHelper address; address.SetBase ("10.1.1.0", "255.255.255.0"); Ipv4InterfaceContainer interfaces = address.Assign (devices); - + // Setup ping Ptr ping = CreateObject (); ping->SetAttribute ("Remote", Ipv4AddressValue (Ipv4Address::GetLoopback ())); @@ -89,12 +89,12 @@ LoopbackTestCase::DoRun () ping->SetStopTime (Seconds (4)); Names::Add ("ping", ping); Config::Connect ("/Names/ping/Rtt", MakeCallback (&PingRtt)); - + // Run Simulator::Stop (Seconds (5)); Simulator::Run (); Simulator::Destroy (); - + // Check that 4 packets delivered NS_TEST_ASSERT_MSG_EQ (g_count, 4, "Exactly 4 ping replies must be delivered."); }