Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 from ryu.base import app_manager | 1 from ryu.base import app_manager |
Vasileios Papageorgiou
2017/12/06 15:24:25
I am adding your own draft comments here so that i
| |
2 from ryu.controller import ofp_event | 2 from ryu.controller import ofp_event |
3 from ryu.controller.handler import set_ev_cls | 3 from ryu.controller.handler import set_ev_cls |
4 from ryu.ofproto import ofproto_v1_0 | 4 from ryu.ofproto import ofproto_v1_0 |
5 from ryu.ofproto import ofproto_v1_3 | 5 from ryu.ofproto import ofproto_v1_3 |
6 from ryu.ofproto import ofproto_v1_2 | 6 from ryu.ofproto import ofproto_v1_2 |
7 from ryu.ofproto import ofproto_v1_2_parser | 7 from ryu.ofproto import ofproto_v1_2_parser |
8 from ryu.ofproto import ofproto_v1_3_parser | 8 from ryu.ofproto import ofproto_v1_3_parser |
9 from ryu.topology import event, switches | 9 from ryu.topology import event, switches |
10 from ryu.controller.handler import CONFIG_DISPATCHER, MAIN_DISPATCHER | 10 from ryu.controller.handler import CONFIG_DISPATCHER, MAIN_DISPATCHER |
11 import time,math, random | 11 import time,math, random |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
53 self.monitor_thread = hub.spawn(self._monitor) | 53 self.monitor_thread = hub.spawn(self._monitor) |
54 self.RTT302_rules={} #values of RTT302, function of number of rules | 54 self.RTT302_rules={} #values of RTT302, function of number of rules |
55 self.RTT302_flows={} #values of RTT302, function of number of flows | 55 self.RTT302_flows={} #values of RTT302, function of number of flows |
56 self.timer_rules=Timer(10,self.addRTT302_rules) | 56 self.timer_rules=Timer(10,self.addRTT302_rules) |
57 self.timer_flows=Timer(50,self.addRTT302_flows) | 57 self.timer_flows=Timer(50,self.addRTT302_flows) |
58 self.nbOfRules=0 #nb of rules sent to s302 | 58 self.nbOfRules=0 #nb of rules sent to s302 |
59 self.nbOfFlows=0 #nb od flows going through s302 | 59 self.nbOfFlows=0 #nb od flows going through s302 |
60 self.lastvalue=0 | 60 self.lastvalue=0 |
61 self.lastvaluebis=0 | 61 self.lastvaluebis=0 |
62 self.plotTimer_rules=Timer(169,self.plot_RTTrules) #timer tha t will plot the graph (RTT function of nb of rules) in 169s | 62 self.plotTimer_rules=Timer(169,self.plot_RTTrules) #timer tha t will plot the graph (RTT function of nb of rules) in 169s |
63 » » self.plotTimer_flows=Timer(330,self.plot_RTTflows) #timer tha t will plot the graph (RTT function of nb of rules) in 330s | 63 » » self.plotTimer_flows=Timer(189,self.plot_RTTflows) #timer tha t will plot the graph (RTT function of nb of rules) in 330s |
64 ················ | 64 ················ |
65 self.table_RTT_314={} | 65 self.table_RTT_314={} |
66 self.iterator_314=0 | 66 self.iterator_314=0 |
67 self.sumRTT314=0 #used for traffic | 67 self.sumRTT314=0 #used for traffic |
68 self.avgRTT314=0 | 68 self.avgRTT314=0 |
69 self.sumRTT314bis=0 #used for nb of commands | 69 self.sumRTT314bis=0 #used for nb of commands |
70 self.avgRTT314bis=0 | 70 self.avgRTT314bis=0 |
71 self.sumRTT314bisbis=0 #used for nb of flows | 71 self.sumRTT314bisbis=0 #used for nb of flows |
72 self.avgRTT314bisbis=0 | 72 self.avgRTT314bisbis=0 |
73 self.RTT314_rules={} #values of RTT302, function of number of rules | 73 self.RTT314_rules={} #values of RTT302, function of number of rules |
74 self.RTT314_flows={} #values of RTT302, function of number of flows | 74 self.RTT314_flows={} #values of RTT302, function of number of flows |
75 self.lastvalue_314=0 | 75 self.lastvalue_314=0 |
76 self.lastvaluebis_314=0 | 76 self.lastvaluebis_314=0 |
77 | 77 |
78 | 78 |
79 @set_ev_cls(event.EventSwitchEnter) #get the datapath for each swit ch· | 79 @set_ev_cls(event.EventSwitchEnter) #get the datapath for each swit ch· |
80 def get_datapaths(self, ev): | 80 def get_datapaths(self, ev): |
81 new_switch = ev.switch.dp | 81 new_switch = ev.switch.dp |
82 self.switches[new_switch.id] = ev.switch.dp | 82 self.switches[new_switch.id] = ev.switch.dp |
83 self.send_barrier_request(new_switch) | 83 self.send_barrier_request(new_switch) |
84 self.sending_time[new_switch.id]=time.time() | 84 self.sending_time[new_switch.id]=time.time() |
85 if new_switch.id == 302: | 85 if new_switch.id == 302: |
86 » » » self.timer_rules.start() #launch the timer th at will call the function addRTT302_rules in 10s | 86 » » » #self.timer_rules.start() #launch the timer t hat will call the function addRTT302_rules in 10s |
87 » » » #self.timer_flows.start() #launch the timer th at will call the function addRTT302_flows in 10s | 87 » » » self.timer_flows.start() #launch the timer tha t will call the function addRTT302_flows in 10s |
88 » » » self.plotTimer_rules.start() #launch the timer th at will plot the graph (RTT function of nb of rules) in 169s | 88 » » » #self.plotTimer_rules.start() #launch the timer t hat will plot the graph (RTT function of nb of rules) in 169s |
89 » » » #self.plotTimer_flows.start() #launch the timer th at will plot the graph (RTT function of nb of rules) in 330s | 89 » » » self.plotTimer_flows.start() #launch the timer tha t will plot the graph (RTT function of nb of rules) in 330s |
90 ················ | 90 ················ |
91 def send_barrier_request(self, datapath): #a barrier request will g et the switches to send back a barrier reply to the controller | 91 def send_barrier_request(self, datapath): #a barrier request will g et the switches to send back a barrier reply to the controller |
92 ofp_parser = datapath.ofproto_parser | 92 ofp_parser = datapath.ofproto_parser |
93 req = ofp_parser.OFPBarrierRequest(datapath) | 93 req = ofp_parser.OFPBarrierRequest(datapath) |
94 datapath.send_msg(req)··· | 94 datapath.send_msg(req)··· |
95 #------------------------------------------------------------------------------- --------------# | 95 #------------------------------------------------------------------------------- --------------# |
96 ················ | 96 ················ |
97 def addRTT302_rules(self): #Computes avg RTT for s302 and s314 each time we add rules(here, 5 sets of rules are added each iteration(10s))·············· | 97 def addRTT302_rules(self): #Computes avg RTT for s302 and s314 each time we add rules(here, 5 sets of rules are added each iteration(10s))·············· |
98 for i in range(self.lastvalue, len(self.table_RTT_302)) : #Get ting the sum of the new values in the list of RTTs of s302 | 98 for i in range(self.lastvalue, len(self.table_RTT_302)) : #Get ting the sum of the new values in the list of RTTs of s302 |
99 self.sumRTT302bis=self.sumRTT302bis+self.table_RTT_302[i ] | 99 self.sumRTT302bis=self.sumRTT302bis+self.table_RTT_302[i ] |
100 self.avgRTT302bis=self.sumRTT302bis/(len(self.table_RTT_302)+1-s elf.lastvalue) #Getting the average of these values | 100 self.avgRTT302bis=self.sumRTT302bis/(len(self.table_RTT_302)+1-s elf.lastvalue) #Getting the average of these values |
101 self.RTT302_rules[self.nbOfRules*20]=self.avgRTT302bis | 101 self.RTT302_rules[self.nbOfRules*20]=self.avgRTT302bis |
102 for i in range(self.lastvalue_314, len(self.table_RTT_314)) : #Doing the same for s314 | 102 for i in range(self.lastvalue_314, len(self.table_RTT_314)) : #Doing the same for s314 |
103 self.sumRTT314bis=self.sumRTT314bis+self.table_RTT_314[i ] | 103 self.sumRTT314bis=self.sumRTT314bis+self.table_RTT_314[i ] |
104 self.avgRTT314bis=self.sumRTT314bis/(len(self.table_RTT_314)+1-s elf.lastvalue_314) | 104 self.avgRTT314bis=self.sumRTT314bis/(len(self.table_RTT_314)+1-s elf.lastvalue_314) |
105 self.RTT314_rules[self.nbOfRules*20]=self.avgRTT314bis | 105 self.RTT314_rules[self.nbOfRules*20]=self.avgRTT314bis |
106 self.lastvalue=len(self.table_RTT_302) | 106 self.lastvalue=len(self.table_RTT_302) |
107 self.lastvalue_314=len(self.table_RTT_314) | 107 self.lastvalue_314=len(self.table_RTT_314) |
108 self.nbOfRules=self.nbOfRules+5 # increasing the frequency of nb of rules sent· | 108 self.nbOfRules=self.nbOfRules+5 # increasing the frequency of nb of rules sent· |
109 self.timer_rules.cancel() | 109 self.timer_rules.cancel() |
110 self.timer_rules=Timer(10,self.addRTT302_rules) #Calling this function again in 10s | 110 self.timer_rules=Timer(10,self.addRTT302_rules) #Calling this function again in 10s |
111 self.timer_rules.start() | 111 self.timer_rules.start() |
112 | 112 |
113 » def addRTT302_flows(self): » #Computes avg RTT for s302 and s314 each time we add flows(here, 1 iperf flow added each 50s)» » »······· | 113 » def addRTT302_flows(self): » #Computes avg RTT for s302 and s314 each time we add flows(here, 1 iperf flow added each 30s)» » »······· |
Vasileios Papageorgiou
2017/12/06 15:24:25
What do you mean by 1 iperf flow added each 30s?
younes.tahri3
2017/12/06 16:00:42
I use iperf_traffic file for this one. And in this
| |
114 for i in range(self.lastvaluebis, len(self.table_RTT_302)) : | 114 for i in range(self.lastvaluebis, len(self.table_RTT_302)) : |
115 self.sumRTT302bisbis=self.sumRTT302bisbis+self.table_RTT _302[i] | 115 self.sumRTT302bisbis=self.sumRTT302bisbis+self.table_RTT _302[i] |
116 self.avgRTT302bisbis=self.sumRTT302bisbis/(len(self.table_RTT_30 2)+1-self.lastvaluebis) | 116 self.avgRTT302bisbis=self.sumRTT302bisbis/(len(self.table_RTT_30 2)+1-self.lastvaluebis) |
117 self.RTT302_flows[self.nbOfFlows]=self.avgRTT302bisbis | 117 self.RTT302_flows[self.nbOfFlows]=self.avgRTT302bisbis |
118 self.lastvaluebis=len(self.table_RTT_302) | 118 self.lastvaluebis=len(self.table_RTT_302) |
119 for i in range(self.lastvaluebis_314, len(self.table_RTT_314)) : | 119 for i in range(self.lastvaluebis_314, len(self.table_RTT_314)) : |
120 self.sumRTT314bisbis=self.sumRTT314bisbis+self.table_RTT _314[i] | 120 self.sumRTT314bisbis=self.sumRTT314bisbis+self.table_RTT _314[i] |
121 self.avgRTT314bisbis=self.sumRTT314bisbis/(len(self.table_RTT_31 4)+1-self.lastvaluebis_314) | 121 self.avgRTT314bisbis=self.sumRTT314bisbis/(len(self.table_RTT_31 4)+1-self.lastvaluebis_314) |
122 self.RTT314_flows[self.nbOfFlows]=self.avgRTT314bisbis | 122 self.RTT314_flows[self.nbOfFlows]=self.avgRTT314bisbis |
123 self.lastvaluebis_314=len(self.table_RTT_314) | 123 self.lastvaluebis_314=len(self.table_RTT_314) |
124 self.nbOfFlows=self.nbOfFlows+1 #Here we add a new iperf flow each 50s | 124 self.nbOfFlows=self.nbOfFlows+1 #Here we add a new iperf flow each 50s |
125 self.timer_flows.cancel() | 125 self.timer_flows.cancel() |
126 » » self.timer_flows=Timer(50,self.addRTT302_flows) # Calling this function again in 50s | 126 » » self.timer_flows=Timer(30,self.addRTT302_flows) # Calling this function again in 30s |
127 self.timer_flows.start() | 127 self.timer_flows.start() |
128 | 128 |
129 #------------------------------------------------------------------------------- ----------------# | 129 #------------------------------------------------------------------------------- ----------------# |
130 def plot_RTTrules(self): #plot graph for s302 and s314 : RTT function o f nb of rules sent to s302,no rules sent ro s314 | 130 def plot_RTTrules(self): #plot graph for s302 and s314 : RTT function o f nb of rules sent to s302,no rules sent ro s314 |
131 fig=plt.figure() | 131 fig=plt.figure() |
132 s302 = fig.add_subplot(221) | 132 s302 = fig.add_subplot(221) |
133 s314 = fig.add_subplot(222) | 133 s314 = fig.add_subplot(222) |
134 number_of_rules_per_second=list(self.RTT302_rules.keys()) | 134 number_of_rules_per_second=list(self.RTT302_rules.keys()) |
135 RTT=list(self.RTT302_rules.values()) | 135 RTT=list(self.RTT302_rules.values()) |
136 RTT314=list(self.RTT314_rules.values()) | 136 RTT314=list(self.RTT314_rules.values()) |
137 s302.plot(number_of_rules_per_second,RTT,'ro') | 137 s302.plot(number_of_rules_per_second,RTT,'ro') |
138 s302.axis([0,1600,0,2])· | 138 s302.axis([0,1600,0,2])· |
139 s314.plot(number_of_rules_per_second,RTT314,'bo') | 139 s314.plot(number_of_rules_per_second,RTT314,'bo') |
140 s314.axis([0,1600,0,2]) | 140 s314.axis([0,1600,0,2]) |
141 fig.suptitle('RTT of s302(red) and s314(blue),function of nb of rules/s sent to s302')· | 141 fig.suptitle('RTT of s302(red) and s314(blue),function of nb of rules/s sent to s302')· |
142 fig.show() | 142 fig.show() |
143 | 143 |
144 def plot_RTTflows(self): #plot graph for s302 and s314 : RTT functio n of nb of flows that go through s302. These flows don't go through s314 (cf top ology) | 144 def plot_RTTflows(self): #plot graph for s302 and s314 : RTT functio n of nb of flows that go through s302. These flows don't go through s314 (cf top ology) |
145 fig=plt.figure() | 145 fig=plt.figure() |
146 s302 = fig.add_subplot(221) | 146 s302 = fig.add_subplot(221) |
147 s314 = fig.add_subplot(222) | 147 s314 = fig.add_subplot(222) |
148 number_of_flows=list(self.RTT302_flows.keys()) | 148 number_of_flows=list(self.RTT302_flows.keys()) |
149 RTT=list(self.RTT302_flows.values()) | 149 RTT=list(self.RTT302_flows.values()) |
150 RTT314=list(self.RTT314_flows.values()) | 150 RTT314=list(self.RTT314_flows.values()) |
151 s302.plot(number_of_flows,RTT,'ro') | 151 s302.plot(number_of_flows,RTT,'ro') |
152 » » s302.axis([0,5,0,6])»··· | 152 » » s302.axis([0,5,0,10])»·· |
153 s314.plot(number_of_flows,RTT314,'bo') | 153 s314.plot(number_of_flows,RTT314,'bo') |
154 » » s314.axis([0,5,0,6]) | 154 » » s314.axis([0,5,0,10]) |
155 fig.suptitle('RTT of s302(red) and s314(blue),function of nb of flows going through s302')· | 155 fig.suptitle('RTT of s302(red) and s314(blue),function of nb of flows going through s302')· |
156 fig.show() | 156 fig.show() |
157 | 157 |
158 ························ | 158 ························ |
159 #------------------------------------------------------------------------------- ---------------# | 159 #------------------------------------------------------------------------------- ---------------# |
160 | 160 |
161 def _monitor(self): #sends barrier request to all switches each period | 161 def _monitor(self): #sends barrier request to all switches each period |
162 while True:··················································································· | 162 while True:··················································································· |
163 for switch in self.switches:···· | 163 for switch in self.switches:···· |
164 self.send_barrier_request(self.switches[switch]) | 164 self.send_barrier_request(self.switches[switch]) |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
216 | 216 |
217 json_formatted = {"switch_id": switch_id, "RTT": self.RTT[switch _id]} | 217 json_formatted = {"switch_id": switch_id, "RTT": self.RTT[switch _id]} |
218 data = json.dumps(json_formatted) | 218 data = json.dumps(json_formatted) |
219 clen = len(data) | 219 clen = len(data) |
220 req = urllib2.Request(self.url, data, {'Content-Type': 'applicat ion/json', 'Content-Length': clen}) # sending the RTT to the cache | 220 req = urllib2.Request(self.url, data, {'Content-Type': 'applicat ion/json', 'Content-Length': clen}) # sending the RTT to the cache |
221 f = urllib2.urlopen(req) | 221 f = urllib2.urlopen(req) |
222 response = f.read() | 222 response = f.read() |
223 | 223 |
224 ················ | 224 ················ |
225 | 225 |
LEFT | RIGHT |