Myung Woo  Kang
Myung Woo Kang

Reputation: 21

How can I measure a specific port transmit speed in Linux? (bit per sec)

I already made a program which can measure a specific network interface (eth1) speed.

This program is built using java and the follow command:

cat /proc/net/dev 

This file shows the total packet number and received data in bytes.

But I can't get data for each port.

How can I get similar information for each port?

Upvotes: 2

Views: 434

Answers (1)

Mark Qvist
Mark Qvist

Reputation: 125

I am assuming that you are using "port" to describe a TCP or UDP port, as in you would want to measure the how many bits per second is being transmitted across all open TCP connections to remote port 80.

Unfortunately, there is no easy way to pull this information from /proc since the kernel doesn't keep traffic counters per port.

If you really want to do this, you need to use deep packet inspection and count it yourself. A good place to start would be libpcap and pcap4j

Upvotes: 1

Related Questions