17
Tracing, awk and xgraph T S Pradeep Kumar http://www.nsnam.com

Tracing and awk in ns2

Embed Size (px)

Citation preview

Page 1: Tracing and awk in ns2

Tracing, awk and xgraph

T S Pradeep Kumar http://www.nsnam.com

Page 2: Tracing and awk in ns2

Tracing• Identify the performance parameters of your network

• Post processing of results in ns2

• Know the format of trace files in ns2 (old and new trace format)

• Know a scripting language for processing the results. AWK is the apt choice

• Compute the performance parameters

Page 3: Tracing and awk in ns2

Wired Trace formatC1 C2 C3 C4

type identifier time source node dest. nodeC5 C6 C7 C8

pkt name pkt size flags flow idC9 C10 C11 C12

Source Addr. Dest. Addre Seq Num Pkt unique ID

Page 4: Tracing and awk in ns2

Wired Trace Format• Type identifier (+, -, r, d, c)

• + - enqueue

• - dequeue

• r - receive

• d - drop

• c - packet collision

Page 5: Tracing and awk in ns2

Wired Trace Format

• C2: Time at which the packet tracing happend

• C3-C4 : Source and destination ID

• C5: name of the packet

• C6: packet size

Page 6: Tracing and awk in ns2

Wired Trace Format• C7: Flags

• 7 digit flag string

• - disable

• E - Explicit congestion notification (ECN)

• P - priority in the IP header

• Not in use

• A- congestion action

• E - Congestion has occured

• F - The TCP fast start is used

• N - ECN is ON

Page 7: Tracing and awk in ns2

Wired Trace Format

• C8: Flow ID

• C9-C10 - Source Address and Destination address where the format is a.b (a is the address and b is the port)

• C11 - Sequence Number

• C12 - Packet Unique ID

Page 8: Tracing and awk in ns2

AWK Scripts

• Either written in one line or written as a separate file with extension .awk (file.awk)

• The syntax to run the awk script is

• awk -f file.awk file.tr

• gawk -f file.awk file.tr

Page 9: Tracing and awk in ns2

AWK• Syntax for AWK inside a file is

• BEGIN {

• }

• {

• }

• END {

• }

Page 10: Tracing and awk in ns2

AWK• FS - Field Separator

• RS - Record Separator

• NR - number of records

• NF - Number of fields in current record

• $0 is the current column

• $1 is the first column

• $2 is the second column and so on

Page 11: Tracing and awk in ns2

Link throughput

• Ratio of

• No of bits from Node A to Node B

• to

• Observation duration (total time)

Page 12: Tracing and awk in ns2

Link throughput• BEGIN {

• lineCount = 0;totalBits = 0;

• }

• {

• if ($3=="0" &&$4=="2") {

• totalBits += 8*$6;

• if ( lineCount==0 ) {

• timeBegin = $2; lineCount++;

• } else {

• timeEnd = $2;

• };

• };

• }

• END {

• duration = timeEnd-timeBegin;

• print "Number of records is " NR;

• print "Transmission: 0 to 1";

• print " - Total transmitted bits = " totalBits " bits";

• print " - duration = " duration " s";

• print " - Thoughput = " totalBits/duration/1e3 " kbps.";

• };

Page 13: Tracing and awk in ns2

End to End throughput

• Ratio of

• no of bits from Node A to node B whose source is S and destination is D

• to

• Observation Destination

Page 14: Tracing and awk in ns2

End to End throughput• BEGIN {

• src1 = 0.0; dst1 = 3.1;

• src2 = 3.0; dst2 = 1.0;

• lineCount1 = 0;totalBits1 = 0;

• lineCount2 = 0;totalBits2 = 0;

• }

• {

• if ($1=="r" && $3=="2" &&$4== "3" && $9==src1 && $10==dst1) {

• totalBits1 += 8*$6;

• if ( lineCount1==0 ) {

• timeBegin1 = $2; lineCount1++;

• } else {

• timeEnd1 = $2;

• };

• };

• if ($1=="r" && $3=="3" &&$4== "2" && $9==src2 && $10==dst2) {

• totalBits2 += 8*$6;

• if ( lineCount2==0 ) {

• timeBegin2 = $2; lineCount2++;

• } else {

• timeEnd2 = $2;

• };

• };

• }

Page 15: Tracing and awk in ns2

End to End Throughput• END{

• duration = timeEnd1-timeBegin1;

• print "Transmission: source " src1 "->Destination" dst1;

• print " - Total transmitted bits = " totalBits1 " bits";

• print " - duration = " duration " s";

• print " - Thoughput = " totalBits1/duration/1e3 " kbps.";

• print " ";

• duration = timeEnd2-timeBegin2;

• print "Transmission: source " src2 "->Destination" dst2;

• print " - Total transmitted bits = " totalBits2 " bits";

• print " - duration = " duration " s";

• print " - Thoughput = " totalBits2/duration/1e3 " kbps.";

• };

Page 16: Tracing and awk in ns2

Link delay

Type of Delay Begin Node End Node

Link Delay Pkt transmitter (C3) Pkt Receiver (C4)

End to End Delay Pkt Creator(C9) Pkt destructor(C10)

Page 17: Tracing and awk in ns2

Delay calculation

• Average delay is ratio of

• Sum of all delay samples

• to

• number of samples