Network Speed Test with SCP

If you’re looking for a basic network speed test, one classic method is to use a basic file transfer protocol to send random large files back-and-forth. If you’re working with Linux systems and SSH is enabled, you can use the standard “scp” utility (SSH Copy or Secure Copy). SCP is the modern replacement for the old insecure “rcp” program.

Here are some example steps to generate a random large file and send it to and from a remote system. You will likely need to do some math to convert the file bytes per second to bits per second numbers. Remember that TCP, Encryption, and SSH control messages add overhead, so your true throughput will be a little higher than the number reported by SCP for the file transfer. This example assumes two hypothetical systems with IP of SYS1=10.1.1.1 and SYS2=10.2.2.2 respectively. Exaple is run from SYS1.

  • dd if=/dev/urandom of=~/randfile bs=1M count=100 # create 100MB random file
  • scp ~/randfile 10.2.2.2:./ # copy your random file to remote system
  • # take note of reported transfer speed, usually in file size per second like MB/s
  • ssh -t 10.2.2.2 scp ~/randfile 10.1.1.1:./ # send the random file back to source system
  • # take note of return transfer speed
  • # calculate bits per second, here’s an example using Bash & Python for 3.3 MB/s
    • printf "%'.0f bps\n" `python -c 'print (3.3*2.0**20.0*8.0)'`
    • 27,682,406 bps # sample output for the above 3.3 MB/s conversion
    • The Python math includes 1MB = 2^20 Bytes and 1 Byte = 8 bits.
    • The Bash printf adds the thousand separator (comma)

If you’re using scp for automated or scripted bandwidth testing, you will likely need the “scp -v” verbose option along with a redirect of standard error like “2>&1” to capture the output. This verbose output has a lot of extra unneeded debug information, so I recommend piping it through “egrep” to filter out just the items you want to see in your script log-file.

There are many ways to test bandwidth between systems, this is a quick and easy way that should work for most Linux systems.

Advertisements

About notesbytom

Keeping technology notes on WordPress.com to free up my mind to solve new problems rather than figuring out the same ones repeatedly :-).
This entry was posted in Linux, Networking, System Administration and tagged , , , , , , , . Bookmark the permalink.

2 Responses to Network Speed Test with SCP

  1. noahcoad says:

    helpful, thanks!
    why use the ssh command instead of this?
    scp 10.2.2.2:~/randfile ~/

    • notesbytom says:

      It’s been a long time since that project but I believe I had an entire test suite running on remote box and not just the single scp command. We were doing connectivity and speed tests for a new multi-site network to validate service provider stated performance including roundtrip delay (ping), hop traces (traceroute), site-to-site transfer speed (scp), etc. The command was something like ssh -t remoteserver ./remotetestscript.sh … and similar commands for each site one at a time to avoid saturating links from multiple sites simultaneously. The scp command(s) would’ve been part of a batch of test commands within remotetestscript.sh.

      We then collected the test output files from each site to a central location to aggregate the test results and create the final test report for each run. It was extremely useful as we had trouble finding a good way to validate private site-to-site connectivity without writing custom scripts like this.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s