Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question
up vote 1 down vote accepted

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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