9

To test my network, I want to send x MB/s between two hosts. I know that ping can be used to send a good amount of data, but I need a solution where I can set the bandwidth (it does not have to be really precise).

$ sendTrafic --throughput 10M 10.0.0.1

Any idea how I can do that? I thought about a script running scappy x times per second, but there should be something better.


EDIT: I used the following solution:

# On receiving node:
iperf -s -u

# On sending node:
iperf -c <ip> -u -b 10m -t 30

Which configures the first host as a UDP server, and the second one as a UDP client who send 10Mb/s for 30 seconds.

Thank everyone for your help.

4
  • 4
    iperf.fr why don't you give it a try? hope this helps . Jun 18, 2018 at 11:49
  • 1
    I would also suggest to use iperf. Jun 18, 2018 at 11:56
  • I'll third iperf. If you can't install something on both hosts, also have a look at bwping.
    – dirkt
    Jun 18, 2018 at 12:00
  • @Nakrule depending of your goal, sending UDP packet at a fix rate will only validate the stability of the line with a fixed traffic (you will see in the result how many lost packet). If you want to test your max throughput you need to use TCP. iperf is not know to be a very accurate solution, there's a lot of side effect, specially when using it cross-platform. Do a lot of testing if you want to validate a bitrate.
    – Kiwy
    Jun 18, 2018 at 14:17

2 Answers 2

14

If you don't want to install iperf (which is not the most reliable tool I've use in the past IMHO), you can use pv and netcat
You would first need to install pv and netcat (it's available in most distro).
On the receiving site you will need a listening socket on a reachable port:

#if you want the output you can remove the redirection or redirect it to a different file.
#if you want to listen to a TCP port below 1024 you will need to use root
nc -l 4444 > /dev/null

On the sending machine you will use this command :

dd if=/dev/urandom bs=1000 count=1000 | pv -L 10M | nc <ip> 4444

dd if=/dev/urandom bs=1000 count=1000 will send blocks of 1000 random characters (1000 Bytes) 1000 time: 1000B * 1000 = 1MB . You can adjust the count to increase the amount of data send.
pv -L 10M: will limit the write rate to 10 mebibytes/s (*1024).
netcat <ip> 4444 will send the data to the IP on port TCP 4444.

You adapt to send more data or even real file using :

cat /some/files| pv -L 1M | nc <ip> 4444

and on the other side :

 nc -l 4444 > /some/destinationfiles
0

Apparently, there are more integrated projects addressing this more systematically already.

E.g.: in the set of minimalistic ones - flowgrind or trafgen

Simply look out for "rate limited traffic generators".

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .