I follow this post to check speed with netcat , but in his blog when he do ctrl-c ,he get data on sent received bytes.

In the post he ran :

time yes|nc -v -v -n 2222 >/dev/null
than after ctrl-c het get:
sent 87478272, rcvd 0
real 0m9.993s
user 0m2.075s
sys 0m0.939s

When I do ctrl-c , I don't get this data.

How can I get sent/received data by netcat?


There are actually two implementations of netcat, the original implementation by *Hobbit* (called netcat-traditional in Debian/Ubuntu) and the OpenBSD implementation (called netcat-openbsd in Debian/Ubuntu). In Debian/Ubuntu the binaries are called nc.traditional and nc.openbsd respectively (and nc is a link to one of those via the alternatives system).

The blog post you reference is using nc.traditional which does show the sent/received bytes when exiting. You are probably using nc.openbsd which doesn't. Install the traditional implementation and call it explicitly.

% time yes | nc.traditional -vvn 10000 > /dev/null
(UNKNOWN) [] 10000 (webmin) open
^C sent 99422208, rcvd 0
yes  1,06s user 0,09s system 38% cpu 3,003 total

Alternately, if you prefer to use the nc.openbsd you can pipe the output of netcat on the server side to wc -c and inspect the output like so:

% nc -l -n -p 10000 | wc --bytes

You can use the Pipe Viewer (pv) utility to watch the visual progress of a stream. It can be modified to display the units of choice and is available on most distributions.


cat largefile | pv | netcat 1234
  • I want to get it from netcat like in the posted blog ? Oct 25 '12 at 14:34
  • Please show your command string.
    – ewwhite
    Oct 25 '12 at 14:36
  • add this to the question, thank you. You can see it in the blog link. Oct 25 '12 at 14:39
  • 1
    time yes|nc -v -v -n 2222 | pv | >/dev/null
    – ewwhite
    Oct 25 '12 at 14:40
  • 1
    The command should be like this - time yes| pv | nc -v -v -n 2222 >/dev/null Oct 25 '12 at 16:37

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.