File size: 910 Bytes
079c32c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
total_epoch=1200            # the total num of msg
interval=0.1                # msg send interval
size=16                     # data size (MB)
test_start_time=20          # network fail time (s)
test_duration=40            # network fail duration (s)
output_file="my_test.log"   # the python script will write its output into this file
ip="0.0.0.0"

rm -f pytmp_*

nohup python test_parallel_socket.py -t $total_epoch -i $interval -s $size 1>$output_file 2>&1 &

flag=true
while $flag
do
    for file in `ls`
    do
        if [[ $file =~ "pytmp" ]]; then
            ip=`cat $file`
            flag=false
            break
        fi
    done
    sleep 0.1
done
echo "get ip: $ip"

sleep $test_start_time
echo "Network shutsown . . ."
sudo iptables -A INPUT -p tcp -s $ip --dport 50516 -j DROP

sleep $test_duration
sudo iptables -D INPUT -p tcp -s $ip --dport 50516 -j DROP
echo "Network recovered . . ."