Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I find one shell command can send large data to target host:

dd if=/dev/zero bs=4096 count=1048576 | ssh user@ip 'cat > /dev/null'

I think i can use this to test network bandwidth, but it can not display the process status.

share|improve this question
    
nuttcp is a more resilient test than going over SSH as it only measures what you're interested in. If your transfer over SSH is slow, does that mean the network is slow? Perhaps you don't have enough CPU to encrypt a 1Gb stream on the fly. I only get 8.8MBps copying a file to localhost over SSH, but nuttcp gives me 2.4GBps. How fast is your CPU? –  MikeyB Jan 17 '11 at 20:12

5 Answers 5

up vote 8 down vote accepted

Well if you wrap this whole thing in time:

time sh -c "dd if=/dev/zero bs=4096 count=1048576 | ssh user@ip 'cat > /dev/null'"

that will give give you the time it takes the transfer to complete. Divide the bytes transferred by the time and that's your throughput.

For a progress meter, you can use pv, which eliminates the need to use time(1):

dd if=/dev/zero bs=1024 count=10000 | pv --size 10240000 | ssh user@ip 'cat > /dev/null'

which will give you a nice progress meter, especially if you load the --size argument with the total size of the transfer.

share|improve this answer

If what you want to do is test network bandwidth, there are more direct ways of doing so.

Try out ttcp or its replacement: nuttcp

[tla ~]$ nuttcp -S

michael@challenger:~$ nuttcp -4 -r tla
   41.5574 MB /  10.46 sec =   33.3336 Mbps 2 %TX 4 %RX
michael@challenger:~$ nuttcp -4 -t tla
   15.4347 MB /  10.13 sec =   12.7821 Mbps 1 %TX 2 %RX 0 retrans 3.30 msRTT
share|improve this answer

Sending SIGUSR1 to dd will cause it to output its progress. You could calculate the difference between subsequent invocations in order to get an approximate rate.

share|improve this answer

you can use iperf if you really want to test connectivity with great detail.

Otherwise,

Create a 100mb test file

dd if=/dev/urandom of=./test.bin bs=1024000 count=100

then scp this file to test upload performance

scp test.bin x.x.x.x:.

or scp from the far side to test your download performance

share|improve this answer

Usually better to use iperf to test bandwidth, beacuse it has no encryption overhead, but you can insert pv between dd and ssh to see transfer speed in real-time:

dd if=/dev/random | pv | ssh somehost 'cat > /dev/null'

Also, on FreeBSD you can send SIGINFO to dd by hitting Ctrl+T, after that some stats (including speed) will be displayed

share|improve this answer
    
On Linux SIGUSR1 does the same, though I don't know whether one can send it directly from tty. –  ulidtko Jan 17 '11 at 15:11
    
On FreeBSD most user shells (including sh, tcsh, zsh, bash) has their own SIGINFO handlers, so ^T has some use even if program ignores it. Typical output looks like this: load: 0.85 cmd: a.out 2440 [running] 1.00r 0.98u 0.00s 8% 992k Here listed current system load, process name, id, state, run times and memory consumption –  gelraen Jan 17 '11 at 15:52
    
Hmm... It's not the shell, it's kernel itself prints status of current foreground process. fxr.watson.org/fxr/source/kern/tty_info.c#L210 –  gelraen Jan 17 '11 at 16:05

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.