Tracing and awk in ns2

6,998 views

Published on

Its about the individual columns in the trace file of ns2 (Old Trace Format)

Published in: Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
6,998
On SlideShare
0
From Embeds
0
Number of Embeds
6,702
Actions
Shares
0
Downloads
15
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Tracing and awk in ns2

  1. 1. Tracing, awk and xgraph T S Pradeep Kumar http://www.nsnam.com
  2. 2. 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
  3. 3. Wired Trace format C1 C2 C3 C4 type identifier time source node dest. node C5 C6 C7 C8 pkt name pkt size flags flow id C9 C10 C11 C12 Source Addr. Dest. Addre Seq Num Pkt unique ID
  4. 4. Wired Trace Format • Type identifier (+, -, r, d, c) • + - enqueue • - dequeue • r - receive • d - drop • c - packet collision
  5. 5. 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
  6. 6. 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
  7. 7. 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
  8. 8. 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
  9. 9. AWK • Syntax for AWK inside a file is • BEGIN { • } • { • } • END { • }
  10. 10. 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
  11. 11. Link throughput • Ratio of • No of bits from Node A to Node B • to • Observation duration (total time)
  12. 12. 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."; • };
  13. 13. 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
  14. 14. 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; • }; • }; • }
  15. 15. 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."; • };
  16. 16. 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)
  17. 17. Delay calculation • Average delay is ratio of • Sum of all delay samples • to • number of samples

×