Difference between revisions of "Ns-3-Network-Simulator/C2/Network-performance-Analysis/English"

From Script | Spoken-Tutorial
Jump to: navigation, search
(Created page with " {| border="1" |- || '''Visual Cue''' || '''Narration''' |- || '''Slide:1''' '''Welcome''' || Welcome to the spoken tutorial on '''Analyzing network performance in ns-3.''...")
 
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
 
 
  
 
{| border="1"
 
{| border="1"
Line 12: Line 9:
 
'''Welcome'''
 
'''Welcome'''
 
|| Welcome to the spoken tutorial on '''Analyzing network performance in ns-3.'''
 
|| Welcome to the spoken tutorial on '''Analyzing network performance in ns-3.'''
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Show slide:
 
|| Show slide:
  
 
'''Learning Outcomes'''
 
'''Learning Outcomes'''
 
|| In this tutorial, we will learn to
 
|| In this tutorial, we will learn to
* <div style="margin-left:1.27cm;margin-right:0cm;">Use trace sources</div>
+
* Use trace sources
* <div style="margin-left:1.27cm;margin-right:0cm;">Create callback functions</div>
+
* Create callback functions
* <div style="margin-left:1.27cm;margin-right:0cm;">Connect trace sources to callback functions and</div>
+
* Connect trace sources to callback functions and
* <div style="margin-left:1.27cm;margin-right:0cm;">Calculate network parameters using trace sources</div>
+
* Calculate network parameters using trace sources
  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Show slide:  
 
|| Show slide:  
  
 
'''System Requirements'''
 
'''System Requirements'''
 
|| To record this tutorial, I am using
 
|| To record this tutorial, I am using
* <div style="margin-left:1.27cm;margin-right:0cm;">'''Ubuntu''' '''Linux Operating system version''' '''22.04'''</div>
+
* '''Ubuntu''' '''Linux Operating system version''' '''22.04'''
* <div style="margin-left:1.27cm;margin-right:0cm;">'''ns-3.38'''</div>
+
* '''ns-3.38'''
* <div style="margin-left:1.27cm;margin-right:0cm;">'''NetAnim '''visualizer tool</div>
+
* '''NetAnim '''visualizer tool
  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Show slide:
 
|| Show slide:
  
Line 38: Line 35:
 
[https://spoken-tutorial.org/ https://spoken-tutorial.org]
 
[https://spoken-tutorial.org/ https://spoken-tutorial.org]
 
|| To follow this tutorial,
 
|| To follow this tutorial,
* <div style="margin-left:1.27cm;margin-right:0cm;">You must have basic knowledge of using Linux terminal</div>
+
* You must have basic knowledge of using Linux terminal
  
* <div style="margin-left:1.27cm;margin-right:0cm;">You must know how to create a '''point-to-point '''network in '''ns-3'''</div>
+
* You must know how to create '''point-to-point '''network in '''ns-3'''
* <div style="margin-left:1.27cm;margin-right:0cm;">For pre-requisite Linux and '''ns-3''' tutorials, please visit this website</div>
+
* For pre-requisite Linux and '''ns-3''' tutorials, please visit this website
  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Show slide:
 
|| Show slide:
  
 
'''Code files'''
 
'''Code files'''
 
||
 
||
* <div style="margin-left:1.27cm;margin-right:0cm;">The files used in this tutorial are provided in the '''Code files''' link</div>
+
* The files used in this tutorial are provided in the '''Code files''' link
* <div style="margin-left:1.27cm;margin-right:0cm;">Please download and extract the files</div>
+
* Please download and extract the files
* <div style="margin-left:1.27cm;margin-right:0cm;">Make a copy and then use them while practising</div>
+
* Make a copy and then use them while practicing
  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Show diagram''':'''
 
|| Show diagram''':'''
  
 
'''Point-to-Point network with two nodes'''
 
'''Point-to-Point network with two nodes'''
 
|| For this tutorial, we would be creating the following topology:
 
|| For this tutorial, we would be creating the following topology:
* <div style="margin-left:1.27cm;margin-right:0cm;">A '''point-to-point''' network with address 10.1.1.0</div>
+
* A '''point-to-point''' network with address 10.1.1.0
  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Open the file '''network_performance.cc '''in the text editor.
 
|| Open the file '''network_performance.cc '''in the text editor.
 
|| I have created the source file '''network_performance.cc''' for this program.
 
|| I have created the source file '''network_performance.cc''' for this program.
Line 66: Line 63:
  
 
The source code contains the required functions to analyse network performance.
 
The source code contains the required functions to analyse network performance.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''double node0_trans_time'''
 
|| Highlight '''double node0_trans_time'''
 
|| First we declare the variables.
 
|| First we declare the variables.
Line 73: Line 70:
  
 
'''node0_trans_time''' holds the transmission time for node 0.
 
'''node0_trans_time''' holds the transmission time for node 0.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''node1_rec_time'''
 
|| Highlight '''node1_rec_time'''
 
|| '''node1_rec_time '''holds the packet receiving time for node 1.
 
|| '''node1_rec_time '''holds the packet receiving time for node 1.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''node0_rec_time'''
 
|| Highlight '''node0_rec_time'''
|| '''Node0_rec_time '''is the time at which node 0 receives the echo packet from node 1.
+
|| '''Node0_rec_time ''' is the time at which node 0 receives the echo packet from node 1.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''round_trip_time <nowiki>= 0.0</nowiki>'''
 
|| Highlight '''round_trip_time <nowiki>= 0.0</nowiki>'''
|| '''round_trip_time '''holds the round-trip packet time.
+
|| '''round_trip_time ''' holds the round-trip packet time.
  
 
That is, the time taken to go from node 0 to node 1 and return.
 
That is, the time taken to go from node 0 to node 1 and return.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''total_delay = 0.0'''
 
|| Highlight '''total_delay = 0.0'''
|| '''total_delay '''holds the sum of all delays.
+
|| '''total_delay ''' holds the sum of all delays.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''prop_delay = 6560.0'''
 
|| Highlight '''prop_delay = 6560.0'''
|| '''prop_delay '''is the propagation delay of the channel.
+
|| '''prop_delay ''' is the propagation delay of the channel.
  
 
It is set by us.
 
It is set by us.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''throughput = 0.0'''
 
|| Highlight '''throughput = 0.0'''
 
|| '''throughput '''holds the throughput of the network.
 
|| '''throughput '''holds the throughput of the network.
  
 
It is the rate of packet delivery.
 
It is the rate of packet delivery.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''trans_delay = 0.0'''
 
|| Highlight '''trans_delay = 0.0'''
 
|| '''trans_delay '''holds''' '''the transmission delay of a packet.
 
|| '''trans_delay '''holds''' '''the transmission delay of a packet.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''RxTraceClient(std::string context, Ptr<const Packet> p)'''
 
|| Highlight '''RxTraceClient(std::string context, Ptr<const Packet> p)'''
 
|| '''RxTraceClient '''is a '''callback function'''.
 
|| '''RxTraceClient '''is a '''callback function'''.
Line 110: Line 107:
 
We shall explain trace sources later in this tutorial.
 
We shall explain trace sources later in this tutorial.
  
Here the traced source is Rx.
+
Here the traced source is '''Rx'''.
  
 
The second argument is the packet received.
 
The second argument is the packet received.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''node0_rec_time = Simulator::Now().GetSeconds()'''
 
|| Highlight '''node0_rec_time = Simulator::Now().GetSeconds()'''
 
|| In the function, we will update the value of '''node0_rec_time '''variable.
 
|| In the function, we will update the value of '''node0_rec_time '''variable.
Line 119: Line 116:
 
Here, we set the value of the current time.
 
Here, we set the value of the current time.
  
The current time is found using the '''GetSeconds '''method.
+
The current time is found using the '''GetSeconds ''' method.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight''' round_trip_time'''
 
|| Highlight''' round_trip_time'''
 
|| Similarly, we update the value of the '''round_trip_time '''variable.
 
|| Similarly, we update the value of the '''round_trip_time '''variable.
Line 129: Line 126:
  
 
The '''node0_trans_time '''variable would be updated in the '''TxTraceClient '''function.
 
The '''node0_trans_time '''variable would be updated in the '''TxTraceClient '''function.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''round_cnt++'''
 
|| Highlight '''round_cnt++'''
 
 
|| Next, we increment the value of the '''round_cnt''' variable by 1.
 
|| Next, we increment the value of the '''round_cnt''' variable by 1.
  
 
We do so, to keep a track of the number of round-trips.
 
We do so, to keep a track of the number of round-trips.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''TxTraceClient'''
 
|| Highlight '''TxTraceClient'''
 
|| '''TxTraceClient '''is a callback function.
 
|| '''TxTraceClient '''is a callback function.
Line 144: Line 140:
  
 
The second argument is the receive packet.
 
The second argument is the receive packet.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
|| Highlight <span style="color:#24292e;">'''node0_trans_time'''</span>
+
|| Highlight '''node0_trans_time'''
 
|| In the function, we set the value of '''node0_trans_time.'''
 
|| In the function, we set the value of '''node0_trans_time.'''
  
 
The value is the time at which transmission starts.
 
The value is the time at which transmission starts.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''RxTraceServer'''
 
|| Highlight '''RxTraceServer'''
 
|| The last callback function is '''RxTraceServer.'''
 
|| The last callback function is '''RxTraceServer.'''
Line 158: Line 154:
  
 
The second argument is the received packet.
 
The second argument is the received packet.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''node1_rec_time = Simulator::Now().GetSeconds()'''
 
|| Highlight '''node1_rec_time = Simulator::Now().GetSeconds()'''
 
|| Here we set the receiving time to the current time in seconds.
 
|| Here we set the receiving time to the current time in seconds.
  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''total_delay += (node1_rec_time - node0_trans_time)*1000'''
 
|| Highlight '''total_delay += (node1_rec_time - node0_trans_time)*1000'''
 
|| Then, we set the '''total_delay''' variable, which stores the total delay.
 
|| Then, we set the '''total_delay''' variable, which stores the total delay.
Line 173: Line 169:
  
 
The value is multiplied by 1000 to get the unit in milliseconds.
 
The value is multiplied by 1000 to get the unit in milliseconds.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''trans_delay += ((node1_rec_time - node0_trans_time)*1000 - prop_delay/1000000)'''
 
|| Highlight '''trans_delay += ((node1_rec_time - node0_trans_time)*1000 - prop_delay/1000000)'''
 
|| Next, we compute the value of '''transmission delay'''.
 
|| Next, we compute the value of '''transmission delay'''.
Line 181: Line 177:
 
The propagation delay value is in nanoseconds, hence we divide it by 1000000.
 
The propagation delay value is in nanoseconds, hence we divide it by 1000000.
  
This converts it into milliseconds.
+
This converts it to milliseconds.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''pkt_cnt++'''
 
|| Highlight '''pkt_cnt++'''
 
|| Next we increment the packet count.
 
|| Next we increment the packet count.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''if (pkt_cnt == pkts)'''
 
|| Highlight '''if (pkt_cnt == pkts)'''
 
|| Finally we compare the value of packet count to the total packets.
 
|| Finally we compare the value of packet count to the total packets.
Line 192: Line 188:
  
 
If this is the last packet, we print all the parameters.
 
If this is the last packet, we print all the parameters.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''NS_LOG_UNCOND'''
 
|| Highlight '''NS_LOG_UNCOND'''
 
|| Using the '''NS_LOG_UNCOND '''function, we print the parameters to the terminal.
 
|| Using the '''NS_LOG_UNCOND '''function, we print the parameters to the terminal.
  
 
We print the parameters:
 
We print the parameters:
* <div style="margin-left:1.27cm;margin-right:0cm;">End-to-end delay</div>
+
* End-to-end delay
* <div style="margin-left:1.27cm;margin-right:0cm;">Transmission delay</div>
+
* Transmission delay
* <div style="margin-left:1.27cm;margin-right:0cm;">Throughput</div>
+
* Throughput
* <div style="margin-left:1.27cm;margin-right:0cm;">Propagation delay (constant)</div>
+
* Propagation delay (constant)
  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''total_delay/(p->GetSize()*pkts'''
 
|| Highlight '''total_delay/(p->GetSize()*pkts'''
 
|| '''Throughput '''is calculated as total delay divided by total data size.
 
|| '''Throughput '''is calculated as total delay divided by total data size.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''nodes.Create(2)'''
 
|| Highlight '''nodes.Create(2)'''
 
 
|| Let’s move to the main function now.
 
|| Let’s move to the main function now.
  
 
For the topology, we create a '''point-to-point''' network with two nodes.
 
For the topology, we create a '''point-to-point''' network with two nodes.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''SetDeviceAttribute'''
 
|| Highlight '''SetDeviceAttribute'''
 
|| The '''data rate''' for the device is 100 Mbps.
 
|| The '''data rate''' for the device is 100 Mbps.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''SetChannelAttribute'''
 
|| Highlight '''SetChannelAttribute'''
 
|| The '''propagation delay''' is set to 6560 nanoseconds.
 
|| The '''propagation delay''' is set to 6560 nanoseconds.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''address.SetBase("10.1.1.0", "255.255.255.0")'''
 
|| Highlight '''address.SetBase("10.1.1.0", "255.255.255.0")'''
 
|| The base address of the network is 10.1.1.0.
 
|| The base address of the network is 10.1.1.0.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''UdpEchoServerHelper echoServer(9)'''
 
|| Highlight '''UdpEchoServerHelper echoServer(9)'''
 
|| Next we create a UDP echo server with port address 9.
 
|| Next we create a UDP echo server with port address 9.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''echoServer.Install(nodes.Get(1))'''
 
|| Highlight '''echoServer.Install(nodes.Get(1))'''
 
|| The echo server application is installed on the second node.
 
|| The echo server application is installed on the second node.
  
 
The index of the node is 1.
 
The index of the node is 1.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''serverApps.Start(Seconds(1.0))'''
 
|| Highlight '''serverApps.Start(Seconds(1.0))'''
 
|| Here we set the start time of the server applications to 1 second.
 
|| Here we set the start time of the server applications to 1 second.
  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''serverApps.Stop(Seconds(10.0))'''
 
|| Highlight '''serverApps.Stop(Seconds(10.0))'''
 
|| Similarly, we set the stop time to 10 seconds.
 
|| Similarly, we set the stop time to 10 seconds.
  
 
Both the times are from the start of the simulation.
 
Both the times are from the start of the simulation.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''echoClient(interfaces.GetAddress(1), 9)'''
 
|| Highlight '''echoClient(interfaces.GetAddress(1), 9)'''
 
|| Then we create an echo client application with destination port 9.
 
|| Then we create an echo client application with destination port 9.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''SetAttribute'''
 
|| Highlight '''SetAttribute'''
 
|| Using the '''SetAttribute '''method we set the following attributes for the client.
 
|| Using the '''SetAttribute '''method we set the following attributes for the client.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''MaxPackets'''
 
|| Highlight '''MaxPackets'''
 
|| The maximum number of packets is 10.
 
|| The maximum number of packets is 10.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''Interval'''
 
|| Highlight '''Interval'''
 
|| The time interval between packet transmissions is 0.5 seconds.
 
|| The time interval between packet transmissions is 0.5 seconds.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''PacketSize'''
 
|| Highlight '''PacketSize'''
 
|| The packet size is 1024 bytes.
 
|| The packet size is 1024 bytes.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''echoClient.Install(nodes.Get(0))'''
 
|| Highlight '''echoClient.Install(nodes.Get(0))'''
 
|| The echo client application is installed on the first node.
 
|| The echo client application is installed on the first node.
  
 
The index of the node is 0.
 
The index of the node is 0.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''clientApps.Start(Seconds(2.0))'''
 
|| Highlight '''clientApps.Start(Seconds(2.0))'''
 
|| The start time of the client apps is set to 2 seconds.
 
|| The start time of the client apps is set to 2 seconds.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''clientApps.Stop(Seconds(10.0))'''
 
|| Highlight '''clientApps.Stop(Seconds(10.0))'''
 
|| The stop time is 10 seconds.
 
|| The stop time is 10 seconds.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''Config::Connect'''
 
|| Highlight '''Config::Connect'''
 
 
|| Using the connect method, we connect trace sources to callback functions.
 
|| Using the connect method, we connect trace sources to callback functions.
  
Line 274: Line 268:
 
These are used in conjunction with trace sources.
 
These are used in conjunction with trace sources.
  
'''Trace sources '''are entities that signal events in an ns-3 program.
+
'''Trace sources ''' are entities that signal events in an ns-3 program.
  
 
These events include packet transmission, change in window size etc.
 
These events include packet transmission, change in window size etc.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''UdpEchoClient/Tx'''
 
|| Highlight '''UdpEchoClient/Tx'''
 
 
|| This program uses three trace sources.
 
|| This program uses three trace sources.
  
Line 285: Line 278:
  
 
It traces the transmission of a packet by an echo client application.
 
It traces the transmission of a packet by an echo client application.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''UdpEchoClient/Rx'''
 
|| Highlight '''UdpEchoClient/Rx'''
|| The second trace source is '''Rx, '''of the '''UdpEchoClient '''class.
+
|| The second trace source is '''Rx''', of the '''UdpEchoClient '''class.
  
 
It traces the reception of a packet by an echo client application.
 
It traces the reception of a packet by an echo client application.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''UdpEchoServer/Rx'''
 
|| Highlight '''UdpEchoServer/Rx'''
 
+
|| The last trace source is '''Rx ''', of the '''UdpEchoServer '''class.
|| The last trace source is '''Rx, '''of the '''UdpEchoServer '''class.
+
  
 
It traces the reception of a packet by an echo server application.
 
It traces the reception of a packet by an echo server application.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
|| Highlight <span style="background-color:#ffffff;">'''AnimationInterface anim ("network_performance.xml");'''</span>
+
|| Highlight '''AnimationInterface anim ("network_performance.xml");'''
  
|| Next we create an '''AnimationInterface '''object, '''anim, '''for '''NetAnim '''animation.
+
|| Next we create an '''AnimationInterface '''object, '''anim''', for '''NetAnim''' animation.
  
 
The parameter for the constructor is the name of the XML animation file.
 
The parameter for the constructor is the name of the XML animation file.
Line 306: Line 298:
  
 
Here the name of the file is '''network_performance.xml'''.
 
Here the name of the file is '''network_performance.xml'''.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
|| <span style="color:#24292e;">Highlight </span>'''anim.SetConstantPosition'''
+
|| Highlight '''anim.SetConstantPosition'''
|| Then set the positions for the nodes using the '''SetConstantPosition '''function.  
+
|| Then set the positions for the nodes using the '''SetConstantPosition ''' function.  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''Simulator::Run()'''
 
|| Highlight '''Simulator::Run()'''
 
|| The '''Run '''function is used to run the simulation.
 
|| The '''Run '''function is used to run the simulation.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''Simulator::Destroy()'''
 
|| Highlight '''Simulator::Destroy()'''
|| The '''Destroy '''function ends the simulation.
+
|| The '''Destroy ''' function ends the simulation.
  
 
Close the text editor.
 
Close the text editor.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
||  
+
|| Press Ctrl, Alt and T keys simultaneously.
 
+
Press Ctrl,Alt and T keys simultaneously.
+
  
 
Type '''cd ns-allinone-3.38/ns-3.38 '''to navigate to the ns3 installation directory
 
Type '''cd ns-allinone-3.38/ns-3.38 '''to navigate to the ns3 installation directory
  
 
Type '''mv ~/Downloads/network_performance.cc scratch/network_performance.cc '''to move the source file to '''scratch '''directory.
 
Type '''mv ~/Downloads/network_performance.cc scratch/network_performance.cc '''to move the source file to '''scratch '''directory.
|| <div style="color:#000000;">Now we will observe the simulation. </div>
+
|| Now we will observe the simulation.  
  
<div style="color:#000000;">Open a terminal by pressing Ctrl, Alt and T keys simultaneously.</div>
+
Open a terminal by pressing Ctrl, Alt and T keys simultaneously.
  
<div style="color:#000000;">Using the '''cd '''command, navigate to the installation directory of '''ns-3'''.</div>
+
Using the '''cd '''command, navigate to the installation directory of '''ns-3'''.
  
<div style="color:#000000;">Go to the '''ns-3.38''' directory.</div>
+
Go to the '''ns-3.38''' directory.
  
<div style="color:#000000;">Move your source file to the '''scratch '''directory within the '''ns-3.38''' directory. </div>
+
Move your source file to the '''scratch ''' directory within the '''ns-3.38''' directory.  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Type ./'''ns3 run scratch/network_performance.cc'''
 
|| Type ./'''ns3 run scratch/network_performance.cc'''
|| <div style="color:#000000;">Run the command '''dot forward slash''' '''ns3 run space scratch forward slash network underscore performance dot cc.'''</div>
+
|| Run the command '''dot forward slash ns3 run space scratch forward slash network '''underscore performance dot cc'''
  
<div style="color:#000000;">'''network underscore performance '''is the name of the source file. </div>
+
'''network underscore performance '''is the name of the source file.  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Keep the terminal open and show the output of the command  
 
|| Keep the terminal open and show the output of the command  
|| After compilation, we get the network parameters. The parameters are
+
|| After compilation, we get the network parameters.  
* <div style="color:#000000;margin-left:1.27cm;margin-right:0cm;">'''End-to-end delay'''</div>
+
* <div style="color:#000000;margin-left:1.27cm;margin-right:0cm;">'''Transmission delay'''</div>
+
* <div style="color:#000000;margin-left:1.27cm;margin-right:0cm;">'''Throughput '''and</div>
+
* <div style="color:#000000;margin-left:1.27cm;margin-right:0cm;">'''Round trip time'''</div>
+
  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
The parameters are
 +
* '''End-to-end delay'''
 +
* '''Transmission delay'''
 +
* '''Throughput '''and
 +
* '''Round trip time'''
 +
 
 +
|-  
 
|| Type '''cd ~/ns-allinone-3.38/netanim'''
 
|| Type '''cd ~/ns-allinone-3.38/netanim'''
 
|| Now, to visualise the network, we will use NetAnim.  
 
|| Now, to visualise the network, we will use NetAnim.  
  
 
Navigate to the '''netanim '''directory under '''ns-allinone-3.38.'''
 
Navigate to the '''netanim '''directory under '''ns-allinone-3.38.'''
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Type ./'''NetAnim'''
 
|| Type ./'''NetAnim'''
|| Now type '''dot forward slash NetAnim. '''The NetAnim window will open.
+
|| Now type '''dot forward slash NetAnim'''.  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
 
|| Click on the '''Open XML trace file '''icon on the top left corner of the window.
+
The '''NetAnim'''' window will open.
 +
|-
 
|| Click on the '''Open XML trace file '''icon on the top left corner of the window.
 
|| Click on the '''Open XML trace file '''icon on the top left corner of the window.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|| Click on the '''Open XML trace file ''' icon on the top left corner of the window.
 +
|-  
 
|| In the file picker, navigate to the '''ns-allinone-3.38/ns-3.38 '''directory and select the '''network_performance.xml '''file.
 
|| In the file picker, navigate to the '''ns-allinone-3.38/ns-3.38 '''directory and select the '''network_performance.xml '''file.
|| In the file picker, navigate to the '''ns-3.38 '''directory.
+
|| In the file picker, navigate to the '''ns-3.38 ''' directory.
  
Select the '''network_performance.xml '''file.
+
Select the '''network_performance.xml ''' file.
  
 
The file would be generated by the program.
 
The file would be generated by the program.
  
 
You can also download the file from '''Code Files''' section.
 
You can also download the file from '''Code Files''' section.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| On the toolbar, click on the '''Node Size '''drop down button, and select size 10.
 
|| On the toolbar, click on the '''Node Size '''drop down button, and select size 10.
|| On the toolbar, click on the '''Node Size '''drop down button.
+
|| On the toolbar, click on the '''Node Size ''' drop down button.
  
 
Select size 10.
 
Select size 10.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| On the toolbar, click on the play button
 
|| On the toolbar, click on the play button
 
|| On the toolbar, click on the play button to view the simulation.
 
|| On the toolbar, click on the play button to view the simulation.
Line 379: Line 373:
  
 
The lines with arrows represent the transfer of packets.
 
The lines with arrows represent the transfer of packets.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Hover over node 0 and node 1 circles.
 
|| Hover over node 0 and node 1 circles.
 
|| We see the packets moving from node 0 to node 1.
 
|| We see the packets moving from node 0 to node 1.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Show slide:  
 
|| Show slide:  
  
 
'''Summary'''
 
'''Summary'''
|| This brings us to the end of the tutorial. Let us summarise.
+
|| This brings us to the end of the tutorial.  
 +
 
 +
Let us summarise.
  
 
In this tutorial, we have learnt to
 
In this tutorial, we have learnt to
* <div style="margin-left:1.27cm;margin-right:0cm;">Use trace sources</div>
+
* Use trace sources
* <div style="margin-left:1.27cm;margin-right:0cm;">Create callback functions</div>
+
* Create callback functions
* <div style="margin-left:1.27cm;margin-right:0cm;">Connect trace sources to callback functions</div>
+
* Connect trace sources to callback functions
* <div style="margin-left:1.27cm;margin-right:0cm;">Calculate network parameters using trace sources</div>
+
* Calculate network parameters using trace sources
  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Show slide:
 
|| Show slide:
  
 
'''Assignment'''
 
'''Assignment'''
|| As an assignment, please do the following:* <div style="margin-left:1.27cm;margin-right:0cm;"><span style="background-color:#ffffff;">Create a </span><span style="background-color:#ffffff;">'''Point-to-Point '''</span><span style="background-color:#ffffff;">network with 3 nodes</span></div>
+
|| As an assignment, please do the following:
* <div style="margin-left:1.27cm;margin-right:0cm;">Send packets from node 0 to node 2</div>
+
* Create a '''Point-to-Point '''network with 3 nodes
* <div style="margin-left:1.27cm;margin-right:0cm;"><span style="background-color:#ffffff;">Calculate </span><span style="background-color:#ffffff;">'''throughput '''</span><span style="background-color:#ffffff;">and</span><span style="background-color:#ffffff;">''' transmission delay'''</span></div>
+
* Send packets from node 0 to node 2
 +
* Calculate '''throughput ''' and''' transmission delay'''
  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Show slide:
 
|| Show slide:
  
Line 411: Line 408:
  
 
These parameters include packet size, propagation delay and data rate.
 
These parameters include packet size, propagation delay and data rate.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Show slide:  
 
|| Show slide:  
  
 
'''About the Spoken Tutorial Project'''
 
'''About the Spoken Tutorial Project'''
|| <span style="background-color:#ffffff;">The video at the following link summarises the </span><span style="background-color:#ffffff;">'''Spoken Tutorial project'''</span><span style="background-color:#ffffff;">.</span>
+
|| The video at the following link summarises the '''Spoken Tutorial project'''.
  
 
Please download and watch it.
 
Please download and watch it.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Show Slide:
 
|| Show Slide:
  
<span style="background-color:#ffffff;color:#252525;">'''Spoken Tutorial Workshops'''</span>
+
'''Spoken Tutorial Workshops'''  
|| <span style="background-color:#ffffff;">The </span><span style="background-color:#ffffff;">'''Spoken Tutorial Project'''</span><span style="background-color:#ffffff;"> team conducts workshops and gives certificates.</span>
+
|| The '''Spoken Tutorial Project''' team conducts workshops and gives certificates.
  
 
For more details, please write to us.
 
For more details, please write to us.
|- style="border:0.75pt solid #808080;padding:0.176cm;"
+
|-  
|| <div style="color:#252525;">Show Slide:</div>
+
|| Show Slide:
  
<div style="color:#252525;">'''Answers for THIS Spoken Tutorial'''</div>
+
'''Answers for THIS Spoken Tutorial'''
| style="color:#252525;" | Post your timed queries in this forum.
+
||Post your timed queries in this forum.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
|| <div style="color:#252525;">Show Slide:</div>
+
|| Show Slide:
  
<div style="color:#252525;">'''FOSSEE Forum'''</div>
+
'''FOSSEE Forum'''
|| <span style="background-color:#ffffff;">For any general or technical questions on </span><span style="background-color:#ffffff;">'''ns-3'''</span><span style="background-color:#ffffff;">, visit the</span><span style="background-color:#ffffff;">''' FOSSEE forum'''</span><span style="background-color:#ffffff;"> and post your question.</span>
+
|| For any general or technical questions on '''ns-3''', visit the''' FOSSEE forum''' and post your question.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Show slide
 
|| Show slide
  
 
'''Acknowledgement'''
 
'''Acknowledgement'''
|| <span style="color:#252525;">'''Spoken Tutorial'''</span><span style="color:#252525;"> Project was established by the </span><span style="color:#252525;">'''Ministry of Education, Government of India'''</span><span style="color:#252525;">.</span>
+
|| '''Spoken Tutorial''' Project was established by the '''Ministry of Education, Government of India'''.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Show slide
 
|| Show slide
  
 
'''Acknowledgement'''
 
'''Acknowledgement'''
|| <span style="color:#252525;">We thank </span><span style="color:#252525;">'''Dr.Moyukh Laha'''</span><span style="color:#252525;"> from </span><span style="color:#252525;">'''IIT Kharagpur'''</span><span style="color:#252525;"> for his </span><span style="color:#252525;">domain support.</span>
+
|| We thank '''Dr.Moyukh Laha''' from '''IIT Kharagpur''' for his domain support.
  
<span style="color:#252525;">We would also like to thank </span><span style="color:#252525;">'''Dr. R. Radha, Dr. X. Anita, and Dr. T. Subbulakshmi '''</span><span style="color:#252525;">from</span><span style="color:#252525;">''' VIT, Chennai '''</span><span style="color:#252525;">for their support.</span>
+
We would also like to thank '''Dr. R. Radha, Dr. X. Anita, and Dr. T. Subbulakshmi ''' from''' VIT, Chennai '''for their support.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Show slide:
 
|| Show slide:
  
 
'''Thank You'''
 
'''Thank You'''
|| <span style="background-color:#ffffff;">This is</span><span style="background-color:#ffffff;">''' Josiga, '''</span><span style="background-color:#ffffff;">a FOSSEE summer fellow 2023, IIT Bombay signing off.</span>
+
|| This is''' Josiga, '''a FOSSEE summer fellow 2023, IIT Bombay signing off.
  
  

Latest revision as of 13:00, 4 March 2024

Visual Cue Narration
Slide:1

Welcome

Welcome to the spoken tutorial on Analyzing network performance in ns-3.
Show slide:

Learning Outcomes

In this tutorial, we will learn to
  • Use trace sources
  • Create callback functions
  • Connect trace sources to callback functions and
  • Calculate network parameters using trace sources
Show slide:

System Requirements

To record this tutorial, I am using
  • Ubuntu Linux Operating system version 22.04
  • ns-3.38
  • NetAnim visualizer tool
Show slide:

Prerequisite

https://spoken-tutorial.org

To follow this tutorial,
  • You must have basic knowledge of using Linux terminal
  • You must know how to create point-to-point network in ns-3
  • For pre-requisite Linux and ns-3 tutorials, please visit this website
Show slide:

Code files

  • The files used in this tutorial are provided in the Code files link
  • Please download and extract the files
  • Make a copy and then use them while practicing
Show diagram:

Point-to-Point network with two nodes

For this tutorial, we would be creating the following topology:
  • A point-to-point network with address 10.1.1.0
Open the file network_performance.cc in the text editor. I have created the source file network_performance.cc for this program.

Now we will go through the source code in the text editor.

The source code contains the required functions to analyse network performance.

Highlight double node0_trans_time First we declare the variables.

These variables shall hold the network parameters.

node0_trans_time holds the transmission time for node 0.

Highlight node1_rec_time node1_rec_time holds the packet receiving time for node 1.
Highlight node0_rec_time Node0_rec_time is the time at which node 0 receives the echo packet from node 1.
Highlight round_trip_time = 0.0 round_trip_time holds the round-trip packet time.

That is, the time taken to go from node 0 to node 1 and return.

Highlight total_delay = 0.0 total_delay holds the sum of all delays.
Highlight prop_delay = 6560.0 prop_delay is the propagation delay of the channel.

It is set by us.

Highlight throughput = 0.0 throughput holds the throughput of the network.

It is the rate of packet delivery.

Highlight trans_delay = 0.0 trans_delay holds the transmission delay of a packet.
Highlight RxTraceClient(std::string context, Ptr<const Packet> p) RxTraceClient is a callback function.

It is executed whenever the client receives a packet.

The first argument is the traced source.

We shall explain trace sources later in this tutorial.

Here the traced source is Rx.

The second argument is the packet received.

Highlight node0_rec_time = Simulator::Now().GetSeconds() In the function, we will update the value of node0_rec_time variable.

Here, we set the value of the current time.

The current time is found using the GetSeconds method.

Highlight round_trip_time Similarly, we update the value of the round_trip_time variable.

We set it to the sum of transmission and reception time of packets.

These values are represented by node0_trans_time and node0_rec_time.

The node0_trans_time variable would be updated in the TxTraceClient function.

Highlight round_cnt++ Next, we increment the value of the round_cnt variable by 1.

We do so, to keep a track of the number of round-trips.

Highlight TxTraceClient TxTraceClient is a callback function.

It is executed whenever the client sends a packet.

The first argument is the traced source.

The second argument is the receive packet.

Highlight node0_trans_time In the function, we set the value of node0_trans_time.

The value is the time at which transmission starts.

Highlight RxTraceServer The last callback function is RxTraceServer.

It is executed when the server node receives a packet.

The first argument is the traced source.

The second argument is the received packet.

Highlight node1_rec_time = Simulator::Now().GetSeconds() Here we set the receiving time to the current time in seconds.
Highlight total_delay += (node1_rec_time - node0_trans_time)*1000 Then, we set the total_delay variable, which stores the total delay.

It is computed as the difference between two variables.

The first is the packet reception time of the server.

The second is the packet transmission time of the client.

The value is multiplied by 1000 to get the unit in milliseconds.

Highlight trans_delay += ((node1_rec_time - node0_trans_time)*1000 - prop_delay/1000000) Next, we compute the value of transmission delay.

We get it by subtracting the value of propagation delay from total delay.

The propagation delay value is in nanoseconds, hence we divide it by 1000000.

This converts it to milliseconds.

Highlight pkt_cnt++ Next we increment the packet count.
Highlight if (pkt_cnt == pkts) Finally we compare the value of packet count to the total packets.

We do this to know when the last packet is received.

If this is the last packet, we print all the parameters.

Highlight NS_LOG_UNCOND Using the NS_LOG_UNCOND function, we print the parameters to the terminal.

We print the parameters:

  • End-to-end delay
  • Transmission delay
  • Throughput
  • Propagation delay (constant)
Highlight total_delay/(p->GetSize()*pkts Throughput is calculated as total delay divided by total data size.
Highlight nodes.Create(2) Let’s move to the main function now.

For the topology, we create a point-to-point network with two nodes.

Highlight SetDeviceAttribute The data rate for the device is 100 Mbps.
Highlight SetChannelAttribute The propagation delay is set to 6560 nanoseconds.
Highlight address.SetBase("10.1.1.0", "255.255.255.0") The base address of the network is 10.1.1.0.
Highlight UdpEchoServerHelper echoServer(9) Next we create a UDP echo server with port address 9.
Highlight echoServer.Install(nodes.Get(1)) The echo server application is installed on the second node.

The index of the node is 1.

Highlight serverApps.Start(Seconds(1.0)) Here we set the start time of the server applications to 1 second.
Highlight serverApps.Stop(Seconds(10.0)) Similarly, we set the stop time to 10 seconds.

Both the times are from the start of the simulation.

Highlight echoClient(interfaces.GetAddress(1), 9) Then we create an echo client application with destination port 9.
Highlight SetAttribute Using the SetAttribute method we set the following attributes for the client.
Highlight MaxPackets The maximum number of packets is 10.
Highlight Interval The time interval between packet transmissions is 0.5 seconds.
Highlight PacketSize The packet size is 1024 bytes.
Highlight echoClient.Install(nodes.Get(0)) The echo client application is installed on the first node.

The index of the node is 0.

Highlight clientApps.Start(Seconds(2.0)) The start time of the client apps is set to 2 seconds.
Highlight clientApps.Stop(Seconds(10.0)) The stop time is 10 seconds.
Highlight Config::Connect Using the connect method, we connect trace sources to callback functions.

These functions are also known as trace sinks.

A callback function is passed as an argument to another function.

These are used in conjunction with trace sources.

Trace sources are entities that signal events in an ns-3 program.

These events include packet transmission, change in window size etc.

Highlight UdpEchoClient/Tx This program uses three trace sources.

The first is the Tx trace source, of the UdpEchoClient class.

It traces the transmission of a packet by an echo client application.

Highlight UdpEchoClient/Rx The second trace source is Rx, of the UdpEchoClient class.

It traces the reception of a packet by an echo client application.

Highlight UdpEchoServer/Rx The last trace source is Rx , of the UdpEchoServer class.

It traces the reception of a packet by an echo server application.

Highlight AnimationInterface anim ("network_performance.xml"); Next we create an AnimationInterface object, anim, for NetAnim animation.

The parameter for the constructor is the name of the XML animation file.

It will be generated by the program after the simulation.

Here the name of the file is network_performance.xml.

Highlight anim.SetConstantPosition Then set the positions for the nodes using the SetConstantPosition function.
Highlight Simulator::Run() The Run function is used to run the simulation.
Highlight Simulator::Destroy() The Destroy function ends the simulation.

Close the text editor.

Press Ctrl, Alt and T keys simultaneously.

Type cd ns-allinone-3.38/ns-3.38 to navigate to the ns3 installation directory

Type mv ~/Downloads/network_performance.cc scratch/network_performance.cc to move the source file to scratch directory.

Now we will observe the simulation.

Open a terminal by pressing Ctrl, Alt and T keys simultaneously.

Using the cd command, navigate to the installation directory of ns-3.

Go to the ns-3.38 directory.

Move your source file to the scratch directory within the ns-3.38 directory.

Type ./ns3 run scratch/network_performance.cc Run the command dot forward slash ns3 run space scratch forward slash network underscore performance dot cc

network underscore performance is the name of the source file.

Keep the terminal open and show the output of the command After compilation, we get the network parameters.

The parameters are

  • End-to-end delay
  • Transmission delay
  • Throughput and
  • Round trip time
Type cd ~/ns-allinone-3.38/netanim Now, to visualise the network, we will use NetAnim.

Navigate to the netanim directory under ns-allinone-3.38.

Type ./NetAnim Now type dot forward slash NetAnim.

The NetAnim' window will open.

Click on the Open XML trace file icon on the top left corner of the window. Click on the Open XML trace file icon on the top left corner of the window.
In the file picker, navigate to the ns-allinone-3.38/ns-3.38 directory and select the network_performance.xml file. In the file picker, navigate to the ns-3.38 directory.

Select the network_performance.xml file.

The file would be generated by the program.

You can also download the file from Code Files section.

On the toolbar, click on the Node Size drop down button, and select size 10. On the toolbar, click on the Node Size drop down button.

Select size 10.

On the toolbar, click on the play button On the toolbar, click on the play button to view the simulation.

We see the circles representing the nodes.

The lines with arrows represent the transfer of packets.

Hover over node 0 and node 1 circles. We see the packets moving from node 0 to node 1.
Show slide:

Summary

This brings us to the end of the tutorial.

Let us summarise.

In this tutorial, we have learnt to

  • Use trace sources
  • Create callback functions
  • Connect trace sources to callback functions
  • Calculate network parameters using trace sources
Show slide:

Assignment

As an assignment, please do the following:
  • Create a Point-to-Point network with 3 nodes
  • Send packets from node 0 to node 2
  • Calculate throughput and transmission delay
Show slide:

Assignment - Observation

In the terminal, you will get this output.

The values may vary depending on the network parameters.

These parameters include packet size, propagation delay and data rate.

Show slide:

About the Spoken Tutorial Project

The video at the following link summarises the Spoken Tutorial project.

Please download and watch it.

Show Slide:

Spoken Tutorial Workshops

The Spoken Tutorial Project team conducts workshops and gives certificates.

For more details, please write to us.

Show Slide:

Answers for THIS Spoken Tutorial

Post your timed queries in this forum.
Show Slide:

FOSSEE Forum

For any general or technical questions on ns-3, visit the FOSSEE forum and post your question.
Show slide

Acknowledgement

Spoken Tutorial Project was established by the Ministry of Education, Government of India.
Show slide

Acknowledgement

We thank Dr.Moyukh Laha from IIT Kharagpur for his domain support.

We would also like to thank Dr. R. Radha, Dr. X. Anita, and Dr. T. Subbulakshmi from VIT, Chennai for their support.

Show slide:

Thank You

This is Josiga, a FOSSEE summer fellow 2023, IIT Bombay signing off.


Thanks for joining.

Contributors and Content Editors

Madhurig, Nirmala Venkat