?? analyse2.pl
字號:
#!/usr/bin/perl#counting by source, how much sent/received$appPacketsSent = 0;$appPacketsReceived = 0;$appBytesSent = 0;$appBytesReceived = 0;$lastAppPacketsSent =0;$lastAppPacketsReceived =0;$tick = 5;$lastTick=0-$tick;printf "Time, CumAppSent, CumAppRecv, CumBytesSent, CumBytesRecv, CumPacketDeliveryRatioTotal, AppSent, AppRecv, PacketDeliveryRatioLast\n";while (<>) { if(/-t (\S+)/) { $time=$1; if($time > ($lastTick+$tick) ) { $lastTick = $lastTick + $tick; ($thisSent, $thisRecv) = ($appPacketsSent-$lastAppPacketsSent, $appPacketsReceived-$lastAppPacketsReceived); $lastAppPacketsReceived = $appPacketsReceived; $lastAppPacketsSent = $appPacketsSent; if($thisSent>0) { printf "%f, %d, %d, %d, %d, %f, %d, %d, %f\n", $lastTick, $appPacketsSent, $appPacketsReceived, $appBytesSent, $appBytesReceived, ($appPacketsReceived/$appPacketsSent), $thisSent, $thisRecv, ($thisRecv/$thisSent); } else { printf "%f, %d, %d, %d, %d, , %d, %d, \n", $lastTick, $appPacketsSent, $appPacketsReceived, $appBytesSent, $appBytesReceived, $thisSent, $thisRecv; } } if (/^.*-Nl AGT/) { # Packet sent/received by the app stack if (/^r.*-Is (\S+) -Id (\S+).*-Il (\S+)/) { $appPacketsReceived++; $appBytesReceived+=$3; $pair = $1."->".$2; $appPacketsReceived{$pair}++; $appBytesReceived{$pair}+=$3; } if (/^s.*-Is (\S+) -Id (\S+).*-Il (\S+)/) { $appPacketsSent++; $appBytesSent+=$3; $pair = $1."->".$2; $appPacketsSent{$pair}++; $appBytesSent{$pair}+=$3; } } }}printf "TOT, %d, %d, %d, %d, %f\n", $appPacketsSent, $appPacketsReceived, $appBytesSent, $appBytesReceived, ($appPacketsReceived/$appPacketsSent);
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -