jitter added for hello
authorBorovkova Elena <borovkovaes@iitp.ru>
Thu, 06 Aug 2009 20:43:17 +0400
changeset 5652 5236285e3818
parent 5651 26deb6597b42
child 5653 3fa3f186e045
jitter added for hello
src/routing/aodv/aodv-routing-protocol.cc
src/routing/aodv/aodv-rtable.cc
src/routing/aodv/aodv-rtable.h
--- a/src/routing/aodv/aodv-routing-protocol.cc	Thu Aug 06 20:05:18 2009 +0400
+++ b/src/routing/aodv/aodv-routing-protocol.cc	Thu Aug 06 20:43:17 2009 +0400
@@ -420,7 +420,7 @@
   if (EnableHello)
     {
       htimer.SetFunction (&RoutingProtocol::HelloTimerExpire, this);
-      htimer.SetDelay (HelloInterval);
+      htimer.SetDelay (HelloInterval - Scalar(0.1)*MilliSeconds(UniformVariable().GetValue (0, 1)));
     }
 
   m_ipv4 = ipv4;
@@ -526,7 +526,7 @@
   if (EnableHello)
     {
       htimer.Cancel ();
-      htimer.Schedule (HelloInterval);
+      htimer.Schedule (HelloInterval - Scalar(0.1)*MilliSeconds(UniformVariable().GetValue (0, 1)));
     }
 }
 
@@ -767,7 +767,7 @@
   if (EnableHello)
     {
       htimer.Cancel ();
-      htimer.Schedule (HelloInterval);
+      htimer.Schedule (HelloInterval - Scalar(0.1)*MilliSeconds(UniformVariable().GetValue (0, 1)));
     }
   NS_LOG_LOGIC ("After recieve request");
   m_routingTable.Print (std::cout);
@@ -1111,7 +1111,7 @@
   SendHello ();
   // TODO select random time for the next hello
   htimer.Cancel ();
-  htimer.Schedule (HelloInterval + MilliSeconds(UniformVariable().GetValue (0, 1)) );
+  htimer.Schedule (HelloInterval - Scalar(0.1)*MilliSeconds(UniformVariable().GetValue (0, 1)) );
 }
 
 void
--- a/src/routing/aodv/aodv-rtable.cc	Thu Aug 06 20:05:18 2009 +0400
+++ b/src/routing/aodv/aodv-rtable.cc	Thu Aug 06 20:43:17 2009 +0400
@@ -306,6 +306,7 @@
 bool
 RoutingTable::SetEntryState (Ipv4Address id, RouteFlags state )
 {
+  Purge ();
   std::map<Ipv4Address, RoutingTableEntry>::iterator i = m_ipv4AddressEntry.find (id);
   if (i == m_ipv4AddressEntry.end ())
     return false;
@@ -373,6 +374,7 @@
 bool
 RoutingTable::MarkLinkAsUinidirectional (Ipv4Address neighbor, Time blacklistTimeout )
 {
+  Purge ();
   std::map<Ipv4Address, RoutingTableEntry>::iterator i = m_ipv4AddressEntry.find (neighbor);
   if (i == m_ipv4AddressEntry.end ())
     return false;
@@ -383,8 +385,9 @@
 }
 
 void
-RoutingTable::Print (std::ostream &os ) const
+RoutingTable::Print (std::ostream &os )
 {
+  Purge ();
   os << "\nAODV Routing table\n" << "Destination\tGateway\t\tInterface\tFlag\tExpire\n";
   for (std::map<Ipv4Address, RoutingTableEntry>::const_iterator i = m_ipv4AddressEntry.begin (); i != m_ipv4AddressEntry.end (); ++i)
     {
--- a/src/routing/aodv/aodv-rtable.h	Thu Aug 06 20:05:18 2009 +0400
+++ b/src/routing/aodv/aodv-rtable.h	Thu Aug 06 20:43:17 2009 +0400
@@ -236,7 +236,7 @@
    */
   bool MarkLinkAsUinidirectional(Ipv4Address neighbor, Time blacklistTimeout);
   /// Print routing table
-  void Print(std::ostream &os) const;
+  void Print(std::ostream &os);
 
 private:
   std::map<Ipv4Address, RoutingTableEntry> m_ipv4AddressEntry;