Download presentation
Presentation is loading. Please wait.
1
M. Dahshan - TCOM52721 TCOM 5272 Telecomm Lab Dr. Mostafa Dahshan OU-Tulsa 4W 2 nd floor 660-3713 mdahshan@ou.edu
2
M. Dahshan - TCOM52722 References Awk – A Tutorial and Introduction www.grymoire.com/Unix/Awk.html www.grymoire.com/Unix/Awk.html NS by Example nile.wpi.edu/NS/ nile.wpi.edu/NS/
3
M. Dahshan - TCOM52723
4
4 Awk utility Awk is an excellent filtering and reporting utility A pseudo-C interpreter Same C arithmetic Supports associative arrays (array index can be a variable of any type)
5
M. Dahshan - TCOM52725 Awk – Basic Structure pattern { action } pattern specifies when action is performed Awk is line oriented Default pattern matches every line Two other important patterns BEGIN END
6
M. Dahshan - TCOM52726 Awk – Basic Structure Example on an NS trace file + 0.5075 0 1 cbr 210 ------- 0 0.0 1.0 2 2 - 0.5075 0 1 cbr 210 ------- 0 0.0 1.0 2 2 r 0.51112 0 1 cbr 210 ------- 0 0.0 1.0 0 0 BEGIN {print “Time\tSequence Number”} {print $2”\t”$11} END {print “DONE”} Output TimeSequence Number 0.50752 0.50752 0.51112 0 DONE
7
M. Dahshan - TCOM52727 Calculating Packet Delay BEGIN { # simple awk script to generate end-to-end # packet lifetime statistics # in a form suitable for plotting with xgraph # Lloyd Wood, July 1999. # http://www.ee.surrey.ac.uk/Personal/L.Wood/ns/ highest_packet_id = 0; }
8
M. Dahshan - TCOM52728 Calculating Packet Delay { action = $1; time = $2; node_1 = $3; node_2 = $4; src = $5; flow_id = $8; node_1_address = $9; node_2_address = $10; seq_no = $11; packet_id = $12;
9
M. Dahshan - TCOM52729 Calculating Packet Delay if ( packet_id > highest_packet_id ) highest_packet_id = packet_id; # getting start time is not a problem, provided you're not starting # traffic at 0.0. # could test for sending node_1_address or flow_id here. if ( start_time[packet_id] == 0 ) start_time[packet_id] = time; # only useful for small unicast where packet_id doesn't wrap. # checking receive means avoiding recording drops if ( action != "d" ) { if ( action == "r" ) { # could test for receiving node_2_address or flow_id here. end_time[packet_id] = time; } } else { end_time[packet_id] = -1; }
10
M. Dahshan - TCOM527210 Calculating Packet Delay 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("%d %f\n", packet_id, packet_duration); }
11
M. Dahshan - TCOM527211 Calculate Average Delay First, calculate packet delay { #increment number of lines num_lines++; #sum the delay values #column 2 is the packet delay sum_delay=sum_delay+$2; } END {print sum_delay/num_lines}
12
M. Dahshan - TCOM527212 Calculating Dropped Packets BEGIN{dropped=0} { action = $1; if(action=="d") dropped++; } END{print dropped}
13
M. Dahshan - TCOM527213 Calculating Throughput Throughput = total number of bytes received BEGIN{dest=3} { action = $1; node2 = $4; packet_size = $6; if(action=="r" && node2=dest) throughput + = packet_size; } END{throughput}
14
M. Dahshan - TCOM527214 Calculating Jitter Jitter = difference between packet delays First, calculate packet delay
15
M. Dahshan - TCOM527215 Calculating Jitter BEGIN {old_delay=0.0;} { delay = $2; if(old_delay>0) jitter=delay-old_delay; else jitter=0.0; #if(jitter<0) jitter = -jitter; old_delay = delay; print $1 " " jitter; }
16
M. Dahshan - TCOM527216 cat, grep, wc We can simplify processing by doing some pre-filtering using grep We can also do some quick calculations by combining multiple small commands Take the output of a command as an input to the next command (pipes)
17
M. Dahshan - TCOM527217 Print only CBR Traffic grep cbr out.tr + 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
18
M. Dahshan - TCOM527218 Print CBR Traffic From 2 to 3 grep "2 3 cbr" out.tr + 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.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.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.138 2 3 cbr 1000 ------- 2 1.0 3.1 3 3 - 0.138 2 3 cbr 1000 ------- 2 1.0 3.1 3 3 r 0.138706 2 3 cbr 1000 ------- 2 1.0 3.1 0 0 + 0.146 2 3 cbr 1000 ------- 2 1.0 3.1 4 4
19
M. Dahshan - TCOM527219 Print Only Received Packets grep ^r out.tr r 0.114 1 2 cbr 1000 ------- 2 1.0 3.1 0 0 r 0.122 1 2 cbr 1000 ------- 2 1.0 3.1 1 1 r 0.13 1 2 cbr 1000 ------- 2 1.0 3.1 2 2 r 0.138 1 2 cbr 1000 ------- 2 1.0 3.1 3 3 r 0.138706 2 3 cbr 1000 ------- 2 1.0 3.1 0 0 r 0.146 1 2 cbr 1000 ------- 2 1.0 3.1 4 4 r 0.146706 2 3 cbr 1000 ------- 2 1.0 3.1 1 1 r 0.154 1 2 cbr 1000 ------- 2 1.0 3.1 5 5 r 0.154706 2 3 cbr 1000 ------- 2 1.0 3.1 2 2 r 0.162 1 2 cbr 1000 ------- 2 1.0 3.1 6 6
20
M. Dahshan - TCOM527220 Print CBR Received at Node 3 grep ^r out.tr | grep "2 3 cbr" r 0.138706 2 3 cbr 1000 ------- 2 1.0 3.1 0 0 r 0.146706 2 3 cbr 1000 ------- 2 1.0 3.1 1 1 r 0.154706 2 3 cbr 1000 ------- 2 1.0 3.1 2 2 r 0.162706 2 3 cbr 1000 ------- 2 1.0 3.1 3 3 r 0.170706 2 3 cbr 1000 ------- 2 1.0 3.1 4 4 r 0.178706 2 3 cbr 1000 ------- 2 1.0 3.1 5 5 r 0.186706 2 3 cbr 1000 ------- 2 1.0 3.1 6 6 r 0.194706 2 3 cbr 1000 ------- 2 1.0 3.1 7 7 r 0.202706 2 3 cbr 1000 ------- 2 1.0 3.1 8 8 r 0.210706 2 3 cbr 1000 ------- 2 1.0 3.1 9 9
21
M. Dahshan - TCOM527221 Calculate Dropped Packets! grep ^d out.tr | wc –l 18
22
M. Dahshan - TCOM527222
23
M. Dahshan - TCOM527223 Trace Analysis Example Download the file Trace Analysis Example http://nile.wpi.edu/NS/Example/ns- simple-trace.tcl http://nile.wpi.edu/NS/Example/ns- simple-trace.tcl
24
M. Dahshan - TCOM527224 Activity 1: Calculate Packet Delay Use the provided packet delay script to calculate the delay for CBR traffic only! Save the output to a file cbr_delay.txt Commands: ns ns-simple-trace.tcl grep cbr out.tr | awk -f pkt_delay.awk > cbr_delay.txt
25
M. Dahshan - TCOM527225 Activity 2: Calculate Jitter Use the provided packet jitter script to calculate the delay for CBR traffic Save the output to a file cbr_jitter.txt Commands: awk -f jitter.awk cbr_delay.txt > cbr_jitter.txt
26
M. Dahshan - TCOM527226 Activity 3: Plot Delay and Jitter Use xgraph or gnuplot to plot the delay and jitter for CBR traffic on the same graph For xgraph xgraph cbr_delay.txt cbr_jitter.txt
27
M. Dahshan - TCOM527227 Activity 3: Plot Delay and Jitter Using gnuplot gnuplot gnuplot>set key left top Right noreverse enhanced box gnuplot>set xlabel "Packet ID" gnuplot>set ylabel "Delay and Jitter (sec)" gnuplot>plot “cbr_delay.txt" using 1:2 title “Packet Delay" with lines 1, “cbr_jitter.txt" using 1:2 title “Jitter" with lines 2
28
M. Dahshan - TCOM527228 Activity 4: Stochastic Fair Queue Edit the ns-sample-trace.tcl script Change the queue type from DropTail to SFQ Save as ns-sample-trace-sfq.tcl Recalculate delay, jitter and plot the results (cbr_delay_sfq.txt, cbr_jitter_sfq.txt) Discuss your findings
29
M. Dahshan - TCOM527229 Activity 4: Random Early Detection Edit the ns-sample-trace.tcl script Change the queue type from DropTail to RED Save as: ns-sample-trace-red.tcl Recalculate delay, jitter and plot the results (cbr_delay_red.txt, cbr_jitter_red.txt) Discuss your findings
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.