Trace文件分析

delay.awk

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;
}
}
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);
}
}

命令行输入:gawk -f delay.awk wired.tr >delay

gnuplot

plot "delay" using 1:2 with lines

 

throughput.awk

BEGIN {
init=0;
i=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(action=="r" && from==2 && to==3 && flow_id==2) {
pkt_byte_sum[i+1]=pkt_byte_sum[i]+ pktsize;

if(init==0) {
start_time = time;
init = 1;
}

end_time[i] = time;
i = i+1;
}
}
END {
printf("%.2f\t%.2f\n", end_time[0], 0);

for(j=1 ; j<i ; j++){
th = pkt_byte_sum[j] / (end_time[j] - start_time)*8/1000;
printf("%.2f\t%.2f\n", end_time[j], th);
}
printf("%.2f\t%.2f\n", end_time[i-1], 0);
}

命令行输入:gawk -f throughput.awk wired.tr >delay

gnuplot

plot "throughput" using 1:2 with lines

 

 

posted @ 2016-07-19 19:21  kun先生  阅读(1117)  评论(0编辑  收藏  举报