📄 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);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -