I need to gather some network statistic to test my server application. I've tried many linux tools, but nothing I've found suits my needs.

Basically I want to gather some UDP statistics (bytes/time_interval, packets/time_interval, packets_loss), but regarding only two particular hosts - for example I want to get UDP statistic from traffic going from IP_A:PORT_A to IP_B:PORT_B.

Tools like tcpdump/wireshark can easily dump such traffic but I have problems with getting statistics like temporary speed (too see throughput peeks), and linux system statistics gives me number for all traffic.

It would be better to get text output so it will be possible to parse it and put to gnuplot. I was able to get desired info from iptables, but parsing output from

iptables -L -v

seems quite difficult.

Anyone has any idea how can I achieve it?

Thanks in advance


Use custom iptables rules:

iptables -I INPUT -p udp -s IP_A --sport PORT_A -d IP_B --dport PORT_B
iptables -I OUTPUT -p udp -s IP_B --sport PORT_B -d IP_A --dport PORT_A

And then poll it at regular intervals (every second? 5 seconds?) noting the changes and doing the appropriate calculations.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.