I want to simulate traffic of 5 hosts in mininet. In such a way that, host2 , host 3, host4 and host5 send tcp traffic using iperf to host1. I want to send iperf traffic at the same time. (in parallel) I wrote a shell code to do that. Here is my code:
for Testduration in 10 20
do
for thread in 1 2 4 6
do
#Edit the attaker info here
hostnum=host2
attacker=10.0.0.2
echo “Test performing with $Testduration duration and $thread threads attacker ”
sudo tcpdump -G $Testduration -W 5 -w /tmp/scripttest-duration-$Testduration-thread-$thread -i h1-eth0 &\
pksize2=$(($RANDOM%1000+200))
pksize3=$(($RANDOM%1000+200))
pksize4=$(($RANDOM%1000+200))
pksize5=$(($RANDOM%1000+200))
#Attacker Host
iperf -c $attacker -t $Testduration -r -P $thread >> /media/sf_sharedsaeed/throughtput/iperthroughput-$hostnum-attack-duration-$Testduration-thread-$thread.txt &
P0=$!
iperf -c 10.0.0.2 -t $Testduration -r -l $pksize2 >> /media/sf_sharedsaeed/throughtput/iperthroughput-host2-duration-$Testduration-thread-$thread.txt &
P1=$!
iperf -c 10.0.0.3 -t $Testduration -r -l $pksize3 >> /media/sf_sharedsaeed/throughtput/iperthroughput-host3-duration-$Testduration-thread-$thread.txt &
P2=$!
iperf -c 10.0.0.4 -t $Testduration -r -l $pksize4 >> /media/sf_sharedsaeed/throughtput/iperthroughput-host4-duration-$Testduration-thread-$thread.txt &
P3=$!
iperf -c 10.0.0.5 -t $Testduration -r -l $pksize5 >> /media/sf_sharedsaeed/throughtput/iperthroughput-host5-duration-$Testduration-thread-$thread.txt &
P5=$!
wait $P0 $P1 $P2 $P3 $P4 $P5
sudo tcpdump -r /tmp/scripttest-duration-$Testduration-thread-$thread > /media/sf_sharedsaeed/scripttest-duration-$Testduration-thread-$thread.txt
done
done