blob: bd99d5eebe29b562c8d5cbff4d7bf22f8772a101 [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#
Chetan Gaonker25470972016-02-26 08:52:15 -080016from nose.tools import *
17from nose.twistedtools import reactor, deferred
18from twisted.internet import defer
19from scapy.all import *
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -080020import time, monotonic
ChetanGaonkerb99538a2016-12-02 13:53:35 -080021import os
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -080022import random
23import threading
Chetan Gaonkere88c95c2016-03-02 05:21:47 -080024from IGMP import *
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -080025from McastTraffic import *
26from Stats import Stats
Chetan Gaonker4a25e2b2016-03-04 14:45:15 -080027from OnosCtrl import OnosCtrl
Chetan Gaonker441c9ac2016-05-06 10:30:13 -070028from OltConfig import OltConfig
Chetan Gaonker4eb12072016-03-28 15:04:15 -070029from Channels import IgmpChannel
A R Karthick9313b762016-11-07 13:14:35 -080030from CordLogger import CordLogger
A R Karthick861da962017-02-08 16:21:36 -080031from CordTestConfig import setup_module
A R Karthick76a497a2017-04-12 10:59:39 -070032from CordTestUtils import log_test
A R Karthick861da962017-02-08 16:21:36 -080033
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'
60 V_INF2 = 'veth1'
61 MGROUP1 = '239.1.2.3'
62 MGROUP2 = '239.2.2.3'
Chetan Gaonker441c9ac2016-05-06 10:30:13 -070063 MINVALIDGROUP1 = '255.255.255.255'
64 MINVALIDGROUP2 = '239.255.255.255'
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -070065 MMACGROUP1 = "01:00:5e:01:02:03"
66 MMACGROUP2 = "01:00:5e:02:02:03"
ChetanGaonkera7e2b412016-09-01 23:19:07 -070067 IGMP_DST_MAC = "01:00:5e:00:00:16"
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -070068 IGMP_SRC_MAC = "5a:e1:ac:ec:4d:a1"
69 IP_SRC = '1.2.3.4'
ChetanGaonkera7e2b412016-09-01 23:19:07 -070070 IP_DST = '224.0.0.22'
Chetan Gaonker441c9ac2016-05-06 10:30:13 -070071 NEGATIVE_TRAFFIC_STATUS = 1
ChetanGaonkera7e2b412016-09-01 23:19:07 -070072 igmp_eth = Ether(dst = IGMP_DST_MAC, type = ETH_P_IP)
73 igmp_ip = IP(dst = IP_DST)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -080074 IGMP_TEST_TIMEOUT = 5
Chetan Gaonker441c9ac2016-05-06 10:30:13 -070075 IGMP_QUERY_TIMEOUT = 60
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -080076 MCAST_TRAFFIC_TIMEOUT = 10
Chetan Gaonker4eb12072016-03-28 15:04:15 -070077 PORT_TX_DEFAULT = 2
78 PORT_RX_DEFAULT = 1
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -080079 max_packets = 100
A.R Karthick95d044e2016-06-10 18:44:36 -070080 app = 'org.opencord.igmp'
A.R Karthick5968e0d2017-05-16 14:50:46 -070081 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 -070082 ROVER_TEST_TIMEOUT = 300 #3600*86
83 ROVER_TIMEOUT = (ROVER_TEST_TIMEOUT - 100)
84 ROVER_JOIN_TIMEOUT = 60
Chetan Gaonker4a25e2b2016-03-04 14:45:15 -080085
Chetan Gaonker441c9ac2016-05-06 10:30:13 -070086 @classmethod
87 def setUpClass(cls):
88 cls.olt = OltConfig(olt_conf_file = cls.olt_conf_file)
A R Karthick2b93d6a2016-09-06 15:19:09 -070089 cls.port_map, _ = cls.olt.olt_port_map()
A R Karthick0f6b6842016-12-06 17:17:44 -080090 OnosCtrl.cord_olt_config(cls.olt)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -070091
92 @classmethod
93 def tearDownClass(cls): pass
A.R Karthick95d044e2016-06-10 18:44:36 -070094
Chetan Gaonker4a25e2b2016-03-04 14:45:15 -080095 def setUp(self):
ChetanGaonkera7e2b412016-09-01 23:19:07 -070096 ''' Activate the igmp app'''
A R Karthick9313b762016-11-07 13:14:35 -080097 super(igmp_exchange, self).setUp()
Chetan Gaonker4a25e2b2016-03-04 14:45:15 -080098 self.onos_ctrl = OnosCtrl(self.app)
ChetanGaonkera7e2b412016-09-01 23:19:07 -070099 self.onos_ctrl.activate()
Chetan Gaonker4eb12072016-03-28 15:04:15 -0700100 self.igmp_channel = IgmpChannel()
Chetan Gaonker4a25e2b2016-03-04 14:45:15 -0800101
A R Karthick9313b762016-11-07 13:14:35 -0800102 def tearDown(self):
103 super(igmp_exchange, self).tearDown()
Chetan Gaonker4a25e2b2016-03-04 14:45:15 -0800104
105 def onos_load_config(self, config):
A R Karthick76a497a2017-04-12 10:59:39 -0700106 log_test.info('onos load config is %s'%config)
Chetan Gaonkera2b87df2016-03-31 15:41:31 -0700107 status, code = OnosCtrl.config(config)
Chetan Gaonker4a25e2b2016-03-04 14:45:15 -0800108 if status is False:
A R Karthick76a497a2017-04-12 10:59:39 -0700109 log_test.info('JSON request returned status %d' %code)
Chetan Gaonker4a25e2b2016-03-04 14:45:15 -0800110 assert_equal(status, True)
111 time.sleep(2)
A.R Karthick95d044e2016-06-10 18:44:36 -0700112
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700113 def onos_ssm_table_load(self, groups, src_list = ['1.2.3.4'],flag = False):
A.R Karthick401a1ed2017-05-18 11:08:27 -0700114 ssm_dict = {'apps' : { 'org.opencord.igmp' : { 'ssmTranslate' : [] } } }
115 ssm_xlate_list = ssm_dict['apps']['org.opencord.igmp']['ssmTranslate']
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700116 if flag: #to maintain seperate group-source pair.
117 for i in range(len(groups)):
118 d = {}
119 d['source'] = src_list[i] or '0.0.0.0'
120 d['group'] = groups[i]
121 ssm_xlate_list.append(d)
122 else:
123 for g in groups:
124 for s in src_list:
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800125 d = {}
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700126 d['source'] = s or '0.0.0.0'
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800127 d['group'] = g
128 ssm_xlate_list.append(d)
Chetan Gaonker4a25e2b2016-03-04 14:45:15 -0800129 self.onos_load_config(ssm_dict)
Chetan Gaonker4eb12072016-03-28 15:04:15 -0700130 cord_port_map = {}
131 for g in groups:
132 cord_port_map[g] = (self.PORT_TX_DEFAULT, self.PORT_RX_DEFAULT)
133 self.igmp_channel.cord_port_table_load(cord_port_map)
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800134 time.sleep(2)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800135
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700136 def mcast_ip_range(self,start_ip = '224.0.1.0', end_ip = '224.0.1.100'):
137 start = list(map(int, start_ip.split(".")))
138 end = list(map(int, end_ip.split(".")))
139 temp = start
140 ip_range = []
141 ip_range.append(start_ip)
142 while temp != end:
143 start[3] += 1
144 for i in (3, 2, 1):
145 if temp[i] == 255:
146 temp[i] = 0
147 temp[i-1] += 1
148 ip_range.append(".".join(map(str, temp)))
149 return ip_range
150
151 def random_mcast_ip(self,start_ip = '224.0.1.0', end_ip = '224.0.1.100'):
152 start = list(map(int, start_ip.split(".")))
153 end = list(map(int, end_ip.split(".")))
154 temp = start
155 ip_range = []
156 ip_range.append(start_ip)
157 while temp != end:
158 start[3] += 1
159 for i in (3, 2, 1):
160 if temp[i] == 255:
161 temp[i] = 0
162 temp[i-1] += 1
163 ip_range.append(".".join(map(str, temp)))
164 return random.choice(ip_range)
165
166 def source_ip_range(self,start_ip = '10.10.0.1', end_ip = '10.10.0.100'):
167 start = list(map(int, start_ip.split(".")))
168 end = list(map(int, end_ip.split(".")))
169 temp = start
170 ip_range = []
171 ip_range.append(start_ip)
172 while temp != end:
173 start[3] += 1
174 for i in (3, 2, 1):
175 if temp[i] == 255:
176 temp[i] = 0
177 temp[i-1] += 1
178 ip_range.append(".".join(map(str, temp)))
179 return ip_range
180
181 def randomsourceip(self,start_ip = '10.10.0.1', end_ip = '10.10.0.100'):
182 start = list(map(int, start_ip.split(".")))
183 end = list(map(int, end_ip.split(".")))
184 temp = start
185 ip_range = []
186 ip_range.append(start_ip)
187 while temp != end:
188 start[3] += 1
189 for i in (3, 2, 1):
190 if temp[i] == 255:
191 temp[i] = 0
192 temp[i-1] += 1
193 ip_range.append(".".join(map(str, temp)))
194 return random.choice(ip_range)
195
A R Karthick2b93d6a2016-09-06 15:19:09 -0700196 def get_igmp_intf(self):
197 inst = os.getenv('TEST_INSTANCE', None)
198 if not inst:
199 return 'veth0'
200 inst = int(inst) + 1
201 if inst >= self.port_map['uplink']:
202 inst += 1
203 if self.port_map.has_key(inst):
204 return self.port_map[inst]
205 return 'veth0'
206
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800207 def igmp_verify_join(self, igmpStateList):
208 sendState, recvState = igmpStateList
Chetan Gaonker25470972016-02-26 08:52:15 -0800209 ## check if the send is received for the groups
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800210 for g in sendState.groups:
A.R Karthick95d044e2016-06-10 18:44:36 -0700211 tx_stats = sendState.group_map[g][0]
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800212 tx = tx_stats.count
Chetan Gaonker25470972016-02-26 08:52:15 -0800213 assert_greater(tx, 0)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800214 rx_stats = recvState.group_map[g][1]
215 rx = rx_stats.count
216 assert_greater(rx, 0)
A R Karthick76a497a2017-04-12 10:59:39 -0700217 log_test.info('Receive stats %s for group %s' %(rx_stats, g))
A.R Karthick95d044e2016-06-10 18:44:36 -0700218
A R Karthick76a497a2017-04-12 10:59:39 -0700219 log_test.info('IGMP test verification success')
Chetan Gaonker25470972016-02-26 08:52:15 -0800220
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800221 def igmp_verify_leave(self, igmpStateList, leave_groups):
222 sendState, recvState = igmpStateList[0], igmpStateList[1]
223 ## check if the send is received for the groups
224 for g in sendState.groups:
225 tx_stats = sendState.group_map[g][0]
226 rx_stats = recvState.group_map[g][1]
227 tx = tx_stats.count
A.R Karthick95d044e2016-06-10 18:44:36 -0700228 rx = rx_stats.count
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800229 assert_greater(tx, 0)
230 if g not in leave_groups:
A R Karthick76a497a2017-04-12 10:59:39 -0700231 log_test.info('Received %d packets for group %s' %(rx, g))
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800232 for g in leave_groups:
233 rx = recvState.group_map[g][1].count
234 assert_equal(rx, 0)
A.R Karthick95d044e2016-06-10 18:44:36 -0700235
A R Karthick76a497a2017-04-12 10:59:39 -0700236 log_test.info('IGMP test verification success')
Chetan Gaonker25470972016-02-26 08:52:15 -0800237
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800238 def mcast_traffic_timer(self):
239 self.mcastTraffic.stopReceives()
240
241 def send_mcast_cb(self, send_state):
242 for g in send_state.groups:
243 send_state.update(g, tx = 1)
Chetan Gaonker25470972016-02-26 08:52:15 -0800244 return 0
245
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800246 ##Runs in the context of twisted reactor thread
Chetan Gaonker25470972016-02-26 08:52:15 -0800247 def igmp_recv(self, igmpState, iface = 'veth0'):
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800248 p = self.recv_socket.recv()
Chetan Gaonkerf1b9e322016-05-09 15:49:15 -0700249 try:
250 send_time = float(p.payload.load)
251 recv_time = monotonic.monotonic()
252 except:
A R Karthick76a497a2017-04-12 10:59:39 -0700253 log_test.info('Unexpected Payload received: %s' %p.payload.load)
Chetan Gaonkerf1b9e322016-05-09 15:49:15 -0700254 return 0
A R Karthick76a497a2017-04-12 10:59:39 -0700255 #log_test.info( 'Recv in %.6f secs' %(recv_time - send_time))
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800256 igmpState.update(p.dst, rx = 1, t = recv_time - send_time)
Chetan Gaonker25470972016-02-26 08:52:15 -0800257 return 0
258
A R Karthick2b93d6a2016-09-06 15:19:09 -0700259 def send_igmp_join(self, groups, src_list = ['1.2.3.4'], record_type=IGMP_V3_GR_TYPE_INCLUDE,
260 ip_pkt = None, iface = 'veth0', ssm_load = False, delay = 1):
261 if ssm_load is True:
262 self.onos_ssm_table_load(groups, src_list)
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800263 igmp = IGMPv3(type = IGMP_TYPE_V3_MEMBERSHIP_REPORT, max_resp_code=30,
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700264 gaddr=self.IP_DST)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800265 for g in groups:
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700266 gr = IGMPv3gr(rtype= record_type, mcaddr=g)
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800267 gr.sources = src_list
268 igmp.grps.append(gr)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700269 if ip_pkt is None:
270 ip_pkt = self.igmp_eth/self.igmp_ip
271 pkt = ip_pkt/igmp
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800272 IGMPv3.fixup(pkt)
273 sendp(pkt, iface=iface)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800274 if delay != 0:
275 time.sleep(delay)
276
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700277 def send_igmp_join_recvQuery(self, groups, rec_queryCount = None, src_list = ['1.2.3.4'], ip_pkt = None, iface = 'veth0', delay = 2):
278 self.onos_ssm_table_load(groups, src_list)
279 igmp = IGMPv3(type = IGMP_TYPE_V3_MEMBERSHIP_REPORT, max_resp_code=30,
280 gaddr=self.IP_DST)
281 for g in groups:
Chetan Gaonker38737f82016-05-11 17:44:17 -0700282 gr = IGMPv3gr(rtype=IGMP_V3_GR_TYPE_INCLUDE, mcaddr=g)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700283 gr.sources = src_list
284 gr.sources = src_list
285 igmp.grps.append(gr)
286 if ip_pkt is None:
287 ip_pkt = self.igmp_eth/self.igmp_ip
288 pkt = ip_pkt/igmp
289 IGMPv3.fixup(pkt)
290 if rec_queryCount == None:
A R Karthick76a497a2017-04-12 10:59:39 -0700291 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 -0700292 resp = srp1(pkt, iface=iface)
293 else:
A R Karthick76a497a2017-04-12 10:59:39 -0700294 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 -0700295 resp = srp1(pkt, iface=iface)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700296# resp = srp1(pkt, iface=iface) if rec_queryCount else srp3(pkt, iface=iface)
297 resp[0].summary()
A R Karthick76a497a2017-04-12 10:59:39 -0700298 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 -0700299 if delay != 0:
300 time.sleep(delay)
301
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700302 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 -0700303 log_test.info('entering into igmp leave function')
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800304 igmp = IGMPv3(type = IGMP_TYPE_V3_MEMBERSHIP_REPORT, max_resp_code=30,
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700305 gaddr=self.IP_DST)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800306 for g in groups:
Chetan Gaonker38737f82016-05-11 17:44:17 -0700307 gr = IGMPv3gr(rtype=IGMP_V3_GR_TYPE_EXCLUDE, mcaddr=g)
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800308 gr.sources = src_list
309 igmp.grps.append(gr)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700310 if ip_pkt is None:
311 ip_pkt = self.igmp_eth/self.igmp_ip
312 pkt = ip_pkt/igmp
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800313 IGMPv3.fixup(pkt)
314 sendp(pkt, iface = iface)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800315 if delay != 0:
316 time.sleep(delay)
Chetan Gaonker25470972016-02-26 08:52:15 -0800317
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700318 def send_igmp_leave_listening_group_specific_query(self, groups, src_list = ['1.2.3.4'], ip_pkt = None, iface = 'veth0', delay = 2):
319 igmp = IGMPv3(type = IGMP_TYPE_V3_MEMBERSHIP_REPORT, max_resp_code=30,
320 gaddr=self.IP_DST)
321 for g in groups:
Chetan Gaonker38737f82016-05-11 17:44:17 -0700322 gr = IGMPv3gr(rtype=IGMP_V3_GR_TYPE_EXCLUDE, mcaddr=g)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700323 gr.sources = src_list
324 igmp.grps.append(gr)
325 if ip_pkt is None:
326 ip_pkt = self.igmp_eth/self.igmp_ip
327 pkt = ip_pkt/igmp
328 IGMPv3.fixup(pkt)
A R Karthick76a497a2017-04-12 10:59:39 -0700329 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 -0700330 resp = srp1(pkt, iface=iface)
331 resp[0].summary()
A R Karthick76a497a2017-04-12 10:59:39 -0700332 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 -0700333 if delay != 0:
334 time.sleep(delay)
335
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800336 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10)
337 def test_igmp_join_verify_traffic(self):
Chetan Gaonkerddfdc522017-04-04 01:15:04 +0000338 groups = [self.MGROUP1, self.MGROUP1]
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700339 self.onos_ssm_table_load(groups)
Chetan Gaonker25470972016-02-26 08:52:15 -0800340 df = defer.Deferred()
341 igmpState = IGMPTestState(groups = groups, df = df)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800342 igmpStateRecv = IGMPTestState(groups = groups, df = df)
343 igmpStateList = (igmpState, igmpStateRecv)
344 mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb, arg = igmpState)
345 self.df = df
346 self.mcastTraffic = mcastTraffic
347 self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP)
348
349 def igmp_srp_task(stateList):
350 igmpSendState, igmpRecvState = stateList
351 if not mcastTraffic.isRecvStopped():
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800352 self.igmp_recv(igmpRecvState)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800353 reactor.callLater(0, igmp_srp_task, stateList)
354 else:
355 self.mcastTraffic.stop()
356 self.recv_socket.close()
357 self.igmp_verify_join(stateList)
358 self.df.callback(0)
359
360 self.send_igmp_join(groups)
361 mcastTraffic.start()
362 self.test_timer = reactor.callLater(self.MCAST_TRAFFIC_TIMEOUT, self.mcast_traffic_timer)
363 reactor.callLater(0, igmp_srp_task, igmpStateList)
Chetan Gaonker25470972016-02-26 08:52:15 -0800364 return df
365
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700366 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+40)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800367 def test_igmp_leave_verify_traffic(self):
Chetan Gaonkerddfdc522017-04-04 01:15:04 +0000368 groups = [self.MGROUP1, self.MGROUP1]
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800369 leave_groups = ['224.0.1.10']
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700370 self.onos_ssm_table_load(groups)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800371 df = defer.Deferred()
372 igmpState = IGMPTestState(groups = groups, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800373 IGMPTestState(groups = groups, df = df)
A.R Karthick95d044e2016-06-10 18:44:36 -0700374 mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb,
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800375 arg = igmpState)
376 self.df = df
377 self.mcastTraffic = mcastTraffic
378 self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP)
A.R Karthick95d044e2016-06-10 18:44:36 -0700379
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700380 mcastTraffic.start()
381 self.send_igmp_join(groups)
382 self.send_igmp_leave(leave_groups, delay = 3)
383 join_state = IGMPTestState(groups = leave_groups)
384 status = self.igmp_not_recv_task(self.V_INF1,leave_groups, join_state)
A R Karthick76a497a2017-04-12 10:59:39 -0700385 log_test.info('verified status for igmp recv task %s'%status)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700386 assert status == 1 , 'EXPECTED RESULT'
387 self.df.callback(0)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800388 return df
389
390 @deferred(timeout=100)
391 def test_igmp_leave_join_loop(self):
392 self.groups = ['226.0.1.1', '227.0.0.1', '228.0.0.1', '229.0.0.1', '230.0.0.1' ]
393 self.src_list = ['3.4.5.6', '7.8.9.10']
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700394 self.onos_ssm_table_load(self.groups,src_list=self.src_list)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800395 df = defer.Deferred()
396 self.df = df
397 self.iterations = 0
398 self.num_groups = len(self.groups)
399 self.MAX_TEST_ITERATIONS = 10
400
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800401 def igmp_srp_task(v):
402 if self.iterations < self.MAX_TEST_ITERATIONS:
403 if v == 1:
404 ##join test
405 self.num_groups = random.randint(0, len(self.groups))
406 self.send_igmp_join(self.groups[:self.num_groups],
407 src_list = self.src_list,
408 iface = 'veth0', delay = 0)
409 else:
410 self.send_igmp_leave(self.groups[:self.num_groups],
411 src_list = self.src_list,
412 iface = 'veth0', delay = 0)
413 self.iterations += 1
414 v ^= 1
415 reactor.callLater(1.0 + 0.5*self.num_groups,
416 igmp_srp_task, v)
417 else:
418 self.df.callback(0)
419
420 reactor.callLater(0, igmp_srp_task, 1)
421 return df
422
423 def igmp_join_task(self, intf, groups, state, src_list = ['1.2.3.4']):
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700424 #self.onos_ssm_table_load(groups, src_list)
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800425 igmp = IGMPv3(type = IGMP_TYPE_V3_MEMBERSHIP_REPORT, max_resp_code=30,
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700426 gaddr=self.IP_DST)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800427 for g in groups:
Chetan Gaonker38737f82016-05-11 17:44:17 -0700428 gr = IGMPv3gr(rtype = IGMP_V3_GR_TYPE_INCLUDE, mcaddr = g)
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800429 gr.sources = src_list
430 igmp.grps.append(gr)
431
432 for g in groups:
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800433 state.group_map[g][0].update(1, t = monotonic.monotonic())
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800434
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700435 pkt = self.igmp_eth/self.igmp_ip/igmp
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800436 IGMPv3.fixup(pkt)
437 sendp(pkt, iface=intf)
A R Karthick76a497a2017-04-12 10:59:39 -0700438 log_test.debug('Returning from join task')
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800439
440 def igmp_recv_task(self, intf, groups, join_state):
441 recv_socket = L3PacketSocket(iface = intf, type = ETH_P_IP)
442 group_map = {}
443 for g in groups:
444 group_map[g] = [0,0]
445
A R Karthick76a497a2017-04-12 10:59:39 -0700446 log_test.info('Verifying join interface should receive multicast data')
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800447 while True:
448 p = recv_socket.recv()
449 if p.dst in groups and group_map[p.dst][0] == 0:
450 group_map[p.dst][0] += 1
451 group_map[p.dst][1] = monotonic.monotonic()
452 c = 0
453 for g in groups:
454 c += group_map[g][0]
455 if c == len(groups):
456 break
457 for g in groups:
458 join_start = join_state.group_map[g][0].start
459 recv_time = group_map[g][1] * 1000000
460 delta = (recv_time - join_start)
A R Karthick76a497a2017-04-12 10:59:39 -0700461 log_test.info('Join for group %s received in %.3f usecs' %
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800462 (g, delta))
463
464 recv_socket.close()
A R Karthick76a497a2017-04-12 10:59:39 -0700465 log_test.debug('Returning from recv task')
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700466
467 def igmp_not_recv_task(self, intf, groups, join_state):
A R Karthick76a497a2017-04-12 10:59:39 -0700468 log_test.info('Entering igmp not recv task loop')
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700469 recv_socket = L2Socket(iface = intf, type = ETH_P_IP)
470 group_map = {}
471 for g in groups:
472 group_map[g] = [0,0]
473
A R Karthick76a497a2017-04-12 10:59:39 -0700474 log_test.info('Verifying join interface, should not receive any multicast data')
Chetan Gaonker7791bda2016-05-12 17:36:52 -0700475 self.NEGATIVE_TRAFFIC_STATUS = 1
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700476 def igmp_recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -0700477 log_test.info('Multicast packet %s received for left groups %s' %(pkt[IP].dst, groups))
Chetan Gaonker7791bda2016-05-12 17:36:52 -0700478 self.NEGATIVE_TRAFFIC_STATUS = 2
Chetan Gaonker38737f82016-05-11 17:44:17 -0700479 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 -0700480 timeout = 3, opened_socket = recv_socket)
481 recv_socket.close()
A.R Karthick95d044e2016-06-10 18:44:36 -0700482 return self.NEGATIVE_TRAFFIC_STATUS
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700483
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800484 def group_latency_check(self, groups):
485 tasks = []
486 self.send_igmp_leave(groups = groups)
487 join_state = IGMPTestState(groups = groups)
488 tasks.append(threading.Thread(target=self.igmp_join_task, args = ('veth0', groups, join_state,)))
489 traffic_state = IGMPTestState(groups = groups)
A.R Karthick95d044e2016-06-10 18:44:36 -0700490 mcast_traffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb,
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800491 arg = traffic_state)
492 mcast_traffic.start()
493 tasks.append(threading.Thread(target=self.igmp_recv_task, args = ('veth0', groups, join_state)))
494 for t in tasks:
495 t.start()
496 for t in tasks:
497 t.join()
498
499 mcast_traffic.stop()
500 self.send_igmp_leave(groups = groups)
501 return
502
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700503 @deferred(timeout=IGMP_QUERY_TIMEOUT + 10)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800504 def test_igmp_1group_join_latency(self):
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700505 groups = ['239.0.1.1']
506 df = defer.Deferred()
507 def igmp_1group_join_latency():
508 self.group_latency_check(groups)
509 df.callback(0)
510 reactor.callLater(0, igmp_1group_join_latency)
511 return df
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800512
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700513 @deferred(timeout=IGMP_QUERY_TIMEOUT + 10)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800514 def test_igmp_2group_join_latency(self):
Chetan Gaonkerddfdc522017-04-04 01:15:04 +0000515 groups = [self.MGROUP1, self.MGROUP1]
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700516 df = defer.Deferred()
517 def igmp_2group_join_latency():
518 self.group_latency_check(groups)
519 df.callback(0)
520 reactor.callLater(0, igmp_2group_join_latency)
521 return df
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800522
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700523 @deferred(timeout=IGMP_QUERY_TIMEOUT + 10)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800524 def test_igmp_Ngroup_join_latency(self):
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700525 groups = ['239.0.1.1', '240.0.1.1', '241.0.1.1', '242.0.1.1']
526 df = defer.Deferred()
527 def igmp_Ngroup_join_latency():
528 self.group_latency_check(groups)
529 df.callback(0)
530 reactor.callLater(0, igmp_Ngroup_join_latency)
531 return df
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800532
A R Karthick2b93d6a2016-09-06 15:19:09 -0700533 def test_igmp_join_rover_all(self):
Chetan Gaonker1f7c3f82016-03-08 12:17:37 -0800534 s = (224 << 24) | 1
535 #e = (225 << 24) | (255 << 16) | (255 << 16) | 255
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700536 e = (224 << 24) | 10
Chetan Gaonker1f7c3f82016-03-08 12:17:37 -0800537 for i in xrange(s, e+1):
538 if i&0xff:
539 ip = '%d.%d.%d.%d'%((i>>24)&0xff, (i>>16)&0xff, (i>>8)&0xff, i&0xff)
540 self.send_igmp_join([ip], delay = 0)
541
A R Karthick2b93d6a2016-09-06 15:19:09 -0700542 @deferred(timeout=ROVER_TEST_TIMEOUT)
543 def test_igmp_join_rover(self):
544 df = defer.Deferred()
545 iface = self.get_igmp_intf()
546 self.df = df
547 self.count = 0
548 self.timeout = 0
549 self.complete = False
550 def igmp_join_timer():
551 self.timeout += self.ROVER_JOIN_TIMEOUT
A R Karthick76a497a2017-04-12 10:59:39 -0700552 log_test.info('IGMP joins sent: %d' %self.count)
A R Karthick2b93d6a2016-09-06 15:19:09 -0700553 if self.timeout >= self.ROVER_TIMEOUT:
554 self.complete = True
555 reactor.callLater(self.ROVER_JOIN_TIMEOUT, igmp_join_timer)
556
557 reactor.callLater(self.ROVER_JOIN_TIMEOUT, igmp_join_timer)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800558 self.start_channel = (224 << 24) | 1
559 self.end_channel = (224 << 24) | 200 #(225 << 24) | (255 << 16) | (255 << 16) | 255
A R Karthick2b93d6a2016-09-06 15:19:09 -0700560 self.current_channel = self.start_channel
561 def igmp_join_rover(self):
562 #e = (224 << 24) | 10
563 chan = self.current_channel
564 self.current_channel += 1
565 if self.current_channel >= self.end_channel:
566 chan = self.current_channel = self.start_channel
567 if chan&0xff:
568 ip = '%d.%d.%d.%d'%((chan>>24)&0xff, (chan>>16)&0xff, (chan>>8)&0xff, chan&0xff)
569 self.send_igmp_join([ip], delay = 0, ssm_load = False, iface = iface)
570 self.count += 1
571 if self.complete == True:
A R Karthick76a497a2017-04-12 10:59:39 -0700572 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 -0700573 self.df.callback(0)
574 else:
575 reactor.callLater(0, igmp_join_rover, self)
576 reactor.callLater(0, igmp_join_rover, self)
577 return df
578
Chetan Gaonker1f7c3f82016-03-08 12:17:37 -0800579 @deferred(timeout=IGMP_QUERY_TIMEOUT + 10)
580 def test_igmp_query(self):
581 groups = ['224.0.0.1'] ##igmp query group
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700582 self.onos_ssm_table_load(groups)
Chetan Gaonker1f7c3f82016-03-08 12:17:37 -0800583 df = defer.Deferred()
584 self.df = df
585 self.recv_socket = L2Socket(iface = 'veth0', type = ETH_P_IP)
A.R Karthick95d044e2016-06-10 18:44:36 -0700586
Chetan Gaonker1f7c3f82016-03-08 12:17:37 -0800587 def igmp_query_timeout():
Chetan Gaonker1f7c3f82016-03-08 12:17:37 -0800588 def igmp_query_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -0700589 log_test.info('received igmp query packet is %s'%pkt.show())
590 log_test.info('Got IGMP query packet from %s for %s' %(pkt[IP].src, pkt[IP].dst))
Chetan Gaonkerbd4390f2016-03-09 18:56:52 -0800591 assert_equal(pkt[IP].dst, '224.0.0.1')
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700592 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 -0800593 opened_socket = self.recv_socket)
Chetan Gaonker1f7c3f82016-03-08 12:17:37 -0800594 self.recv_socket.close()
595 self.df.callback(0)
596
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700597 #self.send_igmp_join(groups)
Chetan Gaonker1f7c3f82016-03-08 12:17:37 -0800598 self.test_timer = reactor.callLater(self.IGMP_QUERY_TIMEOUT, igmp_query_timeout)
599 return df
600
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700601 def igmp_send_joins_different_groups_srclist(self, groups, sources, intf = V_INF1, delay = 2, ip_src = None):
602 g1 = groups[0]
603 g2 = groups[1]
604 sourcelist1 = sources[0]
605 sourcelist2 = sources[1]
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700606 eth = Ether(dst = self.IGMP_DST_MAC,type = ETH_P_IP)
607 ip = IP(dst = self.IP_DST)
A R Karthick76a497a2017-04-12 10:59:39 -0700608 log_test.info('Sending join message for the group %s' %g1)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700609 self.send_igmp_join((g1,), src_list = sourcelist1, ip_pkt = eth/ip, iface = intf, delay = 2)
610 eth = Ether(dst = self.MMACGROUP2, src = self.IGMP_SRC_MAC, type = ETH_P_IP)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700611 ip = IP(dst = g2)
A R Karthick76a497a2017-04-12 10:59:39 -0700612 log_test.info('Sending join message for group %s' %g2)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700613 self.send_igmp_join((g2,), src_list = sourcelist2, ip_pkt = eth/ip, iface = intf, delay = 2)
A R Karthick76a497a2017-04-12 10:59:39 -0700614 log_test.info('Done with igmp_send_joins_different_groups_srclist')
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700615
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700616 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):
617 g1 = groups[0]
618 g2 = groups[1]
619 sourcelist1 = sources[0]
620 sourcelist2 = sources[1]
621 eth = Ether(dst = self.MMACGROUP1, src = self.IGMP_SRC_MAC, type = ETH_P_IP)
622 src_ip = ip_src or self.IP_SRC
623 ip = IP(dst = g1, src = src_ip)
624 if query_group1 is 'group1':
A R Karthick76a497a2017-04-12 10:59:39 -0700625 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 -0700626 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 -0700627 else:
A R Karthick76a497a2017-04-12 10:59:39 -0700628 log_test.info('Sending join message for the group %s' %g1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700629 self.send_igmp_join((g1,), src_list = sourcelist1, ip_pkt = eth/ip, iface = intf, delay = 2)
630 eth = Ether(dst = self.MMACGROUP2, src = self.IGMP_SRC_MAC, type = ETH_P_IP)
631 ip = IP(dst = g2, src = src_ip)
632 if query_group2 is 'group2':
A R Karthick76a497a2017-04-12 10:59:39 -0700633 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 -0700634 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 -0700635 else:
A R Karthick76a497a2017-04-12 10:59:39 -0700636 log_test.info('Sending join message for group %s' %g2)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700637 self.send_igmp_join((g2,), src_list = sourcelist2, ip_pkt = eth/ip, iface = intf, delay = 2)
638
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700639 def igmp_joins_leave(self,groups,src_list,again_join = False, df = None):
640 groups1 = [groups[0]]
641 groups2 = [groups[1]]
642 src1 = [src_list[0]]
643 src2 = [src_list[1]]
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700644 self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700645 (src1, src2), intf = self.V_INF1, delay = 2)
646
647 src_ip = src1[0]
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700648 if df is None:
649 df = defer.Deferred()
650 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800651 IGMPTestState(groups = groups1, df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700652
653 igmpState2 = IGMPTestState(groups = groups2, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800654 IGMPTestState(groups = groups2, df = df)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700655 dst_mac = self.iptomac(groups1[0])
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700656 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
657 src_ip = src_ip, cb = self.send_mcast_cb,
658 arg = igmpState1)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700659 src_ip = src2[0]
660 dst_mac = self.iptomac(groups1[0])
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700661 mcastTraffic2 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
662 src_ip = src_ip, cb = self.send_mcast_cb,
663 arg = igmpState2)
664 mcastTraffic1.start()
665 mcastTraffic2.start()
666 join_state1 = IGMPTestState(groups = groups1)
667 join_state2 = IGMPTestState(groups = groups2)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800668 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
A R Karthick76a497a2017-04-12 10:59:39 -0700669 log_test.info('Interface is receiving multicast groups %s' %groups1)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800670 self.igmp_recv_task(self.V_INF1, groups2, join_state2)
A R Karthick76a497a2017-04-12 10:59:39 -0700671 log_test.info('Interface is receiving multicast groups %s' %groups2)
672 log_test.info('Interface is sending leave message for groups %s now' %groups2)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700673 self.send_igmp_leave(groups = groups2, src_list = src2, iface = self.V_INF1, delay = 2)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800674 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700675 target4 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state2)
676 assert target4 == 1, 'EXPECTED FAILURE'
677 if again_join:
678 dst_mac = '01:00:5e:02:02:03'
679 ip_dst = '239.2.2.3'
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700680 eth = Ether(dst = dst_mac, type = ETH_P_IP)
681 ip = IP(dst = ip_dst)
A R Karthick76a497a2017-04-12 10:59:39 -0700682 log_test.info('Interface sending join message again for the groups %s' %groups2)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700683 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 -0800684 self.igmp_recv_task(self.V_INF1, groups2, join_state2)
A R Karthick76a497a2017-04-12 10:59:39 -0700685 log_test.info('Interface is receiving multicast groups %s again' %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 still receiving from multicast groups %s' %groups1)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700688 else:
A R Karthick76a497a2017-04-12 10:59:39 -0700689 log_test.info('Ended test case')
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700690 mcastTraffic1.stop()
691 mcastTraffic2.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -0700692
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700693
694 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700695 def test_igmp_2joins_1leave(self):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700696 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700697 def igmp_2joins_1leave():
698 groups = ['234.2.3.4','236.8.7.9']
699 src_list = ['2.3.4.5','5.4.3.2']
700 self.onos_ssm_table_load(groups,src_list = src_list)
701 self.igmp_joins_leave(groups,src_list,again_join = False, df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700702 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700703 reactor.callLater(0, igmp_2joins_1leave)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700704 return df
705
706 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+25)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700707 def test_igmp_2joins_1leave_and_join_again(self):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700708 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700709 def igmp_2joins_1leave_join_again():
710 groups = ['234.2.3.4','236.8.7.9']
711 src_list = ['2.3.4.5','5.4.3.2']
712 self.onos_ssm_table_load(groups,src_list = src_list)
713 self.igmp_joins_leave(groups,src_list,again_join = True, df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700714 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700715 reactor.callLater(0, igmp_2joins_1leave_join_again)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700716 return df
717
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700718 def igmp_not_in_src_list(self, df = None):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700719 groups1 = (self.MGROUP1,)
720 groups2 = (self.MGROUP2,)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700721 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 -0700722 self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
723 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
724 intf = self.V_INF1, delay = 2)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700725 src_ip = '6.6.6.6'
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700726 dst_mac = self.iptomac(groups1[0])
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700727 if df is None:
728 df = defer.Deferred()
729 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800730 IGMPTestState(groups = groups1, df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700731 mcastTraffic1 = McastTraffic(groups1, iface = 'veth2', dst_mac = dst_mac,
732 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
733 mcastTraffic1.start()
734 join_state1 = IGMPTestState(groups = groups1)
A R Karthick76a497a2017-04-12 10:59:39 -0700735 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 -0700736 target1 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
Chetan Gaonker7791bda2016-05-12 17:36:52 -0700737 assert target1 == 2, 'EXPECTED FAILURE'
A R Karthick76a497a2017-04-12 10:59:39 -0700738 log_test.info('Interface is not receiving traffic from multicast groups %s, working as expected' %groups1)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700739 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -0700740
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700741 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700742 def test_igmp_not_in_src_list(self):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700743 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700744 def igmp_not_in_src_list():
745 self.igmp_not_in_src_list(df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700746 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700747 reactor.callLater(0, igmp_not_in_src_list)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700748 return df
749
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700750 def igmp_change_to_exclude_src_list(self, df = None):
751 groups1 = [self.random_mcast_ip()]
752 groups2 = [self.random_mcast_ip()]
753 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 -0700754 self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
755 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
756 intf = self.V_INF1, delay = 2)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700757 src_ip = '2.2.2.2'
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700758 dst_mac=self.iptomac(groups1[0])
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700759 if df is None:
760 df = defer.Deferred()
761 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800762 IGMPTestState(groups = groups1, df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700763 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
764 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
765 mcastTraffic1.start()
766 join_state1 = IGMPTestState(groups = groups1)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800767 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700768 self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2'], iface = self.V_INF1, delay =2)
769 target2 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
Chetan Gaonker7791bda2016-05-12 17:36:52 -0700770 assert target2 == 2, 'EXPECTED FAILURE'
A R Karthick76a497a2017-04-12 10:59:39 -0700771 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 -0700772 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -0700773
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700774 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700775 def test_igmp_change_to_exclude_src_list(self):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700776 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700777 def igmp_change_to_exclude_src_list():
778 self.igmp_change_to_exclude_src_list(df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700779 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700780 reactor.callLater(0, igmp_change_to_exclude_src_list)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700781 return df
782
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700783 def igmp_include_to_allow_src_list(self, df = None):
784 groups1 = [self.random_mcast_ip()] #(self.MGROUP1,)
785 self.onos_ssm_table_load(groups1,src_list = ['4.4.4.4','6.6.6.6'])
786 self.send_igmp_join(groups = groups1, src_list = ['4.4.4.4'],record_type = IGMP_V3_GR_TYPE_INCLUDE,
787 iface = self.V_INF1)
788 src_ip = '4.4.4.4'
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700789 if df is None:
790 df = defer.Deferred()
791 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800792 IGMPTestState(groups = groups1, df = df)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700793 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2',src_ip = src_ip,
794 cb = self.send_mcast_cb, arg = igmpState1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700795 mcastTraffic1.start()
796 join_state1 = IGMPTestState(groups = groups1)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800797 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700798 mcastTraffic1.stop()
799 mcastTraffic2 = McastTraffic(groups1, iface= 'veth2',src_ip = '6.6.6.6',
800 cb = self.send_mcast_cb, arg = igmpState1)
801 self.send_igmp_join(groups = groups1, src_list = ['6.6.6.6'],record_type = IGMP_V3_GR_TYPE_ALLOW_NEW,
802 iface = self.V_INF1)
803 mcastTraffic2.start()
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800804 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700805 mcastTraffic2.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -0700806
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700807 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+30)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700808 def test_igmp_include_to_allow_src_list(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700809 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700810 def igmp_include_to_allow_src_list():
811 self.igmp_include_to_allow_src_list(df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700812 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700813 reactor.callLater(0, igmp_include_to_allow_src_list)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700814 return df
815
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700816 def igmp_include_to_block_src_list(self, df = None):
817 groups1 = [self.random_mcast_ip()] #groups1 = (self.MGROUP1,)
818 self.onos_ssm_table_load(groups1,src_list = ['4.4.4.4','6.6.6.6'])
819 self.send_igmp_join(groups = groups1, src_list = ['4.4.4.4','6.6.6.6'],record_type = IGMP_V3_GR_TYPE_INCLUDE,
820 iface = self.V_INF1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700821 if df is None:
822 df = defer.Deferred()
823 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800824 IGMPTestState(groups = groups1, df = df)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700825 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2',src_ip = '6.6.6.6',
826 cb = self.send_mcast_cb, arg = igmpState1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700827 mcastTraffic1.start()
828 join_state1 = IGMPTestState(groups = groups1)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800829 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700830 mcastTraffic1.stop()
831 self.send_igmp_join(groups = groups1, src_list = ['6.6.6.6'],record_type = IGMP_V3_GR_TYPE_BLOCK_OLD,
832 iface = self.V_INF1)
833 mcastTraffic2 = McastTraffic(groups1, iface= 'veth2',src_ip = '6.6.6.6',
834 cb = self.send_mcast_cb, arg = igmpState1)
835 mcastTraffic2.start()
836 target1 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
837 assert target1 == 1, 'EXPECTED FAILURE'
A R Karthick76a497a2017-04-12 10:59:39 -0700838 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 -0700839 mcastTraffic2.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -0700840
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700841 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+30)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700842 def test_igmp_include_to_block_src_list(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700843 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700844 def igmp_include_to_block_src_list():
845 self.igmp_include_to_block_src_list(df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700846 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700847 reactor.callLater(0, igmp_include_to_block_src_list)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700848 return df
849
850
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700851 def igmp_change_to_include_src_list(self, df = None):
852 groups1 = [self.random_mcast_ip()]
853 src_list = ['4.4.4.4','6.6.6.6']
854 self.onos_ssm_table_load(groups1,src_list = src_list)
855 self.send_igmp_leave(groups = groups1, src_list = src_list,
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700856 iface = self.V_INF1, delay = 2)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700857 if df is None:
858 df = defer.Deferred()
859 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800860 IGMPTestState(groups = groups1, df = df)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700861 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2',src_ip = src_list[0],
862 cb = self.send_mcast_cb, arg = igmpState1)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700863 mcastTraffic1.start()
864 join_state1 = IGMPTestState(groups = groups1)
865 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
866 assert target1 == 1, 'EXPECTED FAILURE'
A R Karthick76a497a2017-04-12 10:59:39 -0700867 log_test.info('Interface is not receiving traffic from multicast groups %s' %groups1)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700868 mcastTraffic1.stop()
869 self.send_igmp_join(groups = groups1, src_list = src_list,record_type = IGMP_V3_GR_TYPE_INCLUDE,
870 iface = self.V_INF1)
871 mcastTraffic2 = McastTraffic(groups1, iface= 'veth2',src_ip = src_list[1],
872 cb = self.send_mcast_cb, arg = igmpState1)
873 mcastTraffic2.start()
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800874 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700875 mcastTraffic2.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -0700876
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700877 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700878 def test_igmp_change_to_include_src_list(self):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700879 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700880 def igmp_change_to_include_src_list():
881 self.igmp_change_to_include_src_list(df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700882 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700883 reactor.callLater(0, igmp_change_to_include_src_list)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700884 return df
885
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700886 #this test case failing because group in include receiving multicast traffic from any of the source
887 def igmp_exclude_to_allow_src_list(self, df = None):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700888 groups1 = (self.MGROUP1,)
889 groups2 = (self.MGROUP2,)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700890 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 -0700891 self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4'],
892 iface = self.V_INF1, delay = 2)
A.R Karthick95d044e2016-06-10 18:44:36 -0700893
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700894 dst_mac = '01:00:5e:01:02:03'
895 src_ip = '2.2.2.2'
896 if df is None:
897 df = defer.Deferred()
898 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800899 IGMPTestState(groups = groups1, df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700900 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
901 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
902 mcastTraffic1.start()
903 join_state1 = IGMPTestState(groups = groups1)
904 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
905 assert target1 == 1, 'EXPECTED FAILURE'
A R Karthick76a497a2017-04-12 10:59:39 -0700906 log_test.info('Interface is not receiving traffic from multicast groups %s' %groups1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700907 self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
908 (['6.6.6.6', '7.7.7.7', '8.8.8.8'], ['6.6.6.6', '5.5.5.5']),
909 intf = self.V_INF1, delay = 2)
910 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
911 assert target1 == 1, 'EXPECTED FAILURE'
A R Karthick76a497a2017-04-12 10:59:39 -0700912 log_test.info('Interface is not receiving traffic from multicast groups %s' %groups1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700913 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -0700914
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700915 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700916 def test_igmp_exclude_to_allow_src_list(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700917 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700918 def igmp_exclude_to_allow_src_list():
919 self.igmp_exclude_to_allow_src_list(df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700920 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700921 reactor.callLater(0, igmp_exclude_to_allow_src_list)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700922 return df
923
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700924 def igmp_exclude_to_block_src_list(self, df = None):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700925 groups1 = (self.MGROUP1,)
926 groups2 = (self.MGROUP2,)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700927 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 -0700928 self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4'],
929 iface = self.V_INF1, delay = 2)
A.R Karthick95d044e2016-06-10 18:44:36 -0700930
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700931 dst_mac = '01:00:5e:01:02:03'
932 src_ip = '2.2.2.2'
933 if df is None:
934 df = defer.Deferred()
935 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800936 IGMPTestState(groups = groups1, df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700937 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
938 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
939 mcastTraffic1.start()
940 join_state1 = IGMPTestState(groups = groups1)
941 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
942 assert target1 == 1, 'EXPECTED FAILURE'
A R Karthick76a497a2017-04-12 10:59:39 -0700943 log_test.info('Interface is not receiving traffic from multicast groups %s' %groups1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700944 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'],
945 iface = self.V_INF1, delay = 2)
946 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
947 assert target1 == 1, 'EXPECTED FAILURE'
A R Karthick76a497a2017-04-12 10:59:39 -0700948 log_test.info('Interface is not receiving traffic from multicast groups %s' %groups1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700949 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -0700950
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700951 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700952 def test_igmp_exclude_to_block_src_list(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700953 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700954 def igmp_exclude_to_block_src_list():
955 self.igmp_exclude_to_block_src_list(df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700956 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700957 reactor.callLater(0, igmp_exclude_to_block_src_list)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700958 return df
959
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700960 #this test case failing because group in include mode recieves traffic from other sources also.
961 def igmp_new_src_list(self, df = None):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700962 groups1 = (self.MGROUP1,)
963 groups2 = (self.MGROUP2,)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700964 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 -0700965 self.igmp_send_joins_different_groups_srclist(groups1+groups2,
966 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
967 intf = self.V_INF1, delay = 2)
968 dst_mac = '01:00:5e:01:02:03'
969 src_ip = '6.6.6.6'
970 if df is None:
971 df = defer.Deferred()
972 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800973 IGMPTestState(groups = groups1, df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700974 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
975 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
976 mcastTraffic1.start()
977 join_state1 = IGMPTestState(groups = groups1)
978 target1 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
979 assert target1 == 1, 'EXPECTED FAILURE'
A R Karthick76a497a2017-04-12 10:59:39 -0700980 log_test.info('Interface is not receiving traffic from multicast groups %s' %groups1)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700981 self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700982 (['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 -0700983 intf = self.V_INF1, delay = 2)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800984 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
A R Karthick76a497a2017-04-12 10:59:39 -0700985 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 -0700986 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -0700987
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700988 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700989 def test_igmp_new_src_list(self):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700990 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700991 def igmp_new_src_list():
992 self.igmp_new_src_list(df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700993 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700994 reactor.callLater(0, igmp_new_src_list)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700995 return df
996
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700997 def igmp_block_old_src_list(self, df = None):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700998 groups1 = (self.MGROUP1,)
999 groups2 = (self.MGROUP2,)
1000 groups = groups1 + groups2
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001001 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 -07001002 self.igmp_send_joins_different_groups_srclist(groups,
1003 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
1004 intf = self.V_INF1, delay = 2)
1005 dst_mac = '01:00:5e:02:02:03'
1006 src_ip = '5.5.5.5'
1007 if df is None:
1008 df = defer.Deferred()
1009 igmpState1 = IGMPTestState(groups = groups2, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001010 IGMPTestState(groups = groups2, df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001011 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1012 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1013 mcastTraffic1.start()
1014 join_state1 = IGMPTestState(groups = groups2)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001015 self.igmp_recv_task(self.V_INF1, groups2, join_state1)
A R Karthick76a497a2017-04-12 10:59:39 -07001016 log_test.info('Interface is receiving traffic from multicast groups %s' %groups2)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001017 self.igmp_send_joins_different_groups_srclist(groups,
1018 (['6.6.6.6', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '7.7.7.7']),
1019 intf = self.V_INF1, delay = 2)
1020 target2 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1)
Chetan Gaonker7791bda2016-05-12 17:36:52 -07001021 assert target2 == 2, 'EXPECTED FAILURE'
A R Karthick76a497a2017-04-12 10:59:39 -07001022 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 -07001023 mcastTraffic1.stop()
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001024
1025 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001026 def test_igmp_block_old_src_list(self):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001027 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001028 def igmp_block_old_src_list():
1029 self.igmp_block_old_src_list(df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001030 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001031 reactor.callLater(0, igmp_block_old_src_list)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001032 return df
1033
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001034 def igmp_include_empty_src_list(self, df = None):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001035 groups1 = (self.MGROUP1,)
1036 groups2 = (self.MGROUP2,)
1037 groups = groups1 + groups2
1038 self.igmp_send_joins_different_groups_srclist(groups,
Thangavelu K S790ad332016-12-14 12:54:58 +05301039 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['0']),
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001040 intf = self.V_INF1, delay = 2)
1041 dst_mac = '01:00:5e:02:02:03'
1042 src_ip = '5.5.5.5'
1043 if df is None:
1044 df = defer.Deferred()
1045 igmpState1 = IGMPTestState(groups = groups2, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001046 IGMPTestState(groups = groups2, df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001047 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1048 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1049 mcastTraffic1.start()
1050 join_state1 = IGMPTestState(groups = groups2)
1051 target1 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1)
1052 assert target1==1, 'EXPECTED FAILURE'
A R Karthick76a497a2017-04-12 10:59:39 -07001053 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 -07001054 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001055
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001056 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001057 def test_igmp_include_empty_src_list(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001058 ## '''Disabling this test as scapy IGMP doesn't work with empty source lists'''
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001059 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001060 def igmp_include_empty_src_list():
1061 self.igmp_include_empty_src_list(df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001062 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001063 reactor.callLater(0, igmp_include_empty_src_list)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001064 return df
1065
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001066 def igmp_exclude_empty_src_list(self, df = None):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001067 groups2 = (self.MGROUP2,)
Thangavelu K S790ad332016-12-14 12:54:58 +05301068 self.send_igmp_leave(groups = groups2, src_list = ['0'], iface = self.V_INF1, delay = 2)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001069 dst_mac = '01:00:5e:02:02:03'
1070 src_ip = '5.5.5.5'
1071 if df is None:
1072 df = defer.Deferred()
1073 igmpState1 = IGMPTestState(groups = groups2, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001074 IGMPTestState(groups = groups2, df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001075 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1076 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1077 mcastTraffic1.start()
1078 join_state1 = IGMPTestState(groups = groups2)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001079 self.igmp_recv_task(self.V_INF1, groups2, join_state1)
A R Karthick76a497a2017-04-12 10:59:39 -07001080 log_test.info('Interface is receiving multicast groups %s' %groups2)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001081 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001082
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001083 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001084 def test_igmp_exclude_empty_src_list(self):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001085 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001086 def igmp_exclude_empty_src_list():
1087 self.igmp_exclude_empty_src_list()
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001088 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001089 reactor.callLater(0, igmp_exclude_empty_src_list)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001090 return df
1091
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001092 def igmp_join_sourceip_0_0_0_0(self, df = None):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001093 groups1 = (self.MGROUP1,)
1094 groups2 = (self.MGROUP2,)
1095 groups = groups1 + groups2
1096 ip_src = '0.0.0.0'
1097 self.igmp_send_joins_different_groups_srclist(groups,
1098 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['5.5.5.5']),
1099 intf = self.V_INF1, delay = 2, ip_src = ip_src)
1100 ip_src = self.IP_SRC
1101 dst_mac = '01:00:5e:02:02:03'
1102 src_ip = '5.5.5.5'
1103 if df is None:
1104 df = defer.Deferred()
1105 igmpState1 = IGMPTestState(groups = groups2, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001106 IGMPTestState(groups = groups2, df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001107 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1108 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1109 mcastTraffic1.start()
1110 join_state1 = IGMPTestState(groups = groups2)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001111 self.igmp_recv_task(self.V_INF1, groups2, join_state1)
A R Karthick76a497a2017-04-12 10:59:39 -07001112 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 -07001113 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001114
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001115 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001116 def test_igmp_join_sourceip_0_0_0_0(self):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001117 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001118 def igmp_join_sourceip_0_0_0_0():
1119 self.igmp_join_sourceip_0_0_0_0(df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001120 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001121 reactor.callLater(0, igmp_join_sourceip_0_0_0_0)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001122 return df
1123
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001124 def igmp_invalid_join_packet(self, df = None):
Chetan Gaonker586fec32016-04-29 17:33:54 -07001125 groups1 = (self.MGROUP1,)
1126 groups2 = (self.MINVALIDGROUP1,)
1127 groups = groups1 + groups2
1128 ip_src = '1.1.1.1'
1129 self.igmp_send_joins_different_groups_srclist(groups,
1130 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['5.5.5.5']),
1131 intf = self.V_INF1, delay = 2, ip_src = ip_src)
1132 ip_src = self.IP_SRC
1133 dst_mac = '01:00:5e:02:02:03'
1134 src_ip = '5.5.5.5'
1135 if df is None:
1136 df = defer.Deferred()
1137 igmpState1 = IGMPTestState(groups = groups2, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001138 IGMPTestState(groups = groups2, df = df)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001139 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1140 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1141 mcastTraffic1.start()
1142 join_state1 = IGMPTestState(groups = groups2)
1143 target1 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1)
1144 assert target1==1, 'EXPECTED FAILURE'
A R Karthick76a497a2017-04-12 10:59:39 -07001145 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 -07001146 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001147
Chetan Gaonker586fec32016-04-29 17:33:54 -07001148 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001149 def test_igmp_invalid_join_packet(self):
Chetan Gaonker586fec32016-04-29 17:33:54 -07001150 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001151 def igmp_invalid_join_packet():
1152 self.igmp_invalid_join_packet(df = df)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001153 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001154 reactor.callLater(0, igmp_invalid_join_packet)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001155 return df
1156
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001157 def igmp_join_data_receiving_during_subscriber_link_toggle(self, df = None):
Chetan Gaonker586fec32016-04-29 17:33:54 -07001158 groups1 = (self.MGROUP1,)
1159 groups2 = (self.MGROUP2,)
1160 groups = groups1 + groups2
1161 ip_src = '1.1.1.1'
1162 self.igmp_send_joins_different_groups_srclist(groups,
1163 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['5.5.5.5']),
1164 intf = self.V_INF1, delay = 2, ip_src = ip_src)
1165 ip_src = self.IP_SRC
1166 dst_mac = '01:00:5e:02:02:03'
1167 src_ip = '5.5.5.5'
1168 if df is None:
1169 df = defer.Deferred()
1170 igmpState1 = IGMPTestState(groups = groups2, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001171 IGMPTestState(groups = groups2, df = df)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001172 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1173 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1174 mcastTraffic1.start()
1175 join_state1 = IGMPTestState(groups = groups2)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001176 self.igmp_recv_task(self.V_INF1, groups2, join_state1)
A R Karthick76a497a2017-04-12 10:59:39 -07001177 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 -07001178 os.system('ifconfig '+self.V_INF1+' down')
A R Karthick76a497a2017-04-12 10:59:39 -07001179 log_test.info(' the self.V_INF1 %s is down now ' %self.V_INF1)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001180 os.system('ifconfig '+self.V_INF1)
1181 time.sleep(10)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001182 os.system('ifconfig '+self.V_INF1+' up')
1183 os.system('ifconfig '+self.V_INF1)
A R Karthick76a497a2017-04-12 10:59:39 -07001184 log_test.info(' the self.V_INF1 %s is up now ' %self.V_INF1)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001185 self.igmp_recv_task(self.V_INF1, groups2, join_state1)
A R Karthick76a497a2017-04-12 10:59:39 -07001186 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 -07001187 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001188
Chetan Gaonker586fec32016-04-29 17:33:54 -07001189 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001190 def test_igmp_join_data_received_during_subscriber_link_toggle(self):
Chetan Gaonker586fec32016-04-29 17:33:54 -07001191 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001192 def igmp_join_data_received_during_subscriber_link_toggle():
1193 self.igmp_join_data_received_during_subscriber_link_toggle(df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001194 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001195 reactor.callLater(0, igmp_join_data_received_during_subscriber_link_toggle)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001196 return df
1197
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001198 def igmp_join_data_received_during_channel_distributor_link_toggle(self, df = None):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001199 groups1 = (self.MGROUP1,)
1200 groups2 = (self.MGROUP2,)
1201 groups = groups1 + groups2
1202 ip_src = '1.1.1.1'
1203 self.igmp_send_joins_different_groups_srclist(groups,
1204 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['5.5.5.5', '6.6.6.6']),
1205 intf = self.V_INF1, delay = 2, ip_src = ip_src)
1206 ip_src = self.IP_SRC
1207 dst_mac1 = '01:00:5e:01:02:03'
1208 dst_mac2 = '01:00:5e:02:02:03'
1209 src_ip2 = '5.5.5.5'
1210 src_ip1 = '2.2.2.2'
1211 if df is None:
1212 df = defer.Deferred()
1213 igmpState1 = IGMPTestState(groups = groups1, df = df)
1214 igmpState2 = IGMPTestState(groups = groups2, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001215 IGMPTestState(groups = groups1, df = df)
1216 IGMPTestState(groups = groups2, df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001217 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac1,
1218 src_ip = src_ip1, cb = self.send_mcast_cb, arg = igmpState1)
1219 mcastTraffic2 = McastTraffic(groups2, iface= 'veth3', dst_mac = dst_mac2,
1220 src_ip = src_ip2, cb = self.send_mcast_cb, arg = igmpState2)
1221 mcastTraffic1.start()
1222 mcastTraffic2.start()
1223 join_state1 = IGMPTestState(groups = groups1)
1224 join_state2 = IGMPTestState(groups = groups2)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001225 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
1226 self.igmp_recv_task(self.V_INF1, groups2, join_state2)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001227 mcastTraffic1.stop()
1228 os.system('ifconfig '+'veth2'+' down')
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001229 os.system('ifconfig '+'veth2')
1230 time.sleep(10)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001231 self.igmp_not_recv_task(self.V_INF1, groups2, join_state1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001232 target1 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
1233 assert target1==1, 'EXPECTED FAILURE'
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001234 os.system('ifconfig '+'veth2'+' up')
1235 os.system('ifconfig '+'veth2')
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001236 time.sleep(10)
1237 mcastTraffic1.start()
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001238 self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
1239 self.igmp_recv_task(self.V_INF1, groups2, join_state2)
1240 self.igmp_recv_task(self.V_INF1, groups2, join_state2)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001241 mcastTraffic2.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001242
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001243 ## This test case is failing to receive traffic from multicast data from defferent channel interfaces TO-DO
1244 ###### TO DO scenario #######
1245 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+60)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001246 def test_igmp_join_data_received_during_channel_distributors_link_toggle(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001247 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001248 def igmp_join_data_receiving_during_channel_distributor_link_toggle():
Thangavelu K S790ad332016-12-14 12:54:58 +05301249 self.igmp_join_data_received_during_channel_distributor_link_toggle(df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001250 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001251 reactor.callLater(0, igmp_join_data_receiving_during_channel_distributor_link_toggle)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001252 return df
Chetan Gaonker586fec32016-04-29 17:33:54 -07001253
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001254 def igmp_invalidClassD_IP_join_packet(self, df = None):
Chetan Gaonker586fec32016-04-29 17:33:54 -07001255 groups1 = (self.MGROUP1,)
1256 groups2 = (self.MINVALIDGROUP2,)
1257 groups = groups1 + groups2
1258 ip_src = '1.1.1.1'
1259 self.igmp_send_joins_different_groups_srclist(groups,
1260 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['5.5.5.5']),
1261 intf = self.V_INF1, delay = 2, ip_src = ip_src)
1262 ip_src = self.IP_SRC
1263 dst_mac = '01:00:5e:02:02:03'
1264 src_ip = '5.5.5.5'
1265 if df is None:
1266 df = defer.Deferred()
1267 igmpState1 = IGMPTestState(groups = groups2, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001268 IGMPTestState(groups = groups2, df = df)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001269 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1270 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1271 mcastTraffic1.start()
1272 join_state1 = IGMPTestState(groups = groups2)
1273 target1 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1)
1274 assert target1==1, 'EXPECTED FAILURE'
A R Karthick76a497a2017-04-12 10:59:39 -07001275 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 -07001276 mcastTraffic1.stop()
Chetan Gaonker586fec32016-04-29 17:33:54 -07001277
1278 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001279 def test_igmp_invalid_class_d_ip_for_join_packet(self):
Chetan Gaonker586fec32016-04-29 17:33:54 -07001280 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001281 def igmp_invalidClass_D_IP_join_packet():
Thangavelu K S790ad332016-12-14 12:54:58 +05301282 self.igmp_invalidClassD_IP_join_packet(df = df)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001283 df.callback(0)
Thangavelu K S790ad332016-12-14 12:54:58 +05301284 reactor.callLater(0, igmp_invalidClass_D_IP_join_packet)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001285 return df
1286
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001287 def igmp_invalidClassD_IP_as_srclistIP_join_packet(self, df = None):
Chetan Gaonker586fec32016-04-29 17:33:54 -07001288 groups1 = (self.MGROUP1,)
1289 groups2 = (self.MGROUP2,)
1290 groups = groups1 + groups2
1291 ip_src = '1.1.1.1'
1292 self.igmp_send_joins_different_groups_srclist(groups,
1293 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['239.5.5.5']),
1294 intf = self.V_INF1, delay = 2, ip_src = ip_src)
1295 ip_src = self.IP_SRC
1296 dst_mac = '01:00:5e:02:02:03'
1297 src_ip = '5.5.5.5'
1298 if df is None:
1299 df = defer.Deferred()
1300 igmpState1 = IGMPTestState(groups = groups2, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001301 IGMPTestState(groups = groups2, df = df)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001302 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1303 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1304 mcastTraffic1.start()
1305 join_state1 = IGMPTestState(groups = groups2)
1306 target1 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1)
1307 assert target1==1, 'EXPECTED FAILURE'
A R Karthick76a497a2017-04-12 10:59:39 -07001308 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 -07001309 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001310
Chetan Gaonker586fec32016-04-29 17:33:54 -07001311 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001312 def test_igmp_invalid_class_d_ip_as_srclist_ip_for_join_packet(self):
Chetan Gaonker586fec32016-04-29 17:33:54 -07001313 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001314 def igmp_invalidClassD_IP_as_srclistIP_join_packet():
1315 self.igmp_invalidClassD_IP_as_srclistIP_join_packet(df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001316 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001317 reactor.callLater(0, igmp_invalidClassD_IP_as_srclistIP_join_packet)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001318 return df
Chetan Gaonkerf72ca402016-05-02 16:29:32 -07001319
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001320 def igmp_general_query_recv_packet(self, df = None):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001321 groups1 = (self.MGROUP1,)
1322 groups2 = (self.MGROUP2,)
1323 groups = groups1 + groups2
1324 ip_src = '1.1.1.1'
1325 self.igmp_send_joins_different_groups_srclist(groups,
1326 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['5.5.5.5']),
1327 intf = self.V_INF1, delay = 2, ip_src = ip_src)
1328 ip_src = self.IP_SRC
1329 dst_mac = '01:00:5e:02:02:03'
1330 src_ip = '5.5.5.5'
1331 if df is None:
1332 df = defer.Deferred()
1333 igmpState1 = IGMPTestState(groups = groups2, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001334 IGMPTestState(groups = groups2, df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001335 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1336 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1337 mcastTraffic1.start()
1338 join_state1 = IGMPTestState(groups = groups2)
A R Karthick76a497a2017-04-12 10:59:39 -07001339 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 -07001340 time.sleep(100)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001341 self.igmp_recv_task(self.V_INF1, groups2, join_state1)
A R Karthick76a497a2017-04-12 10:59:39 -07001342 log_test.info('Verified that multicast data for group %s is received after 100 sec ' %groups2)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001343 time.sleep(50)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001344 self.igmp_recv_task(self.V_INF1, groups2, join_state1)
A R Karthick76a497a2017-04-12 10:59:39 -07001345 log_test.info('Verified that multicast data for group %s is received after 150 sec ' %groups2)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001346 time.sleep(30)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001347 self.igmp_recv_task(self.V_INF1, groups2, join_state1)
A R Karthick76a497a2017-04-12 10:59:39 -07001348 log_test.info('Verified that multicast data for group %s is received after 180 sec ' %groups2)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001349 time.sleep(10)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001350 self.igmp_recv_task(self.V_INF1, groups2, join_state1)
A R Karthick76a497a2017-04-12 10:59:39 -07001351 log_test.info('Verified that multicast data for group %s is received after 190 sec ' %groups2)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001352 target3 = mcastTraffic1.isRecvStopped()
1353 assert target3==False, 'EXPECTED FAILURE'
A R Karthick76a497a2017-04-12 10:59:39 -07001354 log_test.info('Verified that multicast data for a group %s is still transmitting from a data interface' %groups2)
1355 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 -07001356 target1 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1)
1357 assert target1==1, 'EXPECTED FAILURE'
A R Karthick76a497a2017-04-12 10:59:39 -07001358 log_test.info('Interface is not receiving multicast data for group %s' %groups2)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001359 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001360
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001361 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+250)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001362 def test_igmp_general_query_received_traffic(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001363 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001364 def igmp_general_query_recv_packet():
1365 self.igmp_general_query_recv_packet(df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001366 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001367 reactor.callLater(0, igmp_general_query_recv_packet)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001368 return df
A.R Karthick95d044e2016-06-10 18:44:36 -07001369
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001370 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+100)
1371 def test_igmp_query_received_on_joining_interface(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001372 groups = ['224.0.1.10', '225.0.0.10']
1373 leave_groups = ['224.0.1.10']
1374 df = defer.Deferred()
1375 igmpState = IGMPTestState(groups = groups, df = df)
1376 igmpStateRecv = IGMPTestState(groups = groups, df = df)
1377 igmpStateList = (igmpState, igmpStateRecv)
A.R Karthick95d044e2016-06-10 18:44:36 -07001378 mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb,
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001379 arg = igmpState)
1380 self.df = df
1381 self.mcastTraffic = mcastTraffic
1382 self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP)
A.R Karthick95d044e2016-06-10 18:44:36 -07001383
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001384 def igmp_srp_task(stateList):
1385 igmpSendState, igmpRecvState = stateList
1386 if not mcastTraffic.isRecvStopped():
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001387 self.igmp_recv(igmpRecvState)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001388 reactor.callLater(0, igmp_srp_task, stateList)
1389 else:
1390 self.mcastTraffic.stop()
1391 self.recv_socket.close()
1392 self.igmp_verify_leave(stateList, leave_groups)
1393 self.df.callback(0)
1394
A R Karthick76a497a2017-04-12 10:59:39 -07001395 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 -07001396 self.send_igmp_join_recvQuery(groups)
A R Karthick76a497a2017-04-12 10:59:39 -07001397 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 -07001398 mcastTraffic.start()
1399 self.test_timer = reactor.callLater(self.MCAST_TRAFFIC_TIMEOUT, self.mcast_traffic_timer)
1400 reactor.callLater(0, igmp_srp_task, igmpStateList)
1401 return df
1402
1403 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+190)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001404 def test_igmp_for_periodic_query_received_on_joining_interface(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001405 groups = ['224.0.1.10', '225.0.0.10']
1406 leave_groups = ['224.0.1.10']
1407 df = defer.Deferred()
1408 igmpState = IGMPTestState(groups = groups, df = df)
A.R Karthick95d044e2016-06-10 18:44:36 -07001409 mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb,
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001410 arg = igmpState)
1411 self.df = df
1412 self.mcastTraffic = mcastTraffic
1413 self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP)
A.R Karthick95d044e2016-06-10 18:44:36 -07001414
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001415 def igmp_srp_task(stateList):
1416 igmpSendState, igmpRecvState = stateList
1417 if not mcastTraffic.isRecvStopped():
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001418 self.igmp_recv(igmpRecvState)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001419 reactor.callLater(0, igmp_srp_task, stateList)
1420 else:
1421 self.mcastTraffic.stop()
1422 self.recv_socket.close()
1423 self.igmp_verify_leave(stateList, leave_groups)
1424 self.df.callback(0)
1425
1426 self.send_igmp_join_recvQuery(groups,3)
1427 return df
1428
1429 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+190)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001430 def test_igmp_for_periodic_query_received_and_checking_entry_deleted(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001431 groups = ['224.0.1.10', '225.0.0.10']
1432 leave_groups = ['224.0.1.10']
1433 df = defer.Deferred()
1434 igmpState = IGMPTestState(groups = groups, df = df)
1435 igmpStateRecv = IGMPTestState(groups = groups, df = df)
1436 igmpStateList = (igmpState, igmpStateRecv)
A.R Karthick95d044e2016-06-10 18:44:36 -07001437 mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb,
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001438 arg = igmpState)
1439 self.df = df
1440 self.mcastTraffic = mcastTraffic
1441 self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP)
A.R Karthick95d044e2016-06-10 18:44:36 -07001442
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001443 def igmp_srp_task(stateList):
1444 igmpSendState, igmpRecvState = stateList
1445 if not mcastTraffic.isRecvStopped():
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001446 self.igmp_recv(igmpRecvState)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001447 reactor.callLater(0, igmp_srp_task, stateList)
1448 else:
1449 self.mcastTraffic.stop()
1450 self.recv_socket.close()
1451 self.igmp_verify_leave(stateList, leave_groups)
1452 self.df.callback(0)
1453
1454 self.send_igmp_join_recvQuery(groups,3)
A R Karthick76a497a2017-04-12 10:59:39 -07001455 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 -07001456 mcastTraffic.start()
1457 self.test_timer = reactor.callLater(self.MCAST_TRAFFIC_TIMEOUT, self.mcast_traffic_timer)
1458 reactor.callLater(0, igmp_srp_task, igmpStateList)
1459 return df
1460
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001461 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+190)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001462 def test_igmp_member_query_interval_and_expiry_for_rejoining_interface(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001463 groups = ['224.0.1.10', '225.0.0.10']
1464 leave_groups = ['224.0.1.10']
1465 df = defer.Deferred()
1466 igmpState = IGMPTestState(groups = groups, df = df)
1467 igmpStateRecv = IGMPTestState(groups = groups, df = df)
1468 igmpStateList = (igmpState, igmpStateRecv)
A.R Karthick95d044e2016-06-10 18:44:36 -07001469 mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb,
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001470 arg = igmpState)
1471 self.df = df
1472 self.mcastTraffic = mcastTraffic
1473 self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP)
A.R Karthick95d044e2016-06-10 18:44:36 -07001474
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001475 def igmp_srp_task(stateList):
1476 igmpSendState, igmpRecvState = stateList
1477 if not mcastTraffic.isRecvStopped():
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001478 self.igmp_recv(igmpRecvState)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001479 reactor.callLater(0, igmp_srp_task, stateList)
1480 else:
1481 self.mcastTraffic.stop()
1482 self.recv_socket.close()
1483 self.igmp_verify_leave(stateList, leave_groups)
1484 self.df.callback(0)
1485
1486 self.send_igmp_join_recvQuery(groups,3)
A R Karthick76a497a2017-04-12 10:59:39 -07001487 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 -07001488 self.send_igmp_join(groups)
1489 mcastTraffic.start()
1490 self.test_timer = reactor.callLater(self.MCAST_TRAFFIC_TIMEOUT, self.mcast_traffic_timer)
1491 reactor.callLater(0, igmp_srp_task, igmpStateList)
1492 return df
1493
1494 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+50)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001495 def test_igmp_leave_received_group_and_source_specific_query(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001496 groups = ['224.0.1.10', '225.0.0.10']
1497 leave_groups = ['224.0.1.10']
1498 df = defer.Deferred()
1499 igmpState = IGMPTestState(groups = groups, df = df)
A.R Karthick95d044e2016-06-10 18:44:36 -07001500 mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb,
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001501 arg = igmpState)
1502 self.df = df
1503 self.mcastTraffic = mcastTraffic
1504 self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP)
A.R Karthick95d044e2016-06-10 18:44:36 -07001505
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001506 def igmp_srp_task(stateList):
1507 igmpSendState, igmpRecvState = stateList
1508 if not mcastTraffic.isRecvStopped():
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001509 self.igmp_recv(igmpRecvState)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001510 reactor.callLater(0, igmp_srp_task, stateList)
1511 else:
1512 self.mcastTraffic.stop()
1513 self.recv_socket.close()
1514 self.igmp_verify_leave(stateList, leave_groups)
1515 self.df.callback(0)
1516
1517 self.send_igmp_join(groups)
1518 self.send_igmp_leave_listening_group_specific_query(leave_groups, delay = 3)
1519 return df
1520
1521 def igmp_change_to_exclude_src_list_check_for_group_source_specific_query(self, df = None):
1522 groups1 = (self.MGROUP1,)
1523 groups2 = (self.MGROUP2,)
1524 self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
1525 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
1526 intf = self.V_INF1, delay = 2)
1527 dst_mac = '01:00:5e:01:02:03'
1528 src_ip = '2.2.2.2'
1529 if df is None:
1530 df = defer.Deferred()
1531 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001532 IGMPTestState(groups = groups1, df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001533 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
1534 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1535 mcastTraffic1.start()
1536 join_state1 = IGMPTestState(groups = groups1)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001537 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001538 self.send_igmp_leave_listening_group_specific_query(groups = groups1, src_list = ['2.2.2.2'], iface = self.V_INF1, delay =2)
1539 time.sleep(10)
1540 target2 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
1541 assert target2 == 1, 'EXPECTED FAILURE'
A R Karthick76a497a2017-04-12 10:59:39 -07001542 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 -07001543 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001544
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001545 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+60)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001546 def test_igmp_change_to_exclude_src_list_and_check_for_group_source_specific_query(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001547 df = defer.Deferred()
1548 def igmp_change_to_exclude_src_list_check_for_group_source_specific_query():
1549 self.igmp_change_to_exclude_src_list_check_for_group_source_specific_query(df = df)
1550 df.callback(0)
1551 reactor.callLater(0, igmp_change_to_exclude_src_list_check_for_group_source_specific_query)
1552 return df
1553
1554 def igmp_change_to_include_src_list_check_for_general_query(self, df = None):
1555 groups1 = (self.MGROUP1,)
1556 groups2 = (self.MGROUP2,)
1557 self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4'],
1558 iface = self.V_INF1, delay = 2)
1559 dst_mac = '01:00:5e:01:02:03'
1560 src_ip = '2.2.2.2'
1561 if df is None:
1562 df = defer.Deferred()
1563 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001564 IGMPTestState(groups = groups1, df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001565 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
1566 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1567 mcastTraffic1.start()
1568 join_state1 = IGMPTestState(groups = groups1)
1569 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
1570 assert target1 == 1, 'EXPECTED FAILURE'
A R Karthick76a497a2017-04-12 10:59:39 -07001571 log_test.info('Interface is not receiving traffic from multicast groups %s' %groups1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001572 self.igmp_send_joins_different_groups_srclist_wait_query_packets(groups1 + groups2,
1573 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['6.6.6.6', '5.5.5.5']),
1574 intf = self.V_INF1, delay = 2,query_group1 = 'group1', query_group2 = None)
1575 time.sleep(10)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001576 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
A R Karthick76a497a2017-04-12 10:59:39 -07001577 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 -07001578 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001579
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001580 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+80)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001581 def test_igmp_change_to_include_src_list_and_check_for_general_query(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001582 df = defer.Deferred()
1583 def igmp_change_to_include_src_list_check_for_general_query():
1584 self.igmp_change_to_include_src_list_check_for_general_query(df = df)
1585 df.callback(0)
1586 reactor.callLater(0, igmp_change_to_include_src_list_check_for_general_query)
1587 return df
1588
1589 def igmp_allow_new_src_list_check_for_general_query(self, df = None):
1590 groups1 = (self.MGROUP1,)
1591 groups2 = (self.MGROUP2,)
1592 self.igmp_send_joins_different_groups_srclist(groups1+groups2,
1593 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
1594 intf = self.V_INF1, delay = 2)
1595 dst_mac = '01:00:5e:01:02:03'
1596 src_ip = '6.6.6.6'
1597 if df is None:
1598 df = defer.Deferred()
1599 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001600 IGMPTestState(groups = groups1, df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001601 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
1602 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1603 mcastTraffic1.start()
1604 join_state1 = IGMPTestState(groups = groups1)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001605 self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
A R Karthick76a497a2017-04-12 10:59:39 -07001606 log_test.info('Interface is not receiving traffic from multicast groups %s' %groups1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001607 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']),
1608 intf = self.V_INF1, delay = 2, query_group1 = 'group1', query_group2 = None)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001609 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
A R Karthick76a497a2017-04-12 10:59:39 -07001610 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 -07001611 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001612
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001613 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+80)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001614 def test_igmp_allow_new_src_list_and_check_for_general_query(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001615 df = defer.Deferred()
1616 def igmp_allow_new_src_list_check_for_general_query():
1617 self.igmp_allow_new_src_list_check_for_general_query(df = df)
1618 df.callback(0)
1619 reactor.callLater(0, igmp_allow_new_src_list_check_for_general_query)
1620 return df
1621
1622 def igmp_block_old_src_list_check_for_group_source_specific_query(self, df = None):
1623 groups1 = (self.MGROUP1,)
1624 groups2 = (self.MGROUP2,)
1625 groups = groups1 + groups2
1626 self.igmp_send_joins_different_groups_srclist(groups,
1627 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
1628 intf = self.V_INF1, delay = 2)
1629 dst_mac = '01:00:5e:02:02:03'
1630 src_ip = '5.5.5.5'
1631 if df is None:
1632 df = defer.Deferred()
1633 igmpState1 = IGMPTestState(groups = groups2, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001634 IGMPTestState(groups = groups2, df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001635 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1636 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1637 mcastTraffic1.start()
1638 join_state1 = IGMPTestState(groups = groups2)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001639 self.igmp_recv_task(self.V_INF1, groups2, join_state1)
A R Karthick76a497a2017-04-12 10:59:39 -07001640 log_test.info('Interface is receiving traffic from multicast groups %s' %groups2)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001641 self.igmp_send_joins_different_groups_srclist_wait_query_packets(groups,
1642 (['6.6.6.6', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '7.7.7.7']),
1643 intf = self.V_INF1, delay = 2, query_group1 = 'group1', query_group2 = None)
1644 target2 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1)
1645 assert target2 == 1, 'EXPECTED FAILURE'
A R Karthick76a497a2017-04-12 10:59:39 -07001646 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 -07001647 mcastTraffic1.stop()
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001648
1649 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+90)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001650 def test_igmp_block_old_src_list_and_check_for_group_source_specific_query(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001651 df = defer.Deferred()
1652 def igmp_block_old_src_list_check_for_group_source_specific_query():
1653 self.igmp_block_old_src_list_check_for_group_source_specific_query(df = df)
1654 df.callback(0)
1655 reactor.callLater(0, igmp_block_old_src_list_check_for_group_source_specific_query)
1656 return df
1657
1658 def igmp_include_to_allow_src_list_check_for_general_query(self, df = None):
1659 groups1 = (self.MGROUP1,)
1660 groups2 = (self.MGROUP2,)
1661 self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
1662 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
1663 intf = self.V_INF1, delay = 2)
1664 dst_mac = '01:00:5e:01:02:03'
1665 src_ip = '2.2.2.2'
1666 if df is None:
1667 df = defer.Deferred()
1668 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001669 IGMPTestState(groups = groups1, df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001670 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
1671 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1672 mcastTraffic1.start()
1673 join_state1 = IGMPTestState(groups = groups1)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001674 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001675 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 -08001676 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001677 mcastTraffic1.stop()
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001678
1679 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+40)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001680 def test_igmp_include_to_allow_src_list_and_check_for_general_query(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001681 df = defer.Deferred()
1682 def igmp_include_to_allow_src_list_check_for_general_query():
1683 self.igmp_include_to_allow_src_list_check_for_general_query(df = df)
1684 df.callback(0)
1685 reactor.callLater(0, igmp_include_to_allow_src_list_check_for_general_query)
1686 return df
1687
1688 def igmp_include_to_block_src_list_check_for_group_source_specific_query(self, df = None):
1689 groups1 = (self.MGROUP1,)
1690 groups2 = (self.MGROUP2,)
1691 self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
1692 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
1693 intf = self.V_INF1, delay = 2)
1694 dst_mac = '01:00:5e:01:02:03'
1695 src_ip = '2.2.2.2'
1696 if df is None:
1697 df = defer.Deferred()
1698 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001699 IGMPTestState(groups = groups1, df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001700 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
1701 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1702 mcastTraffic1.start()
1703 join_state1 = IGMPTestState(groups = groups1)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001704 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001705 self.send_igmp_leave_listening_group_specific_query(groups = groups1, src_list = ['6.6.6.6','7.7.7.7'],
1706 iface = self.V_INF1, delay = 2)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001707 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001708 mcastTraffic1.stop()
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001709
1710 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+40)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001711 def test_igmp_include_to_block_src_list_and_check_for_group_source_specific_query(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001712 df = defer.Deferred()
1713 def igmp_include_to_block_src_list_check_for_group_source_specific_query():
1714 self.igmp_include_to_block_src_list_check_for_group_source_specific_query(df = df)
1715 df.callback(0)
1716 reactor.callLater(0, igmp_include_to_block_src_list_check_for_group_source_specific_query)
1717 return df
1718
1719 def igmp_exclude_to_allow_src_list_check_for_general_query(self, df = None):
1720 groups1 = (self.MGROUP1,)
1721 groups2 = (self.MGROUP2,)
1722 self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4'],
1723 iface = self.V_INF1, delay = 2)
A.R Karthick95d044e2016-06-10 18:44:36 -07001724
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001725 dst_mac = '01:00:5e:01:02:03'
1726 src_ip = '2.2.2.2'
1727 if df is None:
1728 df = defer.Deferred()
1729 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001730 IGMPTestState(groups = groups1, df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001731 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
1732 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1733 mcastTraffic1.start()
1734 join_state1 = IGMPTestState(groups = groups1)
1735 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
1736 assert target1 == 1, 'EXPECTED FAILURE'
A R Karthick76a497a2017-04-12 10:59:39 -07001737 log_test.info('Interface is not receiving traffic from multicast groups %s' %groups1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001738 self.igmp_send_joins_different_groups_srclist_wait_query_packets(groups1 + groups2,
1739 (['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)
1740 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
1741 assert target1 == 1, 'EXPECTED FAILURE'
A R Karthick76a497a2017-04-12 10:59:39 -07001742 log_test.info('Interface is not receiving traffic from multicast groups %s' %groups1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001743 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001744
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001745 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+90)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001746 def test_igmp_exclude_to_allow_src_list_and_check_for_general_query(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001747 df = defer.Deferred()
1748 def igmp_exclude_to_allow_src_list_check_for_general_query():
1749 self.igmp_exclude_to_allow_src_list_check_for_general_query(df = df)
1750 df.callback(0)
1751 reactor.callLater(0, igmp_exclude_to_allow_src_list_check_for_general_query)
1752 return df
1753
1754 def igmp_exclude_to_block_src_list_check_for_group_source_specific_query(self, df = None):
1755 groups1 = (self.MGROUP1,)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001756 self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4'],
1757 iface = self.V_INF1, delay = 2)
A.R Karthick95d044e2016-06-10 18:44:36 -07001758
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001759 dst_mac = '01:00:5e:01:02:03'
1760 src_ip = '2.2.2.2'
1761 if df is None:
1762 df = defer.Deferred()
1763 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001764 IGMPTestState(groups = groups1, df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001765 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
1766 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1767 mcastTraffic1.start()
1768 join_state1 = IGMPTestState(groups = groups1)
1769 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
1770 assert target1 == 1, 'EXPECTED FAILURE'
A R Karthick76a497a2017-04-12 10:59:39 -07001771 log_test.info('Interface is not receiving traffic from multicast groups %s' %groups1)
A.R Karthick95d044e2016-06-10 18:44:36 -07001772 self.send_igmp_leave_listening_group_specific_query(groups = groups1,
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001773 src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4', '5.5.5.5', '7.7.7.7'],
1774 iface = self.V_INF1, delay = 2)
1775 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
1776 assert target1 == 1, 'EXPECTED FAILURE'
A R Karthick76a497a2017-04-12 10:59:39 -07001777 log_test.info('Interface is not receiving traffic from multicast groups %s' %groups1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001778 mcastTraffic1.stop()
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001779
1780 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+40)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001781 def test_igmp_exclude_to_block_src_list_and_check_for_group_source_specific_query(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001782 df = defer.Deferred()
1783 def igmp_exclude_to_block_src_list_check_for_group_source_specific_query():
1784 self.igmp_exclude_to_block_src_list_check_for_group_source_specific_query(df = df)
1785 df.callback(0)
1786 reactor.callLater(0, igmp_exclude_to_block_src_list_check_for_group_source_specific_query)
1787 return df
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001788
1789 def iptomac(self, mcast_ip):
1790 mcast_mac = '01:00:5e:'
1791 octets = mcast_ip.split('.')
1792 second_oct = int(octets[1]) & 127
1793 third_oct = int(octets[2])
1794 fourth_oct = int(octets[3])
1795 mcast_mac = mcast_mac + format(second_oct,'02x') + ':' + format(third_oct, '02x') + ':' + format(fourth_oct, '02x')
1796 return mcast_mac
1797
1798 def send_multicast_data_traffic(self, group, intf= 'veth2',source = '1.2.3.4'):
1799 dst_mac = self.iptomac(group)
1800 eth = Ether(dst= dst_mac)
1801 ip = IP(dst=group,src=source)
1802 data = repr(monotonic.monotonic())
1803 sendp(eth/ip/data,count=20, iface = intf)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001804
1805 def verify_igmp_data_traffic(self, group, intf='veth0', source='1.2.3.4' ):
A R Karthick76a497a2017-04-12 10:59:39 -07001806 log_test.info('verifying multicast traffic for group %s from source %s'%(group,source))
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001807 self.success = False
1808 def recv_task():
1809 def igmp_recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -07001810 #log_test.info('received multicast data packet is %s'%pkt.show())
1811 log_test.info('multicast data received for group %s from source %s'%(group,source))
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001812 self.success = True
1813 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')
1814 t = threading.Thread(target = recv_task)
1815 t.start()
1816 self.send_multicast_data_traffic(group,source=source)
1817 t.join()
1818 return self.success
1819
1820 def test_igmp_include_exclude_modes(self):
1821 groups = ['224.2.3.4','230.5.6.7']
1822 src_list = ['2.2.2.2','3.3.3.3']
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001823 self.onos_ssm_table_load(groups, src_list=src_list)
1824 self.send_igmp_join(groups = [groups[0]], src_list = src_list,record_type = IGMP_V3_GR_TYPE_INCLUDE,
1825 iface = self.V_INF1, delay = 2)
1826 self.send_igmp_join(groups = [groups[1]], src_list = src_list,record_type = IGMP_V3_GR_TYPE_EXCLUDE,
1827 iface = self.V_INF1, delay = 2)
1828 status = self.verify_igmp_data_traffic(groups[0],intf=self.V_INF1,source=src_list[0])
1829 assert_equal(status,True)
1830 status = self.verify_igmp_data_traffic(groups[1],intf = self.V_INF1,source= src_list[1])
1831 assert_equal(status,False)
1832
1833 def test_igmp_allow_new_source_mode(self):
1834 group = ['224.8.9.3']
1835 src_list = ['2.2.2.2','3.3.3.3']
1836 #dst_mac = self.iptomac(group[0])
1837 self.onos_ssm_table_load(group, src_list)
1838 self.send_igmp_join(groups = group, src_list = src_list[0],record_type = IGMP_V3_GR_TYPE_INCLUDE,
1839 iface = self.V_INF1, delay = 1)
1840 status = self.verify_igmp_data_traffic(group[0], intf=self.V_INF1,source = src_list[0])
1841 assert_equal(status,True) # expecting igmp data traffic from source src_list[0]
1842 self.send_igmp_join(groups = group, src_list = src_list[1],record_type = IGMP_V3_GR_TYPE_ALLOW_NEW,
1843 iface = self.V_INF1, delay = 1)
1844 for src in src_list:
1845 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1, source=src)
1846 assert_equal(status,True) # expecting igmp data traffic from both sources
1847
1848
1849 def test_igmp_include_to_exclude_mode_change(self):
1850 group = ['224.2.3.4']
1851 src_list = ['2.2.2.2','3.3.3.3']
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001852 self.onos_ssm_table_load(group, src_list)
1853 self.send_igmp_join(groups = group, src_list = src_list[0],record_type = IGMP_V3_GR_TYPE_INCLUDE,
1854 iface = self.V_INF1, delay = 1)
1855 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source= src_list[0])
1856 assert_equal(status,True) # expecting igmp data traffic from source src_list[0]
1857 self.send_igmp_join(groups = group, src_list = src_list[1],record_type = IGMP_V3_GR_TYPE_EXCLUDE,
1858 iface = self.V_INF1, delay = 1)
1859 for src in src_list:
1860 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source= src)
1861 assert_equal(status,False) # expecting igmp data traffic from both sources
1862
1863 def test_igmp_exclude_to_include_mode_change(self):
1864 group = ['224.2.3.4']
1865 src = ['2.2.2.2']
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001866 self.onos_ssm_table_load(group, src)
1867 self.send_igmp_join(groups = group, src_list = src,record_type = IGMP_V3_GR_TYPE_EXCLUDE,
1868 iface = self.V_INF1, delay = 1)
1869 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source=src[0])
1870 assert_equal(status,False) # not expecting igmp data traffic from source src_list[0]
1871 self.send_igmp_join(groups = group, src_list = src,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[0])
1874 assert_equal(status,True) # expecting igmp data traffic from both sources
1875
1876 #this test case wotks properly if the snooping device(ONOS) have multicast router connected.
1877 def test_igmp_to_include_mode_with_null_source(self):
1878 groups = ['224.2.3.4','230.7.9.8']
1879 src = ['192.168.12.34']
1880 dst_mac = []
1881 dst_mac.append(self.iptomac(groups[0]))
1882 dst_mac.append(self.iptomac(groups[1]))
1883 self.onos_ssm_table_load(groups, src)
1884 self.send_igmp_join(groups = groups, src_list = src,record_type = IGMP_V3_GR_TYPE_INCLUDE,
1885 iface = self.V_INF1, delay = 1)
1886 for grp in groups:
1887 status = self.verify_igmp_data_traffic(grp,intf=self.V_INF1,source= src[0])
1888 assert_equal(status,True) # not expecting igmp data traffic from source src_list[0]
1889 #sending leave packet for group groups[1]
1890 self.send_igmp_join(groups = [groups[1]], src_list = [],record_type = IGMP_V3_GR_TYPE_CHANGE_TO_INCLUDE,
1891 iface = self.V_INF1, delay = 1)
1892 for grp in groups:
1893 status = self.verify_igmp_data_traffic(grp,intf=self.V_INF1,source= src[0])
1894 if grp is groups[0]:
1895 assert_equal(status,True) # expecting igmp data traffic to group groups[0]
1896 else:
1897 assert_equal(status,False) # not expecting igmp data traffic to group groups[1]
1898
1899 def test_igmp_to_include_mode(self):
1900 group = ['229.9.3.6']
1901 src_list = ['192.168.12.34','192.18.1.34']
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001902 self.onos_ssm_table_load(group, src_list)
1903 self.send_igmp_join(groups = group, src_list = [src_list[0]],record_type = IGMP_V3_GR_TYPE_INCLUDE,
1904 iface = self.V_INF1, delay = 1)
1905 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source=src_list[0])
1906 assert_equal(status,True) # not expecting igmp data traffic from source src_list[0]
1907 self.send_igmp_join(groups = group, src_list = src_list,record_type = IGMP_V3_GR_TYPE_CHANGE_TO_INCLUDE,
1908 iface = self.V_INF1, delay = 1)
1909 for src in src_list:
1910 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source= src)
1911 assert_equal(status,True) # expecting igmp data traffic to group groups[0]
1912
1913 #this test case passed only if mulitcast router connected to ONOS.
1914 def test_igmp_blocking_old_source_mode(self):
1915 group = ['224.2.3.4']
1916 src_list = ['2.2.2.2','3.3.3.3']
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001917 self.onos_ssm_table_load(group, src_list)
1918 self.send_igmp_join(groups = group, src_list = src_list,record_type = IGMP_V3_GR_TYPE_INCLUDE,
1919 iface = self.V_INF1, delay = 1)
1920 for src in src_list:
1921 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1, source=src)
1922 assert_equal(status,True) # expecting igmp data traffic from source src_list[0]
1923 self.send_igmp_join(groups = group, src_list = [src_list[1]],record_type = IGMP_V3_GR_TYPE_BLOCK_OLD,
1924 iface = self.V_INF1, delay = 1)
1925 for src in src_list:
1926 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1, source=src)
1927 if src is src_list[0]:
1928 assert_equal(status,True) # expecting igmp data traffic from source src_list[0]
1929 else:
1930 assert_equal(status,False) # not expecting igmp data traffic from source src_list[1]
1931
1932 def test_igmp_multiple_joins_and_data_verification_with_100_groups(self):
1933 groups = []
1934 sources = []
1935 count = 1
1936 mcastips = self.mcast_ip_range(start_ip = '226.0.0.1',end_ip = '226.0.5.254')
1937 sourceips = self.source_ip_range(start_ip = '10.10.0.1',end_ip = '10.10.5.254')
1938 while count<=100:
1939 group = random.choice(mcastips)
1940 source = random.choice(sourceips)
1941 if group in groups:
1942 pass
1943 else:
A R Karthick76a497a2017-04-12 10:59:39 -07001944 log_test.info('group and source are %s and %s'%(group,source))
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001945 groups.append(group)
1946 sources.append(source)
1947 count += 1
1948 self.onos_ssm_table_load(groups,src_list=sources,flag=True)
1949 for i in range(100):
1950 self.send_igmp_join(groups = [groups[i]], src_list = [sources[i]],record_type = IGMP_V3_GR_TYPE_INCLUDE,
1951 iface = self.V_INF1)
1952 status = self.verify_igmp_data_traffic(groups[i],intf=self.V_INF1,source=sources[i])
1953 assert_equal(status, True)
A R Karthick76a497a2017-04-12 10:59:39 -07001954 log_test.info('data received for group %s from source %s'%(groups[i],sources[i]))
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001955
1956 def test_igmp_multiple_joins_with_data_verification_and_leaving_100_groups(self):
1957 groups = []
1958 sources = []
1959 count = 1
1960 mcastips = self.mcast_ip_range(start_ip = '226.0.0.1',end_ip = '226.0.5.254')
1961 sourceips = self.source_ip_range(start_ip = '10.10.0.1',end_ip = '10.10.5.254')
1962 while count<=100:
1963 group = random.choice(mcastips)
1964 source = random.choice(sourceips)
1965 if group in groups:
1966 pass
1967 else:
A R Karthick76a497a2017-04-12 10:59:39 -07001968 log_test.info('group and source are %s and %s'%(group,source))
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001969 groups.append(group)
1970 sources.append(source)
1971 count += 1
1972 self.onos_ssm_table_load(groups,src_list=sources,flag=True)
1973 for i in range(100):
1974 self.send_igmp_join(groups = [groups[i]], src_list = [sources[i]],record_type = IGMP_V3_GR_TYPE_INCLUDE,
1975 iface = self.V_INF1)
1976 status = self.verify_igmp_data_traffic(groups[i],intf=self.V_INF1,source=sources[i])
1977 assert_equal(status, True)
A R Karthick76a497a2017-04-12 10:59:39 -07001978 log_test.info('data received for group %s from source %s'%(groups[i],sources[i]))
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001979 self.send_igmp_join(groups = [groups[i]], src_list = [sources[i]],record_type = IGMP_V3_GR_TYPE_CHANGE_TO_EXCLUDE,
1980 iface = self.V_INF1, delay = 1)
1981 status = self.verify_igmp_data_traffic(groups[i],intf=self.V_INF1,source=sources[i])
1982 assert_equal(status, False)
A R Karthick76a497a2017-04-12 10:59:39 -07001983 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 -07001984
1985 def test_igmp_group_source_for_only_config_with_1000_entries(self):
1986 groups = []
1987 sources = []
1988 count = 1
1989 mcastips = self.mcast_ip_range(start_ip = '229.0.0.1',end_ip = '229.0.50.254')
1990 sourceips = self.source_ip_range(start_ip = '10.10.0.1',end_ip = '10.10.50.254')
1991 while count<=1000:
1992 group = random.choice(mcastips)
1993 source = random.choice(sourceips)
1994 if group in groups:
1995 pass
1996 else:
A R Karthick76a497a2017-04-12 10:59:39 -07001997 log_test.info('group and source are %s and %s'%(group,source))
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001998 groups.append(group)
1999 sources.append(source)
2000 count += 1
2001 self.onos_ssm_table_load(groups,src_list=sources,flag=True)
2002
2003 def test_igmp_from_exclude_to_include_mode_with_100_groups(self):
2004 groups = []
2005 sources = []
2006 count = 1
2007 mcastips = self.mcast_ip_range(start_ip = '229.0.0.1',end_ip = '229.0.10.254')
2008 sourceips = self.source_ip_range(start_ip = '10.10.0.1',end_ip = '10.10.10.254')
2009 while count<=100:
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 for i in range(100):
2021 self.send_igmp_join(groups = [groups[i]], src_list = [sources[i]],record_type = IGMP_V3_GR_TYPE_EXCLUDE,
2022 iface = self.V_INF1)
2023 status = self.verify_igmp_data_traffic(groups[i],intf=self.V_INF1,source=sources[i])
2024 assert_equal(status, False)
A R Karthick76a497a2017-04-12 10:59:39 -07002025 log_test.info('data not received for group %s from source %s as expected'%(groups[i],sources[i]))
ChetanGaonkera7e2b412016-09-01 23:19:07 -07002026 self.send_igmp_join(groups = [groups[i]], src_list = [sources[i]],record_type = IGMP_V3_GR_TYPE_INCLUDE,
2027 iface = self.V_INF1)
2028 status = self.verify_igmp_data_traffic(groups[i],intf=self.V_INF1,source=sources[i])
2029 assert_equal(status, True)
A R Karthick76a497a2017-04-12 10:59:39 -07002030 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 -07002031
2032 def test_igmp_with_multiple_joins_and_data_verify_with_1000_groups(self):
2033 groups = []
2034 sources = []
2035 count = 1
2036 mcastips = self.mcast_ip_range(start_ip = '229.0.0.1',end_ip = '229.0.30.254')
2037 sourceips = self.source_ip_range(start_ip = '10.10.0.1',end_ip = '10.10.30.254')
2038 while count<=1000:
2039 group = random.choice(mcastips)
2040 source = random.choice(sourceips)
2041 if group in groups:
2042 pass
2043 else:
A R Karthick76a497a2017-04-12 10:59:39 -07002044 log_test.info('group and source are %s and %s'%(group,source))
ChetanGaonkera7e2b412016-09-01 23:19:07 -07002045 groups.append(group)
2046 sources.append(source)
2047 count += 1
2048 self.onos_ssm_table_load(groups,src_list=sources,flag=True)
2049 for i in range(1000):
2050 self.send_igmp_join(groups = [groups[i]], src_list = [sources[i]],record_type = IGMP_V3_GR_TYPE_INCLUDE,
2051 iface = self.V_INF1)
2052 status = self.verify_igmp_data_traffic(groups[i],intf=self.V_INF1,source=sources[i])
2053 assert_equal(status, True)
A R Karthick76a497a2017-04-12 10:59:39 -07002054 log_test.info('data received for group %s from source %s - %d'%(groups[i],sources[i],i))
ChetanGaonkera7e2b412016-09-01 23:19:07 -07002055
2056 def test_igmp_with_multiple_joins_and_data_verify_with_5000_groups(self):
2057 groups = []
2058 sources = []
2059 count = 1
2060 mcastips = self.mcast_ip_range(start_ip = '231.39.19.121',end_ip = '231.40.30.25')
2061 sourceips = self.source_ip_range(start_ip = '192.168.56.43',end_ip = '192.169.110.30')
2062 while count<=5000:
2063 group = random.choice(mcastips)
2064 source = random.choice(sourceips)
2065 if group in groups:
2066 pass
2067 else:
A R Karthick76a497a2017-04-12 10:59:39 -07002068 log_test.info('group and source are %s and %s'%(group,source))
ChetanGaonkera7e2b412016-09-01 23:19:07 -07002069 groups.append(group)
2070 sources.append(source)
2071 count += 1
2072 self.onos_ssm_table_load(groups,src_list=sources,flag=True)
2073 for i in range(5000):
2074 self.send_igmp_join(groups = [groups[i]], src_list = [sources[i]],record_type = IGMP_V3_GR_TYPE_INCLUDE,
2075 iface = self.V_INF1)
2076 status = self.verify_igmp_data_traffic(groups[i],intf=self.V_INF1,source=sources[i])
2077 assert_equal(status, True)
A R Karthick76a497a2017-04-12 10:59:39 -07002078 log_test.info('data received for group %s from source %s - %d'%(groups[i],sources[i],i))
ChetanGaonkera7e2b412016-09-01 23:19:07 -07002079
2080 """def test_igmp_join_from_multiple_infts(self):
2081 groups = ['229.9.3.6','234.20.56.2']
2082 src_list = ['192.168.12.34','192.18.1.34']
2083 self.onos_ssm_table_load(groups, src_list=src_list)
2084 self.send_igmp_join(groups = [groups[0]], src_list = src_list,record_type = IGMP_V3_GR_TYPE_INCLUDE,
2085 iface = 'veth0')
2086 self.send_igmp_join(groups = [groups[1]], src_list = src_list,record_type = IGMP_V3_GR_TYPE_INCLUDE,
2087 iface = 'veth2')
2088 status = self.verify_igmp_data_traffic(groups[0],intf='veth0',source=src_list[0])
2089 assert_equal(status,True)
2090 status = self.verify_igmp_data_traffic(groups[1],intf='veth2',source=src_list[1])
2091 assert_equal(status,True) # not expecting igmp data traffic from source src_list[0]
2092 """
2093
2094 def test_igmp_send_data_to_non_registered_group(self):
2095 group = ['224.2.3.4']
2096 src = ['2.2.2.2']
2097 self.onos_ssm_table_load(group,src_list= src)
2098 self.send_igmp_join(groups = ['239.0.0.1'], src_list = src,record_type = IGMP_V3_GR_TYPE_INCLUDE,
2099 iface = self.V_INF1, delay = 1)
2100 status = self.verify_igmp_data_traffic('239.0.0.1',intf=self.V_INF1,source=src[0])
2101 assert_equal(status,False) # not expecting igmp data traffic from source src_list[0]
2102
2103 def test_igmp_traffic_verification_for_registered_group_with_no_join_sent(self):
2104 group = ['227.12.3.40']
2105 src = ['190.4.19.67']
2106 self.onos_ssm_table_load(group,src_list= src)
2107 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source=src[0])
2108 assert_equal(status,False) # not expecting igmp data traffic from source src_list[0]
2109
2110 def test_igmp_toggling_app_activation(self):
2111 group = [self.random_mcast_ip()]
2112 src = [self.randomsourceip()]
2113 self.onos_ssm_table_load(group,src_list= src)
2114 self.send_igmp_join(groups = group, src_list = src,record_type = IGMP_V3_GR_TYPE_INCLUDE,
2115 iface = self.V_INF1)
2116 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source=src[0])
2117 assert_equal(status,True) # expecting igmp data traffic from source src_list[0]
A R Karthick76a497a2017-04-12 10:59:39 -07002118 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 -07002119 self.onos_ctrl.deactivate()
2120 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source=src[0])
2121 assert_equal(status,False) #not expecting igmp data traffic from source src_list[0]
A R Karthick76a497a2017-04-12 10:59:39 -07002122 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 -07002123 self.onos_ctrl.activate()
2124 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source=src[0])
2125 assert_equal(status,True) # expecting igmp data traffic from source src_list[0]
A R Karthick76a497a2017-04-12 10:59:39 -07002126 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 -07002127
2128 def test_igmp_with_mismatch_for_dst_ip_and_mac_in_data_packets(self):
2129 group = ['228.18.19.29']
2130 source = [self.randomsourceip()]
2131 self.onos_ssm_table_load(group,src_list= source)
2132 self.send_igmp_join(groups = group, src_list = source,record_type = IGMP_V3_GR_TYPE_INCLUDE,
2133 iface = self.V_INF1)
2134 dst_mac = '01:00:5e:0A:12:09'
2135 eth = Ether(dst= dst_mac)
2136 ip = IP(dst=group[0],src=source[0])
2137 data = repr(monotonic.monotonic())
2138 pkt = (eth/ip/data)
A R Karthick76a497a2017-04-12 10:59:39 -07002139 log_test.info('Multicast traffic packet %s'%pkt.show())
ChetanGaonkera7e2b412016-09-01 23:19:07 -07002140 self.success = False
2141 def recv_task():
2142 def igmp_recv_cb(pkt):
A R Karthick76a497a2017-04-12 10:59:39 -07002143 #log_test.info('received multicast data packet is %s'%pkt.show())
2144 log_test.info('multicast data received for group %s from source %s'%(group[0],source[0]))
ChetanGaonkera7e2b412016-09-01 23:19:07 -07002145 self.success = True
2146 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')
2147 t = threading.Thread(target = recv_task)
2148 t.start()
2149 sendp(eth/ip/data,count=20, iface = 'veth2')
2150 t.join()
2151 assert_equal(status,False) # not expecting igmp data traffic from source src_list[0]
2152
2153 #test case failing, ONOS registering unicast ip also as an igmp join
2154 def test_igmp_registering_invalid_group(self):
ChetanGaonkerb99538a2016-12-02 13:53:35 -08002155 groups = ['218.18.19.29']
ChetanGaonkera7e2b412016-09-01 23:19:07 -07002156 source = [self.randomsourceip()]
A.R Karthick401a1ed2017-05-18 11:08:27 -07002157 ssm_dict = {'apps' : { 'org.opencord.igmp' : { 'ssmTranslate' : [] } } }
2158 ssm_xlate_list = ssm_dict['apps']['org.opencord.igmp']['ssmTranslate']
ChetanGaonkera7e2b412016-09-01 23:19:07 -07002159 for g in groups:
2160 for s in source:
2161 d = {}
2162 d['source'] = s or '0.0.0.0'
2163 d['group'] = g
2164 ssm_xlate_list.append(d)
A R Karthick76a497a2017-04-12 10:59:39 -07002165 log_test.info('onos load config is %s'%ssm_dict)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07002166 status, code = OnosCtrl.config(ssm_dict)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08002167 self.send_igmp_join(groups, src_list = source, record_type = IGMP_V3_GR_TYPE_INCLUDE,
2168 iface = self.V_INF1, delay = 1)
2169 status = self.verify_igmp_data_traffic(groups[0],intf=self.V_INF1, source=source[0])
2170 assert_equal(status,False) # not expecting igmp data traffic from source src_list[0]
ChetanGaonkera7e2b412016-09-01 23:19:07 -07002171
2172 def test_igmp_registering_invalid_source(self):
2173 groups = [self.random_mcast_ip()]
2174 sources = ['224.10.28.34','193.73.219.257']
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 sources:
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)
2185 assert_equal(status,False)