?? cmd.pl
字號:
#!/usr/bin/perl$rcv = 0;$snt = 0;$tot = 0;$drp = 0;$rst = 0;$fwd = 0;$lat = 0;$started = 0;while (<>) { # extract the time of the first packet sent if (!$started){ $started = 1; /-t (\S+)/; $starttime = $1; } # extract the time of the last packet in the simulation if (/-t (\S+)/){ $finishtime = $1; } # fill array with receive times of app packets if (/^r.*-t (\S+).*-Nl AGT.*-Ii (\d+)/){ $rcv++; $recd[$2] = $1; } # fill array with send times of app packets if (/^s.*-t (\S+).*-Nl AGT.*-Ii (\d+)/){ $snt++; $sent[$2] = $1; } # count number of DSDV routing packets sent if (/^s.*message/){ $rst++; } # count number of AODV routing packets sent if (/^s.*AODV/){ $rst++; } # count number of SWARM routing packets sent if (/^s.*swarm/){ $rst++; } # count number of DSR routing packets sent if (/^s.*DSR/){ $rst++; } # count number of dropped packets if (/^d/){ $drp++; } # count number of app packets forwarded if (/^f.*tcp/){ $fwd++; } $tot++;}for ($i = 0; $i < $snt; $i++){ if (!(!($sent[$i]) || !($recd[$i]))){ $lat += ($recd[$i] - $sent[$i]); }}printf " %d %d %d %d %d %f %d %f %f %f\n" ,$snt, $rst, $rcv, $drp, $fwd, ($lat/$snt), $tot, $starttime, $finishtime, ($finishtime-$starttime);#printf "\nTotal application packets sent ... %d\n", $snt;#printf "Total routing packets sent ... %d\n", $rst;#printf "Total application packets received ... %d\n", $rcv;#printf "Total packets dropped ... %d\n", $drp;#printf "Total application packets forwarded... %d\n", $fwd;#printf "Average Application packet delay ... %f\n", ($lat/$snt);#printf "\nLines processed is ... %d\n\n", $tot;#printf "Start Time ... %f\n", $starttime;#printf "Finish Time ... %f\n", $finishtime;#printf "Elapsed Time ... %f\n\n\n", $finishtime - $starttime;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -