86#include "ns3/command-line.h"
88#include "ns3/nstime.h"
89#include "ns3/random-variable-stream.h"
90#include "ns3/simulator.h"
115 std::cout <<
"Replacing time printer function after Simulator::Run ()" << std::endl;
122main(
int argc,
char* argv[])
124 bool replaceTimePrinter =
false;
125 std::string resolution =
"Time::NS";
129 std::map<std::string, Time::Unit> resolutionMap = {
130 {
"Time::US", Time::US},
131 {
"Time::NS", Time::NS},
132 {
"Time::PS", Time::PS},
133 {
"Time::FS", Time::FS},
137 cmd.AddValue(
"replaceTimePrinter",
"replace time printing function", replaceTimePrinter);
138 cmd.AddValue(
"resolution",
"time resolution", resolution);
139 cmd.Parse(argc, argv);
141 auto search = resolutionMap.find(resolution);
142 if (search != resolutionMap.end())
144 Time::SetResolution(search->second);
149 if (replaceTimePrinter)
154 Simulator::Schedule(
NanoSeconds(1), &UniformRandomVariable::SetAntithetic, uniformRv,
false);
155 Simulator::Schedule(
NanoSeconds(123), &UniformRandomVariable::SetAntithetic, uniformRv,
false);
157 &UniformRandomVariable::SetAntithetic,
161 &UniformRandomVariable::SetAntithetic,
166 Simulator::Destroy();
Parse command-line arguments.
double GetSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
Time Now()
create an ns3::Time instance which contains the current simulation time.
Time NanoSeconds(uint64_t value)
Construct a Time in the indicated unit.
Time Seconds(double value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void LogComponentEnable(const std::string &name, LogLevel level)
Enable the logging output associated with that log component.
void LogSetTimePrinter(TimePrinter printer)
Set the TimePrinter function to be used to prepend log messages with the simulation time.
@ LOG_LEVEL_ALL
Print everything.
@ LOG_PREFIX_TIME
Prefix all trace prints with simulation time.
void LogComponentEnableAll(LogLevel level)
Enable the logging output for all registered log components.