blob: 166139bb6fc9363506f697d9e884ce62dffadac7 [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
A.R Karthick95d044e2016-06-10 18:44:36 -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
A.R Karthick95d044e2016-06-10 18:44:36 -070023#
Chetan Gaonkercfcce782016-05-10 10:10:42 -070024# http://www.apache.org/licenses/LICENSE-2.0
A.R Karthick95d044e2016-06-10 18:44:36 -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#
A R Karthickbd698672017-07-13 16:48:24 -070032from twisted.internet import defer
Chetan Gaonker25470972016-02-26 08:52:15 -080033from nose.tools import *
34from nose.twistedtools import reactor, deferred
Chetan Gaonker25470972016-02-26 08:52:15 -080035from scapy.all import *
A R Karthickbd698672017-07-13 16:48:24 -070036from select import select as socket_select
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -080037import time, monotonic
ChetanGaonkerb99538a2016-12-02 13:53:35 -080038import os
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -080039import random
40import threading
Chetan Gaonkere88c95c2016-03-02 05:21:47 -080041from IGMP import *
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -080042from McastTraffic import *
43from Stats import Stats
Chetan Gaonker4a25e2b2016-03-04 14:45:15 -080044from OnosCtrl import OnosCtrl
Chetan Gaonker441c9ac2016-05-06 10:30:13 -070045from OltConfig import OltConfig
Chetan Gaonker4eb12072016-03-28 15:04:15 -070046from Channels import IgmpChannel
A R Karthick9313b762016-11-07 13:14:35 -080047from CordLogger import CordLogger
A R Karthick9dc6e922017-07-12 14:40:16 -070048from CordTestConfig import setup_module, teardown_module
A R Karthick76a497a2017-04-12 10:59:39 -070049from CordTestUtils import log_test
A R Karthick76a497a2017-04-12 10:59:39 -070050log_test.setLevel('INFO')
Chetan Gaonker25470972016-02-26 08:52:15 -080051
52class IGMPTestState:
53
54 def __init__(self, groups = [], df = None, state = 0):
55 self.df = df
56 self.state = state
57 self.counter = 0
58 self.groups = groups
59 self.group_map = {} ##create a send/recv count map
60 for g in groups:
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -080061 self.group_map[g] = (Stats(), Stats())
A.R Karthick95d044e2016-06-10 18:44:36 -070062
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -080063 def update(self, group, tx = 0, rx = 0, t = 0):
64 self.counter += 1
Chetan Gaonker25470972016-02-26 08:52:15 -080065 index = 0 if rx == 0 else 1
66 v = tx if rx == 0 else rx
67 if self.group_map.has_key(group):
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -080068 self.group_map[group][index].update(packets = v, t = t)
Chetan Gaonker25470972016-02-26 08:52:15 -080069
70 def update_state(self):
71 self.state = self.state ^ 1
Chetan Gaonker25470972016-02-26 08:52:15 -080072
A R Karthick9313b762016-11-07 13:14:35 -080073class igmp_exchange(CordLogger):
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -080074
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -070075 V_INF1 = 'veth0'
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -070076 MGROUP1 = '239.1.2.3'
77 MGROUP2 = '239.2.2.3'
Chetan Gaonker441c9ac2016-05-06 10:30:13 -070078 MINVALIDGROUP1 = '255.255.255.255'
79 MINVALIDGROUP2 = '239.255.255.255'
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -070080 MMACGROUP1 = "01:00:5e:01:02:03"
81 MMACGROUP2 = "01:00:5e:02:02:03"
ChetanGaonkera7e2b412016-09-01 23:19:07 -070082 IGMP_DST_MAC = "01:00:5e:00:00:16"
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -070083 IGMP_SRC_MAC = "5a:e1:ac:ec:4d:a1"
84 IP_SRC = '1.2.3.4'
ChetanGaonkera7e2b412016-09-01 23:19:07 -070085 IP_DST = '224.0.0.22'
Chetan Gaonker441c9ac2016-05-06 10:30:13 -070086 NEGATIVE_TRAFFIC_STATUS = 1
ChetanGaonkera7e2b412016-09-01 23:19:07 -070087 igmp_eth = Ether(dst = IGMP_DST_MAC, type = ETH_P_IP)
88 igmp_ip = IP(dst = IP_DST)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -080089 IGMP_TEST_TIMEOUT = 5
Chetan Gaonker441c9ac2016-05-06 10:30:13 -070090 IGMP_QUERY_TIMEOUT = 60
A R Karthicka93fdee2017-07-14 17:27:35 -070091 MCAST_TRAFFIC_TIMEOUT = 20
Chetan Gaonker4eb12072016-03-28 15:04:15 -070092 PORT_TX_DEFAULT = 2
93 PORT_RX_DEFAULT = 1
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -080094 max_packets = 100
A.R Karthick95d044e2016-06-10 18:44:36 -070095 app = 'org.opencord.igmp'
A.R Karthick5968e0d2017-05-16 14:50:46 -070096 olt_conf_file = os.getenv('OLT_CONFIG_FILE', os.path.join(os.path.dirname(os.path.realpath(__file__)), '../setup/olt_config.json'))
A R Karthick2b93d6a2016-09-06 15:19:09 -070097 ROVER_TEST_TIMEOUT = 300 #3600*86
98 ROVER_TIMEOUT = (ROVER_TEST_TIMEOUT - 100)
99 ROVER_JOIN_TIMEOUT = 60
A R Karthickbd698672017-07-13 16:48:24 -0700100 VOLTHA_ENABLED = bool(int(os.getenv('VOLTHA_ENABLED', 0)))
Chetan Gaonker4a25e2b2016-03-04 14:45:15 -0800101
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700102 @classmethod
103 def setUpClass(cls):
A R Karthick38d5df42017-07-10 13:33:26 -0700104 cls.olt = OltConfig(olt_conf_file = cls.olt_conf_file)
105 cls.port_map, _ = cls.olt.olt_port_map()
A R Karthickbd698672017-07-13 16:48:24 -0700106 if cls.VOLTHA_ENABLED is False:
107 OnosCtrl.config_device_driver()
108 OnosCtrl.cord_olt_config(cls.olt)
A R Karthick38d5df42017-07-10 13:33:26 -0700109 time.sleep(2)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700110
111 @classmethod
A R Karthick38d5df42017-07-10 13:33:26 -0700112 def tearDownClass(cls):
A R Karthickbd698672017-07-13 16:48:24 -0700113 if cls.VOLTHA_ENABLED is False:
114 OnosCtrl.config_device_driver(driver = 'ovs')
A.R Karthick95d044e2016-06-10 18:44:36 -0700115
Chetan Gaonker4a25e2b2016-03-04 14:45:15 -0800116 def setUp(self):
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700117 ''' Activate the igmp app'''
A R Karthick9313b762016-11-07 13:14:35 -0800118 super(igmp_exchange, self).setUp()
Chetan Gaonker4a25e2b2016-03-04 14:45:15 -0800119 self.onos_ctrl = OnosCtrl(self.app)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700120 self.onos_ctrl.activate()
Chetan Gaonker4eb12072016-03-28 15:04:15 -0700121 self.igmp_channel = IgmpChannel()
Chetan Gaonker4a25e2b2016-03-04 14:45:15 -0800122
A R Karthick9313b762016-11-07 13:14:35 -0800123 def tearDown(self):
124 super(igmp_exchange, self).tearDown()
Chetan Gaonker4a25e2b2016-03-04 14:45:15 -0800125
126 def onos_load_config(self, config):
A R Karthick76a497a2017-04-12 10:59:39 -0700127 log_test.info('onos load config is %s'%config)
Chetan Gaonkera2b87df2016-03-31 15:41:31 -0700128 status, code = OnosCtrl.config(config)
Chetan Gaonker4a25e2b2016-03-04 14:45:15 -0800129 if status is False:
A R Karthick76a497a2017-04-12 10:59:39 -0700130 log_test.info('JSON request returned status %d' %code)
Chetan Gaonker4a25e2b2016-03-04 14:45:15 -0800131 assert_equal(status, True)
132 time.sleep(2)
A.R Karthick95d044e2016-06-10 18:44:36 -0700133
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700134 def onos_ssm_table_load(self, groups, src_list = ['1.2.3.4'],flag = False):
A R Karthick38d5df42017-07-10 13:33:26 -0700135 return
A.R Karthick401a1ed2017-05-18 11:08:27 -0700136 ssm_dict = {'apps' : { 'org.opencord.igmp' : { 'ssmTranslate' : [] } } }
137 ssm_xlate_list = ssm_dict['apps']['org.opencord.igmp']['ssmTranslate']
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700138 if flag: #to maintain seperate group-source pair.
139 for i in range(len(groups)):
140 d = {}
141 d['source'] = src_list[i] or '0.0.0.0'
142 d['group'] = groups[i]
143 ssm_xlate_list.append(d)
144 else:
145 for g in groups:
146 for s in src_list:
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800147 d = {}
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700148 d['source'] = s or '0.0.0.0'
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800149 d['group'] = g
150 ssm_xlate_list.append(d)
Chetan Gaonker4a25e2b2016-03-04 14:45:15 -0800151 self.onos_load_config(ssm_dict)
Chetan Gaonker4eb12072016-03-28 15:04:15 -0700152 cord_port_map = {}
153 for g in groups:
154 cord_port_map[g] = (self.PORT_TX_DEFAULT, self.PORT_RX_DEFAULT)
155 self.igmp_channel.cord_port_table_load(cord_port_map)
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800156 time.sleep(2)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800157
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700158 def mcast_ip_range(self,start_ip = '224.0.1.0', end_ip = '224.0.1.100'):
159 start = list(map(int, start_ip.split(".")))
160 end = list(map(int, end_ip.split(".")))
161 temp = start
162 ip_range = []
163 ip_range.append(start_ip)
164 while temp != end:
165 start[3] += 1
166 for i in (3, 2, 1):
167 if temp[i] == 255:
168 temp[i] = 0
169 temp[i-1] += 1
170 ip_range.append(".".join(map(str, temp)))
171 return ip_range
172
173 def random_mcast_ip(self,start_ip = '224.0.1.0', end_ip = '224.0.1.100'):
174 start = list(map(int, start_ip.split(".")))
175 end = list(map(int, end_ip.split(".")))
176 temp = start
177 ip_range = []
178 ip_range.append(start_ip)
179 while temp != end:
180 start[3] += 1
181 for i in (3, 2, 1):
182 if temp[i] == 255:
183 temp[i] = 0
184 temp[i-1] += 1
185 ip_range.append(".".join(map(str, temp)))
186 return random.choice(ip_range)
187
188 def source_ip_range(self,start_ip = '10.10.0.1', end_ip = '10.10.0.100'):
189 start = list(map(int, start_ip.split(".")))
190 end = list(map(int, end_ip.split(".")))
191 temp = start
192 ip_range = []
193 ip_range.append(start_ip)
194 while temp != end:
195 start[3] += 1
196 for i in (3, 2, 1):
197 if temp[i] == 255:
198 temp[i] = 0
199 temp[i-1] += 1
200 ip_range.append(".".join(map(str, temp)))
201 return ip_range
202
203 def randomsourceip(self,start_ip = '10.10.0.1', end_ip = '10.10.0.100'):
204 start = list(map(int, start_ip.split(".")))
205 end = list(map(int, end_ip.split(".")))
206 temp = start
207 ip_range = []
208 ip_range.append(start_ip)
209 while temp != end:
210 start[3] += 1
211 for i in (3, 2, 1):
212 if temp[i] == 255:
213 temp[i] = 0
214 temp[i-1] += 1
215 ip_range.append(".".join(map(str, temp)))
216 return random.choice(ip_range)
217
A R Karthick2b93d6a2016-09-06 15:19:09 -0700218 def get_igmp_intf(self):
219 inst = os.getenv('TEST_INSTANCE', None)
220 if not inst:
221 return 'veth0'
222 inst = int(inst) + 1
223 if inst >= self.port_map['uplink']:
224 inst += 1
225 if self.port_map.has_key(inst):
226 return self.port_map[inst]
227 return 'veth0'
228
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800229 def igmp_verify_join(self, igmpStateList):
230 sendState, recvState = igmpStateList
Chetan Gaonker25470972016-02-26 08:52:15 -0800231 ## check if the send is received for the groups
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800232 for g in sendState.groups:
A.R Karthick95d044e2016-06-10 18:44:36 -0700233 tx_stats = sendState.group_map[g][0]
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800234 tx = tx_stats.count
Chetan Gaonker25470972016-02-26 08:52:15 -0800235 assert_greater(tx, 0)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800236 rx_stats = recvState.group_map[g][1]
237 rx = rx_stats.count
238 assert_greater(rx, 0)
A R Karthick76a497a2017-04-12 10:59:39 -0700239 log_test.info('Receive stats %s for group %s' %(rx_stats, g))
A.R Karthick95d044e2016-06-10 18:44:36 -0700240
A R Karthick76a497a2017-04-12 10:59:39 -0700241 log_test.info('IGMP test verification success')
Chetan Gaonker25470972016-02-26 08:52:15 -0800242
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800243 def igmp_verify_leave(self, igmpStateList, leave_groups):
244 sendState, recvState = igmpStateList[0], igmpStateList[1]
245 ## check if the send is received for the groups
246 for g in sendState.groups:
247 tx_stats = sendState.group_map[g][0]
248 rx_stats = recvState.group_map[g][1]
249 tx = tx_stats.count
A.R Karthick95d044e2016-06-10 18:44:36 -0700250 rx = rx_stats.count
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800251 assert_greater(tx, 0)
252 if g not in leave_groups:
A R Karthick76a497a2017-04-12 10:59:39 -0700253 log_test.info('Received %d packets for group %s' %(rx, g))
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800254 for g in leave_groups:
255 rx = recvState.group_map[g][1].count
256 assert_equal(rx, 0)
A.R Karthick95d044e2016-06-10 18:44:36 -0700257
A R Karthick76a497a2017-04-12 10:59:39 -0700258 log_test.info('IGMP test verification success')
Chetan Gaonker25470972016-02-26 08:52:15 -0800259
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800260 def mcast_traffic_timer(self):
A R Karthickbd698672017-07-13 16:48:24 -0700261 log_test.info('MCAST traffic timer expiry')
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800262 self.mcastTraffic.stopReceives()
263
264 def send_mcast_cb(self, send_state):
265 for g in send_state.groups:
266 send_state.update(g, tx = 1)
Chetan Gaonker25470972016-02-26 08:52:15 -0800267 return 0
268
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800269 ##Runs in the context of twisted reactor thread
A R Karthickbd698672017-07-13 16:48:24 -0700270 def igmp_recv(self, igmpState):
271 s = socket_select([self.recv_socket], [], [], 1.0)
272 if self.recv_socket in s[0]:
273 p = self.recv_socket.recv()
274 try:
275 send_time = float(p.payload.load)
276 recv_time = monotonic.monotonic()
277 except:
278 log_test.info('Unexpected Payload received: %s' %p.payload.load)
279 return 0
280 #log_test.info( 'Recv in %.6f secs' %(recv_time - send_time))
281 igmpState.update(p.dst, rx = 1, t = recv_time - send_time)
Chetan Gaonker25470972016-02-26 08:52:15 -0800282 return 0
283
A R Karthick2b93d6a2016-09-06 15:19:09 -0700284 def send_igmp_join(self, groups, src_list = ['1.2.3.4'], record_type=IGMP_V3_GR_TYPE_INCLUDE,
285 ip_pkt = None, iface = 'veth0', ssm_load = False, delay = 1):
286 if ssm_load is True:
287 self.onos_ssm_table_load(groups, src_list)
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800288 igmp = IGMPv3(type = IGMP_TYPE_V3_MEMBERSHIP_REPORT, max_resp_code=30,
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700289 gaddr=self.IP_DST)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800290 for g in groups:
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700291 gr = IGMPv3gr(rtype= record_type, mcaddr=g)
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800292 gr.sources = src_list
293 igmp.grps.append(gr)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700294 if ip_pkt is None:
295 ip_pkt = self.igmp_eth/self.igmp_ip
296 pkt = ip_pkt/igmp
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800297 IGMPv3.fixup(pkt)
298 sendp(pkt, iface=iface)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800299 if delay != 0:
300 time.sleep(delay)
301
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700302 def send_igmp_join_recvQuery(self, groups, rec_queryCount = None, src_list = ['1.2.3.4'], ip_pkt = None, iface = 'veth0', delay = 2):
303 self.onos_ssm_table_load(groups, src_list)
304 igmp = IGMPv3(type = IGMP_TYPE_V3_MEMBERSHIP_REPORT, max_resp_code=30,
305 gaddr=self.IP_DST)
306 for g in groups:
Chetan Gaonker38737f82016-05-11 17:44:17 -0700307 gr = IGMPv3gr(rtype=IGMP_V3_GR_TYPE_INCLUDE, mcaddr=g)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700308 gr.sources = src_list
309 gr.sources = src_list
310 igmp.grps.append(gr)
311 if ip_pkt is None:
312 ip_pkt = self.igmp_eth/self.igmp_ip
313 pkt = ip_pkt/igmp
314 IGMPv3.fixup(pkt)
315 if rec_queryCount == None:
A R Karthick76a497a2017-04-12 10:59:39 -0700316 log_test.info('Sending IGMP join for group %s and waiting for one query packet and printing the packet' %groups)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700317 resp = srp1(pkt, iface=iface)
318 else:
A R Karthick76a497a2017-04-12 10:59:39 -0700319 log_test.info('Sending IGMP join for group %s and waiting for periodic query packets and printing one packet' %groups)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700320 resp = srp1(pkt, iface=iface)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700321# resp = srp1(pkt, iface=iface) if rec_queryCount else srp3(pkt, iface=iface)
322 resp[0].summary()
A R Karthick76a497a2017-04-12 10:59:39 -0700323 log_test.info('Sent IGMP join for group %s and received a query packet and printing packet' %groups)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700324 if delay != 0:
325 time.sleep(delay)
326
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700327 def send_igmp_leave(self, groups, src_list = ['1.2.3.4'], ip_pkt = None, iface = 'veth0', delay = 2):
A R Karthick76a497a2017-04-12 10:59:39 -0700328 log_test.info('entering into igmp leave function')
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800329 igmp = IGMPv3(type = IGMP_TYPE_V3_MEMBERSHIP_REPORT, max_resp_code=30,
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700330 gaddr=self.IP_DST)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800331 for g in groups:
Chetan Gaonker38737f82016-05-11 17:44:17 -0700332 gr = IGMPv3gr(rtype=IGMP_V3_GR_TYPE_EXCLUDE, mcaddr=g)
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800333 gr.sources = src_list
334 igmp.grps.append(gr)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700335 if ip_pkt is None:
336 ip_pkt = self.igmp_eth/self.igmp_ip
337 pkt = ip_pkt/igmp
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800338 IGMPv3.fixup(pkt)
339 sendp(pkt, iface = iface)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800340 if delay != 0:
341 time.sleep(delay)
Chetan Gaonker25470972016-02-26 08:52:15 -0800342
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700343 def send_igmp_leave_listening_group_specific_query(self, groups, src_list = ['1.2.3.4'], ip_pkt = None, iface = 'veth0', delay = 2):
344 igmp = IGMPv3(type = IGMP_TYPE_V3_MEMBERSHIP_REPORT, max_resp_code=30,
345 gaddr=self.IP_DST)
346 for g in groups:
Chetan Gaonker38737f82016-05-11 17:44:17 -0700347 gr = IGMPv3gr(rtype=IGMP_V3_GR_TYPE_EXCLUDE, mcaddr=g)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700348 gr.sources = src_list
349 igmp.grps.append(gr)
350 if ip_pkt is None:
351 ip_pkt = self.igmp_eth/self.igmp_ip
352 pkt = ip_pkt/igmp
353 IGMPv3.fixup(pkt)
A R Karthick76a497a2017-04-12 10:59:39 -0700354 log_test.info('Sending IGMP leave for group %s and waiting for one group specific query packet and printing the packet' %groups)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700355 resp = srp1(pkt, iface=iface)
356 resp[0].summary()
A R Karthick76a497a2017-04-12 10:59:39 -0700357 log_test.info('Sent IGMP leave for group %s and received a group specific query packet and printing packet' %groups)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700358 if delay != 0:
359 time.sleep(delay)
360
A R Karthicka93fdee2017-07-14 17:27:35 -0700361 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800362 def test_igmp_join_verify_traffic(self):
Chetan Gaonkerddfdc522017-04-04 01:15:04 +0000363 groups = [self.MGROUP1, self.MGROUP1]
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700364 self.onos_ssm_table_load(groups)
Chetan Gaonker25470972016-02-26 08:52:15 -0800365 df = defer.Deferred()
366 igmpState = IGMPTestState(groups = groups, df = df)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800367 igmpStateRecv = IGMPTestState(groups = groups, df = df)
368 igmpStateList = (igmpState, igmpStateRecv)
A R Karthick38d5df42017-07-10 13:33:26 -0700369 tx_intf = self.port_map[self.PORT_TX_DEFAULT]
370 rx_intf = self.port_map[self.PORT_RX_DEFAULT]
371 mcastTraffic = McastTraffic(groups, iface= tx_intf, cb = self.send_mcast_cb, arg = igmpState)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800372 self.df = df
373 self.mcastTraffic = mcastTraffic
A R Karthick38d5df42017-07-10 13:33:26 -0700374 self.recv_socket = L3PacketSocket(iface = rx_intf, type = ETH_P_IP)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800375
376 def igmp_srp_task(stateList):
377 igmpSendState, igmpRecvState = stateList
378 if not mcastTraffic.isRecvStopped():
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800379 self.igmp_recv(igmpRecvState)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800380 reactor.callLater(0, igmp_srp_task, stateList)
381 else:
382 self.mcastTraffic.stop()
A R Karthickbd698672017-07-13 16:48:24 -0700383 #log_test.info('Sending IGMP leave for groups: %s' %groups)
384 self.send_igmp_leave(groups, iface = rx_intf, delay = 2)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800385 self.recv_socket.close()
386 self.igmp_verify_join(stateList)
387 self.df.callback(0)
388
A R Karthick38d5df42017-07-10 13:33:26 -0700389 self.send_igmp_join(groups, iface = rx_intf)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800390 mcastTraffic.start()
391 self.test_timer = reactor.callLater(self.MCAST_TRAFFIC_TIMEOUT, self.mcast_traffic_timer)
392 reactor.callLater(0, igmp_srp_task, igmpStateList)
Chetan Gaonker25470972016-02-26 08:52:15 -0800393 return df
394
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700395 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+40)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800396 def test_igmp_leave_verify_traffic(self):
A R Karthick38d5df42017-07-10 13:33:26 -0700397 groups = [self.MGROUP1]
398 leave_groups = [self.MGROUP1]
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700399 self.onos_ssm_table_load(groups)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800400 df = defer.Deferred()
401 igmpState = IGMPTestState(groups = groups, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800402 IGMPTestState(groups = groups, df = df)
A R Karthick38d5df42017-07-10 13:33:26 -0700403 tx_intf = self.port_map[self.PORT_TX_DEFAULT]
404 rx_intf = self.port_map[self.PORT_RX_DEFAULT]
405 mcastTraffic = McastTraffic(groups, iface= tx_intf, cb = self.send_mcast_cb,
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800406 arg = igmpState)
407 self.df = df
408 self.mcastTraffic = mcastTraffic
A R Karthick38d5df42017-07-10 13:33:26 -0700409 self.recv_socket = L3PacketSocket(iface = rx_intf, type = ETH_P_IP)
A.R Karthick95d044e2016-06-10 18:44:36 -0700410
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700411 mcastTraffic.start()
A R Karthick38d5df42017-07-10 13:33:26 -0700412 self.send_igmp_join(groups, iface = rx_intf)
413 time.sleep(5)
414 self.send_igmp_leave(leave_groups, delay = 3, iface = rx_intf)
415 time.sleep(10)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700416 join_state = IGMPTestState(groups = leave_groups)
A R Karthick38d5df42017-07-10 13:33:26 -0700417 status = self.igmp_not_recv_task(rx_intf, leave_groups, join_state)
A R Karthick76a497a2017-04-12 10:59:39 -0700418 log_test.info('verified status for igmp recv task %s'%status)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700419 assert status == 1 , 'EXPECTED RESULT'
420 self.df.callback(0)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800421 return df
422
423 @deferred(timeout=100)
424 def test_igmp_leave_join_loop(self):
425 self.groups = ['226.0.1.1', '227.0.0.1', '228.0.0.1', '229.0.0.1', '230.0.0.1' ]
426 self.src_list = ['3.4.5.6', '7.8.9.10']
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700427 self.onos_ssm_table_load(self.groups,src_list=self.src_list)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800428 df = defer.Deferred()
429 self.df = df
430 self.iterations = 0
431 self.num_groups = len(self.groups)
432 self.MAX_TEST_ITERATIONS = 10
A R Karthick38d5df42017-07-10 13:33:26 -0700433 rx_intf = self.port_map[self.PORT_RX_DEFAULT]
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800434
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800435 def igmp_srp_task(v):
436 if self.iterations < self.MAX_TEST_ITERATIONS:
437 if v == 1:
438 ##join test
439 self.num_groups = random.randint(0, len(self.groups))
440 self.send_igmp_join(self.groups[:self.num_groups],
441 src_list = self.src_list,
A R Karthick38d5df42017-07-10 13:33:26 -0700442 iface = rx_intf, delay = 0)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800443 else:
444 self.send_igmp_leave(self.groups[:self.num_groups],
445 src_list = self.src_list,
A R Karthick38d5df42017-07-10 13:33:26 -0700446 iface = rx_intf, delay = 0)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800447 self.iterations += 1
448 v ^= 1
449 reactor.callLater(1.0 + 0.5*self.num_groups,
450 igmp_srp_task, v)
451 else:
452 self.df.callback(0)
453
454 reactor.callLater(0, igmp_srp_task, 1)
455 return df
456
457 def igmp_join_task(self, intf, groups, state, src_list = ['1.2.3.4']):
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700458 #self.onos_ssm_table_load(groups, src_list)
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800459 igmp = IGMPv3(type = IGMP_TYPE_V3_MEMBERSHIP_REPORT, max_resp_code=30,
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700460 gaddr=self.IP_DST)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800461 for g in groups:
Chetan Gaonker38737f82016-05-11 17:44:17 -0700462 gr = IGMPv3gr(rtype = IGMP_V3_GR_TYPE_INCLUDE, mcaddr = g)
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800463 gr.sources = src_list
464 igmp.grps.append(gr)
465
466 for g in groups:
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800467 state.group_map[g][0].update(1, t = monotonic.monotonic())
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800468
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700469 pkt = self.igmp_eth/self.igmp_ip/igmp
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800470 IGMPv3.fixup(pkt)
471 sendp(pkt, iface=intf)
A R Karthick76a497a2017-04-12 10:59:39 -0700472 log_test.debug('Returning from join task')
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800473
474 def igmp_recv_task(self, intf, groups, join_state):
475 recv_socket = L3PacketSocket(iface = intf, type = ETH_P_IP)
476 group_map = {}
477 for g in groups:
478 group_map[g] = [0,0]
479
A R Karthick76a497a2017-04-12 10:59:39 -0700480 log_test.info('Verifying join interface should receive multicast data')
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800481 while True:
482 p = recv_socket.recv()
483 if p.dst in groups and group_map[p.dst][0] == 0:
484 group_map[p.dst][0] += 1
485 group_map[p.dst][1] = monotonic.monotonic()
486 c = 0
487 for g in groups:
488 c += group_map[g][0]
489 if c == len(groups):
490 break
491 for g in groups:
492 join_start = join_state.group_map[g][0].start
493 recv_time = group_map[g][1] * 1000000
494 delta = (recv_time - join_start)
A R Karthick76a497a2017-04-12 10:59:39 -0700495 log_test.info('Join for group %s received in %.3f usecs' %
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800496 (g, delta))
497
498 recv_socket.close()
A R Karthick76a497a2017-04-12 10:59:39 -0700499 log_test.debug('Returning from recv task')
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700500
501 def igmp_not_recv_task(self, intf, groups, join_state):
A R Karthick76a497a2017-04-12 10:59:39 -0700502 log_test.info('Entering igmp not recv task loop')
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700503 recv_socket = L2Socket(iface = intf, type = ETH_P_IP)
504 group_map = {}
505 for g in groups:
506 group_map[g] = [0,0]
507
A R Karthick76a497a2017-04-12 10:59:39 -0700508 log_test.info('Verifying join interface, should not receive any multicast data')
Chetan Gaonker7791bda2016-05-12 17:36:52 -0700509 self.NEGATIVE_TRAFFIC_STATUS = 1
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700510 def igmp_recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -0700511 log_test.info('Multicast packet %s received for left groups %s' %(pkt[IP].dst, groups))
Chetan Gaonker7791bda2016-05-12 17:36:52 -0700512 self.NEGATIVE_TRAFFIC_STATUS = 2
Chetan Gaonker38737f82016-05-11 17:44:17 -0700513 sniff(prn = igmp_recv_cb, count = 1, lfilter = lambda p: IP in p and p[IP].dst in groups,
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700514 timeout = 3, opened_socket = recv_socket)
515 recv_socket.close()
A.R Karthick95d044e2016-06-10 18:44:36 -0700516 return self.NEGATIVE_TRAFFIC_STATUS
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700517
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800518 def group_latency_check(self, groups):
519 tasks = []
520 self.send_igmp_leave(groups = groups)
521 join_state = IGMPTestState(groups = groups)
522 tasks.append(threading.Thread(target=self.igmp_join_task, args = ('veth0', groups, join_state,)))
523 traffic_state = IGMPTestState(groups = groups)
A.R Karthick95d044e2016-06-10 18:44:36 -0700524 mcast_traffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb,
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800525 arg = traffic_state)
526 mcast_traffic.start()
527 tasks.append(threading.Thread(target=self.igmp_recv_task, args = ('veth0', groups, join_state)))
528 for t in tasks:
529 t.start()
530 for t in tasks:
531 t.join()
532
533 mcast_traffic.stop()
534 self.send_igmp_leave(groups = groups)
535 return
536
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700537 @deferred(timeout=IGMP_QUERY_TIMEOUT + 10)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800538 def test_igmp_1group_join_latency(self):
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700539 groups = ['239.0.1.1']
540 df = defer.Deferred()
541 def igmp_1group_join_latency():
542 self.group_latency_check(groups)
543 df.callback(0)
544 reactor.callLater(0, igmp_1group_join_latency)
545 return df
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800546
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700547 @deferred(timeout=IGMP_QUERY_TIMEOUT + 10)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800548 def test_igmp_2group_join_latency(self):
Chetan Gaonkerddfdc522017-04-04 01:15:04 +0000549 groups = [self.MGROUP1, self.MGROUP1]
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700550 df = defer.Deferred()
551 def igmp_2group_join_latency():
552 self.group_latency_check(groups)
553 df.callback(0)
554 reactor.callLater(0, igmp_2group_join_latency)
555 return df
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800556
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700557 @deferred(timeout=IGMP_QUERY_TIMEOUT + 10)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800558 def test_igmp_Ngroup_join_latency(self):
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700559 groups = ['239.0.1.1', '240.0.1.1', '241.0.1.1', '242.0.1.1']
560 df = defer.Deferred()
561 def igmp_Ngroup_join_latency():
562 self.group_latency_check(groups)
563 df.callback(0)
564 reactor.callLater(0, igmp_Ngroup_join_latency)
565 return df
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800566
A R Karthick2b93d6a2016-09-06 15:19:09 -0700567 def test_igmp_join_rover_all(self):
Chetan Gaonker1f7c3f82016-03-08 12:17:37 -0800568 s = (224 << 24) | 1
569 #e = (225 << 24) | (255 << 16) | (255 << 16) | 255
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700570 e = (224 << 24) | 10
Chetan Gaonker1f7c3f82016-03-08 12:17:37 -0800571 for i in xrange(s, e+1):
572 if i&0xff:
573 ip = '%d.%d.%d.%d'%((i>>24)&0xff, (i>>16)&0xff, (i>>8)&0xff, i&0xff)
574 self.send_igmp_join([ip], delay = 0)
575
A R Karthick2b93d6a2016-09-06 15:19:09 -0700576 @deferred(timeout=ROVER_TEST_TIMEOUT)
577 def test_igmp_join_rover(self):
578 df = defer.Deferred()
579 iface = self.get_igmp_intf()
580 self.df = df
581 self.count = 0
582 self.timeout = 0
583 self.complete = False
584 def igmp_join_timer():
585 self.timeout += self.ROVER_JOIN_TIMEOUT
A R Karthick76a497a2017-04-12 10:59:39 -0700586 log_test.info('IGMP joins sent: %d' %self.count)
A R Karthick2b93d6a2016-09-06 15:19:09 -0700587 if self.timeout >= self.ROVER_TIMEOUT:
588 self.complete = True
589 reactor.callLater(self.ROVER_JOIN_TIMEOUT, igmp_join_timer)
590
591 reactor.callLater(self.ROVER_JOIN_TIMEOUT, igmp_join_timer)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800592 self.start_channel = (224 << 24) | 1
593 self.end_channel = (224 << 24) | 200 #(225 << 24) | (255 << 16) | (255 << 16) | 255
A R Karthick2b93d6a2016-09-06 15:19:09 -0700594 self.current_channel = self.start_channel
595 def igmp_join_rover(self):
596 #e = (224 << 24) | 10
597 chan = self.current_channel
598 self.current_channel += 1
599 if self.current_channel >= self.end_channel:
600 chan = self.current_channel = self.start_channel
601 if chan&0xff:
602 ip = '%d.%d.%d.%d'%((chan>>24)&0xff, (chan>>16)&0xff, (chan>>8)&0xff, chan&0xff)
603 self.send_igmp_join([ip], delay = 0, ssm_load = False, iface = iface)
604 self.count += 1
605 if self.complete == True:
A R Karthick76a497a2017-04-12 10:59:39 -0700606 log_test.info('%d IGMP joins sent in %d seconds over %s' %(self.count, self.timeout, iface))
A R Karthick2b93d6a2016-09-06 15:19:09 -0700607 self.df.callback(0)
608 else:
609 reactor.callLater(0, igmp_join_rover, self)
610 reactor.callLater(0, igmp_join_rover, self)
611 return df
612
Chetan Gaonker1f7c3f82016-03-08 12:17:37 -0800613 @deferred(timeout=IGMP_QUERY_TIMEOUT + 10)
614 def test_igmp_query(self):
615 groups = ['224.0.0.1'] ##igmp query group
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700616 self.onos_ssm_table_load(groups)
Chetan Gaonker1f7c3f82016-03-08 12:17:37 -0800617 df = defer.Deferred()
618 self.df = df
619 self.recv_socket = L2Socket(iface = 'veth0', type = ETH_P_IP)
A.R Karthick95d044e2016-06-10 18:44:36 -0700620
Chetan Gaonker1f7c3f82016-03-08 12:17:37 -0800621 def igmp_query_timeout():
Chetan Gaonker1f7c3f82016-03-08 12:17:37 -0800622 def igmp_query_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -0700623 log_test.info('received igmp query packet is %s'%pkt.show())
624 log_test.info('Got IGMP query packet from %s for %s' %(pkt[IP].src, pkt[IP].dst))
Chetan Gaonkerbd4390f2016-03-09 18:56:52 -0800625 assert_equal(pkt[IP].dst, '224.0.0.1')
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700626 sniff(prn = igmp_query_cb, count=1, lfilter = lambda p: IP in p and p[IP].dst in groups,
Chetan Gaonkerbd4390f2016-03-09 18:56:52 -0800627 opened_socket = self.recv_socket)
Chetan Gaonker1f7c3f82016-03-08 12:17:37 -0800628 self.recv_socket.close()
629 self.df.callback(0)
630
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700631 #self.send_igmp_join(groups)
Chetan Gaonker1f7c3f82016-03-08 12:17:37 -0800632 self.test_timer = reactor.callLater(self.IGMP_QUERY_TIMEOUT, igmp_query_timeout)
633 return df
634
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700635 def igmp_send_joins_different_groups_srclist(self, groups, sources, intf = V_INF1, delay = 2, ip_src = None):
636 g1 = groups[0]
637 g2 = groups[1]
638 sourcelist1 = sources[0]
639 sourcelist2 = sources[1]
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700640 eth = Ether(dst = self.IGMP_DST_MAC,type = ETH_P_IP)
641 ip = IP(dst = self.IP_DST)
A R Karthick76a497a2017-04-12 10:59:39 -0700642 log_test.info('Sending join message for the group %s' %g1)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700643 self.send_igmp_join((g1,), src_list = sourcelist1, ip_pkt = eth/ip, iface = intf, delay = 2)
644 eth = Ether(dst = self.MMACGROUP2, src = self.IGMP_SRC_MAC, type = ETH_P_IP)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700645 ip = IP(dst = g2)
A R Karthick76a497a2017-04-12 10:59:39 -0700646 log_test.info('Sending join message for group %s' %g2)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700647 self.send_igmp_join((g2,), src_list = sourcelist2, ip_pkt = eth/ip, iface = intf, delay = 2)
A R Karthick76a497a2017-04-12 10:59:39 -0700648 log_test.info('Done with igmp_send_joins_different_groups_srclist')
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700649
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700650 def igmp_send_joins_different_groups_srclist_wait_query_packets(self, groups, sources, intf = V_INF1, delay = 2, ip_src = None, query_group1 = None, query_group2 = None):
651 g1 = groups[0]
652 g2 = groups[1]
653 sourcelist1 = sources[0]
654 sourcelist2 = sources[1]
655 eth = Ether(dst = self.MMACGROUP1, src = self.IGMP_SRC_MAC, type = ETH_P_IP)
656 src_ip = ip_src or self.IP_SRC
657 ip = IP(dst = g1, src = src_ip)
658 if query_group1 is 'group1':
A R Karthick76a497a2017-04-12 10:59:39 -0700659 log_test.info('Sending join message for the group %s and waiting for a query packet on join interface' %g1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700660 self.send_igmp_join_recvQuery((g1,), None, src_list = sourcelist1, ip_pkt = eth/ip, iface = intf, delay = 2)
A.R Karthick95d044e2016-06-10 18:44:36 -0700661 else:
A R Karthick76a497a2017-04-12 10:59:39 -0700662 log_test.info('Sending join message for the group %s' %g1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700663 self.send_igmp_join((g1,), src_list = sourcelist1, ip_pkt = eth/ip, iface = intf, delay = 2)
664 eth = Ether(dst = self.MMACGROUP2, src = self.IGMP_SRC_MAC, type = ETH_P_IP)
665 ip = IP(dst = g2, src = src_ip)
666 if query_group2 is 'group2':
A R Karthick76a497a2017-04-12 10:59:39 -0700667 log_test.info('Sending join message for the group %s and waiting for a query packet on join interface' %g2)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700668 self.send_igmp_join_recvQuery((g2,), None, src_list = sourcelist2, ip_pkt = eth/ip, iface = intf, delay = 2)
A.R Karthick95d044e2016-06-10 18:44:36 -0700669 else:
A R Karthick76a497a2017-04-12 10:59:39 -0700670 log_test.info('Sending join message for group %s' %g2)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700671 self.send_igmp_join((g2,), src_list = sourcelist2, ip_pkt = eth/ip, iface = intf, delay = 2)
672
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700673 def igmp_joins_leave(self,groups,src_list,again_join = False, df = None):
674 groups1 = [groups[0]]
675 groups2 = [groups[1]]
676 src1 = [src_list[0]]
677 src2 = [src_list[1]]
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700678 self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700679 (src1, src2), intf = self.V_INF1, delay = 2)
680
681 src_ip = src1[0]
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700682 if df is None:
683 df = defer.Deferred()
684 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800685 IGMPTestState(groups = groups1, df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700686
687 igmpState2 = IGMPTestState(groups = groups2, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800688 IGMPTestState(groups = groups2, df = df)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700689 dst_mac = self.iptomac(groups1[0])
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700690 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
691 src_ip = src_ip, cb = self.send_mcast_cb,
692 arg = igmpState1)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700693 src_ip = src2[0]
694 dst_mac = self.iptomac(groups1[0])
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700695 mcastTraffic2 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
696 src_ip = src_ip, cb = self.send_mcast_cb,
697 arg = igmpState2)
698 mcastTraffic1.start()
699 mcastTraffic2.start()
700 join_state1 = IGMPTestState(groups = groups1)
701 join_state2 = IGMPTestState(groups = groups2)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800702 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
A R Karthick76a497a2017-04-12 10:59:39 -0700703 log_test.info('Interface is receiving multicast groups %s' %groups1)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800704 self.igmp_recv_task(self.V_INF1, groups2, join_state2)
A R Karthick76a497a2017-04-12 10:59:39 -0700705 log_test.info('Interface is receiving multicast groups %s' %groups2)
706 log_test.info('Interface is sending leave message for groups %s now' %groups2)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700707 self.send_igmp_leave(groups = groups2, src_list = src2, iface = self.V_INF1, delay = 2)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800708 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700709 target4 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state2)
710 assert target4 == 1, 'EXPECTED FAILURE'
711 if again_join:
712 dst_mac = '01:00:5e:02:02:03'
713 ip_dst = '239.2.2.3'
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700714 eth = Ether(dst = dst_mac, type = ETH_P_IP)
715 ip = IP(dst = ip_dst)
A R Karthick76a497a2017-04-12 10:59:39 -0700716 log_test.info('Interface sending join message again for the groups %s' %groups2)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700717 self.send_igmp_join(groups2, src_list = [src_ip], ip_pkt = eth/ip, iface = self.V_INF1, delay = 2)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800718 self.igmp_recv_task(self.V_INF1, groups2, join_state2)
A R Karthick76a497a2017-04-12 10:59:39 -0700719 log_test.info('Interface is receiving multicast groups %s again' %groups2)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800720 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
A R Karthick76a497a2017-04-12 10:59:39 -0700721 log_test.info('Interface is still receiving from multicast groups %s' %groups1)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700722 else:
A R Karthick76a497a2017-04-12 10:59:39 -0700723 log_test.info('Ended test case')
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700724 mcastTraffic1.stop()
725 mcastTraffic2.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -0700726
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700727
728 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700729 def test_igmp_2joins_1leave(self):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700730 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700731 def igmp_2joins_1leave():
732 groups = ['234.2.3.4','236.8.7.9']
733 src_list = ['2.3.4.5','5.4.3.2']
734 self.onos_ssm_table_load(groups,src_list = src_list)
735 self.igmp_joins_leave(groups,src_list,again_join = False, df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700736 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700737 reactor.callLater(0, igmp_2joins_1leave)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700738 return df
739
740 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+25)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700741 def test_igmp_2joins_1leave_and_join_again(self):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700742 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700743 def igmp_2joins_1leave_join_again():
744 groups = ['234.2.3.4','236.8.7.9']
745 src_list = ['2.3.4.5','5.4.3.2']
746 self.onos_ssm_table_load(groups,src_list = src_list)
747 self.igmp_joins_leave(groups,src_list,again_join = True, df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700748 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700749 reactor.callLater(0, igmp_2joins_1leave_join_again)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700750 return df
751
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700752 def igmp_not_in_src_list(self, df = None):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700753 groups1 = (self.MGROUP1,)
754 groups2 = (self.MGROUP2,)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700755 self.onos_ssm_table_load(groups1 + groups2,src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4','2.2.2.2', '5.5.5.5'])
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700756 self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
757 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
758 intf = self.V_INF1, delay = 2)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700759 src_ip = '6.6.6.6'
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700760 dst_mac = self.iptomac(groups1[0])
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700761 if df is None:
762 df = defer.Deferred()
763 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800764 IGMPTestState(groups = groups1, df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700765 mcastTraffic1 = McastTraffic(groups1, iface = 'veth2', dst_mac = dst_mac,
766 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
767 mcastTraffic1.start()
768 join_state1 = IGMPTestState(groups = groups1)
A R Karthick76a497a2017-04-12 10:59:39 -0700769 log_test.info('Interface should not receive from multicast groups %s from an interface, which is expected' %groups1)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700770 target1 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
Chetan Gaonker7791bda2016-05-12 17:36:52 -0700771 assert target1 == 2, 'EXPECTED FAILURE'
A R Karthick76a497a2017-04-12 10:59:39 -0700772 log_test.info('Interface is not receiving traffic from multicast groups %s, working as expected' %groups1)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700773 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -0700774
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700775 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700776 def test_igmp_not_in_src_list(self):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700777 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700778 def igmp_not_in_src_list():
779 self.igmp_not_in_src_list(df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700780 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700781 reactor.callLater(0, igmp_not_in_src_list)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700782 return df
783
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700784 def igmp_change_to_exclude_src_list(self, df = None):
785 groups1 = [self.random_mcast_ip()]
786 groups2 = [self.random_mcast_ip()]
787 self.onos_ssm_table_load(groups1 + groups2,src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4','2.2.2.2', '5.5.5.5'])
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700788 self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
789 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
790 intf = self.V_INF1, delay = 2)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700791 src_ip = '2.2.2.2'
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700792 dst_mac=self.iptomac(groups1[0])
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700793 if df is None:
794 df = defer.Deferred()
795 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800796 IGMPTestState(groups = groups1, df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700797 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
798 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
799 mcastTraffic1.start()
800 join_state1 = IGMPTestState(groups = groups1)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800801 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700802 self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2'], iface = self.V_INF1, delay =2)
803 target2 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
Chetan Gaonker7791bda2016-05-12 17:36:52 -0700804 assert target2 == 2, 'EXPECTED FAILURE'
A R Karthick76a497a2017-04-12 10:59:39 -0700805 log_test.info('Interface is not receiving traffic from multicast groups %s after sending CHANGE_TO_EXCLUDE' %groups1)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700806 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -0700807
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700808 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700809 def test_igmp_change_to_exclude_src_list(self):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700810 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700811 def igmp_change_to_exclude_src_list():
812 self.igmp_change_to_exclude_src_list(df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700813 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700814 reactor.callLater(0, igmp_change_to_exclude_src_list)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700815 return df
816
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700817 def igmp_include_to_allow_src_list(self, df = None):
818 groups1 = [self.random_mcast_ip()] #(self.MGROUP1,)
819 self.onos_ssm_table_load(groups1,src_list = ['4.4.4.4','6.6.6.6'])
820 self.send_igmp_join(groups = groups1, src_list = ['4.4.4.4'],record_type = IGMP_V3_GR_TYPE_INCLUDE,
821 iface = self.V_INF1)
822 src_ip = '4.4.4.4'
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700823 if df is None:
824 df = defer.Deferred()
825 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800826 IGMPTestState(groups = groups1, df = df)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700827 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2',src_ip = src_ip,
828 cb = self.send_mcast_cb, arg = igmpState1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700829 mcastTraffic1.start()
830 join_state1 = IGMPTestState(groups = groups1)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800831 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700832 mcastTraffic1.stop()
833 mcastTraffic2 = McastTraffic(groups1, iface= 'veth2',src_ip = '6.6.6.6',
834 cb = self.send_mcast_cb, arg = igmpState1)
835 self.send_igmp_join(groups = groups1, src_list = ['6.6.6.6'],record_type = IGMP_V3_GR_TYPE_ALLOW_NEW,
836 iface = self.V_INF1)
837 mcastTraffic2.start()
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800838 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700839 mcastTraffic2.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -0700840
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700841 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+30)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700842 def test_igmp_include_to_allow_src_list(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700843 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700844 def igmp_include_to_allow_src_list():
845 self.igmp_include_to_allow_src_list(df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700846 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700847 reactor.callLater(0, igmp_include_to_allow_src_list)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700848 return df
849
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700850 def igmp_include_to_block_src_list(self, df = None):
851 groups1 = [self.random_mcast_ip()] #groups1 = (self.MGROUP1,)
852 self.onos_ssm_table_load(groups1,src_list = ['4.4.4.4','6.6.6.6'])
853 self.send_igmp_join(groups = groups1, src_list = ['4.4.4.4','6.6.6.6'],record_type = IGMP_V3_GR_TYPE_INCLUDE,
854 iface = self.V_INF1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700855 if df is None:
856 df = defer.Deferred()
857 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800858 IGMPTestState(groups = groups1, df = df)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700859 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2',src_ip = '6.6.6.6',
860 cb = self.send_mcast_cb, arg = igmpState1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700861 mcastTraffic1.start()
862 join_state1 = IGMPTestState(groups = groups1)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800863 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700864 mcastTraffic1.stop()
865 self.send_igmp_join(groups = groups1, src_list = ['6.6.6.6'],record_type = IGMP_V3_GR_TYPE_BLOCK_OLD,
866 iface = self.V_INF1)
867 mcastTraffic2 = McastTraffic(groups1, iface= 'veth2',src_ip = '6.6.6.6',
868 cb = self.send_mcast_cb, arg = igmpState1)
869 mcastTraffic2.start()
870 target1 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
871 assert target1 == 1, 'EXPECTED FAILURE'
A R Karthick76a497a2017-04-12 10:59:39 -0700872 log_test.info('Interface is still receiving traffic from old multicast group %s even after we send block for source list' %groups1)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700873 mcastTraffic2.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -0700874
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700875 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+30)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700876 def test_igmp_include_to_block_src_list(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700877 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700878 def igmp_include_to_block_src_list():
879 self.igmp_include_to_block_src_list(df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700880 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700881 reactor.callLater(0, igmp_include_to_block_src_list)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700882 return df
883
884
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700885 def igmp_change_to_include_src_list(self, df = None):
886 groups1 = [self.random_mcast_ip()]
887 src_list = ['4.4.4.4','6.6.6.6']
888 self.onos_ssm_table_load(groups1,src_list = src_list)
889 self.send_igmp_leave(groups = groups1, src_list = src_list,
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700890 iface = self.V_INF1, delay = 2)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700891 if df is None:
892 df = defer.Deferred()
893 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800894 IGMPTestState(groups = groups1, df = df)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700895 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2',src_ip = src_list[0],
896 cb = self.send_mcast_cb, arg = igmpState1)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700897 mcastTraffic1.start()
898 join_state1 = IGMPTestState(groups = groups1)
899 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
900 assert target1 == 1, 'EXPECTED FAILURE'
A R Karthick76a497a2017-04-12 10:59:39 -0700901 log_test.info('Interface is not receiving traffic from multicast groups %s' %groups1)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700902 mcastTraffic1.stop()
903 self.send_igmp_join(groups = groups1, src_list = src_list,record_type = IGMP_V3_GR_TYPE_INCLUDE,
904 iface = self.V_INF1)
905 mcastTraffic2 = McastTraffic(groups1, iface= 'veth2',src_ip = src_list[1],
906 cb = self.send_mcast_cb, arg = igmpState1)
907 mcastTraffic2.start()
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800908 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700909 mcastTraffic2.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -0700910
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700911 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700912 def test_igmp_change_to_include_src_list(self):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700913 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700914 def igmp_change_to_include_src_list():
915 self.igmp_change_to_include_src_list(df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700916 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700917 reactor.callLater(0, igmp_change_to_include_src_list)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700918 return df
919
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700920 #this test case failing because group in include receiving multicast traffic from any of the source
921 def igmp_exclude_to_allow_src_list(self, df = None):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700922 groups1 = (self.MGROUP1,)
923 groups2 = (self.MGROUP2,)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700924 self.onos_ssm_table_load(groups1+groups2,src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4','6.6.6.6', '7.7.7.7', '8.8.8.8','5.5.5.5'])
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700925 self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4'],
926 iface = self.V_INF1, delay = 2)
A.R Karthick95d044e2016-06-10 18:44:36 -0700927
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700928 dst_mac = '01:00:5e:01:02:03'
929 src_ip = '2.2.2.2'
930 if df is None:
931 df = defer.Deferred()
932 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800933 IGMPTestState(groups = groups1, df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700934 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
935 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
936 mcastTraffic1.start()
937 join_state1 = IGMPTestState(groups = groups1)
938 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
939 assert target1 == 1, 'EXPECTED FAILURE'
A R Karthick76a497a2017-04-12 10:59:39 -0700940 log_test.info('Interface is not receiving traffic from multicast groups %s' %groups1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700941 self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
942 (['6.6.6.6', '7.7.7.7', '8.8.8.8'], ['6.6.6.6', '5.5.5.5']),
943 intf = self.V_INF1, delay = 2)
944 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
945 assert target1 == 1, 'EXPECTED FAILURE'
A R Karthick76a497a2017-04-12 10:59:39 -0700946 log_test.info('Interface is not receiving traffic from multicast groups %s' %groups1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700947 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -0700948
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700949 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700950 def test_igmp_exclude_to_allow_src_list(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700951 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700952 def igmp_exclude_to_allow_src_list():
953 self.igmp_exclude_to_allow_src_list(df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700954 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700955 reactor.callLater(0, igmp_exclude_to_allow_src_list)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700956 return df
957
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700958 def igmp_exclude_to_block_src_list(self, df = None):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700959 groups1 = (self.MGROUP1,)
960 groups2 = (self.MGROUP2,)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700961 self.onos_ssm_table_load(groups1+groups2,src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4','7.7.7.7','5.5.5.5'])
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700962 self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4'],
963 iface = self.V_INF1, delay = 2)
A.R Karthick95d044e2016-06-10 18:44:36 -0700964
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700965 dst_mac = '01:00:5e:01:02:03'
966 src_ip = '2.2.2.2'
967 if df is None:
968 df = defer.Deferred()
969 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800970 IGMPTestState(groups = groups1, df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700971 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
972 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
973 mcastTraffic1.start()
974 join_state1 = IGMPTestState(groups = groups1)
975 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
976 assert target1 == 1, 'EXPECTED FAILURE'
A R Karthick76a497a2017-04-12 10:59:39 -0700977 log_test.info('Interface is not receiving traffic from multicast groups %s' %groups1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700978 self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4', '5.5.5.5', '7.7.7.7'],
979 iface = self.V_INF1, delay = 2)
980 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
981 assert target1 == 1, 'EXPECTED FAILURE'
A R Karthick76a497a2017-04-12 10:59:39 -0700982 log_test.info('Interface is not receiving traffic from multicast groups %s' %groups1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700983 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -0700984
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700985 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700986 def test_igmp_exclude_to_block_src_list(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700987 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700988 def igmp_exclude_to_block_src_list():
989 self.igmp_exclude_to_block_src_list(df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700990 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700991 reactor.callLater(0, igmp_exclude_to_block_src_list)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700992 return df
993
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700994 #this test case failing because group in include mode recieves traffic from other sources also.
995 def igmp_new_src_list(self, df = None):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700996 groups1 = (self.MGROUP1,)
997 groups2 = (self.MGROUP2,)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700998 self.onos_ssm_table_load(groups1+groups2,src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4','5.5.5.5','6.6.6.6'])
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700999 self.igmp_send_joins_different_groups_srclist(groups1+groups2,
1000 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
1001 intf = self.V_INF1, delay = 2)
1002 dst_mac = '01:00:5e:01:02:03'
1003 src_ip = '6.6.6.6'
1004 if df is None:
1005 df = defer.Deferred()
1006 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001007 IGMPTestState(groups = groups1, df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001008 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
1009 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1010 mcastTraffic1.start()
1011 join_state1 = IGMPTestState(groups = groups1)
1012 target1 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
1013 assert target1 == 1, 'EXPECTED FAILURE'
A R Karthick76a497a2017-04-12 10:59:39 -07001014 log_test.info('Interface is not receiving traffic from multicast groups %s' %groups1)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001015 self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001016 (['2.2.2.2', '6.6.6.6', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001017 intf = self.V_INF1, delay = 2)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001018 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
A R Karthick76a497a2017-04-12 10:59:39 -07001019 log_test.info('Interface is receiving traffic from multicast groups %s after sending join with new source list' %groups1)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001020 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001021
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001022 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001023 def test_igmp_new_src_list(self):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001024 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001025 def igmp_new_src_list():
1026 self.igmp_new_src_list(df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001027 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001028 reactor.callLater(0, igmp_new_src_list)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001029 return df
1030
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001031 def igmp_block_old_src_list(self, df = None):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001032 groups1 = (self.MGROUP1,)
1033 groups2 = (self.MGROUP2,)
1034 groups = groups1 + groups2
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001035 self.onos_ssm_table_load(groups1+groups2,src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4','5.5.5.5','6.6.6.6','7.7.7.7'])
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001036 self.igmp_send_joins_different_groups_srclist(groups,
1037 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
1038 intf = self.V_INF1, delay = 2)
1039 dst_mac = '01:00:5e:02:02:03'
1040 src_ip = '5.5.5.5'
1041 if df is None:
1042 df = defer.Deferred()
1043 igmpState1 = IGMPTestState(groups = groups2, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001044 IGMPTestState(groups = groups2, df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001045 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1046 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1047 mcastTraffic1.start()
1048 join_state1 = IGMPTestState(groups = groups2)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001049 self.igmp_recv_task(self.V_INF1, groups2, join_state1)
A R Karthick76a497a2017-04-12 10:59:39 -07001050 log_test.info('Interface is receiving traffic from multicast groups %s' %groups2)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001051 self.igmp_send_joins_different_groups_srclist(groups,
1052 (['6.6.6.6', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '7.7.7.7']),
1053 intf = self.V_INF1, delay = 2)
1054 target2 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1)
Chetan Gaonker7791bda2016-05-12 17:36:52 -07001055 assert target2 == 2, 'EXPECTED FAILURE'
A R Karthick76a497a2017-04-12 10:59:39 -07001056 log_test.info('Interface is not receiving traffic from multicast groups %s after sending join with block old source list' %groups2)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001057 mcastTraffic1.stop()
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001058
1059 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001060 def test_igmp_block_old_src_list(self):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001061 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001062 def igmp_block_old_src_list():
1063 self.igmp_block_old_src_list(df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001064 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001065 reactor.callLater(0, igmp_block_old_src_list)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001066 return df
1067
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001068 def igmp_include_empty_src_list(self, df = None):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001069 groups1 = (self.MGROUP1,)
1070 groups2 = (self.MGROUP2,)
1071 groups = groups1 + groups2
1072 self.igmp_send_joins_different_groups_srclist(groups,
Thangavelu K S790ad332016-12-14 12:54:58 +05301073 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['0']),
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001074 intf = self.V_INF1, delay = 2)
1075 dst_mac = '01:00:5e:02:02:03'
1076 src_ip = '5.5.5.5'
1077 if df is None:
1078 df = defer.Deferred()
1079 igmpState1 = IGMPTestState(groups = groups2, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001080 IGMPTestState(groups = groups2, df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001081 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1082 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1083 mcastTraffic1.start()
1084 join_state1 = IGMPTestState(groups = groups2)
1085 target1 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1)
1086 assert target1==1, 'EXPECTED FAILURE'
A R Karthick76a497a2017-04-12 10:59:39 -07001087 log_test.info('Interface is not receiving traffic from multicast groups %s when we sent join with source list is empty' %groups2)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001088 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001089
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001090 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001091 def test_igmp_include_empty_src_list(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001092 ## '''Disabling this test as scapy IGMP doesn't work with empty source lists'''
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001093 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001094 def igmp_include_empty_src_list():
1095 self.igmp_include_empty_src_list(df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001096 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001097 reactor.callLater(0, igmp_include_empty_src_list)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001098 return df
1099
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001100 def igmp_exclude_empty_src_list(self, df = None):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001101 groups2 = (self.MGROUP2,)
Thangavelu K S790ad332016-12-14 12:54:58 +05301102 self.send_igmp_leave(groups = groups2, src_list = ['0'], iface = self.V_INF1, delay = 2)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001103 dst_mac = '01:00:5e:02:02:03'
1104 src_ip = '5.5.5.5'
1105 if df is None:
1106 df = defer.Deferred()
1107 igmpState1 = IGMPTestState(groups = groups2, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001108 IGMPTestState(groups = groups2, df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001109 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1110 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1111 mcastTraffic1.start()
1112 join_state1 = IGMPTestState(groups = groups2)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001113 self.igmp_recv_task(self.V_INF1, groups2, join_state1)
A R Karthick76a497a2017-04-12 10:59:39 -07001114 log_test.info('Interface is receiving multicast groups %s' %groups2)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001115 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001116
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001117 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001118 def test_igmp_exclude_empty_src_list(self):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001119 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001120 def igmp_exclude_empty_src_list():
1121 self.igmp_exclude_empty_src_list()
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001122 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001123 reactor.callLater(0, igmp_exclude_empty_src_list)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001124 return df
1125
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001126 def igmp_join_sourceip_0_0_0_0(self, df = None):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001127 groups1 = (self.MGROUP1,)
1128 groups2 = (self.MGROUP2,)
1129 groups = groups1 + groups2
1130 ip_src = '0.0.0.0'
1131 self.igmp_send_joins_different_groups_srclist(groups,
1132 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['5.5.5.5']),
1133 intf = self.V_INF1, delay = 2, ip_src = ip_src)
1134 ip_src = self.IP_SRC
1135 dst_mac = '01:00:5e:02:02:03'
1136 src_ip = '5.5.5.5'
1137 if df is None:
1138 df = defer.Deferred()
1139 igmpState1 = IGMPTestState(groups = groups2, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001140 IGMPTestState(groups = groups2, df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001141 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1142 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1143 mcastTraffic1.start()
1144 join_state1 = IGMPTestState(groups = groups2)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001145 self.igmp_recv_task(self.V_INF1, groups2, join_state1)
A R Karthick76a497a2017-04-12 10:59:39 -07001146 log_test.info('Interface is receiving traffic from multicast groups %s when we sent join with source IP is 0.0.0.0' %groups2)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001147 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001148
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001149 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001150 def test_igmp_join_sourceip_0_0_0_0(self):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001151 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001152 def igmp_join_sourceip_0_0_0_0():
1153 self.igmp_join_sourceip_0_0_0_0(df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001154 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001155 reactor.callLater(0, igmp_join_sourceip_0_0_0_0)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001156 return df
1157
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001158 def igmp_invalid_join_packet(self, df = None):
Chetan Gaonker586fec32016-04-29 17:33:54 -07001159 groups1 = (self.MGROUP1,)
1160 groups2 = (self.MINVALIDGROUP1,)
1161 groups = groups1 + groups2
1162 ip_src = '1.1.1.1'
1163 self.igmp_send_joins_different_groups_srclist(groups,
1164 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['5.5.5.5']),
1165 intf = self.V_INF1, delay = 2, ip_src = ip_src)
1166 ip_src = self.IP_SRC
1167 dst_mac = '01:00:5e:02:02:03'
1168 src_ip = '5.5.5.5'
1169 if df is None:
1170 df = defer.Deferred()
1171 igmpState1 = IGMPTestState(groups = groups2, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001172 IGMPTestState(groups = groups2, df = df)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001173 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1174 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1175 mcastTraffic1.start()
1176 join_state1 = IGMPTestState(groups = groups2)
1177 target1 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1)
1178 assert target1==1, 'EXPECTED FAILURE'
A R Karthick76a497a2017-04-12 10:59:39 -07001179 log_test.info('Interface is not receiving traffic from multicast groups %s when we sent invalid join packet ' %groups2)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001180 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001181
Chetan Gaonker586fec32016-04-29 17:33:54 -07001182 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001183 def test_igmp_invalid_join_packet(self):
Chetan Gaonker586fec32016-04-29 17:33:54 -07001184 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001185 def igmp_invalid_join_packet():
1186 self.igmp_invalid_join_packet(df = df)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001187 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001188 reactor.callLater(0, igmp_invalid_join_packet)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001189 return df
1190
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001191 def igmp_join_data_receiving_during_subscriber_link_toggle(self, df = None):
Chetan Gaonker586fec32016-04-29 17:33:54 -07001192 groups1 = (self.MGROUP1,)
1193 groups2 = (self.MGROUP2,)
1194 groups = groups1 + groups2
1195 ip_src = '1.1.1.1'
1196 self.igmp_send_joins_different_groups_srclist(groups,
1197 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['5.5.5.5']),
1198 intf = self.V_INF1, delay = 2, ip_src = ip_src)
1199 ip_src = self.IP_SRC
1200 dst_mac = '01:00:5e:02:02:03'
1201 src_ip = '5.5.5.5'
1202 if df is None:
1203 df = defer.Deferred()
1204 igmpState1 = IGMPTestState(groups = groups2, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001205 IGMPTestState(groups = groups2, df = df)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001206 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1207 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1208 mcastTraffic1.start()
1209 join_state1 = IGMPTestState(groups = groups2)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001210 self.igmp_recv_task(self.V_INF1, groups2, join_state1)
A R Karthick76a497a2017-04-12 10:59:39 -07001211 log_test.info('Interface is receiving traffic from multicast groups, before bring down the self.V_INF1=%s ' %self.V_INF1)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001212 os.system('ifconfig '+self.V_INF1+' down')
A R Karthick76a497a2017-04-12 10:59:39 -07001213 log_test.info(' the self.V_INF1 %s is down now ' %self.V_INF1)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001214 os.system('ifconfig '+self.V_INF1)
1215 time.sleep(10)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001216 os.system('ifconfig '+self.V_INF1+' up')
1217 os.system('ifconfig '+self.V_INF1)
A R Karthick76a497a2017-04-12 10:59:39 -07001218 log_test.info(' the self.V_INF1 %s is up now ' %self.V_INF1)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001219 self.igmp_recv_task(self.V_INF1, groups2, join_state1)
A R Karthick76a497a2017-04-12 10:59:39 -07001220 log_test.info('Interface is receiving traffic from multicast groups %s when we nterface up after down ' %groups2)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001221 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001222
Chetan Gaonker586fec32016-04-29 17:33:54 -07001223 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001224 def test_igmp_join_data_received_during_subscriber_link_toggle(self):
Chetan Gaonker586fec32016-04-29 17:33:54 -07001225 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001226 def igmp_join_data_received_during_subscriber_link_toggle():
1227 self.igmp_join_data_received_during_subscriber_link_toggle(df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001228 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001229 reactor.callLater(0, igmp_join_data_received_during_subscriber_link_toggle)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001230 return df
1231
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001232 def igmp_join_data_received_during_channel_distributor_link_toggle(self, df = None):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001233 groups1 = (self.MGROUP1,)
1234 groups2 = (self.MGROUP2,)
1235 groups = groups1 + groups2
1236 ip_src = '1.1.1.1'
1237 self.igmp_send_joins_different_groups_srclist(groups,
1238 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['5.5.5.5', '6.6.6.6']),
1239 intf = self.V_INF1, delay = 2, ip_src = ip_src)
1240 ip_src = self.IP_SRC
1241 dst_mac1 = '01:00:5e:01:02:03'
1242 dst_mac2 = '01:00:5e:02:02:03'
1243 src_ip2 = '5.5.5.5'
1244 src_ip1 = '2.2.2.2'
1245 if df is None:
1246 df = defer.Deferred()
1247 igmpState1 = IGMPTestState(groups = groups1, df = df)
1248 igmpState2 = IGMPTestState(groups = groups2, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001249 IGMPTestState(groups = groups1, df = df)
1250 IGMPTestState(groups = groups2, df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001251 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac1,
1252 src_ip = src_ip1, cb = self.send_mcast_cb, arg = igmpState1)
1253 mcastTraffic2 = McastTraffic(groups2, iface= 'veth3', dst_mac = dst_mac2,
1254 src_ip = src_ip2, cb = self.send_mcast_cb, arg = igmpState2)
1255 mcastTraffic1.start()
1256 mcastTraffic2.start()
1257 join_state1 = IGMPTestState(groups = groups1)
1258 join_state2 = IGMPTestState(groups = groups2)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001259 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
1260 self.igmp_recv_task(self.V_INF1, groups2, join_state2)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001261 mcastTraffic1.stop()
1262 os.system('ifconfig '+'veth2'+' down')
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001263 os.system('ifconfig '+'veth2')
1264 time.sleep(10)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001265 self.igmp_not_recv_task(self.V_INF1, groups2, join_state1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001266 target1 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
1267 assert target1==1, 'EXPECTED FAILURE'
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001268 os.system('ifconfig '+'veth2'+' up')
1269 os.system('ifconfig '+'veth2')
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001270 time.sleep(10)
1271 mcastTraffic1.start()
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001272 self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
1273 self.igmp_recv_task(self.V_INF1, groups2, join_state2)
1274 self.igmp_recv_task(self.V_INF1, groups2, join_state2)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001275 mcastTraffic2.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001276
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001277 ## This test case is failing to receive traffic from multicast data from defferent channel interfaces TO-DO
1278 ###### TO DO scenario #######
1279 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+60)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001280 def test_igmp_join_data_received_during_channel_distributors_link_toggle(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001281 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001282 def igmp_join_data_receiving_during_channel_distributor_link_toggle():
Thangavelu K S790ad332016-12-14 12:54:58 +05301283 self.igmp_join_data_received_during_channel_distributor_link_toggle(df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001284 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001285 reactor.callLater(0, igmp_join_data_receiving_during_channel_distributor_link_toggle)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001286 return df
Chetan Gaonker586fec32016-04-29 17:33:54 -07001287
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001288 def igmp_invalidClassD_IP_join_packet(self, df = None):
Chetan Gaonker586fec32016-04-29 17:33:54 -07001289 groups1 = (self.MGROUP1,)
1290 groups2 = (self.MINVALIDGROUP2,)
1291 groups = groups1 + groups2
1292 ip_src = '1.1.1.1'
1293 self.igmp_send_joins_different_groups_srclist(groups,
1294 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['5.5.5.5']),
1295 intf = self.V_INF1, delay = 2, ip_src = ip_src)
1296 ip_src = self.IP_SRC
1297 dst_mac = '01:00:5e:02:02:03'
1298 src_ip = '5.5.5.5'
1299 if df is None:
1300 df = defer.Deferred()
1301 igmpState1 = IGMPTestState(groups = groups2, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001302 IGMPTestState(groups = groups2, df = df)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001303 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1304 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1305 mcastTraffic1.start()
1306 join_state1 = IGMPTestState(groups = groups2)
1307 target1 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1)
1308 assert target1==1, 'EXPECTED FAILURE'
A R Karthick76a497a2017-04-12 10:59:39 -07001309 log_test.info('Interface is not receiving traffic from multicast groups %s when we sent invalid join packet ' %groups2)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001310 mcastTraffic1.stop()
Chetan Gaonker586fec32016-04-29 17:33:54 -07001311
1312 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001313 def test_igmp_invalid_class_d_ip_for_join_packet(self):
Chetan Gaonker586fec32016-04-29 17:33:54 -07001314 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001315 def igmp_invalidClass_D_IP_join_packet():
Thangavelu K S790ad332016-12-14 12:54:58 +05301316 self.igmp_invalidClassD_IP_join_packet(df = df)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001317 df.callback(0)
Thangavelu K S790ad332016-12-14 12:54:58 +05301318 reactor.callLater(0, igmp_invalidClass_D_IP_join_packet)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001319 return df
1320
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001321 def igmp_invalidClassD_IP_as_srclistIP_join_packet(self, df = None):
Chetan Gaonker586fec32016-04-29 17:33:54 -07001322 groups1 = (self.MGROUP1,)
1323 groups2 = (self.MGROUP2,)
1324 groups = groups1 + groups2
1325 ip_src = '1.1.1.1'
1326 self.igmp_send_joins_different_groups_srclist(groups,
1327 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['239.5.5.5']),
1328 intf = self.V_INF1, delay = 2, ip_src = ip_src)
1329 ip_src = self.IP_SRC
1330 dst_mac = '01:00:5e:02:02:03'
1331 src_ip = '5.5.5.5'
1332 if df is None:
1333 df = defer.Deferred()
1334 igmpState1 = IGMPTestState(groups = groups2, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001335 IGMPTestState(groups = groups2, df = df)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001336 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1337 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1338 mcastTraffic1.start()
1339 join_state1 = IGMPTestState(groups = groups2)
1340 target1 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1)
1341 assert target1==1, 'EXPECTED FAILURE'
A R Karthick76a497a2017-04-12 10:59:39 -07001342 log_test.info('Interface is not receiving traffic from multicast groups %s when we sent invalid join packet ' %groups2)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001343 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001344
Chetan Gaonker586fec32016-04-29 17:33:54 -07001345 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001346 def test_igmp_invalid_class_d_ip_as_srclist_ip_for_join_packet(self):
Chetan Gaonker586fec32016-04-29 17:33:54 -07001347 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001348 def igmp_invalidClassD_IP_as_srclistIP_join_packet():
1349 self.igmp_invalidClassD_IP_as_srclistIP_join_packet(df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001350 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001351 reactor.callLater(0, igmp_invalidClassD_IP_as_srclistIP_join_packet)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001352 return df
Chetan Gaonkerf72ca402016-05-02 16:29:32 -07001353
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001354 def igmp_general_query_recv_packet(self, df = None):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001355 groups1 = (self.MGROUP1,)
1356 groups2 = (self.MGROUP2,)
1357 groups = groups1 + groups2
1358 ip_src = '1.1.1.1'
1359 self.igmp_send_joins_different_groups_srclist(groups,
1360 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['5.5.5.5']),
1361 intf = self.V_INF1, delay = 2, ip_src = ip_src)
1362 ip_src = self.IP_SRC
1363 dst_mac = '01:00:5e:02:02:03'
1364 src_ip = '5.5.5.5'
1365 if df is None:
1366 df = defer.Deferred()
1367 igmpState1 = IGMPTestState(groups = groups2, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001368 IGMPTestState(groups = groups2, df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001369 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1370 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1371 mcastTraffic1.start()
1372 join_state1 = IGMPTestState(groups = groups2)
A R Karthick76a497a2017-04-12 10:59:39 -07001373 log_test.info('Started delay to verify multicast data taraffic for group %s is received or not for 180 sec ' %groups2)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001374 time.sleep(100)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001375 self.igmp_recv_task(self.V_INF1, groups2, join_state1)
A R Karthick76a497a2017-04-12 10:59:39 -07001376 log_test.info('Verified that multicast data for group %s is received after 100 sec ' %groups2)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001377 time.sleep(50)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001378 self.igmp_recv_task(self.V_INF1, groups2, join_state1)
A R Karthick76a497a2017-04-12 10:59:39 -07001379 log_test.info('Verified that multicast data for group %s is received after 150 sec ' %groups2)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001380 time.sleep(30)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001381 self.igmp_recv_task(self.V_INF1, groups2, join_state1)
A R Karthick76a497a2017-04-12 10:59:39 -07001382 log_test.info('Verified that multicast data for group %s is received after 180 sec ' %groups2)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001383 time.sleep(10)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001384 self.igmp_recv_task(self.V_INF1, groups2, join_state1)
A R Karthick76a497a2017-04-12 10:59:39 -07001385 log_test.info('Verified that multicast data for group %s is received after 190 sec ' %groups2)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001386 target3 = mcastTraffic1.isRecvStopped()
1387 assert target3==False, 'EXPECTED FAILURE'
A R Karthick76a497a2017-04-12 10:59:39 -07001388 log_test.info('Verified that multicast data for a group %s is still transmitting from a data interface' %groups2)
1389 log_test.info('Now checking join interface is receiving a multicast data for group %s after 190 sec' %groups2)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001390 target1 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1)
1391 assert target1==1, 'EXPECTED FAILURE'
A R Karthick76a497a2017-04-12 10:59:39 -07001392 log_test.info('Interface is not receiving multicast data for group %s' %groups2)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001393 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001394
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001395 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+250)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001396 def test_igmp_general_query_received_traffic(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001397 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001398 def igmp_general_query_recv_packet():
1399 self.igmp_general_query_recv_packet(df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001400 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001401 reactor.callLater(0, igmp_general_query_recv_packet)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001402 return df
A.R Karthick95d044e2016-06-10 18:44:36 -07001403
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001404 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+100)
1405 def test_igmp_query_received_on_joining_interface(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001406 groups = ['224.0.1.10', '225.0.0.10']
1407 leave_groups = ['224.0.1.10']
1408 df = defer.Deferred()
1409 igmpState = IGMPTestState(groups = groups, df = df)
1410 igmpStateRecv = IGMPTestState(groups = groups, df = df)
1411 igmpStateList = (igmpState, igmpStateRecv)
A.R Karthick95d044e2016-06-10 18:44:36 -07001412 mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb,
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001413 arg = igmpState)
1414 self.df = df
1415 self.mcastTraffic = mcastTraffic
1416 self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP)
A.R Karthick95d044e2016-06-10 18:44:36 -07001417
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001418 def igmp_srp_task(stateList):
1419 igmpSendState, igmpRecvState = stateList
1420 if not mcastTraffic.isRecvStopped():
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001421 self.igmp_recv(igmpRecvState)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001422 reactor.callLater(0, igmp_srp_task, stateList)
1423 else:
1424 self.mcastTraffic.stop()
1425 self.recv_socket.close()
1426 self.igmp_verify_leave(stateList, leave_groups)
1427 self.df.callback(0)
1428
A R Karthick76a497a2017-04-12 10:59:39 -07001429 log_test.info('Sending join packet and expect to receive on general query packet after 60 sec for multicast %s ' %groups)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001430 self.send_igmp_join_recvQuery(groups)
A R Karthick76a497a2017-04-12 10:59:39 -07001431 log_test.info('Received a general query packet for multicast %s group on joing interface and sending traffic' %groups)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001432 mcastTraffic.start()
1433 self.test_timer = reactor.callLater(self.MCAST_TRAFFIC_TIMEOUT, self.mcast_traffic_timer)
1434 reactor.callLater(0, igmp_srp_task, igmpStateList)
1435 return df
1436
1437 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+190)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001438 def test_igmp_for_periodic_query_received_on_joining_interface(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001439 groups = ['224.0.1.10', '225.0.0.10']
1440 leave_groups = ['224.0.1.10']
1441 df = defer.Deferred()
1442 igmpState = IGMPTestState(groups = groups, df = df)
A.R Karthick95d044e2016-06-10 18:44:36 -07001443 mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb,
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001444 arg = igmpState)
1445 self.df = df
1446 self.mcastTraffic = mcastTraffic
1447 self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP)
A.R Karthick95d044e2016-06-10 18:44:36 -07001448
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001449 def igmp_srp_task(stateList):
1450 igmpSendState, igmpRecvState = stateList
1451 if not mcastTraffic.isRecvStopped():
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001452 self.igmp_recv(igmpRecvState)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001453 reactor.callLater(0, igmp_srp_task, stateList)
1454 else:
1455 self.mcastTraffic.stop()
1456 self.recv_socket.close()
1457 self.igmp_verify_leave(stateList, leave_groups)
1458 self.df.callback(0)
1459
1460 self.send_igmp_join_recvQuery(groups,3)
1461 return df
1462
1463 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+190)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001464 def test_igmp_for_periodic_query_received_and_checking_entry_deleted(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001465 groups = ['224.0.1.10', '225.0.0.10']
1466 leave_groups = ['224.0.1.10']
1467 df = defer.Deferred()
1468 igmpState = IGMPTestState(groups = groups, df = df)
1469 igmpStateRecv = IGMPTestState(groups = groups, df = df)
1470 igmpStateList = (igmpState, igmpStateRecv)
A.R Karthick95d044e2016-06-10 18:44:36 -07001471 mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb,
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001472 arg = igmpState)
1473 self.df = df
1474 self.mcastTraffic = mcastTraffic
1475 self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP)
A.R Karthick95d044e2016-06-10 18:44:36 -07001476
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001477 def igmp_srp_task(stateList):
1478 igmpSendState, igmpRecvState = stateList
1479 if not mcastTraffic.isRecvStopped():
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001480 self.igmp_recv(igmpRecvState)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001481 reactor.callLater(0, igmp_srp_task, stateList)
1482 else:
1483 self.mcastTraffic.stop()
1484 self.recv_socket.close()
1485 self.igmp_verify_leave(stateList, leave_groups)
1486 self.df.callback(0)
1487
1488 self.send_igmp_join_recvQuery(groups,3)
A R Karthick76a497a2017-04-12 10:59:39 -07001489 log_test.info('Received periodic general query packets for multicast %s, now checking entry is deleted from tabel by sending traffic for that group' %groups)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001490 mcastTraffic.start()
1491 self.test_timer = reactor.callLater(self.MCAST_TRAFFIC_TIMEOUT, self.mcast_traffic_timer)
1492 reactor.callLater(0, igmp_srp_task, igmpStateList)
1493 return df
1494
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001495 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+190)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001496 def test_igmp_member_query_interval_and_expiry_for_rejoining_interface(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001497 groups = ['224.0.1.10', '225.0.0.10']
1498 leave_groups = ['224.0.1.10']
1499 df = defer.Deferred()
1500 igmpState = IGMPTestState(groups = groups, df = df)
1501 igmpStateRecv = IGMPTestState(groups = groups, df = df)
1502 igmpStateList = (igmpState, igmpStateRecv)
A.R Karthick95d044e2016-06-10 18:44:36 -07001503 mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb,
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001504 arg = igmpState)
1505 self.df = df
1506 self.mcastTraffic = mcastTraffic
1507 self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP)
A.R Karthick95d044e2016-06-10 18:44:36 -07001508
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001509 def igmp_srp_task(stateList):
1510 igmpSendState, igmpRecvState = stateList
1511 if not mcastTraffic.isRecvStopped():
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001512 self.igmp_recv(igmpRecvState)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001513 reactor.callLater(0, igmp_srp_task, stateList)
1514 else:
1515 self.mcastTraffic.stop()
1516 self.recv_socket.close()
1517 self.igmp_verify_leave(stateList, leave_groups)
1518 self.df.callback(0)
1519
1520 self.send_igmp_join_recvQuery(groups,3)
A R Karthick76a497a2017-04-12 10:59:39 -07001521 log_test.info('Received periodic general query packets for multicast %s, now sending join packet again and verifying traffic for that group is received or not on joining interface' %groups)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001522 self.send_igmp_join(groups)
1523 mcastTraffic.start()
1524 self.test_timer = reactor.callLater(self.MCAST_TRAFFIC_TIMEOUT, self.mcast_traffic_timer)
1525 reactor.callLater(0, igmp_srp_task, igmpStateList)
1526 return df
1527
1528 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+50)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001529 def test_igmp_leave_received_group_and_source_specific_query(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001530 groups = ['224.0.1.10', '225.0.0.10']
1531 leave_groups = ['224.0.1.10']
1532 df = defer.Deferred()
1533 igmpState = IGMPTestState(groups = groups, df = df)
A.R Karthick95d044e2016-06-10 18:44:36 -07001534 mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb,
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001535 arg = igmpState)
1536 self.df = df
1537 self.mcastTraffic = mcastTraffic
1538 self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP)
A.R Karthick95d044e2016-06-10 18:44:36 -07001539
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001540 def igmp_srp_task(stateList):
1541 igmpSendState, igmpRecvState = stateList
1542 if not mcastTraffic.isRecvStopped():
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001543 self.igmp_recv(igmpRecvState)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001544 reactor.callLater(0, igmp_srp_task, stateList)
1545 else:
1546 self.mcastTraffic.stop()
1547 self.recv_socket.close()
1548 self.igmp_verify_leave(stateList, leave_groups)
1549 self.df.callback(0)
1550
1551 self.send_igmp_join(groups)
1552 self.send_igmp_leave_listening_group_specific_query(leave_groups, delay = 3)
1553 return df
1554
1555 def igmp_change_to_exclude_src_list_check_for_group_source_specific_query(self, df = None):
1556 groups1 = (self.MGROUP1,)
1557 groups2 = (self.MGROUP2,)
1558 self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
1559 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
1560 intf = self.V_INF1, delay = 2)
1561 dst_mac = '01:00:5e:01:02:03'
1562 src_ip = '2.2.2.2'
1563 if df is None:
1564 df = defer.Deferred()
1565 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001566 IGMPTestState(groups = groups1, df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001567 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
1568 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1569 mcastTraffic1.start()
1570 join_state1 = IGMPTestState(groups = groups1)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001571 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001572 self.send_igmp_leave_listening_group_specific_query(groups = groups1, src_list = ['2.2.2.2'], iface = self.V_INF1, delay =2)
1573 time.sleep(10)
1574 target2 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
1575 assert target2 == 1, 'EXPECTED FAILURE'
A R Karthick76a497a2017-04-12 10:59:39 -07001576 log_test.info('Interface is not receiving traffic from multicast groups %s after sending CHANGE_TO_EXCLUDE' %groups2)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001577 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001578
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001579 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+60)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001580 def test_igmp_change_to_exclude_src_list_and_check_for_group_source_specific_query(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001581 df = defer.Deferred()
1582 def igmp_change_to_exclude_src_list_check_for_group_source_specific_query():
1583 self.igmp_change_to_exclude_src_list_check_for_group_source_specific_query(df = df)
1584 df.callback(0)
1585 reactor.callLater(0, igmp_change_to_exclude_src_list_check_for_group_source_specific_query)
1586 return df
1587
1588 def igmp_change_to_include_src_list_check_for_general_query(self, df = None):
1589 groups1 = (self.MGROUP1,)
1590 groups2 = (self.MGROUP2,)
1591 self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4'],
1592 iface = self.V_INF1, delay = 2)
1593 dst_mac = '01:00:5e:01:02:03'
1594 src_ip = '2.2.2.2'
1595 if df is None:
1596 df = defer.Deferred()
1597 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001598 IGMPTestState(groups = groups1, df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001599 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
1600 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1601 mcastTraffic1.start()
1602 join_state1 = IGMPTestState(groups = groups1)
1603 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
1604 assert target1 == 1, 'EXPECTED FAILURE'
A R Karthick76a497a2017-04-12 10:59:39 -07001605 log_test.info('Interface is not receiving traffic from multicast groups %s' %groups1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001606 self.igmp_send_joins_different_groups_srclist_wait_query_packets(groups1 + groups2,
1607 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['6.6.6.6', '5.5.5.5']),
1608 intf = self.V_INF1, delay = 2,query_group1 = 'group1', query_group2 = None)
1609 time.sleep(10)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001610 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
A R Karthick76a497a2017-04-12 10:59:39 -07001611 log_test.info('Interface is receiving traffic from multicast groups %s after send Change to include message' %groups1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001612 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001613
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001614 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+80)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001615 def test_igmp_change_to_include_src_list_and_check_for_general_query(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001616 df = defer.Deferred()
1617 def igmp_change_to_include_src_list_check_for_general_query():
1618 self.igmp_change_to_include_src_list_check_for_general_query(df = df)
1619 df.callback(0)
1620 reactor.callLater(0, igmp_change_to_include_src_list_check_for_general_query)
1621 return df
1622
1623 def igmp_allow_new_src_list_check_for_general_query(self, df = None):
1624 groups1 = (self.MGROUP1,)
1625 groups2 = (self.MGROUP2,)
1626 self.igmp_send_joins_different_groups_srclist(groups1+groups2,
1627 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
1628 intf = self.V_INF1, delay = 2)
1629 dst_mac = '01:00:5e:01:02:03'
1630 src_ip = '6.6.6.6'
1631 if df is None:
1632 df = defer.Deferred()
1633 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001634 IGMPTestState(groups = groups1, df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001635 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
1636 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1637 mcastTraffic1.start()
1638 join_state1 = IGMPTestState(groups = groups1)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001639 self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
A R Karthick76a497a2017-04-12 10:59:39 -07001640 log_test.info('Interface is not receiving traffic from multicast groups %s' %groups1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001641 self.igmp_send_joins_different_groups_srclist_wait_query_packets(groups1 + groups2, (['2.2.2.2', '6.6.6.6', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
1642 intf = self.V_INF1, delay = 2, query_group1 = 'group1', query_group2 = None)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001643 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
A R Karthick76a497a2017-04-12 10:59:39 -07001644 log_test.info('Interface is receiving traffic from multicast groups %s after sending join with new source list' %groups1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001645 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001646
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001647 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+80)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001648 def test_igmp_allow_new_src_list_and_check_for_general_query(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001649 df = defer.Deferred()
1650 def igmp_allow_new_src_list_check_for_general_query():
1651 self.igmp_allow_new_src_list_check_for_general_query(df = df)
1652 df.callback(0)
1653 reactor.callLater(0, igmp_allow_new_src_list_check_for_general_query)
1654 return df
1655
1656 def igmp_block_old_src_list_check_for_group_source_specific_query(self, df = None):
1657 groups1 = (self.MGROUP1,)
1658 groups2 = (self.MGROUP2,)
1659 groups = groups1 + groups2
1660 self.igmp_send_joins_different_groups_srclist(groups,
1661 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
1662 intf = self.V_INF1, delay = 2)
1663 dst_mac = '01:00:5e:02:02:03'
1664 src_ip = '5.5.5.5'
1665 if df is None:
1666 df = defer.Deferred()
1667 igmpState1 = IGMPTestState(groups = groups2, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001668 IGMPTestState(groups = groups2, df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001669 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1670 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1671 mcastTraffic1.start()
1672 join_state1 = IGMPTestState(groups = groups2)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001673 self.igmp_recv_task(self.V_INF1, groups2, join_state1)
A R Karthick76a497a2017-04-12 10:59:39 -07001674 log_test.info('Interface is receiving traffic from multicast groups %s' %groups2)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001675 self.igmp_send_joins_different_groups_srclist_wait_query_packets(groups,
1676 (['6.6.6.6', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '7.7.7.7']),
1677 intf = self.V_INF1, delay = 2, query_group1 = 'group1', query_group2 = None)
1678 target2 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1)
1679 assert target2 == 1, 'EXPECTED FAILURE'
A R Karthick76a497a2017-04-12 10:59:39 -07001680 log_test.info('Interface is not receiving traffic from multicast groups %s after sending join with block old source list' %groups2)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001681 mcastTraffic1.stop()
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001682
1683 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+90)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001684 def test_igmp_block_old_src_list_and_check_for_group_source_specific_query(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001685 df = defer.Deferred()
1686 def igmp_block_old_src_list_check_for_group_source_specific_query():
1687 self.igmp_block_old_src_list_check_for_group_source_specific_query(df = df)
1688 df.callback(0)
1689 reactor.callLater(0, igmp_block_old_src_list_check_for_group_source_specific_query)
1690 return df
1691
1692 def igmp_include_to_allow_src_list_check_for_general_query(self, df = None):
1693 groups1 = (self.MGROUP1,)
1694 groups2 = (self.MGROUP2,)
1695 self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
1696 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
1697 intf = self.V_INF1, delay = 2)
1698 dst_mac = '01:00:5e:01:02:03'
1699 src_ip = '2.2.2.2'
1700 if df is None:
1701 df = defer.Deferred()
1702 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001703 IGMPTestState(groups = groups1, df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001704 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
1705 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1706 mcastTraffic1.start()
1707 join_state1 = IGMPTestState(groups = groups1)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001708 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001709 self.igmp_send_joins_different_groups_srclist_wait_query_packets(groups1 + groups2,(['2.2.2.2', '3.3.3.3', '4.4.4.4', '6.6.6.6'], ['2.2.2.2', '5.5.5.5']), intf = self.V_INF1, delay = 2, query_group1 = 'group1', query_group2 = None)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001710 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001711 mcastTraffic1.stop()
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001712
1713 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+40)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001714 def test_igmp_include_to_allow_src_list_and_check_for_general_query(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001715 df = defer.Deferred()
1716 def igmp_include_to_allow_src_list_check_for_general_query():
1717 self.igmp_include_to_allow_src_list_check_for_general_query(df = df)
1718 df.callback(0)
1719 reactor.callLater(0, igmp_include_to_allow_src_list_check_for_general_query)
1720 return df
1721
1722 def igmp_include_to_block_src_list_check_for_group_source_specific_query(self, df = None):
1723 groups1 = (self.MGROUP1,)
1724 groups2 = (self.MGROUP2,)
1725 self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
1726 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
1727 intf = self.V_INF1, delay = 2)
1728 dst_mac = '01:00:5e:01:02:03'
1729 src_ip = '2.2.2.2'
1730 if df is None:
1731 df = defer.Deferred()
1732 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001733 IGMPTestState(groups = groups1, df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001734 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
1735 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1736 mcastTraffic1.start()
1737 join_state1 = IGMPTestState(groups = groups1)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001738 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001739 self.send_igmp_leave_listening_group_specific_query(groups = groups1, src_list = ['6.6.6.6','7.7.7.7'],
1740 iface = self.V_INF1, delay = 2)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001741 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001742 mcastTraffic1.stop()
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001743
1744 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+40)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001745 def test_igmp_include_to_block_src_list_and_check_for_group_source_specific_query(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001746 df = defer.Deferred()
1747 def igmp_include_to_block_src_list_check_for_group_source_specific_query():
1748 self.igmp_include_to_block_src_list_check_for_group_source_specific_query(df = df)
1749 df.callback(0)
1750 reactor.callLater(0, igmp_include_to_block_src_list_check_for_group_source_specific_query)
1751 return df
1752
1753 def igmp_exclude_to_allow_src_list_check_for_general_query(self, df = None):
1754 groups1 = (self.MGROUP1,)
1755 groups2 = (self.MGROUP2,)
1756 self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4'],
1757 iface = self.V_INF1, delay = 2)
A.R Karthick95d044e2016-06-10 18:44:36 -07001758
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001759 dst_mac = '01:00:5e:01:02:03'
1760 src_ip = '2.2.2.2'
1761 if df is None:
1762 df = defer.Deferred()
1763 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001764 IGMPTestState(groups = groups1, df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001765 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
1766 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1767 mcastTraffic1.start()
1768 join_state1 = IGMPTestState(groups = groups1)
1769 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
1770 assert target1 == 1, 'EXPECTED FAILURE'
A R Karthick76a497a2017-04-12 10:59:39 -07001771 log_test.info('Interface is not receiving traffic from multicast groups %s' %groups1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001772 self.igmp_send_joins_different_groups_srclist_wait_query_packets(groups1 + groups2,
1773 (['6.6.6.6', '7.7.7.7', '8.8.8.8'], ['6.6.6.6', '5.5.5.5']), intf = self.V_INF1, delay = 2, query_group1 = 'group1', query_group2 = None)
1774 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
1775 assert target1 == 1, 'EXPECTED FAILURE'
A R Karthick76a497a2017-04-12 10:59:39 -07001776 log_test.info('Interface is not receiving traffic from multicast groups %s' %groups1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001777 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001778
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001779 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+90)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001780 def test_igmp_exclude_to_allow_src_list_and_check_for_general_query(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001781 df = defer.Deferred()
1782 def igmp_exclude_to_allow_src_list_check_for_general_query():
1783 self.igmp_exclude_to_allow_src_list_check_for_general_query(df = df)
1784 df.callback(0)
1785 reactor.callLater(0, igmp_exclude_to_allow_src_list_check_for_general_query)
1786 return df
1787
1788 def igmp_exclude_to_block_src_list_check_for_group_source_specific_query(self, df = None):
1789 groups1 = (self.MGROUP1,)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001790 self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4'],
1791 iface = self.V_INF1, delay = 2)
A.R Karthick95d044e2016-06-10 18:44:36 -07001792
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001793 dst_mac = '01:00:5e:01:02:03'
1794 src_ip = '2.2.2.2'
1795 if df is None:
1796 df = defer.Deferred()
1797 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001798 IGMPTestState(groups = groups1, df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001799 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
1800 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1801 mcastTraffic1.start()
1802 join_state1 = IGMPTestState(groups = groups1)
1803 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
1804 assert target1 == 1, 'EXPECTED FAILURE'
A R Karthick76a497a2017-04-12 10:59:39 -07001805 log_test.info('Interface is not receiving traffic from multicast groups %s' %groups1)
A.R Karthick95d044e2016-06-10 18:44:36 -07001806 self.send_igmp_leave_listening_group_specific_query(groups = groups1,
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001807 src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4', '5.5.5.5', '7.7.7.7'],
1808 iface = self.V_INF1, delay = 2)
1809 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
1810 assert target1 == 1, 'EXPECTED FAILURE'
A R Karthick76a497a2017-04-12 10:59:39 -07001811 log_test.info('Interface is not receiving traffic from multicast groups %s' %groups1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001812 mcastTraffic1.stop()
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001813
1814 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+40)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001815 def test_igmp_exclude_to_block_src_list_and_check_for_group_source_specific_query(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001816 df = defer.Deferred()
1817 def igmp_exclude_to_block_src_list_check_for_group_source_specific_query():
1818 self.igmp_exclude_to_block_src_list_check_for_group_source_specific_query(df = df)
1819 df.callback(0)
1820 reactor.callLater(0, igmp_exclude_to_block_src_list_check_for_group_source_specific_query)
1821 return df
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001822
1823 def iptomac(self, mcast_ip):
1824 mcast_mac = '01:00:5e:'
1825 octets = mcast_ip.split('.')
1826 second_oct = int(octets[1]) & 127
1827 third_oct = int(octets[2])
1828 fourth_oct = int(octets[3])
1829 mcast_mac = mcast_mac + format(second_oct,'02x') + ':' + format(third_oct, '02x') + ':' + format(fourth_oct, '02x')
1830 return mcast_mac
1831
1832 def send_multicast_data_traffic(self, group, intf= 'veth2',source = '1.2.3.4'):
1833 dst_mac = self.iptomac(group)
1834 eth = Ether(dst= dst_mac)
1835 ip = IP(dst=group,src=source)
1836 data = repr(monotonic.monotonic())
1837 sendp(eth/ip/data,count=20, iface = intf)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001838
1839 def verify_igmp_data_traffic(self, group, intf='veth0', source='1.2.3.4' ):
A R Karthick76a497a2017-04-12 10:59:39 -07001840 log_test.info('verifying multicast traffic for group %s from source %s'%(group,source))
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001841 self.success = False
1842 def recv_task():
1843 def igmp_recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -07001844 #log_test.info('received multicast data packet is %s'%pkt.show())
1845 log_test.info('multicast data received for group %s from source %s'%(group,source))
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001846 self.success = True
1847 sniff(prn = igmp_recv_cb,lfilter = lambda p: IP in p and p[IP].dst == group and p[IP].src == source, count=1,timeout = 2, iface='veth0')
1848 t = threading.Thread(target = recv_task)
1849 t.start()
1850 self.send_multicast_data_traffic(group,source=source)
1851 t.join()
1852 return self.success
1853
1854 def test_igmp_include_exclude_modes(self):
1855 groups = ['224.2.3.4','230.5.6.7']
1856 src_list = ['2.2.2.2','3.3.3.3']
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001857 self.onos_ssm_table_load(groups, src_list=src_list)
1858 self.send_igmp_join(groups = [groups[0]], src_list = src_list,record_type = IGMP_V3_GR_TYPE_INCLUDE,
1859 iface = self.V_INF1, delay = 2)
1860 self.send_igmp_join(groups = [groups[1]], src_list = src_list,record_type = IGMP_V3_GR_TYPE_EXCLUDE,
1861 iface = self.V_INF1, delay = 2)
1862 status = self.verify_igmp_data_traffic(groups[0],intf=self.V_INF1,source=src_list[0])
1863 assert_equal(status,True)
1864 status = self.verify_igmp_data_traffic(groups[1],intf = self.V_INF1,source= src_list[1])
1865 assert_equal(status,False)
1866
1867 def test_igmp_allow_new_source_mode(self):
1868 group = ['224.8.9.3']
1869 src_list = ['2.2.2.2','3.3.3.3']
1870 #dst_mac = self.iptomac(group[0])
1871 self.onos_ssm_table_load(group, src_list)
1872 self.send_igmp_join(groups = group, src_list = src_list[0],record_type = IGMP_V3_GR_TYPE_INCLUDE,
1873 iface = self.V_INF1, delay = 1)
1874 status = self.verify_igmp_data_traffic(group[0], intf=self.V_INF1,source = src_list[0])
1875 assert_equal(status,True) # expecting igmp data traffic from source src_list[0]
1876 self.send_igmp_join(groups = group, src_list = src_list[1],record_type = IGMP_V3_GR_TYPE_ALLOW_NEW,
1877 iface = self.V_INF1, delay = 1)
1878 for src in src_list:
1879 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1, source=src)
1880 assert_equal(status,True) # expecting igmp data traffic from both sources
1881
1882
1883 def test_igmp_include_to_exclude_mode_change(self):
1884 group = ['224.2.3.4']
1885 src_list = ['2.2.2.2','3.3.3.3']
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001886 self.onos_ssm_table_load(group, src_list)
1887 self.send_igmp_join(groups = group, src_list = src_list[0],record_type = IGMP_V3_GR_TYPE_INCLUDE,
1888 iface = self.V_INF1, delay = 1)
1889 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source= src_list[0])
1890 assert_equal(status,True) # expecting igmp data traffic from source src_list[0]
1891 self.send_igmp_join(groups = group, src_list = src_list[1],record_type = IGMP_V3_GR_TYPE_EXCLUDE,
1892 iface = self.V_INF1, delay = 1)
1893 for src in src_list:
1894 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source= src)
1895 assert_equal(status,False) # expecting igmp data traffic from both sources
1896
1897 def test_igmp_exclude_to_include_mode_change(self):
1898 group = ['224.2.3.4']
1899 src = ['2.2.2.2']
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001900 self.onos_ssm_table_load(group, src)
1901 self.send_igmp_join(groups = group, src_list = src,record_type = IGMP_V3_GR_TYPE_EXCLUDE,
1902 iface = self.V_INF1, delay = 1)
1903 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source=src[0])
1904 assert_equal(status,False) # not expecting igmp data traffic from source src_list[0]
1905 self.send_igmp_join(groups = group, src_list = src,record_type = IGMP_V3_GR_TYPE_INCLUDE,
1906 iface = self.V_INF1, delay = 1)
1907 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source = src[0])
1908 assert_equal(status,True) # expecting igmp data traffic from both sources
1909
1910 #this test case wotks properly if the snooping device(ONOS) have multicast router connected.
1911 def test_igmp_to_include_mode_with_null_source(self):
1912 groups = ['224.2.3.4','230.7.9.8']
1913 src = ['192.168.12.34']
1914 dst_mac = []
1915 dst_mac.append(self.iptomac(groups[0]))
1916 dst_mac.append(self.iptomac(groups[1]))
1917 self.onos_ssm_table_load(groups, src)
1918 self.send_igmp_join(groups = groups, src_list = src,record_type = IGMP_V3_GR_TYPE_INCLUDE,
1919 iface = self.V_INF1, delay = 1)
1920 for grp in groups:
1921 status = self.verify_igmp_data_traffic(grp,intf=self.V_INF1,source= src[0])
1922 assert_equal(status,True) # not expecting igmp data traffic from source src_list[0]
1923 #sending leave packet for group groups[1]
1924 self.send_igmp_join(groups = [groups[1]], src_list = [],record_type = IGMP_V3_GR_TYPE_CHANGE_TO_INCLUDE,
1925 iface = self.V_INF1, delay = 1)
1926 for grp in groups:
1927 status = self.verify_igmp_data_traffic(grp,intf=self.V_INF1,source= src[0])
1928 if grp is groups[0]:
1929 assert_equal(status,True) # expecting igmp data traffic to group groups[0]
1930 else:
1931 assert_equal(status,False) # not expecting igmp data traffic to group groups[1]
1932
1933 def test_igmp_to_include_mode(self):
1934 group = ['229.9.3.6']
1935 src_list = ['192.168.12.34','192.18.1.34']
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001936 self.onos_ssm_table_load(group, src_list)
1937 self.send_igmp_join(groups = group, src_list = [src_list[0]],record_type = IGMP_V3_GR_TYPE_INCLUDE,
1938 iface = self.V_INF1, delay = 1)
1939 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source=src_list[0])
1940 assert_equal(status,True) # not expecting igmp data traffic from source src_list[0]
1941 self.send_igmp_join(groups = group, src_list = src_list,record_type = IGMP_V3_GR_TYPE_CHANGE_TO_INCLUDE,
1942 iface = self.V_INF1, delay = 1)
1943 for src in src_list:
1944 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source= src)
1945 assert_equal(status,True) # expecting igmp data traffic to group groups[0]
1946
1947 #this test case passed only if mulitcast router connected to ONOS.
1948 def test_igmp_blocking_old_source_mode(self):
1949 group = ['224.2.3.4']
1950 src_list = ['2.2.2.2','3.3.3.3']
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001951 self.onos_ssm_table_load(group, src_list)
1952 self.send_igmp_join(groups = group, src_list = src_list,record_type = IGMP_V3_GR_TYPE_INCLUDE,
1953 iface = self.V_INF1, delay = 1)
1954 for src in src_list:
1955 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1, source=src)
1956 assert_equal(status,True) # expecting igmp data traffic from source src_list[0]
1957 self.send_igmp_join(groups = group, src_list = [src_list[1]],record_type = IGMP_V3_GR_TYPE_BLOCK_OLD,
1958 iface = self.V_INF1, delay = 1)
1959 for src in src_list:
1960 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1, source=src)
1961 if src is src_list[0]:
1962 assert_equal(status,True) # expecting igmp data traffic from source src_list[0]
1963 else:
1964 assert_equal(status,False) # not expecting igmp data traffic from source src_list[1]
1965
1966 def test_igmp_multiple_joins_and_data_verification_with_100_groups(self):
1967 groups = []
1968 sources = []
1969 count = 1
1970 mcastips = self.mcast_ip_range(start_ip = '226.0.0.1',end_ip = '226.0.5.254')
1971 sourceips = self.source_ip_range(start_ip = '10.10.0.1',end_ip = '10.10.5.254')
1972 while count<=100:
1973 group = random.choice(mcastips)
1974 source = random.choice(sourceips)
1975 if group in groups:
1976 pass
1977 else:
A R Karthick76a497a2017-04-12 10:59:39 -07001978 log_test.info('group and source are %s and %s'%(group,source))
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001979 groups.append(group)
1980 sources.append(source)
1981 count += 1
1982 self.onos_ssm_table_load(groups,src_list=sources,flag=True)
1983 for i in range(100):
1984 self.send_igmp_join(groups = [groups[i]], src_list = [sources[i]],record_type = IGMP_V3_GR_TYPE_INCLUDE,
1985 iface = self.V_INF1)
1986 status = self.verify_igmp_data_traffic(groups[i],intf=self.V_INF1,source=sources[i])
1987 assert_equal(status, True)
A R Karthick76a497a2017-04-12 10:59:39 -07001988 log_test.info('data received for group %s from source %s'%(groups[i],sources[i]))
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001989
1990 def test_igmp_multiple_joins_with_data_verification_and_leaving_100_groups(self):
1991 groups = []
1992 sources = []
1993 count = 1
1994 mcastips = self.mcast_ip_range(start_ip = '226.0.0.1',end_ip = '226.0.5.254')
1995 sourceips = self.source_ip_range(start_ip = '10.10.0.1',end_ip = '10.10.5.254')
1996 while count<=100:
1997 group = random.choice(mcastips)
1998 source = random.choice(sourceips)
1999 if group in groups:
2000 pass
2001 else:
A R Karthick76a497a2017-04-12 10:59:39 -07002002 log_test.info('group and source are %s and %s'%(group,source))
ChetanGaonkera7e2b412016-09-01 23:19:07 -07002003 groups.append(group)
2004 sources.append(source)
2005 count += 1
2006 self.onos_ssm_table_load(groups,src_list=sources,flag=True)
2007 for i in range(100):
2008 self.send_igmp_join(groups = [groups[i]], src_list = [sources[i]],record_type = IGMP_V3_GR_TYPE_INCLUDE,
2009 iface = self.V_INF1)
2010 status = self.verify_igmp_data_traffic(groups[i],intf=self.V_INF1,source=sources[i])
2011 assert_equal(status, True)
A R Karthick76a497a2017-04-12 10:59:39 -07002012 log_test.info('data received for group %s from source %s'%(groups[i],sources[i]))
ChetanGaonkera7e2b412016-09-01 23:19:07 -07002013 self.send_igmp_join(groups = [groups[i]], src_list = [sources[i]],record_type = IGMP_V3_GR_TYPE_CHANGE_TO_EXCLUDE,
2014 iface = self.V_INF1, delay = 1)
2015 status = self.verify_igmp_data_traffic(groups[i],intf=self.V_INF1,source=sources[i])
2016 assert_equal(status, False)
A R Karthick76a497a2017-04-12 10:59:39 -07002017 log_test.info("data not received for group %s from source %s after changing group mode to 'TO-EXCLUDE' mode"%(groups[i],sources[i]))
ChetanGaonkera7e2b412016-09-01 23:19:07 -07002018
2019 def test_igmp_group_source_for_only_config_with_1000_entries(self):
2020 groups = []
2021 sources = []
2022 count = 1
2023 mcastips = self.mcast_ip_range(start_ip = '229.0.0.1',end_ip = '229.0.50.254')
2024 sourceips = self.source_ip_range(start_ip = '10.10.0.1',end_ip = '10.10.50.254')
2025 while count<=1000:
2026 group = random.choice(mcastips)
2027 source = random.choice(sourceips)
2028 if group in groups:
2029 pass
2030 else:
A R Karthick76a497a2017-04-12 10:59:39 -07002031 log_test.info('group and source are %s and %s'%(group,source))
ChetanGaonkera7e2b412016-09-01 23:19:07 -07002032 groups.append(group)
2033 sources.append(source)
2034 count += 1
2035 self.onos_ssm_table_load(groups,src_list=sources,flag=True)
2036
2037 def test_igmp_from_exclude_to_include_mode_with_100_groups(self):
2038 groups = []
2039 sources = []
2040 count = 1
2041 mcastips = self.mcast_ip_range(start_ip = '229.0.0.1',end_ip = '229.0.10.254')
2042 sourceips = self.source_ip_range(start_ip = '10.10.0.1',end_ip = '10.10.10.254')
2043 while count<=100:
2044 group = random.choice(mcastips)
2045 source = random.choice(sourceips)
2046 if group in groups:
2047 pass
2048 else:
A R Karthick76a497a2017-04-12 10:59:39 -07002049 log_test.info('group and source are %s and %s'%(group,source))
ChetanGaonkera7e2b412016-09-01 23:19:07 -07002050 groups.append(group)
2051 sources.append(source)
2052 count += 1
2053 self.onos_ssm_table_load(groups,src_list=sources,flag=True)
2054 for i in range(100):
2055 self.send_igmp_join(groups = [groups[i]], src_list = [sources[i]],record_type = IGMP_V3_GR_TYPE_EXCLUDE,
2056 iface = self.V_INF1)
2057 status = self.verify_igmp_data_traffic(groups[i],intf=self.V_INF1,source=sources[i])
2058 assert_equal(status, False)
A R Karthick76a497a2017-04-12 10:59:39 -07002059 log_test.info('data not received for group %s from source %s as expected'%(groups[i],sources[i]))
ChetanGaonkera7e2b412016-09-01 23:19:07 -07002060 self.send_igmp_join(groups = [groups[i]], src_list = [sources[i]],record_type = IGMP_V3_GR_TYPE_INCLUDE,
2061 iface = self.V_INF1)
2062 status = self.verify_igmp_data_traffic(groups[i],intf=self.V_INF1,source=sources[i])
2063 assert_equal(status, True)
A R Karthick76a497a2017-04-12 10:59:39 -07002064 log_test.info("data received for group %s from source %s after changing group mode to 'TO-INCLUDE' mode"%(groups[i],sources[i]))
ChetanGaonkera7e2b412016-09-01 23:19:07 -07002065
2066 def test_igmp_with_multiple_joins_and_data_verify_with_1000_groups(self):
2067 groups = []
2068 sources = []
2069 count = 1
2070 mcastips = self.mcast_ip_range(start_ip = '229.0.0.1',end_ip = '229.0.30.254')
2071 sourceips = self.source_ip_range(start_ip = '10.10.0.1',end_ip = '10.10.30.254')
2072 while count<=1000:
2073 group = random.choice(mcastips)
2074 source = random.choice(sourceips)
2075 if group in groups:
2076 pass
2077 else:
A R Karthick76a497a2017-04-12 10:59:39 -07002078 log_test.info('group and source are %s and %s'%(group,source))
ChetanGaonkera7e2b412016-09-01 23:19:07 -07002079 groups.append(group)
2080 sources.append(source)
2081 count += 1
2082 self.onos_ssm_table_load(groups,src_list=sources,flag=True)
2083 for i in range(1000):
2084 self.send_igmp_join(groups = [groups[i]], src_list = [sources[i]],record_type = IGMP_V3_GR_TYPE_INCLUDE,
2085 iface = self.V_INF1)
2086 status = self.verify_igmp_data_traffic(groups[i],intf=self.V_INF1,source=sources[i])
2087 assert_equal(status, True)
A R Karthick76a497a2017-04-12 10:59:39 -07002088 log_test.info('data received for group %s from source %s - %d'%(groups[i],sources[i],i))
ChetanGaonkera7e2b412016-09-01 23:19:07 -07002089
2090 def test_igmp_with_multiple_joins_and_data_verify_with_5000_groups(self):
2091 groups = []
2092 sources = []
2093 count = 1
2094 mcastips = self.mcast_ip_range(start_ip = '231.39.19.121',end_ip = '231.40.30.25')
2095 sourceips = self.source_ip_range(start_ip = '192.168.56.43',end_ip = '192.169.110.30')
2096 while count<=5000:
2097 group = random.choice(mcastips)
2098 source = random.choice(sourceips)
2099 if group in groups:
2100 pass
2101 else:
A R Karthick76a497a2017-04-12 10:59:39 -07002102 log_test.info('group and source are %s and %s'%(group,source))
ChetanGaonkera7e2b412016-09-01 23:19:07 -07002103 groups.append(group)
2104 sources.append(source)
2105 count += 1
2106 self.onos_ssm_table_load(groups,src_list=sources,flag=True)
2107 for i in range(5000):
2108 self.send_igmp_join(groups = [groups[i]], src_list = [sources[i]],record_type = IGMP_V3_GR_TYPE_INCLUDE,
2109 iface = self.V_INF1)
2110 status = self.verify_igmp_data_traffic(groups[i],intf=self.V_INF1,source=sources[i])
2111 assert_equal(status, True)
A R Karthick76a497a2017-04-12 10:59:39 -07002112 log_test.info('data received for group %s from source %s - %d'%(groups[i],sources[i],i))
ChetanGaonkera7e2b412016-09-01 23:19:07 -07002113
2114 """def test_igmp_join_from_multiple_infts(self):
2115 groups = ['229.9.3.6','234.20.56.2']
2116 src_list = ['192.168.12.34','192.18.1.34']
2117 self.onos_ssm_table_load(groups, src_list=src_list)
2118 self.send_igmp_join(groups = [groups[0]], src_list = src_list,record_type = IGMP_V3_GR_TYPE_INCLUDE,
2119 iface = 'veth0')
2120 self.send_igmp_join(groups = [groups[1]], src_list = src_list,record_type = IGMP_V3_GR_TYPE_INCLUDE,
2121 iface = 'veth2')
2122 status = self.verify_igmp_data_traffic(groups[0],intf='veth0',source=src_list[0])
2123 assert_equal(status,True)
2124 status = self.verify_igmp_data_traffic(groups[1],intf='veth2',source=src_list[1])
2125 assert_equal(status,True) # not expecting igmp data traffic from source src_list[0]
2126 """
2127
2128 def test_igmp_send_data_to_non_registered_group(self):
2129 group = ['224.2.3.4']
2130 src = ['2.2.2.2']
2131 self.onos_ssm_table_load(group,src_list= src)
2132 self.send_igmp_join(groups = ['239.0.0.1'], src_list = src,record_type = IGMP_V3_GR_TYPE_INCLUDE,
2133 iface = self.V_INF1, delay = 1)
2134 status = self.verify_igmp_data_traffic('239.0.0.1',intf=self.V_INF1,source=src[0])
2135 assert_equal(status,False) # not expecting igmp data traffic from source src_list[0]
2136
2137 def test_igmp_traffic_verification_for_registered_group_with_no_join_sent(self):
2138 group = ['227.12.3.40']
2139 src = ['190.4.19.67']
2140 self.onos_ssm_table_load(group,src_list= src)
2141 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source=src[0])
2142 assert_equal(status,False) # not expecting igmp data traffic from source src_list[0]
2143
2144 def test_igmp_toggling_app_activation(self):
2145 group = [self.random_mcast_ip()]
2146 src = [self.randomsourceip()]
2147 self.onos_ssm_table_load(group,src_list= src)
2148 self.send_igmp_join(groups = group, src_list = src,record_type = IGMP_V3_GR_TYPE_INCLUDE,
2149 iface = self.V_INF1)
2150 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source=src[0])
2151 assert_equal(status,True) # expecting igmp data traffic from source src_list[0]
A R Karthick76a497a2017-04-12 10:59:39 -07002152 log_test.info('Multicast traffic received for group %s from source %s before the app is deactivated'%(group[0],src[0]))
ChetanGaonkera7e2b412016-09-01 23:19:07 -07002153 self.onos_ctrl.deactivate()
2154 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source=src[0])
2155 assert_equal(status,False) #not expecting igmp data traffic from source src_list[0]
A R Karthick76a497a2017-04-12 10:59:39 -07002156 log_test.info('Multicast traffic not received for group %s from source %s after the app is deactivated'%(group[0],src[0]))
ChetanGaonkera7e2b412016-09-01 23:19:07 -07002157 self.onos_ctrl.activate()
2158 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source=src[0])
2159 assert_equal(status,True) # expecting igmp data traffic from source src_list[0]
A R Karthick76a497a2017-04-12 10:59:39 -07002160 log_test.info('Multicast traffic received for group %s from source %s the app is re-activated'%(group[0],src[0]))
ChetanGaonkera7e2b412016-09-01 23:19:07 -07002161
2162 def test_igmp_with_mismatch_for_dst_ip_and_mac_in_data_packets(self):
2163 group = ['228.18.19.29']
2164 source = [self.randomsourceip()]
2165 self.onos_ssm_table_load(group,src_list= source)
2166 self.send_igmp_join(groups = group, src_list = source,record_type = IGMP_V3_GR_TYPE_INCLUDE,
2167 iface = self.V_INF1)
2168 dst_mac = '01:00:5e:0A:12:09'
2169 eth = Ether(dst= dst_mac)
2170 ip = IP(dst=group[0],src=source[0])
2171 data = repr(monotonic.monotonic())
2172 pkt = (eth/ip/data)
A R Karthick76a497a2017-04-12 10:59:39 -07002173 log_test.info('Multicast traffic packet %s'%pkt.show())
ChetanGaonkera7e2b412016-09-01 23:19:07 -07002174 self.success = False
2175 def recv_task():
2176 def igmp_recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -07002177 #log_test.info('received multicast data packet is %s'%pkt.show())
2178 log_test.info('multicast data received for group %s from source %s'%(group[0],source[0]))
ChetanGaonkera7e2b412016-09-01 23:19:07 -07002179 self.success = True
2180 sniff(prn = igmp_recv_cb,lfilter = lambda p: IP in p and p[IP].dst == group[0] and p[IP].src == source[0], count=1,timeout = 2, iface='veth0')
2181 t = threading.Thread(target = recv_task)
2182 t.start()
2183 sendp(eth/ip/data,count=20, iface = 'veth2')
2184 t.join()
2185 assert_equal(status,False) # not expecting igmp data traffic from source src_list[0]
2186
2187 #test case failing, ONOS registering unicast ip also as an igmp join
2188 def test_igmp_registering_invalid_group(self):
ChetanGaonkerb99538a2016-12-02 13:53:35 -08002189 groups = ['218.18.19.29']
ChetanGaonkera7e2b412016-09-01 23:19:07 -07002190 source = [self.randomsourceip()]
A.R Karthick401a1ed2017-05-18 11:08:27 -07002191 ssm_dict = {'apps' : { 'org.opencord.igmp' : { 'ssmTranslate' : [] } } }
2192 ssm_xlate_list = ssm_dict['apps']['org.opencord.igmp']['ssmTranslate']
ChetanGaonkera7e2b412016-09-01 23:19:07 -07002193 for g in groups:
2194 for s in source:
2195 d = {}
2196 d['source'] = s or '0.0.0.0'
2197 d['group'] = g
2198 ssm_xlate_list.append(d)
A R Karthick76a497a2017-04-12 10:59:39 -07002199 log_test.info('onos load config is %s'%ssm_dict)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07002200 status, code = OnosCtrl.config(ssm_dict)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08002201 self.send_igmp_join(groups, src_list = source, record_type = IGMP_V3_GR_TYPE_INCLUDE,
2202 iface = self.V_INF1, delay = 1)
2203 status = self.verify_igmp_data_traffic(groups[0],intf=self.V_INF1, source=source[0])
2204 assert_equal(status,False) # not expecting igmp data traffic from source src_list[0]
ChetanGaonkera7e2b412016-09-01 23:19:07 -07002205
2206 def test_igmp_registering_invalid_source(self):
2207 groups = [self.random_mcast_ip()]
2208 sources = ['224.10.28.34','193.73.219.257']
A.R Karthick401a1ed2017-05-18 11:08:27 -07002209 ssm_dict = {'apps' : { 'org.opencord.igmp' : { 'ssmTranslate' : [] } } }
2210 ssm_xlate_list = ssm_dict['apps']['org.opencord.igmp']['ssmTranslate']
ChetanGaonkera7e2b412016-09-01 23:19:07 -07002211 for g in groups:
2212 for s in sources:
2213 d = {}
2214 d['source'] = s or '0.0.0.0'
2215 d['group'] = g
2216 ssm_xlate_list.append(d)
A R Karthick76a497a2017-04-12 10:59:39 -07002217 log_test.info('onos load config is %s'%ssm_dict)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07002218 status, code = OnosCtrl.config(ssm_dict)
2219 assert_equal(status,False)