diff --git a/CHANGES.html b/CHANGES.html
index c68f32087..5e9cfcdf5 100644
--- a/CHANGES.html
+++ b/CHANGES.html
@@ -63,6 +63,7 @@ nodes to be placed outside of buildings defined in the scenario.
hash of various fields of the packet header (depending on the packet type).
Added a priority queue disc (PrioQueueDisc).
Added a new trace source in StaWifiMac for tracing beacon arrivals
+ Added a new helper method to ApplicationContainer to start applications with some jitter around the start time
Changes to existing API:
diff --git a/RELEASE_NOTES b/RELEASE_NOTES
index 8c8cff901..896a67279 100644
--- a/RELEASE_NOTES
+++ b/RELEASE_NOTES
@@ -30,6 +30,8 @@ New user-visible features
that are located within buildings defined in the scenario.
- (tcp) Added PRR as recovery algorithm
- (wifi) Add a new trace source to StaWifiMac to trace beacon arrivals
+- (network) Add a method to allow random variable-based jitter to be added
+ to the start times of applications in a container.
Bugs fixed
----------
diff --git a/src/network/helper/application-container.cc b/src/network/helper/application-container.cc
index 243eac34d..8c394a083 100644
--- a/src/network/helper/application-container.cc
+++ b/src/network/helper/application-container.cc
@@ -19,10 +19,13 @@
*/
#include "ns3/names.h"
+#include "ns3/log.h"
#include "application-container.h"
namespace ns3 {
+NS_LOG_COMPONENT_DEFINE ("ApplicationContainer");
+
ApplicationContainer::ApplicationContainer ()
{
}
@@ -90,6 +93,17 @@ ApplicationContainer::Start (Time start)
}
}
void
+ApplicationContainer::StartWithJitter (Time start, Ptr rv)
+{
+ for (Iterator i = Begin (); i != End (); ++i)
+ {
+ Ptr app = *i;
+ double value = rv->GetValue ();
+ NS_LOG_DEBUG ("Start application at time " << start.GetSeconds () + value << "s");
+ app->SetStartTime (start + Seconds (value));
+ }
+}
+void
ApplicationContainer::Stop (Time stop)
{
for (Iterator i = Begin (); i != End (); ++i)
diff --git a/src/network/helper/application-container.h b/src/network/helper/application-container.h
index 88ba9a9d4..25aef36bd 100644
--- a/src/network/helper/application-container.h
+++ b/src/network/helper/application-container.h
@@ -24,6 +24,7 @@
#include
#include
#include "ns3/application.h"
+#include "ns3/random-variable-stream.h"
namespace ns3 {
@@ -193,6 +194,19 @@ public:
*/
void Start (Time start);
+ /**
+ * \brief Start all of the Applications in this container at the start time
+ * given as a parameter, plus some jitter.
+ *
+ * This method iterates through the contained Applications and calls
+ * their Start() methods with the provided start Time, plus a jitter value
+ * drawn from the provided random variable.
+ *
+ * \param start The Time at which each of the applications should start.
+ * \param rv The random variable that adds jitter (units of seconds)
+ */
+ void StartWithJitter (Time start, Ptr rv);
+
/**
* \brief Arrange for all of the Applications in this container to Stop()
* at the Time given as a parameter.