Bug 1798 - Changing the rate of onOffApplication might stop transmission
Changing the rate of onOffApplication might stop transmission
Status: RESOLVED FIXED
Product: ns-3
Classification: Unclassified
Component: applications
ns-3-dev
PC Linux
: P1 major
Assigned To: George Riley
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-11-12 10:57 UTC by Ra
Modified: 2013-11-23 09:08 UTC (History)
3 users (show)

See Also:


Attachments
place the file in scratch folder and run "./waf --run onOff-datarateChangeBug" to reproduce the bug. (7.84 KB, text/x-c++src)
2013-11-12 10:57 UTC, Ra
Details
bugfix (1.94 KB, patch)
2013-11-14 16:03 UTC, Tommaso Pecorella
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ra 2013-11-12 10:57:24 UTC
Created attachment 1704 [details]
place the file in scratch folder and run "./waf --run onOff-datarateChangeBug" to reproduce the bug.

Changing the rate of onOffApplication at 5.0 seconds into the simulation results in no packets transmitted. However changing the rate at 5.001 seconds into the simulation seems to work OK. Please see line 204 in the attached file and change the value "5.0" to "5.001" to see the problem go away. You may run the attached file in the scratch folder with default values to reproduce the bug.
Comment 1 Tommaso Pecorella 2013-11-14 16:03:00 UTC
Created attachment 1711 [details]
bugfix

The bug is here:
void OnOffApplication::CancelEvents ()
{
  NS_LOG_FUNCTION (this);

  if (m_sendEvent.IsRunning ())
    { // Cancel the pending send packet event
      // Calculate residual bits since last packet sent
      Time delta (Simulator::Now () - m_lastStartTime);
      int64x64_t bits = delta.To (Time::S) * m_cbrRate.GetBitRate ();
      m_residualBits += bits.GetHigh ();
    }
  Simulator::Cancel (m_sendEvent);
  Simulator::Cancel (m_startStopEvent);
}

If m_cbrRate is changed at the wrong moment, m_residualBits can become larger than m_pktSize * 8. Hence the ScheduleNextTx will schedule the next transmission to an extremely large time.
And the application will seems to stop.

The patch fixes the bug in a rather dirty (but effective) way
Comment 2 Brian Swenson 2013-11-20 14:56:44 UTC
This looks good to me.  Ignoring residual bits immediately after cbr change seems to be the best approach.
Comment 3 Tommaso Pecorella 2013-11-23 09:08:15 UTC
Closed in changeset: 10438:32b7a66dbe7f