From d7d6cf54ff8c5f04e87ecbab509deb94204b75d9 Mon Sep 17 00:00:00 2001 From: Kirill Andreev Date: Mon, 7 Sep 2009 16:04:15 +0400 Subject: [PATCH] Random variable definitions were removed from conditional code --- src/devices/mesh/dot11s/peer-management-protocol.cc | 4 ++-- src/devices/mesh/mesh-wifi-interface-mac.cc | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/devices/mesh/dot11s/peer-management-protocol.cc b/src/devices/mesh/dot11s/peer-management-protocol.cc index 92e01a1fd..fe144f0e5 100644 --- a/src/devices/mesh/dot11s/peer-management-protocol.cc +++ b/src/devices/mesh/dot11s/peer-management-protocol.cc @@ -424,6 +424,8 @@ PeerManagementProtocol::GetNextBeaconShift (uint32_t interface) //So, the shift is a random integer variable uniformly distributed in [-15;-1] U [1;15] static int maxShift = 15; static int minShift = 1; + UniformVariable randomSign (-1, 1); + UniformVariable randomShift (minShift, maxShift); PeerLinksMap::iterator iface = m_peerLinks.find (interface); NS_ASSERT (iface != m_peerLinks.end ()); PeerManagementProtocolMacMap::iterator plugin = m_plugins.find (interface); @@ -452,8 +454,6 @@ PeerManagementProtocol::GetNextBeaconShift (uint32_t interface) if ((TimeToTu (myBeacon.first) - ((*j)->GetLastBeacon () / 4)) % ((*j)->GetBeaconInterval ()) == 0) { - UniformVariable randomSign (-1, 1); - UniformVariable randomShift (minShift, maxShift); int beaconShift = randomShift.GetInteger (minShift, maxShift) * ((randomSign.GetValue () >= 0) ? 1 : -1); NS_LOG_DEBUG ("Apply MBCA: Shift value = " << beaconShift << " beacon TUs"); diff --git a/src/devices/mesh/mesh-wifi-interface-mac.cc b/src/devices/mesh/mesh-wifi-interface-mac.cc index 78c7505be..31020f759 100644 --- a/src/devices/mesh/mesh-wifi-interface-mac.cc +++ b/src/devices/mesh/mesh-wifi-interface-mac.cc @@ -493,12 +493,12 @@ void MeshWifiInterfaceMac::SetBeaconGeneration (bool enable) { NS_LOG_FUNCTION (this << enable); + UniformVariable coefficient (0.0, m_randomStart.GetSeconds ()); if (enable) { - // Now start sending beacons after some random delay (to avoid collisions) - UniformVariable coefficient (0.0, m_randomStart.GetSeconds ()); Time randomStart = Seconds (coefficient.GetValue ()); - + // Now start sending beacons after some random delay (to avoid collisions) + NS_ASSERT (!m_beaconSendEvent.IsRunning ()); m_beaconSendEvent = Simulator::Schedule (randomStart, &MeshWifiInterfaceMac::SendBeacon, this); m_tbtt = Simulator::Now () + randomStart; }