src/applications/onoff-application.cc
changeset 1432 3aef7d7a71c2
parent 1429 31cb0668defd
child 1449 df86e6b876ef
equal deleted inserted replaced
1431:3760d52ef5d1 1432:3aef7d7a71c2
   197   NS_DEBUG("OnOffApplication::ScheduleNextTx ()");
   197   NS_DEBUG("OnOffApplication::ScheduleNextTx ()");
   198 
   198 
   199   if (m_totBytes < m_maxBytes)
   199   if (m_totBytes < m_maxBytes)
   200     {
   200     {
   201       uint32_t bits = m_pktSize * 8 - m_residualBits;
   201       uint32_t bits = m_pktSize * 8 - m_residualBits;
       
   202       NS_DEBUG("OnOffApplication::ScheduleNextTx (): bits = " << bits);
   202       Time nextTime(Seconds (bits / 
   203       Time nextTime(Seconds (bits / 
   203         static_cast<double>(m_cbrRate.GetBitRate()))); // Time till next packet
   204         static_cast<double>(m_cbrRate.GetBitRate()))); // Time till next packet
   204       m_sendEvent = Simulator::Schedule(nextTime, &OnOffApplication::SendPacket, this);
   205       NS_DEBUG("OnOffApplication::ScheduleNextTx (): nextTime = " << nextTime);
       
   206       m_sendEvent = Simulator::Schedule(nextTime, 
       
   207                                         &OnOffApplication::SendPacket, this);
   205     }
   208     }
   206   else
   209   else
   207     { // All done, cancel any pending events
   210     { // All done, cancel any pending events
   208       StopApplication();
   211       StopApplication();
   209     }
   212     }
   212 void OnOffApplication::ScheduleStartEvent()
   215 void OnOffApplication::ScheduleStartEvent()
   213 {  // Schedules the event to start sending data (switch to the "On" state)
   216 {  // Schedules the event to start sending data (switch to the "On" state)
   214   NS_DEBUG("OnOffApplication::ScheduleStartEvent ()");
   217   NS_DEBUG("OnOffApplication::ScheduleStartEvent ()");
   215 
   218 
   216   Time offInterval = Seconds(m_offTime->GetValue());
   219   Time offInterval = Seconds(m_offTime->GetValue());
       
   220   NS_DEBUG("OnOffApplication::ScheduleStartEvent (): "
       
   221     "start at " << offInterval);
   217   m_startStopEvent = Simulator::Schedule(offInterval, &OnOffApplication::StartSending, this);
   222   m_startStopEvent = Simulator::Schedule(offInterval, &OnOffApplication::StartSending, this);
   218 }
   223 }
   219 
   224 
   220 void OnOffApplication::ScheduleStopEvent()
   225 void OnOffApplication::ScheduleStopEvent()
   221 {  // Schedules the event to stop sending data (switch to "Off" state)
   226 {  // Schedules the event to stop sending data (switch to "Off" state)