NS2 Post Analysis : NS2 Post Analysis V. Vasantha M.E.,
Senior Lecturer,
Dept. Of Information Technology,
National Engineering College,
K. R. Nagar, Kovilpatti.
vivekvasantha@gmail.com
Tracing the Network : 10/4/2010 V. Vasantha, NEC, Kovilpatti 2 Tracing the Network Tracing File Contents
Each lines consists of:
● Event Descriptor (+, -, d, r)
● Simulation time (in seconds) of that event
● From Node & To Node, which identify the link on which the event occurred
● Packet type
● Packet size
● Flags (appeared as "------" since no flag is set). Currently, NS implements only the Explicit Congestion Notification (ECN) bit, and the remaining bits are not used.
● Flow id (fid)
● Source and destination address in forms of "node.port".
● The network layer protocol's packet sequence number. What about UDP?
● The last field shows the unique id of the packet.
Trace File format : 10/4/2010 V. Vasantha, NEC, Kovilpatti 3 Trace File format We need to extract the necessary data out of this file. How?
grep : 10/4/2010 V. Vasantha, NEC, Kovilpatti 4 grep It is a UNIX command to filter a file.
The name comes from “search globally for lines matching the regular expression and print them”
grep takes a regular expression on the command line, reads the standard input or list of files, and outputs the lines containing matches for the regular expression
grep Example : 10/4/2010 V. Vasantha, NEC, Kovilpatti 5 grep Example Example 1
In the trace file, if you are intersted only in data concerning tcp packtes that went from node 0 to node 2
grep “0 2 tcp” tr1.tr > tr2.tr
grep Example – contd., : 10/4/2010 V. Vasantha, NEC, Kovilpatti 6 grep Example – contd., Example 2
In the trace file, if you are intersted only in the received packtes
grep “^r” tr1.tr > tr2.tr
grep Example – contd., : 10/4/2010 V. Vasantha, NEC, Kovilpatti 7 grep Example – contd., Example 3
In the trace file, if you are intersted only in lines the begin with “s” and have “tcp 1020” later
grep “^r” tr1.tr | grep “tcp 1020” > tr2.tr
AWK : 10/4/2010 V. Vasantha, NEC, Kovilpatti 8 AWK AWK is a general purpose computer language
AWK is designed for processing text-based data, either in files or data streams
The name AWK is derived from the surnames of its authors — Alfred Aho, Peter Weinberger, and Brian Kernighan;
AWK – contd., : 10/4/2010 V. Vasantha, NEC, Kovilpatti 9 AWK – contd., How to run AWK file?
awk -f file1.awk file2.txt
awk -f file1.awk file2.txt > out.txt file1.awk : is a command file
file2.txt : is a primary input file
out.txt : is an output file
Using AWK with NS-2 : 10/4/2010 V. Vasantha, NEC, Kovilpatti 10 Using AWK with NS-2
Slide 11 : 10/4/2010 V. Vasantha, NEC, Kovilpatti 11 Queries ???
Thank U !!! http://www.wiziq.com/vasantha