-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun
executable file
·83 lines (80 loc) · 2.82 KB
/
run
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
#!/bin/bash
timestamp() {
date +"%T"
}
#notify=1
state="Topk" #Pulling Pushing"
time_step="20.0" #0.001 0.01 0.05 0.1 0.25 0.5 0.75 0.9 0.95 1.0 2.0 3.0 4.0 5.0 10.0 15.0 20.0"
rate="BW" #normal IncreasingBW DecreasingBW IncDecBW HH-several Syn BW"
direction="Source" #Source Destination"
numHH="1" #5 6 7 8 9 10 11 12"
mechanism="table" #prio:"
common_mask="24" #0 8 16 24 30"
ks="2 5 10 15 20"
counters="1024" #16 32 64 128 256 512 1024"
cd ~/SDN-Monitoring/
for m in $mechanism; do
for s in $state; do
for r in $rate; do
for d in $direction; do
time_stamp=`timestamp`
folder_name="logs/${m}-${s}-${r}-${d}-"${time_stamp}
mkdir -p ${folder_name}
if [[ -L "logs/${m}-${s}-${r}-${d}" ]]; then
rm "logs/${m}-${s}-${r}-${d}"
fi
ln -s "../"${folder_name} "logs/${m}-${s}-${r}-${d}"
for h in $numHH; do
for ts in $time_step; do
for c in $common_mask; do
for k in $ks; do
for counter in $counters; do
log_file="${folder_name}/${ts}-${h}-${c}-${k}-${counter}.log"
pcap_file="${folder_name}/${ts}-${h}-${c}-${k}-${counter}.pcap"
python ./SDM/scripts/ChangeConfig.py --state=${s} --rate_type=${r} --timestep=${ts} --direction=${d} --numHH=${h} --mechanism=${m} --common_mask=${c} --k=${k} --counters=${counter}
tshark -i lo -w "${pcap_file}" &
pid=$!
sleep 10s
PYTHONPATH=$PYTHONPATH ./SDM/scripts/run_env.py
kill -9 $pid
sleep 10s
a=`grep "Alert!" ${log_file} | cut -d"(" -f2 | cut -d"," -f1 | uniq | wc -l`
if [[ $a != $h ]]; then
#if [[ $notify != 0 ]]; then
# notify Failed-${h}-${ts}-${c}-${k}-${counter}
#fi
sleep 30s
mn -c
continue
fi
# TODO: Consider moving to after_test
#counters=`grep Maximal ${log_file} | rev | cut -d":" -f1 | rev`
#attack_start=`sed -n -e '/Attack started/,/Time step #/ p' ${log_file} | tail -1 | cut -d"#" -f2 | cut -d" " -f1`
#alert_step=`tac ${log_file} | sed -n -e '/Alert/,/Time step #/ p' | tail -1 | cut -d"#" -f2 | cut -d" " -f1`
#let steps=${alert_step}-${attack_start}
#time=`echo ${steps}*${ts} | bc`
#ofp_packets=`sudo tshark -2 -r ${pcap_file} -R "(openflow||openflow_v1||openflow_v4||openflow_v5) && ((tcp.srcport==6633) || (tcp.dstport==6633))" | wc -l`
#echo ${time_stamp}: ${ts},${attack_start},${alert_step},${steps},${time},${ofp_packets},${h},${c},${counters} >> "logs/${m}-${s}-${r}-${d}.res"
#all_counters=`grep "counters" ${log_file} | cut -d":" -f3`
#arr_counters=($all_counters)
#all_steps=`grep "step" ${log_file} | cut -d"#" -f2 | cut -d" " -f1`
#arr_steps=($all_steps)
#total=${#arr_steps[*]}
#for (( i=${attack_start}-1; i<=$(( $total -1 )); i++ ))
#do
# echo "${arr_steps[$i]}, ${arr_counters[i]}" >> "${folder_name}/${ts}-${h}-${c}.counters"
#done
#if [[ $notify != 0 ]]; then
# notify Success-${h}-${ts}-${c}-${k}-${counter}
#fi
sleep 30s
mn -c
done
done
done
done
done
done
done
done
done