[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.

Iklan
  1. thanx infonya…

  2. salam kenal yaa…

  1. No trackbacks yet.

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s