52 std::string model_name (
"desTraceFile");
55 std::string arg0 = args[0];
58 std::string jsonFile = model_name +
".json";
70 const char * date = ctime (¤t_time);
71 std::string capture_date (date, 24);
73 m_os.open (jsonFile.c_str ());
74 m_os <<
"{" << std::endl;
75 m_os <<
" \"simulator_name\" : \"ns-3\"," << std::endl;
76 m_os <<
" \"model_name\" : \"" << model_name <<
"\"," << std::endl;
77 m_os <<
" \"capture_date\" : \"" << capture_date <<
"\"," << std::endl;
78 m_os <<
" \"command_line_arguments\" : \"";
79 if (args.size () == 0)
81 for (std::size_t i = 0; i < args.size (); ++i)
83 if (i > 0)
m_os <<
" ";
89 m_os <<
"[argv empty or not available]";
91 m_os <<
"\"," << std::endl;
92 m_os <<
" \"events\" : [" << std::endl;
109 std::vector<std::string> args;
113 std::ostringstream ss;
128 << (now + delay).GetTimeStep () <<
"\"]";
148 m_os <<
" ]" << std::endl;
149 m_os <<
"}" << std::endl;
Simulation virtual time values and global simulation resolution.
static uint32_t GetContext(void)
Get the current simulation context.
std::ofstream m_os
The output JSON trace file stream.
void Close(void)
Close the output file.
ns3::Simulator declaration.
ns3::DesMetrics declaration.
std::list< std::string > Split(std::string path)
Split a file system path into directories according to the local path separator.
ns3::SystemPath declarations.
void Initialize(std::vector< std::string > args, std::string outDir="")
Open the DesMetrics trace file and print the header.
A class which provides a simple way to implement a Critical Section.
~DesMetrics(void)
Destructor, closes the trace file.
char m_separator
The separator between event records.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
SystemMutex m_mutex
Mutex to control access to the output file.
void TraceWithContext(uint32_t context, const Time &now, const Time &delay)
Trace an event (with context) at the time it is scheduled.
bool m_initialized
Have we been initialized.
std::string Append(std::string left, std::string right)
Join two file system path elements.
Flag for events not associated with any particular context.
void Trace(const Time &now, const Time &delay)
Trace an event to self at the time it is scheduled.
static std::string m_outputDir
Cache the last-used output directory.
int64_t GetTimeStep(void) const
Get the raw time value, in the current resolution unit.