Reputation: 51
So for my job I need to do an experiment..
The essence and part where I get stuck at now is how to create a specific amount of bandwidth/network traffic. From either Linux or windows, (I have both a Kali and Win10 VM). To a target Win10 pc which monitors it's resources to see the reaction to the traffic.
Preferably 3 different amounts of traffic with a certain time between them, like a scripted sleep timer or something..
So like the following:
Sleep 180 seconds
Send 10mbps for 120 seconds
Sleep 180 seconds
Send 25mbps for 120 seconds
Sleep 180 seconds
Send 50mbps for 120 seconds
Exit
Now this shouldn't be as hard as I'm thinking of it to be right?
Any pointers on some software or scripts I could use for this?
Thanks in advance
Upvotes: 1
Views: 988
Reputation: 1577
You can use iperf3, a tool for stress testing and measuring network performance, along with basic bash scripting to accomplish this. iperf3 is cross-platform, so it is supported on both Kali Linux and Win 10.
On Kali Linux, I used the system package manager to install it:
apt install iperf3
On Windows, I downloaded the 64 bit binary from the iperf3 download site. Then used the following command to start an iperf3 server:
iperf3 -s
-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------
This will start the server listening on a particular port as shown above. Then on my Kali Linux instance, I use iperf3 again as a client to connect to the server:
iperf3 -c <address-of-server> -b 25M -t 7
[ 5] local XXX.XXX.XXX.XXX port 42650 connected to XXX.XXX.XXX.XXX port 5201
[ ID] Interval Transfer Bitrate Retr Cwnd
[ 5] 0.00-1.00 sec 2.98 MBytes 25.0 Mbits/sec 0 133 KBytes
[ 5] 1.00-2.00 sec 3.00 MBytes 25.2 Mbits/sec 0 133 KBytes
[ 5] 2.00-3.00 sec 3.00 MBytes 25.2 Mbits/sec 0 133 KBytes
[ 5] 3.00-4.00 sec 3.00 MBytes 25.2 Mbits/sec 0 133 KBytes
[ 5] 4.00-5.00 sec 3.00 MBytes 25.2 Mbits/sec 0 133 KBytes
[ 5] 5.00-6.00 sec 3.00 MBytes 25.2 Mbits/sec 2 133 KBytes
[ 5] 6.00-7.00 sec 3.00 MBytes 25.2 Mbits/sec 1 133 KBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bitrate Retr
[ 5] 0.00-7.00 sec 21.0 MBytes 25.1 Mbits/sec 3 sender
[ 5] 0.00-7.00 sec 21.0 MBytes 25.1 Mbits/sec receiver
The -b option allows me to specify the bit rate, in the example above 25 Mbits/sec and the -t option allows specifying how long it should run, in this case 7 seconds.
You can easily use this tool in a script to achieve the behavior you want, for example:
#!/bin/bash
echo "Sleeping for 180 seconds"
sleep 180
echo "Stress testing at 10Mb/s for 120 seconds"
iperf3 -c mywinserver.local -b 10M -t 120
echo "Sleeping for 180 seconds"
sleep 180
echo "Stress testing at 25Mb/s for 120 seconds"
iperf3 -c mywinserver.local -b 25M -t 120
echo "Sleeping for 180 seconds"
sleep 180
echo "Stress testing at 50Mb/s for 120 seconds"
iperf3 -c mywinserver.local -b 50M -t 120
Upvotes: 1