|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
29 NS_OBJECT_ENSURE_REGISTERED (OutputManager);
31 NS_LOG_COMPONENT_DEFINE (
"outputmanager");
37 TypeId (
"ns3::OutputManager")
39 .AddConstructor<OutputManager> ()
40 .AddAttribute (
"OutputPath",
"Path to the directory where output files are stored",
41 StringValue (
"./src/onion_routing_wsn/sim_results/"),
43 MakeStringChecker ());
59 m_simDetails = std::to_string (simNum) +
"," + std::to_string (numNodes) +
",";
96 Ptr<OutputStreamWrapper> StreamWrapper =
110 "---------------------------------Simulation description-----------------------------------\n"
112 <<
"-----------------------------------Simulation "
113 "output--------------------------------------");
116 PrintLine (
"---------------------------------Simulation "
117 "description-----------------------------------\n" +
120 "\n-----------------------------------Simulation "
121 "output--------------------------------------");
130 PrintLine (
"-------------------- Simulation end: " + end_at);
142 std::to_string (
m_onionId) +
"," + std::to_string (packet_size) +
"," +
143 std::to_string (head_size) +
"," + std::to_string (body_size) +
"," +
144 std::to_string (onion_path_len) +
"," + std::to_string (sent_at.GetSeconds ());
146 NS_LOG_INFO (
"--------------- Onion message sent at time: "
147 << std::to_string (sent_at.GetSeconds ()) <<
", with onion id: " <<
m_onionId
148 <<
", onion path length: " << onion_path_len
149 <<
", packet size: " + std::to_string (packet_size) <<
" B, head size: " << head_size
150 <<
" B, body size: " << body_size <<
" B");
160 NS_LOG_INFO (
"--------------- Onion message received back at time :"
161 << std::to_string (recv_at.GetSeconds ()) <<
" with onion id: " <<
m_onionId
162 <<
", onion traveling time: "
163 << std::to_string (recv_at.GetSeconds () -
t_onionDelta));
168 int head_size,
int body_size, Time sent_at)
173 Ipv4ToString (recv_ip) +
"," + std::to_string (packet_size) +
"," +
174 std::to_string (head_size) +
"," + std::to_string (body_size) +
"," +
175 std::to_string (sent_at.GetSeconds ());
178 ", of packet size: " + std::to_string (packet_size) +
179 " B, header size: " + std::to_string (head_size) +
180 " B, trailer size: " + std::to_string (body_size) +
188 std::to_string (recv_at.GetSeconds () -
t_hopDelta);
191 NS_LOG_INFO (
m_routingLog <<
", received at time: " + std::to_string (recv_at.GetSeconds ())
192 <<
", hop traveling time: "
193 << std::to_string (recv_at.GetSeconds () -
t_hopDelta));
201 "," + std::to_string (abort_at.GetSeconds ());
204 NS_LOG_INFO (
"Onion Was aborted at time: " << std::to_string (abort_at.GetSeconds ())
212 NS_LOG_INFO (
"New node, number: " << node_num <<
" ip: " <<
Ipv4ToString (node_ip)
213 <<
" at time: " << std::to_string (recv_at.GetSeconds ()));
220 Ipv4ToString (node_ip) +
"," + std::to_string (coord_x) +
"," +
221 std::to_string (coord_y) +
",null";
229 Ipv4ToString (node_ip) +
"," + std::to_string (coord_x) +
"," +
230 std::to_string (coord_y) +
"," + std::to_string (n_degree);
239 if (reachable.find (x.first) != reachable.end ())
250 *stream << line << std::endl;
256 std::stringstream ss;
264 time_t givemetime = time (NULL);
265 std::string timme = std::string (ctime (&givemetime));
266 return timme.substr (0, timme.length () - 5);
std::string h_onionHeader
header of CSV format
OutputManager()
Default constructor.
void SimulationEnd(std::string end_at)
Print at the end of the simulation.
@ OLSR
Optimized Link State Routing Protocol ns3::Olsr.
void OnionRoutingSend(Ipv4Address send_ip, Ipv4Address recv_ip, int packet_size, int head_size, int body_size, Time sent_at)
Called by each node that sends an onion message.
int m_onionId
identifies the onion message
void OnionRoutingRecv(Time recv_at)
Called by each node that receives an onion message.
void AddNodeDetails(Ipv4Address node_ip, int coord_x, int coord_y)
register node details: IP, location on the network
@ DSR
Dynamic Source Routing ns3::Dsr.
@ DISC
Random disc topology.
void SendOnion(int packet_size, int head_size, int body_size, int onion_path_len, Time sent_at)
Called by the sink node when it sends a new onion message.
void CreateOutputFile()
Create stream wrapper and the output file, if the output file already exists, then delete the content...
std::string Ipv4ToString(Ipv4Address ip)
Convert an IpV4 address to a string.
std::string m_simDetails
holds details of the simulation
std::string m_routingLog
holds data of the onion message traveling from hop to hop
void PrintLine(std::string line)
print the given argument on the csv file
std::string h_routingHeader
header of CSV format
@ DSDV
Destination-Sequenced Distance Vector routing ns3::Dsdv.
std::string CurrentTime(void)
return the current time as a string
std::string m_onionData
holds data of the onion message currently executing in the network
int m_onionPathLength
the onion path length
bool m_printDescription
boolean choice to print the description of the simulation parameters
void PrintIntro(std::string intro)
Print the simulation description containing simulation settings on the csv file or on the console log...
void AbortOnion(Time abort_at)
Called when an onion is deleted.
std::string m_routingData
holds data of the onion message traveling from hop to hop
static TypeId GetTypeId(void)
Register this type.
void PrintNodeDetails(std::map< uint32_t, std::string > reachable)
print node details on the csv file, print only nodes reachable by the sink node
Topology
Enumeration defining different network topologies that can be used in the simulation.
void NewHandshake(int node_num, Ipv4Address node_ip, Time recv_at)
Called when the sink receives a new handhake message.
double t_onionDelta
Hold time information of the onion message traveling in the network.
void RecvOnion(Time recv_at)
Called by the sink node when it receives back the onion message.
std::string m_simName
holds the name of the simulation
enum Routing m_routing
information on the routing protocol
std::map< uint32_t, std::string > m_nodeDetails
holds details of nodes in the network for printing at the end of the csv file.
void SetRouting(enum Routing routing)
set the enum of the current routing algorithm used in the network
@ AODV
Ad Hoc On-Demand Distance Vector ns3::Aodv.
enum Routing GetRouting(void)
return the enum of the current routing algorithm used in the network
std::string h_timeoutHeader
header of CSV format
Routing
Enumeration defining different routing algorithms that can be used in the simulator.
Ptr< OutputStreamWrapper > m_simStreamWrapper
stream wrapper to write on file
~OutputManager()
Default destructor.
std::string m_outputFilePath
path to the directory where output files are stored
double t_hopDelta
Hold time information of the onion message traveling from hop to hop.
std::string h_nodeDetailsHeader
header of CSV format