Random variable definitions were removed from conditional code
This commit is contained in:
@@ -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");
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user