blob: edd85cbf5c03d3add549641765d4e6c1fd63af60 [file] [log] [blame]
A.R Karthick95d044e2016-06-10 18:44:36 -07001#
Chetan Gaonkercfcce782016-05-10 10:10:42 -07002# Copyright 2016-present Ciena Corporation
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
A.R Karthick95d044e2016-06-10 18:44:36 -07007#
Chetan Gaonkercfcce782016-05-10 10:10:42 -07008# http://www.apache.org/licenses/LICENSE-2.0
A.R Karthick95d044e2016-06-10 18:44:36 -07009#
Chetan Gaonkercfcce782016-05-10 10:10:42 -070010# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
A R Karthickbd698672017-07-13 16:48:24 -070016from twisted.internet import defer
Chetan Gaonker25470972016-02-26 08:52:15 -080017from nose.tools import *
18from nose.twistedtools import reactor, deferred
Chetan Gaonker25470972016-02-26 08:52:15 -080019from scapy.all import *
A R Karthickbd698672017-07-13 16:48:24 -070020from select import select as socket_select
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -080021import time, monotonic
ChetanGaonkerb99538a2016-12-02 13:53:35 -080022import os
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -080023import random
24import threading
Chetan Gaonkere88c95c2016-03-02 05:21:47 -080025from IGMP import *
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -080026from McastTraffic import *
27from Stats import Stats
Chetan Gaonker4a25e2b2016-03-04 14:45:15 -080028from OnosCtrl import OnosCtrl
Chetan Gaonker441c9ac2016-05-06 10:30:13 -070029from OltConfig import OltConfig
Chetan Gaonker4eb12072016-03-28 15:04:15 -070030from Channels import IgmpChannel
A R Karthick9313b762016-11-07 13:14:35 -080031from CordLogger import CordLogger
A R Karthick9dc6e922017-07-12 14:40:16 -070032from CordTestConfig import setup_module, teardown_module
A R Karthick76a497a2017-04-12 10:59:39 -070033from CordTestUtils import log_test
A R Karthick76a497a2017-04-12 10:59:39 -070034log_test.setLevel('INFO')
Chetan Gaonker25470972016-02-26 08:52:15 -080035
36class IGMPTestState:
37
38 def __init__(self, groups = [], df = None, state = 0):
39 self.df = df
40 self.state = state
41 self.counter = 0
42 self.groups = groups
43 self.group_map = {} ##create a send/recv count map
44 for g in groups:
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -080045 self.group_map[g] = (Stats(), Stats())
A.R Karthick95d044e2016-06-10 18:44:36 -070046
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -080047 def update(self, group, tx = 0, rx = 0, t = 0):
48 self.counter += 1
Chetan Gaonker25470972016-02-26 08:52:15 -080049 index = 0 if rx == 0 else 1
50 v = tx if rx == 0 else rx
51 if self.group_map.has_key(group):
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -080052 self.group_map[group][index].update(packets = v, t = t)
Chetan Gaonker25470972016-02-26 08:52:15 -080053
54 def update_state(self):
55 self.state = self.state ^ 1
Chetan Gaonker25470972016-02-26 08:52:15 -080056
A R Karthick9313b762016-11-07 13:14:35 -080057class igmp_exchange(CordLogger):
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -080058
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -070059 V_INF1 = 'veth0'
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -070060 MGROUP1 = '239.1.2.3'
61 MGROUP2 = '239.2.2.3'
Chetan Gaonker441c9ac2016-05-06 10:30:13 -070062 MINVALIDGROUP1 = '255.255.255.255'
63 MINVALIDGROUP2 = '239.255.255.255'
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -070064 MMACGROUP1 = "01:00:5e:01:02:03"
65 MMACGROUP2 = "01:00:5e:02:02:03"
ChetanGaonkera7e2b412016-09-01 23:19:07 -070066 IGMP_DST_MAC = "01:00:5e:00:00:16"
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -070067 IGMP_SRC_MAC = "5a:e1:ac:ec:4d:a1"
68 IP_SRC = '1.2.3.4'
ChetanGaonkera7e2b412016-09-01 23:19:07 -070069 IP_DST = '224.0.0.22'
Chetan Gaonker441c9ac2016-05-06 10:30:13 -070070 NEGATIVE_TRAFFIC_STATUS = 1
ChetanGaonkera7e2b412016-09-01 23:19:07 -070071 igmp_eth = Ether(dst = IGMP_DST_MAC, type = ETH_P_IP)
72 igmp_ip = IP(dst = IP_DST)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -080073 IGMP_TEST_TIMEOUT = 5
Chetan Gaonker441c9ac2016-05-06 10:30:13 -070074 IGMP_QUERY_TIMEOUT = 60
A R Karthicka93fdee2017-07-14 17:27:35 -070075 MCAST_TRAFFIC_TIMEOUT = 20
Chetan Gaonker4eb12072016-03-28 15:04:15 -070076 PORT_TX_DEFAULT = 2
77 PORT_RX_DEFAULT = 1
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -080078 max_packets = 100
A.R Karthick95d044e2016-06-10 18:44:36 -070079 app = 'org.opencord.igmp'
A.R Karthick5968e0d2017-05-16 14:50:46 -070080 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 -070081 ROVER_TEST_TIMEOUT = 300 #3600*86
82 ROVER_TIMEOUT = (ROVER_TEST_TIMEOUT - 100)
83 ROVER_JOIN_TIMEOUT = 60
A R Karthickbd698672017-07-13 16:48:24 -070084 VOLTHA_ENABLED = bool(int(os.getenv('VOLTHA_ENABLED', 0)))
Chetan Gaonker4a25e2b2016-03-04 14:45:15 -080085
Chetan Gaonker441c9ac2016-05-06 10:30:13 -070086 @classmethod
87 def setUpClass(cls):
A R Karthick38d5df42017-07-10 13:33:26 -070088 cls.olt = OltConfig(olt_conf_file = cls.olt_conf_file)
89 cls.port_map, _ = cls.olt.olt_port_map()
A R Karthickbd698672017-07-13 16:48:24 -070090 if cls.VOLTHA_ENABLED is False:
91 OnosCtrl.config_device_driver()
92 OnosCtrl.cord_olt_config(cls.olt)
A R Karthick38d5df42017-07-10 13:33:26 -070093 time.sleep(2)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -070094
95 @classmethod
A R Karthick38d5df42017-07-10 13:33:26 -070096 def tearDownClass(cls):
A R Karthickbd698672017-07-13 16:48:24 -070097 if cls.VOLTHA_ENABLED is False:
98 OnosCtrl.config_device_driver(driver = 'ovs')
A.R Karthick95d044e2016-06-10 18:44:36 -070099
Chetan Gaonker4a25e2b2016-03-04 14:45:15 -0800100 def setUp(self):
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700101 ''' Activate the igmp app'''
A R Karthick9313b762016-11-07 13:14:35 -0800102 super(igmp_exchange, self).setUp()
Chetan Gaonker4a25e2b2016-03-04 14:45:15 -0800103 self.onos_ctrl = OnosCtrl(self.app)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700104 self.onos_ctrl.activate()
Chetan Gaonker4eb12072016-03-28 15:04:15 -0700105 self.igmp_channel = IgmpChannel()
Chetan Gaonker4a25e2b2016-03-04 14:45:15 -0800106
A R Karthick9313b762016-11-07 13:14:35 -0800107 def tearDown(self):
108 super(igmp_exchange, self).tearDown()
Chetan Gaonker4a25e2b2016-03-04 14:45:15 -0800109
110 def onos_load_config(self, config):
A R Karthick76a497a2017-04-12 10:59:39 -0700111 log_test.info('onos load config is %s'%config)
Chetan Gaonkera2b87df2016-03-31 15:41:31 -0700112 status, code = OnosCtrl.config(config)
Chetan Gaonker4a25e2b2016-03-04 14:45:15 -0800113 if status is False:
A R Karthick76a497a2017-04-12 10:59:39 -0700114 log_test.info('JSON request returned status %d' %code)
Chetan Gaonker4a25e2b2016-03-04 14:45:15 -0800115 assert_equal(status, True)
116 time.sleep(2)
A.R Karthick95d044e2016-06-10 18:44:36 -0700117
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700118 def onos_ssm_table_load(self, groups, src_list = ['1.2.3.4'],flag = False):
A R Karthick38d5df42017-07-10 13:33:26 -0700119 return
A.R Karthick401a1ed2017-05-18 11:08:27 -0700120 ssm_dict = {'apps' : { 'org.opencord.igmp' : { 'ssmTranslate' : [] } } }
121 ssm_xlate_list = ssm_dict['apps']['org.opencord.igmp']['ssmTranslate']
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700122 if flag: #to maintain seperate group-source pair.
123 for i in range(len(groups)):
124 d = {}
125 d['source'] = src_list[i] or '0.0.0.0'
126 d['group'] = groups[i]
127 ssm_xlate_list.append(d)
128 else:
129 for g in groups:
130 for s in src_list:
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800131 d = {}
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700132 d['source'] = s or '0.0.0.0'
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800133 d['group'] = g
134 ssm_xlate_list.append(d)
Chetan Gaonker4a25e2b2016-03-04 14:45:15 -0800135 self.onos_load_config(ssm_dict)
Chetan Gaonker4eb12072016-03-28 15:04:15 -0700136 cord_port_map = {}
137 for g in groups:
138 cord_port_map[g] = (self.PORT_TX_DEFAULT, self.PORT_RX_DEFAULT)
139 self.igmp_channel.cord_port_table_load(cord_port_map)
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800140 time.sleep(2)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800141
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700142 def mcast_ip_range(self,start_ip = '224.0.1.0', end_ip = '224.0.1.100'):
143 start = list(map(int, start_ip.split(".")))
144 end = list(map(int, end_ip.split(".")))
145 temp = start
146 ip_range = []
147 ip_range.append(start_ip)
148 while temp != end:
149 start[3] += 1
150 for i in (3, 2, 1):
151 if temp[i] == 255:
152 temp[i] = 0
153 temp[i-1] += 1
154 ip_range.append(".".join(map(str, temp)))
155 return ip_range
156
157 def random_mcast_ip(self,start_ip = '224.0.1.0', end_ip = '224.0.1.100'):
158 start = list(map(int, start_ip.split(".")))
159 end = list(map(int, end_ip.split(".")))
160 temp = start
161 ip_range = []
162 ip_range.append(start_ip)
163 while temp != end:
164 start[3] += 1
165 for i in (3, 2, 1):
166 if temp[i] == 255:
167 temp[i] = 0
168 temp[i-1] += 1
169 ip_range.append(".".join(map(str, temp)))
170 return random.choice(ip_range)
171
172 def source_ip_range(self,start_ip = '10.10.0.1', end_ip = '10.10.0.100'):
173 start = list(map(int, start_ip.split(".")))
174 end = list(map(int, end_ip.split(".")))
175 temp = start
176 ip_range = []
177 ip_range.append(start_ip)
178 while temp != end:
179 start[3] += 1
180 for i in (3, 2, 1):
181 if temp[i] == 255:
182 temp[i] = 0
183 temp[i-1] += 1
184 ip_range.append(".".join(map(str, temp)))
185 return ip_range
186
187 def randomsourceip(self,start_ip = '10.10.0.1', end_ip = '10.10.0.100'):
188 start = list(map(int, start_ip.split(".")))
189 end = list(map(int, end_ip.split(".")))
190 temp = start
191 ip_range = []
192 ip_range.append(start_ip)
193 while temp != end:
194 start[3] += 1
195 for i in (3, 2, 1):
196 if temp[i] == 255:
197 temp[i] = 0
198 temp[i-1] += 1
199 ip_range.append(".".join(map(str, temp)))
200 return random.choice(ip_range)
201
A R Karthick2b93d6a2016-09-06 15:19:09 -0700202 def get_igmp_intf(self):
203 inst = os.getenv('TEST_INSTANCE', None)
204 if not inst:
205 return 'veth0'
206 inst = int(inst) + 1
207 if inst >= self.port_map['uplink']:
208 inst += 1
209 if self.port_map.has_key(inst):
210 return self.port_map[inst]
211 return 'veth0'
212
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800213 def igmp_verify_join(self, igmpStateList):
214 sendState, recvState = igmpStateList
Chetan Gaonker25470972016-02-26 08:52:15 -0800215 ## check if the send is received for the groups
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800216 for g in sendState.groups:
A.R Karthick95d044e2016-06-10 18:44:36 -0700217 tx_stats = sendState.group_map[g][0]
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800218 tx = tx_stats.count
Chetan Gaonker25470972016-02-26 08:52:15 -0800219 assert_greater(tx, 0)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800220 rx_stats = recvState.group_map[g][1]
221 rx = rx_stats.count
222 assert_greater(rx, 0)
A R Karthick76a497a2017-04-12 10:59:39 -0700223 log_test.info('Receive stats %s for group %s' %(rx_stats, g))
A.R Karthick95d044e2016-06-10 18:44:36 -0700224
A R Karthick76a497a2017-04-12 10:59:39 -0700225 log_test.info('IGMP test verification success')
Chetan Gaonker25470972016-02-26 08:52:15 -0800226
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800227 def igmp_verify_leave(self, igmpStateList, leave_groups):
228 sendState, recvState = igmpStateList[0], igmpStateList[1]
229 ## check if the send is received for the groups
230 for g in sendState.groups:
231 tx_stats = sendState.group_map[g][0]
232 rx_stats = recvState.group_map[g][1]
233 tx = tx_stats.count
A.R Karthick95d044e2016-06-10 18:44:36 -0700234 rx = rx_stats.count
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800235 assert_greater(tx, 0)
236 if g not in leave_groups:
A R Karthick76a497a2017-04-12 10:59:39 -0700237 log_test.info('Received %d packets for group %s' %(rx, g))
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800238 for g in leave_groups:
239 rx = recvState.group_map[g][1].count
240 assert_equal(rx, 0)
A.R Karthick95d044e2016-06-10 18:44:36 -0700241
A R Karthick76a497a2017-04-12 10:59:39 -0700242 log_test.info('IGMP test verification success')
Chetan Gaonker25470972016-02-26 08:52:15 -0800243
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800244 def mcast_traffic_timer(self):
A R Karthickbd698672017-07-13 16:48:24 -0700245 log_test.info('MCAST traffic timer expiry')
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800246 self.mcastTraffic.stopReceives()
247
248 def send_mcast_cb(self, send_state):
249 for g in send_state.groups:
250 send_state.update(g, tx = 1)
Chetan Gaonker25470972016-02-26 08:52:15 -0800251 return 0
252
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800253 ##Runs in the context of twisted reactor thread
A R Karthickbd698672017-07-13 16:48:24 -0700254 def igmp_recv(self, igmpState):
255 s = socket_select([self.recv_socket], [], [], 1.0)
256 if self.recv_socket in s[0]:
257 p = self.recv_socket.recv()
258 try:
259 send_time = float(p.payload.load)
260 recv_time = monotonic.monotonic()
261 except:
262 log_test.info('Unexpected Payload received: %s' %p.payload.load)
263 return 0
264 #log_test.info( 'Recv in %.6f secs' %(recv_time - send_time))
265 igmpState.update(p.dst, rx = 1, t = recv_time - send_time)
Chetan Gaonker25470972016-02-26 08:52:15 -0800266 return 0
267
A R Karthick2b93d6a2016-09-06 15:19:09 -0700268 def send_igmp_join(self, groups, src_list = ['1.2.3.4'], record_type=IGMP_V3_GR_TYPE_INCLUDE,
269 ip_pkt = None, iface = 'veth0', ssm_load = False, delay = 1):
270 if ssm_load is True:
271 self.onos_ssm_table_load(groups, src_list)
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800272 igmp = IGMPv3(type = IGMP_TYPE_V3_MEMBERSHIP_REPORT, max_resp_code=30,
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700273 gaddr=self.IP_DST)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800274 for g in groups:
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700275 gr = IGMPv3gr(rtype= record_type, mcaddr=g)
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800276 gr.sources = src_list
277 igmp.grps.append(gr)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700278 if ip_pkt is None:
279 ip_pkt = self.igmp_eth/self.igmp_ip
280 pkt = ip_pkt/igmp
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800281 IGMPv3.fixup(pkt)
282 sendp(pkt, iface=iface)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800283 if delay != 0:
284 time.sleep(delay)
285
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700286 def send_igmp_join_recvQuery(self, groups, rec_queryCount = None, src_list = ['1.2.3.4'], ip_pkt = None, iface = 'veth0', delay = 2):
287 self.onos_ssm_table_load(groups, src_list)
288 igmp = IGMPv3(type = IGMP_TYPE_V3_MEMBERSHIP_REPORT, max_resp_code=30,
289 gaddr=self.IP_DST)
290 for g in groups:
Chetan Gaonker38737f82016-05-11 17:44:17 -0700291 gr = IGMPv3gr(rtype=IGMP_V3_GR_TYPE_INCLUDE, mcaddr=g)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700292 gr.sources = src_list
293 gr.sources = src_list
294 igmp.grps.append(gr)
295 if ip_pkt is None:
296 ip_pkt = self.igmp_eth/self.igmp_ip
297 pkt = ip_pkt/igmp
298 IGMPv3.fixup(pkt)
299 if rec_queryCount == None:
A R Karthick76a497a2017-04-12 10:59:39 -0700300 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 -0700301 resp = srp1(pkt, iface=iface)
302 else:
A R Karthick76a497a2017-04-12 10:59:39 -0700303 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 -0700304 resp = srp1(pkt, iface=iface)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700305# resp = srp1(pkt, iface=iface) if rec_queryCount else srp3(pkt, iface=iface)
306 resp[0].summary()
A R Karthick76a497a2017-04-12 10:59:39 -0700307 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 -0700308 if delay != 0:
309 time.sleep(delay)
310
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700311 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 -0700312 log_test.info('entering into igmp leave function')
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800313 igmp = IGMPv3(type = IGMP_TYPE_V3_MEMBERSHIP_REPORT, max_resp_code=30,
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700314 gaddr=self.IP_DST)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800315 for g in groups:
Chetan Gaonker38737f82016-05-11 17:44:17 -0700316 gr = IGMPv3gr(rtype=IGMP_V3_GR_TYPE_EXCLUDE, mcaddr=g)
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800317 gr.sources = src_list
318 igmp.grps.append(gr)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700319 if ip_pkt is None:
320 ip_pkt = self.igmp_eth/self.igmp_ip
321 pkt = ip_pkt/igmp
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800322 IGMPv3.fixup(pkt)
323 sendp(pkt, iface = iface)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800324 if delay != 0:
325 time.sleep(delay)
Chetan Gaonker25470972016-02-26 08:52:15 -0800326
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700327 def send_igmp_leave_listening_group_specific_query(self, groups, src_list = ['1.2.3.4'], ip_pkt = None, iface = 'veth0', delay = 2):
328 igmp = IGMPv3(type = IGMP_TYPE_V3_MEMBERSHIP_REPORT, max_resp_code=30,
329 gaddr=self.IP_DST)
330 for g in groups:
Chetan Gaonker38737f82016-05-11 17:44:17 -0700331 gr = IGMPv3gr(rtype=IGMP_V3_GR_TYPE_EXCLUDE, mcaddr=g)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700332 gr.sources = src_list
333 igmp.grps.append(gr)
334 if ip_pkt is None:
335 ip_pkt = self.igmp_eth/self.igmp_ip
336 pkt = ip_pkt/igmp
337 IGMPv3.fixup(pkt)
A R Karthick76a497a2017-04-12 10:59:39 -0700338 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 -0700339 resp = srp1(pkt, iface=iface)
340 resp[0].summary()
A R Karthick76a497a2017-04-12 10:59:39 -0700341 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 -0700342 if delay != 0:
343 time.sleep(delay)
344
A R Karthicka93fdee2017-07-14 17:27:35 -0700345 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800346 def test_igmp_join_verify_traffic(self):
Chetan Gaonkerddfdc522017-04-04 01:15:04 +0000347 groups = [self.MGROUP1, self.MGROUP1]
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700348 self.onos_ssm_table_load(groups)
Chetan Gaonker25470972016-02-26 08:52:15 -0800349 df = defer.Deferred()
350 igmpState = IGMPTestState(groups = groups, df = df)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800351 igmpStateRecv = IGMPTestState(groups = groups, df = df)
352 igmpStateList = (igmpState, igmpStateRecv)
A R Karthick38d5df42017-07-10 13:33:26 -0700353 tx_intf = self.port_map[self.PORT_TX_DEFAULT]
354 rx_intf = self.port_map[self.PORT_RX_DEFAULT]
355 mcastTraffic = McastTraffic(groups, iface= tx_intf, cb = self.send_mcast_cb, arg = igmpState)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800356 self.df = df
357 self.mcastTraffic = mcastTraffic
A R Karthick38d5df42017-07-10 13:33:26 -0700358 self.recv_socket = L3PacketSocket(iface = rx_intf, type = ETH_P_IP)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800359
360 def igmp_srp_task(stateList):
361 igmpSendState, igmpRecvState = stateList
362 if not mcastTraffic.isRecvStopped():
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800363 self.igmp_recv(igmpRecvState)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800364 reactor.callLater(0, igmp_srp_task, stateList)
365 else:
366 self.mcastTraffic.stop()
A R Karthickbd698672017-07-13 16:48:24 -0700367 #log_test.info('Sending IGMP leave for groups: %s' %groups)
368 self.send_igmp_leave(groups, iface = rx_intf, delay = 2)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800369 self.recv_socket.close()
370 self.igmp_verify_join(stateList)
371 self.df.callback(0)
372
A R Karthick38d5df42017-07-10 13:33:26 -0700373 self.send_igmp_join(groups, iface = rx_intf)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800374 mcastTraffic.start()
375 self.test_timer = reactor.callLater(self.MCAST_TRAFFIC_TIMEOUT, self.mcast_traffic_timer)
376 reactor.callLater(0, igmp_srp_task, igmpStateList)
Chetan Gaonker25470972016-02-26 08:52:15 -0800377 return df
378
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700379 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+40)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800380 def test_igmp_leave_verify_traffic(self):
A R Karthick38d5df42017-07-10 13:33:26 -0700381 groups = [self.MGROUP1]
382 leave_groups = [self.MGROUP1]
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700383 self.onos_ssm_table_load(groups)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800384 df = defer.Deferred()
385 igmpState = IGMPTestState(groups = groups, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800386 IGMPTestState(groups = groups, df = df)
A R Karthick38d5df42017-07-10 13:33:26 -0700387 tx_intf = self.port_map[self.PORT_TX_DEFAULT]
388 rx_intf = self.port_map[self.PORT_RX_DEFAULT]
389 mcastTraffic = McastTraffic(groups, iface= tx_intf, cb = self.send_mcast_cb,
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800390 arg = igmpState)
391 self.df = df
392 self.mcastTraffic = mcastTraffic
A R Karthick38d5df42017-07-10 13:33:26 -0700393 self.recv_socket = L3PacketSocket(iface = rx_intf, type = ETH_P_IP)
A.R Karthick95d044e2016-06-10 18:44:36 -0700394
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700395 mcastTraffic.start()
A R Karthick38d5df42017-07-10 13:33:26 -0700396 self.send_igmp_join(groups, iface = rx_intf)
397 time.sleep(5)
398 self.send_igmp_leave(leave_groups, delay = 3, iface = rx_intf)
399 time.sleep(10)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700400 join_state = IGMPTestState(groups = leave_groups)
A R Karthick38d5df42017-07-10 13:33:26 -0700401 status = self.igmp_not_recv_task(rx_intf, leave_groups, join_state)
A R Karthick76a497a2017-04-12 10:59:39 -0700402 log_test.info('verified status for igmp recv task %s'%status)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700403 assert status == 1 , 'EXPECTED RESULT'
404 self.df.callback(0)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800405 return df
406
407 @deferred(timeout=100)
408 def test_igmp_leave_join_loop(self):
409 self.groups = ['226.0.1.1', '227.0.0.1', '228.0.0.1', '229.0.0.1', '230.0.0.1' ]
410 self.src_list = ['3.4.5.6', '7.8.9.10']
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700411 self.onos_ssm_table_load(self.groups,src_list=self.src_list)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800412 df = defer.Deferred()
413 self.df = df
414 self.iterations = 0
415 self.num_groups = len(self.groups)
416 self.MAX_TEST_ITERATIONS = 10
A R Karthick38d5df42017-07-10 13:33:26 -0700417 rx_intf = self.port_map[self.PORT_RX_DEFAULT]
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800418
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800419 def igmp_srp_task(v):
420 if self.iterations < self.MAX_TEST_ITERATIONS:
421 if v == 1:
422 ##join test
423 self.num_groups = random.randint(0, len(self.groups))
424 self.send_igmp_join(self.groups[:self.num_groups],
425 src_list = self.src_list,
A R Karthick38d5df42017-07-10 13:33:26 -0700426 iface = rx_intf, delay = 0)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800427 else:
428 self.send_igmp_leave(self.groups[:self.num_groups],
429 src_list = self.src_list,
A R Karthick38d5df42017-07-10 13:33:26 -0700430 iface = rx_intf, delay = 0)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800431 self.iterations += 1
432 v ^= 1
433 reactor.callLater(1.0 + 0.5*self.num_groups,
434 igmp_srp_task, v)
435 else:
436 self.df.callback(0)
437
438 reactor.callLater(0, igmp_srp_task, 1)
439 return df
440
441 def igmp_join_task(self, intf, groups, state, src_list = ['1.2.3.4']):
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700442 #self.onos_ssm_table_load(groups, src_list)
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800443 igmp = IGMPv3(type = IGMP_TYPE_V3_MEMBERSHIP_REPORT, max_resp_code=30,
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700444 gaddr=self.IP_DST)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800445 for g in groups:
Chetan Gaonker38737f82016-05-11 17:44:17 -0700446 gr = IGMPv3gr(rtype = IGMP_V3_GR_TYPE_INCLUDE, mcaddr = g)
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800447 gr.sources = src_list
448 igmp.grps.append(gr)
449
450 for g in groups:
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800451 state.group_map[g][0].update(1, t = monotonic.monotonic())
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800452
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700453 pkt = self.igmp_eth/self.igmp_ip/igmp
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800454 IGMPv3.fixup(pkt)
455 sendp(pkt, iface=intf)
A R Karthick76a497a2017-04-12 10:59:39 -0700456 log_test.debug('Returning from join task')
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800457
458 def igmp_recv_task(self, intf, groups, join_state):
459 recv_socket = L3PacketSocket(iface = intf, type = ETH_P_IP)
460 group_map = {}
461 for g in groups:
462 group_map[g] = [0,0]
463
A R Karthick76a497a2017-04-12 10:59:39 -0700464 log_test.info('Verifying join interface should receive multicast data')
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800465 while True:
466 p = recv_socket.recv()
467 if p.dst in groups and group_map[p.dst][0] == 0:
468 group_map[p.dst][0] += 1
469 group_map[p.dst][1] = monotonic.monotonic()
470 c = 0
471 for g in groups:
472 c += group_map[g][0]
473 if c == len(groups):
474 break
475 for g in groups:
476 join_start = join_state.group_map[g][0].start
477 recv_time = group_map[g][1] * 1000000
478 delta = (recv_time - join_start)
A R Karthick76a497a2017-04-12 10:59:39 -0700479 log_test.info('Join for group %s received in %.3f usecs' %
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800480 (g, delta))
481
482 recv_socket.close()
A R Karthick76a497a2017-04-12 10:59:39 -0700483 log_test.debug('Returning from recv task')
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700484
485 def igmp_not_recv_task(self, intf, groups, join_state):
A R Karthick76a497a2017-04-12 10:59:39 -0700486 log_test.info('Entering igmp not recv task loop')
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700487 recv_socket = L2Socket(iface = intf, type = ETH_P_IP)
488 group_map = {}
489 for g in groups:
490 group_map[g] = [0,0]
491
A R Karthick76a497a2017-04-12 10:59:39 -0700492 log_test.info('Verifying join interface, should not receive any multicast data')
Chetan Gaonker7791bda2016-05-12 17:36:52 -0700493 self.NEGATIVE_TRAFFIC_STATUS = 1
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700494 def igmp_recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -0700495 log_test.info('Multicast packet %s received for left groups %s' %(pkt[IP].dst, groups))
Chetan Gaonker7791bda2016-05-12 17:36:52 -0700496 self.NEGATIVE_TRAFFIC_STATUS = 2
Chetan Gaonker38737f82016-05-11 17:44:17 -0700497 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 -0700498 timeout = 3, opened_socket = recv_socket)
499 recv_socket.close()
A.R Karthick95d044e2016-06-10 18:44:36 -0700500 return self.NEGATIVE_TRAFFIC_STATUS
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700501
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800502 def group_latency_check(self, groups):
503 tasks = []
504 self.send_igmp_leave(groups = groups)
505 join_state = IGMPTestState(groups = groups)
506 tasks.append(threading.Thread(target=self.igmp_join_task, args = ('veth0', groups, join_state,)))
507 traffic_state = IGMPTestState(groups = groups)
A.R Karthick95d044e2016-06-10 18:44:36 -0700508 mcast_traffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb,
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800509 arg = traffic_state)
510 mcast_traffic.start()
511 tasks.append(threading.Thread(target=self.igmp_recv_task, args = ('veth0', groups, join_state)))
512 for t in tasks:
513 t.start()
514 for t in tasks:
515 t.join()
516
517 mcast_traffic.stop()
518 self.send_igmp_leave(groups = groups)
519 return
520
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700521 @deferred(timeout=IGMP_QUERY_TIMEOUT + 10)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800522 def test_igmp_1group_join_latency(self):
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700523 groups = ['239.0.1.1']
524 df = defer.Deferred()
525 def igmp_1group_join_latency():
526 self.group_latency_check(groups)
527 df.callback(0)
528 reactor.callLater(0, igmp_1group_join_latency)
529 return df
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800530
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700531 @deferred(timeout=IGMP_QUERY_TIMEOUT + 10)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800532 def test_igmp_2group_join_latency(self):
Chetan Gaonkerddfdc522017-04-04 01:15:04 +0000533 groups = [self.MGROUP1, self.MGROUP1]
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700534 df = defer.Deferred()
535 def igmp_2group_join_latency():
536 self.group_latency_check(groups)
537 df.callback(0)
538 reactor.callLater(0, igmp_2group_join_latency)
539 return df
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800540
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700541 @deferred(timeout=IGMP_QUERY_TIMEOUT + 10)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800542 def test_igmp_Ngroup_join_latency(self):
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700543 groups = ['239.0.1.1', '240.0.1.1', '241.0.1.1', '242.0.1.1']
544 df = defer.Deferred()
545 def igmp_Ngroup_join_latency():
546 self.group_latency_check(groups)
547 df.callback(0)
548 reactor.callLater(0, igmp_Ngroup_join_latency)
549 return df
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800550
A R Karthick2b93d6a2016-09-06 15:19:09 -0700551 def test_igmp_join_rover_all(self):
Chetan Gaonker1f7c3f82016-03-08 12:17:37 -0800552 s = (224 << 24) | 1
553 #e = (225 << 24) | (255 << 16) | (255 << 16) | 255
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700554 e = (224 << 24) | 10
Chetan Gaonker1f7c3f82016-03-08 12:17:37 -0800555 for i in xrange(s, e+1):
556 if i&0xff:
557 ip = '%d.%d.%d.%d'%((i>>24)&0xff, (i>>16)&0xff, (i>>8)&0xff, i&0xff)
558 self.send_igmp_join([ip], delay = 0)
559
A R Karthick2b93d6a2016-09-06 15:19:09 -0700560 @deferred(timeout=ROVER_TEST_TIMEOUT)
561 def test_igmp_join_rover(self):
562 df = defer.Deferred()
563 iface = self.get_igmp_intf()
564 self.df = df
565 self.count = 0
566 self.timeout = 0
567 self.complete = False
568 def igmp_join_timer():
569 self.timeout += self.ROVER_JOIN_TIMEOUT
A R Karthick76a497a2017-04-12 10:59:39 -0700570 log_test.info('IGMP joins sent: %d' %self.count)
A R Karthick2b93d6a2016-09-06 15:19:09 -0700571 if self.timeout >= self.ROVER_TIMEOUT:
572 self.complete = True
573 reactor.callLater(self.ROVER_JOIN_TIMEOUT, igmp_join_timer)
574
575 reactor.callLater(self.ROVER_JOIN_TIMEOUT, igmp_join_timer)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800576 self.start_channel = (224 << 24) | 1
577 self.end_channel = (224 << 24) | 200 #(225 << 24) | (255 << 16) | (255 << 16) | 255
A R Karthick2b93d6a2016-09-06 15:19:09 -0700578 self.current_channel = self.start_channel
579 def igmp_join_rover(self):
580 #e = (224 << 24) | 10
581 chan = self.current_channel
582 self.current_channel += 1
583 if self.current_channel >= self.end_channel:
584 chan = self.current_channel = self.start_channel
585 if chan&0xff:
586 ip = '%d.%d.%d.%d'%((chan>>24)&0xff, (chan>>16)&0xff, (chan>>8)&0xff, chan&0xff)
587 self.send_igmp_join([ip], delay = 0, ssm_load = False, iface = iface)
588 self.count += 1
589 if self.complete == True:
A R Karthick76a497a2017-04-12 10:59:39 -0700590 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 -0700591 self.df.callback(0)
592 else:
593 reactor.callLater(0, igmp_join_rover, self)
594 reactor.callLater(0, igmp_join_rover, self)
595 return df
596
Chetan Gaonker1f7c3f82016-03-08 12:17:37 -0800597 @deferred(timeout=IGMP_QUERY_TIMEOUT + 10)
598 def test_igmp_query(self):
599 groups = ['224.0.0.1'] ##igmp query group
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700600 self.onos_ssm_table_load(groups)
Chetan Gaonker1f7c3f82016-03-08 12:17:37 -0800601 df = defer.Deferred()
602 self.df = df
603 self.recv_socket = L2Socket(iface = 'veth0', type = ETH_P_IP)
A.R Karthick95d044e2016-06-10 18:44:36 -0700604
Chetan Gaonker1f7c3f82016-03-08 12:17:37 -0800605 def igmp_query_timeout():
Chetan Gaonker1f7c3f82016-03-08 12:17:37 -0800606 def igmp_query_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -0700607 log_test.info('received igmp query packet is %s'%pkt.show())
608 log_test.info('Got IGMP query packet from %s for %s' %(pkt[IP].src, pkt[IP].dst))
Chetan Gaonkerbd4390f2016-03-09 18:56:52 -0800609 assert_equal(pkt[IP].dst, '224.0.0.1')
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700610 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 -0800611 opened_socket = self.recv_socket)
Chetan Gaonker1f7c3f82016-03-08 12:17:37 -0800612 self.recv_socket.close()
613 self.df.callback(0)
614
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700615 #self.send_igmp_join(groups)
Chetan Gaonker1f7c3f82016-03-08 12:17:37 -0800616 self.test_timer = reactor.callLater(self.IGMP_QUERY_TIMEOUT, igmp_query_timeout)
617 return df
618
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700619 def igmp_send_joins_different_groups_srclist(self, groups, sources, intf = V_INF1, delay = 2, ip_src = None):
620 g1 = groups[0]
621 g2 = groups[1]
622 sourcelist1 = sources[0]
623 sourcelist2 = sources[1]
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700624 eth = Ether(dst = self.IGMP_DST_MAC,type = ETH_P_IP)
625 ip = IP(dst = self.IP_DST)
A R Karthick76a497a2017-04-12 10:59:39 -0700626 log_test.info('Sending join message for the group %s' %g1)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700627 self.send_igmp_join((g1,), src_list = sourcelist1, ip_pkt = eth/ip, iface = intf, delay = 2)
628 eth = Ether(dst = self.MMACGROUP2, src = self.IGMP_SRC_MAC, type = ETH_P_IP)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700629 ip = IP(dst = g2)
A R Karthick76a497a2017-04-12 10:59:39 -0700630 log_test.info('Sending join message for group %s' %g2)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700631 self.send_igmp_join((g2,), src_list = sourcelist2, ip_pkt = eth/ip, iface = intf, delay = 2)
A R Karthick76a497a2017-04-12 10:59:39 -0700632 log_test.info('Done with igmp_send_joins_different_groups_srclist')
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700633
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700634 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):
635 g1 = groups[0]
636 g2 = groups[1]
637 sourcelist1 = sources[0]
638 sourcelist2 = sources[1]
639 eth = Ether(dst = self.MMACGROUP1, src = self.IGMP_SRC_MAC, type = ETH_P_IP)
640 src_ip = ip_src or self.IP_SRC
641 ip = IP(dst = g1, src = src_ip)
642 if query_group1 is 'group1':
A R Karthick76a497a2017-04-12 10:59:39 -0700643 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 -0700644 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 -0700645 else:
A R Karthick76a497a2017-04-12 10:59:39 -0700646 log_test.info('Sending join message for the group %s' %g1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700647 self.send_igmp_join((g1,), src_list = sourcelist1, ip_pkt = eth/ip, iface = intf, delay = 2)
648 eth = Ether(dst = self.MMACGROUP2, src = self.IGMP_SRC_MAC, type = ETH_P_IP)
649 ip = IP(dst = g2, src = src_ip)
650 if query_group2 is 'group2':
A R Karthick76a497a2017-04-12 10:59:39 -0700651 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 -0700652 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 -0700653 else:
A R Karthick76a497a2017-04-12 10:59:39 -0700654 log_test.info('Sending join message for group %s' %g2)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700655 self.send_igmp_join((g2,), src_list = sourcelist2, ip_pkt = eth/ip, iface = intf, delay = 2)
656
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700657 def igmp_joins_leave(self,groups,src_list,again_join = False, df = None):
658 groups1 = [groups[0]]
659 groups2 = [groups[1]]
660 src1 = [src_list[0]]
661 src2 = [src_list[1]]
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700662 self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700663 (src1, src2), intf = self.V_INF1, delay = 2)
664
665 src_ip = src1[0]
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700666 if df is None:
667 df = defer.Deferred()
668 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800669 IGMPTestState(groups = groups1, df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700670
671 igmpState2 = IGMPTestState(groups = groups2, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800672 IGMPTestState(groups = groups2, df = df)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700673 dst_mac = self.iptomac(groups1[0])
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700674 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
675 src_ip = src_ip, cb = self.send_mcast_cb,
676 arg = igmpState1)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700677 src_ip = src2[0]
678 dst_mac = self.iptomac(groups1[0])
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700679 mcastTraffic2 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
680 src_ip = src_ip, cb = self.send_mcast_cb,
681 arg = igmpState2)
682 mcastTraffic1.start()
683 mcastTraffic2.start()
684 join_state1 = IGMPTestState(groups = groups1)
685 join_state2 = IGMPTestState(groups = groups2)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800686 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
A R Karthick76a497a2017-04-12 10:59:39 -0700687 log_test.info('Interface is receiving multicast groups %s' %groups1)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800688 self.igmp_recv_task(self.V_INF1, groups2, join_state2)
A R Karthick76a497a2017-04-12 10:59:39 -0700689 log_test.info('Interface is receiving multicast groups %s' %groups2)
690 log_test.info('Interface is sending leave message for groups %s now' %groups2)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700691 self.send_igmp_leave(groups = groups2, src_list = src2, iface = self.V_INF1, delay = 2)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800692 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700693 target4 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state2)
694 assert target4 == 1, 'EXPECTED FAILURE'
695 if again_join:
696 dst_mac = '01:00:5e:02:02:03'
697 ip_dst = '239.2.2.3'
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700698 eth = Ether(dst = dst_mac, type = ETH_P_IP)
699 ip = IP(dst = ip_dst)
A R Karthick76a497a2017-04-12 10:59:39 -0700700 log_test.info('Interface sending join message again for the groups %s' %groups2)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700701 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 -0800702 self.igmp_recv_task(self.V_INF1, groups2, join_state2)
A R Karthick76a497a2017-04-12 10:59:39 -0700703 log_test.info('Interface is receiving multicast groups %s again' %groups2)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800704 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
A R Karthick76a497a2017-04-12 10:59:39 -0700705 log_test.info('Interface is still receiving from multicast groups %s' %groups1)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700706 else:
A R Karthick76a497a2017-04-12 10:59:39 -0700707 log_test.info('Ended test case')
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700708 mcastTraffic1.stop()
709 mcastTraffic2.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -0700710
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700711
712 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700713 def test_igmp_2joins_1leave(self):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700714 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700715 def igmp_2joins_1leave():
716 groups = ['234.2.3.4','236.8.7.9']
717 src_list = ['2.3.4.5','5.4.3.2']
718 self.onos_ssm_table_load(groups,src_list = src_list)
719 self.igmp_joins_leave(groups,src_list,again_join = False, df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700720 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700721 reactor.callLater(0, igmp_2joins_1leave)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700722 return df
723
724 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+25)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700725 def test_igmp_2joins_1leave_and_join_again(self):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700726 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700727 def igmp_2joins_1leave_join_again():
728 groups = ['234.2.3.4','236.8.7.9']
729 src_list = ['2.3.4.5','5.4.3.2']
730 self.onos_ssm_table_load(groups,src_list = src_list)
731 self.igmp_joins_leave(groups,src_list,again_join = True, df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700732 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700733 reactor.callLater(0, igmp_2joins_1leave_join_again)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700734 return df
735
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700736 def igmp_not_in_src_list(self, df = None):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700737 groups1 = (self.MGROUP1,)
738 groups2 = (self.MGROUP2,)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700739 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 -0700740 self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
741 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
742 intf = self.V_INF1, delay = 2)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700743 src_ip = '6.6.6.6'
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700744 dst_mac = self.iptomac(groups1[0])
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700745 if df is None:
746 df = defer.Deferred()
747 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800748 IGMPTestState(groups = groups1, df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700749 mcastTraffic1 = McastTraffic(groups1, iface = 'veth2', dst_mac = dst_mac,
750 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
751 mcastTraffic1.start()
752 join_state1 = IGMPTestState(groups = groups1)
A R Karthick76a497a2017-04-12 10:59:39 -0700753 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 -0700754 target1 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
Chetan Gaonker7791bda2016-05-12 17:36:52 -0700755 assert target1 == 2, 'EXPECTED FAILURE'
A R Karthick76a497a2017-04-12 10:59:39 -0700756 log_test.info('Interface is not receiving traffic from multicast groups %s, working as expected' %groups1)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700757 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -0700758
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700759 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700760 def test_igmp_not_in_src_list(self):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700761 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700762 def igmp_not_in_src_list():
763 self.igmp_not_in_src_list(df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700764 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700765 reactor.callLater(0, igmp_not_in_src_list)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700766 return df
767
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700768 def igmp_change_to_exclude_src_list(self, df = None):
769 groups1 = [self.random_mcast_ip()]
770 groups2 = [self.random_mcast_ip()]
771 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 -0700772 self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
773 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
774 intf = self.V_INF1, delay = 2)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700775 src_ip = '2.2.2.2'
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700776 dst_mac=self.iptomac(groups1[0])
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700777 if df is None:
778 df = defer.Deferred()
779 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800780 IGMPTestState(groups = groups1, df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700781 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
782 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
783 mcastTraffic1.start()
784 join_state1 = IGMPTestState(groups = groups1)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800785 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700786 self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2'], iface = self.V_INF1, delay =2)
787 target2 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
Chetan Gaonker7791bda2016-05-12 17:36:52 -0700788 assert target2 == 2, 'EXPECTED FAILURE'
A R Karthick76a497a2017-04-12 10:59:39 -0700789 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 -0700790 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -0700791
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700792 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700793 def test_igmp_change_to_exclude_src_list(self):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700794 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700795 def igmp_change_to_exclude_src_list():
796 self.igmp_change_to_exclude_src_list(df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700797 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700798 reactor.callLater(0, igmp_change_to_exclude_src_list)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700799 return df
800
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700801 def igmp_include_to_allow_src_list(self, df = None):
802 groups1 = [self.random_mcast_ip()] #(self.MGROUP1,)
803 self.onos_ssm_table_load(groups1,src_list = ['4.4.4.4','6.6.6.6'])
804 self.send_igmp_join(groups = groups1, src_list = ['4.4.4.4'],record_type = IGMP_V3_GR_TYPE_INCLUDE,
805 iface = self.V_INF1)
806 src_ip = '4.4.4.4'
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700807 if df is None:
808 df = defer.Deferred()
809 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800810 IGMPTestState(groups = groups1, df = df)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700811 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2',src_ip = src_ip,
812 cb = self.send_mcast_cb, arg = igmpState1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700813 mcastTraffic1.start()
814 join_state1 = IGMPTestState(groups = groups1)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800815 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700816 mcastTraffic1.stop()
817 mcastTraffic2 = McastTraffic(groups1, iface= 'veth2',src_ip = '6.6.6.6',
818 cb = self.send_mcast_cb, arg = igmpState1)
819 self.send_igmp_join(groups = groups1, src_list = ['6.6.6.6'],record_type = IGMP_V3_GR_TYPE_ALLOW_NEW,
820 iface = self.V_INF1)
821 mcastTraffic2.start()
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800822 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700823 mcastTraffic2.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -0700824
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700825 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+30)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700826 def test_igmp_include_to_allow_src_list(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700827 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700828 def igmp_include_to_allow_src_list():
829 self.igmp_include_to_allow_src_list(df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700830 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700831 reactor.callLater(0, igmp_include_to_allow_src_list)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700832 return df
833
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700834 def igmp_include_to_block_src_list(self, df = None):
835 groups1 = [self.random_mcast_ip()] #groups1 = (self.MGROUP1,)
836 self.onos_ssm_table_load(groups1,src_list = ['4.4.4.4','6.6.6.6'])
837 self.send_igmp_join(groups = groups1, src_list = ['4.4.4.4','6.6.6.6'],record_type = IGMP_V3_GR_TYPE_INCLUDE,
838 iface = self.V_INF1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700839 if df is None:
840 df = defer.Deferred()
841 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800842 IGMPTestState(groups = groups1, df = df)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700843 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2',src_ip = '6.6.6.6',
844 cb = self.send_mcast_cb, arg = igmpState1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700845 mcastTraffic1.start()
846 join_state1 = IGMPTestState(groups = groups1)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800847 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700848 mcastTraffic1.stop()
849 self.send_igmp_join(groups = groups1, src_list = ['6.6.6.6'],record_type = IGMP_V3_GR_TYPE_BLOCK_OLD,
850 iface = self.V_INF1)
851 mcastTraffic2 = McastTraffic(groups1, iface= 'veth2',src_ip = '6.6.6.6',
852 cb = self.send_mcast_cb, arg = igmpState1)
853 mcastTraffic2.start()
854 target1 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
855 assert target1 == 1, 'EXPECTED FAILURE'
A R Karthick76a497a2017-04-12 10:59:39 -0700856 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 -0700857 mcastTraffic2.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -0700858
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700859 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+30)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700860 def test_igmp_include_to_block_src_list(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700861 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700862 def igmp_include_to_block_src_list():
863 self.igmp_include_to_block_src_list(df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700864 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700865 reactor.callLater(0, igmp_include_to_block_src_list)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700866 return df
867
868
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700869 def igmp_change_to_include_src_list(self, df = None):
870 groups1 = [self.random_mcast_ip()]
871 src_list = ['4.4.4.4','6.6.6.6']
872 self.onos_ssm_table_load(groups1,src_list = src_list)
873 self.send_igmp_leave(groups = groups1, src_list = src_list,
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700874 iface = self.V_INF1, delay = 2)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700875 if df is None:
876 df = defer.Deferred()
877 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800878 IGMPTestState(groups = groups1, df = df)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700879 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2',src_ip = src_list[0],
880 cb = self.send_mcast_cb, arg = igmpState1)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700881 mcastTraffic1.start()
882 join_state1 = IGMPTestState(groups = groups1)
883 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
884 assert target1 == 1, 'EXPECTED FAILURE'
A R Karthick76a497a2017-04-12 10:59:39 -0700885 log_test.info('Interface is not receiving traffic from multicast groups %s' %groups1)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700886 mcastTraffic1.stop()
887 self.send_igmp_join(groups = groups1, src_list = src_list,record_type = IGMP_V3_GR_TYPE_INCLUDE,
888 iface = self.V_INF1)
889 mcastTraffic2 = McastTraffic(groups1, iface= 'veth2',src_ip = src_list[1],
890 cb = self.send_mcast_cb, arg = igmpState1)
891 mcastTraffic2.start()
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800892 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700893 mcastTraffic2.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -0700894
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700895 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700896 def test_igmp_change_to_include_src_list(self):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700897 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700898 def igmp_change_to_include_src_list():
899 self.igmp_change_to_include_src_list(df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700900 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700901 reactor.callLater(0, igmp_change_to_include_src_list)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700902 return df
903
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700904 #this test case failing because group in include receiving multicast traffic from any of the source
905 def igmp_exclude_to_allow_src_list(self, df = None):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700906 groups1 = (self.MGROUP1,)
907 groups2 = (self.MGROUP2,)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700908 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 -0700909 self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4'],
910 iface = self.V_INF1, delay = 2)
A.R Karthick95d044e2016-06-10 18:44:36 -0700911
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700912 dst_mac = '01:00:5e:01:02:03'
913 src_ip = '2.2.2.2'
914 if df is None:
915 df = defer.Deferred()
916 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800917 IGMPTestState(groups = groups1, df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700918 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
919 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
920 mcastTraffic1.start()
921 join_state1 = IGMPTestState(groups = groups1)
922 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
923 assert target1 == 1, 'EXPECTED FAILURE'
A R Karthick76a497a2017-04-12 10:59:39 -0700924 log_test.info('Interface is not receiving traffic from multicast groups %s' %groups1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700925 self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
926 (['6.6.6.6', '7.7.7.7', '8.8.8.8'], ['6.6.6.6', '5.5.5.5']),
927 intf = self.V_INF1, delay = 2)
928 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
929 assert target1 == 1, 'EXPECTED FAILURE'
A R Karthick76a497a2017-04-12 10:59:39 -0700930 log_test.info('Interface is not receiving traffic from multicast groups %s' %groups1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700931 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -0700932
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700933 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700934 def test_igmp_exclude_to_allow_src_list(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700935 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700936 def igmp_exclude_to_allow_src_list():
937 self.igmp_exclude_to_allow_src_list(df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700938 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700939 reactor.callLater(0, igmp_exclude_to_allow_src_list)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700940 return df
941
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700942 def igmp_exclude_to_block_src_list(self, df = None):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700943 groups1 = (self.MGROUP1,)
944 groups2 = (self.MGROUP2,)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700945 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 -0700946 self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4'],
947 iface = self.V_INF1, delay = 2)
A.R Karthick95d044e2016-06-10 18:44:36 -0700948
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700949 dst_mac = '01:00:5e:01:02:03'
950 src_ip = '2.2.2.2'
951 if df is None:
952 df = defer.Deferred()
953 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800954 IGMPTestState(groups = groups1, df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700955 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
956 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
957 mcastTraffic1.start()
958 join_state1 = IGMPTestState(groups = groups1)
959 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
960 assert target1 == 1, 'EXPECTED FAILURE'
A R Karthick76a497a2017-04-12 10:59:39 -0700961 log_test.info('Interface is not receiving traffic from multicast groups %s' %groups1)
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', '5.5.5.5', '7.7.7.7'],
963 iface = self.V_INF1, delay = 2)
964 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
965 assert target1 == 1, 'EXPECTED FAILURE'
A R Karthick76a497a2017-04-12 10:59:39 -0700966 log_test.info('Interface is not receiving traffic from multicast groups %s' %groups1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700967 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -0700968
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700969 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700970 def test_igmp_exclude_to_block_src_list(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700971 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700972 def igmp_exclude_to_block_src_list():
973 self.igmp_exclude_to_block_src_list(df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700974 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700975 reactor.callLater(0, igmp_exclude_to_block_src_list)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700976 return df
977
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700978 #this test case failing because group in include mode recieves traffic from other sources also.
979 def igmp_new_src_list(self, df = None):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700980 groups1 = (self.MGROUP1,)
981 groups2 = (self.MGROUP2,)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700982 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 -0700983 self.igmp_send_joins_different_groups_srclist(groups1+groups2,
984 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
985 intf = self.V_INF1, delay = 2)
986 dst_mac = '01:00:5e:01:02:03'
987 src_ip = '6.6.6.6'
988 if df is None:
989 df = defer.Deferred()
990 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800991 IGMPTestState(groups = groups1, df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700992 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
993 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
994 mcastTraffic1.start()
995 join_state1 = IGMPTestState(groups = groups1)
996 target1 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
997 assert target1 == 1, 'EXPECTED FAILURE'
A R Karthick76a497a2017-04-12 10:59:39 -0700998 log_test.info('Interface is not receiving traffic from multicast groups %s' %groups1)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700999 self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001000 (['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 -07001001 intf = self.V_INF1, delay = 2)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001002 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
A R Karthick76a497a2017-04-12 10:59:39 -07001003 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 -07001004 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001005
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001006 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001007 def test_igmp_new_src_list(self):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001008 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001009 def igmp_new_src_list():
1010 self.igmp_new_src_list(df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001011 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001012 reactor.callLater(0, igmp_new_src_list)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001013 return df
1014
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001015 def igmp_block_old_src_list(self, df = None):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001016 groups1 = (self.MGROUP1,)
1017 groups2 = (self.MGROUP2,)
1018 groups = groups1 + groups2
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001019 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 -07001020 self.igmp_send_joins_different_groups_srclist(groups,
1021 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
1022 intf = self.V_INF1, delay = 2)
1023 dst_mac = '01:00:5e:02:02:03'
1024 src_ip = '5.5.5.5'
1025 if df is None:
1026 df = defer.Deferred()
1027 igmpState1 = IGMPTestState(groups = groups2, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001028 IGMPTestState(groups = groups2, df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001029 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1030 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1031 mcastTraffic1.start()
1032 join_state1 = IGMPTestState(groups = groups2)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001033 self.igmp_recv_task(self.V_INF1, groups2, join_state1)
A R Karthick76a497a2017-04-12 10:59:39 -07001034 log_test.info('Interface is receiving traffic from multicast groups %s' %groups2)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001035 self.igmp_send_joins_different_groups_srclist(groups,
1036 (['6.6.6.6', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '7.7.7.7']),
1037 intf = self.V_INF1, delay = 2)
1038 target2 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1)
Chetan Gaonker7791bda2016-05-12 17:36:52 -07001039 assert target2 == 2, 'EXPECTED FAILURE'
A R Karthick76a497a2017-04-12 10:59:39 -07001040 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 -07001041 mcastTraffic1.stop()
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001042
1043 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001044 def test_igmp_block_old_src_list(self):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001045 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001046 def igmp_block_old_src_list():
1047 self.igmp_block_old_src_list(df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001048 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001049 reactor.callLater(0, igmp_block_old_src_list)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001050 return df
1051
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001052 def igmp_include_empty_src_list(self, df = None):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001053 groups1 = (self.MGROUP1,)
1054 groups2 = (self.MGROUP2,)
1055 groups = groups1 + groups2
1056 self.igmp_send_joins_different_groups_srclist(groups,
Thangavelu K S790ad332016-12-14 12:54:58 +05301057 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['0']),
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001058 intf = self.V_INF1, delay = 2)
1059 dst_mac = '01:00:5e:02:02:03'
1060 src_ip = '5.5.5.5'
1061 if df is None:
1062 df = defer.Deferred()
1063 igmpState1 = IGMPTestState(groups = groups2, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001064 IGMPTestState(groups = groups2, df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001065 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1066 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1067 mcastTraffic1.start()
1068 join_state1 = IGMPTestState(groups = groups2)
1069 target1 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1)
1070 assert target1==1, 'EXPECTED FAILURE'
A R Karthick76a497a2017-04-12 10:59:39 -07001071 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 -07001072 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001073
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001074 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001075 def test_igmp_include_empty_src_list(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001076 ## '''Disabling this test as scapy IGMP doesn't work with empty source lists'''
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001077 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001078 def igmp_include_empty_src_list():
1079 self.igmp_include_empty_src_list(df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001080 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001081 reactor.callLater(0, igmp_include_empty_src_list)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001082 return df
1083
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001084 def igmp_exclude_empty_src_list(self, df = None):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001085 groups2 = (self.MGROUP2,)
Thangavelu K S790ad332016-12-14 12:54:58 +05301086 self.send_igmp_leave(groups = groups2, src_list = ['0'], iface = self.V_INF1, delay = 2)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001087 dst_mac = '01:00:5e:02:02:03'
1088 src_ip = '5.5.5.5'
1089 if df is None:
1090 df = defer.Deferred()
1091 igmpState1 = IGMPTestState(groups = groups2, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001092 IGMPTestState(groups = groups2, df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001093 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1094 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1095 mcastTraffic1.start()
1096 join_state1 = IGMPTestState(groups = groups2)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001097 self.igmp_recv_task(self.V_INF1, groups2, join_state1)
A R Karthick76a497a2017-04-12 10:59:39 -07001098 log_test.info('Interface is receiving multicast groups %s' %groups2)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001099 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001100
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001101 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001102 def test_igmp_exclude_empty_src_list(self):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001103 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001104 def igmp_exclude_empty_src_list():
1105 self.igmp_exclude_empty_src_list()
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001106 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001107 reactor.callLater(0, igmp_exclude_empty_src_list)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001108 return df
1109
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001110 def igmp_join_sourceip_0_0_0_0(self, df = None):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001111 groups1 = (self.MGROUP1,)
1112 groups2 = (self.MGROUP2,)
1113 groups = groups1 + groups2
1114 ip_src = '0.0.0.0'
1115 self.igmp_send_joins_different_groups_srclist(groups,
1116 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['5.5.5.5']),
1117 intf = self.V_INF1, delay = 2, ip_src = ip_src)
1118 ip_src = self.IP_SRC
1119 dst_mac = '01:00:5e:02:02:03'
1120 src_ip = '5.5.5.5'
1121 if df is None:
1122 df = defer.Deferred()
1123 igmpState1 = IGMPTestState(groups = groups2, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001124 IGMPTestState(groups = groups2, df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001125 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1126 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1127 mcastTraffic1.start()
1128 join_state1 = IGMPTestState(groups = groups2)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001129 self.igmp_recv_task(self.V_INF1, groups2, join_state1)
A R Karthick76a497a2017-04-12 10:59:39 -07001130 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 -07001131 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001132
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001133 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001134 def test_igmp_join_sourceip_0_0_0_0(self):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001135 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001136 def igmp_join_sourceip_0_0_0_0():
1137 self.igmp_join_sourceip_0_0_0_0(df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001138 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001139 reactor.callLater(0, igmp_join_sourceip_0_0_0_0)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001140 return df
1141
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001142 def igmp_invalid_join_packet(self, df = None):
Chetan Gaonker586fec32016-04-29 17:33:54 -07001143 groups1 = (self.MGROUP1,)
1144 groups2 = (self.MINVALIDGROUP1,)
1145 groups = groups1 + groups2
1146 ip_src = '1.1.1.1'
1147 self.igmp_send_joins_different_groups_srclist(groups,
1148 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['5.5.5.5']),
1149 intf = self.V_INF1, delay = 2, ip_src = ip_src)
1150 ip_src = self.IP_SRC
1151 dst_mac = '01:00:5e:02:02:03'
1152 src_ip = '5.5.5.5'
1153 if df is None:
1154 df = defer.Deferred()
1155 igmpState1 = IGMPTestState(groups = groups2, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001156 IGMPTestState(groups = groups2, df = df)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001157 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1158 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1159 mcastTraffic1.start()
1160 join_state1 = IGMPTestState(groups = groups2)
1161 target1 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1)
1162 assert target1==1, 'EXPECTED FAILURE'
A R Karthick76a497a2017-04-12 10:59:39 -07001163 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 -07001164 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001165
Chetan Gaonker586fec32016-04-29 17:33:54 -07001166 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001167 def test_igmp_invalid_join_packet(self):
Chetan Gaonker586fec32016-04-29 17:33:54 -07001168 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001169 def igmp_invalid_join_packet():
1170 self.igmp_invalid_join_packet(df = df)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001171 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001172 reactor.callLater(0, igmp_invalid_join_packet)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001173 return df
1174
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001175 def igmp_join_data_receiving_during_subscriber_link_toggle(self, df = None):
Chetan Gaonker586fec32016-04-29 17:33:54 -07001176 groups1 = (self.MGROUP1,)
1177 groups2 = (self.MGROUP2,)
1178 groups = groups1 + groups2
1179 ip_src = '1.1.1.1'
1180 self.igmp_send_joins_different_groups_srclist(groups,
1181 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['5.5.5.5']),
1182 intf = self.V_INF1, delay = 2, ip_src = ip_src)
1183 ip_src = self.IP_SRC
1184 dst_mac = '01:00:5e:02:02:03'
1185 src_ip = '5.5.5.5'
1186 if df is None:
1187 df = defer.Deferred()
1188 igmpState1 = IGMPTestState(groups = groups2, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001189 IGMPTestState(groups = groups2, df = df)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001190 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1191 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1192 mcastTraffic1.start()
1193 join_state1 = IGMPTestState(groups = groups2)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001194 self.igmp_recv_task(self.V_INF1, groups2, join_state1)
A R Karthick76a497a2017-04-12 10:59:39 -07001195 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 -07001196 os.system('ifconfig '+self.V_INF1+' down')
A R Karthick76a497a2017-04-12 10:59:39 -07001197 log_test.info(' the self.V_INF1 %s is down now ' %self.V_INF1)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001198 os.system('ifconfig '+self.V_INF1)
1199 time.sleep(10)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001200 os.system('ifconfig '+self.V_INF1+' up')
1201 os.system('ifconfig '+self.V_INF1)
A R Karthick76a497a2017-04-12 10:59:39 -07001202 log_test.info(' the self.V_INF1 %s is up now ' %self.V_INF1)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001203 self.igmp_recv_task(self.V_INF1, groups2, join_state1)
A R Karthick76a497a2017-04-12 10:59:39 -07001204 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 -07001205 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001206
Chetan Gaonker586fec32016-04-29 17:33:54 -07001207 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001208 def test_igmp_join_data_received_during_subscriber_link_toggle(self):
Chetan Gaonker586fec32016-04-29 17:33:54 -07001209 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001210 def igmp_join_data_received_during_subscriber_link_toggle():
1211 self.igmp_join_data_received_during_subscriber_link_toggle(df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001212 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001213 reactor.callLater(0, igmp_join_data_received_during_subscriber_link_toggle)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001214 return df
1215
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001216 def igmp_join_data_received_during_channel_distributor_link_toggle(self, df = None):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001217 groups1 = (self.MGROUP1,)
1218 groups2 = (self.MGROUP2,)
1219 groups = groups1 + groups2
1220 ip_src = '1.1.1.1'
1221 self.igmp_send_joins_different_groups_srclist(groups,
1222 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['5.5.5.5', '6.6.6.6']),
1223 intf = self.V_INF1, delay = 2, ip_src = ip_src)
1224 ip_src = self.IP_SRC
1225 dst_mac1 = '01:00:5e:01:02:03'
1226 dst_mac2 = '01:00:5e:02:02:03'
1227 src_ip2 = '5.5.5.5'
1228 src_ip1 = '2.2.2.2'
1229 if df is None:
1230 df = defer.Deferred()
1231 igmpState1 = IGMPTestState(groups = groups1, df = df)
1232 igmpState2 = IGMPTestState(groups = groups2, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001233 IGMPTestState(groups = groups1, df = df)
1234 IGMPTestState(groups = groups2, df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001235 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac1,
1236 src_ip = src_ip1, cb = self.send_mcast_cb, arg = igmpState1)
1237 mcastTraffic2 = McastTraffic(groups2, iface= 'veth3', dst_mac = dst_mac2,
1238 src_ip = src_ip2, cb = self.send_mcast_cb, arg = igmpState2)
1239 mcastTraffic1.start()
1240 mcastTraffic2.start()
1241 join_state1 = IGMPTestState(groups = groups1)
1242 join_state2 = IGMPTestState(groups = groups2)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001243 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
1244 self.igmp_recv_task(self.V_INF1, groups2, join_state2)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001245 mcastTraffic1.stop()
1246 os.system('ifconfig '+'veth2'+' down')
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001247 os.system('ifconfig '+'veth2')
1248 time.sleep(10)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001249 self.igmp_not_recv_task(self.V_INF1, groups2, join_state1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001250 target1 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
1251 assert target1==1, 'EXPECTED FAILURE'
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001252 os.system('ifconfig '+'veth2'+' up')
1253 os.system('ifconfig '+'veth2')
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001254 time.sleep(10)
1255 mcastTraffic1.start()
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001256 self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
1257 self.igmp_recv_task(self.V_INF1, groups2, join_state2)
1258 self.igmp_recv_task(self.V_INF1, groups2, join_state2)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001259 mcastTraffic2.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001260
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001261 ## This test case is failing to receive traffic from multicast data from defferent channel interfaces TO-DO
1262 ###### TO DO scenario #######
1263 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+60)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001264 def test_igmp_join_data_received_during_channel_distributors_link_toggle(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001265 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001266 def igmp_join_data_receiving_during_channel_distributor_link_toggle():
Thangavelu K S790ad332016-12-14 12:54:58 +05301267 self.igmp_join_data_received_during_channel_distributor_link_toggle(df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001268 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001269 reactor.callLater(0, igmp_join_data_receiving_during_channel_distributor_link_toggle)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001270 return df
Chetan Gaonker586fec32016-04-29 17:33:54 -07001271
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001272 def igmp_invalidClassD_IP_join_packet(self, df = None):
Chetan Gaonker586fec32016-04-29 17:33:54 -07001273 groups1 = (self.MGROUP1,)
1274 groups2 = (self.MINVALIDGROUP2,)
1275 groups = groups1 + groups2
1276 ip_src = '1.1.1.1'
1277 self.igmp_send_joins_different_groups_srclist(groups,
1278 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['5.5.5.5']),
1279 intf = self.V_INF1, delay = 2, ip_src = ip_src)
1280 ip_src = self.IP_SRC
1281 dst_mac = '01:00:5e:02:02:03'
1282 src_ip = '5.5.5.5'
1283 if df is None:
1284 df = defer.Deferred()
1285 igmpState1 = IGMPTestState(groups = groups2, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001286 IGMPTestState(groups = groups2, df = df)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001287 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1288 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1289 mcastTraffic1.start()
1290 join_state1 = IGMPTestState(groups = groups2)
1291 target1 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1)
1292 assert target1==1, 'EXPECTED FAILURE'
A R Karthick76a497a2017-04-12 10:59:39 -07001293 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 -07001294 mcastTraffic1.stop()
Chetan Gaonker586fec32016-04-29 17:33:54 -07001295
1296 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001297 def test_igmp_invalid_class_d_ip_for_join_packet(self):
Chetan Gaonker586fec32016-04-29 17:33:54 -07001298 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001299 def igmp_invalidClass_D_IP_join_packet():
Thangavelu K S790ad332016-12-14 12:54:58 +05301300 self.igmp_invalidClassD_IP_join_packet(df = df)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001301 df.callback(0)
Thangavelu K S790ad332016-12-14 12:54:58 +05301302 reactor.callLater(0, igmp_invalidClass_D_IP_join_packet)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001303 return df
1304
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001305 def igmp_invalidClassD_IP_as_srclistIP_join_packet(self, df = None):
Chetan Gaonker586fec32016-04-29 17:33:54 -07001306 groups1 = (self.MGROUP1,)
1307 groups2 = (self.MGROUP2,)
1308 groups = groups1 + groups2
1309 ip_src = '1.1.1.1'
1310 self.igmp_send_joins_different_groups_srclist(groups,
1311 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['239.5.5.5']),
1312 intf = self.V_INF1, delay = 2, ip_src = ip_src)
1313 ip_src = self.IP_SRC
1314 dst_mac = '01:00:5e:02:02:03'
1315 src_ip = '5.5.5.5'
1316 if df is None:
1317 df = defer.Deferred()
1318 igmpState1 = IGMPTestState(groups = groups2, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001319 IGMPTestState(groups = groups2, df = df)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001320 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1321 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1322 mcastTraffic1.start()
1323 join_state1 = IGMPTestState(groups = groups2)
1324 target1 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1)
1325 assert target1==1, 'EXPECTED FAILURE'
A R Karthick76a497a2017-04-12 10:59:39 -07001326 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 -07001327 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001328
Chetan Gaonker586fec32016-04-29 17:33:54 -07001329 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001330 def test_igmp_invalid_class_d_ip_as_srclist_ip_for_join_packet(self):
Chetan Gaonker586fec32016-04-29 17:33:54 -07001331 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001332 def igmp_invalidClassD_IP_as_srclistIP_join_packet():
1333 self.igmp_invalidClassD_IP_as_srclistIP_join_packet(df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001334 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001335 reactor.callLater(0, igmp_invalidClassD_IP_as_srclistIP_join_packet)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001336 return df
Chetan Gaonkerf72ca402016-05-02 16:29:32 -07001337
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001338 def igmp_general_query_recv_packet(self, df = None):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001339 groups1 = (self.MGROUP1,)
1340 groups2 = (self.MGROUP2,)
1341 groups = groups1 + groups2
1342 ip_src = '1.1.1.1'
1343 self.igmp_send_joins_different_groups_srclist(groups,
1344 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['5.5.5.5']),
1345 intf = self.V_INF1, delay = 2, ip_src = ip_src)
1346 ip_src = self.IP_SRC
1347 dst_mac = '01:00:5e:02:02:03'
1348 src_ip = '5.5.5.5'
1349 if df is None:
1350 df = defer.Deferred()
1351 igmpState1 = IGMPTestState(groups = groups2, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001352 IGMPTestState(groups = groups2, df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001353 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1354 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1355 mcastTraffic1.start()
1356 join_state1 = IGMPTestState(groups = groups2)
A R Karthick76a497a2017-04-12 10:59:39 -07001357 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 -07001358 time.sleep(100)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001359 self.igmp_recv_task(self.V_INF1, groups2, join_state1)
A R Karthick76a497a2017-04-12 10:59:39 -07001360 log_test.info('Verified that multicast data for group %s is received after 100 sec ' %groups2)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001361 time.sleep(50)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001362 self.igmp_recv_task(self.V_INF1, groups2, join_state1)
A R Karthick76a497a2017-04-12 10:59:39 -07001363 log_test.info('Verified that multicast data for group %s is received after 150 sec ' %groups2)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001364 time.sleep(30)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001365 self.igmp_recv_task(self.V_INF1, groups2, join_state1)
A R Karthick76a497a2017-04-12 10:59:39 -07001366 log_test.info('Verified that multicast data for group %s is received after 180 sec ' %groups2)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001367 time.sleep(10)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001368 self.igmp_recv_task(self.V_INF1, groups2, join_state1)
A R Karthick76a497a2017-04-12 10:59:39 -07001369 log_test.info('Verified that multicast data for group %s is received after 190 sec ' %groups2)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001370 target3 = mcastTraffic1.isRecvStopped()
1371 assert target3==False, 'EXPECTED FAILURE'
A R Karthick76a497a2017-04-12 10:59:39 -07001372 log_test.info('Verified that multicast data for a group %s is still transmitting from a data interface' %groups2)
1373 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 -07001374 target1 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1)
1375 assert target1==1, 'EXPECTED FAILURE'
A R Karthick76a497a2017-04-12 10:59:39 -07001376 log_test.info('Interface is not receiving multicast data for group %s' %groups2)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001377 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001378
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001379 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+250)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001380 def test_igmp_general_query_received_traffic(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001381 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001382 def igmp_general_query_recv_packet():
1383 self.igmp_general_query_recv_packet(df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001384 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001385 reactor.callLater(0, igmp_general_query_recv_packet)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001386 return df
A.R Karthick95d044e2016-06-10 18:44:36 -07001387
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001388 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+100)
1389 def test_igmp_query_received_on_joining_interface(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001390 groups = ['224.0.1.10', '225.0.0.10']
1391 leave_groups = ['224.0.1.10']
1392 df = defer.Deferred()
1393 igmpState = IGMPTestState(groups = groups, df = df)
1394 igmpStateRecv = IGMPTestState(groups = groups, df = df)
1395 igmpStateList = (igmpState, igmpStateRecv)
A.R Karthick95d044e2016-06-10 18:44:36 -07001396 mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb,
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001397 arg = igmpState)
1398 self.df = df
1399 self.mcastTraffic = mcastTraffic
1400 self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP)
A.R Karthick95d044e2016-06-10 18:44:36 -07001401
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001402 def igmp_srp_task(stateList):
1403 igmpSendState, igmpRecvState = stateList
1404 if not mcastTraffic.isRecvStopped():
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001405 self.igmp_recv(igmpRecvState)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001406 reactor.callLater(0, igmp_srp_task, stateList)
1407 else:
1408 self.mcastTraffic.stop()
1409 self.recv_socket.close()
1410 self.igmp_verify_leave(stateList, leave_groups)
1411 self.df.callback(0)
1412
A R Karthick76a497a2017-04-12 10:59:39 -07001413 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 -07001414 self.send_igmp_join_recvQuery(groups)
A R Karthick76a497a2017-04-12 10:59:39 -07001415 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 -07001416 mcastTraffic.start()
1417 self.test_timer = reactor.callLater(self.MCAST_TRAFFIC_TIMEOUT, self.mcast_traffic_timer)
1418 reactor.callLater(0, igmp_srp_task, igmpStateList)
1419 return df
1420
1421 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+190)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001422 def test_igmp_for_periodic_query_received_on_joining_interface(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001423 groups = ['224.0.1.10', '225.0.0.10']
1424 leave_groups = ['224.0.1.10']
1425 df = defer.Deferred()
1426 igmpState = IGMPTestState(groups = groups, df = df)
A.R Karthick95d044e2016-06-10 18:44:36 -07001427 mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb,
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001428 arg = igmpState)
1429 self.df = df
1430 self.mcastTraffic = mcastTraffic
1431 self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP)
A.R Karthick95d044e2016-06-10 18:44:36 -07001432
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001433 def igmp_srp_task(stateList):
1434 igmpSendState, igmpRecvState = stateList
1435 if not mcastTraffic.isRecvStopped():
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001436 self.igmp_recv(igmpRecvState)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001437 reactor.callLater(0, igmp_srp_task, stateList)
1438 else:
1439 self.mcastTraffic.stop()
1440 self.recv_socket.close()
1441 self.igmp_verify_leave(stateList, leave_groups)
1442 self.df.callback(0)
1443
1444 self.send_igmp_join_recvQuery(groups,3)
1445 return df
1446
1447 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+190)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001448 def test_igmp_for_periodic_query_received_and_checking_entry_deleted(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001449 groups = ['224.0.1.10', '225.0.0.10']
1450 leave_groups = ['224.0.1.10']
1451 df = defer.Deferred()
1452 igmpState = IGMPTestState(groups = groups, df = df)
1453 igmpStateRecv = IGMPTestState(groups = groups, df = df)
1454 igmpStateList = (igmpState, igmpStateRecv)
A.R Karthick95d044e2016-06-10 18:44:36 -07001455 mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb,
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001456 arg = igmpState)
1457 self.df = df
1458 self.mcastTraffic = mcastTraffic
1459 self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP)
A.R Karthick95d044e2016-06-10 18:44:36 -07001460
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001461 def igmp_srp_task(stateList):
1462 igmpSendState, igmpRecvState = stateList
1463 if not mcastTraffic.isRecvStopped():
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001464 self.igmp_recv(igmpRecvState)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001465 reactor.callLater(0, igmp_srp_task, stateList)
1466 else:
1467 self.mcastTraffic.stop()
1468 self.recv_socket.close()
1469 self.igmp_verify_leave(stateList, leave_groups)
1470 self.df.callback(0)
1471
1472 self.send_igmp_join_recvQuery(groups,3)
A R Karthick76a497a2017-04-12 10:59:39 -07001473 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 -07001474 mcastTraffic.start()
1475 self.test_timer = reactor.callLater(self.MCAST_TRAFFIC_TIMEOUT, self.mcast_traffic_timer)
1476 reactor.callLater(0, igmp_srp_task, igmpStateList)
1477 return df
1478
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001479 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+190)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001480 def test_igmp_member_query_interval_and_expiry_for_rejoining_interface(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001481 groups = ['224.0.1.10', '225.0.0.10']
1482 leave_groups = ['224.0.1.10']
1483 df = defer.Deferred()
1484 igmpState = IGMPTestState(groups = groups, df = df)
1485 igmpStateRecv = IGMPTestState(groups = groups, df = df)
1486 igmpStateList = (igmpState, igmpStateRecv)
A.R Karthick95d044e2016-06-10 18:44:36 -07001487 mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb,
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001488 arg = igmpState)
1489 self.df = df
1490 self.mcastTraffic = mcastTraffic
1491 self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP)
A.R Karthick95d044e2016-06-10 18:44:36 -07001492
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001493 def igmp_srp_task(stateList):
1494 igmpSendState, igmpRecvState = stateList
1495 if not mcastTraffic.isRecvStopped():
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001496 self.igmp_recv(igmpRecvState)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001497 reactor.callLater(0, igmp_srp_task, stateList)
1498 else:
1499 self.mcastTraffic.stop()
1500 self.recv_socket.close()
1501 self.igmp_verify_leave(stateList, leave_groups)
1502 self.df.callback(0)
1503
1504 self.send_igmp_join_recvQuery(groups,3)
A R Karthick76a497a2017-04-12 10:59:39 -07001505 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 -07001506 self.send_igmp_join(groups)
1507 mcastTraffic.start()
1508 self.test_timer = reactor.callLater(self.MCAST_TRAFFIC_TIMEOUT, self.mcast_traffic_timer)
1509 reactor.callLater(0, igmp_srp_task, igmpStateList)
1510 return df
1511
1512 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+50)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001513 def test_igmp_leave_received_group_and_source_specific_query(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001514 groups = ['224.0.1.10', '225.0.0.10']
1515 leave_groups = ['224.0.1.10']
1516 df = defer.Deferred()
1517 igmpState = IGMPTestState(groups = groups, df = df)
A.R Karthick95d044e2016-06-10 18:44:36 -07001518 mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb,
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001519 arg = igmpState)
1520 self.df = df
1521 self.mcastTraffic = mcastTraffic
1522 self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP)
A.R Karthick95d044e2016-06-10 18:44:36 -07001523
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001524 def igmp_srp_task(stateList):
1525 igmpSendState, igmpRecvState = stateList
1526 if not mcastTraffic.isRecvStopped():
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001527 self.igmp_recv(igmpRecvState)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001528 reactor.callLater(0, igmp_srp_task, stateList)
1529 else:
1530 self.mcastTraffic.stop()
1531 self.recv_socket.close()
1532 self.igmp_verify_leave(stateList, leave_groups)
1533 self.df.callback(0)
1534
1535 self.send_igmp_join(groups)
1536 self.send_igmp_leave_listening_group_specific_query(leave_groups, delay = 3)
1537 return df
1538
1539 def igmp_change_to_exclude_src_list_check_for_group_source_specific_query(self, df = None):
1540 groups1 = (self.MGROUP1,)
1541 groups2 = (self.MGROUP2,)
1542 self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
1543 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
1544 intf = self.V_INF1, delay = 2)
1545 dst_mac = '01:00:5e:01:02:03'
1546 src_ip = '2.2.2.2'
1547 if df is None:
1548 df = defer.Deferred()
1549 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001550 IGMPTestState(groups = groups1, df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001551 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
1552 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1553 mcastTraffic1.start()
1554 join_state1 = IGMPTestState(groups = groups1)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001555 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001556 self.send_igmp_leave_listening_group_specific_query(groups = groups1, src_list = ['2.2.2.2'], iface = self.V_INF1, delay =2)
1557 time.sleep(10)
1558 target2 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
1559 assert target2 == 1, 'EXPECTED FAILURE'
A R Karthick76a497a2017-04-12 10:59:39 -07001560 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 -07001561 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001562
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001563 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+60)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001564 def test_igmp_change_to_exclude_src_list_and_check_for_group_source_specific_query(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001565 df = defer.Deferred()
1566 def igmp_change_to_exclude_src_list_check_for_group_source_specific_query():
1567 self.igmp_change_to_exclude_src_list_check_for_group_source_specific_query(df = df)
1568 df.callback(0)
1569 reactor.callLater(0, igmp_change_to_exclude_src_list_check_for_group_source_specific_query)
1570 return df
1571
1572 def igmp_change_to_include_src_list_check_for_general_query(self, df = None):
1573 groups1 = (self.MGROUP1,)
1574 groups2 = (self.MGROUP2,)
1575 self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4'],
1576 iface = self.V_INF1, delay = 2)
1577 dst_mac = '01:00:5e:01:02:03'
1578 src_ip = '2.2.2.2'
1579 if df is None:
1580 df = defer.Deferred()
1581 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001582 IGMPTestState(groups = groups1, df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001583 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
1584 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1585 mcastTraffic1.start()
1586 join_state1 = IGMPTestState(groups = groups1)
1587 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
1588 assert target1 == 1, 'EXPECTED FAILURE'
A R Karthick76a497a2017-04-12 10:59:39 -07001589 log_test.info('Interface is not receiving traffic from multicast groups %s' %groups1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001590 self.igmp_send_joins_different_groups_srclist_wait_query_packets(groups1 + groups2,
1591 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['6.6.6.6', '5.5.5.5']),
1592 intf = self.V_INF1, delay = 2,query_group1 = 'group1', query_group2 = None)
1593 time.sleep(10)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001594 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
A R Karthick76a497a2017-04-12 10:59:39 -07001595 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 -07001596 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001597
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001598 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+80)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001599 def test_igmp_change_to_include_src_list_and_check_for_general_query(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001600 df = defer.Deferred()
1601 def igmp_change_to_include_src_list_check_for_general_query():
1602 self.igmp_change_to_include_src_list_check_for_general_query(df = df)
1603 df.callback(0)
1604 reactor.callLater(0, igmp_change_to_include_src_list_check_for_general_query)
1605 return df
1606
1607 def igmp_allow_new_src_list_check_for_general_query(self, df = None):
1608 groups1 = (self.MGROUP1,)
1609 groups2 = (self.MGROUP2,)
1610 self.igmp_send_joins_different_groups_srclist(groups1+groups2,
1611 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
1612 intf = self.V_INF1, delay = 2)
1613 dst_mac = '01:00:5e:01:02:03'
1614 src_ip = '6.6.6.6'
1615 if df is None:
1616 df = defer.Deferred()
1617 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001618 IGMPTestState(groups = groups1, df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001619 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
1620 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1621 mcastTraffic1.start()
1622 join_state1 = IGMPTestState(groups = groups1)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001623 self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
A R Karthick76a497a2017-04-12 10:59:39 -07001624 log_test.info('Interface is not receiving traffic from multicast groups %s' %groups1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001625 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']),
1626 intf = self.V_INF1, delay = 2, query_group1 = 'group1', query_group2 = None)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001627 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
A R Karthick76a497a2017-04-12 10:59:39 -07001628 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 -07001629 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001630
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001631 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+80)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001632 def test_igmp_allow_new_src_list_and_check_for_general_query(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001633 df = defer.Deferred()
1634 def igmp_allow_new_src_list_check_for_general_query():
1635 self.igmp_allow_new_src_list_check_for_general_query(df = df)
1636 df.callback(0)
1637 reactor.callLater(0, igmp_allow_new_src_list_check_for_general_query)
1638 return df
1639
1640 def igmp_block_old_src_list_check_for_group_source_specific_query(self, df = None):
1641 groups1 = (self.MGROUP1,)
1642 groups2 = (self.MGROUP2,)
1643 groups = groups1 + groups2
1644 self.igmp_send_joins_different_groups_srclist(groups,
1645 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
1646 intf = self.V_INF1, delay = 2)
1647 dst_mac = '01:00:5e:02:02:03'
1648 src_ip = '5.5.5.5'
1649 if df is None:
1650 df = defer.Deferred()
1651 igmpState1 = IGMPTestState(groups = groups2, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001652 IGMPTestState(groups = groups2, df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001653 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1654 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1655 mcastTraffic1.start()
1656 join_state1 = IGMPTestState(groups = groups2)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001657 self.igmp_recv_task(self.V_INF1, groups2, join_state1)
A R Karthick76a497a2017-04-12 10:59:39 -07001658 log_test.info('Interface is receiving traffic from multicast groups %s' %groups2)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001659 self.igmp_send_joins_different_groups_srclist_wait_query_packets(groups,
1660 (['6.6.6.6', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '7.7.7.7']),
1661 intf = self.V_INF1, delay = 2, query_group1 = 'group1', query_group2 = None)
1662 target2 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1)
1663 assert target2 == 1, 'EXPECTED FAILURE'
A R Karthick76a497a2017-04-12 10:59:39 -07001664 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 -07001665 mcastTraffic1.stop()
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001666
1667 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+90)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001668 def test_igmp_block_old_src_list_and_check_for_group_source_specific_query(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001669 df = defer.Deferred()
1670 def igmp_block_old_src_list_check_for_group_source_specific_query():
1671 self.igmp_block_old_src_list_check_for_group_source_specific_query(df = df)
1672 df.callback(0)
1673 reactor.callLater(0, igmp_block_old_src_list_check_for_group_source_specific_query)
1674 return df
1675
1676 def igmp_include_to_allow_src_list_check_for_general_query(self, df = None):
1677 groups1 = (self.MGROUP1,)
1678 groups2 = (self.MGROUP2,)
1679 self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
1680 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
1681 intf = self.V_INF1, delay = 2)
1682 dst_mac = '01:00:5e:01:02:03'
1683 src_ip = '2.2.2.2'
1684 if df is None:
1685 df = defer.Deferred()
1686 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001687 IGMPTestState(groups = groups1, df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001688 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
1689 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1690 mcastTraffic1.start()
1691 join_state1 = IGMPTestState(groups = groups1)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001692 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001693 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 -08001694 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001695 mcastTraffic1.stop()
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001696
1697 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+40)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001698 def test_igmp_include_to_allow_src_list_and_check_for_general_query(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001699 df = defer.Deferred()
1700 def igmp_include_to_allow_src_list_check_for_general_query():
1701 self.igmp_include_to_allow_src_list_check_for_general_query(df = df)
1702 df.callback(0)
1703 reactor.callLater(0, igmp_include_to_allow_src_list_check_for_general_query)
1704 return df
1705
1706 def igmp_include_to_block_src_list_check_for_group_source_specific_query(self, df = None):
1707 groups1 = (self.MGROUP1,)
1708 groups2 = (self.MGROUP2,)
1709 self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
1710 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
1711 intf = self.V_INF1, delay = 2)
1712 dst_mac = '01:00:5e:01:02:03'
1713 src_ip = '2.2.2.2'
1714 if df is None:
1715 df = defer.Deferred()
1716 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001717 IGMPTestState(groups = groups1, df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001718 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
1719 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1720 mcastTraffic1.start()
1721 join_state1 = IGMPTestState(groups = groups1)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001722 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001723 self.send_igmp_leave_listening_group_specific_query(groups = groups1, src_list = ['6.6.6.6','7.7.7.7'],
1724 iface = self.V_INF1, delay = 2)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001725 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001726 mcastTraffic1.stop()
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001727
1728 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+40)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001729 def test_igmp_include_to_block_src_list_and_check_for_group_source_specific_query(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001730 df = defer.Deferred()
1731 def igmp_include_to_block_src_list_check_for_group_source_specific_query():
1732 self.igmp_include_to_block_src_list_check_for_group_source_specific_query(df = df)
1733 df.callback(0)
1734 reactor.callLater(0, igmp_include_to_block_src_list_check_for_group_source_specific_query)
1735 return df
1736
1737 def igmp_exclude_to_allow_src_list_check_for_general_query(self, df = None):
1738 groups1 = (self.MGROUP1,)
1739 groups2 = (self.MGROUP2,)
1740 self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4'],
1741 iface = self.V_INF1, delay = 2)
A.R Karthick95d044e2016-06-10 18:44:36 -07001742
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001743 dst_mac = '01:00:5e:01:02:03'
1744 src_ip = '2.2.2.2'
1745 if df is None:
1746 df = defer.Deferred()
1747 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001748 IGMPTestState(groups = groups1, df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001749 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
1750 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1751 mcastTraffic1.start()
1752 join_state1 = IGMPTestState(groups = groups1)
1753 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
1754 assert target1 == 1, 'EXPECTED FAILURE'
A R Karthick76a497a2017-04-12 10:59:39 -07001755 log_test.info('Interface is not receiving traffic from multicast groups %s' %groups1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001756 self.igmp_send_joins_different_groups_srclist_wait_query_packets(groups1 + groups2,
1757 (['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)
1758 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
1759 assert target1 == 1, 'EXPECTED FAILURE'
A R Karthick76a497a2017-04-12 10:59:39 -07001760 log_test.info('Interface is not receiving traffic from multicast groups %s' %groups1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001761 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001762
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001763 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+90)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001764 def test_igmp_exclude_to_allow_src_list_and_check_for_general_query(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001765 df = defer.Deferred()
1766 def igmp_exclude_to_allow_src_list_check_for_general_query():
1767 self.igmp_exclude_to_allow_src_list_check_for_general_query(df = df)
1768 df.callback(0)
1769 reactor.callLater(0, igmp_exclude_to_allow_src_list_check_for_general_query)
1770 return df
1771
1772 def igmp_exclude_to_block_src_list_check_for_group_source_specific_query(self, df = None):
1773 groups1 = (self.MGROUP1,)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001774 self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4'],
1775 iface = self.V_INF1, delay = 2)
A.R Karthick95d044e2016-06-10 18:44:36 -07001776
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001777 dst_mac = '01:00:5e:01:02:03'
1778 src_ip = '2.2.2.2'
1779 if df is None:
1780 df = defer.Deferred()
1781 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001782 IGMPTestState(groups = groups1, df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001783 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
1784 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1785 mcastTraffic1.start()
1786 join_state1 = IGMPTestState(groups = groups1)
1787 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
1788 assert target1 == 1, 'EXPECTED FAILURE'
A R Karthick76a497a2017-04-12 10:59:39 -07001789 log_test.info('Interface is not receiving traffic from multicast groups %s' %groups1)
A.R Karthick95d044e2016-06-10 18:44:36 -07001790 self.send_igmp_leave_listening_group_specific_query(groups = groups1,
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001791 src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4', '5.5.5.5', '7.7.7.7'],
1792 iface = self.V_INF1, delay = 2)
1793 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
1794 assert target1 == 1, 'EXPECTED FAILURE'
A R Karthick76a497a2017-04-12 10:59:39 -07001795 log_test.info('Interface is not receiving traffic from multicast groups %s' %groups1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001796 mcastTraffic1.stop()
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001797
1798 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+40)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001799 def test_igmp_exclude_to_block_src_list_and_check_for_group_source_specific_query(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001800 df = defer.Deferred()
1801 def igmp_exclude_to_block_src_list_check_for_group_source_specific_query():
1802 self.igmp_exclude_to_block_src_list_check_for_group_source_specific_query(df = df)
1803 df.callback(0)
1804 reactor.callLater(0, igmp_exclude_to_block_src_list_check_for_group_source_specific_query)
1805 return df
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001806
1807 def iptomac(self, mcast_ip):
1808 mcast_mac = '01:00:5e:'
1809 octets = mcast_ip.split('.')
1810 second_oct = int(octets[1]) & 127
1811 third_oct = int(octets[2])
1812 fourth_oct = int(octets[3])
1813 mcast_mac = mcast_mac + format(second_oct,'02x') + ':' + format(third_oct, '02x') + ':' + format(fourth_oct, '02x')
1814 return mcast_mac
1815
1816 def send_multicast_data_traffic(self, group, intf= 'veth2',source = '1.2.3.4'):
1817 dst_mac = self.iptomac(group)
1818 eth = Ether(dst= dst_mac)
1819 ip = IP(dst=group,src=source)
1820 data = repr(monotonic.monotonic())
1821 sendp(eth/ip/data,count=20, iface = intf)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001822
1823 def verify_igmp_data_traffic(self, group, intf='veth0', source='1.2.3.4' ):
A R Karthick76a497a2017-04-12 10:59:39 -07001824 log_test.info('verifying multicast traffic for group %s from source %s'%(group,source))
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001825 self.success = False
1826 def recv_task():
1827 def igmp_recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -07001828 #log_test.info('received multicast data packet is %s'%pkt.show())
1829 log_test.info('multicast data received for group %s from source %s'%(group,source))
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001830 self.success = True
1831 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')
1832 t = threading.Thread(target = recv_task)
1833 t.start()
1834 self.send_multicast_data_traffic(group,source=source)
1835 t.join()
1836 return self.success
1837
1838 def test_igmp_include_exclude_modes(self):
1839 groups = ['224.2.3.4','230.5.6.7']
1840 src_list = ['2.2.2.2','3.3.3.3']
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001841 self.onos_ssm_table_load(groups, src_list=src_list)
1842 self.send_igmp_join(groups = [groups[0]], src_list = src_list,record_type = IGMP_V3_GR_TYPE_INCLUDE,
1843 iface = self.V_INF1, delay = 2)
1844 self.send_igmp_join(groups = [groups[1]], src_list = src_list,record_type = IGMP_V3_GR_TYPE_EXCLUDE,
1845 iface = self.V_INF1, delay = 2)
1846 status = self.verify_igmp_data_traffic(groups[0],intf=self.V_INF1,source=src_list[0])
1847 assert_equal(status,True)
1848 status = self.verify_igmp_data_traffic(groups[1],intf = self.V_INF1,source= src_list[1])
1849 assert_equal(status,False)
1850
1851 def test_igmp_allow_new_source_mode(self):
1852 group = ['224.8.9.3']
1853 src_list = ['2.2.2.2','3.3.3.3']
1854 #dst_mac = self.iptomac(group[0])
1855 self.onos_ssm_table_load(group, src_list)
1856 self.send_igmp_join(groups = group, src_list = src_list[0],record_type = IGMP_V3_GR_TYPE_INCLUDE,
1857 iface = self.V_INF1, delay = 1)
1858 status = self.verify_igmp_data_traffic(group[0], intf=self.V_INF1,source = src_list[0])
1859 assert_equal(status,True) # expecting igmp data traffic from source src_list[0]
1860 self.send_igmp_join(groups = group, src_list = src_list[1],record_type = IGMP_V3_GR_TYPE_ALLOW_NEW,
1861 iface = self.V_INF1, delay = 1)
1862 for src in src_list:
1863 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1, source=src)
1864 assert_equal(status,True) # expecting igmp data traffic from both sources
1865
1866
1867 def test_igmp_include_to_exclude_mode_change(self):
1868 group = ['224.2.3.4']
1869 src_list = ['2.2.2.2','3.3.3.3']
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001870 self.onos_ssm_table_load(group, src_list)
1871 self.send_igmp_join(groups = group, src_list = src_list[0],record_type = IGMP_V3_GR_TYPE_INCLUDE,
1872 iface = self.V_INF1, delay = 1)
1873 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source= src_list[0])
1874 assert_equal(status,True) # expecting igmp data traffic from source src_list[0]
1875 self.send_igmp_join(groups = group, src_list = src_list[1],record_type = IGMP_V3_GR_TYPE_EXCLUDE,
1876 iface = self.V_INF1, delay = 1)
1877 for src in src_list:
1878 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source= src)
1879 assert_equal(status,False) # expecting igmp data traffic from both sources
1880
1881 def test_igmp_exclude_to_include_mode_change(self):
1882 group = ['224.2.3.4']
1883 src = ['2.2.2.2']
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001884 self.onos_ssm_table_load(group, src)
1885 self.send_igmp_join(groups = group, src_list = src,record_type = IGMP_V3_GR_TYPE_EXCLUDE,
1886 iface = self.V_INF1, delay = 1)
1887 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source=src[0])
1888 assert_equal(status,False) # not expecting igmp data traffic from source src_list[0]
1889 self.send_igmp_join(groups = group, src_list = src,record_type = IGMP_V3_GR_TYPE_INCLUDE,
1890 iface = self.V_INF1, delay = 1)
1891 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source = src[0])
1892 assert_equal(status,True) # expecting igmp data traffic from both sources
1893
1894 #this test case wotks properly if the snooping device(ONOS) have multicast router connected.
1895 def test_igmp_to_include_mode_with_null_source(self):
1896 groups = ['224.2.3.4','230.7.9.8']
1897 src = ['192.168.12.34']
1898 dst_mac = []
1899 dst_mac.append(self.iptomac(groups[0]))
1900 dst_mac.append(self.iptomac(groups[1]))
1901 self.onos_ssm_table_load(groups, src)
1902 self.send_igmp_join(groups = groups, src_list = src,record_type = IGMP_V3_GR_TYPE_INCLUDE,
1903 iface = self.V_INF1, delay = 1)
1904 for grp in groups:
1905 status = self.verify_igmp_data_traffic(grp,intf=self.V_INF1,source= src[0])
1906 assert_equal(status,True) # not expecting igmp data traffic from source src_list[0]
1907 #sending leave packet for group groups[1]
1908 self.send_igmp_join(groups = [groups[1]], src_list = [],record_type = IGMP_V3_GR_TYPE_CHANGE_TO_INCLUDE,
1909 iface = self.V_INF1, delay = 1)
1910 for grp in groups:
1911 status = self.verify_igmp_data_traffic(grp,intf=self.V_INF1,source= src[0])
1912 if grp is groups[0]:
1913 assert_equal(status,True) # expecting igmp data traffic to group groups[0]
1914 else:
1915 assert_equal(status,False) # not expecting igmp data traffic to group groups[1]
1916
1917 def test_igmp_to_include_mode(self):
1918 group = ['229.9.3.6']
1919 src_list = ['192.168.12.34','192.18.1.34']
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001920 self.onos_ssm_table_load(group, src_list)
1921 self.send_igmp_join(groups = group, src_list = [src_list[0]],record_type = IGMP_V3_GR_TYPE_INCLUDE,
1922 iface = self.V_INF1, delay = 1)
1923 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source=src_list[0])
1924 assert_equal(status,True) # not expecting igmp data traffic from source src_list[0]
1925 self.send_igmp_join(groups = group, src_list = src_list,record_type = IGMP_V3_GR_TYPE_CHANGE_TO_INCLUDE,
1926 iface = self.V_INF1, delay = 1)
1927 for src in src_list:
1928 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source= src)
1929 assert_equal(status,True) # expecting igmp data traffic to group groups[0]
1930
1931 #this test case passed only if mulitcast router connected to ONOS.
1932 def test_igmp_blocking_old_source_mode(self):
1933 group = ['224.2.3.4']
1934 src_list = ['2.2.2.2','3.3.3.3']
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001935 self.onos_ssm_table_load(group, src_list)
1936 self.send_igmp_join(groups = group, src_list = src_list,record_type = IGMP_V3_GR_TYPE_INCLUDE,
1937 iface = self.V_INF1, delay = 1)
1938 for src in src_list:
1939 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1, source=src)
1940 assert_equal(status,True) # expecting igmp data traffic from source src_list[0]
1941 self.send_igmp_join(groups = group, src_list = [src_list[1]],record_type = IGMP_V3_GR_TYPE_BLOCK_OLD,
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 if src is src_list[0]:
1946 assert_equal(status,True) # expecting igmp data traffic from source src_list[0]
1947 else:
1948 assert_equal(status,False) # not expecting igmp data traffic from source src_list[1]
1949
1950 def test_igmp_multiple_joins_and_data_verification_with_100_groups(self):
1951 groups = []
1952 sources = []
1953 count = 1
1954 mcastips = self.mcast_ip_range(start_ip = '226.0.0.1',end_ip = '226.0.5.254')
1955 sourceips = self.source_ip_range(start_ip = '10.10.0.1',end_ip = '10.10.5.254')
1956 while count<=100:
1957 group = random.choice(mcastips)
1958 source = random.choice(sourceips)
1959 if group in groups:
1960 pass
1961 else:
A R Karthick76a497a2017-04-12 10:59:39 -07001962 log_test.info('group and source are %s and %s'%(group,source))
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001963 groups.append(group)
1964 sources.append(source)
1965 count += 1
1966 self.onos_ssm_table_load(groups,src_list=sources,flag=True)
1967 for i in range(100):
1968 self.send_igmp_join(groups = [groups[i]], src_list = [sources[i]],record_type = IGMP_V3_GR_TYPE_INCLUDE,
1969 iface = self.V_INF1)
1970 status = self.verify_igmp_data_traffic(groups[i],intf=self.V_INF1,source=sources[i])
1971 assert_equal(status, True)
A R Karthick76a497a2017-04-12 10:59:39 -07001972 log_test.info('data received for group %s from source %s'%(groups[i],sources[i]))
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001973
1974 def test_igmp_multiple_joins_with_data_verification_and_leaving_100_groups(self):
1975 groups = []
1976 sources = []
1977 count = 1
1978 mcastips = self.mcast_ip_range(start_ip = '226.0.0.1',end_ip = '226.0.5.254')
1979 sourceips = self.source_ip_range(start_ip = '10.10.0.1',end_ip = '10.10.5.254')
1980 while count<=100:
1981 group = random.choice(mcastips)
1982 source = random.choice(sourceips)
1983 if group in groups:
1984 pass
1985 else:
A R Karthick76a497a2017-04-12 10:59:39 -07001986 log_test.info('group and source are %s and %s'%(group,source))
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001987 groups.append(group)
1988 sources.append(source)
1989 count += 1
1990 self.onos_ssm_table_load(groups,src_list=sources,flag=True)
1991 for i in range(100):
1992 self.send_igmp_join(groups = [groups[i]], src_list = [sources[i]],record_type = IGMP_V3_GR_TYPE_INCLUDE,
1993 iface = self.V_INF1)
1994 status = self.verify_igmp_data_traffic(groups[i],intf=self.V_INF1,source=sources[i])
1995 assert_equal(status, True)
A R Karthick76a497a2017-04-12 10:59:39 -07001996 log_test.info('data received for group %s from source %s'%(groups[i],sources[i]))
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001997 self.send_igmp_join(groups = [groups[i]], src_list = [sources[i]],record_type = IGMP_V3_GR_TYPE_CHANGE_TO_EXCLUDE,
1998 iface = self.V_INF1, delay = 1)
1999 status = self.verify_igmp_data_traffic(groups[i],intf=self.V_INF1,source=sources[i])
2000 assert_equal(status, False)
A R Karthick76a497a2017-04-12 10:59:39 -07002001 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 -07002002
2003 def test_igmp_group_source_for_only_config_with_1000_entries(self):
2004 groups = []
2005 sources = []
2006 count = 1
2007 mcastips = self.mcast_ip_range(start_ip = '229.0.0.1',end_ip = '229.0.50.254')
2008 sourceips = self.source_ip_range(start_ip = '10.10.0.1',end_ip = '10.10.50.254')
2009 while count<=1000:
2010 group = random.choice(mcastips)
2011 source = random.choice(sourceips)
2012 if group in groups:
2013 pass
2014 else:
A R Karthick76a497a2017-04-12 10:59:39 -07002015 log_test.info('group and source are %s and %s'%(group,source))
ChetanGaonkera7e2b412016-09-01 23:19:07 -07002016 groups.append(group)
2017 sources.append(source)
2018 count += 1
2019 self.onos_ssm_table_load(groups,src_list=sources,flag=True)
2020
2021 def test_igmp_from_exclude_to_include_mode_with_100_groups(self):
2022 groups = []
2023 sources = []
2024 count = 1
2025 mcastips = self.mcast_ip_range(start_ip = '229.0.0.1',end_ip = '229.0.10.254')
2026 sourceips = self.source_ip_range(start_ip = '10.10.0.1',end_ip = '10.10.10.254')
2027 while count<=100:
2028 group = random.choice(mcastips)
2029 source = random.choice(sourceips)
2030 if group in groups:
2031 pass
2032 else:
A R Karthick76a497a2017-04-12 10:59:39 -07002033 log_test.info('group and source are %s and %s'%(group,source))
ChetanGaonkera7e2b412016-09-01 23:19:07 -07002034 groups.append(group)
2035 sources.append(source)
2036 count += 1
2037 self.onos_ssm_table_load(groups,src_list=sources,flag=True)
2038 for i in range(100):
2039 self.send_igmp_join(groups = [groups[i]], src_list = [sources[i]],record_type = IGMP_V3_GR_TYPE_EXCLUDE,
2040 iface = self.V_INF1)
2041 status = self.verify_igmp_data_traffic(groups[i],intf=self.V_INF1,source=sources[i])
2042 assert_equal(status, False)
A R Karthick76a497a2017-04-12 10:59:39 -07002043 log_test.info('data not received for group %s from source %s as expected'%(groups[i],sources[i]))
ChetanGaonkera7e2b412016-09-01 23:19:07 -07002044 self.send_igmp_join(groups = [groups[i]], src_list = [sources[i]],record_type = IGMP_V3_GR_TYPE_INCLUDE,
2045 iface = self.V_INF1)
2046 status = self.verify_igmp_data_traffic(groups[i],intf=self.V_INF1,source=sources[i])
2047 assert_equal(status, True)
A R Karthick76a497a2017-04-12 10:59:39 -07002048 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 -07002049
2050 def test_igmp_with_multiple_joins_and_data_verify_with_1000_groups(self):
2051 groups = []
2052 sources = []
2053 count = 1
2054 mcastips = self.mcast_ip_range(start_ip = '229.0.0.1',end_ip = '229.0.30.254')
2055 sourceips = self.source_ip_range(start_ip = '10.10.0.1',end_ip = '10.10.30.254')
2056 while count<=1000:
2057 group = random.choice(mcastips)
2058 source = random.choice(sourceips)
2059 if group in groups:
2060 pass
2061 else:
A R Karthick76a497a2017-04-12 10:59:39 -07002062 log_test.info('group and source are %s and %s'%(group,source))
ChetanGaonkera7e2b412016-09-01 23:19:07 -07002063 groups.append(group)
2064 sources.append(source)
2065 count += 1
2066 self.onos_ssm_table_load(groups,src_list=sources,flag=True)
2067 for i in range(1000):
2068 self.send_igmp_join(groups = [groups[i]], src_list = [sources[i]],record_type = IGMP_V3_GR_TYPE_INCLUDE,
2069 iface = self.V_INF1)
2070 status = self.verify_igmp_data_traffic(groups[i],intf=self.V_INF1,source=sources[i])
2071 assert_equal(status, True)
A R Karthick76a497a2017-04-12 10:59:39 -07002072 log_test.info('data received for group %s from source %s - %d'%(groups[i],sources[i],i))
ChetanGaonkera7e2b412016-09-01 23:19:07 -07002073
2074 def test_igmp_with_multiple_joins_and_data_verify_with_5000_groups(self):
2075 groups = []
2076 sources = []
2077 count = 1
2078 mcastips = self.mcast_ip_range(start_ip = '231.39.19.121',end_ip = '231.40.30.25')
2079 sourceips = self.source_ip_range(start_ip = '192.168.56.43',end_ip = '192.169.110.30')
2080 while count<=5000:
2081 group = random.choice(mcastips)
2082 source = random.choice(sourceips)
2083 if group in groups:
2084 pass
2085 else:
A R Karthick76a497a2017-04-12 10:59:39 -07002086 log_test.info('group and source are %s and %s'%(group,source))
ChetanGaonkera7e2b412016-09-01 23:19:07 -07002087 groups.append(group)
2088 sources.append(source)
2089 count += 1
2090 self.onos_ssm_table_load(groups,src_list=sources,flag=True)
2091 for i in range(5000):
2092 self.send_igmp_join(groups = [groups[i]], src_list = [sources[i]],record_type = IGMP_V3_GR_TYPE_INCLUDE,
2093 iface = self.V_INF1)
2094 status = self.verify_igmp_data_traffic(groups[i],intf=self.V_INF1,source=sources[i])
2095 assert_equal(status, True)
A R Karthick76a497a2017-04-12 10:59:39 -07002096 log_test.info('data received for group %s from source %s - %d'%(groups[i],sources[i],i))
ChetanGaonkera7e2b412016-09-01 23:19:07 -07002097
2098 """def test_igmp_join_from_multiple_infts(self):
2099 groups = ['229.9.3.6','234.20.56.2']
2100 src_list = ['192.168.12.34','192.18.1.34']
2101 self.onos_ssm_table_load(groups, src_list=src_list)
2102 self.send_igmp_join(groups = [groups[0]], src_list = src_list,record_type = IGMP_V3_GR_TYPE_INCLUDE,
2103 iface = 'veth0')
2104 self.send_igmp_join(groups = [groups[1]], src_list = src_list,record_type = IGMP_V3_GR_TYPE_INCLUDE,
2105 iface = 'veth2')
2106 status = self.verify_igmp_data_traffic(groups[0],intf='veth0',source=src_list[0])
2107 assert_equal(status,True)
2108 status = self.verify_igmp_data_traffic(groups[1],intf='veth2',source=src_list[1])
2109 assert_equal(status,True) # not expecting igmp data traffic from source src_list[0]
2110 """
2111
2112 def test_igmp_send_data_to_non_registered_group(self):
2113 group = ['224.2.3.4']
2114 src = ['2.2.2.2']
2115 self.onos_ssm_table_load(group,src_list= src)
2116 self.send_igmp_join(groups = ['239.0.0.1'], src_list = src,record_type = IGMP_V3_GR_TYPE_INCLUDE,
2117 iface = self.V_INF1, delay = 1)
2118 status = self.verify_igmp_data_traffic('239.0.0.1',intf=self.V_INF1,source=src[0])
2119 assert_equal(status,False) # not expecting igmp data traffic from source src_list[0]
2120
2121 def test_igmp_traffic_verification_for_registered_group_with_no_join_sent(self):
2122 group = ['227.12.3.40']
2123 src = ['190.4.19.67']
2124 self.onos_ssm_table_load(group,src_list= src)
2125 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source=src[0])
2126 assert_equal(status,False) # not expecting igmp data traffic from source src_list[0]
2127
2128 def test_igmp_toggling_app_activation(self):
2129 group = [self.random_mcast_ip()]
2130 src = [self.randomsourceip()]
2131 self.onos_ssm_table_load(group,src_list= src)
2132 self.send_igmp_join(groups = group, src_list = src,record_type = IGMP_V3_GR_TYPE_INCLUDE,
2133 iface = self.V_INF1)
2134 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source=src[0])
2135 assert_equal(status,True) # expecting igmp data traffic from source src_list[0]
A R Karthick76a497a2017-04-12 10:59:39 -07002136 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 -07002137 self.onos_ctrl.deactivate()
2138 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source=src[0])
2139 assert_equal(status,False) #not expecting igmp data traffic from source src_list[0]
A R Karthick76a497a2017-04-12 10:59:39 -07002140 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 -07002141 self.onos_ctrl.activate()
2142 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source=src[0])
2143 assert_equal(status,True) # expecting igmp data traffic from source src_list[0]
A R Karthick76a497a2017-04-12 10:59:39 -07002144 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 -07002145
2146 def test_igmp_with_mismatch_for_dst_ip_and_mac_in_data_packets(self):
2147 group = ['228.18.19.29']
2148 source = [self.randomsourceip()]
2149 self.onos_ssm_table_load(group,src_list= source)
2150 self.send_igmp_join(groups = group, src_list = source,record_type = IGMP_V3_GR_TYPE_INCLUDE,
2151 iface = self.V_INF1)
2152 dst_mac = '01:00:5e:0A:12:09'
2153 eth = Ether(dst= dst_mac)
2154 ip = IP(dst=group[0],src=source[0])
2155 data = repr(monotonic.monotonic())
2156 pkt = (eth/ip/data)
A R Karthick76a497a2017-04-12 10:59:39 -07002157 log_test.info('Multicast traffic packet %s'%pkt.show())
ChetanGaonkera7e2b412016-09-01 23:19:07 -07002158 self.success = False
2159 def recv_task():
2160 def igmp_recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -07002161 #log_test.info('received multicast data packet is %s'%pkt.show())
2162 log_test.info('multicast data received for group %s from source %s'%(group[0],source[0]))
ChetanGaonkera7e2b412016-09-01 23:19:07 -07002163 self.success = True
2164 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')
2165 t = threading.Thread(target = recv_task)
2166 t.start()
2167 sendp(eth/ip/data,count=20, iface = 'veth2')
2168 t.join()
2169 assert_equal(status,False) # not expecting igmp data traffic from source src_list[0]
2170
2171 #test case failing, ONOS registering unicast ip also as an igmp join
2172 def test_igmp_registering_invalid_group(self):
ChetanGaonkerb99538a2016-12-02 13:53:35 -08002173 groups = ['218.18.19.29']
ChetanGaonkera7e2b412016-09-01 23:19:07 -07002174 source = [self.randomsourceip()]
A.R Karthick401a1ed2017-05-18 11:08:27 -07002175 ssm_dict = {'apps' : { 'org.opencord.igmp' : { 'ssmTranslate' : [] } } }
2176 ssm_xlate_list = ssm_dict['apps']['org.opencord.igmp']['ssmTranslate']
ChetanGaonkera7e2b412016-09-01 23:19:07 -07002177 for g in groups:
2178 for s in source:
2179 d = {}
2180 d['source'] = s or '0.0.0.0'
2181 d['group'] = g
2182 ssm_xlate_list.append(d)
A R Karthick76a497a2017-04-12 10:59:39 -07002183 log_test.info('onos load config is %s'%ssm_dict)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07002184 status, code = OnosCtrl.config(ssm_dict)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08002185 self.send_igmp_join(groups, src_list = source, record_type = IGMP_V3_GR_TYPE_INCLUDE,
2186 iface = self.V_INF1, delay = 1)
2187 status = self.verify_igmp_data_traffic(groups[0],intf=self.V_INF1, source=source[0])
2188 assert_equal(status,False) # not expecting igmp data traffic from source src_list[0]
ChetanGaonkera7e2b412016-09-01 23:19:07 -07002189
2190 def test_igmp_registering_invalid_source(self):
2191 groups = [self.random_mcast_ip()]
2192 sources = ['224.10.28.34','193.73.219.257']
A.R Karthick401a1ed2017-05-18 11:08:27 -07002193 ssm_dict = {'apps' : { 'org.opencord.igmp' : { 'ssmTranslate' : [] } } }
2194 ssm_xlate_list = ssm_dict['apps']['org.opencord.igmp']['ssmTranslate']
ChetanGaonkera7e2b412016-09-01 23:19:07 -07002195 for g in groups:
2196 for s in sources:
2197 d = {}
2198 d['source'] = s or '0.0.0.0'
2199 d['group'] = g
2200 ssm_xlate_list.append(d)
A R Karthick76a497a2017-04-12 10:59:39 -07002201 log_test.info('onos load config is %s'%ssm_dict)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07002202 status, code = OnosCtrl.config(ssm_dict)
2203 assert_equal(status,False)