Reputation: 21
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
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