-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathexperiment-fct.sh
executable file
·96 lines (89 loc) · 3.2 KB
/
experiment-fct.sh
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/bin/bash
output_directory=FCT
num_on_off=10
user=ubuntu
if [[ $# != 3 ]] && [[ $1 == "run" ]]; then
echo "Usage: ./experiment-fct [run|graph] [receiver_ip] [tcp]"
exit
fi
receiver_ip=$2
if [[ $1 == "run" ]]; then
if [[ ! -d $output_directory ]]; then
mkdir $output_directory
fi
tcp=$3
#for tcp in "copa" "cubic" "bbr"; do
if [[ -d $output_directory/$tcp ]]; then
echo "Results for $tcp exist. Skipping"
continue
fi
mkdir $output_directory/$tcp
sudo sysctl -w net.core.default_qdisc=pfifo_fast
if [[ $tcp == "bbr" ]]; then
sudo sysctl -w net.ipv4.tcp_congestion_control=bbr
elif [[ $tcp == "cubic" ]]; then
sudo sysctl -w net.ipv4.tcp_congestion_control=cubic
fi
helper_pids=""
for (( i=0; $i < $num_on_off; i++ )); do
outfile=$output_directory/$tcp/`python -c "import random; print(random.randint(0, 1e9))"`.log
chown -R $user $output_directory
su -c "mm-delay 0 ./experiment-fct-helper.sh $tcp $receiver_ip $outfile &" $user
helper_pids="$helper_pids $!"
done
sleep 100
#pkill -9 $helper_pids
sudo killall -9 experiment-fct-helper.sh
#done
elif [[ $1 == "graph" ]]; then
if [[ -d $output_directory/graphdir ]]; then
trash $output_directory/graphdir
fi
mkdir $output_directory/graphdir
for tcp_dir in $output_directory/*; do
echo $tcp_dir
tcp=`expr "$tcp_dir" : '.*/\([^/]*\)'`
if [[ $tcp == "copa" ]]; then
for file in $tcp_dir/*.log; do
while read p; do
tmp_tpt=`echo $p | grep '^\s*Throughput:\ ' | grep -o '[0-9.]*'`
if [[ ! -z "$tmp_tpt" ]]; then
if [[ ! -z "$tpt" ]]; then
echo "Got two throughput values at once. '$tmp_tpt' and '$tpt'"
fi
tpt=$tmp_tpt
fi
fct=`echo $p | grep '^\s*Completion time:\ ' | grep -o '[0-9.]*'`
if [[ ! -z "$fct" ]]; then
bytes=`awk "BEGIN{print($fct * $tpt)}"`
echo " $fct $bytes" >>$output_directory/graphdir/$tcp.dat
tpt=""
fct=""
fi
done < $file
done
cat $output_directory/graphdir/$tcp.dat | sort -n > /tmp/copa-sorted
mv /tmp/copa-sorted $output_directory/graphdir/$tcp.dat
else
cat $tcp_dir/* | grep -v Command | sort -n >$output_directory/graphdir/$tcp.dat
fi
done
for tcp_dat in $output_directory/graphdir/*.dat; do
awk 'BEGIN{bucket_start=100}{ \
if ($1 < 2*bucket_start) { \
bucket_sum += $2; \
bucket_sum_sq += $2 * $2; \
bucket_size += 1; \
} \
else { \
if (bucket_size > 0) { \
print bucket_start, bucket_sum / bucket_size, sqrt(bucket_sum_sq / bucket_size - bucket_sum * bucket_sum / (bucket_size * bucket_size)); \
} \
bucket_start += 1000; \
bucket_size = 0; bucket_sum = 0; bucket_sum_sq = 0; \
} \
}' $tcp_dat >$tcp_dat.bkts
done
else
echo "Unrecognized command '$1'"
fi