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

About these ads
  1. thanx infonya…

  2. salam kenal yaa…

  1. Belum ada trackback.

Tinggalkan Balasan

Fill in your details below or click an icon to log in:

WordPress.com Logo

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

Twitter picture

You are commenting using your Twitter account. Log Out / Ubah )

Facebook photo

You are commenting using your Facebook account. Log Out / Ubah )

Connecting to %s

Ikuti

Get every new post delivered to your Inbox.

Bergabunglah dengan 3.075 pengikut lainnya.