blob: 8fa51fb0497dabe7e9758e2af957e2be1da67bde [file] [log] [blame]
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001#
Chetan Gaonkercfcce782016-05-10 10:10:42 -07002# Copyright 2016-present Ciena Corporation
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07007#
Chetan Gaonkercfcce782016-05-10 10:10:42 -07008# http://www.apache.org/licenses/LICENSE-2.0
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07009#
Chetan Gaonkercfcce782016-05-10 10:10:42 -070010# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
Chetan Gaonker7ab338c2016-04-15 17:23:17 -070016import unittest
17from nose.tools import *
18from nose.twistedtools import reactor, deferred
19from twisted.internet import defer
20from scapy.all import *
21import time
22import json
23import threading
ChetanGaonker720ea612016-06-21 17:54:25 -070024import os
Chetan Gaonker7ab338c2016-04-15 17:23:17 -070025from OnosCtrl import OnosCtrl
A R Karthickb03cecd2016-07-27 10:27:55 -070026from OnosFlowCtrl import OnosFlowCtrl
Chetan Gaonker7ab338c2016-04-15 17:23:17 -070027from OltConfig import OltConfig
ChetanGaonkera6adc0b2016-06-12 12:21:14 -070028import random
29from threading import current_thread
ChetanGaonker720ea612016-06-21 17:54:25 -070030import collections
Chetan Gaonker7ab338c2016-04-15 17:23:17 -070031log.setLevel('INFO')
32
Chetan Gaonker7ab338c2016-04-15 17:23:17 -070033class flows_exchange(unittest.TestCase):
34
35 #Use the first available device id as our device id to program flows
36 app = 'org.onosproject.cli'
37 PORT_TX_DEFAULT = 2
38 PORT_RX_DEFAULT = 1
39 INTF_TX_DEFAULT = 'veth2'
40 INTF_RX_DEFAULT = 'veth0'
ChetanGaonkera6adc0b2016-06-12 12:21:14 -070041 default_port_map = {
Chetan Gaonker7ab338c2016-04-15 17:23:17 -070042 PORT_TX_DEFAULT : INTF_TX_DEFAULT,
43 PORT_RX_DEFAULT : INTF_RX_DEFAULT,
44 INTF_TX_DEFAULT : PORT_TX_DEFAULT,
45 INTF_RX_DEFAULT : PORT_RX_DEFAULT
46 }
47
ChetanGaonkera6adc0b2016-06-12 12:21:14 -070048 def incmac(self, mac):
ChetanGaonker720ea612016-06-21 17:54:25 -070049 tmp = str(hex(int('0x'+mac,16)+1).split('x')[1])
50 mac = '0'+ tmp if len(tmp) < 2 else tmp
51 return mac
ChetanGaonkera6adc0b2016-06-12 12:21:14 -070052
53 def next_mac(self, mac):
54 mac = mac.split(":")
55 mac[5] = self.incmac(mac[5])
56
57 if len(mac[5]) > 2:
ChetanGaonker720ea612016-06-21 17:54:25 -070058 mac[0] = self.incmac(mac[0])
59 mac[5] = '01'
60
ChetanGaonkera6adc0b2016-06-12 12:21:14 -070061 if len(mac[0]) > 2:
ChetanGaonker720ea612016-06-21 17:54:25 -070062 mac[0] = '01'
63 mac[1] = self.incmac(mac[1])
64 mac[5] = '01'
ChetanGaonkera6adc0b2016-06-12 12:21:14 -070065 return ':'.join(mac)
66
67 def to_egress_mac(cls, mac):
68 mac = mac.split(":")
69 mac[4] = '01'
ChetanGaonker720ea612016-06-21 17:54:25 -070070
ChetanGaonkera6adc0b2016-06-12 12:21:14 -070071 return ':'.join(mac)
72
73 def inc_ip(self, ip, i):
ChetanGaonker720ea612016-06-21 17:54:25 -070074
ChetanGaonkera6adc0b2016-06-12 12:21:14 -070075 ip[i] =str(int(ip[i])+1)
76 return '.'.join(ip)
77
78
79 def next_ip(self, ip):
ChetanGaonker720ea612016-06-21 17:54:25 -070080
ChetanGaonkera6adc0b2016-06-12 12:21:14 -070081 lst = ip.split('.')
82 for i in (3,0,-1):
83 if int(lst[i]) < 255:
84 return self.inc_ip(lst, i)
85 elif int(lst[i]) == 255:
ChetanGaonker720ea612016-06-21 17:54:25 -070086 lst[i] = '0'
87 if int(lst[i-1]) < 255:
88 return self.inc_ip(lst,i-1)
89 elif int(lst[i-2]) < 255:
90 lst[i-1] = '0'
91 return self.inc_ip(lst,i-2)
92 else:
93 break
ChetanGaonkera6adc0b2016-06-12 12:21:14 -070094
95 def to_egress_ip(self, ip):
96 lst=ip.split('.')
97 lst[0] = '182'
98 return '.'.join(lst)
99
ChetanGaonker720ea612016-06-21 17:54:25 -0700100
Chetan Gaonker7ab338c2016-04-15 17:23:17 -0700101 @classmethod
102 def setUpClass(cls):
103 cls.olt = OltConfig()
A R Karthickb03cecd2016-07-27 10:27:55 -0700104 cls.port_map, _ = cls.olt.olt_port_map()
Chetan Gaonker7ab338c2016-04-15 17:23:17 -0700105 if not cls.port_map:
106 cls.port_map = cls.default_port_map
A R Karthickb03cecd2016-07-27 10:27:55 -0700107 cls.device_id = OnosCtrl.get_device_id()
Chetan Gaonker7ab338c2016-04-15 17:23:17 -0700108
109 def test_flow_mac(self):
ChetanGaonkera6adc0b2016-06-12 12:21:14 -0700110 '''Test Add and verify flows with MAC selectors'''
Chetan Gaonker7ab338c2016-04-15 17:23:17 -0700111 egress = 1
112 ingress = 2
113 egress_mac = '00:00:00:00:00:01'
114 ingress_mac = '00:00:00:00:00:02'
ChetanGaonker720ea612016-06-21 17:54:25 -0700115
Chetan Gaonker7ab338c2016-04-15 17:23:17 -0700116 flow = OnosFlowCtrl(deviceId = self.device_id,
117 egressPort = egress,
118 ingressPort = ingress,
119 ethSrc = ingress_mac,
120 ethDst = egress_mac)
121 result = flow.addFlow()
122 assert_equal(result, True)
123 ##wait for flows to be added to ONOS
ChetanGaonker720ea612016-06-21 17:54:25 -0700124 time.sleep(1)
Chetan Gaonker7ab338c2016-04-15 17:23:17 -0700125 self.success = False
126 def mac_recv_task():
127 def recv_cb(pkt):
128 log.info('Pkt seen with ingress mac %s, egress mac %s' %(pkt.src, pkt.dst))
129 self.success = True
ChetanGaonkera6adc0b2016-06-12 12:21:14 -0700130 sniff(count=2, timeout=5, lfilter = lambda p: p.src == ingress_mac,
Chetan Gaonker7ab338c2016-04-15 17:23:17 -0700131 prn = recv_cb, iface = self.port_map[egress])
132
133 t = threading.Thread(target = mac_recv_task)
134 t.start()
135 pkt = Ether(src = ingress_mac, dst = egress_mac)/IP()
136 log.info('Sending a packet to verify if flows are correct')
137 sendp(pkt, count=50, iface = self.port_map[ingress])
138 t.join()
139 assert_equal(self.success, True)
140
141 def test_flow_ip(self):
ChetanGaonkera6adc0b2016-06-12 12:21:14 -0700142 '''Test Add and verify flows with IPv4 selectors'''
Chetan Gaonker7ab338c2016-04-15 17:23:17 -0700143 egress = 1
144 ingress = 2
145 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '192.168.30.1' }
146 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.168.40.1' }
147 flow = OnosFlowCtrl(deviceId = self.device_id,
148 egressPort = egress,
149 ingressPort = ingress,
150 ethType = '0x0800',
151 ipSrc = ('IPV4_SRC', ingress_map['ip']+'/32'),
152 ipDst = ('IPV4_DST', egress_map['ip']+'/32')
153 )
154 result = flow.addFlow()
155 assert_equal(result, True)
156 ##wait for flows to be added to ONOS
ChetanGaonker720ea612016-06-21 17:54:25 -0700157 time.sleep(1)
Chetan Gaonker7ab338c2016-04-15 17:23:17 -0700158 self.success = False
159 def mac_recv_task():
160 def recv_cb(pkt):
161 log.info('Pkt seen with ingress ip %s, egress ip %s' %(pkt[IP].src, pkt[IP].dst))
162 self.success = True
ChetanGaonkera6adc0b2016-06-12 12:21:14 -0700163 sniff(count=2, timeout=5,
Chetan Gaonker3533faa2016-04-25 17:50:14 -0700164 lfilter = lambda p: IP in p and p[IP].dst == egress_map['ip'] and p[IP].src == ingress_map['ip'],
Chetan Gaonker7ab338c2016-04-15 17:23:17 -0700165 prn = recv_cb, iface = self.port_map[egress])
166
167 t = threading.Thread(target = mac_recv_task)
168 t.start()
169 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
170 L3 = IP(src = ingress_map['ip'], dst = egress_map['ip'])
171 pkt = L2/L3
172 log.info('Sending a packet to verify if flows are correct')
173 sendp(pkt, count=50, iface = self.port_map[ingress])
174 t.join()
175 assert_equal(self.success, True)
ChetanGaonkera6adc0b2016-06-12 12:21:14 -0700176
177
178 def test_flow_tcp_port(self):
179 egress = 1
180 ingress = 2
181 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '192.168.30.1', 'tcp_port': 9500 }
182 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.168.40.1', 'tcp_port': 9000 }
183 flow = OnosFlowCtrl(deviceId = self.device_id,
184 egressPort = egress,
185 ingressPort = ingress,
186 tcpSrc = ingress_map['tcp_port'],
187 tcpDst = egress_map['tcp_port']
188 )
189 result = flow.addFlow()
190 assert_equal(result, True)
191 ##wait for flows to be added to ONOS
ChetanGaonker720ea612016-06-21 17:54:25 -0700192 time.sleep(1)
ChetanGaonkera6adc0b2016-06-12 12:21:14 -0700193 self.success = False
194 def mac_recv_task():
195 def recv_cb(pkt):
196 log.info('Pkt seen with ingress TCP port %s, egress TCP port %s' %(pkt[TCP].sport, pkt[TCP].dport))
197 self.success = True
ChetanGaonker720ea612016-06-21 17:54:25 -0700198 sniff(count=2, timeout=5, lfilter = lambda p: TCP in p and p[TCP].dport == egress_map['tcp_port']
199 and p[TCP].sport == ingress_map['tcp_port'], prn = recv_cb, iface = self.port_map[egress])
ChetanGaonkera6adc0b2016-06-12 12:21:14 -0700200
201 t = threading.Thread(target = mac_recv_task)
202 t.start()
203 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
204 L3 = IP(src = ingress_map['ip'], dst = egress_map['ip'])
205 L4 = TCP(sport = ingress_map['tcp_port'], dport = egress_map['tcp_port'])
206 pkt = L2/L3/L4
207 log.info('Sending packets to verify if flows are correct')
208 sendp(pkt, count=50, iface = self.port_map[ingress])
209 t.join()
210 assert_equal(self.success, True)
211
ChetanGaonkera6adc0b2016-06-12 12:21:14 -0700212 def test_flow_udp_port(self):
213 egress = 1
214 ingress = 2
215 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '192.168.30.1', 'udp_port': 9500 }
216 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.168.40.1', 'udp_port': 9000 }
217 flow = OnosFlowCtrl(deviceId = self.device_id,
218 egressPort = egress,
219 ingressPort = ingress,
220 udpSrc = ingress_map['udp_port'],
221 udpDst = egress_map['udp_port']
222 )
223 result = flow.addFlow()
224 assert_equal(result, True)
225 ##wait for flows to be added to ONOS
ChetanGaonker720ea612016-06-21 17:54:25 -0700226 time.sleep(1)
ChetanGaonkera6adc0b2016-06-12 12:21:14 -0700227 self.success = False
228 def mac_recv_task():
229 def recv_cb(pkt):
230 log.info('Pkt seen with ingress UDP port %s, egress UDP port %s' %(pkt[UDP].sport, pkt[UDP].dport))
231 self.success = True
232 sniff(count=2, timeout=5,
ChetanGaonker720ea612016-06-21 17:54:25 -0700233 lfilter = lambda p: UDP in p and p[UDP].dport == egress_map['udp_port']
234 and p[UDP].sport == ingress_map['udp_port'], prn = recv_cb, iface = self.port_map[egress])
ChetanGaonkera6adc0b2016-06-12 12:21:14 -0700235
236 t = threading.Thread(target = mac_recv_task)
237 t.start()
238 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
239 L3 = IP(src = ingress_map['ip'], dst = egress_map['ip'])
240 L4 = UDP(sport = ingress_map['udp_port'], dport = egress_map['udp_port'])
241 pkt = L2/L3/L4
242 log.info('Sending packets to verify if flows are correct')
243 sendp(pkt, count=50, iface = self.port_map[ingress])
244 t.join()
245 assert_equal(self.success, True)
246
ChetanGaonker720ea612016-06-21 17:54:25 -0700247 @nottest
248 def test_flow_vlan(self):
249 egress = 1
250 ingress = 2
251 egress_mac = '00:00:00:00:00:01'
252 ingress_mac = '00:00:00:00:00:02'
253 flow = OnosFlowCtrl(deviceId = self.device_id,
254 egressPort = egress,
255 ingressPort = ingress,
256 ethSrc = ingress_mac,
257 ethDst = egress_mac,
258 vlan = 0x10)
259 result = flow.addFlow()
260 assert_equal(result, True)
261 ##wait for flows to be added to ONOS
262 time.sleep(1)
263 self.success = False
264 def mac_recv_task():
265 def recv_cb(pkt):
266 log.info('Pkt seen with ingress mac %s, egress mac %s' %(pkt.src, pkt.dst))
267 log.info('Pkt:%s', pkt.show())
268 self.success = True
269 sniff(count=2, timeout=5, lfilter = lambda p:p.src == ingress_mac,
270 prn = recv_cb, iface = self.port_map[egress])
271
272 t = threading.Thread(target = mac_recv_task)
273 t.start()
274 pkt = Ether(src = ingress_mac, dst = egress_mac)/Dot1Q(vlan = 0x10)/IP()
275 log.info("Sending Packet:%s",pkt.show())
276 log.info('Sending a packet to verify if flows are correct')
277 sendp(pkt, count=50, iface = self.port_map[ingress])
278 t.join()
279 assert_equal(self.success, True)
280
281 def test_flow_ipv6(self):
282 egress = 1
283 ingress = 2
284 egress_map = { 'ether': '00:00:00:00:00:03', 'ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1001' }
285 ingress_map = { 'ether': '00:00:00:00:00:04', 'ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1002' }
286 flow = OnosFlowCtrl(deviceId = self.device_id,
287 egressPort = egress,
288 ingressPort = ingress,
289 ethType = '0x86dd',
290 ipSrc = ('IPV6_SRC', ingress_map['ipv6'] + '/48'),
291 ipDst = ('IPV6_DST', egress_map['ipv6'] + '/48')
292 )
293
294 result = flow.addFlow()
295 assert_equal(result, True)
296 ##wait for flows to be added to ONOS
297 time.sleep(1)
298 self.success = False
299 def mac_recv_task():
300 def recv_cb(pkt):
301 log.info('Pkt seen with ingress ip %s, egress ip %s' %(pkt[IPv6].src, pkt[IPv6].dst))
302 self.success = True
303 sniff(count=2, timeout=5,
304 lfilter = lambda p: IPv6 in p and p[IPv6].dst == egress_map['ipv6'] and p[IPv6].src == ingress_map['ipv6'],
305 prn = recv_cb, iface = self.port_map[egress])
306
307 t = threading.Thread(target = mac_recv_task)
308 t.start()
309 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
310 L3 = IPv6(src = ingress_map['ipv6'] , dst = egress_map['ipv6'])
311 pkt = L2/L3
312 log.info('Sending a packet to verify if flows are correct')
313 sendp(pkt, count=50, iface = self.port_map[ingress])
314 t.join()
315 assert_equal(self.success, True)
316
317 def test_flow_ipv6_flow_label(self):
318 egress = 1
319 ingress = 2
320 egress_map = { 'ether': '00:00:00:00:00:03', 'ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1001' }
321 ingress_map = { 'ether': '00:00:00:00:00:04', 'ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1002' }
322 flow = OnosFlowCtrl(deviceId = self.device_id,
323 egressPort = egress,
324 ingressPort = ingress,
325 ipv6flow_label = 25
326 )
327
328 result = flow.addFlow()
329 assert_equal(result, True)
330 ##wait for flows to be added to ONOS
331 time.sleep(1)
332 self.success = False
333 def mac_recv_task():
334 def recv_cb(pkt):
335 log.info('Pkt seen with ingress ip %s, egress ip %s with flow label %s' %(pkt[IPv6].src, pkt[IPv6].dst, pkt[IPv6].fl))
336 self.success = True
337 sniff(count=2, timeout=5, lfilter = lambda p: IPv6 in p and p[IPv6].dst == egress_map['ipv6']
338 and p[IPv6].src == ingress_map['ipv6'] and p[IPv6].fl == 25, prn = recv_cb, iface = self.port_map[egress])
339
340 t = threading.Thread(target = mac_recv_task)
341 t.start()
342 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
343 L3 = IPv6(src = ingress_map['ipv6'] , dst = egress_map['ipv6'], fl = 25)
344 pkt = L2/L3
345 log.info('Sending a packet to verify if flows are correct')
346 sendp(pkt, count=50, iface = self.port_map[ingress])
347 t.join()
348 assert_equal(self.success, True)
349
350 def test_flow_ipv6_extension_header(self):
351 egress = 1
352 ingress = 2
353 egress_map = { 'ether': '00:00:00:00:00:03', 'ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1001' }
354 ingress_map = { 'ether': '00:00:00:00:00:04', 'ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1002' }
355 flow = OnosFlowCtrl(deviceId = self.device_id,
356 egressPort = egress,
357 ingressPort = ingress,
358 ipv6_extension = 0,
359 )
360
361 result = flow.addFlow()
362 assert_equal(result, True)
363 ##wait for flows to be added to ONOS
364 time.sleep(1)
365 self.success = False
366 def mac_recv_task():
367 def recv_cb(pkt):
368 log.info('Pkt seen with ingress ip %s, egress ip %s, Extension Header Type %s' %(pkt[IPv6].src, pkt[IPv6].dst, pkt[IPv6].nh))
369 self.success = True
370 sniff(count=2, timeout=5,
371 lfilter = lambda p: IPv6 in p and p[IPv6].nh == 0, prn = recv_cb, iface = self.port_map[egress])
372
373 t = threading.Thread(target = mac_recv_task)
374 t.start()
375 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
376 L3 = IPv6(src = ingress_map['ipv6'] , dst = egress_map['ipv6'], nh = 0)
377 pkt = L2/L3
378 log.info('Sending packets to verify if flows are correct')
379 sendp(pkt, count=50, iface = self.port_map[ingress])
380 t.join()
381 assert_equal(self.success, True)
382
383 def test_flow_ipv6_available_extension_headers(self):
384 egress = 1
385 ingress = 2
386 egress_map = { 'ether': '00:00:00:00:00:03', 'ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1001' }
387 ingress_map = { 'ether': '00:00:00:00:00:04', 'ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1002' }
388 for i in [0, 60, 43, 44, 51, 50, 135]:
389 flow = OnosFlowCtrl(deviceId = self.device_id,
390 egressPort = egress,
391 ingressPort = ingress,
392 ipv6_extension = i,
393 )
394
395 result = flow.addFlow()
396 assert_equal(result, True)
397 ##wait for flows to be added to ONOS
398 time.sleep(1)
399 def mac_recv_task():
400 def recv_cb(pkt):
401 log.info('Pkt seen with ingress ip %s, egress ip %s, Extension Header Type %s' %(pkt[IPv6].src, pkt[IPv6].dst, pkt[IPv6].nh))
402 self.success = True
403 sniff(count=2, timeout=5, lfilter = lambda p: IPv6 in p and p[IPv6].nh == i,
404 prn = recv_cb, iface = self.port_map[egress])
405
406 for i in [0, 60, 43, 44, 51, 50, 135]:
407 self.success = False
408 t = threading.Thread(target = mac_recv_task)
409 t.start()
410 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
411 L3 = IPv6(src = ingress_map['ipv6'] , dst = egress_map['ipv6'], nh = i)
412 pkt = L2/L3
413 log.info('Sending packets to verify if flows are correct')
414 sendp(pkt, count=50, iface = self.port_map[ingress])
415 t.join()
416 assert_equal(self.success, True)
417
418
419 def test_flow_dscp(self):
420 egress = 1
421 ingress = 2
422 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '192.168.30.1' }
423 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.168.40.1' }
424 flow = OnosFlowCtrl(deviceId = self.device_id,
425 egressPort = egress,
426 ingressPort = ingress,
427 dscp = 32
428 )
429 result = flow.addFlow()
430 assert_equal(result, True)
431 ##wait for flows to be added to ONOS
432 time.sleep(1)
433 self.success = False
434 def mac_recv_task():
435 def recv_cb(pkt):
436 log.info('Pkt seen with ingress ip %s, egress ip %s and Type of Service %s' %(pkt[IP].src, pkt[IP].dst, pkt[IP].tos))
437 self.success = True
438 sniff(count=2, timeout=5,
439 lfilter = lambda p: IP in p and p[IP].dst == egress_map['ip'] and p[IP].src == ingress_map['ip']
440 and p[IP].tos == 32,prn = recv_cb, iface = self.port_map[egress])
441
442 t = threading.Thread(target = mac_recv_task)
443 t.start()
444 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
445 L3 = IP(src = ingress_map['ip'], dst = egress_map['ip'], tos = 32)
446 pkt = L2/L3
447 log.info('Sending a packet to verify if flows are correct')
448 sendp(pkt, count=50, iface = self.port_map[ingress])
449 t.join()
450 assert_equal(self.success, True)
451
452 def test_flow_available_dscp(self):
453 egress = 1
454 ingress = 2
455 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '192.168.30.1' }
456 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.168.40.1' }
457 dscp = [184, 0, 40, 48, 56, 72, 80, 88, 104, 112, 120, 136, 144, 152, 32, 64, 96, 128, 160, 192, 224]
458 for i in dscp:
459 flow = OnosFlowCtrl(deviceId = self.device_id,
460 egressPort = egress,
461 ingressPort = ingress,
462 dscp = i
463 )
464 result = flow.addFlow()
465 assert_equal(result, True)
466 ##wait for flows to be added to ONOS
467 time.sleep(1)
468
469 def mac_recv_task():
470 def recv_cb(pkt):
471 log.info('Pkt seen with ingress ip %s, egress ip %s and Type of Service %s' %(pkt[IP].src, pkt[IP].dst, pkt[IP].tos))
472 self.success = True
473 sniff(count=2, timeout=5,
474 lfilter = lambda p: IP in p and p[IP].dst == egress_map['ip'] and p[IP].src == ingress_map['ip']
475 and p[IP].tos == i,prn = recv_cb, iface = self.port_map[egress])
476
477 for i in dscp:
478 self.success = False
479 t = threading.Thread(target = mac_recv_task)
480 t.start()
481 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
482 L3 = IP(src = ingress_map['ip'], dst = egress_map['ip'], tos = i)
483 pkt = L2/L3
484 log.info('Sending a packet to verify if flows are correct')
485 sendp(pkt, count=50, iface = self.port_map[ingress])
486 t.join()
487 assert_equal(self.success, True)
488
489 def test_flow_ecn(self):
490 egress = 1
491 ingress = 2
492 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '192.168.30.1' }
493 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.168.40.1' }
494 flow = OnosFlowCtrl(deviceId = self.device_id,
495 egressPort = egress,
496 ingressPort = ingress,
497 ecn = 1
498 )
499 result = flow.addFlow()
500 assert_equal(result, True)
501 ##wait for flows to be added to ONOS
502 time.sleep(1)
503 self.success = False
504 def mac_recv_task():
505 def recv_cb(pkt):
506 log.info('Pkt seen with ingress ip %s, egress ip %s and Type of Service %s' %(pkt[IP].src, pkt[IP].dst, pkt[IP].tos))
507 self.success = True
508 sniff(count=2, timeout=5,
509 lfilter = lambda p: IP in p and p[IP].dst == egress_map['ip'] and p[IP].src == ingress_map['ip']
510 and int(bin(p[IP].tos).split('b')[1][-2:],2) == 1,prn = recv_cb,
511 iface = self.port_map[egress])
512
513 t = threading.Thread(target = mac_recv_task)
514 t.start()
515 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
516 L3 = IP(src = ingress_map['ip'], dst = egress_map['ip'], tos = 1)
517 pkt = L2/L3
518 log.info('Sending a packet to verify if flows are correct')
519 sendp(pkt, count=50, iface = self.port_map[ingress])
520 t.join()
521 assert_equal(self.success, True)
522
523
524 def test_flow_available_ecn(self):
525 egress = 1
526 ingress = 2
527 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '192.168.30.1' }
528 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.168.40.1' }
529 for i in range(4):
530 flow = OnosFlowCtrl(deviceId = self.device_id,
531 egressPort = egress,
532 ingressPort = ingress,
533 ecn = i
534 )
535 result = flow.addFlow()
536 assert_equal(result, True)
537 ##wait for flows to be added to ONOS
538 time.sleep(1)
539 def mac_recv_task():
540 def recv_cb(pkt):
541 log.info('Pkt seen with ingress ip %s, egress ip %s and Type of Service %s' %(pkt[IP].src, pkt[IP].dst, pkt[IP].tos))
542 self.success = True
543 sniff(count=2, timeout=5,
544 lfilter = lambda p: IP in p and p[IP].dst == egress_map['ip'] and p[IP].src == ingress_map['ip']
545 and int(bin(p[IP].tos).split('b')[1][-2:],2) == i,prn = recv_cb,
546 iface = self.port_map[egress])
547
548 for i in range(4):
549 self.success = False
550 t = threading.Thread(target = mac_recv_task)
551 t.start()
552 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
553 L3 = IP(src = ingress_map['ip'], dst = egress_map['ip'], tos = i)
554 pkt = L2/L3
555 log.info('Sending a packet to verify if flows are correct')
556 sendp(pkt, count=50, iface = self.port_map[ingress])
557 t.join()
558 assert_equal(self.success, True)
559
560 def test_flow_available_dscp_and_ecn(self):
561 egress = 1
562 ingress = 2
563 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '192.168.30.1' }
564 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.168.40.1' }
565 dscp = [46, 0, 10, 12, 14, 18, 20, 22, 26, 28, 30, 34, 36, 38, 8, 16, 24, 32, 40, 48, 56]
566 for i in dscp:
567 for j in (0,1,2,3):
568 flow = OnosFlowCtrl(deviceId = self.device_id,
569 egressPort = egress,
570 ingressPort = ingress,
571 dscp = i,
572 ecn = j
573 )
574 result = flow.addFlow()
575 assert_equal(result, True)
576 ##wait for flows to be added to ONOS
577 time.sleep(1)
578
579 def mac_recv_task():
580 def recv_cb(pkt):
581 log.info('Pkt seen with ingress ip %s, egress ip %s and Type of Service %s' %(pkt[IP].src, pkt[IP].dst, pkt[IP].tos))
582 self.success = True
583 sniff(count=2, timeout=5,
584 lfilter = lambda p: IP in p and p[IP].tos == int(bin(i).split('b')[1]+ bin(j).split('b')[1],2)
585 ,prn = recv_cb, iface = self.port_map[egress])
586
587 for i in dscp:
588 for j in (0,1,2,3):
589
590 self.success = False
591 t = threading.Thread(target = mac_recv_task)
592 t.start()
593 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
594 L3 = IP(src = ingress_map['ip'], dst = egress_map['ip'], tos = int(bin(i).split('b')[1]+ bin(j).split('b')[1],2))
595 pkt = L2/L3
596 log.info('Sending packets to verify if flows are correct')
597 sendp(pkt, count=50, iface = self.port_map[ingress])
598 t.join()
599 assert_equal(self.success, True)
600
601 def test_flow_icmp(self):
602 egress = 1
603 ingress = 2
604 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '192.168.30.1' }
605 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.168.40.1' }
606 flow = OnosFlowCtrl(deviceId = self.device_id,
607 egressPort = egress,
608 ingressPort = ingress,
609 icmpv4_type = '3',
610 icmpv4_code = 8
611 )
612 result = flow.addFlow()
613 assert_equal(result, True)
614 ##wait for flows to be added to ONOS
615 time.sleep(1)
616 self.success = False
617
618 def mac_recv_task():
619 def recv_cb(pkt):
620 log.info('Pkt seen with ICMP type %s, ICMP code %s' %(pkt[ICMP].type, pkt[ICMP].code))
621 self.success = True
622 sniff(count=2, timeout=5,
623 lfilter = lambda p: ICMP in p and p[ICMP].type == 3 and p[ICMP].code == 8,
624 prn = recv_cb, iface = self.port_map[egress])
625
626 t = threading.Thread(target = mac_recv_task)
627 t.start()
628 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
629 L3 = IP(src = ingress_map['ip'], dst = egress_map['ip'])/ICMP(type = 3, code = 8)
630 pkt = L2/L3
631 log.info('Sending a packet to verify if flows are correct')
632 sendp(pkt, count=50, iface = self.port_map[ingress])
633 t.join()
634 assert_equal(self.success, True)
635
636 def test_flow_icmp_different_types(self):
637 egress = 1
638 ingress = 2
639 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '192.168.30.1' }
640 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.168.40.1' }
641 icmp = {'11': [0, 1], '10': 0, '0': 0, '3': [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
642 '5': [1, 2, 3], '4': 0, '9': 0, '8': 0}
643 for type,code in icmp.items():
644 if isinstance(code, list):
645 for i in code:
646 flow = OnosFlowCtrl(deviceId = self.device_id,
647 egressPort = egress,
648 ingressPort = ingress,
649 icmpv4_type = type,
650 icmpv4_code = i
651 )
652 result = flow.addFlow()
653 assert_equal(result, True)
654 ##wait for flows to be added to ONOS
655 time.sleep(1)
656 else:
657 flow = OnosFlowCtrl(deviceId = self.device_id,
658 egressPort = egress,
659 ingressPort = ingress,
660 icmpv4_type = type,
661 icmpv4_code = code
662 )
663 result = flow.addFlow()
664 assert_equal(result, True)
665 ##wait for flows to be added to ONOS
666 time.sleep(1)
667 self.success = False
668
669 def mac_recv_task():
670 def recv_cb(pkt):
671 log.info('Pkt seen with ICMP type %s, ICMP code %s' %(pkt[ICMP].type, pkt[ICMP].code))
672 self.success = True
673 sniff(count=2, timeout=5,
674 lfilter = lambda p: ICMP in p and p[ICMP].type == 3 and p[ICMP].code == 8,
675 prn = recv_cb, iface = self.port_map[egress])
676
677 t = threading.Thread(target = mac_recv_task)
678 t.start()
679 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
680 L3 = IP(src = ingress_map['ip'], dst = egress_map['ip'])/ICMP(type = 3, code = 8)
681 pkt = L2/L3
682 log.info('Sending a packet to verify if flows are correct')
683 sendp(pkt, count=50, iface = self.port_map[ingress])
684 t.join()
685 assert_equal(self.success, True)
686
687 def test_flow_icmpv6_EchoRequest(self):
688 egress = 1
689 ingress = 2
690 egress_map = { 'ether': '00:00:00:00:00:03','ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1001'}
691 ingress_map = { 'ether': '00:00:00:00:00:04','ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1002'}
692 flow = OnosFlowCtrl(deviceId = self.device_id,
693 egressPort = egress,
694 ingressPort = ingress,
695 icmpv6_type = '128',
696 icmpv6_code = 0
697 )
698 result = flow.addFlow()
699 assert_equal(result, True)
700 ##wait for flows to be added to ONOS
701 time.sleep(1)
702 self.success = False
703 def mac_recv_task():
704 def recv_cb(pkt):
705 log.info('Pkt seen with ICMPv6 type %s, ICMPv6 code %s' %(pkt[ICMPv6EchoRequest].type, pkt[ICMPv6EchoRequest].code))
706 self.success = True
707 sniff(count=2, timeout=5,
708 lfilter = lambda p: ICMPv6EchoRequest in p and p[ICMPv6EchoRequest].type == 128 and p[ICMPv6EchoRequest].code == 0,
709 prn = recv_cb, iface = self.port_map[egress])
710
711 t = threading.Thread(target = mac_recv_task)
712 t.start()
713 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
714 L3 = IPv6(src = ingress_map['ipv6'], dst = egress_map['ipv6'])/ICMPv6EchoRequest()
715 pkt = L2/L3
716 log.info('Sending a packet to verify if flows are correct')
717 sendp(pkt, count=50, iface = self.port_map[ingress])
718 t.join()
719 assert_equal(self.success, True)
720
721 def test_flow_icmpv6_EchoReply(self):
722 egress = 1
723 ingress = 2
724 egress_map = { 'ether': '00:00:00:00:00:03','ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1001'}
725 ingress_map = { 'ether': '00:00:00:00:00:04','ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1002' }
726 flow = OnosFlowCtrl(deviceId = self.device_id,
727 egressPort = egress,
728 ingressPort = ingress,
729 icmpv6_type = '129',
730 icmpv6_code = 0
731 )
732 result = flow.addFlow()
733 assert_equal(result, True)
734 ##wait for flows to be added to ONOS
735 time.sleep(1)
736 self.success = False
737 def mac_recv_task():
738 def recv_cb(pkt):
739 log.info('Pkt seen with ICMPv6 type %s, ICMPv6 code %s' %(pkt[ICMPv6EchoReply].type, pkt[ICMPv6EchoReply].code))
740 self.success = True
741 sniff(count=2, timeout=5,
742 lfilter = lambda p: ICMPv6EchoReply in p and p[ICMPv6EchoReply].type == 129 and p[ICMPv6EchoReply].code == 0,
743 prn = recv_cb, iface = self.port_map[egress])
744
745 t = threading.Thread(target = mac_recv_task)
746 t.start()
747 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
748 L3 = IPv6(src = ingress_map['ipv6'], dst = egress_map['ipv6'])/ICMPv6EchoReply()
749 pkt = L2/L3
750 log.info('Sending packets to verify if flows are correct')
751 sendp(pkt, count=50, iface = self.port_map[ingress])
752 t.join()
753 assert_equal(self.success, True)
754
755
756 def test_flow_icmpv6_DestUnreachable(self):
757 egress = 1
758 ingress = 2
759 egress_map = { 'ether': '00:00:00:00:00:03','ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1001'}
760 ingress_map = { 'ether': '00:00:00:00:00:04','ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1002' }
761 for i in range(8):
762 flow = OnosFlowCtrl(deviceId = self.device_id,
763 egressPort = egress,
764 ingressPort = ingress,
765 icmpv6_type = '1',
766 icmpv6_code = i
767 )
768 result = flow.addFlow()
769 assert_equal(result, True)
770 ##wait for flows to be added to ONOS
771 time.sleep(1)
772 for i in range(8):
773 self.success = False
774 def mac_recv_task():
775 def recv_cb(pkt):
776 log.info('Pkt seen with ICMPv6 type %s, ICMPv6 code %s' %(pkt[ICMPv6DestUnreach].type, pkt[ICMPv6DestUnreach].code))
777 self.success = True
778 sniff(count=2, timeout=5,
779 lfilter = lambda p: ICMPv6DestUnreach in p and p[ICMPv6DestUnreach].type == 1 and p[ICMPv6DestUnreach].code == i,
780 prn = recv_cb, iface = self.port_map[egress])
781
782 t = threading.Thread(target = mac_recv_task)
783 t.start()
784 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
785 L3 = IPv6(src = ingress_map['ipv6'], dst = egress_map['ipv6'])/ICMPv6DestUnreach(code = i)
786 pkt = L2/L3
787 log.info('Sending packets to verify if flows are correct')
788 sendp(pkt, count=50, iface = self.port_map[ingress])
789 t.join()
790 assert_equal(self.success, True)
791
792 def test_flow_icmpv6_PacketTooBig(self):
793 egress = 1
794 ingress = 2
795 egress_map = { 'ether': '00:00:00:00:00:03','ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1001'}
796 ingress_map = { 'ether': '00:00:00:00:00:04','ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1002' }
797 flow = OnosFlowCtrl(deviceId = self.device_id,
798 egressPort = egress,
799 ingressPort = ingress,
800 icmpv6_type = '2',
801 icmpv6_code = 0
802 )
803 result = flow.addFlow()
804 assert_equal(result, True)
805 ##wait for flows to be added to ONOS
806 time.sleep(1)
807 self.success = False
808 def mac_recv_task():
809 def recv_cb(pkt):
810 log.info('Pkt seen with ICMPv6 type %s, ICMPv6 code %s' %(pkt[ICMPv6PacketTooBig].type, pkt[ICMPv6PacketTooBig].code))
811 self.success = True
812 sniff(count=2, timeout=5,
813 lfilter = lambda p: ICMPv6PacketTooBig in p and p[ICMPv6PacketTooBig].type == 2 and p[ICMPv6PacketTooBig].code == 0,
814 prn = recv_cb, iface = self.port_map[egress])
815
816 t = threading.Thread(target = mac_recv_task)
817 t.start()
818 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
819 L3 = IPv6(src = ingress_map['ipv6'], dst = egress_map['ipv6'])/ICMPv6PacketTooBig()
820 pkt = L2/L3
821 log.info('Sending packets to verify if flows are correct')
822 sendp(pkt, count=50, iface = self.port_map[ingress])
823 t.join()
824 assert_equal(self.success, True)
825
826 def test_flow_icmpv6_TimeExceeded(self):
827 egress = 1
828 ingress = 2
829 egress_map = { 'ether': '00:00:00:00:00:03','ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1001'}
830 ingress_map = { 'ether': '00:00:00:00:00:04','ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1002' }
831 for i in range(2):
832 flow = OnosFlowCtrl(deviceId = self.device_id,
833 egressPort = egress,
834 ingressPort = ingress,
835 icmpv6_type = '3',
836 icmpv6_code = i
837 )
838 result = flow.addFlow()
839 assert_equal(result, True)
840 ##wait for flows to be added to ONOS
841 time.sleep(1)
842 for i in range(2):
843 self.success = False
844 def mac_recv_task():
845 def recv_cb(pkt):
846 log.info('Pkt seen with ICMPv6 type %s, ICMPv6 code %s' %(pkt[ICMPv6TimeExceeded].type, pkt[ICMPv6TimeExceeded].code))
847 self.success = True
848 sniff(count=2, timeout=5,
849 lfilter = lambda p: ICMPv6TimeExceeded in p and p[ICMPv6TimeExceeded].type == 3 and p[ICMPv6TimeExceeded].code == i,
850 prn = recv_cb, iface = self.port_map[egress])
851
852 t = threading.Thread(target = mac_recv_task)
853 t.start()
854 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
855 L3 = IPv6(src = ingress_map['ipv6'], dst = egress_map['ipv6'])/ICMPv6TimeExceeded(code = i)
856 pkt = L2/L3
857 log.info('Sending packets to verify if flows are correct')
858 sendp(pkt, count=50, iface = self.port_map[ingress])
859 t.join()
860 assert_equal(self.success, True)
861
862 def test_flow_icmpv6_ParameterProblem(self):
863 egress = 1
864 ingress = 2
865 egress_map = { 'ether': '00:00:00:00:00:03','ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1001'}
866 ingress_map = { 'ether': '00:00:00:00:00:04','ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1002' }
867 for i in range(3):
868 flow = OnosFlowCtrl(deviceId = self.device_id,
869 egressPort = egress,
870 ingressPort = ingress,
871 icmpv6_type = '4',
872 icmpv6_code = i
873 )
874 result = flow.addFlow()
875 assert_equal(result, True)
876 ##wait for flows to be added to ONOS
877 time.sleep(1)
878 for i in range(3):
879 self.success = False
880 def mac_recv_task():
881 def recv_cb(pkt):
882 log.info('Pkt seen with ICMPv6 type %s, ICMPv6 code %s' %(pkt[ICMPv6ParamProblem].type, pkt[ICMPv6ParamProblem].code))
883 self.success = True
884 sniff(count=2, timeout=5,
885 lfilter = lambda p: ICMPv6ParamProblem in p and p[ICMPv6ParamProblem].type == 4 and p[ICMPv6ParamProblem].code == i,
886 prn = recv_cb, iface = self.port_map[egress])
887
888 t = threading.Thread(target = mac_recv_task)
889 t.start()
890 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
891 L3 = IPv6(src = ingress_map['ipv6'], dst = egress_map['ipv6'])/ICMPv6ParamProblem(code = i)
892 pkt = L2/L3
893 log.info('Sending packets to verify if flows are correct')
894 sendp(pkt, count=50, iface = self.port_map[ingress])
895 t.join()
896 assert_equal(self.success, True)
897
898 def test_flow_icmpv6_ND_Target_address(self):
899 egress = 1
900 ingress = 2
901 ingress_map = { 'ether': '00:00:00:00:00:04','ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1002'}
902 flow = OnosFlowCtrl(deviceId = self.device_id,
903 egressPort = egress,
904 ingressPort = ingress,
905 ipv6_target = '2001:db8:a0b:12f0:1010:1010:1010:1001')
906 result = flow.addFlow()
907 assert_equal(result, True)
908 ##wait for flows to be added to ONOS
909 time.sleep(1)
910 self.success = False
911 def mac_recv_task():
912 def recv_cb(pkt):
913 log.info('Pkt seen with ICMPv6 Neighbor Discovery type %s, target address %s' %(pkt[ICMPv6ND_NS].type, pkt[ICMPv6ND_NS].tgt))
914 self.success = True
915 sniff(count=2, timeout=5,
916 lfilter = lambda p: ICMPv6ND_NS in p and p[ICMPv6ND_NS].tgt == '2001:db8:a0b:12f0:1010:1010:1010:1001',
917 prn = recv_cb, iface = self.port_map[egress])
918
919 t = threading.Thread(target = mac_recv_task)
920 t.start()
921 L2 = Ether(src = ingress_map['ether'])
922 L3 = IPv6(src = ingress_map['ipv6'])/ICMPv6ND_NS(tgt = '2001:db8:a0b:12f0:1010:1010:1010:1001')
923 pkt = L2/L3
924 log.info('Sending packets to verify if flows are correct')
925 sendp(pkt, count=50, iface = self.port_map[ingress])
926 t.join()
927 assert_equal(self.success, True)
928
929 def test_flow_icmpv6_ND_SLL(self):
930 egress = 1
931 ingress = 2
932 egress_map = { 'ether': '00:00:00:00:00:03', 'ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1001'}
933 ingress_map = { 'ether': '00:00:00:00:00:04','ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1002'}
934 flow = OnosFlowCtrl(deviceId = self.device_id,
935 egressPort = egress,
936 ingressPort = ingress,
937 ipv6_sll = ingress_map['ether'])
938 result = flow.addFlow()
939 assert_equal(result, True)
940 ##wait for flows to be added to ONOS
941 time.sleep(1)
942 self.success = False
943 def mac_recv_task():
944 def recv_cb(pkt):
945 log.info('Pkt seen with ICMPv6 Neighbor Discovery type %s, Source Link Layer address %s' %(pkt[ICMPv6ND_NS].type, pkt[ICMPv6NDOptSrcLLAddr].lladdr))
946 self.success = True
947 sniff(count=2, timeout=5,
948 lfilter = lambda p: ICMPv6NDOptSrcLLAddr in p and p[ICMPv6NDOptSrcLLAddr].lladdr == ingress_map['ether'],
949 prn = recv_cb, iface = self.port_map[egress])
950
951 t = threading.Thread(target = mac_recv_task)
952 t.start()
953 L2 = Ether(src = ingress_map['ether'])#, dst = ingress_map['ether'])
954 L3 = IPv6(src = ingress_map['ipv6'], dst = egress_map['ipv6'])/ICMPv6ND_NS(tgt = egress_map['ipv6'])/ICMPv6NDOptSrcLLAddr(lladdr = ingress_map['ether'])
955 pkt = L2/L3
956 log.info('Sending packets to verify if flows are correct')
957 sendp(pkt, count=50, iface = self.port_map[ingress])
958 t.join()
959 assert_equal(self.success, True)
960
961 def test_flow_icmpv6_NA_TLL(self):
962 egress = 1
963 ingress = 2
964 egress_map = { 'ether': '00:00:00:00:00:03', 'ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1001'}
965 ingress_map = { 'ether': '00:00:00:00:00:04','ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1002'}
966 flow = OnosFlowCtrl(deviceId = self.device_id,
967 egressPort = egress,
968 ingressPort = ingress,
969 ipv6_tll = egress_map['ether'])
970 result = flow.addFlow()
971 assert_equal(result, True)
972 ##wait for flows to be added to ONOS
973 time.sleep(1)
974 self.success = False
975 def mac_recv_task():
976 def recv_cb(pkt):
977 log.info('Pkt seen with ICMPv6 Neighbor Advertisement type %s, Target Link Layer address %s' %(pkt[ICMPv6ND_NA].type, pkt[ICMPv6NDOptDstLLAddr].lladdr))
978 self.success = True
979 sniff(count=2, timeout=5,
980 lfilter = lambda p: ICMPv6NDOptDstLLAddr in p and p[ICMPv6NDOptDstLLAddr].lladdr == ingress_map['ether'],
981 prn = recv_cb, iface = self.port_map[egress])
982
983 t = threading.Thread(target = mac_recv_task)
984 t.start()
985 L2 = Ether(src = ingress_map['ether'])#, dst = ingress_map['ether'])
986 L3 = IPv6(src = ingress_map['ipv6'], dst = egress_map['ipv6'])/ICMPv6ND_NA(tgt = ingress_map['ipv6'])/ICMPv6NDOptDstLLAddr(lladdr = ingress_map['ether'])
987 pkt = L2/L3
988 log.info('Sending packets to verify if flows are correct')
989 sendp(pkt, count=50, iface = self.port_map[ingress])
990 t.join()
991 assert_equal(self.success, True)
992
993 def test_flow_ipv6_and_icmpv6(self):
994 egress = 1
995 ingress = 2
996 egress_map = { 'ether': '00:00:00:00:00:03', 'ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1001' }
997 ingress_map = { 'ether': '00:00:00:00:00:04', 'ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1002' }
998 flow = OnosFlowCtrl(deviceId = self.device_id,
999 egressPort = egress,
1000 ingressPort = ingress,
1001 ethType = '0x86dd',
1002 ipSrc = ('IPV6_SRC', ingress_map['ipv6'] + '/48'),
1003 ipDst = ('IPV6_DST', egress_map['ipv6'] + '/48'),
1004 icmpv6_type = '128',
1005 icmpv6_code = 0
1006 )
1007
1008 result = flow.addFlow()
1009 assert_equal(result, True)
1010 ##wait for flows to be added to ONOS
1011 time.sleep(1)
1012 self.success = False
1013
1014 def mac_recv_task():
1015 def recv_cb(pkt):
1016 log.info('Pkt seen with ingress ip %s, egress ip %s' %(pkt[IPv6].src, pkt[IPv6].dst))
1017 self.success = True
1018 sniff(count=2, timeout=5,
1019 lfilter = lambda p: IPv6 in p and p[IPv6].dst == egress_map['ipv6'] and p[IPv6].src == ingress_map['ipv6']
1020 and p[ICMPv6EchoRequest].type == 128 and p[ICMPv6EchoRequest].code == 0, prn = recv_cb, iface = self.port_map[egress])
1021
1022 t = threading.Thread(target = mac_recv_task)
1023 t.start()
1024 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
1025 L3 = IPv6(src = ingress_map['ipv6'] , dst = egress_map['ipv6'])/ICMPv6EchoRequest()
1026 pkt = L2/L3
1027 log.info('Sending a packet to verify if flows are correct')
1028 sendp(pkt, count=50, iface = self.port_map[ingress])
1029 t.join()
1030 assert_equal(self.success, True)
1031
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001032 def test_5_flow_constant_dst_mac(self):
1033 egress = 1
1034 ingress = 2
1035 egress_mac = '00:00:00:00:01:01'
1036 ingress_mac = '00:00:00:00:00:00'
1037
ChetanGaonker720ea612016-06-21 17:54:25 -07001038
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001039 for i in range(0,5):
1040 ingress_mac = self.next_mac(ingress_mac)
1041
1042 flow = OnosFlowCtrl(deviceId = self.device_id,
1043 egressPort = egress,
1044 ingressPort = ingress,
1045 ethSrc = ingress_mac,
1046 ethDst = egress_mac)
1047 result = flow.addFlow()
1048 assert_equal(result, True)
1049 ##wait for flows to be added to ONOS
1050 time.sleep(1)
1051 log.info("%d flow added.",i+1)
1052 self.success = False
1053
1054 def mac_recv_task():
1055 def recv_cb(pkt):
1056 log.info('Pkt seen with ingress mac %s, egress mac %s' %(pkt.src, pkt.dst))
1057 self.success = True
1058 sniff(count=2, timeout=5, lfilter = lambda p: p.src == '00:00:00:00:00:02',
ChetanGaonker720ea612016-06-21 17:54:25 -07001059 prn = recv_cb, iface = self.port_map[egress])
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001060
1061 t = threading.Thread(target = mac_recv_task)
1062 t.start()
1063 pkt = Ether(src = '00:00:00:00:00:02', dst = egress_mac)/IP()
1064 log.info('Sending packets to verify if flows are correct')
1065 sendp(pkt, count=50, iface = self.port_map[ingress])
1066 t.join()
1067 assert_equal(self.success, True)
1068
1069
1070 def test_500_flow_constant_dst_mac(self):
1071 egress = 1
1072 ingress = 2
1073 egress_mac = '00:00:00:00:01:01'
1074 ingress_mac = '00:00:00:00:00:00'
1075 success_dir = {}
1076
1077 for i in range(0,500):
1078 ingress_mac = self.next_mac(ingress_mac)
1079
1080 flow = OnosFlowCtrl(deviceId = self.device_id,
1081 egressPort = egress,
1082 ingressPort = ingress,
1083 ethSrc = ingress_mac,
1084 ethDst = egress_mac)
1085 result = flow.addFlow()
1086 assert_equal(result, True)
1087 ##wait for flows to be added to ONOS
1088 time.sleep(1)
1089 log.info("%d flow added.",i+1)
ChetanGaonker720ea612016-06-21 17:54:25 -07001090 self.success = True
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001091
1092 def verify_flow(*r):
1093 random_src = ''.join(r)
1094 def mac_recv_task():
1095 def recv_cb(pkt):
1096 log.info('Pkt seen with ingress mac %s, egress mac %s' %(pkt.src, pkt.dst))
1097 success_dir[current_thread().name] = True
1098 sniff(count=2, timeout=5, lfilter = lambda p: p.src == random_src,
ChetanGaonker720ea612016-06-21 17:54:25 -07001099 prn = recv_cb, iface = self.port_map[egress])
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001100
ChetanGaonker720ea612016-06-21 17:54:25 -07001101 t = threading.Thread(target = mac_recv_task)
1102 t.start()
1103 pkt = Ether(src = random_src, dst = egress_mac)/IP()
1104 log.info('Sending packets to verify if flows are correct')
1105 sendp(pkt, count=50, iface = self.port_map[ingress])
1106 t.join()
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001107
1108 t1 = threading.Thread(target = verify_flow, args = '00:00:00:00:00:01')
1109 t2 = threading.Thread(target = verify_flow, args = '00:00:00:00:00:' + hex(random.randrange(50,254)).split('x')[1])
1110 t3 = threading.Thread(target = verify_flow, args = '01:00:00:00:00:' + hex(random.randrange(16,100)).split('x')[1])
1111 t4 = threading.Thread(target = verify_flow, args = '01:00:00:00:00:' + hex(random.randrange(101,240)).split('x')[1])
1112 t5 = threading.Thread(target = verify_flow, args = '01:00:00:00:00:f5')
1113 t1.start()
1114 t2.start()
1115 t3.start()
1116 t4.start()
1117 t5.start()
ChetanGaonker720ea612016-06-21 17:54:25 -07001118
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001119 t1.join()
1120 t2.join()
1121 t3.join()
1122 t4.join()
1123 t5.join()
ChetanGaonker720ea612016-06-21 17:54:25 -07001124
1125 if len(success_dir) != 5:
1126 self.success = False
1127
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001128 assert_equal(self.success, True)
1129
ChetanGaonker720ea612016-06-21 17:54:25 -07001130
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001131 def test_1k_flow_constant_dst_mac(self):
1132 egress = 1
1133 ingress = 2
1134 egress_mac = '00:00:00:00:01:01'
1135 ingress_mac = '00:00:00:00:00:00'
1136 success_dir = {}
1137
1138 for i in range(0,1000):
1139 ingress_mac = self.next_mac(ingress_mac)
ChetanGaonker720ea612016-06-21 17:54:25 -07001140
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001141 flow = OnosFlowCtrl(deviceId = self.device_id,
1142 egressPort = egress,
1143 ingressPort = ingress,
1144 ethSrc = ingress_mac,
1145 ethDst = egress_mac)
1146 result = flow.addFlow()
1147 assert_equal(result, True)
1148 ##wait for flows to be added to ONOS
1149 time.sleep(1)
1150 log.info("%d flow added.",i+1)
ChetanGaonker720ea612016-06-21 17:54:25 -07001151 self.success = True
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001152
1153 def verify_flow(*r):
1154 random_src = ''.join(r)
1155 def mac_recv_task():
1156 def recv_cb(pkt):
1157 log.info('Pkt seen with ingress mac %s, egress mac %s' %(pkt.src, pkt.dst))
1158 success_dir[current_thread().name] = True
1159 sniff(count=2, timeout=5, lfilter = lambda p: p.src == random_src,
ChetanGaonker720ea612016-06-21 17:54:25 -07001160 prn = recv_cb, iface = self.port_map[egress])
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001161
1162 t = threading.Thread(target = mac_recv_task)
1163 t.start()
1164 pkt = Ether(src = random_src, dst = egress_mac)/IP()
1165 log.info('Sending packets to verify if flows are correct')
1166 sendp(pkt, count=50, iface = self.port_map[ingress])
1167 t.join()
1168
1169 t1 = threading.Thread(target = verify_flow, args = '00:00:00:00:00:01')
1170 t2 = threading.Thread(target = verify_flow, args = '00:00:00:00:00:' + hex(random.randrange(50,254)).split('x')[1])
1171 t3 = threading.Thread(target = verify_flow, args = '01:00:00:00:00:09')
1172 t4 = threading.Thread(target = verify_flow, args = '01:00:00:00:00:' + hex(random.randrange(16,150)).split('x')[1])
1173 t5 = threading.Thread(target = verify_flow, args = '01:00:00:00:00:' + hex(random.randrange(151,250)).split('x')[1])
1174 t6 = threading.Thread(target = verify_flow, args = '02:00:00:00:00:08')
1175 t7 = threading.Thread(target = verify_flow, args = '02:00:00:00:00:' + hex(random.randrange(16,150)).split('x')[1])
1176 t8 = threading.Thread(target = verify_flow, args = '02:00:00:00:00:' + hex(random.randrange(151,250)).split('x')[1])
1177 t9 = threading.Thread(target = verify_flow, args = '03:00:00:00:00:'+ hex(random.randrange(16,175)).split('x')[1])
1178 t10 = threading.Thread(target = verify_flow, args = '03:00:00:00:00:eb')
1179 t1.start()
1180 t2.start()
1181 t3.start()
1182 t4.start()
1183 t5.start()
1184 t6.start()
1185 t7.start()
1186 t8.start()
1187 t9.start()
1188 t10.start()
1189
1190 t1.join()
1191 t2.join()
1192 t3.join()
1193 t4.join()
1194 t5.join()
1195 t6.join()
1196 t7.join()
1197 t8.join()
1198 t9.join()
1199 t10.join()
ChetanGaonker720ea612016-06-21 17:54:25 -07001200 if len(success_dir) != 10:
1201 self.success = False
1202
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001203 assert_equal(self.success, True)
1204
1205
1206 @nottest
1207 def test_10k_flow_constant_dst_mac(self):
1208 egress = 1
1209 ingress = 2
1210 egress_mac = '00:00:00:00:01:01'
1211 ingress_mac = '00:00:00:00:00:00'
1212 success_dir = {}
1213
ChetanGaonker720ea612016-06-21 17:54:25 -07001214
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001215 for i in range(0,10000):
1216 ingress_mac = self.next_mac(ingress_mac)
1217
1218 flow = OnosFlowCtrl(deviceId = self.device_id,
1219 egressPort = egress,
1220 ingressPort = ingress,
1221 ethSrc = ingress_mac,
1222 ethDst = egress_mac)
1223 result = flow.addFlow()
1224 assert_equal(result, True)
1225 ##wait for flows to be added to ONOS
1226 time.sleep(1)
1227 log.info("%d flow added.",i+1)
1228 self.success = True
1229
1230 def verify_flow(*r):
1231 random_src = ''.join(r)
1232 def mac_recv_task():
1233 def recv_cb(pkt):
1234 log.info('Pkt seen with ingress mac %s, egress mac %s' %(pkt.src, pkt.dst))
1235 success_dir[current_thread().name] = True
1236 sniff(count=2, timeout=5, lfilter = lambda p: p.src == random_src,
ChetanGaonker720ea612016-06-21 17:54:25 -07001237 prn = recv_cb, iface = self.port_map[egress])
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001238
1239 t = threading.Thread(target = mac_recv_task)
1240 t.start()
1241 pkt = Ether(src = random_src, dst = egress_mac)/IP()
1242 log.info('Sending packets to verify if flows are correct')
1243 sendp(pkt, count=50, iface = self.port_map[ingress])
1244 t.join()
1245
1246 t1 = threading.Thread(target = verify_flow, args = '00:00:00:00:00:01')
1247 t2 = threading.Thread(target = verify_flow, args = '01:00:00:00:00:' + hex(random.randrange(16,254)).split('x')[1])
1248 t3 = threading.Thread(target = verify_flow, args = '02:00:00:00:00:'+ hex(random.randrange(16,254)).split('x')[1])
1249 t4 = threading.Thread(target = verify_flow, args = '05:00:00:00:00:' + hex(random.randrange(16,254)).split('x')[1])
1250 t5 = threading.Thread(target = verify_flow, args = '07:00:00:00:00:' + hex(random.randrange(16,254)).split('x')[1])
1251 t6 = threading.Thread(target = verify_flow, args = hex(random.randrange(16,21)).split('x')[1] + ':00:00:00:00:08')
1252 t7 = threading.Thread(target = verify_flow, args = hex(random.randrange(17,21)).split('x')[1] +':00:00:00:00:' +
ChetanGaonker720ea612016-06-21 17:54:25 -07001253 hex(random.randrange(16,254)).split('x')[1])
1254
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001255 t8 = threading.Thread(target = verify_flow, args = hex(random.randrange(22,30)).split('x')[1] +':00:00:00:00:' +
ChetanGaonker720ea612016-06-21 17:54:25 -07001256 hex(random.randrange(16,254)).split('x')[1])
1257
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001258 t9 = threading.Thread(target = verify_flow, args = hex(random.randrange(31,38)).split('x')[1] +':00:00:00:00:' +
ChetanGaonker720ea612016-06-21 17:54:25 -07001259 hex(random.randrange(16,254)).split('x')[1])
1260
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001261 t10 = threading.Thread(target = verify_flow, args = '27:00:00:00:00:37')
1262
1263 t1.start()
1264 t2.start()
1265 t3.start()
1266 t4.start()
1267 t5.start()
1268 t6.start()
1269 t7.start()
1270 t8.start()
1271 t9.start()
1272 t10.start()
1273
1274 t1.join()
1275 t2.join()
1276 t3.join()
1277 t4.join()
1278 t5.join()
1279 t6.join()
1280 t7.join()
1281 t8.join()
1282 t9.join()
1283 t10.join()
ChetanGaonker720ea612016-06-21 17:54:25 -07001284 if len(success_dir) != 10:
1285 self.success = False
1286
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001287 assert_equal(self.success, True)
1288
1289 @nottest
1290 def test_100k_flow_constant_dst_mac(self):
1291 egress = 1
1292 ingress = 2
1293 egress_mac = '00:00:00:00:01:01'
1294 ingress_mac = '00:00:00:00:00:00'
1295 success_dir = {}
1296
1297
1298 for i in range(0,100000):
1299 ingress_mac = self.next_mac(ingress_mac)
1300
1301 flow = OnosFlowCtrl(deviceId = self.device_id,
1302 egressPort = egress,
1303 ingressPort = ingress,
1304 ethSrc = ingress_mac,
1305 ethDst = egress_mac)
1306 result = flow.addFlow()
1307 assert_equal(result, True)
1308 ##wait for flows to be added to ONOS
1309 time.sleep(1)
1310 log.info("%d flow added.",i+1)
1311 self.success = True
1312
1313 def verify_flow(*r):
1314 random_src = ''.join(r)
1315 def mac_recv_task():
1316 def recv_cb(pkt):
1317 log.info('Pkt seen with ingress mac %s, egress mac %s' %(pkt.src, pkt.dst))
1318 success_dir[current_thread().name] = True
1319 sniff(count=2, timeout=5, lfilter = lambda p: p.src == random_src,
ChetanGaonker720ea612016-06-21 17:54:25 -07001320 prn = recv_cb, iface = self.port_map[egress])
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001321
1322 t = threading.Thread(target = mac_recv_task)
1323 t.start()
1324 pkt = Ether(src = random_src, dst = egress_mac)/IP()
1325 log.info('Sending packets to verify if flows are correct')
1326 sendp(pkt, count=50, iface = self.port_map[ingress])
1327 t.join()
1328
1329 t1 = threading.Thread(target = verify_flow, args = '00:00:00:00:00:01')
1330 t2 = threading.Thread(target = verify_flow, args = '01:00:00:00:00:' + hex(random.randrange(16,254)).split('x')[1])
1331 t3 = threading.Thread(target = verify_flow, args = '02:00:00:00:00:'+ hex(random.randrange(16,254)).split('x')[1])
1332 t4 = threading.Thread(target = verify_flow, args = '05:00:00:00:00:' + hex(random.randrange(16,254)).split('x')[1])
1333 t5 = threading.Thread(target = verify_flow, args = '07:00:00:00:00:' + hex(random.randrange(16,254)).split('x')[1])
1334 t6 = threading.Thread(target = verify_flow, args = hex(random.randrange(16,41)).split('x')[1] + ':00:00:00:00:08')
1335 t7 = threading.Thread(target = verify_flow, args = hex(random.randrange(42,72)).split('x')[1] +':00:00:00:00:' +
1336 hex(random.randrange(16,254)).split('x')[1])
1337
1338 t8 = threading.Thread(target = verify_flow, args = hex(random.randrange(73,100)).split('x')[1] +':00:00:00:00:' +
1339 hex(random.randrange(16,254)).split('x')[1])
1340
1341 t9 = threading.Thread(target = verify_flow, args = hex(random.randrange(101,136)).split('x')[1] +':00:00:00:00:' +
1342 hex(random.randrange(16,254)).split('x')[1])
1343
1344 t10 = threading.Thread(target = verify_flow, args = '89:01:00:00:00:28')
1345
1346 t1.start()
1347 t2.start()
1348 t3.start()
1349 t4.start()
1350 t5.start()
1351 t6.start()
1352 t7.start()
1353 t8.start()
1354 t9.start()
1355 t10.start()
1356
1357 t1.join()
1358 t2.join()
1359 t3.join()
1360 t4.join()
1361 t5.join()
1362 t6.join()
1363 t7.join()
1364 t8.join()
1365 t9.join()
1366 t10.join()
ChetanGaonker720ea612016-06-21 17:54:25 -07001367 if len(success_dir) != 10:
1368 self.success = False
1369
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001370 assert_equal(self.success, True)
1371
1372
1373 @nottest
1374 def test_1000k_flow_constant_dst_mac(self):
1375 egress = 1
1376 ingress = 2
1377 egress_mac = '00:00:00:00:01:01'
1378 ingress_mac = '00:00:00:00:00:00'
1379 success_dir = {}
1380
ChetanGaonker720ea612016-06-21 17:54:25 -07001381
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001382 for i in range(0,1000000):
1383 ingress_mac = self.next_mac(ingress_mac)
1384
1385 flow = OnosFlowCtrl(deviceId = self.device_id,
1386 egressPort = egress,
1387 ingressPort = ingress,
1388 ethSrc = ingress_mac,
1389 ethDst = egress_mac)
1390 result = flow.addFlow()
1391 assert_equal(result, True)
1392 ##wait for flows to be added to ONOS
1393 time.sleep(1)
1394 log.info("%d flow added.",i+1)
1395 self.success = True
1396
1397 def verify_flow(*r):
1398 random_src = ''.join(r)
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001399 def mac_recv_task():
1400 def recv_cb(pkt):
1401 log.info('Pkt seen with ingress mac %s, egress mac %s' %(pkt.src, pkt.dst))
1402 success_dir[current_thread().name] = True
1403 sniff(count=2, timeout=5, lfilter = lambda p: p.src == random_src,
ChetanGaonker720ea612016-06-21 17:54:25 -07001404 prn = recv_cb, iface = self.port_map[egress])
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001405
1406 t = threading.Thread(target = mac_recv_task)
1407 t.start()
1408 pkt = Ether(src = random_src, dst = egress_mac)/IP()
1409 log.info('Sending packets to verify if flows are correct')
1410 sendp(pkt, count=50, iface = self.port_map[ingress])
1411 t.join()
1412
1413 t1 = threading.Thread(target = verify_flow, args = '00:00:00:00:00:01')
1414 t2 = threading.Thread(target = verify_flow, args = '01:00:00:00:00:' + hex(random.randrange(16,254)).split('x')[1])
1415 t3 = threading.Thread(target = verify_flow, args = '02:00:00:00:00:'+ hex(random.randrange(16,254)).split('x')[1])
1416 t4 = threading.Thread(target = verify_flow, args = '05:00:00:00:00:' + hex(random.randrange(16,254)).split('x')[1])
1417 t5 = threading.Thread(target = verify_flow, args = '07:00:00:00:00:' + hex(random.randrange(16,254)).split('x')[1])
1418 t6 = threading.Thread(target = verify_flow, args = hex(random.randrange(16,21)).split('x')[1] + ':00:00:00:00:08')
1419 t7 = threading.Thread(target = verify_flow, args = hex(random.randrange(22,50)).split('x')[1] +':00:00:00:00:' +
1420 hex(random.randrange(16,254)).split('x')[1])
1421
1422 t8 = threading.Thread(target = verify_flow, args = hex(random.randrange(51,75)).split('x')[1] +':00:00:00:00:' +
1423 hex(random.randrange(16,254)).split('x')[1])
1424
1425 t9 = threading.Thread(target = verify_flow, args = hex(random.randrange(76,95)).split('x')[1] +':00:00:00:00:' +
1426 hex(random.randrange(16,254)).split('x')[1])
1427
1428 t10 = threading.Thread(target = verify_flow, args = '60:0f:00:00:00:91')
1429
1430 t1.start()
1431 t2.start()
1432 t3.start()
1433 t4.start()
1434 t5.start()
1435 t6.start()
1436 t7.start()
1437 t8.start()
1438 t9.start()
1439 t10.start()
1440
1441 t1.join()
1442 t2.join()
1443 t3.join()
1444 t4.join()
1445 t5.join()
1446 t6.join()
1447 t7.join()
1448 t8.join()
1449 t9.join()
1450 t10.join()
ChetanGaonker720ea612016-06-21 17:54:25 -07001451 if len(success_dir) != 10:
1452 self.success = False
1453
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001454 assert_equal(self.success, True)
1455
ChetanGaonker720ea612016-06-21 17:54:25 -07001456 def test_5_flow_constant_src_mac(self):
1457 egress = 1
1458 ingress = 2
1459 egress_mac = '00:00:00:00:01:00'
1460 ingress_mac = '00:00:00:00:00:01'
1461
1462
1463 for i in range(0,5):
1464 egress_mac = self.next_mac(egress_mac)
1465
1466 flow = OnosFlowCtrl(deviceId = self.device_id,
1467 egressPort = egress,
1468 ingressPort = ingress,
1469 ethSrc = ingress_mac,
1470 ethDst = egress_mac)
1471 result = flow.addFlow()
1472 assert_equal(result, True)
1473 ##wait for flows to be added to ONOS
1474 time.sleep(1)
1475 log.info("%d flow added.",i+1)
1476 self.success = False
1477
1478 def mac_recv_task():
1479 def recv_cb(pkt):
1480 log.info('Pkt seen with ingress mac %s, egress mac %s' %(pkt.src, pkt.dst))
1481 self.success = True
1482 sniff(count=2, timeout=5, lfilter = lambda p: p.src == '00:00:00:00:00:01' and p.dst == '00:00:00:00:01:02',
1483 prn = recv_cb, iface = self.port_map[egress])
1484
1485 t = threading.Thread(target = mac_recv_task)
1486 t.start()
1487 pkt = Ether(src = ingress_mac, dst = '00:00:00:00:01:02')/IP()
1488 log.info('Sending packets to verify if flows are correct')
1489 sendp(pkt, count=50, iface = self.port_map[ingress])
1490 t.join()
1491 assert_equal(self.success, True)
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001492
1493 def test_500_flow_mac(self):
1494 egress = 1
1495 ingress = 2
1496 egress_mac = '00:00:00:00:01:00'
1497 ingress_mac = '00:00:00:00:00:00'
1498 success_dir = {}
1499
1500 for i in range(0,500):
1501 ingress_mac = self.next_mac(ingress_mac)
1502 egress_mac = self.to_egress_mac(ingress_mac)
1503
1504 flow = OnosFlowCtrl(deviceId = self.device_id,
1505 egressPort = egress,
1506 ingressPort = ingress,
1507 ethSrc = ingress_mac,
1508 ethDst = egress_mac)
1509 result = flow.addFlow()
1510 assert_equal(result, True)
1511 ##wait for flows to be added to ONOS
1512 time.sleep(1)
1513 log.info("%d flow added.",i+1)
1514 self.success = True
1515 def verify_flow(*r):
1516 random_src = ''.join(r)
ChetanGaonker720ea612016-06-21 17:54:25 -07001517
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001518 def mac_recv_task():
1519 def recv_cb(pkt):
1520 log.info('Pkt seen with ingress mac %s, egress mac %s' %(pkt.src, pkt.dst))
1521 success_dir[current_thread().name] = True
1522 sniff(count=2, timeout=5, lfilter = lambda p: p.src == random_src,
ChetanGaonker720ea612016-06-21 17:54:25 -07001523 prn = recv_cb, iface = self.port_map[egress])
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001524
1525 t = threading.Thread(target = mac_recv_task)
1526 t.start()
1527 pkt = Ether(src = random_src, dst = self.to_egress_mac(random_src))/IP()
1528 log.info('Sending packets to verify if flows are correct')
1529 sendp(pkt, count=50, iface = self.port_map[ingress])
1530 t.join()
1531
1532 t1 = threading.Thread(target = verify_flow, args = '00:00:00:00:00:01')
1533 t2 = threading.Thread(target = verify_flow, args = '00:00:00:00:00:' + hex(random.randrange(50,254)).split('x')[1])
1534 t3 = threading.Thread(target = verify_flow, args = '01:00:00:00:00:' + hex(random.randrange(16,100)).split('x')[1])
1535 t4 = threading.Thread(target = verify_flow, args = '01:00:00:00:00:' + hex(random.randrange(101,240)).split('x')[1])
1536 t5 = threading.Thread(target = verify_flow, args = '01:00:00:00:00:f5')
1537 t1.start()
1538 t2.start()
1539 t3.start()
1540 t4.start()
1541 t5.start()
1542 t1.join()
1543 t2.join()
1544 t3.join()
1545 t4.join()
1546 t5.join()
ChetanGaonker720ea612016-06-21 17:54:25 -07001547 if len(success_dir) != 5:
1548 self.success = False
1549
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001550 assert_equal(self.success, True)
1551
1552 def test_1k_flow_mac(self):
1553 egress = 1
1554 ingress = 2
1555 egress_mac = '00:00:00:00:01:00'
1556 ingress_mac = '00:00:00:00:00:00'
1557 success_dir = {}
1558
1559 for i in range(0,1000):
1560 ingress_mac = self.next_mac(ingress_mac)
1561 egress_mac = self.to_egress_mac(ingress_mac)
1562
1563 flow = OnosFlowCtrl(deviceId = self.device_id,
1564 egressPort = egress,
1565 ingressPort = ingress,
1566 ethSrc = ingress_mac,
1567 ethDst = egress_mac)
1568 result = flow.addFlow()
1569 assert_equal(result, True)
1570 ##wait for flows to be added to ONOS
1571 time.sleep(1)
1572 log.info("%d flow added.",i+1)
1573 self.success = True
1574 def verify_flow(*r):
1575 random_src = ''.join(r)
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001576 def mac_recv_task():
1577 def recv_cb(pkt):
1578 log.info('Pkt seen with ingress mac %s, egress mac %s' %(pkt.src, pkt.dst))
1579 success_dir[current_thread().name] = True
ChetanGaonker720ea612016-06-21 17:54:25 -07001580 sniff(count=2, timeout=5, lfilter = lambda p: p.src == random_src,
1581 prn = recv_cb, iface = self.port_map[egress])
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001582
1583 t = threading.Thread(target = mac_recv_task)
1584 t.start()
ChetanGaonker720ea612016-06-21 17:54:25 -07001585 pkt = Ether(src = random_src, dst = self.to_egress_mac(random_src))/IP()
1586 log.info('Sending packets to verify if flows are correct')
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001587 sendp(pkt, count=50, iface = self.port_map[ingress])
1588 t.join()
1589
1590 t1 = threading.Thread(target = verify_flow, args = '00:00:00:00:00:01')
1591 t2 = threading.Thread(target = verify_flow, args = '00:00:00:00:00:' + hex(random.randrange(50,254)).split('x')[1])
1592 t3 = threading.Thread(target = verify_flow, args = '01:00:00:00:00:09')
1593 t4 = threading.Thread(target = verify_flow, args = '01:00:00:00:00:' + hex(random.randrange(16,150)).split('x')[1])
1594 t5 = threading.Thread(target = verify_flow, args = '01:00:00:00:00:' + hex(random.randrange(151,250)).split('x')[1])
1595 t6 = threading.Thread(target = verify_flow, args = '02:00:00:00:00:08')
1596 t7 = threading.Thread(target = verify_flow, args = '02:00:00:00:00:' + hex(random.randrange(16,150)).split('x')[1])
1597 t8 = threading.Thread(target = verify_flow, args = '02:00:00:00:00:' + hex(random.randrange(151,250)).split('x')[1])
1598 t9 = threading.Thread(target = verify_flow, args = '03:00:00:00:00:'+ hex(random.randrange(16,175)).split('x')[1])
1599 t10 = threading.Thread(target = verify_flow, args = '03:00:00:00:00:eb')
ChetanGaonker720ea612016-06-21 17:54:25 -07001600
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001601 t1.start()
1602 t2.start()
1603 t3.start()
1604 t4.start()
1605 t5.start()
1606 t6.start()
1607 t7.start()
1608 t8.start()
1609 t9.start()
1610 t10.start()
1611
1612 t1.join()
1613 t2.join()
1614 t3.join()
1615 t4.join()
1616 t5.join()
1617 t6.join()
1618 t7.join()
1619 t8.join()
1620 t9.join()
1621 t10.join()
ChetanGaonker720ea612016-06-21 17:54:25 -07001622 if len(success_dir) != 10:
1623 self.success = False
1624
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001625 assert_equal(self.success, True)
1626
1627 @nottest
1628 def test_10k_flow_mac(self):
1629 egress = 1
1630 ingress = 2
1631 egress_mac = '00:00:00:00:01:00'
1632 ingress_mac = '00:00:00:00:00:00'
1633 success_dir = {}
1634
1635 for i in range(0,10000):
ChetanGaonker720ea612016-06-21 17:54:25 -07001636 ingress_mac = self.next_mac(ingress_mac)
1637 egress_mac = self.to_egress_mac(ingress_mac)
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001638
ChetanGaonker720ea612016-06-21 17:54:25 -07001639 flow = OnosFlowCtrl(deviceId = self.device_id,
1640 egressPort = egress,
1641 ingressPort = ingress,
1642 ethSrc = ingress_mac,
1643 ethDst = egress_mac)
1644 result = flow.addFlow()
1645 assert_equal(result, True)
1646 ##wait for flows to be added to ONOS
1647 time.sleep(1)
1648 log.info("%d flow added.",i+1)
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001649 self.success = True
1650 def verify_flow(*r):
1651 random_src = ''.join(r)
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001652 def mac_recv_task():
1653 def recv_cb(pkt):
1654 log.info('Pkt seen with ingress mac %s, egress mac %s' %(pkt.src, pkt.dst))
1655 success_dir[current_thread().name] = True
1656 sniff(count=2, timeout=5, lfilter = lambda p: p.src == random_src,
ChetanGaonker720ea612016-06-21 17:54:25 -07001657 prn = recv_cb, iface = self.port_map[egress])
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001658
1659 t = threading.Thread(target = mac_recv_task)
1660 t.start()
1661 pkt = Ether(src = random_src, dst = self.to_egress_mac(random_src))/IP()
1662 log.info('Sending packets to verify if flows are correct')
1663 sendp(pkt, count=50, iface = self.port_map[ingress])
1664 t.join()
1665
1666 t1 = threading.Thread(target = verify_flow, args = '00:00:00:00:00:01')
1667 t2 = threading.Thread(target = verify_flow, args = '01:00:00:00:00:' + hex(random.randrange(16,254)).split('x')[1])
1668 t3 = threading.Thread(target = verify_flow, args = '02:00:00:00:00:'+ hex(random.randrange(16,254)).split('x')[1])
1669 t4 = threading.Thread(target = verify_flow, args = '05:00:00:00:00:' + hex(random.randrange(16,254)).split('x')[1])
1670 t5 = threading.Thread(target = verify_flow, args = '07:00:00:00:00:' + hex(random.randrange(16,254)).split('x')[1])
1671 t6 = threading.Thread(target = verify_flow, args = hex(random.randrange(16,21)).split('x')[1] + ':00:00:00:00:08')
1672 t7 = threading.Thread(target = verify_flow, args = hex(random.randrange(17,21)).split('x')[1] +':00:00:00:00:' +
1673 hex(random.randrange(16,254)).split('x')[1])
1674
1675 t8 = threading.Thread(target = verify_flow, args = hex(random.randrange(22,30)).split('x')[1] +':00:00:00:00:' +
1676 hex(random.randrange(16,254)).split('x')[1])
1677
1678 t9 = threading.Thread(target = verify_flow, args = hex(random.randrange(31,38)).split('x')[1] +':00:00:00:00:' +
1679 hex(random.randrange(16,254)).split('x')[1])
1680
1681 t10 = threading.Thread(target = verify_flow, args = '27:00:00:00:00:37')
1682
1683 t1.start()
1684 t2.start()
1685 t3.start()
1686 t4.start()
1687 t5.start()
1688 t6.start()
1689 t7.start()
1690 t8.start()
1691 t9.start()
1692 t10.start()
1693
1694 t1.join()
1695 t2.join()
1696 t3.join()
1697 t4.join()
1698 t5.join()
1699 t6.join()
1700 t7.join()
1701 t8.join()
1702 t9.join()
1703 t10.join()
ChetanGaonker720ea612016-06-21 17:54:25 -07001704 if len(success_dir) != 10:
1705 self.success = False
1706
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001707 assert_equal(self.success, True)
1708
1709 @nottest
1710 def test_100k_flow_mac(self):
1711 egress = 1
1712 ingress = 2
1713 egress_mac = '00:00:00:00:01:00'
1714 ingress_mac = '00:00:00:00:00:00'
1715 success_dir = {}
1716
1717 for i in range(0,100000):
1718 ingress_mac = self.next_mac(ingress_mac)
1719 egress_mac = self.to_egress_mac(ingress_mac)
1720
1721 flow = OnosFlowCtrl(deviceId = self.device_id,
1722 egressPort = egress,
1723 ingressPort = ingress,
1724 ethSrc = ingress_mac,
1725 ethDst = egress_mac)
1726 result = flow.addFlow()
1727 assert_equal(result, True)
1728 ##wait for flows to be added to ONOS
1729 time.sleep(1)
1730 log.info("%d flow added.",i+1)
1731 self.success = True
1732
1733 def verify_flow(*r):
1734 random_src = ''.join(r)
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001735 def mac_recv_task():
1736 def recv_cb(pkt):
1737 log.info('Pkt seen with ingress mac %s, egress mac %s' %(pkt.src, pkt.dst))
1738 success_dir[current_thread().name] = True
1739 sniff(count=2, timeout=5, lfilter = lambda p: p.src == random_src,
ChetanGaonker720ea612016-06-21 17:54:25 -07001740 prn = recv_cb, iface = self.port_map[egress])
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001741
1742 t = threading.Thread(target = mac_recv_task)
1743 t.start()
1744 pkt = Ether(src = random_src, dst = self.to_egress_mac(random_src))/IP()
1745 log.info('Sending packets to verify if flows are correct')
1746 sendp(pkt, count=50, iface = self.port_map[ingress])
1747 t.join()
1748
1749 t1 = threading.Thread(target = verify_flow, args = '00:00:00:00:00:01')
1750 t2 = threading.Thread(target = verify_flow, args = '01:00:00:00:00:' + hex(random.randrange(16,254)).split('x')[1])
1751 t3 = threading.Thread(target = verify_flow, args = '02:00:00:00:00:'+ hex(random.randrange(16,254)).split('x')[1])
1752 t4 = threading.Thread(target = verify_flow, args = '05:00:00:00:00:' + hex(random.randrange(16,254)).split('x')[1])
1753 t5 = threading.Thread(target = verify_flow, args = '07:00:00:00:00:' + hex(random.randrange(16,254)).split('x')[1])
1754 t6 = threading.Thread(target = verify_flow, args = hex(random.randrange(16,41)).split('x')[1] + ':00:00:00:00:08')
1755 t7 = threading.Thread(target = verify_flow, args = hex(random.randrange(42,72)).split('x')[1] +':00:00:00:00:' +
1756 hex(random.randrange(16,254)).split('x')[1])
1757
1758 t8 = threading.Thread(target = verify_flow, args = hex(random.randrange(73,100)).split('x')[1] +':00:00:00:00:' +
1759 hex(random.randrange(16,254)).split('x')[1])
1760
1761 t9 = threading.Thread(target = verify_flow, args = hex(random.randrange(101,136)).split('x')[1] +':00:00:00:00:' +
1762 hex(random.randrange(16,254)).split('x')[1])
1763
1764 t10 = threading.Thread(target = verify_flow, args = '89:01:00:00:00:28')
1765
1766 t1.start()
1767 t2.start()
1768 t3.start()
1769 t4.start()
1770 t5.start()
1771 t6.start()
1772 t7.start()
1773 t8.start()
1774 t9.start()
1775 t10.start()
1776
1777 t1.join()
1778 t2.join()
1779 t3.join()
1780 t4.join()
1781 t5.join()
1782 t6.join()
1783 t7.join()
1784 t8.join()
1785 t9.join()
1786 t10.join()
ChetanGaonker720ea612016-06-21 17:54:25 -07001787 if len(success_dir) != 10:
1788 self.success = False
1789
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001790 assert_equal(self.success, True)
1791
1792 @nottest
1793 def test_1000k_flow_mac(self):
1794 egress = 1
1795 ingress = 2
1796 egress_mac = '00:00:00:00:01:00'
1797 ingress_mac = '00:00:00:00:00:00'
1798 success_dir = {}
1799
1800 for i in range(0,1000000):
1801 ingress_mac = self.next_mac(ingress_mac)
1802 egress_mac = self.to_egress_mac(ingress_mac)
1803
1804 flow = OnosFlowCtrl(deviceId = self.device_id,
1805 egressPort = egress,
1806 ingressPort = ingress,
1807 ethSrc = ingress_mac,
1808 ethDst = egress_mac)
1809 result = flow.addFlow()
1810 assert_equal(result, True)
1811 ##wait for flows to be added to ONOS
1812 time.sleep(1)
1813 log.info("%d flow added.",i+1)
1814 self.success = True
1815
1816 def verify_flow(*r):
1817 random_src = ''.join(r)
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001818 def mac_recv_task():
ChetanGaonker720ea612016-06-21 17:54:25 -07001819 def recv_cb(pkt):
1820 log.info('Pkt seen with ingress mac %s, egress mac %s' %(pkt.src, pkt.dst))
1821 success_dir[current_thread().name] = True
1822 sniff(count=2, timeout=5, lfilter = lambda p: p.src == random_src,
1823 prn = recv_cb, iface = self.port_map[egress])
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001824
1825 t = threading.Thread(target = mac_recv_task)
1826 t.start()
1827 pkt = Ether(src = random_src, dst = egress_mac)/IP()
1828 log.info('Sending packets to verify if flows are correct')
1829 sendp(pkt, count=50, iface = self.port_map[ingress])
1830 t.join()
1831
1832 t1 = threading.Thread(target = verify_flow, args = '00:00:00:00:00:01')
1833 t2 = threading.Thread(target = verify_flow, args = '01:00:00:00:00:' + hex(random.randrange(16,254)).split('x')[1])
1834 t3 = threading.Thread(target = verify_flow, args = '02:00:00:00:00:'+ hex(random.randrange(16,254)).split('x')[1])
1835 t4 = threading.Thread(target = verify_flow, args = '05:00:00:00:00:' + hex(random.randrange(16,254)).split('x')[1])
1836 t5 = threading.Thread(target = verify_flow, args = '07:00:00:00:00:' + hex(random.randrange(16,254)).split('x')[1])
1837 t6 = threading.Thread(target = verify_flow, args = hex(random.randrange(16,21)).split('x')[1] + ':00:00:00:00:08')
1838 t7 = threading.Thread(target = verify_flow, args = hex(random.randrange(22,50)).split('x')[1] +':00:00:00:00:' +
1839 hex(random.randrange(16,254)).split('x')[1])
1840
1841 t8 = threading.Thread(target = verify_flow, args = hex(random.randrange(51,75)).split('x')[1] +':00:00:00:00:' +
1842 hex(random.randrange(16,254)).split('x')[1])
1843
1844 t9 = threading.Thread(target = verify_flow, args = hex(random.randrange(76,95)).split('x')[1] +':00:00:00:00:' +
1845 hex(random.randrange(16,254)).split('x')[1])
1846
1847 t10 = threading.Thread(target = verify_flow, args = '60:0f:00:00:00:91')
1848
1849 t1.start()
1850 t2.start()
1851 t3.start()
1852 t4.start()
1853 t5.start()
1854 t6.start()
1855 t7.start()
1856 t8.start()
1857 t9.start()
1858 t10.start()
1859
1860 t1.join()
1861 t2.join()
1862 t3.join()
1863 t4.join()
1864 t5.join()
1865 t6.join()
1866 t7.join()
1867 t8.join()
1868 t9.join()
1869 t10.join()
ChetanGaonker720ea612016-06-21 17:54:25 -07001870 if len(success_dir) != 10:
1871 self.success = False
1872
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001873 assert_equal(self.success, True)
1874
ChetanGaonkerd376b902016-06-14 11:50:28 -07001875 def test_rate_100_flow_mac(self):
1876 egress = 1
1877 ingress = 2
1878 egress_mac = '00:00:00:00:01:00'
1879 ingress_mac = '00:00:00:00:00:00'
1880 flows_added = 0
1881 stats_dir = collections.OrderedDict()
1882 running_time = 0
1883
1884
1885 for i in range(1,4):
1886 start_time = time.time()
1887 for j in range(0,100):
1888 ingress_mac = self.next_mac(ingress_mac)
1889 egress_mac = self.to_egress_mac(ingress_mac)
1890
1891 flow = OnosFlowCtrl(deviceId = self.device_id,
1892 egressPort = egress,
1893 ingressPort = ingress,
1894 ethSrc = ingress_mac,
1895 ethDst = egress_mac)
1896 result = flow.addFlow()
1897 assert_equal(result, True)
1898 flows_added += 1
1899 ##wait for flows to be added to ONOS
ChetanGaonker720ea612016-06-21 17:54:25 -07001900 time.sleep(1)
ChetanGaonkerd376b902016-06-14 11:50:28 -07001901 log.info("%d flow added.",j+1)
1902 end_time = time.time()
1903 stats_dir['run '+str(i)] = round((end_time - start_time),2)
1904 for t in stats_dir.items():
ChetanGaonker720ea612016-06-21 17:54:25 -07001905 log.info("----------------------------------------------")
1906 log.info("Statics for %s",t[0])
1907 log.info("----------------------------------------------")
1908 log.info("No. of flows added Running Time ")
1909 log.info(" %d %s " %(100, t[1]))
1910 running_time += float(t[1])
ChetanGaonkerd376b902016-06-14 11:50:28 -07001911
1912 log.info("-------------------------------------------------------------------------------------------------------")
1913 log.info("Final Statics")
1914 log.info("-------------------------------------------------------------------------------------------------------")
1915 log.info("Total No. of flows added Total Running Time Average no. of flows per second ")
1916 log.info(" %d %s second %d "
1917 %(flows_added, running_time, round(flows_added/running_time,0)))
1918 log.info("-------------------------------------------------------------------------------------------------------")
1919
1920
1921
1922 def test_rate_500_flow_mac(self):
1923 egress = 1
1924 ingress = 2
1925 egress_mac = '00:00:00:00:01:00'
1926 ingress_mac = '00:00:00:00:00:00'
1927 flows_added = 0
1928 stats_dir = collections.OrderedDict()
1929 running_time = 0
1930
1931
1932 for i in range(1,4):
1933 start_time = time.time()
1934 for j in range(0,500):
1935 ingress_mac = self.next_mac(ingress_mac)
1936 egress_mac = self.to_egress_mac(ingress_mac)
1937
1938 flow = OnosFlowCtrl(deviceId = self.device_id,
1939 egressPort = egress,
1940 ingressPort = ingress,
1941 ethSrc = ingress_mac,
1942 ethDst = egress_mac)
1943 result = flow.addFlow()
1944 assert_equal(result, True)
1945 flows_added += 1
1946 ##wait for flows to be added to ONOS
ChetanGaonker720ea612016-06-21 17:54:25 -07001947 time.sleep(1)
ChetanGaonkerd376b902016-06-14 11:50:28 -07001948 log.info("%d flow added.",j+1)
1949 end_time = time.time()
1950 stats_dir['run '+str(i)] = round((end_time - start_time),2)
1951 for t in stats_dir.items():
1952 log.info("----------------------------------------------")
1953 log.info("Statics for %s",t[0])
1954 log.info("----------------------------------------------")
1955 log.info("No. of flows added Running Time ")
1956 log.info(" %d %s " %(500, t[1]))
1957 running_time += float(t[1])
1958
1959 log.info("-------------------------------------------------------------------------------------------------------")
1960 log.info("Final Statics")
1961 log.info("-------------------------------------------------------------------------------------------------------")
1962 log.info("Total No. of flows added Total Running Time Average no. of flows per second ")
1963 log.info(" %d %s second %d "
1964 %(flows_added, running_time, round(flows_added/running_time,0)))
1965 log.info("-------------------------------------------------------------------------------------------------------")
1966
1967 def test_rate_1k_flow_mac(self):
1968 egress = 1
1969 ingress = 2
1970 egress_mac = '00:00:00:00:01:00'
1971 ingress_mac = '00:00:00:00:00:00'
1972 flows_added = 0
1973 stats_dir = collections.OrderedDict()
1974 running_time = 0
1975
1976
1977 for i in range(1,4):
1978 start_time = time.time()
1979 for j in range(0,1000):
1980 ingress_mac = self.next_mac(ingress_mac)
1981 egress_mac = self.to_egress_mac(ingress_mac)
1982
1983 flow = OnosFlowCtrl(deviceId = self.device_id,
1984 egressPort = egress,
1985 ingressPort = ingress,
1986 ethSrc = ingress_mac,
1987 ethDst = egress_mac)
1988 result = flow.addFlow()
1989 assert_equal(result, True)
1990 flows_added += 1
ChetanGaonker720ea612016-06-21 17:54:25 -07001991 ##wait for flows to be added to ONOS
1992 time.sleep(1)
ChetanGaonkerd376b902016-06-14 11:50:28 -07001993 log.info("%d flow added.",j+1)
1994 end_time = time.time()
1995 stats_dir['run '+str(i)] = round((end_time - start_time),2)
1996 for t in stats_dir.items():
1997 log.info("----------------------------------------------")
1998 log.info("Statics for %s",t[0])
1999 log.info("----------------------------------------------")
2000 log.info("No. of flows added Running Time ")
2001 log.info(" %d %s " %(1000, t[1]))
2002 running_time += float(t[1])
2003
2004 log.info("-------------------------------------------------------------------------------------------------------")
2005 log.info("Final Statics")
2006 log.info("-------------------------------------------------------------------------------------------------------")
2007 log.info("Total No. of flows added Total Running Time Average no. of flows per second ")
2008 log.info(" %d %s second %d "
2009 %(flows_added, running_time, round(flows_added/running_time,0)))
2010 log.info("-------------------------------------------------------------------------------------------------------")
2011
2012
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002013 def test_500_flow_ip(self):
2014 egress = 1
2015 ingress = 2
2016 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '182.0.0.0' }
2017 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.0.0.0' }
ChetanGaonker720ea612016-06-21 17:54:25 -07002018 success_dir = {}
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002019
2020 for i in range(0,500):
2021 ingress_map['ip'] = self.next_ip(ingress_map['ip'])
2022 assert_not_equal(ingress_map['ip'], None)
2023 egress_map['ip'] = self.to_egress_ip(ingress_map['ip'])
2024
2025 flow = OnosFlowCtrl(deviceId = self.device_id,
2026 egressPort = egress,
2027 ingressPort = ingress,
2028 ethType = '0x0800',
2029 ipSrc = ('IPV4_SRC', ingress_map['ip']+'/8'),
2030 ipDst = ('IPV4_DST', egress_map['ip']+'/8')
2031 )
2032 result = flow.addFlow()
2033 assert_equal(result, True)
2034 ##wait for flows to be added to ONOS
2035 time.sleep(1)
2036 log.info("%d flow added.",i+1)
ChetanGaonker720ea612016-06-21 17:54:25 -07002037 self.success = True
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002038
ChetanGaonker720ea612016-06-21 17:54:25 -07002039 def verify_flow(*r):
2040 random_src = ''.join(r)
2041 random_dst = self.to_egress_ip(random_src)
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002042
ChetanGaonker720ea612016-06-21 17:54:25 -07002043 def mac_recv_task():
2044 def recv_cb(pkt):
2045 log.info('Pkt seen with ingress ip %s, egress ip %s' %(pkt[IP].src, pkt[IP].dst))
2046 success_dir[current_thread().name] = True
2047
2048 sniff(count=2, timeout=5, lfilter = lambda p: IP in p and p[IP].dst == random_dst and p[IP].src == random_src
2049 ,prn = recv_cb, iface = self.port_map[egress])
2050
2051 t = threading.Thread(target = mac_recv_task)
2052 t.start()
2053 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
2054 L3 = IP(src = random_src, dst = random_dst)
2055 pkt = L2/L3
2056 log.info('Sending packets to verify if flows are correct')
2057 sendp(pkt, count=50, iface = self.port_map[ingress])
2058 t.join()
2059
2060 t1 = threading.Thread(target = verify_flow, args = '192.0.0.1')
2061 t2 = threading.Thread(target = verify_flow, args = '192.0.0.' + str(random.randrange(10,100,1)))
2062 t3 = threading.Thread(target = verify_flow, args = '192.0.0.' + str(random.randrange(101,255,1)))
2063 t4 = threading.Thread(target = verify_flow, args = '192.0.1.' + str(random.randrange(1,235,1)))
2064 t5 = threading.Thread(target = verify_flow, args = '192.0.1.244')
2065 t1.start()
2066 t2.start()
2067 t3.start()
2068 t4.start()
2069 t5.start()
2070
2071 t1.join()
2072 t2.join()
2073 t3.join()
2074 t4.join()
2075 t5.join()
2076
2077 if len(success_dir) < 5 or len(success_dir) > 5:
2078 self.success = False
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002079 assert_equal(self.success, True)
2080
ChetanGaonker720ea612016-06-21 17:54:25 -07002081
2082 @nottest
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002083 def test_1k_flow_ip(self):
2084 egress = 1
2085 ingress = 2
2086 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '182.0.0.0' }
2087 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.0.0.0' }
ChetanGaonker720ea612016-06-21 17:54:25 -07002088 success_dir ={}
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002089
2090 for i in range(0,1000):
2091 ingress_map['ip'] = self.next_ip(ingress_map['ip'])
2092 assert_not_equal(ingress_map['ip'], None)
2093 egress_map['ip'] = self.to_egress_ip(ingress_map['ip'])
2094
2095 flow = OnosFlowCtrl(deviceId = self.device_id,
2096 egressPort = egress,
2097 ingressPort = ingress,
2098 ethType = '0x0800',
2099 ipSrc = ('IPV4_SRC', ingress_map['ip']+'/8'),
2100 ipDst = ('IPV4_DST', egress_map['ip']+'/8')
2101 )
2102 result = flow.addFlow()
2103 assert_equal(result, True)
2104 ##wait for flows to be added to ONOS
2105 time.sleep(1)
2106 log.info("%d flow added.",i+1)
ChetanGaonker720ea612016-06-21 17:54:25 -07002107 self.success = True
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002108
ChetanGaonker720ea612016-06-21 17:54:25 -07002109 def verify_flow(*r):
2110 random_src = ''.join(r)
2111 random_dst = self.to_egress_ip(random_src)
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002112
ChetanGaonker720ea612016-06-21 17:54:25 -07002113 def mac_recv_task():
2114 def recv_cb(pkt):
2115 log.info('Pkt seen with ingress ip %s, egress ip %s' %(pkt[IP].src, pkt[IP].dst))
2116 success_dir[current_thread().name] = True
2117
2118 sniff(count=2, timeout=5, lfilter = lambda p: IP in p and p[IP].dst == random_dst and p[IP].src == random_src
2119 ,prn = recv_cb, iface = self.port_map[egress])
2120
2121 t = threading.Thread(target = mac_recv_task)
2122 t.start()
2123 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
2124 L3 = IP(src = random_src, dst = random_dst)
2125 pkt = L2/L3
2126 log.info('Sending packets to verify if flows are correct')
2127 sendp(pkt, count=50, iface = self.port_map[ingress])
2128 t.join()
2129
2130 t1 = threading.Thread(target = verify_flow, args = '192.0.0.1')
2131 t2 = threading.Thread(target = verify_flow, args = '192.0.0.' + str(random.randrange(10,255,1)))
2132 t3 = threading.Thread(target = verify_flow, args = '192.0.1.' + str(random.randrange(1,100,1)))
2133 t4 = threading.Thread(target = verify_flow, args = '192.0.1.' + str(random.randrange(101,255,1)))
2134 t5 = threading.Thread(target = verify_flow, args = '192.0.2.' + str(random.randrange(1,100,1)))
2135 t6 = threading.Thread(target = verify_flow, args = '192.0.2.' + str(random.randrange(101,255,1)))
2136 t7 = threading.Thread(target = verify_flow, args = '192.0.3.' + str(random.randrange(1,100,1)))
2137 t8 = threading.Thread(target = verify_flow, args = '192.0.3.' + str(random.randrange(101,200,1)))
2138 t9 = threading.Thread(target = verify_flow, args = '192.0.'+ str(random.randrange(0,3,1)) + '.' +
2139 str(random.randrange(1,255,1)))
2140 t10 = threading.Thread(target = verify_flow, args = '192.0.3.232')
2141
2142 t1.start()
2143 t2.start()
2144 t3.start()
2145 t4.start()
2146 t5.start()
2147 t6.start()
2148 t7.start()
2149 t8.start()
2150 t9.start()
2151 t10.start()
2152
2153 t1.join()
2154 t2.join()
2155 t3.join()
2156 t4.join()
2157 t5.join()
2158 t6.join()
2159 t7.join()
2160 t8.join()
2161 t9.join()
2162 t10.join()
2163
2164 if len(success_dir) != 10:
2165 self.success = False
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002166 assert_equal(self.success, True)
2167
2168 @nottest
2169 def test_10k_flow_ip(self):
2170 egress = 1
2171 ingress = 2
2172 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '182.0.0.0' }
2173 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.0.0.0' }
ChetanGaonker720ea612016-06-21 17:54:25 -07002174 success_dir = {}
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002175
2176 for i in range(0,10000):
2177 ingress_map['ip'] = self.next_ip(ingress_map['ip'])
2178 assert_not_equal(ingress_map['ip'], None)
2179 egress_map['ip'] = self.to_egress_ip(ingress_map['ip'])
2180
2181 flow = OnosFlowCtrl(deviceId = self.device_id,
2182 egressPort = egress,
2183 ingressPort = ingress,
2184 ethType = '0x0800',
2185 ipSrc = ('IPV4_SRC', ingress_map['ip']+'/8'),
2186 ipDst = ('IPV4_DST', egress_map['ip']+'/8')
2187 )
2188 result = flow.addFlow()
2189 assert_equal(result, True)
2190 ##wait for flows to be added to ONOS
2191 time.sleep(1)
2192 log.info("%d flow added.",i+1)
ChetanGaonker720ea612016-06-21 17:54:25 -07002193 self.success = True
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002194
ChetanGaonker720ea612016-06-21 17:54:25 -07002195 def verify_flow(*r):
2196 random_src = ''.join(r)
2197 random_dst = self.to_egress_ip(random_src)
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002198
ChetanGaonker720ea612016-06-21 17:54:25 -07002199 def mac_recv_task():
2200 def recv_cb(pkt):
2201 log.info('Pkt seen with ingress ip %s, egress ip %s' %(pkt[IP].src, pkt[IP].dst))
2202 success_dir[current_thread().name] = True
2203 sniff(count=2, timeout=5, lfilter = lambda p: IP in p and p[IP].dst == random_dst and p[IP].src == random_src
2204 ,prn = recv_cb, iface = self.port_map[egress])
2205
2206 t = threading.Thread(target = mac_recv_task)
2207 t.start()
2208 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
2209 L3 = IP(src = random_src, dst = random_dst)
2210 pkt = L2/L3
2211 log.info('Sending packets to verify if flows are correct')
2212 sendp(pkt, count=50, iface = self.port_map[ingress])
2213 t.join()
2214
2215 t1 = threading.Thread(target = verify_flow, args = '192.0.0.1')
2216 t2 = threading.Thread(target = verify_flow, args = '192.0.0.' + str(random.randrange(1,255,1)))
2217 t3 = threading.Thread(target = verify_flow, args = '192.0.5.' + str(random.randrange(1,255,1)))
2218 t4 = threading.Thread(target = verify_flow, args = '192.0.10.' + str(random.randrange(1,255,1)))
2219 t5 = threading.Thread(target = verify_flow, args = '192.0.15.' + str(random.randrange(1,255,1)))
2220 t6 = threading.Thread(target = verify_flow, args = '192.0.20.' + str(random.randrange(1,255,1)))
2221 t7 = threading.Thread(target = verify_flow, args = '192.0.25.' + str(random.randrange(1,255,1)))
2222 t8 = threading.Thread(target = verify_flow, args = '192.0.30.' + str(random.randrange(1,255,1)))
2223 t9 = threading.Thread(target = verify_flow, args = '192.0.'+ str(random.randrange(0,39,1)) + '.' +
2224 str(random.randrange(1,255,1)))
2225 t10 = threading.Thread(target = verify_flow, args = '192.0.39.16')
2226
2227 t1.start()
2228 t2.start()
2229 t3.start()
2230 t4.start()
2231 t5.start()
2232 t6.start()
2233 t7.start()
2234 t8.start()
2235 t9.start()
2236 t10.start()
2237
2238 t1.join()
2239 t2.join()
2240 t3.join()
2241 t4.join()
2242 t5.join()
2243 t6.join()
2244 t7.join()
2245 t8.join()
2246 t9.join()
2247 t10.join()
2248
2249 if len(success_dir) != 10:
2250 self.success = False
2251
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002252 assert_equal(self.success, True)
2253
2254 @nottest
2255 def test_100k_flow_ip(self):
2256 egress = 1
2257 ingress = 2
2258 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '182.0.0.0' }
2259 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.0.0.0' }
ChetanGaonker720ea612016-06-21 17:54:25 -07002260 success_dir = {}
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002261
2262 for i in range(0,100000):
2263 ingress_map['ip'] = self.next_ip(ingress_map['ip'])
2264 assert_not_equal(ingress_map['ip'], None)
2265 egress_map['ip'] = self.to_egress_ip(ingress_map['ip'])
2266
2267 flow = OnosFlowCtrl(deviceId = self.device_id,
2268 egressPort = egress,
2269 ingressPort = ingress,
2270 ethType = '0x0800',
2271 ipSrc = ('IPV4_SRC', ingress_map['ip']+'/8'),
2272 ipDst = ('IPV4_DST', egress_map['ip']+'/8')
2273 )
2274 result = flow.addFlow()
2275 assert_equal(result, True)
2276 ##wait for flows to be added to ONOS
2277 time.sleep(1)
2278 log.info("%d flow added.",i+1)
ChetanGaonker720ea612016-06-21 17:54:25 -07002279 self.success = True
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002280
ChetanGaonker720ea612016-06-21 17:54:25 -07002281 def verify_flow(*r):
2282 random_src = ''.join(r)
2283 random_dst = self.to_egress_ip(random_src)
2284 def mac_recv_task():
2285 def recv_cb(pkt):
2286 log.info('Pkt seen with ingress ip %s, egress ip %s' %(pkt[IP].src, pkt[IP].dst))
2287 success_dir[current_thread().name] = True
2288 sniff(count=2, timeout=5, lfilter = lambda p: IP in p and p[IP].dst == random_dst and p[IP].src == random_src
2289 ,prn = recv_cb, iface = self.port_map[egress])
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002290
ChetanGaonker720ea612016-06-21 17:54:25 -07002291 t = threading.Thread(target = mac_recv_task)
2292 t.start()
2293 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
2294 L3 = IP(src = random_src, dst = random_dst)
2295 pkt = L2/L3
2296 log.info('Sending packets to verify if flows are correct')
2297 sendp(pkt, count=50, iface = self.port_map[ingress])
2298 t.join()
2299
2300 t1 = threading.Thread(target = verify_flow, args = '192.0.0.1')
2301 t2 = threading.Thread(target = verify_flow, args = '192.0.0.' + str(random.randrange(1,255,1)))
2302 t3 = threading.Thread(target = verify_flow, args = '192.0.50.' + str(random.randrange(1,255,1)))
2303 t4 = threading.Thread(target = verify_flow, args = '192.0.100.' + str(random.randrange(1,255,1)))
2304 t5 = threading.Thread(target = verify_flow, args = '192.0.150.' + str(random.randrange(1,255,1)))
2305 t6 = threading.Thread(target = verify_flow, args = '192.0.200.' + str(random.randrange(1,255,1)))
2306 t7 = threading.Thread(target = verify_flow, args = '192.0.250.' + str(random.randrange(1,255,1)))
2307 t8 = threading.Thread(target = verify_flow, args = '192.1.'+str(random.randrange(1,75,1)) + '.'
2308 + str(random.randrange(1,255,1)))
2309 t9 = threading.Thread(target = verify_flow, args = '192.1.'+str(random.randrange(76,134,1)) + '.'
2310 + str(random.randrange(1,255,1)))
2311 t10 = threading.Thread(target = verify_flow, args = '192.1.134.160')
2312
2313 t1.start()
2314 t2.start()
2315 t3.start()
2316 t4.start()
2317 t5.start()
2318 t6.start()
2319 t7.start()
2320 t8.start()
2321 t9.start()
2322 t10.start()
2323
2324 t1.join()
2325 t2.join()
2326 t3.join()
2327 t4.join()
2328 t5.join()
2329 t6.join()
2330 t7.join()
2331 t8.join()
2332 t9.join()
2333 t10.join()
2334
2335 if len(success_dir) != 10:
2336 self.success = False
2337
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002338 assert_equal(self.success, True)
2339
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002340 @nottest
2341 def test_1000k_flow_ip(self):
2342 egress = 1
2343 ingress = 2
2344 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '182.0.0.0' }
2345 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.0.0.0' }
ChetanGaonker720ea612016-06-21 17:54:25 -07002346 success_dir = {}
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002347
2348 for i in range(0,1000000):
2349 ingress_map['ip'] = self.next_ip(ingress_map['ip'])
2350 assert_not_equal(ingress_map['ip'], None)
2351 egress_map['ip'] = self.to_egress_ip(ingress_map['ip'])
2352
2353 flow = OnosFlowCtrl(deviceId = self.device_id,
2354 egressPort = egress,
2355 ingressPort = ingress,
2356 ethType = '0x0800',
2357 ipSrc = ('IPV4_SRC', ingress_map['ip']+'/8'),
2358 ipDst = ('IPV4_DST', egress_map['ip']+'/8')
2359 )
2360 result = flow.addFlow()
2361 assert_equal(result, True)
2362 ##wait for flows to be added to ONOS
2363 time.sleep(1)
2364 log.info("%d flow added.",i+1)
ChetanGaonker720ea612016-06-21 17:54:25 -07002365 self.success = True
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002366
ChetanGaonker720ea612016-06-21 17:54:25 -07002367 def verify_flow(*r):
2368 random_src = ''.join(r)
2369 random_dst = self.to_egress_ip(random_src)
2370 def mac_recv_task():
2371 def recv_cb(pkt):
2372 log.info('Pkt seen with ingress ip %s, egress ip %s' %(pkt[IP].src, pkt[IP].dst))
2373 success_dir[current_thread().name] = True
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002374
ChetanGaonker720ea612016-06-21 17:54:25 -07002375 sniff(count=2, timeout=5, lfilter = lambda p: IP in p and p[IP].dst == random_dst and p[IP].src == random_src
2376 ,prn = recv_cb, iface = self.port_map[egress])
2377
2378 t = threading.Thread(target = mac_recv_task)
2379 t.start()
2380 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
2381 L3 = IP(src = random_src, dst = random_dst)
2382 pkt = L2/L3
2383 log.info('Sending packets to verify if flows are correct')
2384 sendp(pkt, count=50, iface = self.port_map[ingress])
2385 t.join()
2386
2387 t1 = threading.Thread(target = verify_flow, args = '192.0.0.1')
2388 t2 = threading.Thread(target = verify_flow, args = '192.0.50.' + str(random.randrange(1,255,1)))
2389 t3 = threading.Thread(target = verify_flow, args = '192.0.100.' + str(random.randrange(1,255,1)))
2390 t4 = threading.Thread(target = verify_flow, args = '192.0.150.' + str(random.randrange(1,255,1)))
2391 t5 = threading.Thread(target = verify_flow, args = '192.0.200.' + str(random.randrange(1,255,1)))
2392 t6 = threading.Thread(target = verify_flow, args = '192.0.250.' + str(random.randrange(1,255,1)))
2393 t7 = threading.Thread(target = verify_flow, args = '192.0.250.' + str(random.randrange(1,255,1)))
2394 t8 = threading.Thread(target = verify_flow, args = '192.1.'+str(random.randrange(1,150,1)) + '.'
2395 + str(random.randrange(1,255,1)))
2396 t9 = threading.Thread(target = verify_flow, args = '192.1.'+str(random.randrange(152,255,1)) + '.'
2397 + str(random.randrange(1,255,1)))
2398 t10 = threading.Thread(target = verify_flow, args = '192.15.66.64')
2399
2400 t1.start()
2401 t2.start()
2402 t3.start()
2403 t4.start()
2404 t5.start()
2405 t6.start()
2406 t7.start()
2407 t8.start()
2408 t9.start()
2409 t10.start()
2410
2411 t1.join()
2412 t2.join()
2413 t3.join()
2414 t4.join()
2415 t5.join()
2416 t6.join()
2417 t7.join()
2418 t8.join()
2419 t9.join()
2420 t10.join()
2421
2422 if len(success_dir) != 10:
2423 self.success = False
2424
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002425 assert_equal(self.success, True)
2426
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002427 def test_500_flow_tcp_port(self):
2428 egress = 1
2429 ingress = 2
2430 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '192.168.30.1', 'tcp_port': 3100 }
2431 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.168.40.1', 'tcp_port': 1100 }
ChetanGaonker720ea612016-06-21 17:54:25 -07002432 success_dir = {}
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002433
2434 for i in range(0,500):
2435 ingress_map['tcp_port'] += 1
2436 egress_map['tcp_port'] += 1
2437
2438 flow = OnosFlowCtrl(deviceId = self.device_id,
2439 egressPort = egress,
2440 ingressPort = ingress,
2441 tcpSrc = ingress_map['tcp_port'],
2442 tcpDst = egress_map['tcp_port']
2443 )
2444
2445 result = flow.addFlow()
2446 assert_equal(result, True)
2447 ##wait for flows to be added to ONOS
2448 time.sleep(1)
2449 log.info("%d Flow added",i+1)
ChetanGaonker720ea612016-06-21 17:54:25 -07002450 self.success = True
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002451
ChetanGaonker720ea612016-06-21 17:54:25 -07002452 def verify_flow(*r):
2453 random_sport = int(''.join(r))
2454 random_dport = random_sport + 2000
2455 def mac_recv_task():
2456 def recv_cb(pkt):
2457 log.info('Pkt seen with ingress TCP port %s, egress TCP port %s' %(pkt[TCP].sport, pkt[TCP].dport))
2458 success_dir[current_thread().name] = True
2459 sniff(count=2, timeout=5,
2460 lfilter = lambda p: TCP in p and p[TCP].dport == random_dport and p[TCP].sport == random_sport ,prn = recv_cb, iface = self.port_map[egress])
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002461
ChetanGaonker720ea612016-06-21 17:54:25 -07002462 t = threading.Thread(target = mac_recv_task)
2463 t.start()
2464 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
2465 L3 = IP(src = ingress_map['ip'], dst = egress_map['ip'])
2466 L4 = TCP(sport = random_sport, dport = random_dport)
2467 pkt = L2/L3/L4
2468 log.info('Sending packets to verify if flows are correct')
2469 sendp(pkt, count=50, iface = self.port_map[ingress])
2470 t.join()
2471 t1 = threading.Thread(target = verify_flow, args = str(1101))
2472 t2 = threading.Thread(target = verify_flow, args = str(random.randrange(1110,1250,1)))
2473 t3 = threading.Thread(target = verify_flow, args = str(random.randrange(1251,1400,1)))
2474 t4 = threading.Thread(target = verify_flow, args = str(random.randrange(1401,1590,1)))
2475 t5 = threading.Thread(target = verify_flow, args = str(1600))
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002476
ChetanGaonker720ea612016-06-21 17:54:25 -07002477 t1.start()
2478 t2.start()
2479 t3.start()
2480 t4.start()
2481 t5.start()
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002482
ChetanGaonker720ea612016-06-21 17:54:25 -07002483 t1.join()
2484 t2.join()
2485 t3.join()
2486 t4.join()
2487 t5.join()
2488
2489 if len(success_dir) != 5:
2490 self.success = False
2491
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002492 assert_equal(self.success, True)
2493
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002494 def test_1k_flow_tcp_port(self):
2495 egress = 1
2496 ingress = 2
2497 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '192.168.30.1', 'tcp_port': 3100 }
2498 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.168.40.1', 'tcp_port': 1100 }
ChetanGaonker720ea612016-06-21 17:54:25 -07002499 success_dir = {}
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002500
2501 for i in range(0,1000):
2502 ingress_map['tcp_port'] += 1
2503 egress_map['tcp_port'] += 1
2504
2505 flow = OnosFlowCtrl(deviceId = self.device_id,
2506 egressPort = egress,
2507 ingressPort = ingress,
2508 tcpSrc = ingress_map['tcp_port'],
2509 tcpDst = egress_map['tcp_port']
2510 )
2511
2512 result = flow.addFlow()
2513 assert_equal(result, True)
2514 ##wait for flows to be added to ONOS
2515 time.sleep(1)
2516 log.info("%d flow added.",i+1)
2517
ChetanGaonker720ea612016-06-21 17:54:25 -07002518 self.success = True
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002519
ChetanGaonker720ea612016-06-21 17:54:25 -07002520 def verify_flow(*r):
2521 random_sport = int(''.join(r))
2522 random_dport = random_sport + 2000
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002523
ChetanGaonker720ea612016-06-21 17:54:25 -07002524 def mac_recv_task():
2525 def recv_cb(pkt):
2526 log.info('Pkt seen with ingress TCP port %s, egress TCP port %s' %(pkt[TCP].sport, pkt[TCP].dport))
2527 success_dir[current_thread().name] = True
2528 sniff(count=2, timeout=5,
2529 lfilter = lambda p: TCP in p and p[TCP].dport == random_dport and p[TCP].sport == random_sport ,prn = recv_cb, iface = self.port_map[egress])
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002530
ChetanGaonker720ea612016-06-21 17:54:25 -07002531 t = threading.Thread(target = mac_recv_task)
2532 t.start()
2533 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
2534 L3 = IP(src = ingress_map['ip'], dst = egress_map['ip'])
2535 L4 = TCP(sport = random_sport, dport = random_dport)
2536 pkt = L2/L3/L4
2537 log.info('Sending packets to verify if flows are correct')
2538 sendp(pkt, count=50, iface = self.port_map[ingress])
2539 t.join()
2540
2541 t1 = threading.Thread(target = verify_flow, args = str(1101))
2542 t2 = threading.Thread(target = verify_flow, args = str(random.randrange(1110,1350,1)))
2543 t3 = threading.Thread(target = verify_flow, args = str(random.randrange(1351,1500,1)))
2544 t4 = threading.Thread(target = verify_flow, args = str(random.randrange(1501,1700,1)))
2545 t5 = threading.Thread(target = verify_flow, args = str(random.randrange(1701,1900,1)))
2546 t6 = threading.Thread(target = verify_flow, args = str(random.randrange(1901,2000,1)))
2547 t7 = threading.Thread(target = verify_flow, args = str(random.randrange(2000,2050,1)))
2548 t8 = threading.Thread(target = verify_flow, args = str(random.randrange(2050,2080,1)))
2549 t9 = threading.Thread(target = verify_flow, args = str(random.randrange(1102,2100,1)))
2550 t10 = threading.Thread(target = verify_flow, args = str(2100))
2551
2552
2553 t1.start()
2554 t2.start()
2555 t3.start()
2556 t4.start()
2557 t5.start()
2558 t6.start()
2559 t7.start()
2560 t8.start()
2561 t9.start()
2562 t10.start()
2563
2564 t1.join()
2565 t2.join()
2566 t3.join()
2567 t4.join()
2568 t5.join()
2569 t6.join()
2570 t7.join()
2571 t8.join()
2572 t9.join()
2573 t10.join()
2574
2575 if len(success_dir) != 10:
2576 self.success = False
2577
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002578 assert_equal(self.success, True)
2579
2580 @nottest
2581 def test_10k_flow_tcp_port(self):
2582 egress = 1
2583 ingress = 2
2584 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '192.168.30.1', 'tcp_port': 31000 }
2585 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.168.40.1', 'tcp_port': 11000 }
ChetanGaonker720ea612016-06-21 17:54:25 -07002586 success_dir = {}
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002587
2588 for i in range(0,10000):
2589 ingress_map['tcp_port'] += 1
2590 egress_map['tcp_port'] += 1
2591
2592 flow = OnosFlowCtrl(deviceId = self.device_id,
2593 egressPort = egress,
2594 ingressPort = ingress,
2595 tcpSrc = ingress_map['tcp_port'],
2596 tcpDst = egress_map['tcp_port']
2597 )
2598
2599 result = flow.addFlow()
2600 assert_equal(result, True)
2601 ##wait for flows to be added to ONOS
2602 time.sleep(1)
2603 log.info("%d flow added.",i+1)
2604
ChetanGaonker720ea612016-06-21 17:54:25 -07002605 self.success = True
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002606
ChetanGaonker720ea612016-06-21 17:54:25 -07002607 def verify_flow(*r):
2608 random_sport = int(''.join(r))
2609 random_dport = random_sport + 20000
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002610
ChetanGaonker720ea612016-06-21 17:54:25 -07002611 def mac_recv_task():
2612 def recv_cb(pkt):
2613 log.info('Pkt seen with ingress TCP port %s, egress TCP port %s' %(pkt[TCP].sport, pkt[TCP].dport))
2614 success_dir[current_thread().name] = True
2615 sniff(count=2, timeout=5,
2616 lfilter = lambda p: TCP in p and p[TCP].dport == random_dport
2617 and p[TCP].sport == random_sport,prn = recv_cb, iface = self.port_map[egress])
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002618
ChetanGaonker720ea612016-06-21 17:54:25 -07002619 t = threading.Thread(target = mac_recv_task)
2620 t.start()
2621 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
2622 L3 = IP(src = ingress_map['ip'], dst = egress_map['ip'])
2623 L4 = TCP(sport = random_sport, dport = random_dport)
2624 pkt = L2/L3/L4
2625 log.info('Sending packets to verify if flows are correct')
2626 sendp(pkt, count=50, iface = self.port_map[ingress])
2627 t.join()
2628
2629 t1 = threading.Thread(target = verify_flow, args = str(11001))
2630 t2 = threading.Thread(target = verify_flow, args = str(random.randrange(11110,12501,1)))
2631 t3 = threading.Thread(target = verify_flow, args = str(random.randrange(12510,14001,1)))
2632 t4 = threading.Thread(target = verify_flow, args = str(random.randrange(14010,15900,1)))
2633 t5 = threading.Thread(target = verify_flow, args = str(random.randrange(16000,17000,1)))
2634 t6 = threading.Thread(target = verify_flow, args = str(random.randrange(17001,18000,1)))
2635 t7 = threading.Thread(target = verify_flow, args = str(random.randrange(18000,19000,1)))
2636 t8 = threading.Thread(target = verify_flow, args = str(random.randrange(19000,20980,1)))
2637 t9 = threading.Thread(target = verify_flow, args = str(random.randrange(11002,21000,1)))
2638 t10 = threading.Thread(target = verify_flow, args = str(21000))
2639
2640
2641 t1.start()
2642 t2.start()
2643 t3.start()
2644 t4.start()
2645 t5.start()
2646 t6.start()
2647 t7.start()
2648 t8.start()
2649 t9.start()
2650 t10.start()
2651
2652 t1.join()
2653 t2.join()
2654 t3.join()
2655 t4.join()
2656 t5.join()
2657 t6.join()
2658 t7.join()
2659 t8.join()
2660 t9.join()
2661 t10.join()
2662
2663 if len(success_dir) != 10:
2664 self.success = False
2665
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002666 assert_equal(self.success, True)
2667
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002668 def test_500_flow_udp_port(self):
2669 egress = 1
2670 ingress = 2
2671 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '192.168.30.1', 'udp_port': 3100 }
2672 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.168.40.1', 'udp_port': 1100 }
ChetanGaonker720ea612016-06-21 17:54:25 -07002673 success_dir = {}
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002674
2675 for i in range(0,500):
2676 ingress_map['udp_port'] += 1
2677 egress_map['udp_port'] += 1
2678
2679 flow = OnosFlowCtrl(deviceId = self.device_id,
2680 egressPort = egress,
2681 ingressPort = ingress,
2682 udpSrc = ingress_map['udp_port'],
2683 udpDst = egress_map['udp_port']
2684 )
2685
2686 result = flow.addFlow()
2687 assert_equal(result, True)
2688 ##wait for flows to be added to ONOS
2689 time.sleep(1)
2690 log.info("%d flow added.",i+1)
2691
ChetanGaonker720ea612016-06-21 17:54:25 -07002692 self.success = True
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002693
ChetanGaonker720ea612016-06-21 17:54:25 -07002694 def verify_flow(*r):
2695 random_sport = int(''.join(r))
2696 random_dport = random_sport + 2000
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002697
ChetanGaonker720ea612016-06-21 17:54:25 -07002698 def mac_recv_task():
2699 def recv_cb(pkt):
2700 log.info('Pkt seen with ingress UDP port %s, egress UDP port %s' %(pkt[UDP].sport, pkt[UDP].dport))
2701 success_dir[current_thread().name] = True
2702 sniff(count=2, timeout=5,
2703 lfilter = lambda p: UDP in p and p[UDP].dport == random_dport and p[UDP].sport == random_sport ,prn = recv_cb, iface = self.port_map[egress])
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002704
ChetanGaonker720ea612016-06-21 17:54:25 -07002705 t = threading.Thread(target = mac_recv_task)
2706 t.start()
2707 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
2708 L3 = IP(src = ingress_map['ip'], dst = egress_map['ip'])
2709 L4 = UDP(sport = random_sport, dport = random_dport)
2710 pkt = L2/L3/L4
2711 log.info('Sending packets to verify if flows are correct')
2712 sendp(pkt, count=50, iface = self.port_map[ingress])
2713 t.join()
2714
2715 t1 = threading.Thread(target = verify_flow, args = str(1101))
2716 t2 = threading.Thread(target = verify_flow, args = str(random.randrange(1110,1250,1)))
2717 t3 = threading.Thread(target = verify_flow, args = str(random.randrange(1251,1400,1)))
2718 t4 = threading.Thread(target = verify_flow, args = str(random.randrange(1401,1590,1)))
2719 t5 = threading.Thread(target = verify_flow, args = str(1600))
2720
2721
2722 t1.start()
2723 t2.start()
2724 t3.start()
2725 t4.start()
2726 t5.start()
2727
2728 t1.join()
2729 t2.join()
2730 t3.join()
2731 t4.join()
2732 t5.join()
2733
2734 if len(success_dir) != 5:
2735 self.success = False
2736
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002737 assert_equal(self.success, True)
2738
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002739 def test_1k_flow_udp_port(self):
2740 egress = 1
2741 ingress = 2
2742 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '192.168.30.1', 'udp_port': 3100 }
2743 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.168.40.1', 'udp_port': 1100 }
ChetanGaonker720ea612016-06-21 17:54:25 -07002744 success_dir = {}
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002745
ChetanGaonker720ea612016-06-21 17:54:25 -07002746 for i in range(0,100000):
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002747 ingress_map['udp_port'] += 1
2748 egress_map['udp_port'] += 1
2749
2750 flow = OnosFlowCtrl(deviceId = self.device_id,
2751 egressPort = egress,
2752 ingressPort = ingress,
2753 udpSrc = ingress_map['udp_port'],
2754 udpDst = egress_map['udp_port']
2755 )
2756
2757 result = flow.addFlow()
2758 assert_equal(result, True)
2759 ##wait for flows to be added to ONOS
2760 time.sleep(1)
2761 log.info("%d flow added.",i+1)
2762
ChetanGaonker720ea612016-06-21 17:54:25 -07002763 self.success = True
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002764
ChetanGaonker720ea612016-06-21 17:54:25 -07002765 def verify_flow(*r):
2766 random_sport = int(''.join(r))
2767 random_dport = random_sport + 2000
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002768
ChetanGaonker720ea612016-06-21 17:54:25 -07002769 def mac_recv_task():
2770 def recv_cb(pkt):
2771 log.info('Pkt seen with ingress UDP port %s, egress UDP port %s' %(pkt[UDP].sport, pkt[UDP].dport))
2772 success_dir[current_thread().name] = True
2773 sniff(count=2, timeout=5,
2774 lfilter = lambda p: UDP in p and p[UDP].dport == random_dport and p[UDP].sport == random_sport ,prn = recv_cb, iface = self.port_map[egress])
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002775
ChetanGaonker720ea612016-06-21 17:54:25 -07002776 t = threading.Thread(target = mac_recv_task)
2777 t.start()
2778 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
2779 L3 = IP(src = ingress_map['ip'], dst = egress_map['ip'])
2780 L4 = UDP(sport = random_sport, dport = random_dport)
2781 pkt = L2/L3/L4
2782 log.info('Sending packets to verify if flows are correct')
2783 sendp(pkt, count=50, iface = self.port_map[ingress])
2784 t.join()
2785
2786 t1 = threading.Thread(target = verify_flow, args = str(1101))
2787 t2 = threading.Thread(target = verify_flow, args = str(random.randrange(1110,1350,1)))
2788 t3 = threading.Thread(target = verify_flow, args = str(random.randrange(1351,1500,1)))
2789 t4 = threading.Thread(target = verify_flow, args = str(random.randrange(1501,1700,1)))
2790 t5 = threading.Thread(target = verify_flow, args = str(random.randrange(1701,1900,1)))
2791 t6 = threading.Thread(target = verify_flow, args = str(random.randrange(1901,2000,1)))
2792 t7 = threading.Thread(target = verify_flow, args = str(random.randrange(2000,2050,1)))
2793 t8 = threading.Thread(target = verify_flow, args = str(random.randrange(2050,2080,1)))
2794 t9 = threading.Thread(target = verify_flow, args = str(random.randrange(1102,2100,1)))
2795 t10 = threading.Thread(target = verify_flow, args = str(2100))
2796
2797 t1.start()
2798 t2.start()
2799 t3.start()
2800 t4.start()
2801 t5.start()
2802 t6.start()
2803 t7.start()
2804 t8.start()
2805 t9.start()
2806 t10.start()
2807
2808 t1.join()
2809 t2.join()
2810 t3.join()
2811 t4.join()
2812 t5.join()
2813 t6.join()
2814 t7.join()
2815 t8.join()
2816 t9.join()
2817 t10.join()
2818
2819 if len(success_dir) != 10:
2820 self.success = False
2821
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002822 assert_equal(self.success, True)
2823
2824 @nottest
2825 def test_10k_flow_udp_port(self):
2826 egress = 1
2827 ingress = 2
2828 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '192.168.30.1', 'udp_port': 31000 }
2829 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.168.40.1', 'udp_port': 11000 }
ChetanGaonker720ea612016-06-21 17:54:25 -07002830 success_dir = {}
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002831
2832 for i in range(0,10000):
ChetanGaonker720ea612016-06-21 17:54:25 -07002833 ingress_map['udp_port'] += 1
2834 egress_map['udp_port'] += 1
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002835
ChetanGaonker720ea612016-06-21 17:54:25 -07002836 flow = OnosFlowCtrl(deviceId = self.device_id,
2837 egressPort = egress,
2838 ingressPort = ingress,
2839 udpSrc = ingress_map['udp_port'],
2840 udpDst = egress_map['udp_port']
2841 )
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002842
ChetanGaonker720ea612016-06-21 17:54:25 -07002843 result = flow.addFlow()
2844 assert_equal(result, True)
2845 ##wait for flows to be added to ONOS
2846 time.sleep(1)
2847 log.info("%d flow added.",i+1)
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002848
ChetanGaonker720ea612016-06-21 17:54:25 -07002849 self.success = True
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002850
ChetanGaonker720ea612016-06-21 17:54:25 -07002851 def verify_flow(*r):
2852 random_sport = int(''.join(r))
2853 random_dport = random_sport + 20000
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002854
ChetanGaonker720ea612016-06-21 17:54:25 -07002855 def mac_recv_task():
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002856
ChetanGaonker720ea612016-06-21 17:54:25 -07002857 def recv_cb(pkt):
2858 log.info('Pkt seen with ingress UDP port %s, egress UDP port %s' %(pkt[UDP].sport, pkt[UDP].dport))
2859 success_dir[current_thread().name] = True
2860 sniff(count=2, timeout=5,
2861 lfilter = lambda p: UDP in p and p[UDP].dport == random_dport and p[UDP].sport == random_sport ,prn = recv_cb, iface = self.port_map[egress])
2862
2863 t = threading.Thread(target = mac_recv_task)
2864 t.start()
2865 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
2866 L3 = IP(src = ingress_map['ip'], dst = egress_map['ip'])
2867 L4 = UDP(sport = random_sport, dport = random_dport)
2868 pkt = L2/L3/L4
2869 log.info('Sending packets to verify if flows are correct')
2870 sendp(pkt, count=50, iface = self.port_map[ingress])
2871 t.join()
2872
2873 t1 = threading.Thread(target = verify_flow, args = str(11001))
2874 t2 = threading.Thread(target = verify_flow, args = str(random.randrange(11110,12501,1)))
2875 t3 = threading.Thread(target = verify_flow, args = str(random.randrange(12510,14001,1)))
2876 t4 = threading.Thread(target = verify_flow, args = str(random.randrange(14010,15900,1)))
2877 t5 = threading.Thread(target = verify_flow, args = str(random.randrange(16000,17000,1)))
2878 t6 = threading.Thread(target = verify_flow, args = str(random.randrange(17001,18000,1)))
2879 t7 = threading.Thread(target = verify_flow, args = str(random.randrange(18000,19000,1)))
2880 t8 = threading.Thread(target = verify_flow, args = str(random.randrange(19000,20980,1)))
2881 t9 = threading.Thread(target = verify_flow, args = str(random.randrange(11002,21000,1)))
2882 t10 = threading.Thread(target = verify_flow, args = str(21000))
2883
2884
2885 t1.start()
2886 t2.start()
2887 t3.start()
2888 t4.start()
2889 t5.start()
2890 t6.start()
2891 t7.start()
2892 t8.start()
2893 t9.start()
2894 t10.start()
2895
2896 t1.join()
2897 t2.join()
2898 t3.join()
2899 t4.join()
2900 t5.join()
2901 t6.join()
2902 t7.join()
2903 t8.join()
2904 t9.join()
2905 t10.join()
2906
2907 if len(success_dir) != 10:
2908 self.success = False
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002909 assert_equal(self.success, True)