src/devices/mesh/mesh-wifi-interface-mac.cc
changeset 5178 fa7d9b667efc
parent 5156 5b499f25655a
child 5349 8e8459d1831b
equal deleted inserted replaced
5177:2d82457e44dc 5178:fa7d9b667efc
   491 }
   491 }
   492 void
   492 void
   493 MeshWifiInterfaceMac::SetBeaconGeneration (bool enable)
   493 MeshWifiInterfaceMac::SetBeaconGeneration (bool enable)
   494 {
   494 {
   495   NS_LOG_FUNCTION (this << enable);
   495   NS_LOG_FUNCTION (this << enable);
       
   496   UniformVariable coefficient (0.0, m_randomStart.GetSeconds ());
   496   if (enable)
   497   if (enable)
   497     {
   498     {
       
   499       Time randomStart = Seconds (coefficient.GetValue ());
   498       // Now start sending beacons after some random delay (to avoid collisions)
   500       // Now start sending beacons after some random delay (to avoid collisions)
   499       UniformVariable coefficient (0.0, m_randomStart.GetSeconds ());
   501       NS_ASSERT (!m_beaconSendEvent.IsRunning ());
   500       Time randomStart = Seconds (coefficient.GetValue ());
       
   501 
       
   502       m_beaconSendEvent = Simulator::Schedule (randomStart, &MeshWifiInterfaceMac::SendBeacon, this);
   502       m_beaconSendEvent = Simulator::Schedule (randomStart, &MeshWifiInterfaceMac::SendBeacon, this);
   503       m_tbtt = Simulator::Now () + randomStart;
   503       m_tbtt = Simulator::Now () + randomStart;
   504     }
   504     }
   505   else
   505   else
   506     {
   506     {