Close

How fast is a pipe?

A project log for Silly software wishlist

Motivation to do some software projects by writing them down.

lion-mclionheadlion mclionhead 06/03/2020 at 19:290 Comments

At least on the  lion kingdom's obsolete 4Ghz 8 core Ryzen, it's

% ./random |catbps

main 33: 1154458213 bits/sec
main 33: 1155342065 bits/sec
main 33: 1158795636 bits/sec
main 33: 1161013450 bits/sec
main 33: 1153026045 bits/sec
main 33: 960231704 bits/sec
main 33: 1077391216 bits/sec

From a phone through ADB, it's

% adb shell /data/random | catbps 
main 33: 9080670 bits/sec
main 33: 5169716 bits/sec
main 33: 4291419 bits/sec
main 33: 4482882 bits/sec
main 33: 8428983 bits/sec
main 33: 8613113 bits/sec
main 33: 9701913 bits/sec


Native linux on a laptop to ethernet:

root@heroine:/root% netcat -l -p 1234 | catbps
main 41: 1309 bits/sec total_bytes=1024
main 41: 939087920 bits/sec total_bytes=117504400
main 41: 940861506 bits/sec total_bytes=235229696
main 41: 941440127 bits/sec total_bytes=353027392
main 41: 941604955 bits/sec total_bytes=470845712
main 41: 941564611 bits/sec total_bytes=588658984
main 41: 941590569 bits/sec total_bytes=706475504
main 41: 941602141 bits/sec total_bytes=824293472
main 41: 941494025 bits/sec total_bytes=942097912
main 41: 941467236 bits/sec total_bytes=1059899000

Linux on a virtual machine to ethernet:

root@heroine:/root% netcat -l -p 1234 | catbps
main 41: 5333 bits/sec total_bytes=1024
main 41: 14750500 bits/sec total_bytes=1850368
main 41: 16163477 bits/sec total_bytes=3876864
main 41: 10647144 bits/sec total_bytes=5209088
main 41: 9818954 bits/sec total_bytes=6438912
main 41: 10589858 bits/sec total_bytes=7763968
main 41: 22450331 bits/sec total_bytes=10575872
main 41: 12099960 bits/sec total_bytes=12091392
main 41: 15158875 bits/sec total_bytes=13991936
main 41: 15942073 bits/sec total_bytes=15986688
main 41: 14217453 bits/sec total_bytes=17767424

The random program just prints random ASCII characters as fast as possible.  Recognizing that the rand function has a finite speed, it precalculates a fixed buffer & resend it.


Obviously, adb doesn't do any compression.  The catbps program just measures how fast data is coming from stdin but doesn't write it to stdout.   These are basic needs lions have had for a while.  Next comes hacking ADB to improve this bandwidth.  You can't hack the ADB server on a normal phone, but this is a special phone.

https://cdn.hackaday.io/files/1380505906331200/catbps.c

https://cdn.hackaday.io/files/1380505906331200/random.c


We all want to know how fast our networks are, so these programs can be run with netcat.

netcat -l -p 1234 | catbps

random | netcat 10.0.0.14 1234

Discussions