bug 1982: AODV uses random variables before seeds can be set

This commit is contained in:
Tom Henderson
2015-03-19 20:03:57 -07:00
parent 368e8fcbf6
commit 47fe0d4747
3 changed files with 20 additions and 9 deletions

View File

@@ -582,12 +582,6 @@ RoutingProtocol::SetIpv4 (Ptr<Ipv4> ipv4)
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 @@ RoutingProtocol::FindSubnetBroadcastSocketWithInterfaceAddress (Ipv4InterfaceAdd
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

View File

@@ -97,6 +97,8 @@ public:
*/
int64_t AssignStreams (int64_t stream);
protected:
virtual void DoInitialize (void);
private:
// Protocol parameters.

View File

@@ -93,8 +93,8 @@ public:
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.