Repository navigation
Expand file tree
/
Copy pathcentral_controller2.sh
More file actions
113 lines (83 loc) · 3.72 KB
/
Copy pathcentral_controller2.sh
File metadata and controls
113 lines (83 loc) · 3.72 KB
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/bin/bash
##Set and apply queues on switches
echo -e "\n Configuring queues"
#erase the file with local information storage
rm -f temp2.txt
#collects the DPIDs of the switches in the regions of interest, including their interfaces to apply the queues, and saves this in temp2.txt
mysql -u root -pwifi -e "select dpid,iface_updtip from rsu where Region IN (select region from appkpi)" framework 2> /dev/null | grep '-' |
while read i;
do
echo $i >> temp2.txt
done
#clear the control variable
t2=0
#Identify DPIDs
b2=$(cat temp2.txt | awk -F' ' '{print $1}')
#For each DPID
for i in $b2;
do
#inc control variable
t2=$(echo $t2+1 | bc)
#saves the values of DPID in x2 and the values of inteferface in y2, to mount the REST expressions
x2=$(cat temp2.txt | awk -F' ' '{print $1}' | cut -d$'\n' -f$t2)
y2=$(cat temp2.txt | awk -F' ' '{print $2}' | cut -d$'\n' -f$t2)
#...
# x=$(mysql -u root -pwifi -e "select appkpi.data_rate, infrastructure.ip from appkpi inner join infrastructure on appkpi.id = infrastructure.app;" framework 2> /dev/null | grep '\.' |
# while read i;
# do
# echo $i | awk -F' ' '{print $1}'
# done)
x=$(mysql -u root -pwifi -e "select data_rate from appkpi;" framework 2> /dev/null | grep 0 |
while read i;
do
echo $i
# echo $i*1.1 | bc
done)
#x=$(mysql -u root -pwifi -e "select data_rate from appkpi;" framework 2> /dev/null | grep 0 | while read i; do echo $i; done)
#Number of queues = number of applications (counter)
c=$(echo $x | wc -w)
# sets the minimum rates to apply for each queue. Ex {"min_rate": "500000"}
h=$(for i in $x; do echo {\"min_rate\": "\"$(echo $i)\""},; done | paste -s | cut -d',' -f1-$c)
#define final command with fixed max_rate (improve / adjust)
j=$(echo curl -X POST -d "'{\"port_name\": \"$y2\", \"type\": \"linux-htb\", \"max_rate\": \"5000000\", \"queues\": [{\"max_rate\": \"5000000\"}, $(echo $h)]}'" http://localhost:8080/qos/queue/000000000000000$x2)
#Send command to the controller, containing the queues and references of DPID (switch) and port
# echo $j
/bin/sh -c "$j"
done
echo -e "\n Configuring QoS"
# clear the control variable
t2=0
#For each DPID
for i in $b2;
do
#inc the control variable
t2=$(echo $t2+1 | bc)
#saves emn x2 the values of DPID
x2=$(cat temp2.txt | awk -F' ' '{print $1}' | cut -d$'\n' -f$t2)
#Clear the file for storing local information
rm -f temp.txt
#search the IP address and port information of the servers where the applications are located, and save locally in temp.txt
mysql -u root -pwifi -e "select infrastructure.ip, appkpi.port from appkpi inner join infrastructure on appkpi.id = infrastructure.app;" framework 2> /dev/null | grep '\.' |
while read i;
do
echo $i >> temp.txt
done
#internal control variable
t=0
# Stores the values of IP addresses in b
b=$(cat temp.txt | awk -F' ' '{print $1}')
#For each application server IP address
for i in $b;
do
#inc control variable
t=$(echo $t+1 | bc)
#Stores the IP address at x and port on y
x=$(cat temp.txt | awk -F' ' '{print $1}' | cut -d$'\n' -f$t)
y=$(cat temp.txt | awk -F' ' '{print $2}' | cut -d$'\n' -f$t)
#Assembles and sends the command associating the traffic referring to the IP of the server and the port, its queue and in all the DPIDs
#echo curl -X POST -d '{"match": {"nw_dst": "'$x'", "nw_proto": "UDP", "tp_dst": "'$y'"}, "actions":{"queue": "'$t'"}}' http://localhost:8080/qos/rules/000000000000000$x2
curl -X POST -d '{"match": {"nw_dst": "'$x'", "nw_proto": "UDP", "tp_dst": "'$y'"}, "actions":{"queue": "'$t'"}}' http://localhost:8080/qos/rules/000000000000000$x2
curl -X POST -d '{"match": {"nw_dst": "'$x'", "nw_proto": "ICMP"}, "actions":{"queue": "'$t'"}}' http://localhost:8080/qos/rules/000000000000000$x2
done
done
echo -e "\n Finishing"