Evaluation and Comparison of Wired VoIP Systems to...
Transcript of Evaluation and Comparison of Wired VoIP Systems to...
ENSC 427: COMMUNICATION NETWORKS SPRING 2013
Evaluation and Comparison of Wired VoIP Systems to VoWLAN
Project website: http://www.sfu.ca/~rza6/ensc427.html
Group #15
Leslie Man 301048471 [email protected]
Bill Lu 301049313 [email protected]
David Zhong 301077194 [email protected]
Table of Content Abstract ......................................................................................................................................................................3
Introduction ................................................................................................................................................................3
Background Information ............................................................................................................................................3
History of VoIP ......................................................................................................................................................3
VoIP over Different Protocol .................................................................................................................................3
Voice over UDP .................................................................................................................................................3
Voice over SCTP ................................................................................................................................................4
SCTP VS UDP ...................................................................................................................................................4
LAN VS WLAN .....................................................................................................................................................4
Implementation ...........................................................................................................................................................5
Simulation with ns-2...............................................................................................................................................5
Wired VoIP System Topology ...........................................................................................................................5
VoWLAN System Topology ..............................................................................................................................6
Simulation Results and Discussion ............................................................................................................................6
AWK - Filtering Data in Trace File .......................................................................................................................7
Plotting with gnuplot ............................................................................................ Error! Bookmark not defined.
Throughput .........................................................................................................................................................7
Packet Loss .........................................................................................................................................................8
Latency ...............................................................................................................................................................8
Packet Delay Variation .......................................................................................................................................8
Results and Discussion ......................................................................................... Error! Bookmark not defined.
References: ...............................................................................................................................................................14
Appendix A: NS-2-Code ..........................................................................................................................................14
3
Abstract
VoWLAN is essentially a VoIP system implemented over Wi-Fi, which offers a significantly extended
operational range. However, the extension presents trade-offs in stability, such as packet drop rate and
additional delays. This project will simulate the performance of voice communication over wired
connections to its Wi-Fi counterpart using NS2-2.35, in areas such as operational stability and
operational range.
Introduction
This project is for better understanding of how VoIP works in underlying layers of the network. The
wired VoIP and VoWLAN topologies are built by using NS2. In order to make the simulation more
realistic as in the real world, the background traffic are added. The simulation is starting with UDP
(User Datagram Protocol), and Stream Control Transmission Protocol (SCTP). To have better
understanding of the difference between the VoIP on wired and wireless network, packet loss,
throughput, delay and jitter are measured and analyzed. To better visualize the measured results, the
simulation results are plotted.
Background Information
History of VoIP
Voice over Internet Protocol (VoIP) is a communication protocol which runs over Internet Protocol (IP)
networks. In 1974, IEEE published a paper titled "A Protocol for Packet Network Interconnection". In
Aug 1974, Network Voice Protocol (NVP) first tested over Arpanet. The first VoIP application, Speak
Freely, was released to public in 1991. Three years later, a free VoIP application for Linux, MTALK,
appeared [1].
After forty years of developments, VoIP has become a very mature communication protocols. There are
many popular VoIP applications in 20th
. VoIP was implemented in MSN in 2005. Google Voice service
permitted VoIP connections through Gmail or Google Talk in 2009. The most recently use of VoIP is
Facebook Inc. It launched free calling app for IPhone in January 2013.
VoIP over Different Protocol Voice over UDP
The UDP is one of important members of the Internet protocol suite. It uses a simple transmission
without doing any error checks. Therefore, UDP is not suitable for applications which need error
checking all the time. However, the advantage of UDP is less delay. Theoretically, packet loss must
within certain range in order to deliver normal condition voice package.
4
Voice over SCTP
Similar to UDP, Stream Control Transmission Protocol (SCTP) is a transport layer protocol. It contains
both feature from UDP and TCP. It uses minimal message-oriented Transport Layer protocol as UDP.
Also, it is in-sequence transport of messages with congestion control like TCP. Therefore, it is reliable
and fast.
SCTP VS UDP
From message orientation point of view, SCTP is much more reliable than UDP because there is error
detection in SCTP. To the ordered message service, both SCTP and UDP give unordered service.
Compare to UDP’s 16-bit ones-complement sum, SCTP uses 32-bit end-to-end checksum [2].
LAN VS WLAN LAN refers to a wired network while WLAN is used to refer to a wireless network. Theoretically,
wireless 802.11g has 54Mbps, but wired Ethernet has 1000 Mbps. Therefore, voice data transfer in LAN
is much faster than WLAN.
5
Implementation, Simulations, and Calculations
Simulation with ns-2
The tests will be carried out in NS-2. AWK scripts will be used to parse the resulting
simulation trace files, and evaluate the throughput, latency, jitter, and packet loss.
Gnuplot will be used to graph the resulting data.
The test topology will include two VoIP clients, sending two-way traffic to each other to
simulate normal voice communication. The VoIP traffic will be running at the start of
simulation. At a later time, background traffic will be added to evaluate its effects on the
VoIP traffic. The background traffic will be sent via separated nodes/clients, while only
sharing the transmission paths.
Two protocols will be used for each of the wired and wireless scenarios: UDP and SCTP.
Both protocols are available in NS-2 as source agents. LossMonitor sinks are attached to
each node in the topology.
Wired VoIP System Topology
Figure 1 - Wired VoIP simulation in NAM
6
In our implementation, we decided to use G7.11 codec which is a commonly use audio codec
nowadays. This codec uses a 64kbps bit rate and packet size of 160 bytes [3]. Node 0 & Node 1 will be our
VOIP traffic and Node 3 & Node 4 will be our background. There are two-way traffic for both background
and VoIP.
The background traffic will be sending at a constant bit rate of 128kbps. The bandwidth limits for the routers
(Node 4 & Node 5) is set to the same bitrate as the background traffic. Therefore once the background
traffic start the links between the routers will be overloaded and we can see the impact it will have on the
VOIP application.
The topology for the wired setup is shown in Figure 1, with blue and red denoting two-way traffic between
the VoIP clients. Red and yellow denotes two-way traffic between the background sources. The queue
buildup exists at the center link, serving as a bandwidth bottleneck.
VoWLAN System Topology
Figure 2 - VoWLAN simulation in NAM
The wireless test setup is similar to the wired topology, with the same traffic route shown in figure 2.
Mobile node 3 is sending VoIP traffic (160 bytes with 0.020s interval) to node 0. The traffic arrives at
the base station node, travels through node 1 and is received by the client at node 0. Node 0 will send
VoIP traffic via the same route back to mobile node 3. This will ensure the performances between
WLAN and wired tests can be accurately compared.
The base station acts as a receiver for wireless traffic from nodes 3 and 4. The bandwidth bottleneck for
the wireless setup is the duplex link between node 1 and the base-station, which will generate dropped
packets upon traffic exceeding the transmission speed of 64kbps.
7
AWK - Filtering Data in Trace File
AWK is a data extraction tool in Ubuntu. Trace file is an output data file from ns-2 simulation. Its file
extension is .tr. We only use several types of events in trace file. They are “+” represent “enqueue”, “-”
represent “dequeue”, “r” represents receive, and “d” represents drop. The normal trace file structure is
shown as following Table-1:
1 2 3 4 5 6 7 8 9 10 11 12 abbr. Timestamp Source
Node
Destination
Node
Packet
Type
Packet
Size
Flags Flow
ID
Source
Address
Destination
Address
Sequence
Number
Unique
Packet
ID
Table-1: Trace File Normal Event Structure
1 2 3 4 5 6 7 8 9 10 11 12 abbr. Time Node
ID
X
Coordinate
Y
Coordinate
Trace
Name
Reason Event
Identifier
Packet
Type
Packet
Size
Time
To
Send
Data
Destination
MAC
Address
Table-2: Trace File Normal Event Structure
AWK scripts will be used to parse the trace files created by the simulations, and perform calculations to
obtain the performance values. The trace files under the parameter “trace-all” will contain all necessary
information to obtain the throughput, latency, jitter, and packet loss.
AWK – Performance Calculations Throughput
Throughput is the average rate of successful data pass over a communication channel. It is measured in
bytes/sec. For example, from client Node 0 to client Node 1, both clients connect to server Node A and
Node B, the throughput of VoIP refers to the total amount of voice data transfer between Node 0 and
Node 1. In the trace file, “r” represents “receive” in normal and wireless event, which can be used to
tack throughput. The formula is shown as following:
( )
The instantaneous throughput will generate a graph showing the amount of information received by the
destination node over each second. This is useful for evaluating the immediate effects of the background
traffic on the pre-existing VoIP traffic [6].
The average throughput will produce a single value showing the average throughput for the entire
duration of the simulation. The formula is as following:
8
Packet Loss
Packet loss happens when packets of data travelling across a computer network never reaches its
destination. It occurs when packets enter a queue when it is full. This is for the case of Drop-Tail
queuing method, which will drop the last packet attempting to enter the queue upon reaching queue limit.
For this project, the cumulative packet loss will be evaluated. The cumulative packet loss tells the total
numbers of packets dropped throughout he simulation. In the trace file, the “d” flag represents “drop” in
normal and wireless events, which can be used to count and calculate the instantaneous packet loss and
cumulative packet lost.
The cumulative packet loss can be plotted on a graph progressively over each second, and will also give
summed total of packet loss at the end of the runtime. This will allow easy comparison between various
scenarios and protocols.
Latency
Latency is a measure of time delay experienced in a system. In our simulation, the delay is measured by
taking the time difference between when a packet is sent from the source node, and when it reaches its
destination. The latency (end-to-end delay) will be measured for each packet sent from a VoIP client,
and reaches its partner. The packet will be tracked using its packet ID as it travels through each node in
the network. The instantaneous latency formula is given as:
Instantaneous Latency = Receive time of destination node – Send time of source node
The instantaneous latency can be presented graphically, where the end-to-end delay (in seconds, y-axis)
for a specific packet is posted at the time it was received by the destination node (x-axis)
The Average Latency is a single value, calculated from the formula given below:
Average Latency = cumulative total of instantaneous latency / simulation runtime
The average latency produces a single value which can be easily used to carry out performance
comparisons between different scenarios.
Packet Delay Variation
Jitter is an informal name for IP packet delay variation (IPDV), but it is often use in electronics and
telecommunication. Jitter is the undesired deviation from true periodicity of an assumed periodic signal
in computer network. “As an example, say packets are transmitted every 20 ms. If the 2nd packet is
received 30 ms after the 1st packet, IPDV = −10 ms. This is referred to as dispersion. If the 2nd packet
is received 10 ms after the 1st packet, IPDV = +10 ms. This is referred to as clumping [4].”
Instantaneous Jitter = Current Latency – Previous Latency
9
Instantaneous Jitter is graphed over the simulation period, and each data point will be mapped to its
respective time in the Instantaneous Latency graph. This allows examination of the stability of the
network as the traffic pattern constantly changes throughout the simulation.
The average jitter can be calculated as:
Instantaneous Jitter = sum(Current Latency – Previous Latency) / simulation runtime
The produced value can be easily used to evaluate each scenario.
Results and Discussion
The left side is wired VoIP results, and the right side is WoWLAN simulation results. The performance
between wired and WLAN VoIP networks is compared for UDP and SCTP protocols. The background
traffic initiates at 2 seconds into the simulation.
UDP - Throughput
Figure - Throughput - Wired VoIP VS VoWLAN
The resulting throughput between wired and wireless VoIP networks under UDP is similar. This is due
to the mobile nodes being placed relatively close to the base station, so that the signal is strong enough
to mirror a wired connection. As seen from the figures, without any background traffic, both VoWLAN
and wired networks easily reach the throughput of 60kbps, guaranteeing reliable voice traffic between
the clients.
UDP - Packet Lost
10
Figure - Packet Lost - Wired VoIP VS VoWLAN
The packet loss is significantly more for wired than for wireless under the UDP protocol. This does not
match the theoretical results, in which the instability of wireless packet transfers will result in higher
packet loss. This result is due to the queuing type of the duplex links, as there are three separate queues
between sender and receiver, which results in undesired queue stacking characteristics resulting in
significant amount of packet loss over long periods of times.
UDP - Latency
Figure - Latency - Wired VoIP VS VoWLAN
The latency is shorter for the wireless network than the wired network under the UDP protocol. This is
due to the mobile nodes being in too close proximity of the base station, which resulted in better
performance for the wireless signals than for the preset delays existing in the duplex links. However, the
fluctuation of the latency is significantly higher for the VoWLAN, which is accurate to real-world
scenarios.
UDP - Jitter
11
Figure - Jitter - Wired VoIP VS VoWLAN
As mentioned in the latency test, the jitter is higher for the wireless network than for the wired. This is
also theoretically correct, as wireless signals are prone to interference and signal instability.
SCTP – Throughput
Figure - Throughput - Wired VoIP VS VoWLAN
The throughput under the SCTP protocol remains the same for the wired VoIP network, as the
background traffic caps the transmission speed, and the Drop-Tail queuing method becomes a race
condition between VoIP and background traffic. However, the wireless network benefits from the error
detection of the SCTP protocol, which in itself attributes for some of the extra throughput.
12
SCTP – Latency
Figure - Latency - Wired VoIP VS VoWLAN
Similar to the UDP protocol tests, the SCTP results in higher overall latency, but displays the same
characteristics for the VoIP latency in the presence of background traffic. The SCTP protocol gives a
slightly higher latency due to its error detection functionalities. This also results in higher jitter for
periods when errors occur within the traffic.
SCTP – Jitter
Figure - Jitter - Wired VoIP VS VoWLAN
The following tables summarizes the results of the simulation. The average values can be used to
compare the performances between wired and wireless networks for both UDP and SCTP protocols.
Wired VoIP UDP SCTP
Throughput (kbps) 21.6 35.9431
Latency(s) 0.0445072 0.138427
Jitter(s) 0.000359982 0.00035492
Table 3 – Average Simulation Results of Wired VoIP
13
WLAN VoIP UDP SCTP
Throughput (kbps) 23.76 30.752
Latency(s) 0.0496553 0.142328
Jitter(s) 0.000107147 0.0031937
Table 4 – Average Simulation Results of VoWLAN
Conclusion
The purpose of the project is to evaluate the performance difference between wired and wireless VoIP
networks. The scenarios are created to include a variety of real-world cases, such as for both UDP and
SCTP protocols, and with the addition of background traffic [5]. The results are conclusive for the cases
of throughput, packet loss, latency, and jitter. The wireless nodes are affected by its proximity to the
base station, acting as the receiver. In close proximity, the wireless nodes will perform better than the
wired network, which had a preset delay of 5ms for each of the duplex links. However, the latency and
jitter is unstable for wireless networks, especially as the distance increases between the mobile nodes
and the base station.
14
References:
[1] Wikipedia. “Voice Over IP,” Available: http://en.wikipedia.org/wiki/Voice_over_IP [Accessed:
April 8, 2013]
[2] Computer Networks. “VoIP performance over UDP and SCTP in NS2,” Available:
https://sites.google.com/site/networksprojectwiki/bit10/compnetworks/voip-performance-over-udp-and-
sctp-in-ns2 [Accessed: April 15, 2013]
[3] CISCO, “Voice Over IP - Per Call Bandwidth Consumption,” Available:
http://www.cisco.com/en/US/tech/tk652/tk698/technologies_tech_note09186a0080094ae2.shtml
[Accessed: April 13, 2013]
[4] Wikipedia. “Packet delay variation,” Available: http://en.wikipedia.org/wiki/Packet_delay_variation
[Accessed: April 8, 2013]
[5] Hole, D.P.; Tobagi, F.A.;, "Capacity of an IEEE 802.11b Wireless Lan supporting VoIP,"
Communications, 2004 IEEE Internation Conference on, vol.1, no., pp. 196-201
[6]T. Issaraiyakul and E. Hossain “Post processing NS2 Result using NS2 Trace — Trace file format”
[Online] Available FTP: http://www.ns2ultimate.com/post/2496927327/post-processing-ns2-result-
using-ns2-trace-trace
Appendix A: NS-2-Code
Wired VoIP using UDP:
# starting the simulator
set ns [new Simulator]
#dynamic routing
#$ns rtproto DV
set nf [open lanudp-out.nam w]
$ns namtrace-all $nf
#open tracefile
set nd [open lanudp-out.tr w]
$ns trace-all $nd
proc finish {} {
15
global ns nf
$ns flush-trace
close $nf
exec nam lanudp-out.nam &
exit 0
}
#declare colors
$ns color 1 blue
$ns color 2 red
$ns color 3 purple
$ns color 4 orange
#create node
set n0 [$ns node]
set n1 [$ns node]
set n4 [$ns node]
set n5 [$ns node]
set r1 [$ns node]
set r2 [$ns node]
# shapes for the routers
$r1 shape box
$r2 shape box
#label
$n0 label "0"
$n1 label "1"
$n4 label "4"
$n5 label "5"
$r1 label "router"
$r2 label "router2"
#color nodes
$n0 color blue
$n1 color purple
$n4 color red
$n5 color orange
# how connections are established and bandwidth//delay for our lines
# G7.11 codec
$ns duplex-link $n0 $r1 64kb 5ms DropTail
# background traffic
$ns duplex-link $n1 $r1 128kb 5ms DropTail
16
#G7.11 codec
$ns duplex-link $n4 $r2 64kb 5ms DropTail
#background traffic
$ns duplex-link $n5 $r2 128kb 5ms DropTail
# link between routers
$ns duplex-link $r1 $r2 128kb 5ms DropTail
#orientation
$ns duplex-link-op $n0 $r1 orient right-down
$ns duplex-link-op $n1 $r1 orient right-up
$ns duplex-link-op $r1 $r2 orient right
$ns duplex-link-op $r2 $n4 orient right-up
$ns duplex-link-op $r2 $n5 orient right-down
#monitor queues
$ns duplex-link-op $n0 $r1 queuePos 0.5
$ns duplex-link-op $r1 $r2 queuePos 0.5
$ns duplex-link-op $r2 $n4 queuePos 0.5
#$ns queue-limit $n0 $r1 3
#$ns queue-limit $n4 $r2 3
#create source and traffic
####voip
#Create a UDP agent and attach it to the node
set source0 [new Agent/UDP]
$ns attach-agent $n0 $source0
#set flow id easier to trace afterwards
$source0 set fid_ 1
#create a cbr traffic and attach to source
set traffic0 [new Application/Traffic/CBR]
#set packet size
$traffic0 set packetSize_ 160
#packet size * 8 / speed
$traffic0 set interval_ .02
# Attach traffic source to the traffic generator
$traffic0 attach-agent $source0
$source0 set class_ 1
#Connect the source and the sink
set sink4 [new Agent/LossMonitor]
17
$ns attach-agent $n4 $sink4
$ns connect $source0 $sink4
#background
#create udp agent
set source1 [new Agent/UDP]
$ns attach-agent $n1 $source1
#flowid
$source1 set fid_ 3
#cbr traffic
set traffic1 [new Application/Traffic/CBR]
$traffic1 set packetSize_ 320
#packet size * 8 / speed
$traffic1 set interval_ .02
# Attach traffic source to the traffic generator
$traffic1 attach-agent $source1
$source1 set class_ 3
#Connect the source and the sink
set sink5 [new Agent/LossMonitor]
$ns attach-agent $n5 $sink5
$ns connect $source1 $sink5
#2nd voip
#create a udp agent
set source4 [new Agent/UDP]
$ns attach-agent $n4 $source4
$source4 set fid_ 2
set traffic4 [new Application/Traffic/CBR]
$traffic4 set packetSize_ 160
#packet size * 8 / speed
$traffic4 set interval_ .02
# Attach traffic source to the traffic generator
$traffic4 attach-agent $source4
$source4 set class_ 2
#Connect the source and the sink
set sink0 [new Agent/LossMonitor]
18
$ns attach-agent $n0 $sink0
$ns connect $source4 $sink0
#background
set source5 [new Agent/UDP]
$ns attach-agent $n5 $source5
$source5 set fid_ 4
set traffic5 [new Application/Traffic/CBR]
$traffic5 set packetSize_ 320
#packet size * 8 / speed
$traffic5 set interval_ .02
# Attach traffic source to the traffic generator
$traffic5 attach-agent $source5
$source5 set class_ 4
#Connect the source and the sink
set sink1 [new Agent/LossMonitor]
$ns attach-agent $n1 $sink1
$ns connect $source5 $sink1
####simulation
$ns at 1 "$traffic0 start"
$ns at 1 "$traffic4 start"
$ns at 2 "$traffic1 start"
$ns at 2 "$traffic5 start"
$ns at 10.0 "$traffic1 stop"
$ns at 10.0 "$traffic5 stop"
$ns at 10.0 "$traffic0 stop"
$ns at 10.0 "$traffic4 stop"
$ns at 10.0 "finish"
$ns run
Wired VoIP using SCTP:
# starting the simulator
set ns [new Simulator]
#dynamic routing
#$ns rtproto DV
19
set nf [open lansctp-out.nam w]
$ns namtrace-all $nf
#open tracefile
set nd [open lansctp-out.tr w]
$ns trace-all $nd
proc finish {} {
global ns nf
$ns flush-trace
close $nf
# exec nam rtpout.nam &
exit 0
}
#set the colors of the packets being sent
$ns color 1 blue
$ns color 2 red
$ns color 3 purple
$ns color 4 orange
#create nodes
set n0 [$ns node]
set n1 [$ns node]
set n4 [$ns node]
set n5 [$ns node]
set r1 [$ns node]
set r2 [$ns node]
# shapes for the routers
$r1 shape box
$r2 shape box
#label
$n0 label "0"
$n1 label "1"
$n4 label "4"
$n5 label "5"
$r1 label "access point"
$r2 label "router2"
#color the nodes
$n0 color blue
$n1 color purple
20
$n4 color red
$n5 color orange
# how connections are established and bandwidth//delay for our lines
# G7.11 codec
$ns duplex-link $n0 $r1 64kb 5ms DropTail
# backgroung
$ns duplex-link $n1 $r1 128kb 5ms DropTail
#G7.11 codec
$ns duplex-link $n4 $r2 64kb 5ms DropTail
#background
$ns duplex-link $n5 $r2 128kb 5ms DropTail
# link between routers
$ns duplex-link $r1 $r2 128kb 20ms DropTail
#orientation
$ns duplex-link-op $n0 $r1 orient right-down
$ns duplex-link-op $n1 $r1 orient right-up
$ns duplex-link-op $r1 $r2 orient right
$ns duplex-link-op $r2 $n4 orient right-up
$ns duplex-link-op $r2 $n5 orient right
#to monitor the queues
$ns duplex-link-op $n0 $r1 queuePos 0.5
$ns duplex-link-op $r1 $r2 queuePos 0.5
$ns duplex-link-op $n4 $r2 queuePos 0.5
#set queues limit so the queues will not be that long so the packet created will be sent at the same time
$ns queue-limit $n0 $r1 3
$ns queue-limit $n4 $r2 3
#Create a sctP agent and attach it to the node
set source0 [new Agent/SCTP]
$ns attach-agent $n0 $source0
$source0 set fid_ 1
#create a traffic of cbr
set traffic0 [new Application/Traffic/CBR]
#set packet size
$traffic0 set packetSize_ 160
#packet size * 8 / speed
$traffic0 set interval_ .02
21
# Attach traffic source to the traffic generator
$traffic0 attach-agent $source0
$source0 set class_ 1
#create sink
set sink4 [new Agent/LossMonitor]
$ns attach-agent $n4 $sink4
#create 2nd voip agent
set source4 [new Agent/SCTP]
$ns attach-agent $n4 $source4
$source4 set fid_ 2
#create a traffic for 2nd voip agent
set traffic4 [new Application/Traffic/CBR]
$traffic4 set packetSize_ 160
#packet size * 8 / speed
$traffic4 set interval_ .02
# Attach traffic source to the traffic generator
$traffic4 attach-agent $source4
$source4 set class_ 2
set sink0 [new Agent/LossMonitor]
$ns attach-agent $n0 $sink0
#Connect the source and the sink
#$ns connect $source $sink
#connect both sources
$ns connect $source0 $source4
#return $traffic
#}
############################ BACKGROUND AGENT AND TRAFFIC
#background 1 agent
set source1 [new Agent/SCTP]
$ns attach-agent $n1 $source1
$source1 set fid_ 1
set traffic1 [new Application/Traffic/CBR]
$traffic1 set packetSize_ 320
#packet size * 8 / speed
$traffic1 set interval_ .02
# Attach traffic source to the traffic generator
$traffic1 attach-agent $source1
22
$source1 set class_ 3
set sink5 [new Agent/LossMonitor]
$ns attach-agent $n5 $sink5
#background 2 agent
set source5 [new Agent/SCTP]
$ns attach-agent $n5 $source5
$source5 set fid_ 2
set traffic5 [new Application/Traffic/CBR]
$traffic5 set packetSize_ 320
#packet size * 8 / speed
$traffic5 set interval_ .02
# Attach traffic source to the traffic generator
$traffic5 attach-agent $source5
$source5 set class_ 4
set sink1 [new Agent/LossMonitor]
$ns attach-agent $n1 $sink1
#Connect the source and the sink
#$ns connect $source $sink
#connect the both source
$ns connect $source1 $source5
#run simulation
$ns at 1 "$traffic0 start"
$ns at 1 "$traffic1 start"
$ns at 2 "$traffic4 start"
$ns at 2 "$traffic5 start"
$ns at 60 "$traffic0 stop"
$ns at 60.0 "$traffic1 stop"
$ns at 60.0 "$traffic4 stop"
$ns at 60.0 "$traffic5 stop"
$ns at 60.0 "finish"
$ns run
AWK code (for Wired VoIP)
Throughput:
#throughput bytes receieved in destination node in 1s
23
BEGIN { ###decare variables
sim_time = 0.0;
bytes_counter=0;
counter =0;
tracker =0;
}
{ #get current simulation time
sim_time = $2;
#get simulation time
track = $2;
#tracker = track - counter;
#if receive update bytes counter
if ($1=="r" && $3 == "5" && $4 == "2" ){
#get the packet size and * 8 to convert to 8 and divide by a 1000 to get the unit "k"
bytes_counter+=$6*8/1000;
print "bytes:" bytes_counter
}
#use to check if the data point exceed 1s
tracker = track - counter;
#if it exceed 1s
if (tracker >= 1){
printf("%f %f\n", sim_time, bytes_counter) > "throughput";
#increase counter
counter ++;
#reset the checker
tracker = 0;
print "counter:" counter;
#use to calculate average throughput
total_throughput += bytes_counter;
#reset bytes counter
bytes_counter = 0;
}
}
END { #calculate average throughput
ave_throughput = total_throughput/counter;
print "ave throughput:" ave_throughput;
print("Done");
}
Packet Lost:
#packetlost number of packet lost from the voip nodes
24
BEGIN {
#declare var
time2 = 0.0;
num_packet=0;
bytes_counter=0;
send_flag =0;
send_flag2=0;
}
{
#get the current simulation time
time2 = $2;
if ($1=="+" && ($3 == "0" && $4 == "4") && $8 == 1 && send_flag == 0) {
send_flag = 1;
}
if ($1=="r" && ($3 == "0" && $4 == "4") && $8 == 1 && send_flag ==1){
send_flag =2;
}
if ($1=="+" && ($3 == "4" && $4 == "5") && $8 == 1 && send_flag ==2){
send_flag=3;
}
if ($1=="d" && ($3 == "4" && $4 == "5") && $8 == 1 && send_flag ==3){
#counter for the numbers of packet drops
num_packet++;
printf("%f %f\n", time2, num_packet) > "packetlost";
print "number of packet lost : " num_packet;
print "packet lost time :" time2;
send_flag = 0;
}
if ($1=="+" && ($3 == "2" && $4 == "5") && $8 == 2 && send_flag2 == 0) {
send_flag2 = 1;
}
if ($1=="r" && ($3 == "2" && $4 == "5") && $8 == 2 && send_flag2 ==1){
send_flag2 =2;
}
if ($1=="+" && ($3 == "5" && $4 == "4") && $8 == 2 && send_flag2 ==2){
send_flag2 =3;
}
if ($1=="d" && ($3 == "5" && $4 == "4") && $8 == 2 && send_flag2 ==3){
#counter for the numbers of packet drops
num_packet++;
printf("%f %f\n", time2, num_packet) > "packetlost";
print "number of packet lost 2 : " num_packet;
print "packet lost time :" time2;
send_flag2 = 0;
}
if (num_packet == 0)
{ #if there are no packet lost
25
printf("%f %f\n", time2, num_packet) > "packetlost";
print "no packet lost";
}
}
END {
print("Done");
}
Latency:
#latency difference in the time receieve from packets
BEGIN {highest_packet_id = 0; sendflag =0; flowid=0; count=0;}
{
#######---------------
# $1 = action $2 = time $3 = from node $4 = destionation node $12 = packetid
##-------------#########
sim_time = $2;
packet_id =$12;
#cheack if there is a change in packet id and save it
if (packet_id > high_packet_id && $3 == "0" ){
highest_packet_id = packet_id;
}
if ($1 == "+" && $3 == "0" && $4 == "4" ){
# if ($1 == "-" && $3 == "0" && $4 == "2" ){
#save the send time of specific packet id
send_time[highest_packet_id] = sim_time;
#print "send_time" send_time[highest_packet_id];
}
# if ($1 == "r" && $3 == "4" && $4 == "5" && $8 == "1"){
#if ($1 == "r" && $3 == "0" && $4 == "4" && $8 == "1"){
if ($1 == "r" && $3 == "5" && $4 == "2" && $8 == "1"){
#if ($1 == "r" && $3 == "3" && $4 == "1" && $8 == "1"){
#get the packet id for that condidtion
highest_packet_id =$12;
#get the receieve time & start of that packet id
rcv_time[highest_packet_id] = sim_time;
start = send_time[highest_packet_id];
end = rcv_time[highest_packet_id];
#calculate latency
duration = end - start;
printf("%f %f\n", sim_time, duration) > "latency";
#some up the latency for calculation average latency
count++;
duration_ave += duration;
}
26
#else if ($1 == "d" && $3 == "4" && $4 == "5" && $8 =="1"){
#if there are any drops
else if ($1 == "d" && $3 == "2" && $4 == "3" && $8 =="1"){
print"drop";
}
}
END {
#calculate average latency
latency_ave = duration_ave/count;
print "ave latency:" latency_ave;
print("Done");
}
Jitter:
#jitter difference in e2e delay
BEGIN {highest_packet_id = 0; flowid=0; count=0;}
{
#######---------------
# $1 = action $2 = time $3 = from node $4 = destionation node $12 = packetid
#-------------#########
#get simulation time
sim_time = $2;
#get packet id
packet_id =$12;
#if there is a change in packet id in node 0
if (packet_id > high_packet_id && $3 == "0"){
highest_packet_id = packet_id;
}
#if node 0 have an enqueue
if ($1 == "+" && $3 == "0"){
#save the current simulation time to send time of that specific packet id
send_time[highest_packet_id] = sim_time;
}
if ($1 == "r" && $3 == "5" && $4 == "2" && $8 == "1"){
#get current packet id
highest_packet_id =$12;
#save the receieve and send time of that packet id
rcv_time[highest_packet_id] = sim_time;
start = send_time[highest_packet_id];
end = rcv_time[highest_packet_id];
#calcuate latency
duration = end - start;
#calculate jitter (difference between the new and old latency)
respone = duration - duration_old;
printf("%f %f\n", sim_time, respone) > "jitter";
27
print "packetid:" highest_packet_id;
print "send time:" start;
print "end time:" end;
print "new duartion:" duration;
print "old duration:" duration_old;
print "jitter:" respone;
#save the old latency
duration_old = duration;
###### sum up the jitter for calculating ave jitter
respone_ave += respone;
count++;
}
else if ($1 == "d" && $3 == "4" && $4 == "5" && $8 == "1"){
print"drop";
}
}
END { #to calculate average jitter
ave_jitter = respone_ave/count;
print "ave jitter:" ave_jitter;
print("Done");
}
28
VoWLAN Topology in ns2:
VoWLAN UDP:
set opt(chan) Channel/WirelessChannel ;# channel type
set opt(prop) Propagation/TwoRayGround ;# radio-propagation model
set opt(netif) Phy/WirelessPhy ;# network interface type
set opt(mac) Mac/802_11 ;# MAC type
set opt(ifq) Queue/DropTail/PriQueue ;# interface queue type
set opt(ll) LL ;# link layer type
set opt(ant) Antenna/OmniAntenna ;# antenna model
set opt(ifqlen) 50 ;# max packet in ifq
set opt(nn) 2 ;# number of mobilenodes
set opt(adhocRouting) DSDV ;# routing protocol
set opt(cp) "" ;# connection pattern file
set opt(sc) "" ;# node movement file.
set opt(x) 100 ;# x coordinate of topology
set opt(y) 100 ;# y coordinate of topology
set opt(seed) 0.0 ;# seed for random number gen.
set opt(stop) 10 ;# time to stop simulation
#voip
set opt(ftp1-start) 1.0
set opt(ftp3-start) 1.0
#background
set opt(ftp2-start) 2.0
set opt(ftp4-start) 2.0
set num_wired_nodes 2
set num_bs_nodes 1
# ==================================================================
# check for boundary parameters and random seed
if { $opt(x) == 0 || $opt(y) == 0 } {
puts "No X-Y boundary values given for wireless topology\n"
}
if {$opt(seed) > 0} {
puts "Seeding Random number generator with $opt(seed)\n"
ns-random $opt(seed)
}
# create simulator instance
set ns_ [new Simulator]
# set up for hierarchical routing
$ns_ node-config -addressType hierarchical
AddrParams set domain_num_ 2 ;# number of domains
29
lappend cluster_num 2 1 ;# number of clusters in each domain
AddrParams set cluster_num_ $cluster_num
lappend eilastlevel 1 1 4 ;# number of nodes in each cluster
AddrParams set nodes_num_ $eilastlevel ;# of each domain
set tracefd [open test-udp.tr w]
set namtrace [open test-udp.nam w]
$ns_ trace-all $tracefd
$ns_ namtrace-all-wireless $namtrace $opt(x) $opt(y)
# Create topography object
set topo [new Topography]
# define topology
$topo load_flatgrid $opt(x) $opt(y)
# create God
create-god [expr $opt(nn) + $num_bs_nodes]
#create wired nodes
set temp {0.0.0 0.1.0} ;# hierarchical addresses for wired domain
for {set i 0} {$i < $num_wired_nodes} {incr i} {
set W($i) [$ns_ node [lindex $temp $i]]
}
# configure for base-station node
$ns_ node-config -adhocRouting $opt(adhocRouting) \
-llType $opt(ll) \
-macType $opt(mac) \
-ifqType $opt(ifq) \
-ifqLen $opt(ifqlen) \
-antType $opt(ant) \
-propType $opt(prop) \
-phyType $opt(netif) \
-channelType $opt(chan) \
-topoInstance $topo \
-wiredRouting ON \
-agentTrace ON \
-routerTrace OFF \
-macTrace OFF
#create base-station node
set temp {1.0.0 1.0.1 1.0.2 1.0.3} ;# hier address to be used for wireless
;# domain
set BS(0) [$ns_ node [lindex $temp 0]]
$BS(0) random-motion 0 ;# disable random motion
#provide some co-ord (fixed) to base station node
$BS(0) set X_ 50.0
30
$BS(0) set Y_ 50.0
$BS(0) set Z_ 0.0
# create mobilenodes in the same domain as BS(0)
# note the position and movement of mobilenodes is as defined
# in $opt(sc)
#configure for mobilenodes
$ns_ node-config -wiredRouting OFF
for {set j 0} {$j < $opt(nn)} {incr j} {
set node_($j) [ $ns_ node [lindex $temp \
[expr $j+1]] ]
$node_($j) base-station [AddrParams addr2id \
[$BS(0) node-addr]]
}
#coordinates for mobile nodes
$node_(0) set X_ 25.0 #mobile node #node #2
$node_(0) set Y_ 25.0
$node_(0) set Z_ 0.0
$node_(0) label "VoIP"
$node_(1) set X_ 75.0 #mobile node #node #2
$node_(1) set Y_ 25.0
$node_(1) set Z_ 0.0
$node_(1) label "Background"
$W(0) label "VoIP"
$W(1) label "Background"
$BS(0) label "BaseStation"
#class color
$ns_ color 1 blue
$ns_ color 2 red
$ns_ color 3 black
$ns_ color 4 yellow
#create links between wired and BS nodes
$ns_ duplex-link $W(0) $W(1) 64kb 5ms DropTail
$ns_ duplex-link $W(1) $BS(0) 64kb 5ms DropTail
$ns_ duplex-link-op $W(0) $W(1) orient down
$ns_ duplex-link-op $W(1) $BS(0) orient left-down
# setup TCP connections
set tcp1 [new Agent/UDP]
#$tcp1 set class_ 2
#$tcp1 set fid_ 1
31
$tcp1 set class_ 1
set sink1 [new Agent/LossMonitor]
$ns_ attach-agent $node_(0) $tcp1
$ns_ attach-agent $W(0) $sink1
$ns_ connect $tcp1 $sink1
#set ftp1 [new Application/FTP]
set ftp1 [new Application/Traffic/CBR]
$ftp1 set packetSize_ 160
$ftp1 set interval_ 0.020
#$ftp1 set class_ 3
$ftp1 attach-agent $tcp1
$ns_ at $opt(ftp1-start) "$ftp1 start"
#background traffic
set tcp2 [new Agent/UDP]
#$tcp2 set fid_ 2
$tcp2 set class_ 2
set sink2 [new Agent/LossMonitor]
#$ns_ attach-agent $W(1) $tcp2
#$ns_ attach-agent $node_(1) $sink2
$ns_ attach-agent $node_(1) $tcp2
$ns_ attach-agent $W(1) $sink2
$ns_ connect $tcp2 $sink2
#set ftp2 [new Application/FTP]
set ftp2 [new Application/Traffic/CBR]
$ftp2 set packetSize_ 320
$ftp2 set interval_ 0.020
#$ftp2 set class_ 4
$ftp2 attach-agent $tcp2
$ns_ at $opt(ftp2-start) "$ftp2 start"
##################################################
set tcp3 [new Agent/UDP]
$tcp3 set class_ 3
set sink3 [new Agent/LossMonitor]
$ns_ attach-agent $W(0) $tcp3
$ns_ attach-agent $node_(0) $sink3
$ns_ connect $tcp3 $sink3
set ftp3 [new Application/Traffic/CBR]
$ftp3 set packetSize_ 160
$ftp3 set interval_ 0.020
$ftp3 attach-agent $tcp3
$ns_ at $opt(ftp3-start) "$ftp3 start"
set tcp4 [new Agent/UDP]
$tcp4 set class_ 4
set sink4 [new Agent/LossMonitor]
$ns_ attach-agent $W(1) $tcp4
$ns_ attach-agent $node_(1) $sink4
32
$ns_ connect $tcp4 $sink4
set ftp4 [new Application/Traffic/CBR]
$ftp4 set packetSize_ 320
$ftp4 set interval_ 0.020
$ftp4 attach-agent $tcp4
$ns_ at $opt(ftp4-start) "$ftp4 start"
# source connection-pattern and node-movement scripts
if { $opt(cp) == "" } {
puts "*** NOTE: no connection pattern specified."
set opt(cp) "none"
} else {
puts "Loading connection pattern..."
source $opt(cp)
}
if { $opt(sc) == "" } {
puts "*** NOTE: no scenario file specified."
set opt(sc) "none"
} else {
puts "Loading scenario file..."
source $opt(sc)
puts "Load complete..."
}
# Define initial node position in nam
for {set i 0} {$i < $opt(nn)} {incr i} {
# 20 defines the node size in nam, must adjust it according to your
# scenario
# The function must be called after mobility model is defined
$ns_ initial_node_pos $node_($i) 20
}
# Tell all nodes when the simulation ends
for {set i } {$i < $opt(nn) } {incr i} {
$ns_ at $opt(stop).0 "$node_($i) reset";
}
$ns_ at $opt(stop).0 "$BS(0) reset";
$ns_ at $opt(stop).0002 "puts \"NS EXITING...\" ; $ns_ halt"
$ns_ at $opt(stop).0001 "stop"
proc stop {} {
global ns_ tracefd namtrace
# $ns_ flush-trace
close $tracefd
close $namtrace
}
33
# informative headers for CMUTracefile
puts $tracefd "M 0.0 nn $opt(nn) x $opt(x) y $opt(y) rp \
$opt(adhocRouting)"
puts $tracefd "M 0.0 sc $opt(sc) cp $opt(cp) seed $opt(seed)"
puts $tracefd "M 0.0 prop $opt(prop) ant $opt(ant)"
puts "Starting Simulation..."
$ns_ run
VoWLAN SCTP:
set opt(chan) Channel/WirelessChannel ;# channel type
set opt(prop) Propagation/TwoRayGround ;# radio-propagation model
set opt(netif) Phy/WirelessPhy ;# network interface type
set opt(mac) Mac/802_11 ;# MAC type
set opt(ifq) Queue/DropTail/PriQueue ;# interface queue type
set opt(ll) LL ;# link layer type
set opt(ant) Antenna/OmniAntenna ;# antenna model
set opt(ifqlen) 50 ;# max packet in ifq
set opt(nn) 2 ;# number of mobilenodes
set opt(adhocRouting) DSDV ;# routing protocol
set opt(cp) "" ;# connection pattern file
set opt(sc) "" ;# node movement file.
set opt(x) 100 ;# x coordinate of topology
set opt(y) 100 ;# y coordinate of topology
set opt(seed) 0.0 ;# seed for random number gen.
set opt(stop) 10 ;# time to stop simulation
#voip
set opt(ftp1-start) 1.0
set opt(ftp3-start) 1.0
#background
set opt(ftp2-start) 2.0
set opt(ftp4-start) 2.0
set num_wired_nodes 2
set num_bs_nodes 1
# ===================================================================
# check for boundary parameters and random seed
if { $opt(x) == 0 || $opt(y) == 0 } {
puts "No X-Y boundary values given for wireless topology\n"
}
if {$opt(seed) > 0} {
puts "Seeding Random number generator with $opt(seed)\n"
34
ns-random $opt(seed)
}
# create simulator instance
set ns_ [new Simulator]
# set up for hierarchical routing
$ns_ node-config -addressType hierarchical
AddrParams set domain_num_ 2 ;# number of domains
lappend cluster_num 2 1 ;# number of clusters in each domain
AddrParams set cluster_num_ $cluster_num
lappend eilastlevel 1 1 4 ;# number of nodes in each cluster
AddrParams set nodes_num_ $eilastlevel ;# of each domain
set tracefd [open test-sctp.tr w]
set namtrace [open test-sctp.nam w]
$ns_ trace-all $tracefd
$ns_ namtrace-all-wireless $namtrace $opt(x) $opt(y)
# Create topography object
set topo [new Topography]
# define topology
$topo load_flatgrid $opt(x) $opt(y)
# create God
create-god [expr $opt(nn) + $num_bs_nodes]
#create wired nodes
set temp {0.0.0 0.1.0} ;# hierarchical addresses for wired domain
for {set i 0} {$i < $num_wired_nodes} {incr i} {
set W($i) [$ns_ node [lindex $temp $i]]
}
# configure for base-station node
$ns_ node-config -adhocRouting $opt(adhocRouting) \
-llType $opt(ll) \
-macType $opt(mac) \
-ifqType $opt(ifq) \
-ifqLen $opt(ifqlen) \
-antType $opt(ant) \
-propType $opt(prop) \
-phyType $opt(netif) \
-channelType $opt(chan) \
-topoInstance $topo \
-wiredRouting ON \
-agentTrace ON \
-routerTrace OFF \
-macTrace OFF
35
#create base-station node
set temp {1.0.0 1.0.1 1.0.2 1.0.3} ;# hier address to be used for wireless
;# domain
set BS(0) [$ns_ node [lindex $temp 0]]
$BS(0) random-motion 0 ;# disable random motion
#provide some co-ord (fixed) to base station node
$BS(0) set X_ 50.0
$BS(0) set Y_ 50.0
$BS(0) set Z_ 0.0
# create mobilenodes in the same domain as BS(0)
# note the position and movement of mobilenodes is as defined
# in $opt(sc)
#configure for mobilenodes
$ns_ node-config -wiredRouting OFF
for {set j 0} {$j < $opt(nn)} {incr j} {
set node_($j) [ $ns_ node [lindex $temp \
[expr $j+1]] ]
$node_($j) base-station [AddrParams addr2id \
[$BS(0) node-addr]]
}
#coordinates for mobile nodes
$node_(0) set X_ 25.0 #mobile node #node #2
$node_(0) set Y_ 25.0
$node_(0) set Z_ 0.0
$node_(0) label "VoIP"
$node_(1) set X_ 75.0 #mobile node #node #2
$node_(1) set Y_ 25.0
$node_(1) set Z_ 0.0
$node_(1) label "Background"
$W(0) label "VoIP"
$W(1) label "Background"
$BS(0) label "BaseStation"
#class color
$ns_ color 1 blue
$ns_ color 2 red
$ns_ color 3 black
$ns_ color 4 yellow
#create links between wired and BS nodes
$ns_ duplex-link $W(0) $W(1) 64kb 5ms DropTail
36
$ns_ duplex-link $W(1) $BS(0) 64kb 5ms DropTail
$ns_ duplex-link-op $W(0) $W(1) orient down
$ns_ duplex-link-op $W(1) $BS(0) orient left-down
# setup TCP connections
set tcp1 [new Agent/SCTP]
$tcp1 set class_ 1
set sink1 [new Agent/LossMonitor]
$ns_ attach-agent $node_(0) $tcp1
$ns_ attach-agent $W(0) $sink1
#$ns_ connect $tcp1 $sink1
set ftp1 [new Application/Traffic/CBR]
$ftp1 set packetSize_ 160
$ftp1 set interval_ 0.020
$ftp1 attach-agent $tcp1
$ns_ at $opt(ftp1-start) "$ftp1 start"
set tcp3 [new Agent/SCTP]
$tcp3 set class_ 3
set sink3 [new Agent/LossMonitor]
$ns_ attach-agent $W(0) $tcp3
$ns_ attach-agent $node_(0) $sink3
#$ns_ connect $tcp3 $sink3
set ftp3 [new Application/Traffic/CBR]
$ftp3 set packetSize_ 160
$ftp3 set interval_ 0.020
$ftp3 attach-agent $tcp3
$ns_ at $opt(ftp3-start) "$ftp3 start"
$ns_ connect $tcp1 $tcp3
#background traffic
set tcp2 [new Agent/SCTP]
$tcp2 set class_ 2
set sink2 [new Agent/LossMonitor]
$ns_ attach-agent $node_(1) $tcp2
$ns_ attach-agent $W(1) $sink2
#$ns_ connect $tcp2 $sink2
set ftp2 [new Application/Traffic/CBR]
$ftp2 set packetSize_ 320
$ftp2 set interval_ 0.020
$ftp2 attach-agent $tcp2
$ns_ at $opt(ftp2-start) "$ftp2 start"
set tcp4 [new Agent/SCTP]
$tcp4 set class_ 4
set sink4 [new Agent/LossMonitor]
$ns_ attach-agent $W(1) $tcp4
37
$ns_ attach-agent $node_(1) $sink4
#$ns_ connect $tcp4 $sink4
set ftp4 [new Application/Traffic/CBR]
$ftp4 set packetSize_ 320
$ftp4 set interval_ 0.020
$ftp4 attach-agent $tcp4
$ns_ at $opt(ftp4-start) "$ftp4 start"
$ns_ connect $tcp2 $tcp4
# source connection-pattern and node-movement scripts
if { $opt(cp) == "" } {
puts "*** NOTE: no connection pattern specified."
set opt(cp) "none"
} else {
puts "Loading connection pattern..."
source $opt(cp)
}
if { $opt(sc) == "" } {
puts "*** NOTE: no scenario file specified."
set opt(sc) "none"
} else {
puts "Loading scenario file..."
source $opt(sc)
puts "Load complete..."
}
# Define initial node position in nam
for {set i 0} {$i < $opt(nn)} {incr i} {
# 20 defines the node size in nam, must adjust it according to your
# scenario
# The function must be called after mobility model is defined
$ns_ initial_node_pos $node_($i) 20
}
# Tell all nodes when the simulation ends
for {set i } {$i < $opt(nn) } {incr i} {
$ns_ at $opt(stop).0 "$node_($i) reset";
}
$ns_ at $opt(stop).0 "$BS(0) reset";
$ns_ at $opt(stop).0002 "puts \"NS EXITING...\" ; $ns_ halt"
$ns_ at $opt(stop).0001 "stop"
proc stop {} {
global ns_ tracefd namtrace
# $ns_ flush-trace
38
close $tracefd
close $namtrace
}
# informative headers for CMUTracefile
puts $tracefd "M 0.0 nn $opt(nn) x $opt(x) y $opt(y) rp \
$opt(adhocRouting)"
puts $tracefd "M 0.0 sc $opt(sc) cp $opt(cp) seed $opt(seed)"
puts $tracefd "M 0.0 prop $opt(prop) ant $opt(ant)"
puts "Starting Simulation..."
$ns_ run
AWK file code:
Throughput:
#throughput
BEGIN {
node =1;
time1 = 0.0;
time2 = 0.0;
num_packet=0;
count = 0;
bytes_counter=0;
time_counter=0;
}
{
time2 = $2;
#if ($3=="_3_"){
#bytes_counter+=$8*8/1000;
#}
if ( ($3=="1" && $4=="0" && $1=="r") || ($3=="1" && $4=="0" && $1=="r")){
bytes_counter+=$6*8/1000;
}
time_counter = time2-count;
if ( time_counter>=1) {
#bytes_counter = bytes_counter/time_counter;
printf("%f %f\n", time2, bytes_counter) > "throughput";
total_bytes += bytes_counter;
time_counter=0;
bytes_counter=0;
count++;
}
}
39
END {
average = total_bytes/count;
print "average throughput:" average;
print("Done");
}
Packet Loss:
BEGIN {
node =1;
time1 = 0.0;
time2 = 0.0;
num_packet=0;
packet_id = 0;
bytes_counter=0;
}
{
time2 = $2;
if ($1=="s" && $3=="_3_") {
packet_id = $6;
}
if ( ($1=="d" || $1 == "D") && $12==packet_id ) {
bytes_counter += $6;
num_packet++;
printf("%f %f\n", time2, num_packet) > "packetlost";
time1 = $2;
}
}
END {
print("Done");
40
}
Latency:
#latency
BEGIN {
send_time = 0.0;
receive_time = 0.0;
sim_time = 0.0;
send_flag = 0;
lat_time = 0;
ave_lat = 0;
count =0;
}
{
sim_time = $2;
if ($1=="s" && $3=="_3_" && send_flag==0) {
send_time = $2;
send_flag = 1;
}
if ($1=="r" && $3=="1" && $4=="0" && send_flag==1) {
receive_time = $2
send_flag = 0;
lat_time = receive_time - send_time;
printf("%f %f\n", sim_time, lat_time) > "latency";
#leslie
ave_lat += lat_time;
count++;
}
}
END {
average = ave_lat/count;
print "average latency:" average;
print("Done");
}
Jitter:
BEGIN {
send_time = 0.0;
receive_time = 0.0;
sim_time = 0.0;
41
send_flag = 0;
lat_time_curr = 0;
lat_time_prev = 0;
jitter = 0;
count =0;
}
{
sim_time = $2;
if ($1=="s" && $3=="_3_"&& send_flag==0) {
send_time = $2;
send_flag = 1;
}
if ($1=="r" && $3=="1" && $4=="0" && send_flag==1) {
receive_time = $2
send_flag = 0;
lat_time_curr = receive_time - send_time;
jitter = lat_time_curr - lat_time_prev;
printf("%f %f\n", sim_time, jitter) > "jitter";
ave_jitter += jitter;
lat_time_prev = lat_time_curr;
count++;
}
}
END {
average = ave_jitter/count;
print"average jitter:" average;
print("Done");
}
Gnuplot Code:
Throughput:
set title 'VoWLAN over SCTP - throughput'
set grid
set ylabel 'kbps'
set xlabel 'time'
plot 'throughput' w linespoints title 'voip throughput'
Packet Loss:
set title 'VoWLAN over SCTP - packetloss'
set grid
set ylabel 'byte'
set xlabel 'time'
plot 'packetlost' w linespoints title 'voip packetlost'
Latency:
set title 'VoWLAN over SCTP - Latency'
set grid
42
set ylabel 's'
set xlabel 'time'
plot 'latency' w linespoints title 'voip latency'