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 192.168.0.8 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?
Best Answer
There are actually two implementations of netcat, the original implementation by *Hobbit* (called
netcat-traditional
in Debian/Ubuntu) and the OpenBSD implementation (callednetcat-openbsd
in Debian/Ubuntu). In Debian/Ubuntu the binaries are callednc.traditional
andnc.openbsd
respectively (andnc
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 usingnc.openbsd
which doesn't. Install the traditional implementation and call it explicitly.Alternately, if you prefer to use the
nc.openbsd
you can pipe the output of netcat on the server side towc -c
and inspect the output like so: