Bug 1798 - Changing the rate of onOffApplication might stop transmission
authorTommaso Pecorella <tommaso.pecorella@unifi.it>
Sat, 23 Nov 2013 15:05:28 +0100
changeset 10438 32b7a66dbe7f
parent 10437 0571abffdfe1
child 10439 73bc9e55f9bd
Bug 1798 - Changing the rate of onOffApplication might stop transmission
RELEASE_NOTES
src/applications/model/onoff-application.cc
src/applications/model/onoff-application.h
--- a/RELEASE_NOTES	Wed Nov 20 20:12:13 2013 +0100
+++ b/RELEASE_NOTES	Sat Nov 23 15:05:28 2013 +0100
@@ -27,6 +27,7 @@
 - Bug 1778 - Implement TapBridge::IsLinkUp() function
 - Bug 1777 - Implement the more direct way of "using" configuration of existing tap interface
 - Bug 1776 - Improve CRC performance for CsmaNetDevice in emulation modes
+- Bug 1798 - Changing the rate of onOffApplication might stop transmission
 
 Release 3.18.1
 ==============
--- a/src/applications/model/onoff-application.cc	Wed Nov 20 20:12:13 2013 +0100
+++ b/src/applications/model/onoff-application.cc	Sat Nov 23 15:05:28 2013 +0100
@@ -167,6 +167,8 @@
         MakeCallback (&OnOffApplication::ConnectionSucceeded, this),
         MakeCallback (&OnOffApplication::ConnectionFailed, this));
     }
+  m_cbrRateFailSafe = m_cbrRate;
+
   // Insure no pending event
   CancelEvents ();
   // If we are not yet connected, there is nothing to do here
@@ -194,13 +196,14 @@
 {
   NS_LOG_FUNCTION (this);
 
-  if (m_sendEvent.IsRunning ())
+  if (m_sendEvent.IsRunning () && m_cbrRateFailSafe == m_cbrRate )
     { // 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 ();
     }
+  m_cbrRateFailSafe = m_cbrRate;
   Simulator::Cancel (m_sendEvent);
   Simulator::Cancel (m_startStopEvent);
 }
--- a/src/applications/model/onoff-application.h	Wed Nov 20 20:12:13 2013 +0100
+++ b/src/applications/model/onoff-application.h	Sat Nov 23 15:05:28 2013 +0100
@@ -145,6 +145,7 @@
   Ptr<RandomVariableStream>  m_onTime;       // rng for On Time
   Ptr<RandomVariableStream>  m_offTime;      // rng for Off Time
   DataRate        m_cbrRate;      // Rate that data is generated
+  DataRate        m_cbrRateFailSafe;      // Rate that data is generated (check copy)
   uint32_t        m_pktSize;      // Size of packets
   uint32_t        m_residualBits; // Number of generated, but not sent, bits
   Time            m_lastStartTime; // Time last packet sent