22#include "ns3/core-module.h"
55 m_interval = interval;
58 m_rng->SetAttribute(
"Mean",
DoubleValue(m_wait.GetSeconds()));
74 double delta = m_rng->GetValue();
82 bool even = (ratio.
GetHigh() % 2);
83 Time work = m_wait * (even ? 3 : 1);
84 std::this_thread::sleep_for(std::chrono::nanoseconds(work.
GetNanoSeconds()));
100main(
int argc,
char** argv)
108 cmd.AddValue(
"stop",
"Simulation duration in virtual time.", stop);
109 cmd.AddValue(
"interval",
"Approximate reporting interval, in wall clock time.", interval);
110 cmd.AddValue(
"wait",
"Wallclock time to burn on each event.", wait);
111 cmd.AddValue(
"verbose",
"Turn on verbose progress message.",
verbose);
112 cmd.Parse(argc, argv);
115 << cmd.GetName() <<
":\n"
117 <<
"verbose progress message: " << (
verbose ?
"on\n" :
"off\n")
118 <<
"target reporting interval: " << interval.
As(
Time::S) <<
"\n"
119 <<
"average event sleep time: " << wait.
As(
Time::MS) <<
"\n"
120 <<
"total simulation run time: " << stop.As(
Time::S) << std::endl;
Execute a function periodically, which takes more or less time to run.
Time m_interval
Time between switching workloads.
void Event()
The Hold event.
Ptr< RandomVariableStream > m_rng
The random number generator for the interval between events.
Hold(Ptr< RandomVariableStream > rng)
Create a hold with a specified random number generator for the wait time.
Time m_wait
Mean inter-event time.
Hold(Time wait, Time interval)
Create a Hold with mean inter-event time wait , changing workload every interval .
Parse command-line arguments.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Smart pointer class similar to boost::intrusive_ptr.
Periodically print a status message indicating simulator progress.
void SetVerbose(bool verbose)
Set verbose mode to print real and virtual time intervals.
A template-based reference counting class.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
static Time Now()
Return the current simulation virtual time.
static void Run()
Run the simulation.
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Simulation virtual time values and global simulation resolution.
int64_t GetNanoSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
TimeWithUnit As(const Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
High precision numerical type, implementing Q64.64 fixed precision.
int64_t GetHigh() const
Get the integer portion.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Time Seconds(double value)
Construct a Time in the indicated unit.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.