Visualize Trace File Data with GnuPlot

Use gnuplot to visualize the trace file. For this example, I use the trace file which is generated from this code. The first step is using awk to get throughput of cbr and tcp packets from node 2 to node 3.

Create awk program : myflowcalcall.awk

# a general script for computing throughput

BEGIN {
arguments = 2;
if (ARGC < arguments || ARGC > arguments || flowtype == 0) {
printf(“error: wrong number of arguments.\nawk: usage – awk -f flowcalc.awk [-v graphgran=value] [-v fidfrom=value] [-v fidto=value] [-v fid=value] -v flowtype=\”type\” -v outdata_file=\”filename\” indata_file\n–%d”,ARGC);
exit;
}
measure_interval = 0.5;
bits = 0;
first_time = graphgran;
}

{
if (($1 == “r”) &&
((fidfrom == 0 && fidto ==0) || (($8 == fid) && ($3 == fidfrom) && ($4 == fidto))) &&
(flowtype == “all” || flowtype == $5)) {
if (($2 – first_time) > measure_interval) {
first_time = first_time + measure_interval;
rate = (bits/1000000)/first_time;
print filename first_time, rate;
}
bits = bits + $6 * 8;
}
}
END {
measure_interval = 0.5;
first_time = first_time + measure_interval;
rate = (bits/1000000)/first_time;
print filename first_time, rate;
}

Run at the terminal :

$ awk -f myflowcalcall.awk -v graphgran=0 -v fidfrom=2 -v fidto=3 -v fid=1 -v flowtype=”tcp” -v outdata_file=”nothing” out_example4.tr > thr1

$ awk -f myflowcalcall.awk -v graphgran=0 -v fidfrom=2 -v fidto=3 -v fid=2 -v flowtype=”cbr” -v outdata_file=”nothing” out_example4.tr > thr2

Result : thr1

0.5 0
1 0.00032
1.5 0.20544
2 0.29968
2.5 0.349568
3 0.413333
3.5 0.430354
4 0.47224
4.5 0.43456

the above data comes from :

r 1.034894 2 3 tcp 40 ——- 1 0.0 3.0 0 113
r 1.104296 2 3 tcp 1040 ——- 1 0.0 3.0 1 123
r 1.502847 2 3 tcp 1040 ——- 1 0.0 3.0 44 238
r 2.006188 2 3 tcp 1040 ——- 1 0.0 3.0 61 375
r 2.500588 2 3 tcp 1040 ——- 1 0.0 3.0 91 511
r 3.008447 2 3 tcp 1040 ——- 1 0.0 3.0 135 658
r 3.5068 2 3 tcp 1040 ——- 1 0.0 3.0 167 793
r 4.005153 2 3 tcp 1040 ——- 1 0.0 3.0 213 939

Result : thr2

0.5 0.736
1 0.864
1.5 0.858667
2 0.892
2.5 0.9216
3 0.928
3.5 0.944
4 0.942
4.5 0.956444
5 0.8672

the above data comes from :

r 0.506706 2 3 cbr 1000 ——- 2 1.0 3.1 46 46
r 1.002706 2 3 cbr 1000 ——- 2 1.0 3.1 108 108
r 1.507553 2 3 cbr 1000 ——- 2 1.0 3.1 166 239
r 2.001294 2 3 cbr 1000 ——- 2 1.0 3.1 228 373
r 2.505294 2 3 cbr 1000 ——- 2 1.0 3.1 294 512
r 3.003553 2 3 cbr 1000 ——- 2 1.0 3.1 354 657
r 3.501906 2 3 cbr 1000 ——- 2 1.0 3.1 420 792
r 4.000259 2 3 cbr 1000 ——- 2 1.0 3.1 478 937
r 4.506706 2 3 cbr 1000 ——- 2 1.0 3.1 546 1028

Visualize thr1 and thr2 with gnuplot :

$ gnuplot
gnuplot> set title “One CBR Competes with One FTP”
gnuplot> set xlabel “Time in second”
gnuplot> set ylabel “Throughput in Mbps”
gnuplot> set key 3,1.8
gnuplot> set label “Yield Point” at 0.003,260
gnuplot> set arrow from 0.002,250 to 0.003,280
gnuplot> set xr[0:5]
gnuplot> set yr[0:2]
gnuplot> plot “thr1” using 1:2 title ‘CBR Flow’ with lines,\
> “thr2” using 1:2 title ‘TCP Flow’ with lines

Final Result :

References :

Strive To Be Independence

May 15, 2008
Taipei City
High Speed Network Lab

Udin Harun

Comments are closed.

%d bloggers like this: