Labwork 2 Logging Attribute and Tracing
Labwork 2 Logging Attribute and Tracing
Logging
Code addition
#include "ns3/applications-module.h"
#include "ns3/core-module.h"
#include "ns3/internet-module.h"
#include "ns3/network-module.h"
#include "ns3/point-to-point-module.h"
#include "ns3/log.h" //include the log library
NS_LOG_COMPONENT_DEFINE("FirstScriptExample");
int
main(int argc, char* argv[])
{
CommandLine cmd(__FILE__);
cmd.Parse(argc, argv);
Time::SetResolution(Time::NS);
LogComponentEnable("UdpEchoClientApplication", LOG_LEVEL_INFO);
LogComponentEnable("UdpEchoServerApplication", LOG_LEVEL_INFO);
UdpEchoServerApplication:UdpEchoServer(0x600000b20410)
UdpEchoClientApplication:UdpEchoClient(0x7fb4e8706f60)
UdpEchoClientApplication:SetDataSize(0x7fb4e8706f60, 1024)
UdpEchoServerApplication:StartApplication(0x600000b20410)
UdpEchoClientApplication:StartApplication(0x7fb4e8706f60)
UdpEchoClientApplication:ScheduleTransmit(0x7fb4e8706f60, +0ns)
UdpEchoClientApplication:Send(0x7fb4e8706f60)
At time +2s client sent 1024 bytes to 10.1.1.2 port 9
UdpEchoServerApplication:HandleRead(0x600000b20410, 0x7fb4e8707090)
At time +2.00369s server received 1024 bytes from 10.1.1.1 port 49153
At time +2.00369s server sent 1024 bytes to 10.1.1.1 port 49153
UdpEchoClientApplication:HandleRead(0x7fb4e8706f60, 0x7fb4e8707330)
At time +2.00737s client received 1024 bytes from 10.1.1.2 port 9
UdpEchoClientApplication:StopApplication(0x7fb4e8706f60)
UdpEchoServerApplication:StopApplication(0x600000b20410)
UdpEchoClientApplication:DoDispose(0x7fb4e8706f60)
Editing Attributes
The logging function from last exercise is disabled for better observation
PointToPointHelper pointToPoint;
pointToPoint.SetDeviceAttribute("DataRate", StringValue("10Mbps"));
pointToPoint.SetChannelAttribute("Delay", StringValue("10ms"));
Before After
At time +2s client sent 1024 bytes to 10.1.1 At time +2s client sent 1024 bytes to 10.1.1
At time +2.00369s server received 1024 bytes At time +2.01084s server received 1024 bytes
At time +2.00369s server sent 1024 bytes to 1 At time +2.01084s server sent 1024 bytes to 1
At time +2.00737s client received 1024 bytes At time +2.02169s client received 1024 bytes
Time::SetResolution(Time::NS);
LogComponentEnable("UdpEchoClientApplication", LOG_LEVEL_INFO);
LogComponentEnable("UdpEchoServerApplication", LOG_LEVEL_INFO);
Time::SetResolution(Time::NS);
LogComponentEnable("UdpEchoClientApplication", LOG_LEVEL_INFO);
LogComponentEnable("UdpEchoServerApplication", LOG_LEVEL_INFO);
nPackets=100 nPackets=100
At time +2s client sent 1024 bytes to 10.1.1.2 port 9 At time +2s cli
At time +2.00269s server received 1024 bytes from 10.1.1.1 port 49153 At time +2.0108
At time +2.00269s server sent 1024 bytes to 10.1.1.1 port 49153 At time +2.0108
At time +2.00537s client received 1024 bytes from 10.1.1.2 port 9 At time +2.0216
At time +3s client sent 1024 bytes to 10.1.1.2 port 9 At time +3s cli
At time +3.00269s server received 1024 bytes from 10.1.1.1 port 49153 At time +3.0108
At time +3.00269s server sent 1024 bytes to 10.1.1.1 port 49153 At time +3.0108
At time +3.00537s client received 1024 bytes from 10.1.1.2 port 9 At time +3.0216
At time +4s client sent 1024 bytes to 10.1.1.2 port 9 At time +4s cli
At time +4.00269s server received 1024 bytes from 10.1.1.1 port 49153 At time +4.0108
At time +4.00269s server sent 1024 bytes to 10.1.1.1 port 49153 At time +4.0108
At time +4.00537s client received 1024 bytes from 10.1.1.2 port 9 At time +4.0216
At time +5s client sent 1024 bytes to 10.1.1.2 port 9 At time +5s cli
Result
After editing point-to-point network device and channel attributes to:
at client: 5.37ms
at server: 0.0ms
at client: 21.69ms
at server: 0.0ms
Capture Packet Traces
ASCII Tracing: Output the trace to a text file
“first-0-0.pcap”: packet trace for the first network device on the first node (client node)
“first-1-0.pcap”: packet trace for the first network device on the second node (server node)
Report Results
Set 1: nPackets=100, dataRate=5Mbps, delay=1ms Set 2: nPackets=100, dataRate=10Mbps, delay=10ms