diff --git a/src/routing/aodv/aodv-routing-protocol.cc b/src/routing/aodv/aodv-routing-protocol.cc index 26a6aab35..6d23bc856 100644 --- a/src/routing/aodv/aodv-routing-protocol.cc +++ b/src/routing/aodv/aodv-routing-protocol.cc @@ -81,7 +81,7 @@ RoutingProtocol::RoutingProtocol () : DestinationOnly (false), GratuitousReply (true), EnableExpandingRingSearch (false), - EnableHello (true), + EnableHello (false), EnableLocalRepair (true), m_routingTable (DeletePeriod), m_queue (MaxQueueLen, MaxQueueTime), @@ -163,7 +163,7 @@ RoutingProtocol::GetTypeId (void) UintegerValue (2), MakeUintegerAccessor (&RoutingProtocol::AllowedHelloLoss), MakeUintegerChecker ()) - .AddAttribute ("GratuitousReply", "indicates whether a gratuitous RREP should be unicast to the node originated route discovery.", + .AddAttribute ("GratuitousReply", "Indicates whether a gratuitous RREP should be unicast to the node originated route discovery.", BooleanValue (true), MakeBooleanAccessor (&RoutingProtocol::SetGratuitousReplyFlag, &RoutingProtocol::GetGratuitousReplyFlag), @@ -178,8 +178,8 @@ RoutingProtocol::GetTypeId (void) MakeBooleanAccessor (&RoutingProtocol::SetExpandingRingSearchEnable, &RoutingProtocol::GetExpandingRingSearchEnable), MakeBooleanChecker ()) - .AddAttribute ("EnableHello", "Enable hello message.", - BooleanValue (true), + .AddAttribute ("EnableHello", "Indicates whether a hello messages enable.", + BooleanValue (false), MakeBooleanAccessor (&RoutingProtocol::SetHelloEnable, &RoutingProtocol::GetHelloEnable), MakeBooleanChecker ()) @@ -422,7 +422,7 @@ RoutingProtocol::SetIpv4 (Ptr ipv4) if (EnableHello) { htimer.SetFunction (&RoutingProtocol::HelloTimerExpire, this); - htimer.Schedule(MilliSeconds(UniformVariable().GetValue (0.0, 1000.0))); + htimer.Schedule(MilliSeconds(UniformVariable().GetValue (0.0, 10.0))); } m_ipv4 = ipv4; @@ -477,12 +477,6 @@ RoutingProtocol::SendRequest (Ipv4Address dst, uint16_t ttl) RoutingTableEntry rt; if (m_routingTable.LookupRoute (dst, rt)) { - // if we already send maximum number of RREQ - if (rt.GetRreqCnt () == RreqRetries) - { - NS_LOG_LOGIC ("Route does not found to " << dst); - return; - } rreqHeader.SetHopCount (rt.GetHop ()); if (rt.GetValidSeqNo ()) rreqHeader.SetDstSeqno (rt.GetSeqNo ()); @@ -528,7 +522,7 @@ RoutingProtocol::SendRequest (Ipv4Address dst, uint16_t ttl) if (EnableHello) { htimer.Cancel (); - htimer.Schedule (HelloInterval - Scalar(0.1)*MilliSeconds(UniformVariable().GetValue (0, 10))); + htimer.Schedule (HelloInterval - Scalar(0.01)*MilliSeconds(UniformVariable().GetValue (0, 10))); } } @@ -1083,6 +1077,7 @@ RoutingProtocol::RouteRequestTimerExpire (Ipv4Address dst, uint16_t lastTtl ) { NS_LOG_LOGIC("route discovery to " << dst << " has been attempted RreqRetries times"); m_addressReqTimer.erase(dst); + m_routingTable.DeleteRoute(dst); NS_LOG_LOGIC ("Route not found. Drop packet with dst " << dst); DropFromQueue (dst); // TODO drop packet from queue and deliver Destination Unreachable message to the application. @@ -1107,6 +1102,7 @@ RoutingProtocol::RouteRequestTimerExpire (Ipv4Address dst, uint16_t lastTtl ) { NS_LOG_LOGIC ("Route down. Stop search. Drop packet with destination " << dst); m_addressReqTimer.erase(dst); + m_routingTable.DeleteRoute(dst); DropFromQueue (dst); } } @@ -1118,7 +1114,7 @@ RoutingProtocol::HelloTimerExpire () SendHello (); // TODO select random time for the next hello htimer.Cancel (); - htimer.Schedule (HelloInterval - Scalar(0.1)*MilliSeconds(UniformVariable().GetValue (0.0, 10.0)) ); + htimer.Schedule (HelloInterval - Scalar(0.01)*MilliSeconds(UniformVariable().GetValue (0.0, 10.0)) ); } void diff --git a/src/routing/aodv/aodv-routing-protocol.h b/src/routing/aodv/aodv-routing-protocol.h index 95de6f118..ed14f56ad 100644 --- a/src/routing/aodv/aodv-routing-protocol.h +++ b/src/routing/aodv/aodv-routing-protocol.h @@ -93,42 +93,46 @@ public: private: ///\name Protocol parameters. TODO document //\{ - uint32_t RreqRetries; ///< Maximum number of retransmissions of RREQ with TTL = NetDiameter to discover a route - Time ActiveRouteTimeout; // 3 seconds - uint32_t NetDiameter; ///< Net diameter measures the maximum possible number of hops between two nodes in the network + uint32_t RreqRetries; ///< Maximum number of retransmissions of RREQ with TTL = NetDiameter to discover a route + Time ActiveRouteTimeout; + uint32_t NetDiameter; ///< Net diameter measures the maximum possible number of hops between two nodes in the network /** * NodeTraversalTime is a conservative estimate of the average one hop traversal time for packets * and should include queuing delays, interrupt processing times and transfer times. */ Time NodeTraversalTime; - Time NetTraversalTime; // 2 * NodeTraversalTime * NetDiameter + Time NetTraversalTime; Time PathDiscoveryTime; - Time MyRouteTimeout; ///< Value of lifetime field in RREP generating by this node + Time MyRouteTimeout; ///< Value of lifetime field in RREP generating by this node + /** + * Every HelloInterval the node checks whether it has sent a broadcast within the last HelloInterval. + * If it has not, it MAY broadcast a Hello message + */ Time HelloInterval; - uint32_t AllowedHelloLoss; ///< Number of hello messages which may be loss for valid link + uint32_t AllowedHelloLoss; ///< Number of hello messages which may be loss for valid link /** * 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. */ Time DeletePeriod; Time NextHopWait; - uint16_t TtlStart; - uint16_t TtlIncrement; - uint16_t TtlThreshold; - uint16_t MaxRepairTtl; // 0.3 * NetDiameter - uint16_t LocalAddTtl; + uint16_t TtlStart; ///< Initial value of TTL in RREQ when use an expanding ring search + uint16_t TtlIncrement; ///< Increment value of RREQ TTL when use an expanding ring search + uint16_t TtlThreshold; ///< Threshold, beyond which TTL = NetDiameter is used for each attempt in RREQ + uint16_t MaxRepairTtl; ///< Maximum distance in hops between intermediate node and destination node when local repair still may be applied. + uint16_t LocalAddTtl; ///< Value used in calculation RREQ TTL when use local repair /** * The TimeoutBuffer is configurable. 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. */ uint16_t TimeoutBuffer; Time BlackListTimeout; - uint32_t MaxQueueLen; - Time MaxQueueTime; - bool DestinationOnly; - bool GratuitousReply; + uint32_t MaxQueueLen; ///< The maximum number of packets that we allow a routing protocol to buffer. + Time MaxQueueTime; ///< The maximum period of time that a routing protocol is allowed to buffer a packet for. + bool DestinationOnly; ///< Indicates only the destination may respond to this RREQ. + bool GratuitousReply; ///< Indicates whether a gratuitous RREP should be unicast to the node originated route discovery. bool EnableExpandingRingSearch; - bool EnableHello; + bool EnableHello; ///< Indicates whether a hello messages enable bool EnableLocalRepair; //\} diff --git a/src/routing/aodv/aodv-rtable.cc b/src/routing/aodv/aodv-rtable.cc index 9546e088f..bb93de4fa 100644 --- a/src/routing/aodv/aodv-rtable.cc +++ b/src/routing/aodv/aodv-rtable.cc @@ -283,7 +283,6 @@ RoutingTable::DeleteRoute (Ipv4Address dst ) bool RoutingTable::AddRoute (RoutingTableEntry & rt ) { - Purge (); if (rt.GetFlag () != RTF_IN_SEARCH) rt.SetRreqCnt (0); std::pair::iterator, bool> result = m_ipv4AddressEntry.insert (std::make_pair (rt.GetDestination (), rt)); @@ -293,7 +292,6 @@ RoutingTable::AddRoute (RoutingTableEntry & rt ) bool RoutingTable::Update (RoutingTableEntry & rt ) { - Purge (); std::map::iterator i = m_ipv4AddressEntry.find (rt.GetDestination ()); if (i == m_ipv4AddressEntry.end ()) return false; @@ -306,7 +304,6 @@ RoutingTable::Update (RoutingTableEntry & rt ) bool RoutingTable::SetEntryState (Ipv4Address id, RouteFlags state ) { - Purge (); std::map::iterator i = m_ipv4AddressEntry.find (id); if (i == m_ipv4AddressEntry.end ()) return false; @@ -361,7 +358,6 @@ RoutingTable::Purge () NS_LOG_LOGIC ("invalidate route with dst " << i->first ); i->second.Invalidate (m_badLinkLifetime); NS_LOG_LOGIC (Simulator::Now().GetSeconds()); - Print(std::cout); ++i; } else @@ -374,7 +370,6 @@ RoutingTable::Purge () bool RoutingTable::MarkLinkAsUinidirectional (Ipv4Address neighbor, Time blacklistTimeout ) { - Purge (); std::map::iterator i = m_ipv4AddressEntry.find (neighbor); if (i == m_ipv4AddressEntry.end ()) return false;