network: Add ApplicationContainer::StartWithJitter()

This commit is contained in:
Tom Henderson
2018-08-08 16:31:39 -07:00
parent 0a29d747c6
commit 55df7237fe
4 changed files with 31 additions and 0 deletions

View File

@@ -63,6 +63,7 @@ nodes to be placed outside of buildings defined in the scenario.</li>
hash of various fields of the packet header (depending on the packet type).</li>
<li> Added a priority queue disc (PrioQueueDisc).</li>
<li> Added a new trace source in StaWifiMac for tracing beacon arrivals</li>
<li> Added a new helper method to ApplicationContainer to start applications with some jitter around the start time</li>
</ul>
<h2>Changes to existing API:</h2>
<ul>

View File

@@ -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
----------

View File

@@ -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<RandomVariableStream> rv)
{
for (Iterator i = Begin (); i != End (); ++i)
{
Ptr<Application> 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)

View File

@@ -24,6 +24,7 @@
#include <stdint.h>
#include <vector>
#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<RandomVariableStream> rv);
/**
* \brief Arrange for all of the Applications in this container to Stop()
* at the Time given as a parameter.