[AWK] Ekstrak Pita Lebar TCPDump
AWK is really awesome script ! almost of my PhD code rely on AWK. At This time, I wanna share my snippet to extract uplink adn downlink bandwith for certain port in localhost. In this case, suppose that we will investigate port 8000, thus I put regex
(.*)8000:$
ok, let’s play TCPDUMP now.
tcpdump -l -i lo port 8000 -nNqttf > tcpdump
Here is the following awk code to parse each line of tcpdump that are stored in tcpdump file
cat tcpdump | awk -F " " '{
if($5 ~ /(.*)8000:$/)
uplink=uplink+$7
else
downlink=downlink+$7
}
END {
print uplink
print downlink
}'
Above code will produce the number of uplink and downlink in bytes.
thanx infonya…
salam kenal yaa…