|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
34 #include "ns3/core-module.h"
67 m_interval = interval;
69 m_rng = CreateObject<ExponentialRandomVariable> ();
70 m_rng->SetAttribute (
"Mean",
DoubleValue (m_wait.GetSeconds ()));
85 double delta = m_rng->GetValue ();
93 bool even = (ratio.
GetHigh () % 2);
94 Time work = m_wait * (even ? 3 : 1);
115 main (
int argc,
char ** argv)
123 cmd.AddValue (
"stop",
"Simulation duration in virtual time.", stop);
124 cmd.AddValue (
"interval",
"Approximate reporting interval, in wall clock time.", interval);
125 cmd.AddValue (
"wait",
"Wallclock time to burn on each event.", wait);
126 cmd.AddValue (
"verbose",
"Turn on verbose progress message.",
verbose);
127 cmd.Parse (argc, argv);
130 <<
cmd.GetName () <<
":\n"
132 <<
"verbose progress message: " << (
verbose ?
"on\n" :
"off\n")
133 <<
"target reporting interval: " << interval.
As (
Time::S) <<
"\n"
134 <<
"average event sleep time: " << wait.
As (
Time::MS) <<
"\n"
135 <<
"total simulation run time: " << stop.
As (
Time::S)
138 Ptr<Hold> h = Create<Hold> (wait, interval);
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Parse command-line arguments.
static Time Now(void)
Return the current simulation virtual time.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Time m_wait
Mean inter-event time.
A template-based reference counting class.
Hold(Time wait, Time interval)
Create a Hold with mean inter-event time wait, changing workload every interval.
A class which provides a relatively platform-independent conditional-wait thread synchronization prim...
TimeWithUnit As(const enum Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
High precision numerical type, implementing Q64.64 fixed precision.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
void SetVerbose(bool verbose)
Set verbose mode to print real and virtual time intervals.
Hold(Ptr< RandomVariableStream > rng)
Create a hold with a specified random number generator for the wait time.
static void Stop(void)
Tell the Simulator the calling event should be the last one executed.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Simulation virtual time values and global simulation resolution.
int64_t GetNanoSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Time m_interval
Time between switching workloads.
Ptr< RandomVariableStream > m_rng
The random number generator for the interval between events.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
static void Run(void)
Run the simulation.
Execute a function periodically, which takes more or less time to run.
int64_t GetHigh(void) const
Get the integer portion.
SystemCondition m_condition
Timer to represent workload.
Time Seconds(double value)
Construct a Time in the indicated unit.
static void Destroy(void)
Execute the events scheduled with ScheduleDestroy().
void Event(void)
The Hold event.
Periodically print a status message indicating simulator progress.