All pastes #11261 Raw Edit

Mine

public text v1 · immutable
#11261 ·published 2005-05-08 23:15 UTC
rendered paste body
#!/bin/sh
#this creates a ramdrive on the source, creates a X MB file on it,
#and tests how fast that file can be sent to /dev/null on the destination

size="${1}"
host="${2}" #for ssh connection
ncport="${3}"

if [ "${3}" == "" ]; then
        echo "bw_test.sh 100M 10.0.0.250 9999"
        echo "bw_test.sh size dest port"
        exit
fi
mkdir /mnt/bwtest
umount /mnt/bwtest #just in case
mount -t ramfs none /mnt/bwtest
dd if=/dev/zero of=/mnt/bwtest/zerofile.dd bs="${size}" count=1 && echo "Made ${size} file on /mnt/bwtest" && ls -alh /mnt/bwtest
ssh -f "${host}" "killall nc ; nc -w 3 -lnvvp "${ncport}" > /dev/null" &
echo "Sleeping 5 seconds while ssh connects"
sleep 5
time nc -w 1 -nvv "${host}" "${ncport}" < /mnt/bwtest/zerofile.dd
umount /mnt/bwtest
echo "Subtract 3 seconds to account for the timeout on the destination (-w 3) (i think... we have -w 1 on the sending side too..)"
echo "need some math to compare to 100Mbit and 1000Mbit connections"