blob: d75441581aa0b780b1d717d5a2ad7302e69ac0ef [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
A R Karthick9313b762016-11-07 13:14:35 -080028from CordLogger import CordLogger
A R Karthick76a497a2017-04-12 10:59:39 -070029from CordTestUtils import log_test
ChetanGaonkera6adc0b2016-06-12 12:21:14 -070030import random
31from threading import current_thread
ChetanGaonker720ea612016-06-21 17:54:25 -070032import collections
A R Karthick76a497a2017-04-12 10:59:39 -070033log_test.setLevel('INFO')
Chetan Gaonker7ab338c2016-04-15 17:23:17 -070034
A R Karthick9313b762016-11-07 13:14:35 -080035class flows_exchange(CordLogger):
Chetan Gaonker7ab338c2016-04-15 17:23:17 -070036
37 #Use the first available device id as our device id to program flows
38 app = 'org.onosproject.cli'
39 PORT_TX_DEFAULT = 2
40 PORT_RX_DEFAULT = 1
41 INTF_TX_DEFAULT = 'veth2'
42 INTF_RX_DEFAULT = 'veth0'
ChetanGaonkera6adc0b2016-06-12 12:21:14 -070043 default_port_map = {
Chetan Gaonker7ab338c2016-04-15 17:23:17 -070044 PORT_TX_DEFAULT : INTF_TX_DEFAULT,
45 PORT_RX_DEFAULT : INTF_RX_DEFAULT,
46 INTF_TX_DEFAULT : PORT_TX_DEFAULT,
47 INTF_RX_DEFAULT : PORT_RX_DEFAULT
48 }
49
ChetanGaonkera6adc0b2016-06-12 12:21:14 -070050 def incmac(self, mac):
ChetanGaonker720ea612016-06-21 17:54:25 -070051 tmp = str(hex(int('0x'+mac,16)+1).split('x')[1])
52 mac = '0'+ tmp if len(tmp) < 2 else tmp
53 return mac
ChetanGaonkera6adc0b2016-06-12 12:21:14 -070054
55 def next_mac(self, mac):
56 mac = mac.split(":")
57 mac[5] = self.incmac(mac[5])
58
59 if len(mac[5]) > 2:
ChetanGaonker720ea612016-06-21 17:54:25 -070060 mac[0] = self.incmac(mac[0])
61 mac[5] = '01'
62
ChetanGaonkera6adc0b2016-06-12 12:21:14 -070063 if len(mac[0]) > 2:
ChetanGaonker720ea612016-06-21 17:54:25 -070064 mac[0] = '01'
65 mac[1] = self.incmac(mac[1])
66 mac[5] = '01'
ChetanGaonkera6adc0b2016-06-12 12:21:14 -070067 return ':'.join(mac)
68
69 def to_egress_mac(cls, mac):
70 mac = mac.split(":")
71 mac[4] = '01'
ChetanGaonker720ea612016-06-21 17:54:25 -070072
ChetanGaonkera6adc0b2016-06-12 12:21:14 -070073 return ':'.join(mac)
74
75 def inc_ip(self, ip, i):
ChetanGaonker720ea612016-06-21 17:54:25 -070076
ChetanGaonkera6adc0b2016-06-12 12:21:14 -070077 ip[i] =str(int(ip[i])+1)
78 return '.'.join(ip)
79
80
81 def next_ip(self, ip):
ChetanGaonker720ea612016-06-21 17:54:25 -070082
ChetanGaonkera6adc0b2016-06-12 12:21:14 -070083 lst = ip.split('.')
84 for i in (3,0,-1):
85 if int(lst[i]) < 255:
86 return self.inc_ip(lst, i)
87 elif int(lst[i]) == 255:
ChetanGaonker720ea612016-06-21 17:54:25 -070088 lst[i] = '0'
89 if int(lst[i-1]) < 255:
90 return self.inc_ip(lst,i-1)
91 elif int(lst[i-2]) < 255:
92 lst[i-1] = '0'
93 return self.inc_ip(lst,i-2)
94 else:
95 break
ChetanGaonkera6adc0b2016-06-12 12:21:14 -070096
97 def to_egress_ip(self, ip):
98 lst=ip.split('.')
99 lst[0] = '182'
100 return '.'.join(lst)
101
ChetanGaonker720ea612016-06-21 17:54:25 -0700102
Chetan Gaonker7ab338c2016-04-15 17:23:17 -0700103 @classmethod
104 def setUpClass(cls):
105 cls.olt = OltConfig()
A R Karthickb03cecd2016-07-27 10:27:55 -0700106 cls.port_map, _ = cls.olt.olt_port_map()
Chetan Gaonker7ab338c2016-04-15 17:23:17 -0700107 if not cls.port_map:
108 cls.port_map = cls.default_port_map
A R Karthickb03cecd2016-07-27 10:27:55 -0700109 cls.device_id = OnosCtrl.get_device_id()
A R Karthicke4660f52017-02-23 12:08:41 -0800110 num_ports = len(cls.port_map['ports'] + cls.port_map['relay_ports'])
111 cls.port_offset = int(os.getenv('TEST_INSTANCE', 0)) * num_ports
Chetan Gaonker7ab338c2016-04-15 17:23:17 -0700112
113 def test_flow_mac(self):
ChetanGaonkera6adc0b2016-06-12 12:21:14 -0700114 '''Test Add and verify flows with MAC selectors'''
Chetan Gaonker7ab338c2016-04-15 17:23:17 -0700115 egress = 1
116 ingress = 2
117 egress_mac = '00:00:00:00:00:01'
118 ingress_mac = '00:00:00:00:00:02'
ChetanGaonker720ea612016-06-21 17:54:25 -0700119
Chetan Gaonker7ab338c2016-04-15 17:23:17 -0700120 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -0800121 egressPort = egress + self.port_offset,
122 ingressPort = ingress + self.port_offset,
Chetan Gaonker7ab338c2016-04-15 17:23:17 -0700123 ethSrc = ingress_mac,
124 ethDst = egress_mac)
125 result = flow.addFlow()
126 assert_equal(result, True)
127 ##wait for flows to be added to ONOS
ChetanGaonker720ea612016-06-21 17:54:25 -0700128 time.sleep(1)
Chetan Gaonker7ab338c2016-04-15 17:23:17 -0700129 self.success = False
130 def mac_recv_task():
131 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -0700132 log_test.info('Pkt seen with ingress mac %s, egress mac %s' %(pkt.src, pkt.dst))
Chetan Gaonker7ab338c2016-04-15 17:23:17 -0700133 self.success = True
ChetanGaonkera6adc0b2016-06-12 12:21:14 -0700134 sniff(count=2, timeout=5, lfilter = lambda p: p.src == ingress_mac,
Chetan Gaonker7ab338c2016-04-15 17:23:17 -0700135 prn = recv_cb, iface = self.port_map[egress])
136
137 t = threading.Thread(target = mac_recv_task)
138 t.start()
139 pkt = Ether(src = ingress_mac, dst = egress_mac)/IP()
A R Karthick76a497a2017-04-12 10:59:39 -0700140 log_test.info('Sending a packet to verify if flows are correct')
Chetan Gaonker7ab338c2016-04-15 17:23:17 -0700141 sendp(pkt, count=50, iface = self.port_map[ingress])
142 t.join()
143 assert_equal(self.success, True)
144
145 def test_flow_ip(self):
ChetanGaonkera6adc0b2016-06-12 12:21:14 -0700146 '''Test Add and verify flows with IPv4 selectors'''
Chetan Gaonker7ab338c2016-04-15 17:23:17 -0700147 egress = 1
148 ingress = 2
149 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '192.168.30.1' }
150 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.168.40.1' }
151 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -0800152 egressPort = egress + self.port_offset,
153 ingressPort = ingress + self.port_offset,
Chetan Gaonker7ab338c2016-04-15 17:23:17 -0700154 ethType = '0x0800',
155 ipSrc = ('IPV4_SRC', ingress_map['ip']+'/32'),
156 ipDst = ('IPV4_DST', egress_map['ip']+'/32')
157 )
158 result = flow.addFlow()
159 assert_equal(result, True)
160 ##wait for flows to be added to ONOS
ChetanGaonker720ea612016-06-21 17:54:25 -0700161 time.sleep(1)
Chetan Gaonker7ab338c2016-04-15 17:23:17 -0700162 self.success = False
163 def mac_recv_task():
164 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -0700165 log_test.info('Pkt seen with ingress ip %s, egress ip %s' %(pkt[IP].src, pkt[IP].dst))
Chetan Gaonker7ab338c2016-04-15 17:23:17 -0700166 self.success = True
ChetanGaonkera6adc0b2016-06-12 12:21:14 -0700167 sniff(count=2, timeout=5,
Chetan Gaonker3533faa2016-04-25 17:50:14 -0700168 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 -0700169 prn = recv_cb, iface = self.port_map[egress])
170
171 t = threading.Thread(target = mac_recv_task)
172 t.start()
173 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
174 L3 = IP(src = ingress_map['ip'], dst = egress_map['ip'])
175 pkt = L2/L3
A R Karthick76a497a2017-04-12 10:59:39 -0700176 log_test.info('Sending a packet to verify if flows are correct')
Chetan Gaonker7ab338c2016-04-15 17:23:17 -0700177 sendp(pkt, count=50, iface = self.port_map[ingress])
178 t.join()
179 assert_equal(self.success, True)
ChetanGaonkera6adc0b2016-06-12 12:21:14 -0700180
181
182 def test_flow_tcp_port(self):
183 egress = 1
184 ingress = 2
185 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '192.168.30.1', 'tcp_port': 9500 }
186 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.168.40.1', 'tcp_port': 9000 }
187 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -0800188 egressPort = egress + self.port_offset,
189 ingressPort = ingress + self.port_offset,
ChetanGaonkera6adc0b2016-06-12 12:21:14 -0700190 tcpSrc = ingress_map['tcp_port'],
191 tcpDst = egress_map['tcp_port']
192 )
193 result = flow.addFlow()
194 assert_equal(result, True)
195 ##wait for flows to be added to ONOS
ChetanGaonker720ea612016-06-21 17:54:25 -0700196 time.sleep(1)
ChetanGaonkera6adc0b2016-06-12 12:21:14 -0700197 self.success = False
198 def mac_recv_task():
199 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -0700200 log_test.info('Pkt seen with ingress TCP port %s, egress TCP port %s' %(pkt[TCP].sport, pkt[TCP].dport))
ChetanGaonkera6adc0b2016-06-12 12:21:14 -0700201 self.success = True
ChetanGaonker720ea612016-06-21 17:54:25 -0700202 sniff(count=2, timeout=5, lfilter = lambda p: TCP in p and p[TCP].dport == egress_map['tcp_port']
203 and p[TCP].sport == ingress_map['tcp_port'], prn = recv_cb, iface = self.port_map[egress])
ChetanGaonkera6adc0b2016-06-12 12:21:14 -0700204
205 t = threading.Thread(target = mac_recv_task)
206 t.start()
207 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
208 L3 = IP(src = ingress_map['ip'], dst = egress_map['ip'])
209 L4 = TCP(sport = ingress_map['tcp_port'], dport = egress_map['tcp_port'])
210 pkt = L2/L3/L4
A R Karthick76a497a2017-04-12 10:59:39 -0700211 log_test.info('Sending packets to verify if flows are correct')
ChetanGaonkera6adc0b2016-06-12 12:21:14 -0700212 sendp(pkt, count=50, iface = self.port_map[ingress])
213 t.join()
214 assert_equal(self.success, True)
215
ChetanGaonkera6adc0b2016-06-12 12:21:14 -0700216 def test_flow_udp_port(self):
217 egress = 1
218 ingress = 2
219 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '192.168.30.1', 'udp_port': 9500 }
220 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.168.40.1', 'udp_port': 9000 }
221 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -0800222 egressPort = egress + self.port_offset,
223 ingressPort = ingress + self.port_offset,
ChetanGaonkera6adc0b2016-06-12 12:21:14 -0700224 udpSrc = ingress_map['udp_port'],
225 udpDst = egress_map['udp_port']
226 )
227 result = flow.addFlow()
228 assert_equal(result, True)
229 ##wait for flows to be added to ONOS
ChetanGaonker720ea612016-06-21 17:54:25 -0700230 time.sleep(1)
ChetanGaonkera6adc0b2016-06-12 12:21:14 -0700231 self.success = False
232 def mac_recv_task():
233 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -0700234 log_test.info('Pkt seen with ingress UDP port %s, egress UDP port %s' %(pkt[UDP].sport, pkt[UDP].dport))
ChetanGaonkera6adc0b2016-06-12 12:21:14 -0700235 self.success = True
236 sniff(count=2, timeout=5,
ChetanGaonker720ea612016-06-21 17:54:25 -0700237 lfilter = lambda p: UDP in p and p[UDP].dport == egress_map['udp_port']
238 and p[UDP].sport == ingress_map['udp_port'], prn = recv_cb, iface = self.port_map[egress])
ChetanGaonkera6adc0b2016-06-12 12:21:14 -0700239
240 t = threading.Thread(target = mac_recv_task)
241 t.start()
242 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
243 L3 = IP(src = ingress_map['ip'], dst = egress_map['ip'])
244 L4 = UDP(sport = ingress_map['udp_port'], dport = egress_map['udp_port'])
245 pkt = L2/L3/L4
A R Karthick76a497a2017-04-12 10:59:39 -0700246 log_test.info('Sending packets to verify if flows are correct')
ChetanGaonkera6adc0b2016-06-12 12:21:14 -0700247 sendp(pkt, count=50, iface = self.port_map[ingress])
248 t.join()
249 assert_equal(self.success, True)
250
ChetanGaonker720ea612016-06-21 17:54:25 -0700251 @nottest
252 def test_flow_vlan(self):
253 egress = 1
254 ingress = 2
255 egress_mac = '00:00:00:00:00:01'
256 ingress_mac = '00:00:00:00:00:02'
257 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -0800258 egressPort = egress + self.port_offset,
259 ingressPort = ingress + self.port_offset,
ChetanGaonker720ea612016-06-21 17:54:25 -0700260 ethSrc = ingress_mac,
261 ethDst = egress_mac,
262 vlan = 0x10)
263 result = flow.addFlow()
264 assert_equal(result, True)
265 ##wait for flows to be added to ONOS
266 time.sleep(1)
267 self.success = False
268 def mac_recv_task():
269 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -0700270 log_test.info('Pkt seen with ingress mac %s, egress mac %s' %(pkt.src, pkt.dst))
271 log_test.info('Pkt:%s', pkt.show())
ChetanGaonker720ea612016-06-21 17:54:25 -0700272 self.success = True
273 sniff(count=2, timeout=5, lfilter = lambda p:p.src == ingress_mac,
274 prn = recv_cb, iface = self.port_map[egress])
275
276 t = threading.Thread(target = mac_recv_task)
277 t.start()
278 pkt = Ether(src = ingress_mac, dst = egress_mac)/Dot1Q(vlan = 0x10)/IP()
A R Karthick76a497a2017-04-12 10:59:39 -0700279 log_test.info("Sending Packet:%s",pkt.show())
280 log_test.info('Sending a packet to verify if flows are correct')
ChetanGaonker720ea612016-06-21 17:54:25 -0700281 sendp(pkt, count=50, iface = self.port_map[ingress])
282 t.join()
283 assert_equal(self.success, True)
284
285 def test_flow_ipv6(self):
286 egress = 1
287 ingress = 2
288 egress_map = { 'ether': '00:00:00:00:00:03', 'ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1001' }
289 ingress_map = { 'ether': '00:00:00:00:00:04', 'ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1002' }
290 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -0800291 egressPort = egress + self.port_offset,
292 ingressPort = ingress + self.port_offset,
ChetanGaonker720ea612016-06-21 17:54:25 -0700293 ethType = '0x86dd',
294 ipSrc = ('IPV6_SRC', ingress_map['ipv6'] + '/48'),
295 ipDst = ('IPV6_DST', egress_map['ipv6'] + '/48')
296 )
297
298 result = flow.addFlow()
299 assert_equal(result, True)
300 ##wait for flows to be added to ONOS
301 time.sleep(1)
302 self.success = False
303 def mac_recv_task():
304 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -0700305 log_test.info('Pkt seen with ingress ip %s, egress ip %s' %(pkt[IPv6].src, pkt[IPv6].dst))
ChetanGaonker720ea612016-06-21 17:54:25 -0700306 self.success = True
307 sniff(count=2, timeout=5,
308 lfilter = lambda p: IPv6 in p and p[IPv6].dst == egress_map['ipv6'] and p[IPv6].src == ingress_map['ipv6'],
309 prn = recv_cb, iface = self.port_map[egress])
310
311 t = threading.Thread(target = mac_recv_task)
312 t.start()
313 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
314 L3 = IPv6(src = ingress_map['ipv6'] , dst = egress_map['ipv6'])
315 pkt = L2/L3
A R Karthick76a497a2017-04-12 10:59:39 -0700316 log_test.info('Sending a packet to verify if flows are correct')
ChetanGaonker720ea612016-06-21 17:54:25 -0700317 sendp(pkt, count=50, iface = self.port_map[ingress])
318 t.join()
319 assert_equal(self.success, True)
320
321 def test_flow_ipv6_flow_label(self):
322 egress = 1
323 ingress = 2
324 egress_map = { 'ether': '00:00:00:00:00:03', 'ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1001' }
325 ingress_map = { 'ether': '00:00:00:00:00:04', 'ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1002' }
326 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -0800327 egressPort = egress + self.port_offset,
328 ingressPort = ingress + self.port_offset,
ChetanGaonker720ea612016-06-21 17:54:25 -0700329 ipv6flow_label = 25
330 )
331
332 result = flow.addFlow()
333 assert_equal(result, True)
334 ##wait for flows to be added to ONOS
335 time.sleep(1)
336 self.success = False
337 def mac_recv_task():
338 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -0700339 log_test.info('Pkt seen with ingress ip %s, egress ip %s with flow label %s' %(pkt[IPv6].src, pkt[IPv6].dst, pkt[IPv6].fl))
ChetanGaonker720ea612016-06-21 17:54:25 -0700340 self.success = True
341 sniff(count=2, timeout=5, lfilter = lambda p: IPv6 in p and p[IPv6].dst == egress_map['ipv6']
342 and p[IPv6].src == ingress_map['ipv6'] and p[IPv6].fl == 25, prn = recv_cb, iface = self.port_map[egress])
343
344 t = threading.Thread(target = mac_recv_task)
345 t.start()
346 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
347 L3 = IPv6(src = ingress_map['ipv6'] , dst = egress_map['ipv6'], fl = 25)
348 pkt = L2/L3
A R Karthick76a497a2017-04-12 10:59:39 -0700349 log_test.info('Sending a packet to verify if flows are correct')
ChetanGaonker720ea612016-06-21 17:54:25 -0700350 sendp(pkt, count=50, iface = self.port_map[ingress])
351 t.join()
352 assert_equal(self.success, True)
353
354 def test_flow_ipv6_extension_header(self):
355 egress = 1
356 ingress = 2
357 egress_map = { 'ether': '00:00:00:00:00:03', 'ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1001' }
358 ingress_map = { 'ether': '00:00:00:00:00:04', 'ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1002' }
359 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -0800360 egressPort = egress + self.port_offset,
361 ingressPort = ingress + self.port_offset,
ChetanGaonker720ea612016-06-21 17:54:25 -0700362 ipv6_extension = 0,
363 )
364
365 result = flow.addFlow()
366 assert_equal(result, True)
367 ##wait for flows to be added to ONOS
368 time.sleep(1)
369 self.success = False
370 def mac_recv_task():
371 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -0700372 log_test.info('Pkt seen with ingress ip %s, egress ip %s, Extension Header Type %s' %(pkt[IPv6].src, pkt[IPv6].dst, pkt[IPv6].nh))
ChetanGaonker720ea612016-06-21 17:54:25 -0700373 self.success = True
374 sniff(count=2, timeout=5,
375 lfilter = lambda p: IPv6 in p and p[IPv6].nh == 0, prn = recv_cb, iface = self.port_map[egress])
376
377 t = threading.Thread(target = mac_recv_task)
378 t.start()
379 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
380 L3 = IPv6(src = ingress_map['ipv6'] , dst = egress_map['ipv6'], nh = 0)
381 pkt = L2/L3
A R Karthick76a497a2017-04-12 10:59:39 -0700382 log_test.info('Sending packets to verify if flows are correct')
ChetanGaonker720ea612016-06-21 17:54:25 -0700383 sendp(pkt, count=50, iface = self.port_map[ingress])
384 t.join()
385 assert_equal(self.success, True)
386
387 def test_flow_ipv6_available_extension_headers(self):
388 egress = 1
389 ingress = 2
390 egress_map = { 'ether': '00:00:00:00:00:03', 'ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1001' }
391 ingress_map = { 'ether': '00:00:00:00:00:04', 'ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1002' }
392 for i in [0, 60, 43, 44, 51, 50, 135]:
393 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -0800394 egressPort = egress + self.port_offset,
395 ingressPort = ingress + self.port_offset,
ChetanGaonker720ea612016-06-21 17:54:25 -0700396 ipv6_extension = i,
397 )
398
399 result = flow.addFlow()
400 assert_equal(result, True)
401 ##wait for flows to be added to ONOS
402 time.sleep(1)
403 def mac_recv_task():
404 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -0700405 log_test.info('Pkt seen with ingress ip %s, egress ip %s, Extension Header Type %s' %(pkt[IPv6].src, pkt[IPv6].dst, pkt[IPv6].nh))
ChetanGaonker720ea612016-06-21 17:54:25 -0700406 self.success = True
407 sniff(count=2, timeout=5, lfilter = lambda p: IPv6 in p and p[IPv6].nh == i,
408 prn = recv_cb, iface = self.port_map[egress])
409
410 for i in [0, 60, 43, 44, 51, 50, 135]:
411 self.success = False
412 t = threading.Thread(target = mac_recv_task)
413 t.start()
414 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
415 L3 = IPv6(src = ingress_map['ipv6'] , dst = egress_map['ipv6'], nh = i)
416 pkt = L2/L3
A R Karthick76a497a2017-04-12 10:59:39 -0700417 log_test.info('Sending packets to verify if flows are correct')
ChetanGaonker720ea612016-06-21 17:54:25 -0700418 sendp(pkt, count=50, iface = self.port_map[ingress])
419 t.join()
420 assert_equal(self.success, True)
421
422
423 def test_flow_dscp(self):
424 egress = 1
425 ingress = 2
426 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '192.168.30.1' }
427 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.168.40.1' }
428 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -0800429 egressPort = egress + self.port_offset,
430 ingressPort = ingress + self.port_offset,
ChetanGaonker720ea612016-06-21 17:54:25 -0700431 dscp = 32
432 )
433 result = flow.addFlow()
434 assert_equal(result, True)
435 ##wait for flows to be added to ONOS
436 time.sleep(1)
437 self.success = False
438 def mac_recv_task():
439 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -0700440 log_test.info('Pkt seen with ingress ip %s, egress ip %s and Type of Service %s' %(pkt[IP].src, pkt[IP].dst, pkt[IP].tos))
ChetanGaonker720ea612016-06-21 17:54:25 -0700441 self.success = True
442 sniff(count=2, timeout=5,
443 lfilter = lambda p: IP in p and p[IP].dst == egress_map['ip'] and p[IP].src == ingress_map['ip']
444 and p[IP].tos == 32,prn = recv_cb, iface = self.port_map[egress])
445
446 t = threading.Thread(target = mac_recv_task)
447 t.start()
448 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
449 L3 = IP(src = ingress_map['ip'], dst = egress_map['ip'], tos = 32)
450 pkt = L2/L3
A R Karthick76a497a2017-04-12 10:59:39 -0700451 log_test.info('Sending a packet to verify if flows are correct')
ChetanGaonker720ea612016-06-21 17:54:25 -0700452 sendp(pkt, count=50, iface = self.port_map[ingress])
453 t.join()
454 assert_equal(self.success, True)
455
456 def test_flow_available_dscp(self):
457 egress = 1
458 ingress = 2
459 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '192.168.30.1' }
460 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.168.40.1' }
461 dscp = [184, 0, 40, 48, 56, 72, 80, 88, 104, 112, 120, 136, 144, 152, 32, 64, 96, 128, 160, 192, 224]
462 for i in dscp:
463 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -0800464 egressPort = egress + self.port_offset,
465 ingressPort = ingress + self.port_offset,
ChetanGaonker720ea612016-06-21 17:54:25 -0700466 dscp = i
467 )
468 result = flow.addFlow()
469 assert_equal(result, True)
470 ##wait for flows to be added to ONOS
471 time.sleep(1)
472
473 def mac_recv_task():
474 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -0700475 log_test.info('Pkt seen with ingress ip %s, egress ip %s and Type of Service %s' %(pkt[IP].src, pkt[IP].dst, pkt[IP].tos))
ChetanGaonker720ea612016-06-21 17:54:25 -0700476 self.success = True
477 sniff(count=2, timeout=5,
478 lfilter = lambda p: IP in p and p[IP].dst == egress_map['ip'] and p[IP].src == ingress_map['ip']
479 and p[IP].tos == i,prn = recv_cb, iface = self.port_map[egress])
480
481 for i in dscp:
482 self.success = False
483 t = threading.Thread(target = mac_recv_task)
484 t.start()
485 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
486 L3 = IP(src = ingress_map['ip'], dst = egress_map['ip'], tos = i)
487 pkt = L2/L3
A R Karthick76a497a2017-04-12 10:59:39 -0700488 log_test.info('Sending a packet to verify if flows are correct')
ChetanGaonker720ea612016-06-21 17:54:25 -0700489 sendp(pkt, count=50, iface = self.port_map[ingress])
490 t.join()
491 assert_equal(self.success, True)
492
493 def test_flow_ecn(self):
494 egress = 1
495 ingress = 2
496 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '192.168.30.1' }
497 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.168.40.1' }
498 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -0800499 egressPort = egress + self.port_offset,
500 ingressPort = ingress + self.port_offset,
ChetanGaonker720ea612016-06-21 17:54:25 -0700501 ecn = 1
502 )
503 result = flow.addFlow()
504 assert_equal(result, True)
505 ##wait for flows to be added to ONOS
506 time.sleep(1)
507 self.success = False
508 def mac_recv_task():
509 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -0700510 log_test.info('Pkt seen with ingress ip %s, egress ip %s and Type of Service %s' %(pkt[IP].src, pkt[IP].dst, pkt[IP].tos))
ChetanGaonker720ea612016-06-21 17:54:25 -0700511 self.success = True
512 sniff(count=2, timeout=5,
513 lfilter = lambda p: IP in p and p[IP].dst == egress_map['ip'] and p[IP].src == ingress_map['ip']
514 and int(bin(p[IP].tos).split('b')[1][-2:],2) == 1,prn = recv_cb,
515 iface = self.port_map[egress])
516
517 t = threading.Thread(target = mac_recv_task)
518 t.start()
519 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
520 L3 = IP(src = ingress_map['ip'], dst = egress_map['ip'], tos = 1)
521 pkt = L2/L3
A R Karthick76a497a2017-04-12 10:59:39 -0700522 log_test.info('Sending a packet to verify if flows are correct')
ChetanGaonker720ea612016-06-21 17:54:25 -0700523 sendp(pkt, count=50, iface = self.port_map[ingress])
524 t.join()
525 assert_equal(self.success, True)
526
527
528 def test_flow_available_ecn(self):
529 egress = 1
530 ingress = 2
531 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '192.168.30.1' }
532 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.168.40.1' }
533 for i in range(4):
534 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -0800535 egressPort = egress + self.port_offset,
536 ingressPort = ingress + self.port_offset,
ChetanGaonker720ea612016-06-21 17:54:25 -0700537 ecn = i
538 )
539 result = flow.addFlow()
540 assert_equal(result, True)
541 ##wait for flows to be added to ONOS
542 time.sleep(1)
543 def mac_recv_task():
544 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -0700545 log_test.info('Pkt seen with ingress ip %s, egress ip %s and Type of Service %s' %(pkt[IP].src, pkt[IP].dst, pkt[IP].tos))
ChetanGaonker720ea612016-06-21 17:54:25 -0700546 self.success = True
547 sniff(count=2, timeout=5,
548 lfilter = lambda p: IP in p and p[IP].dst == egress_map['ip'] and p[IP].src == ingress_map['ip']
549 and int(bin(p[IP].tos).split('b')[1][-2:],2) == i,prn = recv_cb,
550 iface = self.port_map[egress])
551
552 for i in range(4):
553 self.success = False
554 t = threading.Thread(target = mac_recv_task)
555 t.start()
556 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
557 L3 = IP(src = ingress_map['ip'], dst = egress_map['ip'], tos = i)
558 pkt = L2/L3
A R Karthick76a497a2017-04-12 10:59:39 -0700559 log_test.info('Sending a packet to verify if flows are correct')
ChetanGaonker720ea612016-06-21 17:54:25 -0700560 sendp(pkt, count=50, iface = self.port_map[ingress])
561 t.join()
562 assert_equal(self.success, True)
563
564 def test_flow_available_dscp_and_ecn(self):
565 egress = 1
566 ingress = 2
567 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '192.168.30.1' }
568 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.168.40.1' }
569 dscp = [46, 0, 10, 12, 14, 18, 20, 22, 26, 28, 30, 34, 36, 38, 8, 16, 24, 32, 40, 48, 56]
570 for i in dscp:
571 for j in (0,1,2,3):
572 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -0800573 egressPort = egress + self.port_offset,
574 ingressPort = ingress + self.port_offset,
ChetanGaonker720ea612016-06-21 17:54:25 -0700575 dscp = i,
576 ecn = j
577 )
578 result = flow.addFlow()
579 assert_equal(result, True)
580 ##wait for flows to be added to ONOS
581 time.sleep(1)
582
583 def mac_recv_task():
584 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -0700585 log_test.info('Pkt seen with ingress ip %s, egress ip %s and Type of Service %s' %(pkt[IP].src, pkt[IP].dst, pkt[IP].tos))
ChetanGaonker720ea612016-06-21 17:54:25 -0700586 self.success = True
587 sniff(count=2, timeout=5,
588 lfilter = lambda p: IP in p and p[IP].tos == int(bin(i).split('b')[1]+ bin(j).split('b')[1],2)
589 ,prn = recv_cb, iface = self.port_map[egress])
590
591 for i in dscp:
592 for j in (0,1,2,3):
593
594 self.success = False
595 t = threading.Thread(target = mac_recv_task)
596 t.start()
597 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
598 L3 = IP(src = ingress_map['ip'], dst = egress_map['ip'], tos = int(bin(i).split('b')[1]+ bin(j).split('b')[1],2))
599 pkt = L2/L3
A R Karthick76a497a2017-04-12 10:59:39 -0700600 log_test.info('Sending packets to verify if flows are correct')
ChetanGaonker720ea612016-06-21 17:54:25 -0700601 sendp(pkt, count=50, iface = self.port_map[ingress])
602 t.join()
603 assert_equal(self.success, True)
604
605 def test_flow_icmp(self):
606 egress = 1
607 ingress = 2
608 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '192.168.30.1' }
609 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.168.40.1' }
610 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -0800611 egressPort = egress + self.port_offset,
612 ingressPort = ingress + self.port_offset,
ChetanGaonker720ea612016-06-21 17:54:25 -0700613 icmpv4_type = '3',
614 icmpv4_code = 8
615 )
616 result = flow.addFlow()
617 assert_equal(result, True)
618 ##wait for flows to be added to ONOS
619 time.sleep(1)
620 self.success = False
621
622 def mac_recv_task():
623 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -0700624 log_test.info('Pkt seen with ICMP type %s, ICMP code %s' %(pkt[ICMP].type, pkt[ICMP].code))
ChetanGaonker720ea612016-06-21 17:54:25 -0700625 self.success = True
626 sniff(count=2, timeout=5,
627 lfilter = lambda p: ICMP in p and p[ICMP].type == 3 and p[ICMP].code == 8,
628 prn = recv_cb, iface = self.port_map[egress])
629
630 t = threading.Thread(target = mac_recv_task)
631 t.start()
632 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
633 L3 = IP(src = ingress_map['ip'], dst = egress_map['ip'])/ICMP(type = 3, code = 8)
634 pkt = L2/L3
A R Karthick76a497a2017-04-12 10:59:39 -0700635 log_test.info('Sending a packet to verify if flows are correct')
ChetanGaonker720ea612016-06-21 17:54:25 -0700636 sendp(pkt, count=50, iface = self.port_map[ingress])
637 t.join()
638 assert_equal(self.success, True)
639
640 def test_flow_icmp_different_types(self):
641 egress = 1
642 ingress = 2
643 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '192.168.30.1' }
644 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.168.40.1' }
645 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],
646 '5': [1, 2, 3], '4': 0, '9': 0, '8': 0}
647 for type,code in icmp.items():
648 if isinstance(code, list):
649 for i in code:
650 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -0800651 egressPort = egress + self.port_offset,
652 ingressPort = ingress + self.port_offset,
ChetanGaonker720ea612016-06-21 17:54:25 -0700653 icmpv4_type = type,
654 icmpv4_code = i
655 )
656 result = flow.addFlow()
657 assert_equal(result, True)
658 ##wait for flows to be added to ONOS
659 time.sleep(1)
660 else:
661 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -0800662 egressPort = egress + self.port_offset,
663 ingressPort = ingress + self.port_offset,
ChetanGaonker720ea612016-06-21 17:54:25 -0700664 icmpv4_type = type,
665 icmpv4_code = code
666 )
667 result = flow.addFlow()
668 assert_equal(result, True)
669 ##wait for flows to be added to ONOS
670 time.sleep(1)
671 self.success = False
672
673 def mac_recv_task():
674 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -0700675 log_test.info('Pkt seen with ICMP type %s, ICMP code %s' %(pkt[ICMP].type, pkt[ICMP].code))
ChetanGaonker720ea612016-06-21 17:54:25 -0700676 self.success = True
677 sniff(count=2, timeout=5,
678 lfilter = lambda p: ICMP in p and p[ICMP].type == 3 and p[ICMP].code == 8,
679 prn = recv_cb, iface = self.port_map[egress])
680
681 t = threading.Thread(target = mac_recv_task)
682 t.start()
683 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
684 L3 = IP(src = ingress_map['ip'], dst = egress_map['ip'])/ICMP(type = 3, code = 8)
685 pkt = L2/L3
A R Karthick76a497a2017-04-12 10:59:39 -0700686 log_test.info('Sending a packet to verify if flows are correct')
ChetanGaonker720ea612016-06-21 17:54:25 -0700687 sendp(pkt, count=50, iface = self.port_map[ingress])
688 t.join()
689 assert_equal(self.success, True)
690
691 def test_flow_icmpv6_EchoRequest(self):
692 egress = 1
693 ingress = 2
694 egress_map = { 'ether': '00:00:00:00:00:03','ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1001'}
695 ingress_map = { 'ether': '00:00:00:00:00:04','ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1002'}
696 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -0800697 egressPort = egress + self.port_offset,
698 ingressPort = ingress + self.port_offset,
ChetanGaonker720ea612016-06-21 17:54:25 -0700699 icmpv6_type = '128',
700 icmpv6_code = 0
701 )
702 result = flow.addFlow()
703 assert_equal(result, True)
704 ##wait for flows to be added to ONOS
705 time.sleep(1)
706 self.success = False
707 def mac_recv_task():
708 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -0700709 log_test.info('Pkt seen with ICMPv6 type %s, ICMPv6 code %s' %(pkt[ICMPv6EchoRequest].type, pkt[ICMPv6EchoRequest].code))
ChetanGaonker720ea612016-06-21 17:54:25 -0700710 self.success = True
711 sniff(count=2, timeout=5,
712 lfilter = lambda p: ICMPv6EchoRequest in p and p[ICMPv6EchoRequest].type == 128 and p[ICMPv6EchoRequest].code == 0,
713 prn = recv_cb, iface = self.port_map[egress])
714
715 t = threading.Thread(target = mac_recv_task)
716 t.start()
717 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
718 L3 = IPv6(src = ingress_map['ipv6'], dst = egress_map['ipv6'])/ICMPv6EchoRequest()
719 pkt = L2/L3
A R Karthick76a497a2017-04-12 10:59:39 -0700720 log_test.info('Sending a packet to verify if flows are correct')
ChetanGaonker720ea612016-06-21 17:54:25 -0700721 sendp(pkt, count=50, iface = self.port_map[ingress])
722 t.join()
723 assert_equal(self.success, True)
724
725 def test_flow_icmpv6_EchoReply(self):
726 egress = 1
727 ingress = 2
728 egress_map = { 'ether': '00:00:00:00:00:03','ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1001'}
729 ingress_map = { 'ether': '00:00:00:00:00:04','ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1002' }
730 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -0800731 egressPort = egress + self.port_offset,
732 ingressPort = ingress + self.port_offset,
ChetanGaonker720ea612016-06-21 17:54:25 -0700733 icmpv6_type = '129',
734 icmpv6_code = 0
735 )
736 result = flow.addFlow()
737 assert_equal(result, True)
738 ##wait for flows to be added to ONOS
739 time.sleep(1)
740 self.success = False
741 def mac_recv_task():
742 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -0700743 log_test.info('Pkt seen with ICMPv6 type %s, ICMPv6 code %s' %(pkt[ICMPv6EchoReply].type, pkt[ICMPv6EchoReply].code))
ChetanGaonker720ea612016-06-21 17:54:25 -0700744 self.success = True
745 sniff(count=2, timeout=5,
746 lfilter = lambda p: ICMPv6EchoReply in p and p[ICMPv6EchoReply].type == 129 and p[ICMPv6EchoReply].code == 0,
747 prn = recv_cb, iface = self.port_map[egress])
748
749 t = threading.Thread(target = mac_recv_task)
750 t.start()
751 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
752 L3 = IPv6(src = ingress_map['ipv6'], dst = egress_map['ipv6'])/ICMPv6EchoReply()
753 pkt = L2/L3
A R Karthick76a497a2017-04-12 10:59:39 -0700754 log_test.info('Sending packets to verify if flows are correct')
ChetanGaonker720ea612016-06-21 17:54:25 -0700755 sendp(pkt, count=50, iface = self.port_map[ingress])
756 t.join()
757 assert_equal(self.success, True)
758
759
760 def test_flow_icmpv6_DestUnreachable(self):
761 egress = 1
762 ingress = 2
763 egress_map = { 'ether': '00:00:00:00:00:03','ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1001'}
764 ingress_map = { 'ether': '00:00:00:00:00:04','ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1002' }
765 for i in range(8):
766 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -0800767 egressPort = egress + self.port_offset,
768 ingressPort = ingress + self.port_offset,
ChetanGaonker720ea612016-06-21 17:54:25 -0700769 icmpv6_type = '1',
770 icmpv6_code = i
771 )
772 result = flow.addFlow()
773 assert_equal(result, True)
774 ##wait for flows to be added to ONOS
775 time.sleep(1)
776 for i in range(8):
777 self.success = False
778 def mac_recv_task():
779 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -0700780 log_test.info('Pkt seen with ICMPv6 type %s, ICMPv6 code %s' %(pkt[ICMPv6DestUnreach].type, pkt[ICMPv6DestUnreach].code))
ChetanGaonker720ea612016-06-21 17:54:25 -0700781 self.success = True
782 sniff(count=2, timeout=5,
783 lfilter = lambda p: ICMPv6DestUnreach in p and p[ICMPv6DestUnreach].type == 1 and p[ICMPv6DestUnreach].code == i,
784 prn = recv_cb, iface = self.port_map[egress])
785
786 t = threading.Thread(target = mac_recv_task)
787 t.start()
788 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
789 L3 = IPv6(src = ingress_map['ipv6'], dst = egress_map['ipv6'])/ICMPv6DestUnreach(code = i)
790 pkt = L2/L3
A R Karthick76a497a2017-04-12 10:59:39 -0700791 log_test.info('Sending packets to verify if flows are correct')
ChetanGaonker720ea612016-06-21 17:54:25 -0700792 sendp(pkt, count=50, iface = self.port_map[ingress])
793 t.join()
794 assert_equal(self.success, True)
795
796 def test_flow_icmpv6_PacketTooBig(self):
797 egress = 1
798 ingress = 2
799 egress_map = { 'ether': '00:00:00:00:00:03','ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1001'}
800 ingress_map = { 'ether': '00:00:00:00:00:04','ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1002' }
801 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -0800802 egressPort = egress + self.port_offset,
803 ingressPort = ingress + self.port_offset,
ChetanGaonker720ea612016-06-21 17:54:25 -0700804 icmpv6_type = '2',
805 icmpv6_code = 0
806 )
807 result = flow.addFlow()
808 assert_equal(result, True)
809 ##wait for flows to be added to ONOS
810 time.sleep(1)
811 self.success = False
812 def mac_recv_task():
813 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -0700814 log_test.info('Pkt seen with ICMPv6 type %s, ICMPv6 code %s' %(pkt[ICMPv6PacketTooBig].type, pkt[ICMPv6PacketTooBig].code))
ChetanGaonker720ea612016-06-21 17:54:25 -0700815 self.success = True
816 sniff(count=2, timeout=5,
817 lfilter = lambda p: ICMPv6PacketTooBig in p and p[ICMPv6PacketTooBig].type == 2 and p[ICMPv6PacketTooBig].code == 0,
818 prn = recv_cb, iface = self.port_map[egress])
819
820 t = threading.Thread(target = mac_recv_task)
821 t.start()
822 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
823 L3 = IPv6(src = ingress_map['ipv6'], dst = egress_map['ipv6'])/ICMPv6PacketTooBig()
824 pkt = L2/L3
A R Karthick76a497a2017-04-12 10:59:39 -0700825 log_test.info('Sending packets to verify if flows are correct')
ChetanGaonker720ea612016-06-21 17:54:25 -0700826 sendp(pkt, count=50, iface = self.port_map[ingress])
827 t.join()
828 assert_equal(self.success, True)
829
830 def test_flow_icmpv6_TimeExceeded(self):
831 egress = 1
832 ingress = 2
833 egress_map = { 'ether': '00:00:00:00:00:03','ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1001'}
834 ingress_map = { 'ether': '00:00:00:00:00:04','ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1002' }
835 for i in range(2):
836 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -0800837 egressPort = egress + self.port_offset,
838 ingressPort = ingress + self.port_offset,
ChetanGaonker720ea612016-06-21 17:54:25 -0700839 icmpv6_type = '3',
840 icmpv6_code = i
841 )
842 result = flow.addFlow()
843 assert_equal(result, True)
844 ##wait for flows to be added to ONOS
845 time.sleep(1)
846 for i in range(2):
847 self.success = False
848 def mac_recv_task():
849 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -0700850 log_test.info('Pkt seen with ICMPv6 type %s, ICMPv6 code %s' %(pkt[ICMPv6TimeExceeded].type, pkt[ICMPv6TimeExceeded].code))
ChetanGaonker720ea612016-06-21 17:54:25 -0700851 self.success = True
852 sniff(count=2, timeout=5,
853 lfilter = lambda p: ICMPv6TimeExceeded in p and p[ICMPv6TimeExceeded].type == 3 and p[ICMPv6TimeExceeded].code == i,
854 prn = recv_cb, iface = self.port_map[egress])
855
856 t = threading.Thread(target = mac_recv_task)
857 t.start()
858 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
859 L3 = IPv6(src = ingress_map['ipv6'], dst = egress_map['ipv6'])/ICMPv6TimeExceeded(code = i)
860 pkt = L2/L3
A R Karthick76a497a2017-04-12 10:59:39 -0700861 log_test.info('Sending packets to verify if flows are correct')
ChetanGaonker720ea612016-06-21 17:54:25 -0700862 sendp(pkt, count=50, iface = self.port_map[ingress])
863 t.join()
864 assert_equal(self.success, True)
865
866 def test_flow_icmpv6_ParameterProblem(self):
867 egress = 1
868 ingress = 2
869 egress_map = { 'ether': '00:00:00:00:00:03','ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1001'}
870 ingress_map = { 'ether': '00:00:00:00:00:04','ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1002' }
871 for i in range(3):
872 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -0800873 egressPort = egress + self.port_offset,
874 ingressPort = ingress + self.port_offset,
ChetanGaonker720ea612016-06-21 17:54:25 -0700875 icmpv6_type = '4',
876 icmpv6_code = i
877 )
878 result = flow.addFlow()
879 assert_equal(result, True)
880 ##wait for flows to be added to ONOS
881 time.sleep(1)
882 for i in range(3):
883 self.success = False
884 def mac_recv_task():
885 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -0700886 log_test.info('Pkt seen with ICMPv6 type %s, ICMPv6 code %s' %(pkt[ICMPv6ParamProblem].type, pkt[ICMPv6ParamProblem].code))
ChetanGaonker720ea612016-06-21 17:54:25 -0700887 self.success = True
888 sniff(count=2, timeout=5,
889 lfilter = lambda p: ICMPv6ParamProblem in p and p[ICMPv6ParamProblem].type == 4 and p[ICMPv6ParamProblem].code == i,
890 prn = recv_cb, iface = self.port_map[egress])
891
892 t = threading.Thread(target = mac_recv_task)
893 t.start()
894 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
895 L3 = IPv6(src = ingress_map['ipv6'], dst = egress_map['ipv6'])/ICMPv6ParamProblem(code = i)
896 pkt = L2/L3
A R Karthick76a497a2017-04-12 10:59:39 -0700897 log_test.info('Sending packets to verify if flows are correct')
ChetanGaonker720ea612016-06-21 17:54:25 -0700898 sendp(pkt, count=50, iface = self.port_map[ingress])
899 t.join()
900 assert_equal(self.success, True)
901
902 def test_flow_icmpv6_ND_Target_address(self):
903 egress = 1
904 ingress = 2
905 ingress_map = { 'ether': '00:00:00:00:00:04','ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1002'}
906 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -0800907 egressPort = egress + self.port_offset,
908 ingressPort = ingress + self.port_offset,
ChetanGaonker720ea612016-06-21 17:54:25 -0700909 ipv6_target = '2001:db8:a0b:12f0:1010:1010:1010:1001')
910 result = flow.addFlow()
911 assert_equal(result, True)
912 ##wait for flows to be added to ONOS
913 time.sleep(1)
914 self.success = False
915 def mac_recv_task():
916 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -0700917 log_test.info('Pkt seen with ICMPv6 Neighbor Discovery type %s, target address %s' %(pkt[ICMPv6ND_NS].type, pkt[ICMPv6ND_NS].tgt))
ChetanGaonker720ea612016-06-21 17:54:25 -0700918 self.success = True
919 sniff(count=2, timeout=5,
920 lfilter = lambda p: ICMPv6ND_NS in p and p[ICMPv6ND_NS].tgt == '2001:db8:a0b:12f0:1010:1010:1010:1001',
921 prn = recv_cb, iface = self.port_map[egress])
922
923 t = threading.Thread(target = mac_recv_task)
924 t.start()
925 L2 = Ether(src = ingress_map['ether'])
926 L3 = IPv6(src = ingress_map['ipv6'])/ICMPv6ND_NS(tgt = '2001:db8:a0b:12f0:1010:1010:1010:1001')
927 pkt = L2/L3
A R Karthick76a497a2017-04-12 10:59:39 -0700928 log_test.info('Sending packets to verify if flows are correct')
ChetanGaonker720ea612016-06-21 17:54:25 -0700929 sendp(pkt, count=50, iface = self.port_map[ingress])
930 t.join()
931 assert_equal(self.success, True)
932
933 def test_flow_icmpv6_ND_SLL(self):
934 egress = 1
935 ingress = 2
936 egress_map = { 'ether': '00:00:00:00:00:03', 'ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1001'}
937 ingress_map = { 'ether': '00:00:00:00:00:04','ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1002'}
938 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -0800939 egressPort = egress + self.port_offset,
940 ingressPort = ingress + self.port_offset,
ChetanGaonker720ea612016-06-21 17:54:25 -0700941 ipv6_sll = ingress_map['ether'])
942 result = flow.addFlow()
943 assert_equal(result, True)
944 ##wait for flows to be added to ONOS
945 time.sleep(1)
946 self.success = False
947 def mac_recv_task():
948 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -0700949 log_test.info('Pkt seen with ICMPv6 Neighbor Discovery type %s, Source Link Layer address %s' %(pkt[ICMPv6ND_NS].type, pkt[ICMPv6NDOptSrcLLAddr].lladdr))
ChetanGaonker720ea612016-06-21 17:54:25 -0700950 self.success = True
951 sniff(count=2, timeout=5,
952 lfilter = lambda p: ICMPv6NDOptSrcLLAddr in p and p[ICMPv6NDOptSrcLLAddr].lladdr == ingress_map['ether'],
953 prn = recv_cb, iface = self.port_map[egress])
954
955 t = threading.Thread(target = mac_recv_task)
956 t.start()
957 L2 = Ether(src = ingress_map['ether'])#, dst = ingress_map['ether'])
958 L3 = IPv6(src = ingress_map['ipv6'], dst = egress_map['ipv6'])/ICMPv6ND_NS(tgt = egress_map['ipv6'])/ICMPv6NDOptSrcLLAddr(lladdr = ingress_map['ether'])
959 pkt = L2/L3
A R Karthick76a497a2017-04-12 10:59:39 -0700960 log_test.info('Sending packets to verify if flows are correct')
ChetanGaonker720ea612016-06-21 17:54:25 -0700961 sendp(pkt, count=50, iface = self.port_map[ingress])
962 t.join()
963 assert_equal(self.success, True)
964
965 def test_flow_icmpv6_NA_TLL(self):
966 egress = 1
967 ingress = 2
968 egress_map = { 'ether': '00:00:00:00:00:03', 'ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1001'}
969 ingress_map = { 'ether': '00:00:00:00:00:04','ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1002'}
970 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -0800971 egressPort = egress + self.port_offset,
972 ingressPort = ingress + self.port_offset,
ChetanGaonker720ea612016-06-21 17:54:25 -0700973 ipv6_tll = egress_map['ether'])
974 result = flow.addFlow()
975 assert_equal(result, True)
976 ##wait for flows to be added to ONOS
977 time.sleep(1)
978 self.success = False
979 def mac_recv_task():
980 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -0700981 log_test.info('Pkt seen with ICMPv6 Neighbor Advertisement type %s, Target Link Layer address %s' %(pkt[ICMPv6ND_NA].type, pkt[ICMPv6NDOptDstLLAddr].lladdr))
ChetanGaonker720ea612016-06-21 17:54:25 -0700982 self.success = True
983 sniff(count=2, timeout=5,
984 lfilter = lambda p: ICMPv6NDOptDstLLAddr in p and p[ICMPv6NDOptDstLLAddr].lladdr == ingress_map['ether'],
985 prn = recv_cb, iface = self.port_map[egress])
986
987 t = threading.Thread(target = mac_recv_task)
988 t.start()
989 L2 = Ether(src = ingress_map['ether'])#, dst = ingress_map['ether'])
990 L3 = IPv6(src = ingress_map['ipv6'], dst = egress_map['ipv6'])/ICMPv6ND_NA(tgt = ingress_map['ipv6'])/ICMPv6NDOptDstLLAddr(lladdr = ingress_map['ether'])
991 pkt = L2/L3
A R Karthick76a497a2017-04-12 10:59:39 -0700992 log_test.info('Sending packets to verify if flows are correct')
ChetanGaonker720ea612016-06-21 17:54:25 -0700993 sendp(pkt, count=50, iface = self.port_map[ingress])
994 t.join()
995 assert_equal(self.success, True)
996
997 def test_flow_ipv6_and_icmpv6(self):
998 egress = 1
999 ingress = 2
1000 egress_map = { 'ether': '00:00:00:00:00:03', 'ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1001' }
1001 ingress_map = { 'ether': '00:00:00:00:00:04', 'ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1002' }
1002 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -08001003 egressPort = egress + self.port_offset,
1004 ingressPort = ingress + self.port_offset,
ChetanGaonker720ea612016-06-21 17:54:25 -07001005 ethType = '0x86dd',
1006 ipSrc = ('IPV6_SRC', ingress_map['ipv6'] + '/48'),
1007 ipDst = ('IPV6_DST', egress_map['ipv6'] + '/48'),
1008 icmpv6_type = '128',
1009 icmpv6_code = 0
1010 )
1011
1012 result = flow.addFlow()
1013 assert_equal(result, True)
1014 ##wait for flows to be added to ONOS
1015 time.sleep(1)
1016 self.success = False
1017
1018 def mac_recv_task():
1019 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -07001020 log_test.info('Pkt seen with ingress ip %s, egress ip %s' %(pkt[IPv6].src, pkt[IPv6].dst))
ChetanGaonker720ea612016-06-21 17:54:25 -07001021 self.success = True
1022 sniff(count=2, timeout=5,
1023 lfilter = lambda p: IPv6 in p and p[IPv6].dst == egress_map['ipv6'] and p[IPv6].src == ingress_map['ipv6']
1024 and p[ICMPv6EchoRequest].type == 128 and p[ICMPv6EchoRequest].code == 0, prn = recv_cb, iface = self.port_map[egress])
1025
1026 t = threading.Thread(target = mac_recv_task)
1027 t.start()
1028 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
1029 L3 = IPv6(src = ingress_map['ipv6'] , dst = egress_map['ipv6'])/ICMPv6EchoRequest()
1030 pkt = L2/L3
A R Karthick76a497a2017-04-12 10:59:39 -07001031 log_test.info('Sending a packet to verify if flows are correct')
ChetanGaonker720ea612016-06-21 17:54:25 -07001032 sendp(pkt, count=50, iface = self.port_map[ingress])
1033 t.join()
1034 assert_equal(self.success, True)
1035
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001036 def test_5_flow_constant_dst_mac(self):
1037 egress = 1
1038 ingress = 2
1039 egress_mac = '00:00:00:00:01:01'
1040 ingress_mac = '00:00:00:00:00:00'
1041
ChetanGaonker720ea612016-06-21 17:54:25 -07001042
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001043 for i in range(0,5):
1044 ingress_mac = self.next_mac(ingress_mac)
1045
1046 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -08001047 egressPort = egress + self.port_offset,
1048 ingressPort = ingress + self.port_offset,
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001049 ethSrc = ingress_mac,
1050 ethDst = egress_mac)
1051 result = flow.addFlow()
1052 assert_equal(result, True)
1053 ##wait for flows to be added to ONOS
1054 time.sleep(1)
A R Karthick76a497a2017-04-12 10:59:39 -07001055 log_test.info("%d flow added.",i+1)
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001056 self.success = False
1057
1058 def mac_recv_task():
1059 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -07001060 log_test.info('Pkt seen with ingress mac %s, egress mac %s' %(pkt.src, pkt.dst))
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001061 self.success = True
1062 sniff(count=2, timeout=5, lfilter = lambda p: p.src == '00:00:00:00:00:02',
ChetanGaonker720ea612016-06-21 17:54:25 -07001063 prn = recv_cb, iface = self.port_map[egress])
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001064
1065 t = threading.Thread(target = mac_recv_task)
1066 t.start()
1067 pkt = Ether(src = '00:00:00:00:00:02', dst = egress_mac)/IP()
A R Karthick76a497a2017-04-12 10:59:39 -07001068 log_test.info('Sending packets to verify if flows are correct')
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001069 sendp(pkt, count=50, iface = self.port_map[ingress])
1070 t.join()
1071 assert_equal(self.success, True)
1072
1073
1074 def test_500_flow_constant_dst_mac(self):
1075 egress = 1
1076 ingress = 2
1077 egress_mac = '00:00:00:00:01:01'
1078 ingress_mac = '00:00:00:00:00:00'
1079 success_dir = {}
1080
1081 for i in range(0,500):
1082 ingress_mac = self.next_mac(ingress_mac)
1083
1084 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -08001085 egressPort = egress + self.port_offset,
1086 ingressPort = ingress + self.port_offset,
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001087 ethSrc = ingress_mac,
1088 ethDst = egress_mac)
1089 result = flow.addFlow()
1090 assert_equal(result, True)
1091 ##wait for flows to be added to ONOS
1092 time.sleep(1)
A R Karthick76a497a2017-04-12 10:59:39 -07001093 log_test.info("%d flow added.",i+1)
ChetanGaonker720ea612016-06-21 17:54:25 -07001094 self.success = True
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001095
1096 def verify_flow(*r):
1097 random_src = ''.join(r)
1098 def mac_recv_task():
1099 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -07001100 log_test.info('Pkt seen with ingress mac %s, egress mac %s' %(pkt.src, pkt.dst))
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001101 success_dir[current_thread().name] = True
1102 sniff(count=2, timeout=5, lfilter = lambda p: p.src == random_src,
ChetanGaonker720ea612016-06-21 17:54:25 -07001103 prn = recv_cb, iface = self.port_map[egress])
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001104
ChetanGaonker720ea612016-06-21 17:54:25 -07001105 t = threading.Thread(target = mac_recv_task)
1106 t.start()
1107 pkt = Ether(src = random_src, dst = egress_mac)/IP()
A R Karthick76a497a2017-04-12 10:59:39 -07001108 log_test.info('Sending packets to verify if flows are correct')
ChetanGaonker720ea612016-06-21 17:54:25 -07001109 sendp(pkt, count=50, iface = self.port_map[ingress])
1110 t.join()
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001111
1112 t1 = threading.Thread(target = verify_flow, args = '00:00:00:00:00:01')
1113 t2 = threading.Thread(target = verify_flow, args = '00:00:00:00:00:' + hex(random.randrange(50,254)).split('x')[1])
1114 t3 = threading.Thread(target = verify_flow, args = '01:00:00:00:00:' + hex(random.randrange(16,100)).split('x')[1])
1115 t4 = threading.Thread(target = verify_flow, args = '01:00:00:00:00:' + hex(random.randrange(101,240)).split('x')[1])
1116 t5 = threading.Thread(target = verify_flow, args = '01:00:00:00:00:f5')
1117 t1.start()
1118 t2.start()
1119 t3.start()
1120 t4.start()
1121 t5.start()
ChetanGaonker720ea612016-06-21 17:54:25 -07001122
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001123 t1.join()
1124 t2.join()
1125 t3.join()
1126 t4.join()
1127 t5.join()
ChetanGaonker720ea612016-06-21 17:54:25 -07001128
1129 if len(success_dir) != 5:
1130 self.success = False
1131
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001132 assert_equal(self.success, True)
1133
ChetanGaonker720ea612016-06-21 17:54:25 -07001134
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001135 def test_1k_flow_constant_dst_mac(self):
1136 egress = 1
1137 ingress = 2
1138 egress_mac = '00:00:00:00:01:01'
1139 ingress_mac = '00:00:00:00:00:00'
1140 success_dir = {}
1141
1142 for i in range(0,1000):
1143 ingress_mac = self.next_mac(ingress_mac)
ChetanGaonker720ea612016-06-21 17:54:25 -07001144
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001145 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -08001146 egressPort = egress + self.port_offset,
1147 ingressPort = ingress + self.port_offset,
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001148 ethSrc = ingress_mac,
1149 ethDst = egress_mac)
1150 result = flow.addFlow()
1151 assert_equal(result, True)
1152 ##wait for flows to be added to ONOS
1153 time.sleep(1)
A R Karthick76a497a2017-04-12 10:59:39 -07001154 log_test.info("%d flow added.",i+1)
ChetanGaonker720ea612016-06-21 17:54:25 -07001155 self.success = True
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001156
1157 def verify_flow(*r):
1158 random_src = ''.join(r)
1159 def mac_recv_task():
1160 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -07001161 log_test.info('Pkt seen with ingress mac %s, egress mac %s' %(pkt.src, pkt.dst))
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001162 success_dir[current_thread().name] = True
1163 sniff(count=2, timeout=5, lfilter = lambda p: p.src == random_src,
ChetanGaonker720ea612016-06-21 17:54:25 -07001164 prn = recv_cb, iface = self.port_map[egress])
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001165
1166 t = threading.Thread(target = mac_recv_task)
1167 t.start()
1168 pkt = Ether(src = random_src, dst = egress_mac)/IP()
A R Karthick76a497a2017-04-12 10:59:39 -07001169 log_test.info('Sending packets to verify if flows are correct')
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001170 sendp(pkt, count=50, iface = self.port_map[ingress])
1171 t.join()
1172
1173 t1 = threading.Thread(target = verify_flow, args = '00:00:00:00:00:01')
1174 t2 = threading.Thread(target = verify_flow, args = '00:00:00:00:00:' + hex(random.randrange(50,254)).split('x')[1])
1175 t3 = threading.Thread(target = verify_flow, args = '01:00:00:00:00:09')
1176 t4 = threading.Thread(target = verify_flow, args = '01:00:00:00:00:' + hex(random.randrange(16,150)).split('x')[1])
1177 t5 = threading.Thread(target = verify_flow, args = '01:00:00:00:00:' + hex(random.randrange(151,250)).split('x')[1])
1178 t6 = threading.Thread(target = verify_flow, args = '02:00:00:00:00:08')
1179 t7 = threading.Thread(target = verify_flow, args = '02:00:00:00:00:' + hex(random.randrange(16,150)).split('x')[1])
1180 t8 = threading.Thread(target = verify_flow, args = '02:00:00:00:00:' + hex(random.randrange(151,250)).split('x')[1])
1181 t9 = threading.Thread(target = verify_flow, args = '03:00:00:00:00:'+ hex(random.randrange(16,175)).split('x')[1])
1182 t10 = threading.Thread(target = verify_flow, args = '03:00:00:00:00:eb')
1183 t1.start()
1184 t2.start()
1185 t3.start()
1186 t4.start()
1187 t5.start()
1188 t6.start()
1189 t7.start()
1190 t8.start()
1191 t9.start()
1192 t10.start()
1193
1194 t1.join()
1195 t2.join()
1196 t3.join()
1197 t4.join()
1198 t5.join()
1199 t6.join()
1200 t7.join()
1201 t8.join()
1202 t9.join()
1203 t10.join()
ChetanGaonker720ea612016-06-21 17:54:25 -07001204 if len(success_dir) != 10:
1205 self.success = False
1206
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001207 assert_equal(self.success, True)
1208
1209
1210 @nottest
1211 def test_10k_flow_constant_dst_mac(self):
1212 egress = 1
1213 ingress = 2
1214 egress_mac = '00:00:00:00:01:01'
1215 ingress_mac = '00:00:00:00:00:00'
1216 success_dir = {}
1217
ChetanGaonker720ea612016-06-21 17:54:25 -07001218
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001219 for i in range(0,10000):
1220 ingress_mac = self.next_mac(ingress_mac)
1221
1222 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -08001223 egressPort = egress + self.port_offset,
1224 ingressPort = ingress + self.port_offset,
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001225 ethSrc = ingress_mac,
1226 ethDst = egress_mac)
1227 result = flow.addFlow()
1228 assert_equal(result, True)
1229 ##wait for flows to be added to ONOS
1230 time.sleep(1)
A R Karthick76a497a2017-04-12 10:59:39 -07001231 log_test.info("%d flow added.",i+1)
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001232 self.success = True
1233
1234 def verify_flow(*r):
1235 random_src = ''.join(r)
1236 def mac_recv_task():
1237 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -07001238 log_test.info('Pkt seen with ingress mac %s, egress mac %s' %(pkt.src, pkt.dst))
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001239 success_dir[current_thread().name] = True
1240 sniff(count=2, timeout=5, lfilter = lambda p: p.src == random_src,
ChetanGaonker720ea612016-06-21 17:54:25 -07001241 prn = recv_cb, iface = self.port_map[egress])
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001242
1243 t = threading.Thread(target = mac_recv_task)
1244 t.start()
1245 pkt = Ether(src = random_src, dst = egress_mac)/IP()
A R Karthick76a497a2017-04-12 10:59:39 -07001246 log_test.info('Sending packets to verify if flows are correct')
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001247 sendp(pkt, count=50, iface = self.port_map[ingress])
1248 t.join()
1249
1250 t1 = threading.Thread(target = verify_flow, args = '00:00:00:00:00:01')
1251 t2 = threading.Thread(target = verify_flow, args = '01:00:00:00:00:' + hex(random.randrange(16,254)).split('x')[1])
1252 t3 = threading.Thread(target = verify_flow, args = '02:00:00:00:00:'+ hex(random.randrange(16,254)).split('x')[1])
1253 t4 = threading.Thread(target = verify_flow, args = '05:00:00:00:00:' + hex(random.randrange(16,254)).split('x')[1])
1254 t5 = threading.Thread(target = verify_flow, args = '07:00:00:00:00:' + hex(random.randrange(16,254)).split('x')[1])
1255 t6 = threading.Thread(target = verify_flow, args = hex(random.randrange(16,21)).split('x')[1] + ':00:00:00:00:08')
1256 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 -07001257 hex(random.randrange(16,254)).split('x')[1])
1258
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001259 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 -07001260 hex(random.randrange(16,254)).split('x')[1])
1261
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001262 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 -07001263 hex(random.randrange(16,254)).split('x')[1])
1264
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001265 t10 = threading.Thread(target = verify_flow, args = '27:00:00:00:00:37')
1266
1267 t1.start()
1268 t2.start()
1269 t3.start()
1270 t4.start()
1271 t5.start()
1272 t6.start()
1273 t7.start()
1274 t8.start()
1275 t9.start()
1276 t10.start()
1277
1278 t1.join()
1279 t2.join()
1280 t3.join()
1281 t4.join()
1282 t5.join()
1283 t6.join()
1284 t7.join()
1285 t8.join()
1286 t9.join()
1287 t10.join()
ChetanGaonker720ea612016-06-21 17:54:25 -07001288 if len(success_dir) != 10:
1289 self.success = False
1290
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001291 assert_equal(self.success, True)
1292
1293 @nottest
1294 def test_100k_flow_constant_dst_mac(self):
1295 egress = 1
1296 ingress = 2
1297 egress_mac = '00:00:00:00:01:01'
1298 ingress_mac = '00:00:00:00:00:00'
1299 success_dir = {}
1300
1301
1302 for i in range(0,100000):
1303 ingress_mac = self.next_mac(ingress_mac)
1304
1305 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -08001306 egressPort = egress + self.port_offset,
1307 ingressPort = ingress + self.port_offset,
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001308 ethSrc = ingress_mac,
1309 ethDst = egress_mac)
1310 result = flow.addFlow()
1311 assert_equal(result, True)
1312 ##wait for flows to be added to ONOS
1313 time.sleep(1)
A R Karthick76a497a2017-04-12 10:59:39 -07001314 log_test.info("%d flow added.",i+1)
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001315 self.success = True
1316
1317 def verify_flow(*r):
1318 random_src = ''.join(r)
1319 def mac_recv_task():
1320 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -07001321 log_test.info('Pkt seen with ingress mac %s, egress mac %s' %(pkt.src, pkt.dst))
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001322 success_dir[current_thread().name] = True
1323 sniff(count=2, timeout=5, lfilter = lambda p: p.src == random_src,
ChetanGaonker720ea612016-06-21 17:54:25 -07001324 prn = recv_cb, iface = self.port_map[egress])
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001325
1326 t = threading.Thread(target = mac_recv_task)
1327 t.start()
1328 pkt = Ether(src = random_src, dst = egress_mac)/IP()
A R Karthick76a497a2017-04-12 10:59:39 -07001329 log_test.info('Sending packets to verify if flows are correct')
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001330 sendp(pkt, count=50, iface = self.port_map[ingress])
1331 t.join()
1332
1333 t1 = threading.Thread(target = verify_flow, args = '00:00:00:00:00:01')
1334 t2 = threading.Thread(target = verify_flow, args = '01:00:00:00:00:' + hex(random.randrange(16,254)).split('x')[1])
1335 t3 = threading.Thread(target = verify_flow, args = '02:00:00:00:00:'+ hex(random.randrange(16,254)).split('x')[1])
1336 t4 = threading.Thread(target = verify_flow, args = '05:00:00:00:00:' + hex(random.randrange(16,254)).split('x')[1])
1337 t5 = threading.Thread(target = verify_flow, args = '07:00:00:00:00:' + hex(random.randrange(16,254)).split('x')[1])
1338 t6 = threading.Thread(target = verify_flow, args = hex(random.randrange(16,41)).split('x')[1] + ':00:00:00:00:08')
1339 t7 = threading.Thread(target = verify_flow, args = hex(random.randrange(42,72)).split('x')[1] +':00:00:00:00:' +
1340 hex(random.randrange(16,254)).split('x')[1])
1341
1342 t8 = threading.Thread(target = verify_flow, args = hex(random.randrange(73,100)).split('x')[1] +':00:00:00:00:' +
1343 hex(random.randrange(16,254)).split('x')[1])
1344
1345 t9 = threading.Thread(target = verify_flow, args = hex(random.randrange(101,136)).split('x')[1] +':00:00:00:00:' +
1346 hex(random.randrange(16,254)).split('x')[1])
1347
1348 t10 = threading.Thread(target = verify_flow, args = '89:01:00:00:00:28')
1349
1350 t1.start()
1351 t2.start()
1352 t3.start()
1353 t4.start()
1354 t5.start()
1355 t6.start()
1356 t7.start()
1357 t8.start()
1358 t9.start()
1359 t10.start()
1360
1361 t1.join()
1362 t2.join()
1363 t3.join()
1364 t4.join()
1365 t5.join()
1366 t6.join()
1367 t7.join()
1368 t8.join()
1369 t9.join()
1370 t10.join()
ChetanGaonker720ea612016-06-21 17:54:25 -07001371 if len(success_dir) != 10:
1372 self.success = False
1373
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001374 assert_equal(self.success, True)
1375
1376
1377 @nottest
1378 def test_1000k_flow_constant_dst_mac(self):
1379 egress = 1
1380 ingress = 2
1381 egress_mac = '00:00:00:00:01:01'
1382 ingress_mac = '00:00:00:00:00:00'
1383 success_dir = {}
1384
ChetanGaonker720ea612016-06-21 17:54:25 -07001385
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001386 for i in range(0,1000000):
1387 ingress_mac = self.next_mac(ingress_mac)
1388
1389 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -08001390 egressPort = egress + self.port_offset,
1391 ingressPort = ingress + self.port_offset,
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001392 ethSrc = ingress_mac,
1393 ethDst = egress_mac)
1394 result = flow.addFlow()
1395 assert_equal(result, True)
1396 ##wait for flows to be added to ONOS
1397 time.sleep(1)
A R Karthick76a497a2017-04-12 10:59:39 -07001398 log_test.info("%d flow added.",i+1)
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001399 self.success = True
1400
1401 def verify_flow(*r):
1402 random_src = ''.join(r)
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001403 def mac_recv_task():
1404 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -07001405 log_test.info('Pkt seen with ingress mac %s, egress mac %s' %(pkt.src, pkt.dst))
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001406 success_dir[current_thread().name] = True
1407 sniff(count=2, timeout=5, lfilter = lambda p: p.src == random_src,
ChetanGaonker720ea612016-06-21 17:54:25 -07001408 prn = recv_cb, iface = self.port_map[egress])
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001409
1410 t = threading.Thread(target = mac_recv_task)
1411 t.start()
1412 pkt = Ether(src = random_src, dst = egress_mac)/IP()
A R Karthick76a497a2017-04-12 10:59:39 -07001413 log_test.info('Sending packets to verify if flows are correct')
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001414 sendp(pkt, count=50, iface = self.port_map[ingress])
1415 t.join()
1416
1417 t1 = threading.Thread(target = verify_flow, args = '00:00:00:00:00:01')
1418 t2 = threading.Thread(target = verify_flow, args = '01:00:00:00:00:' + hex(random.randrange(16,254)).split('x')[1])
1419 t3 = threading.Thread(target = verify_flow, args = '02:00:00:00:00:'+ hex(random.randrange(16,254)).split('x')[1])
1420 t4 = threading.Thread(target = verify_flow, args = '05:00:00:00:00:' + hex(random.randrange(16,254)).split('x')[1])
1421 t5 = threading.Thread(target = verify_flow, args = '07:00:00:00:00:' + hex(random.randrange(16,254)).split('x')[1])
1422 t6 = threading.Thread(target = verify_flow, args = hex(random.randrange(16,21)).split('x')[1] + ':00:00:00:00:08')
1423 t7 = threading.Thread(target = verify_flow, args = hex(random.randrange(22,50)).split('x')[1] +':00:00:00:00:' +
1424 hex(random.randrange(16,254)).split('x')[1])
1425
1426 t8 = threading.Thread(target = verify_flow, args = hex(random.randrange(51,75)).split('x')[1] +':00:00:00:00:' +
1427 hex(random.randrange(16,254)).split('x')[1])
1428
1429 t9 = threading.Thread(target = verify_flow, args = hex(random.randrange(76,95)).split('x')[1] +':00:00:00:00:' +
1430 hex(random.randrange(16,254)).split('x')[1])
1431
1432 t10 = threading.Thread(target = verify_flow, args = '60:0f:00:00:00:91')
1433
1434 t1.start()
1435 t2.start()
1436 t3.start()
1437 t4.start()
1438 t5.start()
1439 t6.start()
1440 t7.start()
1441 t8.start()
1442 t9.start()
1443 t10.start()
1444
1445 t1.join()
1446 t2.join()
1447 t3.join()
1448 t4.join()
1449 t5.join()
1450 t6.join()
1451 t7.join()
1452 t8.join()
1453 t9.join()
1454 t10.join()
ChetanGaonker720ea612016-06-21 17:54:25 -07001455 if len(success_dir) != 10:
1456 self.success = False
1457
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001458 assert_equal(self.success, True)
1459
ChetanGaonker720ea612016-06-21 17:54:25 -07001460 def test_5_flow_constant_src_mac(self):
1461 egress = 1
1462 ingress = 2
1463 egress_mac = '00:00:00:00:01:00'
1464 ingress_mac = '00:00:00:00:00:01'
1465
1466
1467 for i in range(0,5):
1468 egress_mac = self.next_mac(egress_mac)
1469
1470 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -08001471 egressPort = egress + self.port_offset,
1472 ingressPort = ingress + self.port_offset,
ChetanGaonker720ea612016-06-21 17:54:25 -07001473 ethSrc = ingress_mac,
1474 ethDst = egress_mac)
1475 result = flow.addFlow()
1476 assert_equal(result, True)
1477 ##wait for flows to be added to ONOS
1478 time.sleep(1)
A R Karthick76a497a2017-04-12 10:59:39 -07001479 log_test.info("%d flow added.",i+1)
ChetanGaonker720ea612016-06-21 17:54:25 -07001480 self.success = False
1481
1482 def mac_recv_task():
1483 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -07001484 log_test.info('Pkt seen with ingress mac %s, egress mac %s' %(pkt.src, pkt.dst))
ChetanGaonker720ea612016-06-21 17:54:25 -07001485 self.success = True
1486 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',
1487 prn = recv_cb, iface = self.port_map[egress])
1488
1489 t = threading.Thread(target = mac_recv_task)
1490 t.start()
1491 pkt = Ether(src = ingress_mac, dst = '00:00:00:00:01:02')/IP()
A R Karthick76a497a2017-04-12 10:59:39 -07001492 log_test.info('Sending packets to verify if flows are correct')
ChetanGaonker720ea612016-06-21 17:54:25 -07001493 sendp(pkt, count=50, iface = self.port_map[ingress])
1494 t.join()
1495 assert_equal(self.success, True)
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001496
1497 def test_500_flow_mac(self):
1498 egress = 1
1499 ingress = 2
1500 egress_mac = '00:00:00:00:01:00'
1501 ingress_mac = '00:00:00:00:00:00'
1502 success_dir = {}
1503
1504 for i in range(0,500):
1505 ingress_mac = self.next_mac(ingress_mac)
1506 egress_mac = self.to_egress_mac(ingress_mac)
1507
1508 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -08001509 egressPort = egress + self.port_offset,
1510 ingressPort = ingress + self.port_offset,
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001511 ethSrc = ingress_mac,
1512 ethDst = egress_mac)
1513 result = flow.addFlow()
1514 assert_equal(result, True)
1515 ##wait for flows to be added to ONOS
1516 time.sleep(1)
A R Karthick76a497a2017-04-12 10:59:39 -07001517 log_test.info("%d flow added.",i+1)
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001518 self.success = True
1519 def verify_flow(*r):
1520 random_src = ''.join(r)
ChetanGaonker720ea612016-06-21 17:54:25 -07001521
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001522 def mac_recv_task():
1523 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -07001524 log_test.info('Pkt seen with ingress mac %s, egress mac %s' %(pkt.src, pkt.dst))
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001525 success_dir[current_thread().name] = True
1526 sniff(count=2, timeout=5, lfilter = lambda p: p.src == random_src,
ChetanGaonker720ea612016-06-21 17:54:25 -07001527 prn = recv_cb, iface = self.port_map[egress])
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001528
1529 t = threading.Thread(target = mac_recv_task)
1530 t.start()
1531 pkt = Ether(src = random_src, dst = self.to_egress_mac(random_src))/IP()
A R Karthick76a497a2017-04-12 10:59:39 -07001532 log_test.info('Sending packets to verify if flows are correct')
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001533 sendp(pkt, count=50, iface = self.port_map[ingress])
1534 t.join()
1535
1536 t1 = threading.Thread(target = verify_flow, args = '00:00:00:00:00:01')
1537 t2 = threading.Thread(target = verify_flow, args = '00:00:00:00:00:' + hex(random.randrange(50,254)).split('x')[1])
1538 t3 = threading.Thread(target = verify_flow, args = '01:00:00:00:00:' + hex(random.randrange(16,100)).split('x')[1])
1539 t4 = threading.Thread(target = verify_flow, args = '01:00:00:00:00:' + hex(random.randrange(101,240)).split('x')[1])
1540 t5 = threading.Thread(target = verify_flow, args = '01:00:00:00:00:f5')
1541 t1.start()
1542 t2.start()
1543 t3.start()
1544 t4.start()
1545 t5.start()
1546 t1.join()
1547 t2.join()
1548 t3.join()
1549 t4.join()
1550 t5.join()
ChetanGaonker720ea612016-06-21 17:54:25 -07001551 if len(success_dir) != 5:
1552 self.success = False
1553
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001554 assert_equal(self.success, True)
1555
1556 def test_1k_flow_mac(self):
1557 egress = 1
1558 ingress = 2
1559 egress_mac = '00:00:00:00:01:00'
1560 ingress_mac = '00:00:00:00:00:00'
1561 success_dir = {}
1562
1563 for i in range(0,1000):
1564 ingress_mac = self.next_mac(ingress_mac)
1565 egress_mac = self.to_egress_mac(ingress_mac)
1566
1567 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -08001568 egressPort = egress + self.port_offset,
1569 ingressPort = ingress + self.port_offset,
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001570 ethSrc = ingress_mac,
1571 ethDst = egress_mac)
1572 result = flow.addFlow()
1573 assert_equal(result, True)
1574 ##wait for flows to be added to ONOS
1575 time.sleep(1)
A R Karthick76a497a2017-04-12 10:59:39 -07001576 log_test.info("%d flow added.",i+1)
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001577 self.success = True
1578 def verify_flow(*r):
1579 random_src = ''.join(r)
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001580 def mac_recv_task():
1581 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -07001582 log_test.info('Pkt seen with ingress mac %s, egress mac %s' %(pkt.src, pkt.dst))
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001583 success_dir[current_thread().name] = True
ChetanGaonker720ea612016-06-21 17:54:25 -07001584 sniff(count=2, timeout=5, lfilter = lambda p: p.src == random_src,
1585 prn = recv_cb, iface = self.port_map[egress])
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001586
1587 t = threading.Thread(target = mac_recv_task)
1588 t.start()
ChetanGaonker720ea612016-06-21 17:54:25 -07001589 pkt = Ether(src = random_src, dst = self.to_egress_mac(random_src))/IP()
A R Karthick76a497a2017-04-12 10:59:39 -07001590 log_test.info('Sending packets to verify if flows are correct')
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001591 sendp(pkt, count=50, iface = self.port_map[ingress])
1592 t.join()
1593
1594 t1 = threading.Thread(target = verify_flow, args = '00:00:00:00:00:01')
1595 t2 = threading.Thread(target = verify_flow, args = '00:00:00:00:00:' + hex(random.randrange(50,254)).split('x')[1])
1596 t3 = threading.Thread(target = verify_flow, args = '01:00:00:00:00:09')
1597 t4 = threading.Thread(target = verify_flow, args = '01:00:00:00:00:' + hex(random.randrange(16,150)).split('x')[1])
1598 t5 = threading.Thread(target = verify_flow, args = '01:00:00:00:00:' + hex(random.randrange(151,250)).split('x')[1])
1599 t6 = threading.Thread(target = verify_flow, args = '02:00:00:00:00:08')
1600 t7 = threading.Thread(target = verify_flow, args = '02:00:00:00:00:' + hex(random.randrange(16,150)).split('x')[1])
1601 t8 = threading.Thread(target = verify_flow, args = '02:00:00:00:00:' + hex(random.randrange(151,250)).split('x')[1])
1602 t9 = threading.Thread(target = verify_flow, args = '03:00:00:00:00:'+ hex(random.randrange(16,175)).split('x')[1])
1603 t10 = threading.Thread(target = verify_flow, args = '03:00:00:00:00:eb')
ChetanGaonker720ea612016-06-21 17:54:25 -07001604
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001605 t1.start()
1606 t2.start()
1607 t3.start()
1608 t4.start()
1609 t5.start()
1610 t6.start()
1611 t7.start()
1612 t8.start()
1613 t9.start()
1614 t10.start()
1615
1616 t1.join()
1617 t2.join()
1618 t3.join()
1619 t4.join()
1620 t5.join()
1621 t6.join()
1622 t7.join()
1623 t8.join()
1624 t9.join()
1625 t10.join()
ChetanGaonker720ea612016-06-21 17:54:25 -07001626 if len(success_dir) != 10:
1627 self.success = False
1628
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001629 assert_equal(self.success, True)
1630
1631 @nottest
1632 def test_10k_flow_mac(self):
1633 egress = 1
1634 ingress = 2
1635 egress_mac = '00:00:00:00:01:00'
1636 ingress_mac = '00:00:00:00:00:00'
1637 success_dir = {}
1638
1639 for i in range(0,10000):
ChetanGaonker720ea612016-06-21 17:54:25 -07001640 ingress_mac = self.next_mac(ingress_mac)
1641 egress_mac = self.to_egress_mac(ingress_mac)
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001642
ChetanGaonker720ea612016-06-21 17:54:25 -07001643 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -08001644 egressPort = egress + self.port_offset,
1645 ingressPort = ingress + self.port_offset,
ChetanGaonker720ea612016-06-21 17:54:25 -07001646 ethSrc = ingress_mac,
1647 ethDst = egress_mac)
1648 result = flow.addFlow()
1649 assert_equal(result, True)
1650 ##wait for flows to be added to ONOS
1651 time.sleep(1)
A R Karthick76a497a2017-04-12 10:59:39 -07001652 log_test.info("%d flow added.",i+1)
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001653 self.success = True
1654 def verify_flow(*r):
1655 random_src = ''.join(r)
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001656 def mac_recv_task():
1657 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -07001658 log_test.info('Pkt seen with ingress mac %s, egress mac %s' %(pkt.src, pkt.dst))
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001659 success_dir[current_thread().name] = True
1660 sniff(count=2, timeout=5, lfilter = lambda p: p.src == random_src,
ChetanGaonker720ea612016-06-21 17:54:25 -07001661 prn = recv_cb, iface = self.port_map[egress])
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001662
1663 t = threading.Thread(target = mac_recv_task)
1664 t.start()
1665 pkt = Ether(src = random_src, dst = self.to_egress_mac(random_src))/IP()
A R Karthick76a497a2017-04-12 10:59:39 -07001666 log_test.info('Sending packets to verify if flows are correct')
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001667 sendp(pkt, count=50, iface = self.port_map[ingress])
1668 t.join()
1669
1670 t1 = threading.Thread(target = verify_flow, args = '00:00:00:00:00:01')
1671 t2 = threading.Thread(target = verify_flow, args = '01:00:00:00:00:' + hex(random.randrange(16,254)).split('x')[1])
1672 t3 = threading.Thread(target = verify_flow, args = '02:00:00:00:00:'+ hex(random.randrange(16,254)).split('x')[1])
1673 t4 = threading.Thread(target = verify_flow, args = '05:00:00:00:00:' + hex(random.randrange(16,254)).split('x')[1])
1674 t5 = threading.Thread(target = verify_flow, args = '07:00:00:00:00:' + hex(random.randrange(16,254)).split('x')[1])
1675 t6 = threading.Thread(target = verify_flow, args = hex(random.randrange(16,21)).split('x')[1] + ':00:00:00:00:08')
1676 t7 = threading.Thread(target = verify_flow, args = hex(random.randrange(17,21)).split('x')[1] +':00:00:00:00:' +
1677 hex(random.randrange(16,254)).split('x')[1])
1678
1679 t8 = threading.Thread(target = verify_flow, args = hex(random.randrange(22,30)).split('x')[1] +':00:00:00:00:' +
1680 hex(random.randrange(16,254)).split('x')[1])
1681
1682 t9 = threading.Thread(target = verify_flow, args = hex(random.randrange(31,38)).split('x')[1] +':00:00:00:00:' +
1683 hex(random.randrange(16,254)).split('x')[1])
1684
1685 t10 = threading.Thread(target = verify_flow, args = '27:00:00:00:00:37')
1686
1687 t1.start()
1688 t2.start()
1689 t3.start()
1690 t4.start()
1691 t5.start()
1692 t6.start()
1693 t7.start()
1694 t8.start()
1695 t9.start()
1696 t10.start()
1697
1698 t1.join()
1699 t2.join()
1700 t3.join()
1701 t4.join()
1702 t5.join()
1703 t6.join()
1704 t7.join()
1705 t8.join()
1706 t9.join()
1707 t10.join()
ChetanGaonker720ea612016-06-21 17:54:25 -07001708 if len(success_dir) != 10:
1709 self.success = False
1710
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001711 assert_equal(self.success, True)
1712
1713 @nottest
1714 def test_100k_flow_mac(self):
1715 egress = 1
1716 ingress = 2
1717 egress_mac = '00:00:00:00:01:00'
1718 ingress_mac = '00:00:00:00:00:00'
1719 success_dir = {}
1720
1721 for i in range(0,100000):
1722 ingress_mac = self.next_mac(ingress_mac)
1723 egress_mac = self.to_egress_mac(ingress_mac)
1724
1725 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -08001726 egressPort = egress + self.port_offset,
1727 ingressPort = ingress + self.port_offset,
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001728 ethSrc = ingress_mac,
1729 ethDst = egress_mac)
1730 result = flow.addFlow()
1731 assert_equal(result, True)
1732 ##wait for flows to be added to ONOS
1733 time.sleep(1)
A R Karthick76a497a2017-04-12 10:59:39 -07001734 log_test.info("%d flow added.",i+1)
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001735 self.success = True
1736
1737 def verify_flow(*r):
1738 random_src = ''.join(r)
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001739 def mac_recv_task():
1740 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -07001741 log_test.info('Pkt seen with ingress mac %s, egress mac %s' %(pkt.src, pkt.dst))
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001742 success_dir[current_thread().name] = True
1743 sniff(count=2, timeout=5, lfilter = lambda p: p.src == random_src,
ChetanGaonker720ea612016-06-21 17:54:25 -07001744 prn = recv_cb, iface = self.port_map[egress])
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001745
1746 t = threading.Thread(target = mac_recv_task)
1747 t.start()
1748 pkt = Ether(src = random_src, dst = self.to_egress_mac(random_src))/IP()
A R Karthick76a497a2017-04-12 10:59:39 -07001749 log_test.info('Sending packets to verify if flows are correct')
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001750 sendp(pkt, count=50, iface = self.port_map[ingress])
1751 t.join()
1752
1753 t1 = threading.Thread(target = verify_flow, args = '00:00:00:00:00:01')
1754 t2 = threading.Thread(target = verify_flow, args = '01:00:00:00:00:' + hex(random.randrange(16,254)).split('x')[1])
1755 t3 = threading.Thread(target = verify_flow, args = '02:00:00:00:00:'+ hex(random.randrange(16,254)).split('x')[1])
1756 t4 = threading.Thread(target = verify_flow, args = '05:00:00:00:00:' + hex(random.randrange(16,254)).split('x')[1])
1757 t5 = threading.Thread(target = verify_flow, args = '07:00:00:00:00:' + hex(random.randrange(16,254)).split('x')[1])
1758 t6 = threading.Thread(target = verify_flow, args = hex(random.randrange(16,41)).split('x')[1] + ':00:00:00:00:08')
1759 t7 = threading.Thread(target = verify_flow, args = hex(random.randrange(42,72)).split('x')[1] +':00:00:00:00:' +
1760 hex(random.randrange(16,254)).split('x')[1])
1761
1762 t8 = threading.Thread(target = verify_flow, args = hex(random.randrange(73,100)).split('x')[1] +':00:00:00:00:' +
1763 hex(random.randrange(16,254)).split('x')[1])
1764
1765 t9 = threading.Thread(target = verify_flow, args = hex(random.randrange(101,136)).split('x')[1] +':00:00:00:00:' +
1766 hex(random.randrange(16,254)).split('x')[1])
1767
1768 t10 = threading.Thread(target = verify_flow, args = '89:01:00:00:00:28')
1769
1770 t1.start()
1771 t2.start()
1772 t3.start()
1773 t4.start()
1774 t5.start()
1775 t6.start()
1776 t7.start()
1777 t8.start()
1778 t9.start()
1779 t10.start()
1780
1781 t1.join()
1782 t2.join()
1783 t3.join()
1784 t4.join()
1785 t5.join()
1786 t6.join()
1787 t7.join()
1788 t8.join()
1789 t9.join()
1790 t10.join()
ChetanGaonker720ea612016-06-21 17:54:25 -07001791 if len(success_dir) != 10:
1792 self.success = False
1793
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001794 assert_equal(self.success, True)
1795
1796 @nottest
1797 def test_1000k_flow_mac(self):
1798 egress = 1
1799 ingress = 2
1800 egress_mac = '00:00:00:00:01:00'
1801 ingress_mac = '00:00:00:00:00:00'
1802 success_dir = {}
1803
1804 for i in range(0,1000000):
1805 ingress_mac = self.next_mac(ingress_mac)
1806 egress_mac = self.to_egress_mac(ingress_mac)
1807
1808 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -08001809 egressPort = egress + self.port_offset,
1810 ingressPort = ingress + self.port_offset,
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001811 ethSrc = ingress_mac,
1812 ethDst = egress_mac)
1813 result = flow.addFlow()
1814 assert_equal(result, True)
1815 ##wait for flows to be added to ONOS
1816 time.sleep(1)
A R Karthick76a497a2017-04-12 10:59:39 -07001817 log_test.info("%d flow added.",i+1)
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001818 self.success = True
1819
1820 def verify_flow(*r):
1821 random_src = ''.join(r)
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001822 def mac_recv_task():
ChetanGaonker720ea612016-06-21 17:54:25 -07001823 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -07001824 log_test.info('Pkt seen with ingress mac %s, egress mac %s' %(pkt.src, pkt.dst))
ChetanGaonker720ea612016-06-21 17:54:25 -07001825 success_dir[current_thread().name] = True
1826 sniff(count=2, timeout=5, lfilter = lambda p: p.src == random_src,
1827 prn = recv_cb, iface = self.port_map[egress])
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001828
1829 t = threading.Thread(target = mac_recv_task)
1830 t.start()
1831 pkt = Ether(src = random_src, dst = egress_mac)/IP()
A R Karthick76a497a2017-04-12 10:59:39 -07001832 log_test.info('Sending packets to verify if flows are correct')
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001833 sendp(pkt, count=50, iface = self.port_map[ingress])
1834 t.join()
1835
1836 t1 = threading.Thread(target = verify_flow, args = '00:00:00:00:00:01')
1837 t2 = threading.Thread(target = verify_flow, args = '01:00:00:00:00:' + hex(random.randrange(16,254)).split('x')[1])
1838 t3 = threading.Thread(target = verify_flow, args = '02:00:00:00:00:'+ hex(random.randrange(16,254)).split('x')[1])
1839 t4 = threading.Thread(target = verify_flow, args = '05:00:00:00:00:' + hex(random.randrange(16,254)).split('x')[1])
1840 t5 = threading.Thread(target = verify_flow, args = '07:00:00:00:00:' + hex(random.randrange(16,254)).split('x')[1])
1841 t6 = threading.Thread(target = verify_flow, args = hex(random.randrange(16,21)).split('x')[1] + ':00:00:00:00:08')
1842 t7 = threading.Thread(target = verify_flow, args = hex(random.randrange(22,50)).split('x')[1] +':00:00:00:00:' +
1843 hex(random.randrange(16,254)).split('x')[1])
1844
1845 t8 = threading.Thread(target = verify_flow, args = hex(random.randrange(51,75)).split('x')[1] +':00:00:00:00:' +
1846 hex(random.randrange(16,254)).split('x')[1])
1847
1848 t9 = threading.Thread(target = verify_flow, args = hex(random.randrange(76,95)).split('x')[1] +':00:00:00:00:' +
1849 hex(random.randrange(16,254)).split('x')[1])
1850
1851 t10 = threading.Thread(target = verify_flow, args = '60:0f:00:00:00:91')
1852
1853 t1.start()
1854 t2.start()
1855 t3.start()
1856 t4.start()
1857 t5.start()
1858 t6.start()
1859 t7.start()
1860 t8.start()
1861 t9.start()
1862 t10.start()
1863
1864 t1.join()
1865 t2.join()
1866 t3.join()
1867 t4.join()
1868 t5.join()
1869 t6.join()
1870 t7.join()
1871 t8.join()
1872 t9.join()
1873 t10.join()
ChetanGaonker720ea612016-06-21 17:54:25 -07001874 if len(success_dir) != 10:
1875 self.success = False
1876
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001877 assert_equal(self.success, True)
1878
ChetanGaonkerd376b902016-06-14 11:50:28 -07001879 def test_rate_100_flow_mac(self):
1880 egress = 1
1881 ingress = 2
1882 egress_mac = '00:00:00:00:01:00'
1883 ingress_mac = '00:00:00:00:00:00'
1884 flows_added = 0
1885 stats_dir = collections.OrderedDict()
1886 running_time = 0
1887
1888
1889 for i in range(1,4):
1890 start_time = time.time()
1891 for j in range(0,100):
1892 ingress_mac = self.next_mac(ingress_mac)
1893 egress_mac = self.to_egress_mac(ingress_mac)
1894
1895 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -08001896 egressPort = egress + self.port_offset,
1897 ingressPort = ingress + self.port_offset,
ChetanGaonkerd376b902016-06-14 11:50:28 -07001898 ethSrc = ingress_mac,
1899 ethDst = egress_mac)
1900 result = flow.addFlow()
1901 assert_equal(result, True)
1902 flows_added += 1
1903 ##wait for flows to be added to ONOS
ChetanGaonker720ea612016-06-21 17:54:25 -07001904 time.sleep(1)
A R Karthick76a497a2017-04-12 10:59:39 -07001905 log_test.info("%d flow added.",j+1)
ChetanGaonkerd376b902016-06-14 11:50:28 -07001906 end_time = time.time()
1907 stats_dir['run '+str(i)] = round((end_time - start_time),2)
1908 for t in stats_dir.items():
A R Karthick76a497a2017-04-12 10:59:39 -07001909 log_test.info("----------------------------------------------")
1910 log_test.info("Statics for %s",t[0])
1911 log_test.info("----------------------------------------------")
1912 log_test.info("No. of flows added Running Time ")
1913 log_test.info(" %d %s " %(100, t[1]))
ChetanGaonker720ea612016-06-21 17:54:25 -07001914 running_time += float(t[1])
ChetanGaonkerd376b902016-06-14 11:50:28 -07001915
A R Karthick76a497a2017-04-12 10:59:39 -07001916 log_test.info("-------------------------------------------------------------------------------------------------------")
1917 log_test.info("Final Statics")
1918 log_test.info("-------------------------------------------------------------------------------------------------------")
1919 log_test.info("Total No. of flows added Total Running Time Average no. of flows per second ")
1920 log_test.info(" %d %s second %d "
ChetanGaonkerd376b902016-06-14 11:50:28 -07001921 %(flows_added, running_time, round(flows_added/running_time,0)))
A R Karthick76a497a2017-04-12 10:59:39 -07001922 log_test.info("-------------------------------------------------------------------------------------------------------")
ChetanGaonkerd376b902016-06-14 11:50:28 -07001923
1924
1925
1926 def test_rate_500_flow_mac(self):
1927 egress = 1
1928 ingress = 2
1929 egress_mac = '00:00:00:00:01:00'
1930 ingress_mac = '00:00:00:00:00:00'
1931 flows_added = 0
1932 stats_dir = collections.OrderedDict()
1933 running_time = 0
1934
1935
1936 for i in range(1,4):
1937 start_time = time.time()
1938 for j in range(0,500):
1939 ingress_mac = self.next_mac(ingress_mac)
1940 egress_mac = self.to_egress_mac(ingress_mac)
1941
1942 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -08001943 egressPort = egress + self.port_offset,
1944 ingressPort = ingress + self.port_offset,
ChetanGaonkerd376b902016-06-14 11:50:28 -07001945 ethSrc = ingress_mac,
1946 ethDst = egress_mac)
1947 result = flow.addFlow()
1948 assert_equal(result, True)
1949 flows_added += 1
1950 ##wait for flows to be added to ONOS
ChetanGaonker720ea612016-06-21 17:54:25 -07001951 time.sleep(1)
A R Karthick76a497a2017-04-12 10:59:39 -07001952 log_test.info("%d flow added.",j+1)
ChetanGaonkerd376b902016-06-14 11:50:28 -07001953 end_time = time.time()
1954 stats_dir['run '+str(i)] = round((end_time - start_time),2)
1955 for t in stats_dir.items():
A R Karthick76a497a2017-04-12 10:59:39 -07001956 log_test.info("----------------------------------------------")
1957 log_test.info("Statics for %s",t[0])
1958 log_test.info("----------------------------------------------")
1959 log_test.info("No. of flows added Running Time ")
1960 log_test.info(" %d %s " %(500, t[1]))
ChetanGaonkerd376b902016-06-14 11:50:28 -07001961 running_time += float(t[1])
1962
A R Karthick76a497a2017-04-12 10:59:39 -07001963 log_test.info("-------------------------------------------------------------------------------------------------------")
1964 log_test.info("Final Statics")
1965 log_test.info("-------------------------------------------------------------------------------------------------------")
1966 log_test.info("Total No. of flows added Total Running Time Average no. of flows per second ")
1967 log_test.info(" %d %s second %d "
ChetanGaonkerd376b902016-06-14 11:50:28 -07001968 %(flows_added, running_time, round(flows_added/running_time,0)))
A R Karthick76a497a2017-04-12 10:59:39 -07001969 log_test.info("-------------------------------------------------------------------------------------------------------")
ChetanGaonkerd376b902016-06-14 11:50:28 -07001970
1971 def test_rate_1k_flow_mac(self):
1972 egress = 1
1973 ingress = 2
1974 egress_mac = '00:00:00:00:01:00'
1975 ingress_mac = '00:00:00:00:00:00'
1976 flows_added = 0
1977 stats_dir = collections.OrderedDict()
1978 running_time = 0
1979
1980
1981 for i in range(1,4):
1982 start_time = time.time()
1983 for j in range(0,1000):
1984 ingress_mac = self.next_mac(ingress_mac)
1985 egress_mac = self.to_egress_mac(ingress_mac)
1986
1987 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -08001988 egressPort = egress + self.port_offset,
1989 ingressPort = ingress + self.port_offset,
ChetanGaonkerd376b902016-06-14 11:50:28 -07001990 ethSrc = ingress_mac,
1991 ethDst = egress_mac)
1992 result = flow.addFlow()
1993 assert_equal(result, True)
1994 flows_added += 1
ChetanGaonker720ea612016-06-21 17:54:25 -07001995 ##wait for flows to be added to ONOS
1996 time.sleep(1)
A R Karthick76a497a2017-04-12 10:59:39 -07001997 log_test.info("%d flow added.",j+1)
ChetanGaonkerd376b902016-06-14 11:50:28 -07001998 end_time = time.time()
1999 stats_dir['run '+str(i)] = round((end_time - start_time),2)
2000 for t in stats_dir.items():
A R Karthick76a497a2017-04-12 10:59:39 -07002001 log_test.info("----------------------------------------------")
2002 log_test.info("Statics for %s",t[0])
2003 log_test.info("----------------------------------------------")
2004 log_test.info("No. of flows added Running Time ")
2005 log_test.info(" %d %s " %(1000, t[1]))
ChetanGaonkerd376b902016-06-14 11:50:28 -07002006 running_time += float(t[1])
2007
A R Karthick76a497a2017-04-12 10:59:39 -07002008 log_test.info("-------------------------------------------------------------------------------------------------------")
2009 log_test.info("Final Statics")
2010 log_test.info("-------------------------------------------------------------------------------------------------------")
2011 log_test.info("Total No. of flows added Total Running Time Average no. of flows per second ")
2012 log_test.info(" %d %s second %d "
ChetanGaonkerd376b902016-06-14 11:50:28 -07002013 %(flows_added, running_time, round(flows_added/running_time,0)))
A R Karthick76a497a2017-04-12 10:59:39 -07002014 log_test.info("-------------------------------------------------------------------------------------------------------")
ChetanGaonkerd376b902016-06-14 11:50:28 -07002015
2016
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002017 def test_500_flow_ip(self):
2018 egress = 1
2019 ingress = 2
2020 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '182.0.0.0' }
2021 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.0.0.0' }
ChetanGaonker720ea612016-06-21 17:54:25 -07002022 success_dir = {}
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002023
2024 for i in range(0,500):
2025 ingress_map['ip'] = self.next_ip(ingress_map['ip'])
2026 assert_not_equal(ingress_map['ip'], None)
2027 egress_map['ip'] = self.to_egress_ip(ingress_map['ip'])
2028
2029 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -08002030 egressPort = egress + self.port_offset,
2031 ingressPort = ingress + self.port_offset,
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002032 ethType = '0x0800',
2033 ipSrc = ('IPV4_SRC', ingress_map['ip']+'/8'),
2034 ipDst = ('IPV4_DST', egress_map['ip']+'/8')
2035 )
2036 result = flow.addFlow()
2037 assert_equal(result, True)
2038 ##wait for flows to be added to ONOS
2039 time.sleep(1)
A R Karthick76a497a2017-04-12 10:59:39 -07002040 log_test.info("%d flow added.",i+1)
ChetanGaonker720ea612016-06-21 17:54:25 -07002041 self.success = True
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002042
ChetanGaonker720ea612016-06-21 17:54:25 -07002043 def verify_flow(*r):
2044 random_src = ''.join(r)
2045 random_dst = self.to_egress_ip(random_src)
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002046
ChetanGaonker720ea612016-06-21 17:54:25 -07002047 def mac_recv_task():
2048 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -07002049 log_test.info('Pkt seen with ingress ip %s, egress ip %s' %(pkt[IP].src, pkt[IP].dst))
ChetanGaonker720ea612016-06-21 17:54:25 -07002050 success_dir[current_thread().name] = True
2051
2052 sniff(count=2, timeout=5, lfilter = lambda p: IP in p and p[IP].dst == random_dst and p[IP].src == random_src
2053 ,prn = recv_cb, iface = self.port_map[egress])
2054
2055 t = threading.Thread(target = mac_recv_task)
2056 t.start()
2057 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
2058 L3 = IP(src = random_src, dst = random_dst)
2059 pkt = L2/L3
A R Karthick76a497a2017-04-12 10:59:39 -07002060 log_test.info('Sending packets to verify if flows are correct')
ChetanGaonker720ea612016-06-21 17:54:25 -07002061 sendp(pkt, count=50, iface = self.port_map[ingress])
2062 t.join()
2063
2064 t1 = threading.Thread(target = verify_flow, args = '192.0.0.1')
2065 t2 = threading.Thread(target = verify_flow, args = '192.0.0.' + str(random.randrange(10,100,1)))
2066 t3 = threading.Thread(target = verify_flow, args = '192.0.0.' + str(random.randrange(101,255,1)))
2067 t4 = threading.Thread(target = verify_flow, args = '192.0.1.' + str(random.randrange(1,235,1)))
2068 t5 = threading.Thread(target = verify_flow, args = '192.0.1.244')
2069 t1.start()
2070 t2.start()
2071 t3.start()
2072 t4.start()
2073 t5.start()
2074
2075 t1.join()
2076 t2.join()
2077 t3.join()
2078 t4.join()
2079 t5.join()
2080
2081 if len(success_dir) < 5 or len(success_dir) > 5:
2082 self.success = False
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002083 assert_equal(self.success, True)
2084
ChetanGaonker720ea612016-06-21 17:54:25 -07002085
2086 @nottest
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002087 def test_1k_flow_ip(self):
2088 egress = 1
2089 ingress = 2
2090 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '182.0.0.0' }
2091 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.0.0.0' }
ChetanGaonker720ea612016-06-21 17:54:25 -07002092 success_dir ={}
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002093
2094 for i in range(0,1000):
2095 ingress_map['ip'] = self.next_ip(ingress_map['ip'])
2096 assert_not_equal(ingress_map['ip'], None)
2097 egress_map['ip'] = self.to_egress_ip(ingress_map['ip'])
2098
2099 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -08002100 egressPort = egress + self.port_offset,
2101 ingressPort = ingress + self.port_offset,
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002102 ethType = '0x0800',
2103 ipSrc = ('IPV4_SRC', ingress_map['ip']+'/8'),
2104 ipDst = ('IPV4_DST', egress_map['ip']+'/8')
2105 )
2106 result = flow.addFlow()
2107 assert_equal(result, True)
2108 ##wait for flows to be added to ONOS
2109 time.sleep(1)
A R Karthick76a497a2017-04-12 10:59:39 -07002110 log_test.info("%d flow added.",i+1)
ChetanGaonker720ea612016-06-21 17:54:25 -07002111 self.success = True
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002112
ChetanGaonker720ea612016-06-21 17:54:25 -07002113 def verify_flow(*r):
2114 random_src = ''.join(r)
2115 random_dst = self.to_egress_ip(random_src)
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002116
ChetanGaonker720ea612016-06-21 17:54:25 -07002117 def mac_recv_task():
2118 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -07002119 log_test.info('Pkt seen with ingress ip %s, egress ip %s' %(pkt[IP].src, pkt[IP].dst))
ChetanGaonker720ea612016-06-21 17:54:25 -07002120 success_dir[current_thread().name] = True
2121
2122 sniff(count=2, timeout=5, lfilter = lambda p: IP in p and p[IP].dst == random_dst and p[IP].src == random_src
2123 ,prn = recv_cb, iface = self.port_map[egress])
2124
2125 t = threading.Thread(target = mac_recv_task)
2126 t.start()
2127 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
2128 L3 = IP(src = random_src, dst = random_dst)
2129 pkt = L2/L3
A R Karthick76a497a2017-04-12 10:59:39 -07002130 log_test.info('Sending packets to verify if flows are correct')
ChetanGaonker720ea612016-06-21 17:54:25 -07002131 sendp(pkt, count=50, iface = self.port_map[ingress])
2132 t.join()
2133
2134 t1 = threading.Thread(target = verify_flow, args = '192.0.0.1')
2135 t2 = threading.Thread(target = verify_flow, args = '192.0.0.' + str(random.randrange(10,255,1)))
2136 t3 = threading.Thread(target = verify_flow, args = '192.0.1.' + str(random.randrange(1,100,1)))
2137 t4 = threading.Thread(target = verify_flow, args = '192.0.1.' + str(random.randrange(101,255,1)))
2138 t5 = threading.Thread(target = verify_flow, args = '192.0.2.' + str(random.randrange(1,100,1)))
2139 t6 = threading.Thread(target = verify_flow, args = '192.0.2.' + str(random.randrange(101,255,1)))
2140 t7 = threading.Thread(target = verify_flow, args = '192.0.3.' + str(random.randrange(1,100,1)))
2141 t8 = threading.Thread(target = verify_flow, args = '192.0.3.' + str(random.randrange(101,200,1)))
2142 t9 = threading.Thread(target = verify_flow, args = '192.0.'+ str(random.randrange(0,3,1)) + '.' +
2143 str(random.randrange(1,255,1)))
2144 t10 = threading.Thread(target = verify_flow, args = '192.0.3.232')
2145
2146 t1.start()
2147 t2.start()
2148 t3.start()
2149 t4.start()
2150 t5.start()
2151 t6.start()
2152 t7.start()
2153 t8.start()
2154 t9.start()
2155 t10.start()
2156
2157 t1.join()
2158 t2.join()
2159 t3.join()
2160 t4.join()
2161 t5.join()
2162 t6.join()
2163 t7.join()
2164 t8.join()
2165 t9.join()
2166 t10.join()
2167
2168 if len(success_dir) != 10:
2169 self.success = False
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002170 assert_equal(self.success, True)
2171
2172 @nottest
2173 def test_10k_flow_ip(self):
2174 egress = 1
2175 ingress = 2
2176 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '182.0.0.0' }
2177 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.0.0.0' }
ChetanGaonker720ea612016-06-21 17:54:25 -07002178 success_dir = {}
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002179
2180 for i in range(0,10000):
2181 ingress_map['ip'] = self.next_ip(ingress_map['ip'])
2182 assert_not_equal(ingress_map['ip'], None)
2183 egress_map['ip'] = self.to_egress_ip(ingress_map['ip'])
2184
2185 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -08002186 egressPort = egress + self.port_offset,
2187 ingressPort = ingress + self.port_offset,
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002188 ethType = '0x0800',
2189 ipSrc = ('IPV4_SRC', ingress_map['ip']+'/8'),
2190 ipDst = ('IPV4_DST', egress_map['ip']+'/8')
2191 )
2192 result = flow.addFlow()
2193 assert_equal(result, True)
2194 ##wait for flows to be added to ONOS
2195 time.sleep(1)
A R Karthick76a497a2017-04-12 10:59:39 -07002196 log_test.info("%d flow added.",i+1)
ChetanGaonker720ea612016-06-21 17:54:25 -07002197 self.success = True
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002198
ChetanGaonker720ea612016-06-21 17:54:25 -07002199 def verify_flow(*r):
2200 random_src = ''.join(r)
2201 random_dst = self.to_egress_ip(random_src)
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002202
ChetanGaonker720ea612016-06-21 17:54:25 -07002203 def mac_recv_task():
2204 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -07002205 log_test.info('Pkt seen with ingress ip %s, egress ip %s' %(pkt[IP].src, pkt[IP].dst))
ChetanGaonker720ea612016-06-21 17:54:25 -07002206 success_dir[current_thread().name] = True
2207 sniff(count=2, timeout=5, lfilter = lambda p: IP in p and p[IP].dst == random_dst and p[IP].src == random_src
2208 ,prn = recv_cb, iface = self.port_map[egress])
2209
2210 t = threading.Thread(target = mac_recv_task)
2211 t.start()
2212 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
2213 L3 = IP(src = random_src, dst = random_dst)
2214 pkt = L2/L3
A R Karthick76a497a2017-04-12 10:59:39 -07002215 log_test.info('Sending packets to verify if flows are correct')
ChetanGaonker720ea612016-06-21 17:54:25 -07002216 sendp(pkt, count=50, iface = self.port_map[ingress])
2217 t.join()
2218
2219 t1 = threading.Thread(target = verify_flow, args = '192.0.0.1')
2220 t2 = threading.Thread(target = verify_flow, args = '192.0.0.' + str(random.randrange(1,255,1)))
2221 t3 = threading.Thread(target = verify_flow, args = '192.0.5.' + str(random.randrange(1,255,1)))
2222 t4 = threading.Thread(target = verify_flow, args = '192.0.10.' + str(random.randrange(1,255,1)))
2223 t5 = threading.Thread(target = verify_flow, args = '192.0.15.' + str(random.randrange(1,255,1)))
2224 t6 = threading.Thread(target = verify_flow, args = '192.0.20.' + str(random.randrange(1,255,1)))
2225 t7 = threading.Thread(target = verify_flow, args = '192.0.25.' + str(random.randrange(1,255,1)))
2226 t8 = threading.Thread(target = verify_flow, args = '192.0.30.' + str(random.randrange(1,255,1)))
2227 t9 = threading.Thread(target = verify_flow, args = '192.0.'+ str(random.randrange(0,39,1)) + '.' +
2228 str(random.randrange(1,255,1)))
2229 t10 = threading.Thread(target = verify_flow, args = '192.0.39.16')
2230
2231 t1.start()
2232 t2.start()
2233 t3.start()
2234 t4.start()
2235 t5.start()
2236 t6.start()
2237 t7.start()
2238 t8.start()
2239 t9.start()
2240 t10.start()
2241
2242 t1.join()
2243 t2.join()
2244 t3.join()
2245 t4.join()
2246 t5.join()
2247 t6.join()
2248 t7.join()
2249 t8.join()
2250 t9.join()
2251 t10.join()
2252
2253 if len(success_dir) != 10:
2254 self.success = False
2255
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002256 assert_equal(self.success, True)
2257
2258 @nottest
2259 def test_100k_flow_ip(self):
2260 egress = 1
2261 ingress = 2
2262 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '182.0.0.0' }
2263 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.0.0.0' }
ChetanGaonker720ea612016-06-21 17:54:25 -07002264 success_dir = {}
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002265
2266 for i in range(0,100000):
2267 ingress_map['ip'] = self.next_ip(ingress_map['ip'])
2268 assert_not_equal(ingress_map['ip'], None)
2269 egress_map['ip'] = self.to_egress_ip(ingress_map['ip'])
2270
2271 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -08002272 egressPort = egress + self.port_offset,
2273 ingressPort = ingress + self.port_offset,
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002274 ethType = '0x0800',
2275 ipSrc = ('IPV4_SRC', ingress_map['ip']+'/8'),
2276 ipDst = ('IPV4_DST', egress_map['ip']+'/8')
2277 )
2278 result = flow.addFlow()
2279 assert_equal(result, True)
2280 ##wait for flows to be added to ONOS
2281 time.sleep(1)
A R Karthick76a497a2017-04-12 10:59:39 -07002282 log_test.info("%d flow added.",i+1)
ChetanGaonker720ea612016-06-21 17:54:25 -07002283 self.success = True
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002284
ChetanGaonker720ea612016-06-21 17:54:25 -07002285 def verify_flow(*r):
2286 random_src = ''.join(r)
2287 random_dst = self.to_egress_ip(random_src)
2288 def mac_recv_task():
2289 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -07002290 log_test.info('Pkt seen with ingress ip %s, egress ip %s' %(pkt[IP].src, pkt[IP].dst))
ChetanGaonker720ea612016-06-21 17:54:25 -07002291 success_dir[current_thread().name] = True
2292 sniff(count=2, timeout=5, lfilter = lambda p: IP in p and p[IP].dst == random_dst and p[IP].src == random_src
2293 ,prn = recv_cb, iface = self.port_map[egress])
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002294
ChetanGaonker720ea612016-06-21 17:54:25 -07002295 t = threading.Thread(target = mac_recv_task)
2296 t.start()
2297 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
2298 L3 = IP(src = random_src, dst = random_dst)
2299 pkt = L2/L3
A R Karthick76a497a2017-04-12 10:59:39 -07002300 log_test.info('Sending packets to verify if flows are correct')
ChetanGaonker720ea612016-06-21 17:54:25 -07002301 sendp(pkt, count=50, iface = self.port_map[ingress])
2302 t.join()
2303
2304 t1 = threading.Thread(target = verify_flow, args = '192.0.0.1')
2305 t2 = threading.Thread(target = verify_flow, args = '192.0.0.' + str(random.randrange(1,255,1)))
2306 t3 = threading.Thread(target = verify_flow, args = '192.0.50.' + str(random.randrange(1,255,1)))
2307 t4 = threading.Thread(target = verify_flow, args = '192.0.100.' + str(random.randrange(1,255,1)))
2308 t5 = threading.Thread(target = verify_flow, args = '192.0.150.' + str(random.randrange(1,255,1)))
2309 t6 = threading.Thread(target = verify_flow, args = '192.0.200.' + str(random.randrange(1,255,1)))
2310 t7 = threading.Thread(target = verify_flow, args = '192.0.250.' + str(random.randrange(1,255,1)))
2311 t8 = threading.Thread(target = verify_flow, args = '192.1.'+str(random.randrange(1,75,1)) + '.'
2312 + str(random.randrange(1,255,1)))
2313 t9 = threading.Thread(target = verify_flow, args = '192.1.'+str(random.randrange(76,134,1)) + '.'
2314 + str(random.randrange(1,255,1)))
2315 t10 = threading.Thread(target = verify_flow, args = '192.1.134.160')
2316
2317 t1.start()
2318 t2.start()
2319 t3.start()
2320 t4.start()
2321 t5.start()
2322 t6.start()
2323 t7.start()
2324 t8.start()
2325 t9.start()
2326 t10.start()
2327
2328 t1.join()
2329 t2.join()
2330 t3.join()
2331 t4.join()
2332 t5.join()
2333 t6.join()
2334 t7.join()
2335 t8.join()
2336 t9.join()
2337 t10.join()
2338
2339 if len(success_dir) != 10:
2340 self.success = False
2341
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002342 assert_equal(self.success, True)
2343
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002344 @nottest
2345 def test_1000k_flow_ip(self):
2346 egress = 1
2347 ingress = 2
2348 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '182.0.0.0' }
2349 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.0.0.0' }
ChetanGaonker720ea612016-06-21 17:54:25 -07002350 success_dir = {}
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002351
2352 for i in range(0,1000000):
2353 ingress_map['ip'] = self.next_ip(ingress_map['ip'])
2354 assert_not_equal(ingress_map['ip'], None)
2355 egress_map['ip'] = self.to_egress_ip(ingress_map['ip'])
2356
2357 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -08002358 egressPort = egress + self.port_offset,
2359 ingressPort = ingress + self.port_offset,
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002360 ethType = '0x0800',
2361 ipSrc = ('IPV4_SRC', ingress_map['ip']+'/8'),
2362 ipDst = ('IPV4_DST', egress_map['ip']+'/8')
2363 )
2364 result = flow.addFlow()
2365 assert_equal(result, True)
2366 ##wait for flows to be added to ONOS
2367 time.sleep(1)
A R Karthick76a497a2017-04-12 10:59:39 -07002368 log_test.info("%d flow added.",i+1)
ChetanGaonker720ea612016-06-21 17:54:25 -07002369 self.success = True
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002370
ChetanGaonker720ea612016-06-21 17:54:25 -07002371 def verify_flow(*r):
2372 random_src = ''.join(r)
2373 random_dst = self.to_egress_ip(random_src)
2374 def mac_recv_task():
2375 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -07002376 log_test.info('Pkt seen with ingress ip %s, egress ip %s' %(pkt[IP].src, pkt[IP].dst))
ChetanGaonker720ea612016-06-21 17:54:25 -07002377 success_dir[current_thread().name] = True
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002378
ChetanGaonker720ea612016-06-21 17:54:25 -07002379 sniff(count=2, timeout=5, lfilter = lambda p: IP in p and p[IP].dst == random_dst and p[IP].src == random_src
2380 ,prn = recv_cb, iface = self.port_map[egress])
2381
2382 t = threading.Thread(target = mac_recv_task)
2383 t.start()
2384 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
2385 L3 = IP(src = random_src, dst = random_dst)
2386 pkt = L2/L3
A R Karthick76a497a2017-04-12 10:59:39 -07002387 log_test.info('Sending packets to verify if flows are correct')
ChetanGaonker720ea612016-06-21 17:54:25 -07002388 sendp(pkt, count=50, iface = self.port_map[ingress])
2389 t.join()
2390
2391 t1 = threading.Thread(target = verify_flow, args = '192.0.0.1')
2392 t2 = threading.Thread(target = verify_flow, args = '192.0.50.' + str(random.randrange(1,255,1)))
2393 t3 = threading.Thread(target = verify_flow, args = '192.0.100.' + str(random.randrange(1,255,1)))
2394 t4 = threading.Thread(target = verify_flow, args = '192.0.150.' + str(random.randrange(1,255,1)))
2395 t5 = threading.Thread(target = verify_flow, args = '192.0.200.' + str(random.randrange(1,255,1)))
2396 t6 = threading.Thread(target = verify_flow, args = '192.0.250.' + str(random.randrange(1,255,1)))
2397 t7 = threading.Thread(target = verify_flow, args = '192.0.250.' + str(random.randrange(1,255,1)))
2398 t8 = threading.Thread(target = verify_flow, args = '192.1.'+str(random.randrange(1,150,1)) + '.'
2399 + str(random.randrange(1,255,1)))
2400 t9 = threading.Thread(target = verify_flow, args = '192.1.'+str(random.randrange(152,255,1)) + '.'
2401 + str(random.randrange(1,255,1)))
2402 t10 = threading.Thread(target = verify_flow, args = '192.15.66.64')
2403
2404 t1.start()
2405 t2.start()
2406 t3.start()
2407 t4.start()
2408 t5.start()
2409 t6.start()
2410 t7.start()
2411 t8.start()
2412 t9.start()
2413 t10.start()
2414
2415 t1.join()
2416 t2.join()
2417 t3.join()
2418 t4.join()
2419 t5.join()
2420 t6.join()
2421 t7.join()
2422 t8.join()
2423 t9.join()
2424 t10.join()
2425
2426 if len(success_dir) != 10:
2427 self.success = False
2428
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002429 assert_equal(self.success, True)
2430
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002431 def test_500_flow_tcp_port(self):
2432 egress = 1
2433 ingress = 2
2434 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '192.168.30.1', 'tcp_port': 3100 }
2435 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.168.40.1', 'tcp_port': 1100 }
ChetanGaonker720ea612016-06-21 17:54:25 -07002436 success_dir = {}
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002437
2438 for i in range(0,500):
2439 ingress_map['tcp_port'] += 1
2440 egress_map['tcp_port'] += 1
2441
2442 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -08002443 egressPort = egress + self.port_offset,
2444 ingressPort = ingress + self.port_offset,
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002445 tcpSrc = ingress_map['tcp_port'],
2446 tcpDst = egress_map['tcp_port']
2447 )
2448
2449 result = flow.addFlow()
2450 assert_equal(result, True)
2451 ##wait for flows to be added to ONOS
2452 time.sleep(1)
A R Karthick76a497a2017-04-12 10:59:39 -07002453 log_test.info("%d Flow added",i+1)
ChetanGaonker720ea612016-06-21 17:54:25 -07002454 self.success = True
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002455
ChetanGaonker720ea612016-06-21 17:54:25 -07002456 def verify_flow(*r):
2457 random_sport = int(''.join(r))
2458 random_dport = random_sport + 2000
2459 def mac_recv_task():
2460 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -07002461 log_test.info('Pkt seen with ingress TCP port %s, egress TCP port %s' %(pkt[TCP].sport, pkt[TCP].dport))
ChetanGaonker720ea612016-06-21 17:54:25 -07002462 success_dir[current_thread().name] = True
2463 sniff(count=2, timeout=5,
2464 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 -07002465
ChetanGaonker720ea612016-06-21 17:54:25 -07002466 t = threading.Thread(target = mac_recv_task)
2467 t.start()
2468 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
2469 L3 = IP(src = ingress_map['ip'], dst = egress_map['ip'])
2470 L4 = TCP(sport = random_sport, dport = random_dport)
2471 pkt = L2/L3/L4
A R Karthick76a497a2017-04-12 10:59:39 -07002472 log_test.info('Sending packets to verify if flows are correct')
ChetanGaonker720ea612016-06-21 17:54:25 -07002473 sendp(pkt, count=50, iface = self.port_map[ingress])
2474 t.join()
2475 t1 = threading.Thread(target = verify_flow, args = str(1101))
2476 t2 = threading.Thread(target = verify_flow, args = str(random.randrange(1110,1250,1)))
2477 t3 = threading.Thread(target = verify_flow, args = str(random.randrange(1251,1400,1)))
2478 t4 = threading.Thread(target = verify_flow, args = str(random.randrange(1401,1590,1)))
2479 t5 = threading.Thread(target = verify_flow, args = str(1600))
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002480
ChetanGaonker720ea612016-06-21 17:54:25 -07002481 t1.start()
2482 t2.start()
2483 t3.start()
2484 t4.start()
2485 t5.start()
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002486
ChetanGaonker720ea612016-06-21 17:54:25 -07002487 t1.join()
2488 t2.join()
2489 t3.join()
2490 t4.join()
2491 t5.join()
2492
2493 if len(success_dir) != 5:
2494 self.success = False
2495
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002496 assert_equal(self.success, True)
2497
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002498 def test_1k_flow_tcp_port(self):
2499 egress = 1
2500 ingress = 2
2501 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '192.168.30.1', 'tcp_port': 3100 }
2502 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.168.40.1', 'tcp_port': 1100 }
ChetanGaonker720ea612016-06-21 17:54:25 -07002503 success_dir = {}
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002504
2505 for i in range(0,1000):
2506 ingress_map['tcp_port'] += 1
2507 egress_map['tcp_port'] += 1
2508
2509 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -08002510 egressPort = egress + self.port_offset,
2511 ingressPort = ingress + self.port_offset,
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002512 tcpSrc = ingress_map['tcp_port'],
2513 tcpDst = egress_map['tcp_port']
2514 )
2515
2516 result = flow.addFlow()
2517 assert_equal(result, True)
2518 ##wait for flows to be added to ONOS
2519 time.sleep(1)
A R Karthick76a497a2017-04-12 10:59:39 -07002520 log_test.info("%d flow added.",i+1)
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002521
ChetanGaonker720ea612016-06-21 17:54:25 -07002522 self.success = True
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002523
ChetanGaonker720ea612016-06-21 17:54:25 -07002524 def verify_flow(*r):
2525 random_sport = int(''.join(r))
2526 random_dport = random_sport + 2000
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002527
ChetanGaonker720ea612016-06-21 17:54:25 -07002528 def mac_recv_task():
2529 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -07002530 log_test.info('Pkt seen with ingress TCP port %s, egress TCP port %s' %(pkt[TCP].sport, pkt[TCP].dport))
ChetanGaonker720ea612016-06-21 17:54:25 -07002531 success_dir[current_thread().name] = True
2532 sniff(count=2, timeout=5,
2533 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 -07002534
ChetanGaonker720ea612016-06-21 17:54:25 -07002535 t = threading.Thread(target = mac_recv_task)
2536 t.start()
2537 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
2538 L3 = IP(src = ingress_map['ip'], dst = egress_map['ip'])
2539 L4 = TCP(sport = random_sport, dport = random_dport)
2540 pkt = L2/L3/L4
A R Karthick76a497a2017-04-12 10:59:39 -07002541 log_test.info('Sending packets to verify if flows are correct')
ChetanGaonker720ea612016-06-21 17:54:25 -07002542 sendp(pkt, count=50, iface = self.port_map[ingress])
2543 t.join()
2544
2545 t1 = threading.Thread(target = verify_flow, args = str(1101))
2546 t2 = threading.Thread(target = verify_flow, args = str(random.randrange(1110,1350,1)))
2547 t3 = threading.Thread(target = verify_flow, args = str(random.randrange(1351,1500,1)))
2548 t4 = threading.Thread(target = verify_flow, args = str(random.randrange(1501,1700,1)))
2549 t5 = threading.Thread(target = verify_flow, args = str(random.randrange(1701,1900,1)))
2550 t6 = threading.Thread(target = verify_flow, args = str(random.randrange(1901,2000,1)))
2551 t7 = threading.Thread(target = verify_flow, args = str(random.randrange(2000,2050,1)))
2552 t8 = threading.Thread(target = verify_flow, args = str(random.randrange(2050,2080,1)))
2553 t9 = threading.Thread(target = verify_flow, args = str(random.randrange(1102,2100,1)))
2554 t10 = threading.Thread(target = verify_flow, args = str(2100))
2555
2556
2557 t1.start()
2558 t2.start()
2559 t3.start()
2560 t4.start()
2561 t5.start()
2562 t6.start()
2563 t7.start()
2564 t8.start()
2565 t9.start()
2566 t10.start()
2567
2568 t1.join()
2569 t2.join()
2570 t3.join()
2571 t4.join()
2572 t5.join()
2573 t6.join()
2574 t7.join()
2575 t8.join()
2576 t9.join()
2577 t10.join()
2578
2579 if len(success_dir) != 10:
2580 self.success = False
2581
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002582 assert_equal(self.success, True)
2583
2584 @nottest
2585 def test_10k_flow_tcp_port(self):
2586 egress = 1
2587 ingress = 2
2588 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '192.168.30.1', 'tcp_port': 31000 }
2589 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.168.40.1', 'tcp_port': 11000 }
ChetanGaonker720ea612016-06-21 17:54:25 -07002590 success_dir = {}
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002591
2592 for i in range(0,10000):
2593 ingress_map['tcp_port'] += 1
2594 egress_map['tcp_port'] += 1
2595
2596 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -08002597 egressPort = egress + self.port_offset,
2598 ingressPort = ingress + self.port_offset,
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002599 tcpSrc = ingress_map['tcp_port'],
2600 tcpDst = egress_map['tcp_port']
2601 )
2602
2603 result = flow.addFlow()
2604 assert_equal(result, True)
2605 ##wait for flows to be added to ONOS
2606 time.sleep(1)
A R Karthick76a497a2017-04-12 10:59:39 -07002607 log_test.info("%d flow added.",i+1)
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002608
ChetanGaonker720ea612016-06-21 17:54:25 -07002609 self.success = True
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002610
ChetanGaonker720ea612016-06-21 17:54:25 -07002611 def verify_flow(*r):
2612 random_sport = int(''.join(r))
2613 random_dport = random_sport + 20000
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002614
ChetanGaonker720ea612016-06-21 17:54:25 -07002615 def mac_recv_task():
2616 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -07002617 log_test.info('Pkt seen with ingress TCP port %s, egress TCP port %s' %(pkt[TCP].sport, pkt[TCP].dport))
ChetanGaonker720ea612016-06-21 17:54:25 -07002618 success_dir[current_thread().name] = True
2619 sniff(count=2, timeout=5,
2620 lfilter = lambda p: TCP in p and p[TCP].dport == random_dport
2621 and p[TCP].sport == random_sport,prn = recv_cb, iface = self.port_map[egress])
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002622
ChetanGaonker720ea612016-06-21 17:54:25 -07002623 t = threading.Thread(target = mac_recv_task)
2624 t.start()
2625 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
2626 L3 = IP(src = ingress_map['ip'], dst = egress_map['ip'])
2627 L4 = TCP(sport = random_sport, dport = random_dport)
2628 pkt = L2/L3/L4
A R Karthick76a497a2017-04-12 10:59:39 -07002629 log_test.info('Sending packets to verify if flows are correct')
ChetanGaonker720ea612016-06-21 17:54:25 -07002630 sendp(pkt, count=50, iface = self.port_map[ingress])
2631 t.join()
2632
2633 t1 = threading.Thread(target = verify_flow, args = str(11001))
2634 t2 = threading.Thread(target = verify_flow, args = str(random.randrange(11110,12501,1)))
2635 t3 = threading.Thread(target = verify_flow, args = str(random.randrange(12510,14001,1)))
2636 t4 = threading.Thread(target = verify_flow, args = str(random.randrange(14010,15900,1)))
2637 t5 = threading.Thread(target = verify_flow, args = str(random.randrange(16000,17000,1)))
2638 t6 = threading.Thread(target = verify_flow, args = str(random.randrange(17001,18000,1)))
2639 t7 = threading.Thread(target = verify_flow, args = str(random.randrange(18000,19000,1)))
2640 t8 = threading.Thread(target = verify_flow, args = str(random.randrange(19000,20980,1)))
2641 t9 = threading.Thread(target = verify_flow, args = str(random.randrange(11002,21000,1)))
2642 t10 = threading.Thread(target = verify_flow, args = str(21000))
2643
2644
2645 t1.start()
2646 t2.start()
2647 t3.start()
2648 t4.start()
2649 t5.start()
2650 t6.start()
2651 t7.start()
2652 t8.start()
2653 t9.start()
2654 t10.start()
2655
2656 t1.join()
2657 t2.join()
2658 t3.join()
2659 t4.join()
2660 t5.join()
2661 t6.join()
2662 t7.join()
2663 t8.join()
2664 t9.join()
2665 t10.join()
2666
2667 if len(success_dir) != 10:
2668 self.success = False
2669
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002670 assert_equal(self.success, True)
2671
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002672 def test_500_flow_udp_port(self):
2673 egress = 1
2674 ingress = 2
2675 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '192.168.30.1', 'udp_port': 3100 }
2676 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.168.40.1', 'udp_port': 1100 }
ChetanGaonker720ea612016-06-21 17:54:25 -07002677 success_dir = {}
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002678
2679 for i in range(0,500):
2680 ingress_map['udp_port'] += 1
2681 egress_map['udp_port'] += 1
2682
2683 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -08002684 egressPort = egress + self.port_offset,
2685 ingressPort = ingress + self.port_offset,
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002686 udpSrc = ingress_map['udp_port'],
2687 udpDst = egress_map['udp_port']
2688 )
2689
2690 result = flow.addFlow()
2691 assert_equal(result, True)
2692 ##wait for flows to be added to ONOS
2693 time.sleep(1)
A R Karthick76a497a2017-04-12 10:59:39 -07002694 log_test.info("%d flow added.",i+1)
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002695
ChetanGaonker720ea612016-06-21 17:54:25 -07002696 self.success = True
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002697
ChetanGaonker720ea612016-06-21 17:54:25 -07002698 def verify_flow(*r):
2699 random_sport = int(''.join(r))
2700 random_dport = random_sport + 2000
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002701
ChetanGaonker720ea612016-06-21 17:54:25 -07002702 def mac_recv_task():
2703 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -07002704 log_test.info('Pkt seen with ingress UDP port %s, egress UDP port %s' %(pkt[UDP].sport, pkt[UDP].dport))
ChetanGaonker720ea612016-06-21 17:54:25 -07002705 success_dir[current_thread().name] = True
2706 sniff(count=2, timeout=5,
2707 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 -07002708
ChetanGaonker720ea612016-06-21 17:54:25 -07002709 t = threading.Thread(target = mac_recv_task)
2710 t.start()
2711 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
2712 L3 = IP(src = ingress_map['ip'], dst = egress_map['ip'])
2713 L4 = UDP(sport = random_sport, dport = random_dport)
2714 pkt = L2/L3/L4
A R Karthick76a497a2017-04-12 10:59:39 -07002715 log_test.info('Sending packets to verify if flows are correct')
ChetanGaonker720ea612016-06-21 17:54:25 -07002716 sendp(pkt, count=50, iface = self.port_map[ingress])
2717 t.join()
2718
2719 t1 = threading.Thread(target = verify_flow, args = str(1101))
2720 t2 = threading.Thread(target = verify_flow, args = str(random.randrange(1110,1250,1)))
2721 t3 = threading.Thread(target = verify_flow, args = str(random.randrange(1251,1400,1)))
2722 t4 = threading.Thread(target = verify_flow, args = str(random.randrange(1401,1590,1)))
2723 t5 = threading.Thread(target = verify_flow, args = str(1600))
2724
2725
2726 t1.start()
2727 t2.start()
2728 t3.start()
2729 t4.start()
2730 t5.start()
2731
2732 t1.join()
2733 t2.join()
2734 t3.join()
2735 t4.join()
2736 t5.join()
2737
2738 if len(success_dir) != 5:
2739 self.success = False
2740
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002741 assert_equal(self.success, True)
2742
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002743 def test_1k_flow_udp_port(self):
2744 egress = 1
2745 ingress = 2
2746 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '192.168.30.1', 'udp_port': 3100 }
2747 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.168.40.1', 'udp_port': 1100 }
ChetanGaonker720ea612016-06-21 17:54:25 -07002748 success_dir = {}
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002749
ChetanGaonker720ea612016-06-21 17:54:25 -07002750 for i in range(0,100000):
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002751 ingress_map['udp_port'] += 1
2752 egress_map['udp_port'] += 1
2753
2754 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -08002755 egressPort = egress + self.port_offset,
2756 ingressPort = ingress + self.port_offset,
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002757 udpSrc = ingress_map['udp_port'],
2758 udpDst = egress_map['udp_port']
2759 )
2760
2761 result = flow.addFlow()
2762 assert_equal(result, True)
2763 ##wait for flows to be added to ONOS
2764 time.sleep(1)
A R Karthick76a497a2017-04-12 10:59:39 -07002765 log_test.info("%d flow added.",i+1)
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002766
ChetanGaonker720ea612016-06-21 17:54:25 -07002767 self.success = True
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002768
ChetanGaonker720ea612016-06-21 17:54:25 -07002769 def verify_flow(*r):
2770 random_sport = int(''.join(r))
2771 random_dport = random_sport + 2000
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002772
ChetanGaonker720ea612016-06-21 17:54:25 -07002773 def mac_recv_task():
2774 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -07002775 log_test.info('Pkt seen with ingress UDP port %s, egress UDP port %s' %(pkt[UDP].sport, pkt[UDP].dport))
ChetanGaonker720ea612016-06-21 17:54:25 -07002776 success_dir[current_thread().name] = True
2777 sniff(count=2, timeout=5,
2778 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 -07002779
ChetanGaonker720ea612016-06-21 17:54:25 -07002780 t = threading.Thread(target = mac_recv_task)
2781 t.start()
2782 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
2783 L3 = IP(src = ingress_map['ip'], dst = egress_map['ip'])
2784 L4 = UDP(sport = random_sport, dport = random_dport)
2785 pkt = L2/L3/L4
A R Karthick76a497a2017-04-12 10:59:39 -07002786 log_test.info('Sending packets to verify if flows are correct')
ChetanGaonker720ea612016-06-21 17:54:25 -07002787 sendp(pkt, count=50, iface = self.port_map[ingress])
2788 t.join()
2789
2790 t1 = threading.Thread(target = verify_flow, args = str(1101))
2791 t2 = threading.Thread(target = verify_flow, args = str(random.randrange(1110,1350,1)))
2792 t3 = threading.Thread(target = verify_flow, args = str(random.randrange(1351,1500,1)))
2793 t4 = threading.Thread(target = verify_flow, args = str(random.randrange(1501,1700,1)))
2794 t5 = threading.Thread(target = verify_flow, args = str(random.randrange(1701,1900,1)))
2795 t6 = threading.Thread(target = verify_flow, args = str(random.randrange(1901,2000,1)))
2796 t7 = threading.Thread(target = verify_flow, args = str(random.randrange(2000,2050,1)))
2797 t8 = threading.Thread(target = verify_flow, args = str(random.randrange(2050,2080,1)))
2798 t9 = threading.Thread(target = verify_flow, args = str(random.randrange(1102,2100,1)))
2799 t10 = threading.Thread(target = verify_flow, args = str(2100))
2800
2801 t1.start()
2802 t2.start()
2803 t3.start()
2804 t4.start()
2805 t5.start()
2806 t6.start()
2807 t7.start()
2808 t8.start()
2809 t9.start()
2810 t10.start()
2811
2812 t1.join()
2813 t2.join()
2814 t3.join()
2815 t4.join()
2816 t5.join()
2817 t6.join()
2818 t7.join()
2819 t8.join()
2820 t9.join()
2821 t10.join()
2822
2823 if len(success_dir) != 10:
2824 self.success = False
2825
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002826 assert_equal(self.success, True)
2827
2828 @nottest
2829 def test_10k_flow_udp_port(self):
2830 egress = 1
2831 ingress = 2
2832 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '192.168.30.1', 'udp_port': 31000 }
2833 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.168.40.1', 'udp_port': 11000 }
ChetanGaonker720ea612016-06-21 17:54:25 -07002834 success_dir = {}
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002835
2836 for i in range(0,10000):
ChetanGaonker720ea612016-06-21 17:54:25 -07002837 ingress_map['udp_port'] += 1
2838 egress_map['udp_port'] += 1
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002839
ChetanGaonker720ea612016-06-21 17:54:25 -07002840 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -08002841 egressPort = egress + self.port_offset,
2842 ingressPort = ingress + self.port_offset,
ChetanGaonker720ea612016-06-21 17:54:25 -07002843 udpSrc = ingress_map['udp_port'],
2844 udpDst = egress_map['udp_port']
2845 )
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002846
ChetanGaonker720ea612016-06-21 17:54:25 -07002847 result = flow.addFlow()
2848 assert_equal(result, True)
2849 ##wait for flows to be added to ONOS
2850 time.sleep(1)
A R Karthick76a497a2017-04-12 10:59:39 -07002851 log_test.info("%d flow added.",i+1)
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002852
ChetanGaonker720ea612016-06-21 17:54:25 -07002853 self.success = True
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002854
ChetanGaonker720ea612016-06-21 17:54:25 -07002855 def verify_flow(*r):
2856 random_sport = int(''.join(r))
2857 random_dport = random_sport + 20000
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002858
ChetanGaonker720ea612016-06-21 17:54:25 -07002859 def mac_recv_task():
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002860
ChetanGaonker720ea612016-06-21 17:54:25 -07002861 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -07002862 log_test.info('Pkt seen with ingress UDP port %s, egress UDP port %s' %(pkt[UDP].sport, pkt[UDP].dport))
ChetanGaonker720ea612016-06-21 17:54:25 -07002863 success_dir[current_thread().name] = True
2864 sniff(count=2, timeout=5,
2865 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])
2866
2867 t = threading.Thread(target = mac_recv_task)
2868 t.start()
2869 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
2870 L3 = IP(src = ingress_map['ip'], dst = egress_map['ip'])
2871 L4 = UDP(sport = random_sport, dport = random_dport)
2872 pkt = L2/L3/L4
A R Karthick76a497a2017-04-12 10:59:39 -07002873 log_test.info('Sending packets to verify if flows are correct')
ChetanGaonker720ea612016-06-21 17:54:25 -07002874 sendp(pkt, count=50, iface = self.port_map[ingress])
2875 t.join()
2876
2877 t1 = threading.Thread(target = verify_flow, args = str(11001))
2878 t2 = threading.Thread(target = verify_flow, args = str(random.randrange(11110,12501,1)))
2879 t3 = threading.Thread(target = verify_flow, args = str(random.randrange(12510,14001,1)))
2880 t4 = threading.Thread(target = verify_flow, args = str(random.randrange(14010,15900,1)))
2881 t5 = threading.Thread(target = verify_flow, args = str(random.randrange(16000,17000,1)))
2882 t6 = threading.Thread(target = verify_flow, args = str(random.randrange(17001,18000,1)))
2883 t7 = threading.Thread(target = verify_flow, args = str(random.randrange(18000,19000,1)))
2884 t8 = threading.Thread(target = verify_flow, args = str(random.randrange(19000,20980,1)))
2885 t9 = threading.Thread(target = verify_flow, args = str(random.randrange(11002,21000,1)))
2886 t10 = threading.Thread(target = verify_flow, args = str(21000))
2887
2888
2889 t1.start()
2890 t2.start()
2891 t3.start()
2892 t4.start()
2893 t5.start()
2894 t6.start()
2895 t7.start()
2896 t8.start()
2897 t9.start()
2898 t10.start()
2899
2900 t1.join()
2901 t2.join()
2902 t3.join()
2903 t4.join()
2904 t5.join()
2905 t6.join()
2906 t7.join()
2907 t8.join()
2908 t9.join()
2909 t10.join()
2910
2911 if len(success_dir) != 10:
2912 self.success = False
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002913 assert_equal(self.success, True)