2

I was curious to know how much traffic the Linux kernel could handle on the loopback network, so I decided to benchmark it. In one terminal, I ran:

% nc -l -p 5235 127.0.0.1 > /dev/null

And in another I ran:

% nc 127.0.0.1 5235 < /dev/zero

Then to actually measure traffic I ran sudo nethogs lo. This shows an entry for the second nc showing that it sends about 570,000 KB/second (on average). The first nc seems to send about 1,300 KB/second on average, which I assume is TCP control packets. However, both nc processes show 0 KB/second received. Why is this? It seems like each process should report a received value equal to the other's sent value.

Version information:

% nethogs -V
 version 0.8.1

% uname -a
Linux file-not-regular.strugee.net 3.16.0-4-amd64 #1 SMP Debian 3.16.36-1+deb8u2 (2016-10-19) x86_64 GNU/Linux

% nc -h |& head -1
[v1.10-41]
0

This is because the kernel doesn't really distinguish between inbound and outbound traffic beyond the source and destination IP addresses. The packets don't get "double-counted" because the kernel looks at the source IP, sees that it's local, classifies it as outbound, and doesn't bother classifying the packet any further (e.g. as inbound).

  • does this mean there is anything wrong in the network? I am having the same issue with nethogs. It shows 0 KB. – user9371654 Dec 10 '18 at 15:28
  • @user9371654 what do you mean "wrong with the network"? you mean the kernel's networking subsystem? if so, it depends on how you define "wrong". can you clarify? – strugee Apr 4 at 17:02

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.