blob: fa22b726b9d1622ea4c27081e944c360a53c2e66 [file] [log] [blame]
Matteo Scandolo48d3d2d2017-08-08 13:05:27 -07001
2# Copyright 2017-present Open Networking Foundation
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
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# 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
16
ChetanGaonkera6adc0b2016-06-12 12:21:14 -070017#
Chetan Gaonkercfcce782016-05-10 10:10:42 -070018# Copyright 2016-present Ciena Corporation
19#
20# Licensed under the Apache License, Version 2.0 (the "License");
21# you may not use this file except in compliance with the License.
22# You may obtain a copy of the License at
ChetanGaonkera6adc0b2016-06-12 12:21:14 -070023#
Chetan Gaonkercfcce782016-05-10 10:10:42 -070024# http://www.apache.org/licenses/LICENSE-2.0
ChetanGaonkera6adc0b2016-06-12 12:21:14 -070025#
Chetan Gaonkercfcce782016-05-10 10:10:42 -070026# Unless required by applicable law or agreed to in writing, software
27# distributed under the License is distributed on an "AS IS" BASIS,
28# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
29# See the License for the specific language governing permissions and
30# limitations under the License.
31#
Chetan Gaonker7ab338c2016-04-15 17:23:17 -070032import unittest
33from nose.tools import *
34from nose.twistedtools import reactor, deferred
35from twisted.internet import defer
36from scapy.all import *
37import time
38import json
39import threading
ChetanGaonker720ea612016-06-21 17:54:25 -070040import os
Chetan Gaonker7ab338c2016-04-15 17:23:17 -070041from OnosCtrl import OnosCtrl
A R Karthickb03cecd2016-07-27 10:27:55 -070042from OnosFlowCtrl import OnosFlowCtrl
Chetan Gaonker7ab338c2016-04-15 17:23:17 -070043from OltConfig import OltConfig
A R Karthick9313b762016-11-07 13:14:35 -080044from CordLogger import CordLogger
A R Karthick76a497a2017-04-12 10:59:39 -070045from CordTestUtils import log_test
ChetanGaonkera6adc0b2016-06-12 12:21:14 -070046import random
47from threading import current_thread
ChetanGaonker720ea612016-06-21 17:54:25 -070048import collections
A R Karthick76a497a2017-04-12 10:59:39 -070049log_test.setLevel('INFO')
Chetan Gaonker7ab338c2016-04-15 17:23:17 -070050
A R Karthick9313b762016-11-07 13:14:35 -080051class flows_exchange(CordLogger):
Chetan Gaonker7ab338c2016-04-15 17:23:17 -070052
53 #Use the first available device id as our device id to program flows
54 app = 'org.onosproject.cli'
55 PORT_TX_DEFAULT = 2
56 PORT_RX_DEFAULT = 1
57 INTF_TX_DEFAULT = 'veth2'
58 INTF_RX_DEFAULT = 'veth0'
ChetanGaonkera6adc0b2016-06-12 12:21:14 -070059 default_port_map = {
Chetan Gaonker7ab338c2016-04-15 17:23:17 -070060 PORT_TX_DEFAULT : INTF_TX_DEFAULT,
61 PORT_RX_DEFAULT : INTF_RX_DEFAULT,
62 INTF_TX_DEFAULT : PORT_TX_DEFAULT,
63 INTF_RX_DEFAULT : PORT_RX_DEFAULT
64 }
65
ChetanGaonkera6adc0b2016-06-12 12:21:14 -070066 def incmac(self, mac):
ChetanGaonker720ea612016-06-21 17:54:25 -070067 tmp = str(hex(int('0x'+mac,16)+1).split('x')[1])
68 mac = '0'+ tmp if len(tmp) < 2 else tmp
69 return mac
ChetanGaonkera6adc0b2016-06-12 12:21:14 -070070
71 def next_mac(self, mac):
72 mac = mac.split(":")
73 mac[5] = self.incmac(mac[5])
74
75 if len(mac[5]) > 2:
ChetanGaonker720ea612016-06-21 17:54:25 -070076 mac[0] = self.incmac(mac[0])
77 mac[5] = '01'
78
ChetanGaonkera6adc0b2016-06-12 12:21:14 -070079 if len(mac[0]) > 2:
ChetanGaonker720ea612016-06-21 17:54:25 -070080 mac[0] = '01'
81 mac[1] = self.incmac(mac[1])
82 mac[5] = '01'
ChetanGaonkera6adc0b2016-06-12 12:21:14 -070083 return ':'.join(mac)
84
85 def to_egress_mac(cls, mac):
86 mac = mac.split(":")
87 mac[4] = '01'
ChetanGaonker720ea612016-06-21 17:54:25 -070088
ChetanGaonkera6adc0b2016-06-12 12:21:14 -070089 return ':'.join(mac)
90
91 def inc_ip(self, ip, i):
ChetanGaonker720ea612016-06-21 17:54:25 -070092
ChetanGaonkera6adc0b2016-06-12 12:21:14 -070093 ip[i] =str(int(ip[i])+1)
94 return '.'.join(ip)
95
96
97 def next_ip(self, ip):
ChetanGaonker720ea612016-06-21 17:54:25 -070098
ChetanGaonkera6adc0b2016-06-12 12:21:14 -070099 lst = ip.split('.')
100 for i in (3,0,-1):
101 if int(lst[i]) < 255:
102 return self.inc_ip(lst, i)
103 elif int(lst[i]) == 255:
ChetanGaonker720ea612016-06-21 17:54:25 -0700104 lst[i] = '0'
105 if int(lst[i-1]) < 255:
106 return self.inc_ip(lst,i-1)
107 elif int(lst[i-2]) < 255:
108 lst[i-1] = '0'
109 return self.inc_ip(lst,i-2)
110 else:
111 break
ChetanGaonkera6adc0b2016-06-12 12:21:14 -0700112
113 def to_egress_ip(self, ip):
114 lst=ip.split('.')
115 lst[0] = '182'
116 return '.'.join(lst)
117
ChetanGaonker720ea612016-06-21 17:54:25 -0700118
Chetan Gaonker7ab338c2016-04-15 17:23:17 -0700119 @classmethod
120 def setUpClass(cls):
121 cls.olt = OltConfig()
A R Karthickb03cecd2016-07-27 10:27:55 -0700122 cls.port_map, _ = cls.olt.olt_port_map()
Chetan Gaonker7ab338c2016-04-15 17:23:17 -0700123 if not cls.port_map:
124 cls.port_map = cls.default_port_map
A R Karthickb03cecd2016-07-27 10:27:55 -0700125 cls.device_id = OnosCtrl.get_device_id()
A R Karthicke4660f52017-02-23 12:08:41 -0800126 num_ports = len(cls.port_map['ports'] + cls.port_map['relay_ports'])
127 cls.port_offset = int(os.getenv('TEST_INSTANCE', 0)) * num_ports
Chetan Gaonker7ab338c2016-04-15 17:23:17 -0700128
129 def test_flow_mac(self):
ChetanGaonkera6adc0b2016-06-12 12:21:14 -0700130 '''Test Add and verify flows with MAC selectors'''
Chetan Gaonker7ab338c2016-04-15 17:23:17 -0700131 egress = 1
132 ingress = 2
133 egress_mac = '00:00:00:00:00:01'
134 ingress_mac = '00:00:00:00:00:02'
ChetanGaonker720ea612016-06-21 17:54:25 -0700135
Chetan Gaonker7ab338c2016-04-15 17:23:17 -0700136 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -0800137 egressPort = egress + self.port_offset,
138 ingressPort = ingress + self.port_offset,
Chetan Gaonker7ab338c2016-04-15 17:23:17 -0700139 ethSrc = ingress_mac,
140 ethDst = egress_mac)
141 result = flow.addFlow()
142 assert_equal(result, True)
143 ##wait for flows to be added to ONOS
ChetanGaonker720ea612016-06-21 17:54:25 -0700144 time.sleep(1)
Chetan Gaonker7ab338c2016-04-15 17:23:17 -0700145 self.success = False
146 def mac_recv_task():
147 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -0700148 log_test.info('Pkt seen with ingress mac %s, egress mac %s' %(pkt.src, pkt.dst))
Chetan Gaonker7ab338c2016-04-15 17:23:17 -0700149 self.success = True
ChetanGaonkera6adc0b2016-06-12 12:21:14 -0700150 sniff(count=2, timeout=5, lfilter = lambda p: p.src == ingress_mac,
Chetan Gaonker7ab338c2016-04-15 17:23:17 -0700151 prn = recv_cb, iface = self.port_map[egress])
152
153 t = threading.Thread(target = mac_recv_task)
154 t.start()
155 pkt = Ether(src = ingress_mac, dst = egress_mac)/IP()
A R Karthick76a497a2017-04-12 10:59:39 -0700156 log_test.info('Sending a packet to verify if flows are correct')
Chetan Gaonker7ab338c2016-04-15 17:23:17 -0700157 sendp(pkt, count=50, iface = self.port_map[ingress])
158 t.join()
159 assert_equal(self.success, True)
160
161 def test_flow_ip(self):
ChetanGaonkera6adc0b2016-06-12 12:21:14 -0700162 '''Test Add and verify flows with IPv4 selectors'''
Chetan Gaonker7ab338c2016-04-15 17:23:17 -0700163 egress = 1
164 ingress = 2
165 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '192.168.30.1' }
166 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.168.40.1' }
167 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -0800168 egressPort = egress + self.port_offset,
169 ingressPort = ingress + self.port_offset,
Chetan Gaonker7ab338c2016-04-15 17:23:17 -0700170 ethType = '0x0800',
171 ipSrc = ('IPV4_SRC', ingress_map['ip']+'/32'),
172 ipDst = ('IPV4_DST', egress_map['ip']+'/32')
173 )
174 result = flow.addFlow()
175 assert_equal(result, True)
176 ##wait for flows to be added to ONOS
ChetanGaonker720ea612016-06-21 17:54:25 -0700177 time.sleep(1)
Chetan Gaonker7ab338c2016-04-15 17:23:17 -0700178 self.success = False
179 def mac_recv_task():
180 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -0700181 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 -0700182 self.success = True
ChetanGaonkera6adc0b2016-06-12 12:21:14 -0700183 sniff(count=2, timeout=5,
Chetan Gaonker3533faa2016-04-25 17:50:14 -0700184 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 -0700185 prn = recv_cb, iface = self.port_map[egress])
186
187 t = threading.Thread(target = mac_recv_task)
188 t.start()
189 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
190 L3 = IP(src = ingress_map['ip'], dst = egress_map['ip'])
191 pkt = L2/L3
A R Karthick76a497a2017-04-12 10:59:39 -0700192 log_test.info('Sending a packet to verify if flows are correct')
Chetan Gaonker7ab338c2016-04-15 17:23:17 -0700193 sendp(pkt, count=50, iface = self.port_map[ingress])
194 t.join()
195 assert_equal(self.success, True)
ChetanGaonkera6adc0b2016-06-12 12:21:14 -0700196
197
198 def test_flow_tcp_port(self):
199 egress = 1
200 ingress = 2
201 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '192.168.30.1', 'tcp_port': 9500 }
202 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.168.40.1', 'tcp_port': 9000 }
203 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -0800204 egressPort = egress + self.port_offset,
205 ingressPort = ingress + self.port_offset,
ChetanGaonkera6adc0b2016-06-12 12:21:14 -0700206 tcpSrc = ingress_map['tcp_port'],
207 tcpDst = egress_map['tcp_port']
208 )
209 result = flow.addFlow()
210 assert_equal(result, True)
211 ##wait for flows to be added to ONOS
ChetanGaonker720ea612016-06-21 17:54:25 -0700212 time.sleep(1)
ChetanGaonkera6adc0b2016-06-12 12:21:14 -0700213 self.success = False
214 def mac_recv_task():
215 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -0700216 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 -0700217 self.success = True
ChetanGaonker720ea612016-06-21 17:54:25 -0700218 sniff(count=2, timeout=5, lfilter = lambda p: TCP in p and p[TCP].dport == egress_map['tcp_port']
219 and p[TCP].sport == ingress_map['tcp_port'], prn = recv_cb, iface = self.port_map[egress])
ChetanGaonkera6adc0b2016-06-12 12:21:14 -0700220
221 t = threading.Thread(target = mac_recv_task)
222 t.start()
223 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
224 L3 = IP(src = ingress_map['ip'], dst = egress_map['ip'])
225 L4 = TCP(sport = ingress_map['tcp_port'], dport = egress_map['tcp_port'])
226 pkt = L2/L3/L4
A R Karthick76a497a2017-04-12 10:59:39 -0700227 log_test.info('Sending packets to verify if flows are correct')
ChetanGaonkera6adc0b2016-06-12 12:21:14 -0700228 sendp(pkt, count=50, iface = self.port_map[ingress])
229 t.join()
230 assert_equal(self.success, True)
231
ChetanGaonkera6adc0b2016-06-12 12:21:14 -0700232 def test_flow_udp_port(self):
233 egress = 1
234 ingress = 2
235 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '192.168.30.1', 'udp_port': 9500 }
236 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.168.40.1', 'udp_port': 9000 }
237 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -0800238 egressPort = egress + self.port_offset,
239 ingressPort = ingress + self.port_offset,
ChetanGaonkera6adc0b2016-06-12 12:21:14 -0700240 udpSrc = ingress_map['udp_port'],
241 udpDst = egress_map['udp_port']
242 )
243 result = flow.addFlow()
244 assert_equal(result, True)
245 ##wait for flows to be added to ONOS
ChetanGaonker720ea612016-06-21 17:54:25 -0700246 time.sleep(1)
ChetanGaonkera6adc0b2016-06-12 12:21:14 -0700247 self.success = False
248 def mac_recv_task():
249 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -0700250 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 -0700251 self.success = True
252 sniff(count=2, timeout=5,
ChetanGaonker720ea612016-06-21 17:54:25 -0700253 lfilter = lambda p: UDP in p and p[UDP].dport == egress_map['udp_port']
254 and p[UDP].sport == ingress_map['udp_port'], prn = recv_cb, iface = self.port_map[egress])
ChetanGaonkera6adc0b2016-06-12 12:21:14 -0700255
256 t = threading.Thread(target = mac_recv_task)
257 t.start()
258 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
259 L3 = IP(src = ingress_map['ip'], dst = egress_map['ip'])
260 L4 = UDP(sport = ingress_map['udp_port'], dport = egress_map['udp_port'])
261 pkt = L2/L3/L4
A R Karthick76a497a2017-04-12 10:59:39 -0700262 log_test.info('Sending packets to verify if flows are correct')
ChetanGaonkera6adc0b2016-06-12 12:21:14 -0700263 sendp(pkt, count=50, iface = self.port_map[ingress])
264 t.join()
265 assert_equal(self.success, True)
266
ChetanGaonker720ea612016-06-21 17:54:25 -0700267 @nottest
268 def test_flow_vlan(self):
269 egress = 1
270 ingress = 2
271 egress_mac = '00:00:00:00:00:01'
272 ingress_mac = '00:00:00:00:00:02'
273 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -0800274 egressPort = egress + self.port_offset,
275 ingressPort = ingress + self.port_offset,
ChetanGaonker720ea612016-06-21 17:54:25 -0700276 ethSrc = ingress_mac,
277 ethDst = egress_mac,
278 vlan = 0x10)
279 result = flow.addFlow()
280 assert_equal(result, True)
281 ##wait for flows to be added to ONOS
282 time.sleep(1)
283 self.success = False
284 def mac_recv_task():
285 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -0700286 log_test.info('Pkt seen with ingress mac %s, egress mac %s' %(pkt.src, pkt.dst))
287 log_test.info('Pkt:%s', pkt.show())
ChetanGaonker720ea612016-06-21 17:54:25 -0700288 self.success = True
289 sniff(count=2, timeout=5, lfilter = lambda p:p.src == ingress_mac,
290 prn = recv_cb, iface = self.port_map[egress])
291
292 t = threading.Thread(target = mac_recv_task)
293 t.start()
294 pkt = Ether(src = ingress_mac, dst = egress_mac)/Dot1Q(vlan = 0x10)/IP()
A R Karthick76a497a2017-04-12 10:59:39 -0700295 log_test.info("Sending Packet:%s",pkt.show())
296 log_test.info('Sending a packet to verify if flows are correct')
ChetanGaonker720ea612016-06-21 17:54:25 -0700297 sendp(pkt, count=50, iface = self.port_map[ingress])
298 t.join()
299 assert_equal(self.success, True)
300
301 def test_flow_ipv6(self):
302 egress = 1
303 ingress = 2
304 egress_map = { 'ether': '00:00:00:00:00:03', 'ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1001' }
305 ingress_map = { 'ether': '00:00:00:00:00:04', 'ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1002' }
306 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -0800307 egressPort = egress + self.port_offset,
308 ingressPort = ingress + self.port_offset,
ChetanGaonker720ea612016-06-21 17:54:25 -0700309 ethType = '0x86dd',
310 ipSrc = ('IPV6_SRC', ingress_map['ipv6'] + '/48'),
311 ipDst = ('IPV6_DST', egress_map['ipv6'] + '/48')
312 )
313
314 result = flow.addFlow()
315 assert_equal(result, True)
316 ##wait for flows to be added to ONOS
317 time.sleep(1)
318 self.success = False
319 def mac_recv_task():
320 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -0700321 log_test.info('Pkt seen with ingress ip %s, egress ip %s' %(pkt[IPv6].src, pkt[IPv6].dst))
ChetanGaonker720ea612016-06-21 17:54:25 -0700322 self.success = True
323 sniff(count=2, timeout=5,
324 lfilter = lambda p: IPv6 in p and p[IPv6].dst == egress_map['ipv6'] and p[IPv6].src == ingress_map['ipv6'],
325 prn = recv_cb, iface = self.port_map[egress])
326
327 t = threading.Thread(target = mac_recv_task)
328 t.start()
329 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
330 L3 = IPv6(src = ingress_map['ipv6'] , dst = egress_map['ipv6'])
331 pkt = L2/L3
A R Karthick76a497a2017-04-12 10:59:39 -0700332 log_test.info('Sending a packet to verify if flows are correct')
ChetanGaonker720ea612016-06-21 17:54:25 -0700333 sendp(pkt, count=50, iface = self.port_map[ingress])
334 t.join()
335 assert_equal(self.success, True)
336
337 def test_flow_ipv6_flow_label(self):
338 egress = 1
339 ingress = 2
340 egress_map = { 'ether': '00:00:00:00:00:03', 'ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1001' }
341 ingress_map = { 'ether': '00:00:00:00:00:04', 'ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1002' }
342 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -0800343 egressPort = egress + self.port_offset,
344 ingressPort = ingress + self.port_offset,
ChetanGaonker720ea612016-06-21 17:54:25 -0700345 ipv6flow_label = 25
346 )
347
348 result = flow.addFlow()
349 assert_equal(result, True)
350 ##wait for flows to be added to ONOS
351 time.sleep(1)
352 self.success = False
353 def mac_recv_task():
354 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -0700355 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 -0700356 self.success = True
357 sniff(count=2, timeout=5, lfilter = lambda p: IPv6 in p and p[IPv6].dst == egress_map['ipv6']
358 and p[IPv6].src == ingress_map['ipv6'] and p[IPv6].fl == 25, prn = recv_cb, iface = self.port_map[egress])
359
360 t = threading.Thread(target = mac_recv_task)
361 t.start()
362 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
363 L3 = IPv6(src = ingress_map['ipv6'] , dst = egress_map['ipv6'], fl = 25)
364 pkt = L2/L3
A R Karthick76a497a2017-04-12 10:59:39 -0700365 log_test.info('Sending a packet to verify if flows are correct')
ChetanGaonker720ea612016-06-21 17:54:25 -0700366 sendp(pkt, count=50, iface = self.port_map[ingress])
367 t.join()
368 assert_equal(self.success, True)
369
370 def test_flow_ipv6_extension_header(self):
371 egress = 1
372 ingress = 2
373 egress_map = { 'ether': '00:00:00:00:00:03', 'ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1001' }
374 ingress_map = { 'ether': '00:00:00:00:00:04', 'ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1002' }
375 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -0800376 egressPort = egress + self.port_offset,
377 ingressPort = ingress + self.port_offset,
ChetanGaonker720ea612016-06-21 17:54:25 -0700378 ipv6_extension = 0,
379 )
380
381 result = flow.addFlow()
382 assert_equal(result, True)
383 ##wait for flows to be added to ONOS
384 time.sleep(1)
385 self.success = False
386 def mac_recv_task():
387 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -0700388 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 -0700389 self.success = True
390 sniff(count=2, timeout=5,
391 lfilter = lambda p: IPv6 in p and p[IPv6].nh == 0, prn = recv_cb, iface = self.port_map[egress])
392
393 t = threading.Thread(target = mac_recv_task)
394 t.start()
395 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
396 L3 = IPv6(src = ingress_map['ipv6'] , dst = egress_map['ipv6'], nh = 0)
397 pkt = L2/L3
A R Karthick76a497a2017-04-12 10:59:39 -0700398 log_test.info('Sending packets to verify if flows are correct')
ChetanGaonker720ea612016-06-21 17:54:25 -0700399 sendp(pkt, count=50, iface = self.port_map[ingress])
400 t.join()
401 assert_equal(self.success, True)
402
403 def test_flow_ipv6_available_extension_headers(self):
404 egress = 1
405 ingress = 2
406 egress_map = { 'ether': '00:00:00:00:00:03', 'ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1001' }
407 ingress_map = { 'ether': '00:00:00:00:00:04', 'ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1002' }
408 for i in [0, 60, 43, 44, 51, 50, 135]:
409 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -0800410 egressPort = egress + self.port_offset,
411 ingressPort = ingress + self.port_offset,
ChetanGaonker720ea612016-06-21 17:54:25 -0700412 ipv6_extension = i,
413 )
414
415 result = flow.addFlow()
416 assert_equal(result, True)
417 ##wait for flows to be added to ONOS
418 time.sleep(1)
419 def mac_recv_task():
420 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -0700421 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 -0700422 self.success = True
423 sniff(count=2, timeout=5, lfilter = lambda p: IPv6 in p and p[IPv6].nh == i,
424 prn = recv_cb, iface = self.port_map[egress])
425
426 for i in [0, 60, 43, 44, 51, 50, 135]:
427 self.success = False
428 t = threading.Thread(target = mac_recv_task)
429 t.start()
430 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
431 L3 = IPv6(src = ingress_map['ipv6'] , dst = egress_map['ipv6'], nh = i)
432 pkt = L2/L3
A R Karthick76a497a2017-04-12 10:59:39 -0700433 log_test.info('Sending packets to verify if flows are correct')
ChetanGaonker720ea612016-06-21 17:54:25 -0700434 sendp(pkt, count=50, iface = self.port_map[ingress])
435 t.join()
436 assert_equal(self.success, True)
437
438
439 def test_flow_dscp(self):
440 egress = 1
441 ingress = 2
442 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '192.168.30.1' }
443 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.168.40.1' }
444 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -0800445 egressPort = egress + self.port_offset,
446 ingressPort = ingress + self.port_offset,
ChetanGaonker720ea612016-06-21 17:54:25 -0700447 dscp = 32
448 )
449 result = flow.addFlow()
450 assert_equal(result, True)
451 ##wait for flows to be added to ONOS
452 time.sleep(1)
453 self.success = False
454 def mac_recv_task():
455 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -0700456 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 -0700457 self.success = True
458 sniff(count=2, timeout=5,
459 lfilter = lambda p: IP in p and p[IP].dst == egress_map['ip'] and p[IP].src == ingress_map['ip']
460 and p[IP].tos == 32,prn = recv_cb, iface = self.port_map[egress])
461
462 t = threading.Thread(target = mac_recv_task)
463 t.start()
464 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
465 L3 = IP(src = ingress_map['ip'], dst = egress_map['ip'], tos = 32)
466 pkt = L2/L3
A R Karthick76a497a2017-04-12 10:59:39 -0700467 log_test.info('Sending a packet to verify if flows are correct')
ChetanGaonker720ea612016-06-21 17:54:25 -0700468 sendp(pkt, count=50, iface = self.port_map[ingress])
469 t.join()
470 assert_equal(self.success, True)
471
472 def test_flow_available_dscp(self):
473 egress = 1
474 ingress = 2
475 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '192.168.30.1' }
476 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.168.40.1' }
477 dscp = [184, 0, 40, 48, 56, 72, 80, 88, 104, 112, 120, 136, 144, 152, 32, 64, 96, 128, 160, 192, 224]
478 for i in dscp:
479 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -0800480 egressPort = egress + self.port_offset,
481 ingressPort = ingress + self.port_offset,
ChetanGaonker720ea612016-06-21 17:54:25 -0700482 dscp = i
483 )
484 result = flow.addFlow()
485 assert_equal(result, True)
486 ##wait for flows to be added to ONOS
487 time.sleep(1)
488
489 def mac_recv_task():
490 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -0700491 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 -0700492 self.success = True
493 sniff(count=2, timeout=5,
494 lfilter = lambda p: IP in p and p[IP].dst == egress_map['ip'] and p[IP].src == ingress_map['ip']
495 and p[IP].tos == i,prn = recv_cb, iface = self.port_map[egress])
496
497 for i in dscp:
498 self.success = False
499 t = threading.Thread(target = mac_recv_task)
500 t.start()
501 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
502 L3 = IP(src = ingress_map['ip'], dst = egress_map['ip'], tos = i)
503 pkt = L2/L3
A R Karthick76a497a2017-04-12 10:59:39 -0700504 log_test.info('Sending a packet to verify if flows are correct')
ChetanGaonker720ea612016-06-21 17:54:25 -0700505 sendp(pkt, count=50, iface = self.port_map[ingress])
506 t.join()
507 assert_equal(self.success, True)
508
509 def test_flow_ecn(self):
510 egress = 1
511 ingress = 2
512 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '192.168.30.1' }
513 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.168.40.1' }
514 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -0800515 egressPort = egress + self.port_offset,
516 ingressPort = ingress + self.port_offset,
ChetanGaonker720ea612016-06-21 17:54:25 -0700517 ecn = 1
518 )
519 result = flow.addFlow()
520 assert_equal(result, True)
521 ##wait for flows to be added to ONOS
522 time.sleep(1)
523 self.success = False
524 def mac_recv_task():
525 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -0700526 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 -0700527 self.success = True
528 sniff(count=2, timeout=5,
529 lfilter = lambda p: IP in p and p[IP].dst == egress_map['ip'] and p[IP].src == ingress_map['ip']
530 and int(bin(p[IP].tos).split('b')[1][-2:],2) == 1,prn = recv_cb,
531 iface = self.port_map[egress])
532
533 t = threading.Thread(target = mac_recv_task)
534 t.start()
535 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
536 L3 = IP(src = ingress_map['ip'], dst = egress_map['ip'], tos = 1)
537 pkt = L2/L3
A R Karthick76a497a2017-04-12 10:59:39 -0700538 log_test.info('Sending a packet to verify if flows are correct')
ChetanGaonker720ea612016-06-21 17:54:25 -0700539 sendp(pkt, count=50, iface = self.port_map[ingress])
540 t.join()
541 assert_equal(self.success, True)
542
543
544 def test_flow_available_ecn(self):
545 egress = 1
546 ingress = 2
547 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '192.168.30.1' }
548 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.168.40.1' }
549 for i in range(4):
550 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -0800551 egressPort = egress + self.port_offset,
552 ingressPort = ingress + self.port_offset,
ChetanGaonker720ea612016-06-21 17:54:25 -0700553 ecn = i
554 )
555 result = flow.addFlow()
556 assert_equal(result, True)
557 ##wait for flows to be added to ONOS
558 time.sleep(1)
559 def mac_recv_task():
560 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -0700561 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 -0700562 self.success = True
563 sniff(count=2, timeout=5,
564 lfilter = lambda p: IP in p and p[IP].dst == egress_map['ip'] and p[IP].src == ingress_map['ip']
565 and int(bin(p[IP].tos).split('b')[1][-2:],2) == i,prn = recv_cb,
566 iface = self.port_map[egress])
567
568 for i in range(4):
569 self.success = False
570 t = threading.Thread(target = mac_recv_task)
571 t.start()
572 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
573 L3 = IP(src = ingress_map['ip'], dst = egress_map['ip'], tos = i)
574 pkt = L2/L3
A R Karthick76a497a2017-04-12 10:59:39 -0700575 log_test.info('Sending a packet to verify if flows are correct')
ChetanGaonker720ea612016-06-21 17:54:25 -0700576 sendp(pkt, count=50, iface = self.port_map[ingress])
577 t.join()
578 assert_equal(self.success, True)
579
580 def test_flow_available_dscp_and_ecn(self):
581 egress = 1
582 ingress = 2
583 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '192.168.30.1' }
584 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.168.40.1' }
585 dscp = [46, 0, 10, 12, 14, 18, 20, 22, 26, 28, 30, 34, 36, 38, 8, 16, 24, 32, 40, 48, 56]
586 for i in dscp:
587 for j in (0,1,2,3):
588 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -0800589 egressPort = egress + self.port_offset,
590 ingressPort = ingress + self.port_offset,
ChetanGaonker720ea612016-06-21 17:54:25 -0700591 dscp = i,
592 ecn = j
593 )
594 result = flow.addFlow()
595 assert_equal(result, True)
596 ##wait for flows to be added to ONOS
597 time.sleep(1)
598
599 def mac_recv_task():
600 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -0700601 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 -0700602 self.success = True
603 sniff(count=2, timeout=5,
604 lfilter = lambda p: IP in p and p[IP].tos == int(bin(i).split('b')[1]+ bin(j).split('b')[1],2)
605 ,prn = recv_cb, iface = self.port_map[egress])
606
607 for i in dscp:
608 for j in (0,1,2,3):
609
610 self.success = False
611 t = threading.Thread(target = mac_recv_task)
612 t.start()
613 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
614 L3 = IP(src = ingress_map['ip'], dst = egress_map['ip'], tos = int(bin(i).split('b')[1]+ bin(j).split('b')[1],2))
615 pkt = L2/L3
A R Karthick76a497a2017-04-12 10:59:39 -0700616 log_test.info('Sending packets to verify if flows are correct')
ChetanGaonker720ea612016-06-21 17:54:25 -0700617 sendp(pkt, count=50, iface = self.port_map[ingress])
618 t.join()
619 assert_equal(self.success, True)
620
621 def test_flow_icmp(self):
622 egress = 1
623 ingress = 2
624 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '192.168.30.1' }
625 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.168.40.1' }
626 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -0800627 egressPort = egress + self.port_offset,
628 ingressPort = ingress + self.port_offset,
ChetanGaonker720ea612016-06-21 17:54:25 -0700629 icmpv4_type = '3',
630 icmpv4_code = 8
631 )
632 result = flow.addFlow()
633 assert_equal(result, True)
634 ##wait for flows to be added to ONOS
635 time.sleep(1)
636 self.success = False
637
638 def mac_recv_task():
639 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -0700640 log_test.info('Pkt seen with ICMP type %s, ICMP code %s' %(pkt[ICMP].type, pkt[ICMP].code))
ChetanGaonker720ea612016-06-21 17:54:25 -0700641 self.success = True
642 sniff(count=2, timeout=5,
643 lfilter = lambda p: ICMP in p and p[ICMP].type == 3 and p[ICMP].code == 8,
644 prn = recv_cb, iface = self.port_map[egress])
645
646 t = threading.Thread(target = mac_recv_task)
647 t.start()
648 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
649 L3 = IP(src = ingress_map['ip'], dst = egress_map['ip'])/ICMP(type = 3, code = 8)
650 pkt = L2/L3
A R Karthick76a497a2017-04-12 10:59:39 -0700651 log_test.info('Sending a packet to verify if flows are correct')
ChetanGaonker720ea612016-06-21 17:54:25 -0700652 sendp(pkt, count=50, iface = self.port_map[ingress])
653 t.join()
654 assert_equal(self.success, True)
655
656 def test_flow_icmp_different_types(self):
657 egress = 1
658 ingress = 2
659 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '192.168.30.1' }
660 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.168.40.1' }
661 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],
662 '5': [1, 2, 3], '4': 0, '9': 0, '8': 0}
663 for type,code in icmp.items():
664 if isinstance(code, list):
665 for i in code:
666 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -0800667 egressPort = egress + self.port_offset,
668 ingressPort = ingress + self.port_offset,
ChetanGaonker720ea612016-06-21 17:54:25 -0700669 icmpv4_type = type,
670 icmpv4_code = i
671 )
672 result = flow.addFlow()
673 assert_equal(result, True)
674 ##wait for flows to be added to ONOS
675 time.sleep(1)
676 else:
677 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -0800678 egressPort = egress + self.port_offset,
679 ingressPort = ingress + self.port_offset,
ChetanGaonker720ea612016-06-21 17:54:25 -0700680 icmpv4_type = type,
681 icmpv4_code = code
682 )
683 result = flow.addFlow()
684 assert_equal(result, True)
685 ##wait for flows to be added to ONOS
686 time.sleep(1)
687 self.success = False
688
689 def mac_recv_task():
690 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -0700691 log_test.info('Pkt seen with ICMP type %s, ICMP code %s' %(pkt[ICMP].type, pkt[ICMP].code))
ChetanGaonker720ea612016-06-21 17:54:25 -0700692 self.success = True
693 sniff(count=2, timeout=5,
694 lfilter = lambda p: ICMP in p and p[ICMP].type == 3 and p[ICMP].code == 8,
695 prn = recv_cb, iface = self.port_map[egress])
696
697 t = threading.Thread(target = mac_recv_task)
698 t.start()
699 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
700 L3 = IP(src = ingress_map['ip'], dst = egress_map['ip'])/ICMP(type = 3, code = 8)
701 pkt = L2/L3
A R Karthick76a497a2017-04-12 10:59:39 -0700702 log_test.info('Sending a packet to verify if flows are correct')
ChetanGaonker720ea612016-06-21 17:54:25 -0700703 sendp(pkt, count=50, iface = self.port_map[ingress])
704 t.join()
705 assert_equal(self.success, True)
706
707 def test_flow_icmpv6_EchoRequest(self):
708 egress = 1
709 ingress = 2
710 egress_map = { 'ether': '00:00:00:00:00:03','ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1001'}
711 ingress_map = { 'ether': '00:00:00:00:00:04','ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1002'}
712 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -0800713 egressPort = egress + self.port_offset,
714 ingressPort = ingress + self.port_offset,
ChetanGaonker720ea612016-06-21 17:54:25 -0700715 icmpv6_type = '128',
716 icmpv6_code = 0
717 )
718 result = flow.addFlow()
719 assert_equal(result, True)
720 ##wait for flows to be added to ONOS
721 time.sleep(1)
722 self.success = False
723 def mac_recv_task():
724 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -0700725 log_test.info('Pkt seen with ICMPv6 type %s, ICMPv6 code %s' %(pkt[ICMPv6EchoRequest].type, pkt[ICMPv6EchoRequest].code))
ChetanGaonker720ea612016-06-21 17:54:25 -0700726 self.success = True
727 sniff(count=2, timeout=5,
728 lfilter = lambda p: ICMPv6EchoRequest in p and p[ICMPv6EchoRequest].type == 128 and p[ICMPv6EchoRequest].code == 0,
729 prn = recv_cb, iface = self.port_map[egress])
730
731 t = threading.Thread(target = mac_recv_task)
732 t.start()
733 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
734 L3 = IPv6(src = ingress_map['ipv6'], dst = egress_map['ipv6'])/ICMPv6EchoRequest()
735 pkt = L2/L3
A R Karthick76a497a2017-04-12 10:59:39 -0700736 log_test.info('Sending a packet to verify if flows are correct')
ChetanGaonker720ea612016-06-21 17:54:25 -0700737 sendp(pkt, count=50, iface = self.port_map[ingress])
738 t.join()
739 assert_equal(self.success, True)
740
741 def test_flow_icmpv6_EchoReply(self):
742 egress = 1
743 ingress = 2
744 egress_map = { 'ether': '00:00:00:00:00:03','ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1001'}
745 ingress_map = { 'ether': '00:00:00:00:00:04','ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1002' }
746 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -0800747 egressPort = egress + self.port_offset,
748 ingressPort = ingress + self.port_offset,
ChetanGaonker720ea612016-06-21 17:54:25 -0700749 icmpv6_type = '129',
750 icmpv6_code = 0
751 )
752 result = flow.addFlow()
753 assert_equal(result, True)
754 ##wait for flows to be added to ONOS
755 time.sleep(1)
756 self.success = False
757 def mac_recv_task():
758 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -0700759 log_test.info('Pkt seen with ICMPv6 type %s, ICMPv6 code %s' %(pkt[ICMPv6EchoReply].type, pkt[ICMPv6EchoReply].code))
ChetanGaonker720ea612016-06-21 17:54:25 -0700760 self.success = True
761 sniff(count=2, timeout=5,
762 lfilter = lambda p: ICMPv6EchoReply in p and p[ICMPv6EchoReply].type == 129 and p[ICMPv6EchoReply].code == 0,
763 prn = recv_cb, iface = self.port_map[egress])
764
765 t = threading.Thread(target = mac_recv_task)
766 t.start()
767 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
768 L3 = IPv6(src = ingress_map['ipv6'], dst = egress_map['ipv6'])/ICMPv6EchoReply()
769 pkt = L2/L3
A R Karthick76a497a2017-04-12 10:59:39 -0700770 log_test.info('Sending packets to verify if flows are correct')
ChetanGaonker720ea612016-06-21 17:54:25 -0700771 sendp(pkt, count=50, iface = self.port_map[ingress])
772 t.join()
773 assert_equal(self.success, True)
774
775
776 def test_flow_icmpv6_DestUnreachable(self):
777 egress = 1
778 ingress = 2
779 egress_map = { 'ether': '00:00:00:00:00:03','ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1001'}
780 ingress_map = { 'ether': '00:00:00:00:00:04','ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1002' }
781 for i in range(8):
782 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -0800783 egressPort = egress + self.port_offset,
784 ingressPort = ingress + self.port_offset,
ChetanGaonker720ea612016-06-21 17:54:25 -0700785 icmpv6_type = '1',
786 icmpv6_code = i
787 )
788 result = flow.addFlow()
789 assert_equal(result, True)
790 ##wait for flows to be added to ONOS
791 time.sleep(1)
792 for i in range(8):
793 self.success = False
794 def mac_recv_task():
795 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -0700796 log_test.info('Pkt seen with ICMPv6 type %s, ICMPv6 code %s' %(pkt[ICMPv6DestUnreach].type, pkt[ICMPv6DestUnreach].code))
ChetanGaonker720ea612016-06-21 17:54:25 -0700797 self.success = True
798 sniff(count=2, timeout=5,
799 lfilter = lambda p: ICMPv6DestUnreach in p and p[ICMPv6DestUnreach].type == 1 and p[ICMPv6DestUnreach].code == i,
800 prn = recv_cb, iface = self.port_map[egress])
801
802 t = threading.Thread(target = mac_recv_task)
803 t.start()
804 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
805 L3 = IPv6(src = ingress_map['ipv6'], dst = egress_map['ipv6'])/ICMPv6DestUnreach(code = i)
806 pkt = L2/L3
A R Karthick76a497a2017-04-12 10:59:39 -0700807 log_test.info('Sending packets to verify if flows are correct')
ChetanGaonker720ea612016-06-21 17:54:25 -0700808 sendp(pkt, count=50, iface = self.port_map[ingress])
809 t.join()
810 assert_equal(self.success, True)
811
812 def test_flow_icmpv6_PacketTooBig(self):
813 egress = 1
814 ingress = 2
815 egress_map = { 'ether': '00:00:00:00:00:03','ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1001'}
816 ingress_map = { 'ether': '00:00:00:00:00:04','ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1002' }
817 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -0800818 egressPort = egress + self.port_offset,
819 ingressPort = ingress + self.port_offset,
ChetanGaonker720ea612016-06-21 17:54:25 -0700820 icmpv6_type = '2',
821 icmpv6_code = 0
822 )
823 result = flow.addFlow()
824 assert_equal(result, True)
825 ##wait for flows to be added to ONOS
826 time.sleep(1)
827 self.success = False
828 def mac_recv_task():
829 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -0700830 log_test.info('Pkt seen with ICMPv6 type %s, ICMPv6 code %s' %(pkt[ICMPv6PacketTooBig].type, pkt[ICMPv6PacketTooBig].code))
ChetanGaonker720ea612016-06-21 17:54:25 -0700831 self.success = True
832 sniff(count=2, timeout=5,
833 lfilter = lambda p: ICMPv6PacketTooBig in p and p[ICMPv6PacketTooBig].type == 2 and p[ICMPv6PacketTooBig].code == 0,
834 prn = recv_cb, iface = self.port_map[egress])
835
836 t = threading.Thread(target = mac_recv_task)
837 t.start()
838 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
839 L3 = IPv6(src = ingress_map['ipv6'], dst = egress_map['ipv6'])/ICMPv6PacketTooBig()
840 pkt = L2/L3
A R Karthick76a497a2017-04-12 10:59:39 -0700841 log_test.info('Sending packets to verify if flows are correct')
ChetanGaonker720ea612016-06-21 17:54:25 -0700842 sendp(pkt, count=50, iface = self.port_map[ingress])
843 t.join()
844 assert_equal(self.success, True)
845
846 def test_flow_icmpv6_TimeExceeded(self):
847 egress = 1
848 ingress = 2
849 egress_map = { 'ether': '00:00:00:00:00:03','ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1001'}
850 ingress_map = { 'ether': '00:00:00:00:00:04','ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1002' }
851 for i in range(2):
852 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -0800853 egressPort = egress + self.port_offset,
854 ingressPort = ingress + self.port_offset,
ChetanGaonker720ea612016-06-21 17:54:25 -0700855 icmpv6_type = '3',
856 icmpv6_code = i
857 )
858 result = flow.addFlow()
859 assert_equal(result, True)
860 ##wait for flows to be added to ONOS
861 time.sleep(1)
862 for i in range(2):
863 self.success = False
864 def mac_recv_task():
865 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -0700866 log_test.info('Pkt seen with ICMPv6 type %s, ICMPv6 code %s' %(pkt[ICMPv6TimeExceeded].type, pkt[ICMPv6TimeExceeded].code))
ChetanGaonker720ea612016-06-21 17:54:25 -0700867 self.success = True
868 sniff(count=2, timeout=5,
869 lfilter = lambda p: ICMPv6TimeExceeded in p and p[ICMPv6TimeExceeded].type == 3 and p[ICMPv6TimeExceeded].code == i,
870 prn = recv_cb, iface = self.port_map[egress])
871
872 t = threading.Thread(target = mac_recv_task)
873 t.start()
874 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
875 L3 = IPv6(src = ingress_map['ipv6'], dst = egress_map['ipv6'])/ICMPv6TimeExceeded(code = i)
876 pkt = L2/L3
A R Karthick76a497a2017-04-12 10:59:39 -0700877 log_test.info('Sending packets to verify if flows are correct')
ChetanGaonker720ea612016-06-21 17:54:25 -0700878 sendp(pkt, count=50, iface = self.port_map[ingress])
879 t.join()
880 assert_equal(self.success, True)
881
882 def test_flow_icmpv6_ParameterProblem(self):
883 egress = 1
884 ingress = 2
885 egress_map = { 'ether': '00:00:00:00:00:03','ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1001'}
886 ingress_map = { 'ether': '00:00:00:00:00:04','ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1002' }
887 for i in range(3):
888 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -0800889 egressPort = egress + self.port_offset,
890 ingressPort = ingress + self.port_offset,
ChetanGaonker720ea612016-06-21 17:54:25 -0700891 icmpv6_type = '4',
892 icmpv6_code = i
893 )
894 result = flow.addFlow()
895 assert_equal(result, True)
896 ##wait for flows to be added to ONOS
897 time.sleep(1)
898 for i in range(3):
899 self.success = False
900 def mac_recv_task():
901 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -0700902 log_test.info('Pkt seen with ICMPv6 type %s, ICMPv6 code %s' %(pkt[ICMPv6ParamProblem].type, pkt[ICMPv6ParamProblem].code))
ChetanGaonker720ea612016-06-21 17:54:25 -0700903 self.success = True
904 sniff(count=2, timeout=5,
905 lfilter = lambda p: ICMPv6ParamProblem in p and p[ICMPv6ParamProblem].type == 4 and p[ICMPv6ParamProblem].code == i,
906 prn = recv_cb, iface = self.port_map[egress])
907
908 t = threading.Thread(target = mac_recv_task)
909 t.start()
910 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
911 L3 = IPv6(src = ingress_map['ipv6'], dst = egress_map['ipv6'])/ICMPv6ParamProblem(code = i)
912 pkt = L2/L3
A R Karthick76a497a2017-04-12 10:59:39 -0700913 log_test.info('Sending packets to verify if flows are correct')
ChetanGaonker720ea612016-06-21 17:54:25 -0700914 sendp(pkt, count=50, iface = self.port_map[ingress])
915 t.join()
916 assert_equal(self.success, True)
917
918 def test_flow_icmpv6_ND_Target_address(self):
919 egress = 1
920 ingress = 2
921 ingress_map = { 'ether': '00:00:00:00:00:04','ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1002'}
922 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -0800923 egressPort = egress + self.port_offset,
924 ingressPort = ingress + self.port_offset,
ChetanGaonker720ea612016-06-21 17:54:25 -0700925 ipv6_target = '2001:db8:a0b:12f0:1010:1010:1010:1001')
926 result = flow.addFlow()
927 assert_equal(result, True)
928 ##wait for flows to be added to ONOS
929 time.sleep(1)
930 self.success = False
931 def mac_recv_task():
932 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -0700933 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 -0700934 self.success = True
935 sniff(count=2, timeout=5,
936 lfilter = lambda p: ICMPv6ND_NS in p and p[ICMPv6ND_NS].tgt == '2001:db8:a0b:12f0:1010:1010:1010:1001',
937 prn = recv_cb, iface = self.port_map[egress])
938
939 t = threading.Thread(target = mac_recv_task)
940 t.start()
941 L2 = Ether(src = ingress_map['ether'])
942 L3 = IPv6(src = ingress_map['ipv6'])/ICMPv6ND_NS(tgt = '2001:db8:a0b:12f0:1010:1010:1010:1001')
943 pkt = L2/L3
A R Karthick76a497a2017-04-12 10:59:39 -0700944 log_test.info('Sending packets to verify if flows are correct')
ChetanGaonker720ea612016-06-21 17:54:25 -0700945 sendp(pkt, count=50, iface = self.port_map[ingress])
946 t.join()
947 assert_equal(self.success, True)
948
949 def test_flow_icmpv6_ND_SLL(self):
950 egress = 1
951 ingress = 2
952 egress_map = { 'ether': '00:00:00:00:00:03', 'ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1001'}
953 ingress_map = { 'ether': '00:00:00:00:00:04','ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1002'}
954 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -0800955 egressPort = egress + self.port_offset,
956 ingressPort = ingress + self.port_offset,
ChetanGaonker720ea612016-06-21 17:54:25 -0700957 ipv6_sll = ingress_map['ether'])
958 result = flow.addFlow()
959 assert_equal(result, True)
960 ##wait for flows to be added to ONOS
961 time.sleep(1)
962 self.success = False
963 def mac_recv_task():
964 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -0700965 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 -0700966 self.success = True
967 sniff(count=2, timeout=5,
968 lfilter = lambda p: ICMPv6NDOptSrcLLAddr in p and p[ICMPv6NDOptSrcLLAddr].lladdr == ingress_map['ether'],
969 prn = recv_cb, iface = self.port_map[egress])
970
971 t = threading.Thread(target = mac_recv_task)
972 t.start()
973 L2 = Ether(src = ingress_map['ether'])#, dst = ingress_map['ether'])
974 L3 = IPv6(src = ingress_map['ipv6'], dst = egress_map['ipv6'])/ICMPv6ND_NS(tgt = egress_map['ipv6'])/ICMPv6NDOptSrcLLAddr(lladdr = ingress_map['ether'])
975 pkt = L2/L3
A R Karthick76a497a2017-04-12 10:59:39 -0700976 log_test.info('Sending packets to verify if flows are correct')
ChetanGaonker720ea612016-06-21 17:54:25 -0700977 sendp(pkt, count=50, iface = self.port_map[ingress])
978 t.join()
979 assert_equal(self.success, True)
980
981 def test_flow_icmpv6_NA_TLL(self):
982 egress = 1
983 ingress = 2
984 egress_map = { 'ether': '00:00:00:00:00:03', 'ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1001'}
985 ingress_map = { 'ether': '00:00:00:00:00:04','ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1002'}
986 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -0800987 egressPort = egress + self.port_offset,
988 ingressPort = ingress + self.port_offset,
ChetanGaonker720ea612016-06-21 17:54:25 -0700989 ipv6_tll = egress_map['ether'])
990 result = flow.addFlow()
991 assert_equal(result, True)
992 ##wait for flows to be added to ONOS
993 time.sleep(1)
994 self.success = False
995 def mac_recv_task():
996 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -0700997 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 -0700998 self.success = True
999 sniff(count=2, timeout=5,
1000 lfilter = lambda p: ICMPv6NDOptDstLLAddr in p and p[ICMPv6NDOptDstLLAddr].lladdr == ingress_map['ether'],
1001 prn = recv_cb, iface = self.port_map[egress])
1002
1003 t = threading.Thread(target = mac_recv_task)
1004 t.start()
1005 L2 = Ether(src = ingress_map['ether'])#, dst = ingress_map['ether'])
1006 L3 = IPv6(src = ingress_map['ipv6'], dst = egress_map['ipv6'])/ICMPv6ND_NA(tgt = ingress_map['ipv6'])/ICMPv6NDOptDstLLAddr(lladdr = ingress_map['ether'])
1007 pkt = L2/L3
A R Karthick76a497a2017-04-12 10:59:39 -07001008 log_test.info('Sending packets to verify if flows are correct')
ChetanGaonker720ea612016-06-21 17:54:25 -07001009 sendp(pkt, count=50, iface = self.port_map[ingress])
1010 t.join()
1011 assert_equal(self.success, True)
1012
1013 def test_flow_ipv6_and_icmpv6(self):
1014 egress = 1
1015 ingress = 2
1016 egress_map = { 'ether': '00:00:00:00:00:03', 'ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1001' }
1017 ingress_map = { 'ether': '00:00:00:00:00:04', 'ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1002' }
1018 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -08001019 egressPort = egress + self.port_offset,
1020 ingressPort = ingress + self.port_offset,
ChetanGaonker720ea612016-06-21 17:54:25 -07001021 ethType = '0x86dd',
1022 ipSrc = ('IPV6_SRC', ingress_map['ipv6'] + '/48'),
1023 ipDst = ('IPV6_DST', egress_map['ipv6'] + '/48'),
1024 icmpv6_type = '128',
1025 icmpv6_code = 0
1026 )
1027
1028 result = flow.addFlow()
1029 assert_equal(result, True)
1030 ##wait for flows to be added to ONOS
1031 time.sleep(1)
1032 self.success = False
1033
1034 def mac_recv_task():
1035 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -07001036 log_test.info('Pkt seen with ingress ip %s, egress ip %s' %(pkt[IPv6].src, pkt[IPv6].dst))
ChetanGaonker720ea612016-06-21 17:54:25 -07001037 self.success = True
1038 sniff(count=2, timeout=5,
1039 lfilter = lambda p: IPv6 in p and p[IPv6].dst == egress_map['ipv6'] and p[IPv6].src == ingress_map['ipv6']
1040 and p[ICMPv6EchoRequest].type == 128 and p[ICMPv6EchoRequest].code == 0, prn = recv_cb, iface = self.port_map[egress])
1041
1042 t = threading.Thread(target = mac_recv_task)
1043 t.start()
1044 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
1045 L3 = IPv6(src = ingress_map['ipv6'] , dst = egress_map['ipv6'])/ICMPv6EchoRequest()
1046 pkt = L2/L3
A R Karthick76a497a2017-04-12 10:59:39 -07001047 log_test.info('Sending a packet to verify if flows are correct')
ChetanGaonker720ea612016-06-21 17:54:25 -07001048 sendp(pkt, count=50, iface = self.port_map[ingress])
1049 t.join()
1050 assert_equal(self.success, True)
1051
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001052 def test_5_flow_constant_dst_mac(self):
1053 egress = 1
1054 ingress = 2
1055 egress_mac = '00:00:00:00:01:01'
1056 ingress_mac = '00:00:00:00:00:00'
1057
ChetanGaonker720ea612016-06-21 17:54:25 -07001058
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001059 for i in range(0,5):
1060 ingress_mac = self.next_mac(ingress_mac)
1061
1062 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -08001063 egressPort = egress + self.port_offset,
1064 ingressPort = ingress + self.port_offset,
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001065 ethSrc = ingress_mac,
1066 ethDst = egress_mac)
1067 result = flow.addFlow()
1068 assert_equal(result, True)
1069 ##wait for flows to be added to ONOS
1070 time.sleep(1)
A R Karthick76a497a2017-04-12 10:59:39 -07001071 log_test.info("%d flow added.",i+1)
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001072 self.success = False
1073
1074 def mac_recv_task():
1075 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -07001076 log_test.info('Pkt seen with ingress mac %s, egress mac %s' %(pkt.src, pkt.dst))
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001077 self.success = True
1078 sniff(count=2, timeout=5, lfilter = lambda p: p.src == '00:00:00:00:00:02',
ChetanGaonker720ea612016-06-21 17:54:25 -07001079 prn = recv_cb, iface = self.port_map[egress])
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001080
1081 t = threading.Thread(target = mac_recv_task)
1082 t.start()
1083 pkt = Ether(src = '00:00:00:00:00:02', dst = egress_mac)/IP()
A R Karthick76a497a2017-04-12 10:59:39 -07001084 log_test.info('Sending packets to verify if flows are correct')
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001085 sendp(pkt, count=50, iface = self.port_map[ingress])
1086 t.join()
1087 assert_equal(self.success, True)
1088
1089
1090 def test_500_flow_constant_dst_mac(self):
1091 egress = 1
1092 ingress = 2
1093 egress_mac = '00:00:00:00:01:01'
1094 ingress_mac = '00:00:00:00:00:00'
1095 success_dir = {}
1096
1097 for i in range(0,500):
1098 ingress_mac = self.next_mac(ingress_mac)
1099
1100 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -08001101 egressPort = egress + self.port_offset,
1102 ingressPort = ingress + self.port_offset,
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001103 ethSrc = ingress_mac,
1104 ethDst = egress_mac)
1105 result = flow.addFlow()
1106 assert_equal(result, True)
1107 ##wait for flows to be added to ONOS
1108 time.sleep(1)
A R Karthick76a497a2017-04-12 10:59:39 -07001109 log_test.info("%d flow added.",i+1)
ChetanGaonker720ea612016-06-21 17:54:25 -07001110 self.success = True
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001111
1112 def verify_flow(*r):
1113 random_src = ''.join(r)
1114 def mac_recv_task():
1115 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -07001116 log_test.info('Pkt seen with ingress mac %s, egress mac %s' %(pkt.src, pkt.dst))
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001117 success_dir[current_thread().name] = True
1118 sniff(count=2, timeout=5, lfilter = lambda p: p.src == random_src,
ChetanGaonker720ea612016-06-21 17:54:25 -07001119 prn = recv_cb, iface = self.port_map[egress])
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001120
ChetanGaonker720ea612016-06-21 17:54:25 -07001121 t = threading.Thread(target = mac_recv_task)
1122 t.start()
1123 pkt = Ether(src = random_src, dst = egress_mac)/IP()
A R Karthick76a497a2017-04-12 10:59:39 -07001124 log_test.info('Sending packets to verify if flows are correct')
ChetanGaonker720ea612016-06-21 17:54:25 -07001125 sendp(pkt, count=50, iface = self.port_map[ingress])
1126 t.join()
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001127
1128 t1 = threading.Thread(target = verify_flow, args = '00:00:00:00:00:01')
1129 t2 = threading.Thread(target = verify_flow, args = '00:00:00:00:00:' + hex(random.randrange(50,254)).split('x')[1])
1130 t3 = threading.Thread(target = verify_flow, args = '01:00:00:00:00:' + hex(random.randrange(16,100)).split('x')[1])
1131 t4 = threading.Thread(target = verify_flow, args = '01:00:00:00:00:' + hex(random.randrange(101,240)).split('x')[1])
1132 t5 = threading.Thread(target = verify_flow, args = '01:00:00:00:00:f5')
1133 t1.start()
1134 t2.start()
1135 t3.start()
1136 t4.start()
1137 t5.start()
ChetanGaonker720ea612016-06-21 17:54:25 -07001138
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001139 t1.join()
1140 t2.join()
1141 t3.join()
1142 t4.join()
1143 t5.join()
ChetanGaonker720ea612016-06-21 17:54:25 -07001144
1145 if len(success_dir) != 5:
1146 self.success = False
1147
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001148 assert_equal(self.success, True)
1149
ChetanGaonker720ea612016-06-21 17:54:25 -07001150
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001151 def test_1k_flow_constant_dst_mac(self):
1152 egress = 1
1153 ingress = 2
1154 egress_mac = '00:00:00:00:01:01'
1155 ingress_mac = '00:00:00:00:00:00'
1156 success_dir = {}
1157
1158 for i in range(0,1000):
1159 ingress_mac = self.next_mac(ingress_mac)
ChetanGaonker720ea612016-06-21 17:54:25 -07001160
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001161 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -08001162 egressPort = egress + self.port_offset,
1163 ingressPort = ingress + self.port_offset,
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001164 ethSrc = ingress_mac,
1165 ethDst = egress_mac)
1166 result = flow.addFlow()
1167 assert_equal(result, True)
1168 ##wait for flows to be added to ONOS
1169 time.sleep(1)
A R Karthick76a497a2017-04-12 10:59:39 -07001170 log_test.info("%d flow added.",i+1)
ChetanGaonker720ea612016-06-21 17:54:25 -07001171 self.success = True
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001172
1173 def verify_flow(*r):
1174 random_src = ''.join(r)
1175 def mac_recv_task():
1176 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -07001177 log_test.info('Pkt seen with ingress mac %s, egress mac %s' %(pkt.src, pkt.dst))
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001178 success_dir[current_thread().name] = True
1179 sniff(count=2, timeout=5, lfilter = lambda p: p.src == random_src,
ChetanGaonker720ea612016-06-21 17:54:25 -07001180 prn = recv_cb, iface = self.port_map[egress])
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001181
1182 t = threading.Thread(target = mac_recv_task)
1183 t.start()
1184 pkt = Ether(src = random_src, dst = egress_mac)/IP()
A R Karthick76a497a2017-04-12 10:59:39 -07001185 log_test.info('Sending packets to verify if flows are correct')
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001186 sendp(pkt, count=50, iface = self.port_map[ingress])
1187 t.join()
1188
1189 t1 = threading.Thread(target = verify_flow, args = '00:00:00:00:00:01')
1190 t2 = threading.Thread(target = verify_flow, args = '00:00:00:00:00:' + hex(random.randrange(50,254)).split('x')[1])
1191 t3 = threading.Thread(target = verify_flow, args = '01:00:00:00:00:09')
1192 t4 = threading.Thread(target = verify_flow, args = '01:00:00:00:00:' + hex(random.randrange(16,150)).split('x')[1])
1193 t5 = threading.Thread(target = verify_flow, args = '01:00:00:00:00:' + hex(random.randrange(151,250)).split('x')[1])
1194 t6 = threading.Thread(target = verify_flow, args = '02:00:00:00:00:08')
1195 t7 = threading.Thread(target = verify_flow, args = '02:00:00:00:00:' + hex(random.randrange(16,150)).split('x')[1])
1196 t8 = threading.Thread(target = verify_flow, args = '02:00:00:00:00:' + hex(random.randrange(151,250)).split('x')[1])
1197 t9 = threading.Thread(target = verify_flow, args = '03:00:00:00:00:'+ hex(random.randrange(16,175)).split('x')[1])
1198 t10 = threading.Thread(target = verify_flow, args = '03:00:00:00:00:eb')
1199 t1.start()
1200 t2.start()
1201 t3.start()
1202 t4.start()
1203 t5.start()
1204 t6.start()
1205 t7.start()
1206 t8.start()
1207 t9.start()
1208 t10.start()
1209
1210 t1.join()
1211 t2.join()
1212 t3.join()
1213 t4.join()
1214 t5.join()
1215 t6.join()
1216 t7.join()
1217 t8.join()
1218 t9.join()
1219 t10.join()
ChetanGaonker720ea612016-06-21 17:54:25 -07001220 if len(success_dir) != 10:
1221 self.success = False
1222
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001223 assert_equal(self.success, True)
1224
1225
1226 @nottest
1227 def test_10k_flow_constant_dst_mac(self):
1228 egress = 1
1229 ingress = 2
1230 egress_mac = '00:00:00:00:01:01'
1231 ingress_mac = '00:00:00:00:00:00'
1232 success_dir = {}
1233
ChetanGaonker720ea612016-06-21 17:54:25 -07001234
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001235 for i in range(0,10000):
1236 ingress_mac = self.next_mac(ingress_mac)
1237
1238 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -08001239 egressPort = egress + self.port_offset,
1240 ingressPort = ingress + self.port_offset,
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001241 ethSrc = ingress_mac,
1242 ethDst = egress_mac)
1243 result = flow.addFlow()
1244 assert_equal(result, True)
1245 ##wait for flows to be added to ONOS
1246 time.sleep(1)
A R Karthick76a497a2017-04-12 10:59:39 -07001247 log_test.info("%d flow added.",i+1)
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001248 self.success = True
1249
1250 def verify_flow(*r):
1251 random_src = ''.join(r)
1252 def mac_recv_task():
1253 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -07001254 log_test.info('Pkt seen with ingress mac %s, egress mac %s' %(pkt.src, pkt.dst))
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001255 success_dir[current_thread().name] = True
1256 sniff(count=2, timeout=5, lfilter = lambda p: p.src == random_src,
ChetanGaonker720ea612016-06-21 17:54:25 -07001257 prn = recv_cb, iface = self.port_map[egress])
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001258
1259 t = threading.Thread(target = mac_recv_task)
1260 t.start()
1261 pkt = Ether(src = random_src, dst = egress_mac)/IP()
A R Karthick76a497a2017-04-12 10:59:39 -07001262 log_test.info('Sending packets to verify if flows are correct')
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001263 sendp(pkt, count=50, iface = self.port_map[ingress])
1264 t.join()
1265
1266 t1 = threading.Thread(target = verify_flow, args = '00:00:00:00:00:01')
1267 t2 = threading.Thread(target = verify_flow, args = '01:00:00:00:00:' + hex(random.randrange(16,254)).split('x')[1])
1268 t3 = threading.Thread(target = verify_flow, args = '02:00:00:00:00:'+ hex(random.randrange(16,254)).split('x')[1])
1269 t4 = threading.Thread(target = verify_flow, args = '05:00:00:00:00:' + hex(random.randrange(16,254)).split('x')[1])
1270 t5 = threading.Thread(target = verify_flow, args = '07:00:00:00:00:' + hex(random.randrange(16,254)).split('x')[1])
1271 t6 = threading.Thread(target = verify_flow, args = hex(random.randrange(16,21)).split('x')[1] + ':00:00:00:00:08')
1272 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 -07001273 hex(random.randrange(16,254)).split('x')[1])
1274
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001275 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 -07001276 hex(random.randrange(16,254)).split('x')[1])
1277
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001278 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 -07001279 hex(random.randrange(16,254)).split('x')[1])
1280
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001281 t10 = threading.Thread(target = verify_flow, args = '27:00:00:00:00:37')
1282
1283 t1.start()
1284 t2.start()
1285 t3.start()
1286 t4.start()
1287 t5.start()
1288 t6.start()
1289 t7.start()
1290 t8.start()
1291 t9.start()
1292 t10.start()
1293
1294 t1.join()
1295 t2.join()
1296 t3.join()
1297 t4.join()
1298 t5.join()
1299 t6.join()
1300 t7.join()
1301 t8.join()
1302 t9.join()
1303 t10.join()
ChetanGaonker720ea612016-06-21 17:54:25 -07001304 if len(success_dir) != 10:
1305 self.success = False
1306
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001307 assert_equal(self.success, True)
1308
1309 @nottest
1310 def test_100k_flow_constant_dst_mac(self):
1311 egress = 1
1312 ingress = 2
1313 egress_mac = '00:00:00:00:01:01'
1314 ingress_mac = '00:00:00:00:00:00'
1315 success_dir = {}
1316
1317
1318 for i in range(0,100000):
1319 ingress_mac = self.next_mac(ingress_mac)
1320
1321 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -08001322 egressPort = egress + self.port_offset,
1323 ingressPort = ingress + self.port_offset,
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001324 ethSrc = ingress_mac,
1325 ethDst = egress_mac)
1326 result = flow.addFlow()
1327 assert_equal(result, True)
1328 ##wait for flows to be added to ONOS
1329 time.sleep(1)
A R Karthick76a497a2017-04-12 10:59:39 -07001330 log_test.info("%d flow added.",i+1)
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001331 self.success = True
1332
1333 def verify_flow(*r):
1334 random_src = ''.join(r)
1335 def mac_recv_task():
1336 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -07001337 log_test.info('Pkt seen with ingress mac %s, egress mac %s' %(pkt.src, pkt.dst))
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001338 success_dir[current_thread().name] = True
1339 sniff(count=2, timeout=5, lfilter = lambda p: p.src == random_src,
ChetanGaonker720ea612016-06-21 17:54:25 -07001340 prn = recv_cb, iface = self.port_map[egress])
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001341
1342 t = threading.Thread(target = mac_recv_task)
1343 t.start()
1344 pkt = Ether(src = random_src, dst = egress_mac)/IP()
A R Karthick76a497a2017-04-12 10:59:39 -07001345 log_test.info('Sending packets to verify if flows are correct')
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001346 sendp(pkt, count=50, iface = self.port_map[ingress])
1347 t.join()
1348
1349 t1 = threading.Thread(target = verify_flow, args = '00:00:00:00:00:01')
1350 t2 = threading.Thread(target = verify_flow, args = '01:00:00:00:00:' + hex(random.randrange(16,254)).split('x')[1])
1351 t3 = threading.Thread(target = verify_flow, args = '02:00:00:00:00:'+ hex(random.randrange(16,254)).split('x')[1])
1352 t4 = threading.Thread(target = verify_flow, args = '05:00:00:00:00:' + hex(random.randrange(16,254)).split('x')[1])
1353 t5 = threading.Thread(target = verify_flow, args = '07:00:00:00:00:' + hex(random.randrange(16,254)).split('x')[1])
1354 t6 = threading.Thread(target = verify_flow, args = hex(random.randrange(16,41)).split('x')[1] + ':00:00:00:00:08')
1355 t7 = threading.Thread(target = verify_flow, args = hex(random.randrange(42,72)).split('x')[1] +':00:00:00:00:' +
1356 hex(random.randrange(16,254)).split('x')[1])
1357
1358 t8 = threading.Thread(target = verify_flow, args = hex(random.randrange(73,100)).split('x')[1] +':00:00:00:00:' +
1359 hex(random.randrange(16,254)).split('x')[1])
1360
1361 t9 = threading.Thread(target = verify_flow, args = hex(random.randrange(101,136)).split('x')[1] +':00:00:00:00:' +
1362 hex(random.randrange(16,254)).split('x')[1])
1363
1364 t10 = threading.Thread(target = verify_flow, args = '89:01:00:00:00:28')
1365
1366 t1.start()
1367 t2.start()
1368 t3.start()
1369 t4.start()
1370 t5.start()
1371 t6.start()
1372 t7.start()
1373 t8.start()
1374 t9.start()
1375 t10.start()
1376
1377 t1.join()
1378 t2.join()
1379 t3.join()
1380 t4.join()
1381 t5.join()
1382 t6.join()
1383 t7.join()
1384 t8.join()
1385 t9.join()
1386 t10.join()
ChetanGaonker720ea612016-06-21 17:54:25 -07001387 if len(success_dir) != 10:
1388 self.success = False
1389
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001390 assert_equal(self.success, True)
1391
1392
1393 @nottest
1394 def test_1000k_flow_constant_dst_mac(self):
1395 egress = 1
1396 ingress = 2
1397 egress_mac = '00:00:00:00:01:01'
1398 ingress_mac = '00:00:00:00:00:00'
1399 success_dir = {}
1400
ChetanGaonker720ea612016-06-21 17:54:25 -07001401
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001402 for i in range(0,1000000):
1403 ingress_mac = self.next_mac(ingress_mac)
1404
1405 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -08001406 egressPort = egress + self.port_offset,
1407 ingressPort = ingress + self.port_offset,
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001408 ethSrc = ingress_mac,
1409 ethDst = egress_mac)
1410 result = flow.addFlow()
1411 assert_equal(result, True)
1412 ##wait for flows to be added to ONOS
1413 time.sleep(1)
A R Karthick76a497a2017-04-12 10:59:39 -07001414 log_test.info("%d flow added.",i+1)
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001415 self.success = True
1416
1417 def verify_flow(*r):
1418 random_src = ''.join(r)
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001419 def mac_recv_task():
1420 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -07001421 log_test.info('Pkt seen with ingress mac %s, egress mac %s' %(pkt.src, pkt.dst))
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001422 success_dir[current_thread().name] = True
1423 sniff(count=2, timeout=5, lfilter = lambda p: p.src == random_src,
ChetanGaonker720ea612016-06-21 17:54:25 -07001424 prn = recv_cb, iface = self.port_map[egress])
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001425
1426 t = threading.Thread(target = mac_recv_task)
1427 t.start()
1428 pkt = Ether(src = random_src, dst = egress_mac)/IP()
A R Karthick76a497a2017-04-12 10:59:39 -07001429 log_test.info('Sending packets to verify if flows are correct')
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001430 sendp(pkt, count=50, iface = self.port_map[ingress])
1431 t.join()
1432
1433 t1 = threading.Thread(target = verify_flow, args = '00:00:00:00:00:01')
1434 t2 = threading.Thread(target = verify_flow, args = '01:00:00:00:00:' + hex(random.randrange(16,254)).split('x')[1])
1435 t3 = threading.Thread(target = verify_flow, args = '02:00:00:00:00:'+ hex(random.randrange(16,254)).split('x')[1])
1436 t4 = threading.Thread(target = verify_flow, args = '05:00:00:00:00:' + hex(random.randrange(16,254)).split('x')[1])
1437 t5 = threading.Thread(target = verify_flow, args = '07:00:00:00:00:' + hex(random.randrange(16,254)).split('x')[1])
1438 t6 = threading.Thread(target = verify_flow, args = hex(random.randrange(16,21)).split('x')[1] + ':00:00:00:00:08')
1439 t7 = threading.Thread(target = verify_flow, args = hex(random.randrange(22,50)).split('x')[1] +':00:00:00:00:' +
1440 hex(random.randrange(16,254)).split('x')[1])
1441
1442 t8 = threading.Thread(target = verify_flow, args = hex(random.randrange(51,75)).split('x')[1] +':00:00:00:00:' +
1443 hex(random.randrange(16,254)).split('x')[1])
1444
1445 t9 = threading.Thread(target = verify_flow, args = hex(random.randrange(76,95)).split('x')[1] +':00:00:00:00:' +
1446 hex(random.randrange(16,254)).split('x')[1])
1447
1448 t10 = threading.Thread(target = verify_flow, args = '60:0f:00:00:00:91')
1449
1450 t1.start()
1451 t2.start()
1452 t3.start()
1453 t4.start()
1454 t5.start()
1455 t6.start()
1456 t7.start()
1457 t8.start()
1458 t9.start()
1459 t10.start()
1460
1461 t1.join()
1462 t2.join()
1463 t3.join()
1464 t4.join()
1465 t5.join()
1466 t6.join()
1467 t7.join()
1468 t8.join()
1469 t9.join()
1470 t10.join()
ChetanGaonker720ea612016-06-21 17:54:25 -07001471 if len(success_dir) != 10:
1472 self.success = False
1473
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001474 assert_equal(self.success, True)
1475
ChetanGaonker720ea612016-06-21 17:54:25 -07001476 def test_5_flow_constant_src_mac(self):
1477 egress = 1
1478 ingress = 2
1479 egress_mac = '00:00:00:00:01:00'
1480 ingress_mac = '00:00:00:00:00:01'
1481
1482
1483 for i in range(0,5):
1484 egress_mac = self.next_mac(egress_mac)
1485
1486 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -08001487 egressPort = egress + self.port_offset,
1488 ingressPort = ingress + self.port_offset,
ChetanGaonker720ea612016-06-21 17:54:25 -07001489 ethSrc = ingress_mac,
1490 ethDst = egress_mac)
1491 result = flow.addFlow()
1492 assert_equal(result, True)
1493 ##wait for flows to be added to ONOS
1494 time.sleep(1)
A R Karthick76a497a2017-04-12 10:59:39 -07001495 log_test.info("%d flow added.",i+1)
ChetanGaonker720ea612016-06-21 17:54:25 -07001496 self.success = False
1497
1498 def mac_recv_task():
1499 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -07001500 log_test.info('Pkt seen with ingress mac %s, egress mac %s' %(pkt.src, pkt.dst))
ChetanGaonker720ea612016-06-21 17:54:25 -07001501 self.success = True
1502 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',
1503 prn = recv_cb, iface = self.port_map[egress])
1504
1505 t = threading.Thread(target = mac_recv_task)
1506 t.start()
1507 pkt = Ether(src = ingress_mac, dst = '00:00:00:00:01:02')/IP()
A R Karthick76a497a2017-04-12 10:59:39 -07001508 log_test.info('Sending packets to verify if flows are correct')
ChetanGaonker720ea612016-06-21 17:54:25 -07001509 sendp(pkt, count=50, iface = self.port_map[ingress])
1510 t.join()
1511 assert_equal(self.success, True)
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001512
1513 def test_500_flow_mac(self):
1514 egress = 1
1515 ingress = 2
1516 egress_mac = '00:00:00:00:01:00'
1517 ingress_mac = '00:00:00:00:00:00'
1518 success_dir = {}
1519
1520 for i in range(0,500):
1521 ingress_mac = self.next_mac(ingress_mac)
1522 egress_mac = self.to_egress_mac(ingress_mac)
1523
1524 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -08001525 egressPort = egress + self.port_offset,
1526 ingressPort = ingress + self.port_offset,
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001527 ethSrc = ingress_mac,
1528 ethDst = egress_mac)
1529 result = flow.addFlow()
1530 assert_equal(result, True)
1531 ##wait for flows to be added to ONOS
1532 time.sleep(1)
A R Karthick76a497a2017-04-12 10:59:39 -07001533 log_test.info("%d flow added.",i+1)
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001534 self.success = True
1535 def verify_flow(*r):
1536 random_src = ''.join(r)
ChetanGaonker720ea612016-06-21 17:54:25 -07001537
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001538 def mac_recv_task():
1539 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -07001540 log_test.info('Pkt seen with ingress mac %s, egress mac %s' %(pkt.src, pkt.dst))
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001541 success_dir[current_thread().name] = True
1542 sniff(count=2, timeout=5, lfilter = lambda p: p.src == random_src,
ChetanGaonker720ea612016-06-21 17:54:25 -07001543 prn = recv_cb, iface = self.port_map[egress])
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001544
1545 t = threading.Thread(target = mac_recv_task)
1546 t.start()
1547 pkt = Ether(src = random_src, dst = self.to_egress_mac(random_src))/IP()
A R Karthick76a497a2017-04-12 10:59:39 -07001548 log_test.info('Sending packets to verify if flows are correct')
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001549 sendp(pkt, count=50, iface = self.port_map[ingress])
1550 t.join()
1551
1552 t1 = threading.Thread(target = verify_flow, args = '00:00:00:00:00:01')
1553 t2 = threading.Thread(target = verify_flow, args = '00:00:00:00:00:' + hex(random.randrange(50,254)).split('x')[1])
1554 t3 = threading.Thread(target = verify_flow, args = '01:00:00:00:00:' + hex(random.randrange(16,100)).split('x')[1])
1555 t4 = threading.Thread(target = verify_flow, args = '01:00:00:00:00:' + hex(random.randrange(101,240)).split('x')[1])
1556 t5 = threading.Thread(target = verify_flow, args = '01:00:00:00:00:f5')
1557 t1.start()
1558 t2.start()
1559 t3.start()
1560 t4.start()
1561 t5.start()
1562 t1.join()
1563 t2.join()
1564 t3.join()
1565 t4.join()
1566 t5.join()
ChetanGaonker720ea612016-06-21 17:54:25 -07001567 if len(success_dir) != 5:
1568 self.success = False
1569
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001570 assert_equal(self.success, True)
1571
1572 def test_1k_flow_mac(self):
1573 egress = 1
1574 ingress = 2
1575 egress_mac = '00:00:00:00:01:00'
1576 ingress_mac = '00:00:00:00:00:00'
1577 success_dir = {}
1578
1579 for i in range(0,1000):
1580 ingress_mac = self.next_mac(ingress_mac)
1581 egress_mac = self.to_egress_mac(ingress_mac)
1582
1583 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -08001584 egressPort = egress + self.port_offset,
1585 ingressPort = ingress + self.port_offset,
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001586 ethSrc = ingress_mac,
1587 ethDst = egress_mac)
1588 result = flow.addFlow()
1589 assert_equal(result, True)
1590 ##wait for flows to be added to ONOS
1591 time.sleep(1)
A R Karthick76a497a2017-04-12 10:59:39 -07001592 log_test.info("%d flow added.",i+1)
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001593 self.success = True
1594 def verify_flow(*r):
1595 random_src = ''.join(r)
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001596 def mac_recv_task():
1597 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -07001598 log_test.info('Pkt seen with ingress mac %s, egress mac %s' %(pkt.src, pkt.dst))
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001599 success_dir[current_thread().name] = True
ChetanGaonker720ea612016-06-21 17:54:25 -07001600 sniff(count=2, timeout=5, lfilter = lambda p: p.src == random_src,
1601 prn = recv_cb, iface = self.port_map[egress])
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001602
1603 t = threading.Thread(target = mac_recv_task)
1604 t.start()
ChetanGaonker720ea612016-06-21 17:54:25 -07001605 pkt = Ether(src = random_src, dst = self.to_egress_mac(random_src))/IP()
A R Karthick76a497a2017-04-12 10:59:39 -07001606 log_test.info('Sending packets to verify if flows are correct')
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001607 sendp(pkt, count=50, iface = self.port_map[ingress])
1608 t.join()
1609
1610 t1 = threading.Thread(target = verify_flow, args = '00:00:00:00:00:01')
1611 t2 = threading.Thread(target = verify_flow, args = '00:00:00:00:00:' + hex(random.randrange(50,254)).split('x')[1])
1612 t3 = threading.Thread(target = verify_flow, args = '01:00:00:00:00:09')
1613 t4 = threading.Thread(target = verify_flow, args = '01:00:00:00:00:' + hex(random.randrange(16,150)).split('x')[1])
1614 t5 = threading.Thread(target = verify_flow, args = '01:00:00:00:00:' + hex(random.randrange(151,250)).split('x')[1])
1615 t6 = threading.Thread(target = verify_flow, args = '02:00:00:00:00:08')
1616 t7 = threading.Thread(target = verify_flow, args = '02:00:00:00:00:' + hex(random.randrange(16,150)).split('x')[1])
1617 t8 = threading.Thread(target = verify_flow, args = '02:00:00:00:00:' + hex(random.randrange(151,250)).split('x')[1])
1618 t9 = threading.Thread(target = verify_flow, args = '03:00:00:00:00:'+ hex(random.randrange(16,175)).split('x')[1])
1619 t10 = threading.Thread(target = verify_flow, args = '03:00:00:00:00:eb')
ChetanGaonker720ea612016-06-21 17:54:25 -07001620
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001621 t1.start()
1622 t2.start()
1623 t3.start()
1624 t4.start()
1625 t5.start()
1626 t6.start()
1627 t7.start()
1628 t8.start()
1629 t9.start()
1630 t10.start()
1631
1632 t1.join()
1633 t2.join()
1634 t3.join()
1635 t4.join()
1636 t5.join()
1637 t6.join()
1638 t7.join()
1639 t8.join()
1640 t9.join()
1641 t10.join()
ChetanGaonker720ea612016-06-21 17:54:25 -07001642 if len(success_dir) != 10:
1643 self.success = False
1644
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001645 assert_equal(self.success, True)
1646
1647 @nottest
1648 def test_10k_flow_mac(self):
1649 egress = 1
1650 ingress = 2
1651 egress_mac = '00:00:00:00:01:00'
1652 ingress_mac = '00:00:00:00:00:00'
1653 success_dir = {}
1654
1655 for i in range(0,10000):
ChetanGaonker720ea612016-06-21 17:54:25 -07001656 ingress_mac = self.next_mac(ingress_mac)
1657 egress_mac = self.to_egress_mac(ingress_mac)
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001658
ChetanGaonker720ea612016-06-21 17:54:25 -07001659 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -08001660 egressPort = egress + self.port_offset,
1661 ingressPort = ingress + self.port_offset,
ChetanGaonker720ea612016-06-21 17:54:25 -07001662 ethSrc = ingress_mac,
1663 ethDst = egress_mac)
1664 result = flow.addFlow()
1665 assert_equal(result, True)
1666 ##wait for flows to be added to ONOS
1667 time.sleep(1)
A R Karthick76a497a2017-04-12 10:59:39 -07001668 log_test.info("%d flow added.",i+1)
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001669 self.success = True
1670 def verify_flow(*r):
1671 random_src = ''.join(r)
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001672 def mac_recv_task():
1673 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -07001674 log_test.info('Pkt seen with ingress mac %s, egress mac %s' %(pkt.src, pkt.dst))
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001675 success_dir[current_thread().name] = True
1676 sniff(count=2, timeout=5, lfilter = lambda p: p.src == random_src,
ChetanGaonker720ea612016-06-21 17:54:25 -07001677 prn = recv_cb, iface = self.port_map[egress])
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001678
1679 t = threading.Thread(target = mac_recv_task)
1680 t.start()
1681 pkt = Ether(src = random_src, dst = self.to_egress_mac(random_src))/IP()
A R Karthick76a497a2017-04-12 10:59:39 -07001682 log_test.info('Sending packets to verify if flows are correct')
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001683 sendp(pkt, count=50, iface = self.port_map[ingress])
1684 t.join()
1685
1686 t1 = threading.Thread(target = verify_flow, args = '00:00:00:00:00:01')
1687 t2 = threading.Thread(target = verify_flow, args = '01:00:00:00:00:' + hex(random.randrange(16,254)).split('x')[1])
1688 t3 = threading.Thread(target = verify_flow, args = '02:00:00:00:00:'+ hex(random.randrange(16,254)).split('x')[1])
1689 t4 = threading.Thread(target = verify_flow, args = '05:00:00:00:00:' + hex(random.randrange(16,254)).split('x')[1])
1690 t5 = threading.Thread(target = verify_flow, args = '07:00:00:00:00:' + hex(random.randrange(16,254)).split('x')[1])
1691 t6 = threading.Thread(target = verify_flow, args = hex(random.randrange(16,21)).split('x')[1] + ':00:00:00:00:08')
1692 t7 = threading.Thread(target = verify_flow, args = hex(random.randrange(17,21)).split('x')[1] +':00:00:00:00:' +
1693 hex(random.randrange(16,254)).split('x')[1])
1694
1695 t8 = threading.Thread(target = verify_flow, args = hex(random.randrange(22,30)).split('x')[1] +':00:00:00:00:' +
1696 hex(random.randrange(16,254)).split('x')[1])
1697
1698 t9 = threading.Thread(target = verify_flow, args = hex(random.randrange(31,38)).split('x')[1] +':00:00:00:00:' +
1699 hex(random.randrange(16,254)).split('x')[1])
1700
1701 t10 = threading.Thread(target = verify_flow, args = '27:00:00:00:00:37')
1702
1703 t1.start()
1704 t2.start()
1705 t3.start()
1706 t4.start()
1707 t5.start()
1708 t6.start()
1709 t7.start()
1710 t8.start()
1711 t9.start()
1712 t10.start()
1713
1714 t1.join()
1715 t2.join()
1716 t3.join()
1717 t4.join()
1718 t5.join()
1719 t6.join()
1720 t7.join()
1721 t8.join()
1722 t9.join()
1723 t10.join()
ChetanGaonker720ea612016-06-21 17:54:25 -07001724 if len(success_dir) != 10:
1725 self.success = False
1726
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001727 assert_equal(self.success, True)
1728
1729 @nottest
1730 def test_100k_flow_mac(self):
1731 egress = 1
1732 ingress = 2
1733 egress_mac = '00:00:00:00:01:00'
1734 ingress_mac = '00:00:00:00:00:00'
1735 success_dir = {}
1736
1737 for i in range(0,100000):
1738 ingress_mac = self.next_mac(ingress_mac)
1739 egress_mac = self.to_egress_mac(ingress_mac)
1740
1741 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -08001742 egressPort = egress + self.port_offset,
1743 ingressPort = ingress + self.port_offset,
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001744 ethSrc = ingress_mac,
1745 ethDst = egress_mac)
1746 result = flow.addFlow()
1747 assert_equal(result, True)
1748 ##wait for flows to be added to ONOS
1749 time.sleep(1)
A R Karthick76a497a2017-04-12 10:59:39 -07001750 log_test.info("%d flow added.",i+1)
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001751 self.success = True
1752
1753 def verify_flow(*r):
1754 random_src = ''.join(r)
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001755 def mac_recv_task():
1756 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -07001757 log_test.info('Pkt seen with ingress mac %s, egress mac %s' %(pkt.src, pkt.dst))
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001758 success_dir[current_thread().name] = True
1759 sniff(count=2, timeout=5, lfilter = lambda p: p.src == random_src,
ChetanGaonker720ea612016-06-21 17:54:25 -07001760 prn = recv_cb, iface = self.port_map[egress])
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001761
1762 t = threading.Thread(target = mac_recv_task)
1763 t.start()
1764 pkt = Ether(src = random_src, dst = self.to_egress_mac(random_src))/IP()
A R Karthick76a497a2017-04-12 10:59:39 -07001765 log_test.info('Sending packets to verify if flows are correct')
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001766 sendp(pkt, count=50, iface = self.port_map[ingress])
1767 t.join()
1768
1769 t1 = threading.Thread(target = verify_flow, args = '00:00:00:00:00:01')
1770 t2 = threading.Thread(target = verify_flow, args = '01:00:00:00:00:' + hex(random.randrange(16,254)).split('x')[1])
1771 t3 = threading.Thread(target = verify_flow, args = '02:00:00:00:00:'+ hex(random.randrange(16,254)).split('x')[1])
1772 t4 = threading.Thread(target = verify_flow, args = '05:00:00:00:00:' + hex(random.randrange(16,254)).split('x')[1])
1773 t5 = threading.Thread(target = verify_flow, args = '07:00:00:00:00:' + hex(random.randrange(16,254)).split('x')[1])
1774 t6 = threading.Thread(target = verify_flow, args = hex(random.randrange(16,41)).split('x')[1] + ':00:00:00:00:08')
1775 t7 = threading.Thread(target = verify_flow, args = hex(random.randrange(42,72)).split('x')[1] +':00:00:00:00:' +
1776 hex(random.randrange(16,254)).split('x')[1])
1777
1778 t8 = threading.Thread(target = verify_flow, args = hex(random.randrange(73,100)).split('x')[1] +':00:00:00:00:' +
1779 hex(random.randrange(16,254)).split('x')[1])
1780
1781 t9 = threading.Thread(target = verify_flow, args = hex(random.randrange(101,136)).split('x')[1] +':00:00:00:00:' +
1782 hex(random.randrange(16,254)).split('x')[1])
1783
1784 t10 = threading.Thread(target = verify_flow, args = '89:01:00:00:00:28')
1785
1786 t1.start()
1787 t2.start()
1788 t3.start()
1789 t4.start()
1790 t5.start()
1791 t6.start()
1792 t7.start()
1793 t8.start()
1794 t9.start()
1795 t10.start()
1796
1797 t1.join()
1798 t2.join()
1799 t3.join()
1800 t4.join()
1801 t5.join()
1802 t6.join()
1803 t7.join()
1804 t8.join()
1805 t9.join()
1806 t10.join()
ChetanGaonker720ea612016-06-21 17:54:25 -07001807 if len(success_dir) != 10:
1808 self.success = False
1809
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001810 assert_equal(self.success, True)
1811
1812 @nottest
1813 def test_1000k_flow_mac(self):
1814 egress = 1
1815 ingress = 2
1816 egress_mac = '00:00:00:00:01:00'
1817 ingress_mac = '00:00:00:00:00:00'
1818 success_dir = {}
1819
1820 for i in range(0,1000000):
1821 ingress_mac = self.next_mac(ingress_mac)
1822 egress_mac = self.to_egress_mac(ingress_mac)
1823
1824 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -08001825 egressPort = egress + self.port_offset,
1826 ingressPort = ingress + self.port_offset,
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001827 ethSrc = ingress_mac,
1828 ethDst = egress_mac)
1829 result = flow.addFlow()
1830 assert_equal(result, True)
1831 ##wait for flows to be added to ONOS
1832 time.sleep(1)
A R Karthick76a497a2017-04-12 10:59:39 -07001833 log_test.info("%d flow added.",i+1)
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001834 self.success = True
1835
1836 def verify_flow(*r):
1837 random_src = ''.join(r)
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001838 def mac_recv_task():
ChetanGaonker720ea612016-06-21 17:54:25 -07001839 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -07001840 log_test.info('Pkt seen with ingress mac %s, egress mac %s' %(pkt.src, pkt.dst))
ChetanGaonker720ea612016-06-21 17:54:25 -07001841 success_dir[current_thread().name] = True
1842 sniff(count=2, timeout=5, lfilter = lambda p: p.src == random_src,
1843 prn = recv_cb, iface = self.port_map[egress])
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001844
1845 t = threading.Thread(target = mac_recv_task)
1846 t.start()
1847 pkt = Ether(src = random_src, dst = egress_mac)/IP()
A R Karthick76a497a2017-04-12 10:59:39 -07001848 log_test.info('Sending packets to verify if flows are correct')
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001849 sendp(pkt, count=50, iface = self.port_map[ingress])
1850 t.join()
1851
1852 t1 = threading.Thread(target = verify_flow, args = '00:00:00:00:00:01')
1853 t2 = threading.Thread(target = verify_flow, args = '01:00:00:00:00:' + hex(random.randrange(16,254)).split('x')[1])
1854 t3 = threading.Thread(target = verify_flow, args = '02:00:00:00:00:'+ hex(random.randrange(16,254)).split('x')[1])
1855 t4 = threading.Thread(target = verify_flow, args = '05:00:00:00:00:' + hex(random.randrange(16,254)).split('x')[1])
1856 t5 = threading.Thread(target = verify_flow, args = '07:00:00:00:00:' + hex(random.randrange(16,254)).split('x')[1])
1857 t6 = threading.Thread(target = verify_flow, args = hex(random.randrange(16,21)).split('x')[1] + ':00:00:00:00:08')
1858 t7 = threading.Thread(target = verify_flow, args = hex(random.randrange(22,50)).split('x')[1] +':00:00:00:00:' +
1859 hex(random.randrange(16,254)).split('x')[1])
1860
1861 t8 = threading.Thread(target = verify_flow, args = hex(random.randrange(51,75)).split('x')[1] +':00:00:00:00:' +
1862 hex(random.randrange(16,254)).split('x')[1])
1863
1864 t9 = threading.Thread(target = verify_flow, args = hex(random.randrange(76,95)).split('x')[1] +':00:00:00:00:' +
1865 hex(random.randrange(16,254)).split('x')[1])
1866
1867 t10 = threading.Thread(target = verify_flow, args = '60:0f:00:00:00:91')
1868
1869 t1.start()
1870 t2.start()
1871 t3.start()
1872 t4.start()
1873 t5.start()
1874 t6.start()
1875 t7.start()
1876 t8.start()
1877 t9.start()
1878 t10.start()
1879
1880 t1.join()
1881 t2.join()
1882 t3.join()
1883 t4.join()
1884 t5.join()
1885 t6.join()
1886 t7.join()
1887 t8.join()
1888 t9.join()
1889 t10.join()
ChetanGaonker720ea612016-06-21 17:54:25 -07001890 if len(success_dir) != 10:
1891 self.success = False
1892
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07001893 assert_equal(self.success, True)
1894
ChetanGaonkerd376b902016-06-14 11:50:28 -07001895 def test_rate_100_flow_mac(self):
1896 egress = 1
1897 ingress = 2
1898 egress_mac = '00:00:00:00:01:00'
1899 ingress_mac = '00:00:00:00:00:00'
1900 flows_added = 0
1901 stats_dir = collections.OrderedDict()
1902 running_time = 0
1903
1904
1905 for i in range(1,4):
1906 start_time = time.time()
1907 for j in range(0,100):
1908 ingress_mac = self.next_mac(ingress_mac)
1909 egress_mac = self.to_egress_mac(ingress_mac)
1910
1911 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -08001912 egressPort = egress + self.port_offset,
1913 ingressPort = ingress + self.port_offset,
ChetanGaonkerd376b902016-06-14 11:50:28 -07001914 ethSrc = ingress_mac,
1915 ethDst = egress_mac)
1916 result = flow.addFlow()
1917 assert_equal(result, True)
1918 flows_added += 1
1919 ##wait for flows to be added to ONOS
ChetanGaonker720ea612016-06-21 17:54:25 -07001920 time.sleep(1)
A R Karthick76a497a2017-04-12 10:59:39 -07001921 log_test.info("%d flow added.",j+1)
ChetanGaonkerd376b902016-06-14 11:50:28 -07001922 end_time = time.time()
1923 stats_dir['run '+str(i)] = round((end_time - start_time),2)
1924 for t in stats_dir.items():
A R Karthick76a497a2017-04-12 10:59:39 -07001925 log_test.info("----------------------------------------------")
1926 log_test.info("Statics for %s",t[0])
1927 log_test.info("----------------------------------------------")
1928 log_test.info("No. of flows added Running Time ")
1929 log_test.info(" %d %s " %(100, t[1]))
ChetanGaonker720ea612016-06-21 17:54:25 -07001930 running_time += float(t[1])
ChetanGaonkerd376b902016-06-14 11:50:28 -07001931
A R Karthick76a497a2017-04-12 10:59:39 -07001932 log_test.info("-------------------------------------------------------------------------------------------------------")
1933 log_test.info("Final Statics")
1934 log_test.info("-------------------------------------------------------------------------------------------------------")
1935 log_test.info("Total No. of flows added Total Running Time Average no. of flows per second ")
1936 log_test.info(" %d %s second %d "
ChetanGaonkerd376b902016-06-14 11:50:28 -07001937 %(flows_added, running_time, round(flows_added/running_time,0)))
A R Karthick76a497a2017-04-12 10:59:39 -07001938 log_test.info("-------------------------------------------------------------------------------------------------------")
ChetanGaonkerd376b902016-06-14 11:50:28 -07001939
1940
1941
1942 def test_rate_500_flow_mac(self):
1943 egress = 1
1944 ingress = 2
1945 egress_mac = '00:00:00:00:01:00'
1946 ingress_mac = '00:00:00:00:00:00'
1947 flows_added = 0
1948 stats_dir = collections.OrderedDict()
1949 running_time = 0
1950
1951
1952 for i in range(1,4):
1953 start_time = time.time()
1954 for j in range(0,500):
1955 ingress_mac = self.next_mac(ingress_mac)
1956 egress_mac = self.to_egress_mac(ingress_mac)
1957
1958 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -08001959 egressPort = egress + self.port_offset,
1960 ingressPort = ingress + self.port_offset,
ChetanGaonkerd376b902016-06-14 11:50:28 -07001961 ethSrc = ingress_mac,
1962 ethDst = egress_mac)
1963 result = flow.addFlow()
1964 assert_equal(result, True)
1965 flows_added += 1
1966 ##wait for flows to be added to ONOS
ChetanGaonker720ea612016-06-21 17:54:25 -07001967 time.sleep(1)
A R Karthick76a497a2017-04-12 10:59:39 -07001968 log_test.info("%d flow added.",j+1)
ChetanGaonkerd376b902016-06-14 11:50:28 -07001969 end_time = time.time()
1970 stats_dir['run '+str(i)] = round((end_time - start_time),2)
1971 for t in stats_dir.items():
A R Karthick76a497a2017-04-12 10:59:39 -07001972 log_test.info("----------------------------------------------")
1973 log_test.info("Statics for %s",t[0])
1974 log_test.info("----------------------------------------------")
1975 log_test.info("No. of flows added Running Time ")
1976 log_test.info(" %d %s " %(500, t[1]))
ChetanGaonkerd376b902016-06-14 11:50:28 -07001977 running_time += float(t[1])
1978
A R Karthick76a497a2017-04-12 10:59:39 -07001979 log_test.info("-------------------------------------------------------------------------------------------------------")
1980 log_test.info("Final Statics")
1981 log_test.info("-------------------------------------------------------------------------------------------------------")
1982 log_test.info("Total No. of flows added Total Running Time Average no. of flows per second ")
1983 log_test.info(" %d %s second %d "
ChetanGaonkerd376b902016-06-14 11:50:28 -07001984 %(flows_added, running_time, round(flows_added/running_time,0)))
A R Karthick76a497a2017-04-12 10:59:39 -07001985 log_test.info("-------------------------------------------------------------------------------------------------------")
ChetanGaonkerd376b902016-06-14 11:50:28 -07001986
1987 def test_rate_1k_flow_mac(self):
1988 egress = 1
1989 ingress = 2
1990 egress_mac = '00:00:00:00:01:00'
1991 ingress_mac = '00:00:00:00:00:00'
1992 flows_added = 0
1993 stats_dir = collections.OrderedDict()
1994 running_time = 0
1995
1996
1997 for i in range(1,4):
1998 start_time = time.time()
1999 for j in range(0,1000):
2000 ingress_mac = self.next_mac(ingress_mac)
2001 egress_mac = self.to_egress_mac(ingress_mac)
2002
2003 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -08002004 egressPort = egress + self.port_offset,
2005 ingressPort = ingress + self.port_offset,
ChetanGaonkerd376b902016-06-14 11:50:28 -07002006 ethSrc = ingress_mac,
2007 ethDst = egress_mac)
2008 result = flow.addFlow()
2009 assert_equal(result, True)
2010 flows_added += 1
ChetanGaonker720ea612016-06-21 17:54:25 -07002011 ##wait for flows to be added to ONOS
2012 time.sleep(1)
A R Karthick76a497a2017-04-12 10:59:39 -07002013 log_test.info("%d flow added.",j+1)
ChetanGaonkerd376b902016-06-14 11:50:28 -07002014 end_time = time.time()
2015 stats_dir['run '+str(i)] = round((end_time - start_time),2)
2016 for t in stats_dir.items():
A R Karthick76a497a2017-04-12 10:59:39 -07002017 log_test.info("----------------------------------------------")
2018 log_test.info("Statics for %s",t[0])
2019 log_test.info("----------------------------------------------")
2020 log_test.info("No. of flows added Running Time ")
2021 log_test.info(" %d %s " %(1000, t[1]))
ChetanGaonkerd376b902016-06-14 11:50:28 -07002022 running_time += float(t[1])
2023
A R Karthick76a497a2017-04-12 10:59:39 -07002024 log_test.info("-------------------------------------------------------------------------------------------------------")
2025 log_test.info("Final Statics")
2026 log_test.info("-------------------------------------------------------------------------------------------------------")
2027 log_test.info("Total No. of flows added Total Running Time Average no. of flows per second ")
2028 log_test.info(" %d %s second %d "
ChetanGaonkerd376b902016-06-14 11:50:28 -07002029 %(flows_added, running_time, round(flows_added/running_time,0)))
A R Karthick76a497a2017-04-12 10:59:39 -07002030 log_test.info("-------------------------------------------------------------------------------------------------------")
ChetanGaonkerd376b902016-06-14 11:50:28 -07002031
2032
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002033 def test_500_flow_ip(self):
2034 egress = 1
2035 ingress = 2
2036 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '182.0.0.0' }
2037 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.0.0.0' }
ChetanGaonker720ea612016-06-21 17:54:25 -07002038 success_dir = {}
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002039
2040 for i in range(0,500):
2041 ingress_map['ip'] = self.next_ip(ingress_map['ip'])
2042 assert_not_equal(ingress_map['ip'], None)
2043 egress_map['ip'] = self.to_egress_ip(ingress_map['ip'])
2044
2045 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -08002046 egressPort = egress + self.port_offset,
2047 ingressPort = ingress + self.port_offset,
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002048 ethType = '0x0800',
2049 ipSrc = ('IPV4_SRC', ingress_map['ip']+'/8'),
2050 ipDst = ('IPV4_DST', egress_map['ip']+'/8')
2051 )
2052 result = flow.addFlow()
2053 assert_equal(result, True)
2054 ##wait for flows to be added to ONOS
2055 time.sleep(1)
A R Karthick76a497a2017-04-12 10:59:39 -07002056 log_test.info("%d flow added.",i+1)
ChetanGaonker720ea612016-06-21 17:54:25 -07002057 self.success = True
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002058
ChetanGaonker720ea612016-06-21 17:54:25 -07002059 def verify_flow(*r):
2060 random_src = ''.join(r)
2061 random_dst = self.to_egress_ip(random_src)
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002062
ChetanGaonker720ea612016-06-21 17:54:25 -07002063 def mac_recv_task():
2064 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -07002065 log_test.info('Pkt seen with ingress ip %s, egress ip %s' %(pkt[IP].src, pkt[IP].dst))
ChetanGaonker720ea612016-06-21 17:54:25 -07002066 success_dir[current_thread().name] = True
2067
2068 sniff(count=2, timeout=5, lfilter = lambda p: IP in p and p[IP].dst == random_dst and p[IP].src == random_src
2069 ,prn = recv_cb, iface = self.port_map[egress])
2070
2071 t = threading.Thread(target = mac_recv_task)
2072 t.start()
2073 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
2074 L3 = IP(src = random_src, dst = random_dst)
2075 pkt = L2/L3
A R Karthick76a497a2017-04-12 10:59:39 -07002076 log_test.info('Sending packets to verify if flows are correct')
ChetanGaonker720ea612016-06-21 17:54:25 -07002077 sendp(pkt, count=50, iface = self.port_map[ingress])
2078 t.join()
2079
2080 t1 = threading.Thread(target = verify_flow, args = '192.0.0.1')
2081 t2 = threading.Thread(target = verify_flow, args = '192.0.0.' + str(random.randrange(10,100,1)))
2082 t3 = threading.Thread(target = verify_flow, args = '192.0.0.' + str(random.randrange(101,255,1)))
2083 t4 = threading.Thread(target = verify_flow, args = '192.0.1.' + str(random.randrange(1,235,1)))
2084 t5 = threading.Thread(target = verify_flow, args = '192.0.1.244')
2085 t1.start()
2086 t2.start()
2087 t3.start()
2088 t4.start()
2089 t5.start()
2090
2091 t1.join()
2092 t2.join()
2093 t3.join()
2094 t4.join()
2095 t5.join()
2096
2097 if len(success_dir) < 5 or len(success_dir) > 5:
2098 self.success = False
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002099 assert_equal(self.success, True)
2100
ChetanGaonker720ea612016-06-21 17:54:25 -07002101
2102 @nottest
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002103 def test_1k_flow_ip(self):
2104 egress = 1
2105 ingress = 2
2106 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '182.0.0.0' }
2107 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.0.0.0' }
ChetanGaonker720ea612016-06-21 17:54:25 -07002108 success_dir ={}
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002109
2110 for i in range(0,1000):
2111 ingress_map['ip'] = self.next_ip(ingress_map['ip'])
2112 assert_not_equal(ingress_map['ip'], None)
2113 egress_map['ip'] = self.to_egress_ip(ingress_map['ip'])
2114
2115 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -08002116 egressPort = egress + self.port_offset,
2117 ingressPort = ingress + self.port_offset,
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002118 ethType = '0x0800',
2119 ipSrc = ('IPV4_SRC', ingress_map['ip']+'/8'),
2120 ipDst = ('IPV4_DST', egress_map['ip']+'/8')
2121 )
2122 result = flow.addFlow()
2123 assert_equal(result, True)
2124 ##wait for flows to be added to ONOS
2125 time.sleep(1)
A R Karthick76a497a2017-04-12 10:59:39 -07002126 log_test.info("%d flow added.",i+1)
ChetanGaonker720ea612016-06-21 17:54:25 -07002127 self.success = True
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002128
ChetanGaonker720ea612016-06-21 17:54:25 -07002129 def verify_flow(*r):
2130 random_src = ''.join(r)
2131 random_dst = self.to_egress_ip(random_src)
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002132
ChetanGaonker720ea612016-06-21 17:54:25 -07002133 def mac_recv_task():
2134 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -07002135 log_test.info('Pkt seen with ingress ip %s, egress ip %s' %(pkt[IP].src, pkt[IP].dst))
ChetanGaonker720ea612016-06-21 17:54:25 -07002136 success_dir[current_thread().name] = True
2137
2138 sniff(count=2, timeout=5, lfilter = lambda p: IP in p and p[IP].dst == random_dst and p[IP].src == random_src
2139 ,prn = recv_cb, iface = self.port_map[egress])
2140
2141 t = threading.Thread(target = mac_recv_task)
2142 t.start()
2143 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
2144 L3 = IP(src = random_src, dst = random_dst)
2145 pkt = L2/L3
A R Karthick76a497a2017-04-12 10:59:39 -07002146 log_test.info('Sending packets to verify if flows are correct')
ChetanGaonker720ea612016-06-21 17:54:25 -07002147 sendp(pkt, count=50, iface = self.port_map[ingress])
2148 t.join()
2149
2150 t1 = threading.Thread(target = verify_flow, args = '192.0.0.1')
2151 t2 = threading.Thread(target = verify_flow, args = '192.0.0.' + str(random.randrange(10,255,1)))
2152 t3 = threading.Thread(target = verify_flow, args = '192.0.1.' + str(random.randrange(1,100,1)))
2153 t4 = threading.Thread(target = verify_flow, args = '192.0.1.' + str(random.randrange(101,255,1)))
2154 t5 = threading.Thread(target = verify_flow, args = '192.0.2.' + str(random.randrange(1,100,1)))
2155 t6 = threading.Thread(target = verify_flow, args = '192.0.2.' + str(random.randrange(101,255,1)))
2156 t7 = threading.Thread(target = verify_flow, args = '192.0.3.' + str(random.randrange(1,100,1)))
2157 t8 = threading.Thread(target = verify_flow, args = '192.0.3.' + str(random.randrange(101,200,1)))
2158 t9 = threading.Thread(target = verify_flow, args = '192.0.'+ str(random.randrange(0,3,1)) + '.' +
2159 str(random.randrange(1,255,1)))
2160 t10 = threading.Thread(target = verify_flow, args = '192.0.3.232')
2161
2162 t1.start()
2163 t2.start()
2164 t3.start()
2165 t4.start()
2166 t5.start()
2167 t6.start()
2168 t7.start()
2169 t8.start()
2170 t9.start()
2171 t10.start()
2172
2173 t1.join()
2174 t2.join()
2175 t3.join()
2176 t4.join()
2177 t5.join()
2178 t6.join()
2179 t7.join()
2180 t8.join()
2181 t9.join()
2182 t10.join()
2183
2184 if len(success_dir) != 10:
2185 self.success = False
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002186 assert_equal(self.success, True)
2187
2188 @nottest
2189 def test_10k_flow_ip(self):
2190 egress = 1
2191 ingress = 2
2192 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '182.0.0.0' }
2193 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.0.0.0' }
ChetanGaonker720ea612016-06-21 17:54:25 -07002194 success_dir = {}
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002195
2196 for i in range(0,10000):
2197 ingress_map['ip'] = self.next_ip(ingress_map['ip'])
2198 assert_not_equal(ingress_map['ip'], None)
2199 egress_map['ip'] = self.to_egress_ip(ingress_map['ip'])
2200
2201 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -08002202 egressPort = egress + self.port_offset,
2203 ingressPort = ingress + self.port_offset,
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002204 ethType = '0x0800',
2205 ipSrc = ('IPV4_SRC', ingress_map['ip']+'/8'),
2206 ipDst = ('IPV4_DST', egress_map['ip']+'/8')
2207 )
2208 result = flow.addFlow()
2209 assert_equal(result, True)
2210 ##wait for flows to be added to ONOS
2211 time.sleep(1)
A R Karthick76a497a2017-04-12 10:59:39 -07002212 log_test.info("%d flow added.",i+1)
ChetanGaonker720ea612016-06-21 17:54:25 -07002213 self.success = True
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002214
ChetanGaonker720ea612016-06-21 17:54:25 -07002215 def verify_flow(*r):
2216 random_src = ''.join(r)
2217 random_dst = self.to_egress_ip(random_src)
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002218
ChetanGaonker720ea612016-06-21 17:54:25 -07002219 def mac_recv_task():
2220 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -07002221 log_test.info('Pkt seen with ingress ip %s, egress ip %s' %(pkt[IP].src, pkt[IP].dst))
ChetanGaonker720ea612016-06-21 17:54:25 -07002222 success_dir[current_thread().name] = True
2223 sniff(count=2, timeout=5, lfilter = lambda p: IP in p and p[IP].dst == random_dst and p[IP].src == random_src
2224 ,prn = recv_cb, iface = self.port_map[egress])
2225
2226 t = threading.Thread(target = mac_recv_task)
2227 t.start()
2228 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
2229 L3 = IP(src = random_src, dst = random_dst)
2230 pkt = L2/L3
A R Karthick76a497a2017-04-12 10:59:39 -07002231 log_test.info('Sending packets to verify if flows are correct')
ChetanGaonker720ea612016-06-21 17:54:25 -07002232 sendp(pkt, count=50, iface = self.port_map[ingress])
2233 t.join()
2234
2235 t1 = threading.Thread(target = verify_flow, args = '192.0.0.1')
2236 t2 = threading.Thread(target = verify_flow, args = '192.0.0.' + str(random.randrange(1,255,1)))
2237 t3 = threading.Thread(target = verify_flow, args = '192.0.5.' + str(random.randrange(1,255,1)))
2238 t4 = threading.Thread(target = verify_flow, args = '192.0.10.' + str(random.randrange(1,255,1)))
2239 t5 = threading.Thread(target = verify_flow, args = '192.0.15.' + str(random.randrange(1,255,1)))
2240 t6 = threading.Thread(target = verify_flow, args = '192.0.20.' + str(random.randrange(1,255,1)))
2241 t7 = threading.Thread(target = verify_flow, args = '192.0.25.' + str(random.randrange(1,255,1)))
2242 t8 = threading.Thread(target = verify_flow, args = '192.0.30.' + str(random.randrange(1,255,1)))
2243 t9 = threading.Thread(target = verify_flow, args = '192.0.'+ str(random.randrange(0,39,1)) + '.' +
2244 str(random.randrange(1,255,1)))
2245 t10 = threading.Thread(target = verify_flow, args = '192.0.39.16')
2246
2247 t1.start()
2248 t2.start()
2249 t3.start()
2250 t4.start()
2251 t5.start()
2252 t6.start()
2253 t7.start()
2254 t8.start()
2255 t9.start()
2256 t10.start()
2257
2258 t1.join()
2259 t2.join()
2260 t3.join()
2261 t4.join()
2262 t5.join()
2263 t6.join()
2264 t7.join()
2265 t8.join()
2266 t9.join()
2267 t10.join()
2268
2269 if len(success_dir) != 10:
2270 self.success = False
2271
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002272 assert_equal(self.success, True)
2273
2274 @nottest
2275 def test_100k_flow_ip(self):
2276 egress = 1
2277 ingress = 2
2278 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '182.0.0.0' }
2279 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.0.0.0' }
ChetanGaonker720ea612016-06-21 17:54:25 -07002280 success_dir = {}
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002281
2282 for i in range(0,100000):
2283 ingress_map['ip'] = self.next_ip(ingress_map['ip'])
2284 assert_not_equal(ingress_map['ip'], None)
2285 egress_map['ip'] = self.to_egress_ip(ingress_map['ip'])
2286
2287 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -08002288 egressPort = egress + self.port_offset,
2289 ingressPort = ingress + self.port_offset,
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002290 ethType = '0x0800',
2291 ipSrc = ('IPV4_SRC', ingress_map['ip']+'/8'),
2292 ipDst = ('IPV4_DST', egress_map['ip']+'/8')
2293 )
2294 result = flow.addFlow()
2295 assert_equal(result, True)
2296 ##wait for flows to be added to ONOS
2297 time.sleep(1)
A R Karthick76a497a2017-04-12 10:59:39 -07002298 log_test.info("%d flow added.",i+1)
ChetanGaonker720ea612016-06-21 17:54:25 -07002299 self.success = True
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002300
ChetanGaonker720ea612016-06-21 17:54:25 -07002301 def verify_flow(*r):
2302 random_src = ''.join(r)
2303 random_dst = self.to_egress_ip(random_src)
2304 def mac_recv_task():
2305 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -07002306 log_test.info('Pkt seen with ingress ip %s, egress ip %s' %(pkt[IP].src, pkt[IP].dst))
ChetanGaonker720ea612016-06-21 17:54:25 -07002307 success_dir[current_thread().name] = True
2308 sniff(count=2, timeout=5, lfilter = lambda p: IP in p and p[IP].dst == random_dst and p[IP].src == random_src
2309 ,prn = recv_cb, iface = self.port_map[egress])
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002310
ChetanGaonker720ea612016-06-21 17:54:25 -07002311 t = threading.Thread(target = mac_recv_task)
2312 t.start()
2313 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
2314 L3 = IP(src = random_src, dst = random_dst)
2315 pkt = L2/L3
A R Karthick76a497a2017-04-12 10:59:39 -07002316 log_test.info('Sending packets to verify if flows are correct')
ChetanGaonker720ea612016-06-21 17:54:25 -07002317 sendp(pkt, count=50, iface = self.port_map[ingress])
2318 t.join()
2319
2320 t1 = threading.Thread(target = verify_flow, args = '192.0.0.1')
2321 t2 = threading.Thread(target = verify_flow, args = '192.0.0.' + str(random.randrange(1,255,1)))
2322 t3 = threading.Thread(target = verify_flow, args = '192.0.50.' + str(random.randrange(1,255,1)))
2323 t4 = threading.Thread(target = verify_flow, args = '192.0.100.' + str(random.randrange(1,255,1)))
2324 t5 = threading.Thread(target = verify_flow, args = '192.0.150.' + str(random.randrange(1,255,1)))
2325 t6 = threading.Thread(target = verify_flow, args = '192.0.200.' + str(random.randrange(1,255,1)))
2326 t7 = threading.Thread(target = verify_flow, args = '192.0.250.' + str(random.randrange(1,255,1)))
2327 t8 = threading.Thread(target = verify_flow, args = '192.1.'+str(random.randrange(1,75,1)) + '.'
2328 + str(random.randrange(1,255,1)))
2329 t9 = threading.Thread(target = verify_flow, args = '192.1.'+str(random.randrange(76,134,1)) + '.'
2330 + str(random.randrange(1,255,1)))
2331 t10 = threading.Thread(target = verify_flow, args = '192.1.134.160')
2332
2333 t1.start()
2334 t2.start()
2335 t3.start()
2336 t4.start()
2337 t5.start()
2338 t6.start()
2339 t7.start()
2340 t8.start()
2341 t9.start()
2342 t10.start()
2343
2344 t1.join()
2345 t2.join()
2346 t3.join()
2347 t4.join()
2348 t5.join()
2349 t6.join()
2350 t7.join()
2351 t8.join()
2352 t9.join()
2353 t10.join()
2354
2355 if len(success_dir) != 10:
2356 self.success = False
2357
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002358 assert_equal(self.success, True)
2359
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002360 @nottest
2361 def test_1000k_flow_ip(self):
2362 egress = 1
2363 ingress = 2
2364 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '182.0.0.0' }
2365 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.0.0.0' }
ChetanGaonker720ea612016-06-21 17:54:25 -07002366 success_dir = {}
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002367
2368 for i in range(0,1000000):
2369 ingress_map['ip'] = self.next_ip(ingress_map['ip'])
2370 assert_not_equal(ingress_map['ip'], None)
2371 egress_map['ip'] = self.to_egress_ip(ingress_map['ip'])
2372
2373 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -08002374 egressPort = egress + self.port_offset,
2375 ingressPort = ingress + self.port_offset,
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002376 ethType = '0x0800',
2377 ipSrc = ('IPV4_SRC', ingress_map['ip']+'/8'),
2378 ipDst = ('IPV4_DST', egress_map['ip']+'/8')
2379 )
2380 result = flow.addFlow()
2381 assert_equal(result, True)
2382 ##wait for flows to be added to ONOS
2383 time.sleep(1)
A R Karthick76a497a2017-04-12 10:59:39 -07002384 log_test.info("%d flow added.",i+1)
ChetanGaonker720ea612016-06-21 17:54:25 -07002385 self.success = True
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002386
ChetanGaonker720ea612016-06-21 17:54:25 -07002387 def verify_flow(*r):
2388 random_src = ''.join(r)
2389 random_dst = self.to_egress_ip(random_src)
2390 def mac_recv_task():
2391 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -07002392 log_test.info('Pkt seen with ingress ip %s, egress ip %s' %(pkt[IP].src, pkt[IP].dst))
ChetanGaonker720ea612016-06-21 17:54:25 -07002393 success_dir[current_thread().name] = True
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002394
ChetanGaonker720ea612016-06-21 17:54:25 -07002395 sniff(count=2, timeout=5, lfilter = lambda p: IP in p and p[IP].dst == random_dst and p[IP].src == random_src
2396 ,prn = recv_cb, iface = self.port_map[egress])
2397
2398 t = threading.Thread(target = mac_recv_task)
2399 t.start()
2400 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
2401 L3 = IP(src = random_src, dst = random_dst)
2402 pkt = L2/L3
A R Karthick76a497a2017-04-12 10:59:39 -07002403 log_test.info('Sending packets to verify if flows are correct')
ChetanGaonker720ea612016-06-21 17:54:25 -07002404 sendp(pkt, count=50, iface = self.port_map[ingress])
2405 t.join()
2406
2407 t1 = threading.Thread(target = verify_flow, args = '192.0.0.1')
2408 t2 = threading.Thread(target = verify_flow, args = '192.0.50.' + str(random.randrange(1,255,1)))
2409 t3 = threading.Thread(target = verify_flow, args = '192.0.100.' + str(random.randrange(1,255,1)))
2410 t4 = threading.Thread(target = verify_flow, args = '192.0.150.' + str(random.randrange(1,255,1)))
2411 t5 = threading.Thread(target = verify_flow, args = '192.0.200.' + str(random.randrange(1,255,1)))
2412 t6 = threading.Thread(target = verify_flow, args = '192.0.250.' + str(random.randrange(1,255,1)))
2413 t7 = threading.Thread(target = verify_flow, args = '192.0.250.' + str(random.randrange(1,255,1)))
2414 t8 = threading.Thread(target = verify_flow, args = '192.1.'+str(random.randrange(1,150,1)) + '.'
2415 + str(random.randrange(1,255,1)))
2416 t9 = threading.Thread(target = verify_flow, args = '192.1.'+str(random.randrange(152,255,1)) + '.'
2417 + str(random.randrange(1,255,1)))
2418 t10 = threading.Thread(target = verify_flow, args = '192.15.66.64')
2419
2420 t1.start()
2421 t2.start()
2422 t3.start()
2423 t4.start()
2424 t5.start()
2425 t6.start()
2426 t7.start()
2427 t8.start()
2428 t9.start()
2429 t10.start()
2430
2431 t1.join()
2432 t2.join()
2433 t3.join()
2434 t4.join()
2435 t5.join()
2436 t6.join()
2437 t7.join()
2438 t8.join()
2439 t9.join()
2440 t10.join()
2441
2442 if len(success_dir) != 10:
2443 self.success = False
2444
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002445 assert_equal(self.success, True)
2446
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002447 def test_500_flow_tcp_port(self):
2448 egress = 1
2449 ingress = 2
2450 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '192.168.30.1', 'tcp_port': 3100 }
2451 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.168.40.1', 'tcp_port': 1100 }
ChetanGaonker720ea612016-06-21 17:54:25 -07002452 success_dir = {}
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002453
2454 for i in range(0,500):
2455 ingress_map['tcp_port'] += 1
2456 egress_map['tcp_port'] += 1
2457
2458 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -08002459 egressPort = egress + self.port_offset,
2460 ingressPort = ingress + self.port_offset,
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002461 tcpSrc = ingress_map['tcp_port'],
2462 tcpDst = egress_map['tcp_port']
2463 )
2464
2465 result = flow.addFlow()
2466 assert_equal(result, True)
2467 ##wait for flows to be added to ONOS
2468 time.sleep(1)
A R Karthick76a497a2017-04-12 10:59:39 -07002469 log_test.info("%d Flow added",i+1)
ChetanGaonker720ea612016-06-21 17:54:25 -07002470 self.success = True
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002471
ChetanGaonker720ea612016-06-21 17:54:25 -07002472 def verify_flow(*r):
2473 random_sport = int(''.join(r))
2474 random_dport = random_sport + 2000
2475 def mac_recv_task():
2476 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -07002477 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 -07002478 success_dir[current_thread().name] = True
2479 sniff(count=2, timeout=5,
2480 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 -07002481
ChetanGaonker720ea612016-06-21 17:54:25 -07002482 t = threading.Thread(target = mac_recv_task)
2483 t.start()
2484 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
2485 L3 = IP(src = ingress_map['ip'], dst = egress_map['ip'])
2486 L4 = TCP(sport = random_sport, dport = random_dport)
2487 pkt = L2/L3/L4
A R Karthick76a497a2017-04-12 10:59:39 -07002488 log_test.info('Sending packets to verify if flows are correct')
ChetanGaonker720ea612016-06-21 17:54:25 -07002489 sendp(pkt, count=50, iface = self.port_map[ingress])
2490 t.join()
2491 t1 = threading.Thread(target = verify_flow, args = str(1101))
2492 t2 = threading.Thread(target = verify_flow, args = str(random.randrange(1110,1250,1)))
2493 t3 = threading.Thread(target = verify_flow, args = str(random.randrange(1251,1400,1)))
2494 t4 = threading.Thread(target = verify_flow, args = str(random.randrange(1401,1590,1)))
2495 t5 = threading.Thread(target = verify_flow, args = str(1600))
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002496
ChetanGaonker720ea612016-06-21 17:54:25 -07002497 t1.start()
2498 t2.start()
2499 t3.start()
2500 t4.start()
2501 t5.start()
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002502
ChetanGaonker720ea612016-06-21 17:54:25 -07002503 t1.join()
2504 t2.join()
2505 t3.join()
2506 t4.join()
2507 t5.join()
2508
2509 if len(success_dir) != 5:
2510 self.success = False
2511
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002512 assert_equal(self.success, True)
2513
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002514 def test_1k_flow_tcp_port(self):
2515 egress = 1
2516 ingress = 2
2517 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '192.168.30.1', 'tcp_port': 3100 }
2518 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.168.40.1', 'tcp_port': 1100 }
ChetanGaonker720ea612016-06-21 17:54:25 -07002519 success_dir = {}
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002520
2521 for i in range(0,1000):
2522 ingress_map['tcp_port'] += 1
2523 egress_map['tcp_port'] += 1
2524
2525 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -08002526 egressPort = egress + self.port_offset,
2527 ingressPort = ingress + self.port_offset,
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002528 tcpSrc = ingress_map['tcp_port'],
2529 tcpDst = egress_map['tcp_port']
2530 )
2531
2532 result = flow.addFlow()
2533 assert_equal(result, True)
2534 ##wait for flows to be added to ONOS
2535 time.sleep(1)
A R Karthick76a497a2017-04-12 10:59:39 -07002536 log_test.info("%d flow added.",i+1)
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002537
ChetanGaonker720ea612016-06-21 17:54:25 -07002538 self.success = True
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002539
ChetanGaonker720ea612016-06-21 17:54:25 -07002540 def verify_flow(*r):
2541 random_sport = int(''.join(r))
2542 random_dport = random_sport + 2000
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002543
ChetanGaonker720ea612016-06-21 17:54:25 -07002544 def mac_recv_task():
2545 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -07002546 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 -07002547 success_dir[current_thread().name] = True
2548 sniff(count=2, timeout=5,
2549 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 -07002550
ChetanGaonker720ea612016-06-21 17:54:25 -07002551 t = threading.Thread(target = mac_recv_task)
2552 t.start()
2553 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
2554 L3 = IP(src = ingress_map['ip'], dst = egress_map['ip'])
2555 L4 = TCP(sport = random_sport, dport = random_dport)
2556 pkt = L2/L3/L4
A R Karthick76a497a2017-04-12 10:59:39 -07002557 log_test.info('Sending packets to verify if flows are correct')
ChetanGaonker720ea612016-06-21 17:54:25 -07002558 sendp(pkt, count=50, iface = self.port_map[ingress])
2559 t.join()
2560
2561 t1 = threading.Thread(target = verify_flow, args = str(1101))
2562 t2 = threading.Thread(target = verify_flow, args = str(random.randrange(1110,1350,1)))
2563 t3 = threading.Thread(target = verify_flow, args = str(random.randrange(1351,1500,1)))
2564 t4 = threading.Thread(target = verify_flow, args = str(random.randrange(1501,1700,1)))
2565 t5 = threading.Thread(target = verify_flow, args = str(random.randrange(1701,1900,1)))
2566 t6 = threading.Thread(target = verify_flow, args = str(random.randrange(1901,2000,1)))
2567 t7 = threading.Thread(target = verify_flow, args = str(random.randrange(2000,2050,1)))
2568 t8 = threading.Thread(target = verify_flow, args = str(random.randrange(2050,2080,1)))
2569 t9 = threading.Thread(target = verify_flow, args = str(random.randrange(1102,2100,1)))
2570 t10 = threading.Thread(target = verify_flow, args = str(2100))
2571
2572
2573 t1.start()
2574 t2.start()
2575 t3.start()
2576 t4.start()
2577 t5.start()
2578 t6.start()
2579 t7.start()
2580 t8.start()
2581 t9.start()
2582 t10.start()
2583
2584 t1.join()
2585 t2.join()
2586 t3.join()
2587 t4.join()
2588 t5.join()
2589 t6.join()
2590 t7.join()
2591 t8.join()
2592 t9.join()
2593 t10.join()
2594
2595 if len(success_dir) != 10:
2596 self.success = False
2597
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002598 assert_equal(self.success, True)
2599
2600 @nottest
2601 def test_10k_flow_tcp_port(self):
2602 egress = 1
2603 ingress = 2
2604 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '192.168.30.1', 'tcp_port': 31000 }
2605 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.168.40.1', 'tcp_port': 11000 }
ChetanGaonker720ea612016-06-21 17:54:25 -07002606 success_dir = {}
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002607
2608 for i in range(0,10000):
2609 ingress_map['tcp_port'] += 1
2610 egress_map['tcp_port'] += 1
2611
2612 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -08002613 egressPort = egress + self.port_offset,
2614 ingressPort = ingress + self.port_offset,
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002615 tcpSrc = ingress_map['tcp_port'],
2616 tcpDst = egress_map['tcp_port']
2617 )
2618
2619 result = flow.addFlow()
2620 assert_equal(result, True)
2621 ##wait for flows to be added to ONOS
2622 time.sleep(1)
A R Karthick76a497a2017-04-12 10:59:39 -07002623 log_test.info("%d flow added.",i+1)
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002624
ChetanGaonker720ea612016-06-21 17:54:25 -07002625 self.success = True
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002626
ChetanGaonker720ea612016-06-21 17:54:25 -07002627 def verify_flow(*r):
2628 random_sport = int(''.join(r))
2629 random_dport = random_sport + 20000
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002630
ChetanGaonker720ea612016-06-21 17:54:25 -07002631 def mac_recv_task():
2632 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -07002633 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 -07002634 success_dir[current_thread().name] = True
2635 sniff(count=2, timeout=5,
2636 lfilter = lambda p: TCP in p and p[TCP].dport == random_dport
2637 and p[TCP].sport == random_sport,prn = recv_cb, iface = self.port_map[egress])
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002638
ChetanGaonker720ea612016-06-21 17:54:25 -07002639 t = threading.Thread(target = mac_recv_task)
2640 t.start()
2641 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
2642 L3 = IP(src = ingress_map['ip'], dst = egress_map['ip'])
2643 L4 = TCP(sport = random_sport, dport = random_dport)
2644 pkt = L2/L3/L4
A R Karthick76a497a2017-04-12 10:59:39 -07002645 log_test.info('Sending packets to verify if flows are correct')
ChetanGaonker720ea612016-06-21 17:54:25 -07002646 sendp(pkt, count=50, iface = self.port_map[ingress])
2647 t.join()
2648
2649 t1 = threading.Thread(target = verify_flow, args = str(11001))
2650 t2 = threading.Thread(target = verify_flow, args = str(random.randrange(11110,12501,1)))
2651 t3 = threading.Thread(target = verify_flow, args = str(random.randrange(12510,14001,1)))
2652 t4 = threading.Thread(target = verify_flow, args = str(random.randrange(14010,15900,1)))
2653 t5 = threading.Thread(target = verify_flow, args = str(random.randrange(16000,17000,1)))
2654 t6 = threading.Thread(target = verify_flow, args = str(random.randrange(17001,18000,1)))
2655 t7 = threading.Thread(target = verify_flow, args = str(random.randrange(18000,19000,1)))
2656 t8 = threading.Thread(target = verify_flow, args = str(random.randrange(19000,20980,1)))
2657 t9 = threading.Thread(target = verify_flow, args = str(random.randrange(11002,21000,1)))
2658 t10 = threading.Thread(target = verify_flow, args = str(21000))
2659
2660
2661 t1.start()
2662 t2.start()
2663 t3.start()
2664 t4.start()
2665 t5.start()
2666 t6.start()
2667 t7.start()
2668 t8.start()
2669 t9.start()
2670 t10.start()
2671
2672 t1.join()
2673 t2.join()
2674 t3.join()
2675 t4.join()
2676 t5.join()
2677 t6.join()
2678 t7.join()
2679 t8.join()
2680 t9.join()
2681 t10.join()
2682
2683 if len(success_dir) != 10:
2684 self.success = False
2685
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002686 assert_equal(self.success, True)
2687
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002688 def test_500_flow_udp_port(self):
2689 egress = 1
2690 ingress = 2
2691 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '192.168.30.1', 'udp_port': 3100 }
2692 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.168.40.1', 'udp_port': 1100 }
ChetanGaonker720ea612016-06-21 17:54:25 -07002693 success_dir = {}
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002694
2695 for i in range(0,500):
2696 ingress_map['udp_port'] += 1
2697 egress_map['udp_port'] += 1
2698
2699 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -08002700 egressPort = egress + self.port_offset,
2701 ingressPort = ingress + self.port_offset,
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002702 udpSrc = ingress_map['udp_port'],
2703 udpDst = egress_map['udp_port']
2704 )
2705
2706 result = flow.addFlow()
2707 assert_equal(result, True)
2708 ##wait for flows to be added to ONOS
2709 time.sleep(1)
A R Karthick76a497a2017-04-12 10:59:39 -07002710 log_test.info("%d flow added.",i+1)
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002711
ChetanGaonker720ea612016-06-21 17:54:25 -07002712 self.success = True
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002713
ChetanGaonker720ea612016-06-21 17:54:25 -07002714 def verify_flow(*r):
2715 random_sport = int(''.join(r))
2716 random_dport = random_sport + 2000
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002717
ChetanGaonker720ea612016-06-21 17:54:25 -07002718 def mac_recv_task():
2719 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -07002720 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 -07002721 success_dir[current_thread().name] = True
2722 sniff(count=2, timeout=5,
2723 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 -07002724
ChetanGaonker720ea612016-06-21 17:54:25 -07002725 t = threading.Thread(target = mac_recv_task)
2726 t.start()
2727 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
2728 L3 = IP(src = ingress_map['ip'], dst = egress_map['ip'])
2729 L4 = UDP(sport = random_sport, dport = random_dport)
2730 pkt = L2/L3/L4
A R Karthick76a497a2017-04-12 10:59:39 -07002731 log_test.info('Sending packets to verify if flows are correct')
ChetanGaonker720ea612016-06-21 17:54:25 -07002732 sendp(pkt, count=50, iface = self.port_map[ingress])
2733 t.join()
2734
2735 t1 = threading.Thread(target = verify_flow, args = str(1101))
2736 t2 = threading.Thread(target = verify_flow, args = str(random.randrange(1110,1250,1)))
2737 t3 = threading.Thread(target = verify_flow, args = str(random.randrange(1251,1400,1)))
2738 t4 = threading.Thread(target = verify_flow, args = str(random.randrange(1401,1590,1)))
2739 t5 = threading.Thread(target = verify_flow, args = str(1600))
2740
2741
2742 t1.start()
2743 t2.start()
2744 t3.start()
2745 t4.start()
2746 t5.start()
2747
2748 t1.join()
2749 t2.join()
2750 t3.join()
2751 t4.join()
2752 t5.join()
2753
2754 if len(success_dir) != 5:
2755 self.success = False
2756
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002757 assert_equal(self.success, True)
2758
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002759 def test_1k_flow_udp_port(self):
2760 egress = 1
2761 ingress = 2
2762 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '192.168.30.1', 'udp_port': 3100 }
2763 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.168.40.1', 'udp_port': 1100 }
ChetanGaonker720ea612016-06-21 17:54:25 -07002764 success_dir = {}
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002765
ChetanGaonker720ea612016-06-21 17:54:25 -07002766 for i in range(0,100000):
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002767 ingress_map['udp_port'] += 1
2768 egress_map['udp_port'] += 1
2769
2770 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -08002771 egressPort = egress + self.port_offset,
2772 ingressPort = ingress + self.port_offset,
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002773 udpSrc = ingress_map['udp_port'],
2774 udpDst = egress_map['udp_port']
2775 )
2776
2777 result = flow.addFlow()
2778 assert_equal(result, True)
2779 ##wait for flows to be added to ONOS
2780 time.sleep(1)
A R Karthick76a497a2017-04-12 10:59:39 -07002781 log_test.info("%d flow added.",i+1)
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002782
ChetanGaonker720ea612016-06-21 17:54:25 -07002783 self.success = True
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002784
ChetanGaonker720ea612016-06-21 17:54:25 -07002785 def verify_flow(*r):
2786 random_sport = int(''.join(r))
2787 random_dport = random_sport + 2000
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002788
ChetanGaonker720ea612016-06-21 17:54:25 -07002789 def mac_recv_task():
2790 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -07002791 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 -07002792 success_dir[current_thread().name] = True
2793 sniff(count=2, timeout=5,
2794 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 -07002795
ChetanGaonker720ea612016-06-21 17:54:25 -07002796 t = threading.Thread(target = mac_recv_task)
2797 t.start()
2798 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
2799 L3 = IP(src = ingress_map['ip'], dst = egress_map['ip'])
2800 L4 = UDP(sport = random_sport, dport = random_dport)
2801 pkt = L2/L3/L4
A R Karthick76a497a2017-04-12 10:59:39 -07002802 log_test.info('Sending packets to verify if flows are correct')
ChetanGaonker720ea612016-06-21 17:54:25 -07002803 sendp(pkt, count=50, iface = self.port_map[ingress])
2804 t.join()
2805
2806 t1 = threading.Thread(target = verify_flow, args = str(1101))
2807 t2 = threading.Thread(target = verify_flow, args = str(random.randrange(1110,1350,1)))
2808 t3 = threading.Thread(target = verify_flow, args = str(random.randrange(1351,1500,1)))
2809 t4 = threading.Thread(target = verify_flow, args = str(random.randrange(1501,1700,1)))
2810 t5 = threading.Thread(target = verify_flow, args = str(random.randrange(1701,1900,1)))
2811 t6 = threading.Thread(target = verify_flow, args = str(random.randrange(1901,2000,1)))
2812 t7 = threading.Thread(target = verify_flow, args = str(random.randrange(2000,2050,1)))
2813 t8 = threading.Thread(target = verify_flow, args = str(random.randrange(2050,2080,1)))
2814 t9 = threading.Thread(target = verify_flow, args = str(random.randrange(1102,2100,1)))
2815 t10 = threading.Thread(target = verify_flow, args = str(2100))
2816
2817 t1.start()
2818 t2.start()
2819 t3.start()
2820 t4.start()
2821 t5.start()
2822 t6.start()
2823 t7.start()
2824 t8.start()
2825 t9.start()
2826 t10.start()
2827
2828 t1.join()
2829 t2.join()
2830 t3.join()
2831 t4.join()
2832 t5.join()
2833 t6.join()
2834 t7.join()
2835 t8.join()
2836 t9.join()
2837 t10.join()
2838
2839 if len(success_dir) != 10:
2840 self.success = False
2841
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002842 assert_equal(self.success, True)
2843
2844 @nottest
2845 def test_10k_flow_udp_port(self):
2846 egress = 1
2847 ingress = 2
2848 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '192.168.30.1', 'udp_port': 31000 }
2849 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.168.40.1', 'udp_port': 11000 }
ChetanGaonker720ea612016-06-21 17:54:25 -07002850 success_dir = {}
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002851
2852 for i in range(0,10000):
ChetanGaonker720ea612016-06-21 17:54:25 -07002853 ingress_map['udp_port'] += 1
2854 egress_map['udp_port'] += 1
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002855
ChetanGaonker720ea612016-06-21 17:54:25 -07002856 flow = OnosFlowCtrl(deviceId = self.device_id,
A R Karthicke4660f52017-02-23 12:08:41 -08002857 egressPort = egress + self.port_offset,
2858 ingressPort = ingress + self.port_offset,
ChetanGaonker720ea612016-06-21 17:54:25 -07002859 udpSrc = ingress_map['udp_port'],
2860 udpDst = egress_map['udp_port']
2861 )
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002862
ChetanGaonker720ea612016-06-21 17:54:25 -07002863 result = flow.addFlow()
2864 assert_equal(result, True)
2865 ##wait for flows to be added to ONOS
2866 time.sleep(1)
A R Karthick76a497a2017-04-12 10:59:39 -07002867 log_test.info("%d flow added.",i+1)
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002868
ChetanGaonker720ea612016-06-21 17:54:25 -07002869 self.success = True
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002870
ChetanGaonker720ea612016-06-21 17:54:25 -07002871 def verify_flow(*r):
2872 random_sport = int(''.join(r))
2873 random_dport = random_sport + 20000
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002874
ChetanGaonker720ea612016-06-21 17:54:25 -07002875 def mac_recv_task():
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002876
ChetanGaonker720ea612016-06-21 17:54:25 -07002877 def recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -07002878 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 -07002879 success_dir[current_thread().name] = True
2880 sniff(count=2, timeout=5,
2881 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])
2882
2883 t = threading.Thread(target = mac_recv_task)
2884 t.start()
2885 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
2886 L3 = IP(src = ingress_map['ip'], dst = egress_map['ip'])
2887 L4 = UDP(sport = random_sport, dport = random_dport)
2888 pkt = L2/L3/L4
A R Karthick76a497a2017-04-12 10:59:39 -07002889 log_test.info('Sending packets to verify if flows are correct')
ChetanGaonker720ea612016-06-21 17:54:25 -07002890 sendp(pkt, count=50, iface = self.port_map[ingress])
2891 t.join()
2892
2893 t1 = threading.Thread(target = verify_flow, args = str(11001))
2894 t2 = threading.Thread(target = verify_flow, args = str(random.randrange(11110,12501,1)))
2895 t3 = threading.Thread(target = verify_flow, args = str(random.randrange(12510,14001,1)))
2896 t4 = threading.Thread(target = verify_flow, args = str(random.randrange(14010,15900,1)))
2897 t5 = threading.Thread(target = verify_flow, args = str(random.randrange(16000,17000,1)))
2898 t6 = threading.Thread(target = verify_flow, args = str(random.randrange(17001,18000,1)))
2899 t7 = threading.Thread(target = verify_flow, args = str(random.randrange(18000,19000,1)))
2900 t8 = threading.Thread(target = verify_flow, args = str(random.randrange(19000,20980,1)))
2901 t9 = threading.Thread(target = verify_flow, args = str(random.randrange(11002,21000,1)))
2902 t10 = threading.Thread(target = verify_flow, args = str(21000))
2903
2904
2905 t1.start()
2906 t2.start()
2907 t3.start()
2908 t4.start()
2909 t5.start()
2910 t6.start()
2911 t7.start()
2912 t8.start()
2913 t9.start()
2914 t10.start()
2915
2916 t1.join()
2917 t2.join()
2918 t3.join()
2919 t4.join()
2920 t5.join()
2921 t6.join()
2922 t7.join()
2923 t8.join()
2924 t9.join()
2925 t10.join()
2926
2927 if len(success_dir) != 10:
2928 self.success = False
ChetanGaonkera6adc0b2016-06-12 12:21:14 -07002929 assert_equal(self.success, True)