34 #include "ns3/core-module.h" 58 time_t seconds = time (NULL);
59 diff = seconds - last;
64 std::string now = ctime ( &last );
65 now.resize(now.length () - 1);
85 m_interval = interval;
87 m_rng = CreateObject<ExponentialRandomVariable> ();
98 double delta = m_rng->GetValue ();
106 bool even = (ratio.
GetHigh () % 2);
107 Time work = m_wait * (even ? 3 : 1);
124 main (
int argc,
char ** argv)
132 cmd.AddValue (
"stop",
"Simulation duration in virtual time.", stop);
133 cmd.AddValue (
"interval",
"Approximate reporting interval, in wall clock time.", interval);
134 cmd.AddValue (
"wait",
"Wallclock time to burn on each event.", wait);
135 cmd.AddValue (
"verbose",
"Turn on verbose progress message.",
verbose);
136 cmd.Parse (argc, argv);
139 <<
cmd.GetName () <<
":\n" 141 <<
"verbose progress message: " << (
verbose ?
"on\n" :
"off\n")
142 <<
"target reporting interval: " << interval.
As (
Time::S) <<
"\n" 143 <<
"average event sleep time: " << wait.
As (
Time::MS) <<
"\n" 144 <<
"total simulation run time: " << stop.
As (
Time::S)
147 Ptr<Hold> h = Create<Hold> (wait, interval);
157 std::cout << std::endl;
158 std::cout <<
"Start wall clock: " << ts.string ()
159 <<
" (" << ts.last <<
")" 165 std::cout <<
"Elapsed wall clock: " << ts.diff <<
"s" << std::endl;
Simulation virtual time values and global simulation resolution.
Periodically print a status message indicating simulator progress.
Hold(Time wait, Time interval)
High precision numerical type, implementing Q64.64 fixed precision.
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
static void Run(void)
Run the simulation.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
A class which provides a relatively platform-independent conditional-wait thread synchronization prim...
TimeWithUnit As(const enum Unit unit) const
Attach a unit to a Time, to facilitate output in a specific unit.
void SetVerbose(bool verbose)
Set verbose mode to print real and virtual time intervals.
Hold(Ptr< RandomVariableStream > rng)
static EventId Schedule(Time const &delay, MEM mem_ptr, OBJ obj)
Schedule an event to expire after delay.
Parse command-line arguments.
static void Destroy(void)
Execute the events scheduled with ScheduleDestroy().
SystemCondition m_condition
Every class exported by the ns3 library is enclosed in the ns3 namespace.
int64_t GetNanoSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
static Time Now(void)
Return the current simulation virtual time.
NS_LOG_LOGIC("Net device "<< nd<< " is not bridged")
static void Stop(void)
Tell the Simulator the calling event should be the last one executed.
Time Seconds(double value)
Construct a Time in the indicated unit.
Ptr< RandomVariableStream > m_rng
Execute a function periodically.
This class can be used to hold variables of floating point type such as 'double' or 'float'...
A template-based reference counting class.
int64_t GetHigh(void) const
Get the integer portion.