--- a/src/devices/mesh/dot11s/peer-management-protocol.cc Wed Sep 02 14:58:36 2009 +0400
+++ b/src/devices/mesh/dot11s/peer-management-protocol.cc Mon Sep 07 16:04:15 2009 +0400
@@ -424,6 +424,8 @@
//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 @@
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");
--- a/src/devices/mesh/mesh-wifi-interface-mac.cc Wed Sep 02 14:58:36 2009 +0400
+++ b/src/devices/mesh/mesh-wifi-interface-mac.cc Mon Sep 07 16:04:15 2009 +0400
@@ -493,12 +493,12 @@
MeshWifiInterfaceMac::SetBeaconGeneration (bool enable)
{
NS_LOG_FUNCTION (this << enable);
+ UniformVariable coefficient (0.0, m_randomStart.GetSeconds ());
if (enable)
{
+ Time randomStart = Seconds (coefficient.GetValue ());
// Now start sending beacons after some random delay (to avoid collisions)
- UniformVariable coefficient (0.0, m_randomStart.GetSeconds ());
- Time randomStart = Seconds (coefficient.GetValue ());
-
+ NS_ASSERT (!m_beaconSendEvent.IsRunning ());
m_beaconSendEvent = Simulator::Schedule (randomStart, &MeshWifiInterfaceMac::SendBeacon, this);
m_tbtt = Simulator::Now () + randomStart;
}