bug 1982: AODV uses random variables before seeds can be set
authorTom Henderson <tomh@tomh.org>
Thu, 19 Mar 2015 20:03:57 -0700
changeset 11250 06390d19e6f9
parent 11249 525aab463dac
child 11251 73dd242bbaed
bug 1982: AODV uses random variables before seeds can be set
src/aodv/model/aodv-routing-protocol.cc
src/aodv/model/aodv-routing-protocol.h
src/internet/model/ipv4-list-routing.h
--- a/src/aodv/model/aodv-routing-protocol.cc	Fri Mar 27 11:58:58 2015 -0700
+++ b/src/aodv/model/aodv-routing-protocol.cc	Thu Mar 19 20:03:57 2015 -0700
@@ -582,12 +582,6 @@
   NS_ASSERT (ipv4 != 0);
   NS_ASSERT (m_ipv4 == 0);
 
-  if (EnableHello)
-    {
-      m_htimer.SetFunction (&RoutingProtocol::HelloTimerExpire, this);
-      m_htimer.Schedule (MilliSeconds (m_uniformRandomVariable->GetInteger (0, 100)));
-    }
-
   m_ipv4 = ipv4;
 
   // Create lo route. It is asserted that the only one interface up for now is loopback
@@ -1930,5 +1924,20 @@
   return socket;
 }
 
+void
+RoutingProtocol::DoInitialize (void)
+{
+  NS_LOG_FUNCTION (this);
+  uint32_t startTime;
+  if (EnableHello)
+    {
+      m_htimer.SetFunction (&RoutingProtocol::HelloTimerExpire, this);
+      startTime = m_uniformRandomVariable->GetInteger (0, 100);
+      NS_LOG_DEBUG ("Starting at time " << startTime << "ms");
+      m_htimer.Schedule (MilliSeconds (startTime));
+    }
+  Ipv4RoutingProtocol::DoInitialize ();
 }
-}
+
+} //namespace aodv
+} //namespace ns3
--- a/src/aodv/model/aodv-routing-protocol.h	Fri Mar 27 11:58:58 2015 -0700
+++ b/src/aodv/model/aodv-routing-protocol.h	Thu Mar 19 20:03:57 2015 -0700
@@ -97,6 +97,8 @@
   */
   int64_t AssignStreams (int64_t stream);
 
+protected:
+  virtual void DoInitialize (void);
 private:
   
   // Protocol parameters.
--- a/src/internet/model/ipv4-list-routing.h	Fri Mar 27 11:58:58 2015 -0700
+++ b/src/internet/model/ipv4-list-routing.h	Thu Mar 19 20:03:57 2015 -0700
@@ -93,8 +93,8 @@
   virtual void PrintRoutingTable (Ptr<OutputStreamWrapper> stream) const;
 
 protected:
-  void DoDispose (void);
-  void DoInitialize (void);
+  virtual void DoDispose (void);
+  virtual void DoInitialize (void);
 private:
   /**
    * \brief Container identifying an IPv4 Routing Protocol entry in the list.