part 3 result analysis
play

Part 3. Result Analysis Min Chen School of Computer Science and - PowerPoint PPT Presentation

Introduction to NS-2 Part 3. Result Analysis Min Chen School of Computer Science and Engineering Seoul National University 1 Outline A Simulation and its results The Format of Trace File The AWK language Result Analysis


  1. Introduction to NS-2 Part 3. Result Analysis Min Chen School of Computer Science and Engineering Seoul National University 1

  2. Outline  A Simulation and its results  The Format of Trace File  The AWK language  Result Analysis  End-to-End Delay  Jitter  Packet Loss  Figure Output  GNUplot 2

  3. A Simulation: TCP and UDP TCP and UDP Queuing ftp tcp 1 s ~ 4.0 s sink s1 r d s2 null 0.1 s ~ 4.5 s cbr udp 3

  4. The OTcl Script set s1 [$ns node] set s2 [$ns node] set r [$ns node] set d [$ns node] $ns duplex-link $s1 $r 2Mb 10ms DropTail $ns duplex-link $s2 $r 2Mb 10ms DropTail $ns duplex-link $r $d 1.7Mb 20ms DropTail $ns queue-limit $r $d 10 $ns duplex-link-op $s1 $r orient right-down $ns duplex-link-op $s2 $r orient right-up $ns duplex-link-op $r $d orient right $ns duplex-link-op $r $d queuePos 0.5 4

  5. The OTcl Script set tcp [new Agent/TCP] $ns attach-agent $s1 $tcp set sink [new Agent/TCPSink] $ns attach-agent $d $sink $ns connect $tcp $sink $tcp set fid_ 1 set ftp [new Application/FTP] $ftp attach-agent $tcp $ftp set type_ FTP 5

  6. The OTcl Script set udp [new Agent/UDP] $ns attach-agent $s2 $udp set null [new Agent/Null] $ns attach-agent $d $null $ns connect $udp $null $udp set fid_ 2 set cbr [new Application/Traffic/CBR] $cbr attach-agent $udp $cbr set type_ CBR $cbr set packet_size_ 1000 $cbr set rate_ 1mb $cbr set random_ false 6

  7. The OTcl Script $ns at 0.1 "$cbr start" $ns at 1.0 "$ftp start" $ns at 4.0 "$ftp stop" $ns at 4.5 "$cbr stop" $ns at 4.5 "$ns detach-agent $s1 $tcp; $ns detach-agent $d $sink" $ns at 5.0 "finish" 7

  8. NAM Result 8

  9. Trace File + 0.1 1 2 cbr 1000 ------- 2 1.0 3.1 0 0 - 0.1 1 2 cbr 1000 ------- 2 1.0 3.1 0 0 + 0.108 1 2 cbr 1000 ------- 2 1.0 3.1 1 1 - 0.108 1 2 cbr 1000 ------- 2 1.0 3.1 1 1 r 0.114 1 2 cbr 1000 ------- 2 1.0 3.1 0 0 + 0.114 2 3 cbr 1000 ------- 2 1.0 3.1 0 0 - 0.114 2 3 cbr 1000 ------- 2 1.0 3.1 0 0 + 0.116 1 2 cbr 1000 ------- 2 1.0 3.1 2 2 - 0.116 1 2 cbr 1000 ------- 2 1.0 3.1 2 2 r 0.122 1 2 cbr 1000 ------- 2 1.0 3.1 1 1 + 0.122 2 3 cbr 1000 ------- 2 1.0 3.1 1 1 - 0.122 2 3 cbr 1000 ------- 2 1.0 3.1 1 1 + 0.124 1 2 cbr 1000 ------- 2 1.0 3.1 3 3 - 0.124 1 2 cbr 1000 ------- 2 1.0 3.1 3 3 r 0.13 1 2 cbr 1000 ------- 2 1.0 3.1 2 2 + 0.13 2 3 cbr 1000 ------- 2 1.0 3.1 2 2 - 0.13 2 3 cbr 1000 ------- 2 1.0 3.1 2 2 + 0.132 1 2 cbr 1000 ------- 2 1.0 3.1 4 4 ... 9

  10. Trace Format + 0.1 0.1 1 1 2 2 cbr cbr 1000 1000 ------- ------- 2 2 1.0 1.0 3.1 3.1 0 0 0 0 + r: receive r: receive Event Event +: enqueue +: enqueue Time Time -: dequeue -: dequeue From node From node d: drop d: drop To node To node Packet Type Packet Type Packet Size Packet Size Flags Flags Flow ID Flow ID src_node.port Source address src_node.port Source address Destination address dest_node.port Destination address dest_node.port Sequence number Sequence number Packet ID Packet ID 10

  11. AWK Language  Designed for text analysis  Similar to C but more simple  Read the records line by line  $0: the whole string in the corresponding line  $1: the first data in the corresponding line  $2: the second data in the corresponding line  ... + 0.1 0.1 1 1 2 2 cbr cbr 1000 1000 ------- ------- 2 2 1.0 1.0 3.1 3.1 0 0 0 0 + $1 $2 $3 $4 $5 $6 $7 $8 $9 $10 $11 $12 11

  12. AWK Language (Cont.)  Three parts in the AWK code  BEGIN  Process  END  Process Procedure 1) Read one record 2) Update the parameters 3) Run the Pattern Code 4) Repeat until no record remain 12

  13. An AWK Example AWK Code: awk.awk file BEGIN{ sum=0; } { if($1=="+") { sum++; } } END{ printf("The number of enqueue is: %d\n",sum); } 13

  14. An AWK Example (Cont.)  Use the awk.awk to anlyze the out.tr trace file ~$ awk -f awk.awk out.tr  Output the results into sum.txt ~$ awk -f awk.awk out.tr > sum.txt 14

  15. Analysis 1: End-to-End Delay  Calculate the duration of a packet End to End Delay = End Time – Start Time r d End Time s2 Start Time  In this example, we calculate the end-to-end delay for the cbr traffic via udp transmission 15

  16. Analysis 1: End-to-End Delay (Cont.) BEGIN { highest_packet_id=0; } { action = $1; time = $2; from = $3; to = $4; type = $5; pktsize = $6; flow_id = $8; src = $9; dst = $10; seq_no = $11; packet_id = $12; if ( packet_id > highest_packet_id ) highest_packet_id = packet_id; if ( start_time[packet_id] == 0 ) start_time[packet_id] = time; if ( flow_id == 2 && action != "d" ) { if( action == "r" ) { end_time[packet_id] = time; } else { end_time[packet_id] = -1; } } 16 }

  17. Analysis 1: End-to-End Delay (Cont.) END { for(packet_id=0; packet_id < highest_packet_id; packet_id++) { start = start_time[packet_id]; end = end_time[packet_id]; packet_duration = end-start; if( start < end ) { printf("%f %f\n",start, packet_duration); } } } 17

  18. Analysis 1: End-to-End Delay (Cont.)  ~$ awk -f delay.awk out.tr > delay.txt  delay.txt: 0.100000 0.038706 0.108000 0.038706 0.116000 0.038706 0.124000 0.038706 0.132000 0.038706 0.140000 0.038706 0.148000 0.038706 0.156000 0.038706 18 … ...

  19. Analysis 2: Jitter  Jitter represents the variance of delay Jitter = ( (EndTime(j)-StartTime(j)) - (EndTime(i)-StartTime(i)) ) / (j – i)  In this example, we calculate the jitter for the cbr traffic via udp transmission 19

  20. Analysis 2: Jitter(Cont.) BEGIN { highest_packet_id=0; } { action = $1; time = $2; from = $3; to = $4; type = $5; pktsize = $6; flow_id = $8; src = $9; dst = $10; seq_no = $11; packet_id = $12; if ( packet_id > highest_packet_id ) highest_packet_id = packet_id; if ( start_time[packet_id] == 0 ) { pkt_seqno[packet_id] = seq_no; start_time[packet_id] = time; } if ( flow_id == 2 && action != "d" ) { if( action == "r" ) { end_time[packet_id] = time; } else { end_time[packet_id] = -1; } } } 20

  21. Analysis 2: Jitter(Cont.) END { last_sequno = 0; last_delay = 0; seqno_diff = 0; for(packet_id=0; packet_id < highest_packet_id; packet_id++) { start = start_time[packet_id]; end = end_time[packet_id]; packet_duration = end-start; if( start < end ) { seqno_diff = pkt_seqno[packet_id]-last_seqno; delay_diff = packet_duration - last_delay; if ( seqno_diff == 0 ) { jitter = 0; } else { jitter = delay_diff/seqno_diff; } printf("%f %f\n",start, jitter); last_seqno = pkt_seqno[packet_id]; last_delay = packet_duration; } } 21 }

  22. Analysis 2: Jitter(Cont.)  ~$ awk jitter.awk out.tr > jitter.txt 0.100000 0.000000 0.108000 0.000000 0.116000 0.000000 0.124000 -0.000000 0.132000 0.000000 0.140000 0.000000 0.148000 0.000000 0.156000 -0.000000 … ... 22

  23. Analysis 3: Packet Loss  In the transmission, some of the packets may be lost due to the overflow of the queue Loss = Packets_Sent - Packets_Recieve r d End Time s2 Start Time  In this example, we calculate the packet loss for the cbr traffic via udp transmission 23

  24. Analysis 3: Packet Loss(Cont.) BEGIN { fsDrops = 0; numFs = 0; } { action = $1; time = $2; from = $3; to = $4; type = $5; pktsize = $6; flow_id = $8; src = $9; dst = $10; seq_no = $11; packet_id = $12; if ( from == 1 && to == 2 && action == "+" ) { numFs++; } if ( flow_id == 2 && action == "d" ) { fsDrops++; } } END{ printf("number of packets sent:%d lost:%d\n",numFs, fsDrops); } 24

  25. Practice 1: Throughput  To calculate the average throughput of the cbr traffic between node 2 and node 3 Average Throughput = Total Recieved Bytes / Elapsed Time  Once node 3 recieve a packet, print out the real-time thoughput 25

  26. Figure Output  A picture paints a thousand words  In a paper, figures(plots) are always the essential parts of the simulation and analysis section  Tools for figure drawing  Matlab  Mathematica  GNUplot 26

  27. GNUplot  Portable command-line driven graphing utility  Support Linux, Windows, Mac OS...  It allows scientists and students to visualize mathematical functions and data  Supports many types of plots in either 2D and 3D.  http://www.gnuplot.info/  Installation in Ubuntu from source  sudo apt-get install gnuplot 27

  28. How to draw a figure  Enter the GNUplot model ~$ gnuplot  Draw a plot gnuplot > plot ”delay.txt” To denote the The command for To denote the The command for The file name The file name gnuplot model drawing gnuplot model drawing 28

  29. Result from the GNUplot 29

  30. Commands in GNUplot (1)  Set Axis  Range  Step  Example  For x axis gnuplot > set xtics -10,1,10 gnuplot > plot sin(x)  Showing range ` ` gnuplot > set yrange [-2:2] gnuplot > plot sin(x) 30

  31. Commands in GNUplot (2)  Show grid gnuplot > set grid gnuplot > plot sin(x) 31

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend