87#include "ns3/simulator.h"
88#include "ns3/nstime.h"
89#include "ns3/command-line.h"
91#include "ns3/random-variable-stream.h"
115 std::cout <<
"Replacing time printer function after Simulator::Run ()" << std::endl;
123int main (
int argc,
char *argv[])
125 bool replaceTimePrinter =
false;
126 std::string resolution =
"Time::NS";
130 std::map<std::string, Time::Unit> resolutionMap = {{
"Time::US", Time::US}, {
"Time::NS", Time::NS}, {
"Time::PS", Time::PS}, {
"Time::FS", Time::FS}};
133 cmd.AddValue (
"replaceTimePrinter",
"replace time printing function", replaceTimePrinter);
134 cmd.AddValue (
"resolution",
"time resolution", resolution);
135 cmd.Parse (argc, argv);
137 auto search = resolutionMap.find (resolution);
138 if (search != resolutionMap.end ())
140 Time::SetResolution (search->second);
145 if (replaceTimePrinter)
150 Simulator::Schedule (
NanoSeconds (1), &UniformRandomVariable::SetAntithetic, uniformRv,
false);
151 Simulator::Schedule (
NanoSeconds (123), &UniformRandomVariable::SetAntithetic, uniformRv,
false);
152 Simulator::Schedule (
NanoSeconds (123456), &UniformRandomVariable::SetAntithetic, uniformRv,
false);
153 Simulator::Schedule (
NanoSeconds (123456789), &UniformRandomVariable::SetAntithetic, uniformRv,
false);
156 Simulator::Destroy ();
Parse command-line arguments.
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Time Now(void)
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 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 LogComponentEnable(char const *name, enum LogLevel level)
Enable the logging output associated with that log component.
void LogComponentEnableAll(enum LogLevel level)
Enable the logging output for all registered log components.