set OnOffApplication::m_lastStartTime correctly (bug #490)
authorTom Henderson <tomh@tomh.org>
Thu, 12 Mar 2009 15:55:40 -0400
changeset 4262 170eff4aba90
parent 4261 82be63aaf35a
child 4267 c6c745185930
child 4814 61d0cf0fa146
set OnOffApplication::m_lastStartTime correctly (bug #490)
src/applications/onoff/onoff-application.cc
src/applications/onoff/onoff-application.h
--- a/src/applications/onoff/onoff-application.cc	Wed Mar 11 11:16:25 2009 +0000
+++ b/src/applications/onoff/onoff-application.cc	Thu Mar 12 15:55:40 2009 -0400
@@ -176,7 +176,7 @@
 void OnOffApplication::StartSending()
 {
   NS_LOG_FUNCTION_NOARGS ();
-
+  m_lastStartTime = Simulator::Now();
   ScheduleNextTx();  // Schedule the send packet event
   ScheduleStopEvent();
 }
--- a/src/applications/onoff/onoff-application.h	Wed Mar 11 11:16:25 2009 +0000
+++ b/src/applications/onoff/onoff-application.h	Thu Mar 12 15:55:40 2009 -0400
@@ -64,6 +64,22 @@
  * variables. During the "Off" state, no traffic is generated.
  * During the "On" state, cbr traffic is generated. This cbr traffic is
  * characterized by the specified "data rate" and "packet size".
+ *
+ * Note:  When an application is started, the first packet transmission
+ * occurs _after_ a delay equal to (packet size/bit rate).  Note also,
+ * when an application transitions into an off state in between packet
+ * transmissions, the remaining time until when the next transmission
+ * would have occurred is cached and is used when the application starts
+ * up again.  Example:  packet size = 1000 bits, bit rate = 500 bits/sec.
+ * If the application is started at time 3 seconds, the first packet
+ * transmission will be scheduled for time 5 seconds (3 + 1000/500)
+ * and subsequent transmissions at 2 second intervals.  If the above
+ * application were instead stopped at time 4 seconds, and restarted at
+ * time 5.5 seconds, then the first packet would be sent at time 6.5 seconds,
+ * because when it was stopped at 4 seconds, there was only 1 second remaining
+ * until the originally scheduled transmission, and this time remaining
+ * information is cached and used to schedule the next transmission
+ * upon restarting.
  */
 class OnOffApplication : public Application 
 {