📄 wlan-lat
字号:
#!/bin/tcsh## works on a trace file produced by ns# outputs layer-to-layer per-packet latency for a given flow,# indexed by the send time for the packetif ( $#argv != 3 ) then echo usage: echo " " $0 \<scenario\> \<flow id\> \<layer\> exit 1endifset scenario = $1set flow = $2set layer = $3set sendlayer = $layerif ( $layer == 'MAC' ) then set sendlayer = IFQendifset tracefile = $scenario.trset tmpfile = `mktemp /tmp/latency.sendtimes.XXXXXX`set outfile = $scenario.$flow.latrm -f $outfiletouch $outfile# determine the first packet for a flow based on the first pkt# received at the agent layerset pkt = `egrep "^r .*\-Nl AGT .*\-If $flow " $tracefile | head -1 | gawk '{print $43;}'`# determine the sender/receiver based on the first packet exchanged# the true receiver is the last node to receive the packetset snode = `egrep "^s .*\-Nl $layer .*\-If $flow .*\-Ii $pkt " $tracefile | head -1 | gawk '{print $9;}'`set rnode = `egrep "^r .*\-Nl $layer .*\-If $flow .*\-Ii $pkt " $tracefile | tail -1 | gawk '{print $9;}'`# determine per-packet send times; use the first transmission# time if there are retransmissionsegrep "^s .*\-Ni $snode .*\-Nl $sendlayer .*\-If $flow " $tracefile | gawk '{print $43, $3;}' | sort -k1,1g -u >> $tmpfile# determine per-packet recv times, match them to send times# based on the packet id, and compute latency; use the time# of the first recv if there were retransmissionsegrep "^r .*\-Ni $rnode .*\-Nl $layer .*\-If $flow " $tracefile | gawk '{print $43, $3;}' | sort -k1,1g -u | \gawk -v sendfile=$tmpfile -v outfile=$outfile '{ \ pkt = $1; \ rtime = $2; \ getline < sendfile; \ while ($1 < pkt) { getline < sendfile }; \ if ($1 > pkt) { print "FATAL ERROR"; exit 1 }; \ printf "%.9f %.9f\n", $2, (rtime - $2) >> outfile; \}'# run latstats tool on the outfilegawk '{print $2;}' $outfile | latstats | gawk '{print "Latency", $0}'# cleanuprm $tmpfile
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -