You are on page 1of 5

Appendix

Appendix:

Performance Tuning in Geographic Routing for Wireless Networks............. Page | 169


Appendix

To evaluate the trace file generated as simulation results having the above
describe trace format we use AWK scripts to find delay, throughput.

AWK is a programming language that is designed for processing text-


based data, either in files or data streams, and was created at Bell Labs in
the 1970s. The name AWK is derived from the family names of its
authors - Alfred Aho, Peter Weinberger and Brian Kernighan.

AWK is a language for processing files of text. A file is treated as a


sequence of records, and by default each line is a record. Each line is
broken up into a sequence of fields, so we can think of the first word in a
line as the first field, the second word as the second field, and so on. An
AWK program is of a sequence of pattern-action statements. AWK reads
the input a line at a time. A line is scanned for each pattern in the
program, and for each pattern that matches, the associated action is
executed.

This information comes from "The ns Manual" "Mobile Networking in


ns: Trace Support" chapter, and the "trace/cmu-trace.cc" file. Wireless
traces begin with one of four characters followed by one of two different
trace formats, depending on whether the trace logs the X and Y
coordinates of the mobile node.

Performance Tuning in Geographic Routing for Wireless Networks............. Page | 170


Appendix

Event Abbreviation Type Value

%.9f %d (%6.2f %6.2f) %3s %4s %d %s %d


[%x %x %x %x]

%.9f _%d_ %3s %4s %d %s %d [%x %x %x %x]

double Time

int Node ID

double X Coordinate (If Logging Position)

double Y Coordinate (If Logging Position)

s: Send string Trace Name


Wireless r: Receive
Event d: Drop string Reason
f: Forward
int Event Identifier

string Packet Type

int Packet Size

hexadecimal Time To Send Data

hexadecimal Destination MAC Address

hexadecimal Source MAC Address

hexadecimal Type (ARP, IP)

Some older versions of NS2 have five hexidecimal values between the
square braces. The first hexidecimal value is the MAC frame control
information, and the remaining hexidecimal values are the same as listed
above.

Depending on the packet type, the trace may log additional information:

Performance Tuning in Geographic Routing for Wireless Networks............. Page | 171


Appendix

AWT Script: Throughput


# ===========================================================
# AWK Script for calculating:
# => Throughput.
#
=============================================================
BEGIN {
recvdSize = 0
startTime = 400
stopTime = 0
}

{
event = $1
time = $2
node_id = $3
pkt_size = $8
level = $4

# Store start time


if (level == "AGT" && event == "s" && pkt_size >= 512) {
if (time < startTime) {
startTime = time
}
}

# Update total received packets' size and store packets


arrival time
if (level == "AGT" && event == "r" && pkt_size >= 512) {
if (time > stopTime) {
stopTime = time
}
# Rip off the header
hdr_size = pkt_size % 512
pkt_size -= hdr_size
# Store received packet's size
recvdSize += pkt_size
}
}

END {
printf("Average Throughput[kbps] = %.2f\t\t
StartTime=%.2f\tStopTime=%.2f\n",(recvdSize/(stopTime-
startTime))*(8/1000),startTime,stopTime)
}
AWK Script: End to End Delay
# ===========================================================
# AWK Script for calculating:
# => Average End-to-End Delay.
#
=============================================================
BEGIN {
seqno = -1;

Performance Tuning in Geographic Routing for Wireless Networks............. Page | 172


Appendix

# droppedPackets = 0;
# receivedPackets = 0;
count = 0;
}
{
if($4 == "AGT" && $1 == "s" && seqno < $6) {
seqno = $6;
}
# else if(($4 == "AGT") && ($1 == "r")) {
# receivedPackets++;
# } else if ($1 == "D" && $7 == "tcp" && $8 > 512){
# droppedPackets++;
# }

#end-to-end delay
if($4 == "AGT" && $1 == "s") {
start_time[$6] = $2;
} else if(($7 == "tcp") && ($1 == "r")) {
end_time[$6] = $2;
} else if($1 == "D" && $7 == "tcp") {
end_time[$6] = -1;
}
}
END {
for(i=0; i<=seqno; i++) {
if(end_time[i] > 0) {
delay[i] = end_time[i] - start_time[i];
count++;
}
else
{
delay[i] = -1;
}
}
for(i=0; i<=seqno; i++) {
if(delay[i] > 0) {
n_to_n_delay = n_to_n_delay + delay[i];
}
}
n_to_n_delay = n_to_n_delay/count;
print "\n";
# print "GeneratedPackets = " seqno+1;
# print "ReceivedPackets = " receivedPackets;
# print "Packet Delivery Ratio = "
receivedPackets/(seqno+1)*100
#"%";
# print "Total Dropped Packets = " droppedPackets;
print "Average End-to-End Delay = " n_to_n_delay * 1000 "
ms";
print "\n";

Performance Tuning in Geographic Routing for Wireless Networks............. Page | 173

You might also like