blob: 2ada5337fccd8e639792f2d0d802b2886e59a073 [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
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -080031log.setLevel('INFO')
Chetan Gaonker25470972016-02-26 08:52:15 -080032
33class IGMPTestState:
34
35 def __init__(self, groups = [], df = None, state = 0):
36 self.df = df
37 self.state = state
38 self.counter = 0
39 self.groups = groups
40 self.group_map = {} ##create a send/recv count map
41 for g in groups:
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -080042 self.group_map[g] = (Stats(), Stats())
A.R Karthick95d044e2016-06-10 18:44:36 -070043
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -080044 def update(self, group, tx = 0, rx = 0, t = 0):
45 self.counter += 1
Chetan Gaonker25470972016-02-26 08:52:15 -080046 index = 0 if rx == 0 else 1
47 v = tx if rx == 0 else rx
48 if self.group_map.has_key(group):
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -080049 self.group_map[group][index].update(packets = v, t = t)
Chetan Gaonker25470972016-02-26 08:52:15 -080050
51 def update_state(self):
52 self.state = self.state ^ 1
Chetan Gaonker25470972016-02-26 08:52:15 -080053
A R Karthick9313b762016-11-07 13:14:35 -080054class igmp_exchange(CordLogger):
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -080055
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -070056 V_INF1 = 'veth0'
57 V_INF2 = 'veth1'
58 MGROUP1 = '239.1.2.3'
59 MGROUP2 = '239.2.2.3'
Chetan Gaonker441c9ac2016-05-06 10:30:13 -070060 MINVALIDGROUP1 = '255.255.255.255'
61 MINVALIDGROUP2 = '239.255.255.255'
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -070062 MMACGROUP1 = "01:00:5e:01:02:03"
63 MMACGROUP2 = "01:00:5e:02:02:03"
ChetanGaonkera7e2b412016-09-01 23:19:07 -070064 IGMP_DST_MAC = "01:00:5e:00:00:16"
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -070065 IGMP_SRC_MAC = "5a:e1:ac:ec:4d:a1"
66 IP_SRC = '1.2.3.4'
ChetanGaonkera7e2b412016-09-01 23:19:07 -070067 IP_DST = '224.0.0.22'
Chetan Gaonker441c9ac2016-05-06 10:30:13 -070068 NEGATIVE_TRAFFIC_STATUS = 1
ChetanGaonkera7e2b412016-09-01 23:19:07 -070069 igmp_eth = Ether(dst = IGMP_DST_MAC, type = ETH_P_IP)
70 igmp_ip = IP(dst = IP_DST)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -080071 IGMP_TEST_TIMEOUT = 5
Chetan Gaonker441c9ac2016-05-06 10:30:13 -070072 IGMP_QUERY_TIMEOUT = 60
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -080073 MCAST_TRAFFIC_TIMEOUT = 10
Chetan Gaonker4eb12072016-03-28 15:04:15 -070074 PORT_TX_DEFAULT = 2
75 PORT_RX_DEFAULT = 1
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -080076 max_packets = 100
A.R Karthick95d044e2016-06-10 18:44:36 -070077 app = 'org.opencord.igmp'
Chetan Gaonker441c9ac2016-05-06 10:30:13 -070078 olt_conf_file = os.path.join(os.path.dirname(os.path.realpath(__file__)), '../setup/olt_config.json')
A R Karthick2b93d6a2016-09-06 15:19:09 -070079 ROVER_TEST_TIMEOUT = 300 #3600*86
80 ROVER_TIMEOUT = (ROVER_TEST_TIMEOUT - 100)
81 ROVER_JOIN_TIMEOUT = 60
Chetan Gaonker4a25e2b2016-03-04 14:45:15 -080082
Chetan Gaonker441c9ac2016-05-06 10:30:13 -070083 @classmethod
84 def setUpClass(cls):
85 cls.olt = OltConfig(olt_conf_file = cls.olt_conf_file)
A R Karthick2b93d6a2016-09-06 15:19:09 -070086 cls.port_map, _ = cls.olt.olt_port_map()
A R Karthick0f6b6842016-12-06 17:17:44 -080087 OnosCtrl.cord_olt_config(cls.olt)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -070088
89 @classmethod
90 def tearDownClass(cls): pass
A.R Karthick95d044e2016-06-10 18:44:36 -070091
Chetan Gaonker4a25e2b2016-03-04 14:45:15 -080092 def setUp(self):
ChetanGaonkera7e2b412016-09-01 23:19:07 -070093 ''' Activate the igmp app'''
A R Karthick9313b762016-11-07 13:14:35 -080094 super(igmp_exchange, self).setUp()
Chetan Gaonker4a25e2b2016-03-04 14:45:15 -080095 self.onos_ctrl = OnosCtrl(self.app)
ChetanGaonkera7e2b412016-09-01 23:19:07 -070096 self.onos_ctrl.activate()
Chetan Gaonker4eb12072016-03-28 15:04:15 -070097 self.igmp_channel = IgmpChannel()
Chetan Gaonker4a25e2b2016-03-04 14:45:15 -080098
A R Karthick9313b762016-11-07 13:14:35 -080099 def tearDown(self):
100 super(igmp_exchange, self).tearDown()
Chetan Gaonker4a25e2b2016-03-04 14:45:15 -0800101
102 def onos_load_config(self, config):
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700103 log.info('onos load config is %s'%config)
Chetan Gaonkera2b87df2016-03-31 15:41:31 -0700104 status, code = OnosCtrl.config(config)
Chetan Gaonker4a25e2b2016-03-04 14:45:15 -0800105 if status is False:
106 log.info('JSON request returned status %d' %code)
107 assert_equal(status, True)
108 time.sleep(2)
A.R Karthick95d044e2016-06-10 18:44:36 -0700109
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700110 def onos_ssm_table_load(self, groups, src_list = ['1.2.3.4'],flag = False):
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800111 ssm_dict = {'apps' : { 'org.onosproject.igmp' : { 'ssmTranslate' : [] } } }
112 ssm_xlate_list = ssm_dict['apps']['org.onosproject.igmp']['ssmTranslate']
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700113 if flag: #to maintain seperate group-source pair.
114 for i in range(len(groups)):
115 d = {}
116 d['source'] = src_list[i] or '0.0.0.0'
117 d['group'] = groups[i]
118 ssm_xlate_list.append(d)
119 else:
120 for g in groups:
121 for s in src_list:
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800122 d = {}
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700123 d['source'] = s or '0.0.0.0'
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800124 d['group'] = g
125 ssm_xlate_list.append(d)
Chetan Gaonker4a25e2b2016-03-04 14:45:15 -0800126 self.onos_load_config(ssm_dict)
Chetan Gaonker4eb12072016-03-28 15:04:15 -0700127 cord_port_map = {}
128 for g in groups:
129 cord_port_map[g] = (self.PORT_TX_DEFAULT, self.PORT_RX_DEFAULT)
130 self.igmp_channel.cord_port_table_load(cord_port_map)
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800131 time.sleep(2)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800132
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700133 def mcast_ip_range(self,start_ip = '224.0.1.0', end_ip = '224.0.1.100'):
134 start = list(map(int, start_ip.split(".")))
135 end = list(map(int, end_ip.split(".")))
136 temp = start
137 ip_range = []
138 ip_range.append(start_ip)
139 while temp != end:
140 start[3] += 1
141 for i in (3, 2, 1):
142 if temp[i] == 255:
143 temp[i] = 0
144 temp[i-1] += 1
145 ip_range.append(".".join(map(str, temp)))
146 return ip_range
147
148 def random_mcast_ip(self,start_ip = '224.0.1.0', end_ip = '224.0.1.100'):
149 start = list(map(int, start_ip.split(".")))
150 end = list(map(int, end_ip.split(".")))
151 temp = start
152 ip_range = []
153 ip_range.append(start_ip)
154 while temp != end:
155 start[3] += 1
156 for i in (3, 2, 1):
157 if temp[i] == 255:
158 temp[i] = 0
159 temp[i-1] += 1
160 ip_range.append(".".join(map(str, temp)))
161 return random.choice(ip_range)
162
163 def source_ip_range(self,start_ip = '10.10.0.1', end_ip = '10.10.0.100'):
164 start = list(map(int, start_ip.split(".")))
165 end = list(map(int, end_ip.split(".")))
166 temp = start
167 ip_range = []
168 ip_range.append(start_ip)
169 while temp != end:
170 start[3] += 1
171 for i in (3, 2, 1):
172 if temp[i] == 255:
173 temp[i] = 0
174 temp[i-1] += 1
175 ip_range.append(".".join(map(str, temp)))
176 return ip_range
177
178 def randomsourceip(self,start_ip = '10.10.0.1', end_ip = '10.10.0.100'):
179 start = list(map(int, start_ip.split(".")))
180 end = list(map(int, end_ip.split(".")))
181 temp = start
182 ip_range = []
183 ip_range.append(start_ip)
184 while temp != end:
185 start[3] += 1
186 for i in (3, 2, 1):
187 if temp[i] == 255:
188 temp[i] = 0
189 temp[i-1] += 1
190 ip_range.append(".".join(map(str, temp)))
191 return random.choice(ip_range)
192
A R Karthick2b93d6a2016-09-06 15:19:09 -0700193 def get_igmp_intf(self):
194 inst = os.getenv('TEST_INSTANCE', None)
195 if not inst:
196 return 'veth0'
197 inst = int(inst) + 1
198 if inst >= self.port_map['uplink']:
199 inst += 1
200 if self.port_map.has_key(inst):
201 return self.port_map[inst]
202 return 'veth0'
203
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800204 def igmp_verify_join(self, igmpStateList):
205 sendState, recvState = igmpStateList
Chetan Gaonker25470972016-02-26 08:52:15 -0800206 ## check if the send is received for the groups
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800207 for g in sendState.groups:
A.R Karthick95d044e2016-06-10 18:44:36 -0700208 tx_stats = sendState.group_map[g][0]
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800209 tx = tx_stats.count
Chetan Gaonker25470972016-02-26 08:52:15 -0800210 assert_greater(tx, 0)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800211 rx_stats = recvState.group_map[g][1]
212 rx = rx_stats.count
213 assert_greater(rx, 0)
214 log.info('Receive stats %s for group %s' %(rx_stats, g))
A.R Karthick95d044e2016-06-10 18:44:36 -0700215
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800216 log.info('IGMP test verification success')
Chetan Gaonker25470972016-02-26 08:52:15 -0800217
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800218 def igmp_verify_leave(self, igmpStateList, leave_groups):
219 sendState, recvState = igmpStateList[0], igmpStateList[1]
220 ## check if the send is received for the groups
221 for g in sendState.groups:
222 tx_stats = sendState.group_map[g][0]
223 rx_stats = recvState.group_map[g][1]
224 tx = tx_stats.count
A.R Karthick95d044e2016-06-10 18:44:36 -0700225 rx = rx_stats.count
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800226 assert_greater(tx, 0)
227 if g not in leave_groups:
228 log.info('Received %d packets for group %s' %(rx, g))
229 for g in leave_groups:
230 rx = recvState.group_map[g][1].count
231 assert_equal(rx, 0)
A.R Karthick95d044e2016-06-10 18:44:36 -0700232
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800233 log.info('IGMP test verification success')
Chetan Gaonker25470972016-02-26 08:52:15 -0800234
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800235 def mcast_traffic_timer(self):
236 self.mcastTraffic.stopReceives()
237
238 def send_mcast_cb(self, send_state):
239 for g in send_state.groups:
240 send_state.update(g, tx = 1)
Chetan Gaonker25470972016-02-26 08:52:15 -0800241 return 0
242
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800243 ##Runs in the context of twisted reactor thread
Chetan Gaonker25470972016-02-26 08:52:15 -0800244 def igmp_recv(self, igmpState, iface = 'veth0'):
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800245 p = self.recv_socket.recv()
Chetan Gaonkerf1b9e322016-05-09 15:49:15 -0700246 try:
247 send_time = float(p.payload.load)
248 recv_time = monotonic.monotonic()
249 except:
250 log.info('Unexpected Payload received: %s' %p.payload.load)
251 return 0
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800252 #log.info( 'Recv in %.6f secs' %(recv_time - send_time))
253 igmpState.update(p.dst, rx = 1, t = recv_time - send_time)
Chetan Gaonker25470972016-02-26 08:52:15 -0800254 return 0
255
A R Karthick2b93d6a2016-09-06 15:19:09 -0700256 def send_igmp_join(self, groups, src_list = ['1.2.3.4'], record_type=IGMP_V3_GR_TYPE_INCLUDE,
257 ip_pkt = None, iface = 'veth0', ssm_load = False, delay = 1):
258 if ssm_load is True:
259 self.onos_ssm_table_load(groups, src_list)
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800260 igmp = IGMPv3(type = IGMP_TYPE_V3_MEMBERSHIP_REPORT, max_resp_code=30,
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700261 gaddr=self.IP_DST)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800262 for g in groups:
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700263 gr = IGMPv3gr(rtype= record_type, mcaddr=g)
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800264 gr.sources = src_list
265 igmp.grps.append(gr)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700266 if ip_pkt is None:
267 ip_pkt = self.igmp_eth/self.igmp_ip
268 pkt = ip_pkt/igmp
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800269 IGMPv3.fixup(pkt)
270 sendp(pkt, iface=iface)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800271 if delay != 0:
272 time.sleep(delay)
273
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700274 def send_igmp_join_recvQuery(self, groups, rec_queryCount = None, src_list = ['1.2.3.4'], ip_pkt = None, iface = 'veth0', delay = 2):
275 self.onos_ssm_table_load(groups, src_list)
276 igmp = IGMPv3(type = IGMP_TYPE_V3_MEMBERSHIP_REPORT, max_resp_code=30,
277 gaddr=self.IP_DST)
278 for g in groups:
Chetan Gaonker38737f82016-05-11 17:44:17 -0700279 gr = IGMPv3gr(rtype=IGMP_V3_GR_TYPE_INCLUDE, mcaddr=g)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700280 gr.sources = src_list
281 gr.sources = src_list
282 igmp.grps.append(gr)
283 if ip_pkt is None:
284 ip_pkt = self.igmp_eth/self.igmp_ip
285 pkt = ip_pkt/igmp
286 IGMPv3.fixup(pkt)
287 if rec_queryCount == None:
288 log.info('Sending IGMP join for group %s and waiting for one query packet and printing the packet' %groups)
289 resp = srp1(pkt, iface=iface)
290 else:
291 log.info('Sending IGMP join for group %s and waiting for periodic query packets and printing one packet' %groups)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700292 resp = srp1(pkt, iface=iface)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700293# resp = srp1(pkt, iface=iface) if rec_queryCount else srp3(pkt, iface=iface)
294 resp[0].summary()
295 log.info('Sent IGMP join for group %s and received a query packet and printing packet' %groups)
296 if delay != 0:
297 time.sleep(delay)
298
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700299 def send_igmp_leave(self, groups, src_list = ['1.2.3.4'], ip_pkt = None, iface = 'veth0', delay = 2):
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700300 log.info('entering into igmp leave function')
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800301 igmp = IGMPv3(type = IGMP_TYPE_V3_MEMBERSHIP_REPORT, max_resp_code=30,
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700302 gaddr=self.IP_DST)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800303 for g in groups:
Chetan Gaonker38737f82016-05-11 17:44:17 -0700304 gr = IGMPv3gr(rtype=IGMP_V3_GR_TYPE_EXCLUDE, mcaddr=g)
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800305 gr.sources = src_list
306 igmp.grps.append(gr)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700307 if ip_pkt is None:
308 ip_pkt = self.igmp_eth/self.igmp_ip
309 pkt = ip_pkt/igmp
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800310 IGMPv3.fixup(pkt)
311 sendp(pkt, iface = iface)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800312 if delay != 0:
313 time.sleep(delay)
Chetan Gaonker25470972016-02-26 08:52:15 -0800314
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700315 def send_igmp_leave_listening_group_specific_query(self, groups, src_list = ['1.2.3.4'], ip_pkt = None, iface = 'veth0', delay = 2):
316 igmp = IGMPv3(type = IGMP_TYPE_V3_MEMBERSHIP_REPORT, max_resp_code=30,
317 gaddr=self.IP_DST)
318 for g in groups:
Chetan Gaonker38737f82016-05-11 17:44:17 -0700319 gr = IGMPv3gr(rtype=IGMP_V3_GR_TYPE_EXCLUDE, mcaddr=g)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700320 gr.sources = src_list
321 igmp.grps.append(gr)
322 if ip_pkt is None:
323 ip_pkt = self.igmp_eth/self.igmp_ip
324 pkt = ip_pkt/igmp
325 IGMPv3.fixup(pkt)
326 log.info('Sending IGMP leave for group %s and waiting for one group specific query packet and printing the packet' %groups)
327 resp = srp1(pkt, iface=iface)
328 resp[0].summary()
329 log.info('Sent IGMP leave for group %s and received a group specific query packet and printing packet' %groups)
330 if delay != 0:
331 time.sleep(delay)
332
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800333 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10)
334 def test_igmp_join_verify_traffic(self):
Chetan Gaonker25470972016-02-26 08:52:15 -0800335 groups = ['224.0.1.1', '225.0.0.1']
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700336 self.onos_ssm_table_load(groups)
Chetan Gaonker25470972016-02-26 08:52:15 -0800337 df = defer.Deferred()
338 igmpState = IGMPTestState(groups = groups, df = df)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800339 igmpStateRecv = IGMPTestState(groups = groups, df = df)
340 igmpStateList = (igmpState, igmpStateRecv)
341 mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb, arg = igmpState)
342 self.df = df
343 self.mcastTraffic = mcastTraffic
344 self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP)
345
346 def igmp_srp_task(stateList):
347 igmpSendState, igmpRecvState = stateList
348 if not mcastTraffic.isRecvStopped():
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800349 self.igmp_recv(igmpRecvState)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800350 reactor.callLater(0, igmp_srp_task, stateList)
351 else:
352 self.mcastTraffic.stop()
353 self.recv_socket.close()
354 self.igmp_verify_join(stateList)
355 self.df.callback(0)
356
357 self.send_igmp_join(groups)
358 mcastTraffic.start()
359 self.test_timer = reactor.callLater(self.MCAST_TRAFFIC_TIMEOUT, self.mcast_traffic_timer)
360 reactor.callLater(0, igmp_srp_task, igmpStateList)
Chetan Gaonker25470972016-02-26 08:52:15 -0800361 return df
362
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700363 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+40)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800364 def test_igmp_leave_verify_traffic(self):
365 groups = ['224.0.1.10', '225.0.0.10']
366 leave_groups = ['224.0.1.10']
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700367 self.onos_ssm_table_load(groups)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800368 df = defer.Deferred()
369 igmpState = IGMPTestState(groups = groups, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800370 IGMPTestState(groups = groups, df = df)
A.R Karthick95d044e2016-06-10 18:44:36 -0700371 mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb,
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800372 arg = igmpState)
373 self.df = df
374 self.mcastTraffic = mcastTraffic
375 self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP)
A.R Karthick95d044e2016-06-10 18:44:36 -0700376
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700377 mcastTraffic.start()
378 self.send_igmp_join(groups)
379 self.send_igmp_leave(leave_groups, delay = 3)
380 join_state = IGMPTestState(groups = leave_groups)
381 status = self.igmp_not_recv_task(self.V_INF1,leave_groups, join_state)
382 log.info('verified status for igmp recv task %s'%status)
383 assert status == 1 , 'EXPECTED RESULT'
384 self.df.callback(0)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800385 return df
386
387 @deferred(timeout=100)
388 def test_igmp_leave_join_loop(self):
389 self.groups = ['226.0.1.1', '227.0.0.1', '228.0.0.1', '229.0.0.1', '230.0.0.1' ]
390 self.src_list = ['3.4.5.6', '7.8.9.10']
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700391 self.onos_ssm_table_load(self.groups,src_list=self.src_list)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800392 df = defer.Deferred()
393 self.df = df
394 self.iterations = 0
395 self.num_groups = len(self.groups)
396 self.MAX_TEST_ITERATIONS = 10
397
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800398 def igmp_srp_task(v):
399 if self.iterations < self.MAX_TEST_ITERATIONS:
400 if v == 1:
401 ##join test
402 self.num_groups = random.randint(0, len(self.groups))
403 self.send_igmp_join(self.groups[:self.num_groups],
404 src_list = self.src_list,
405 iface = 'veth0', delay = 0)
406 else:
407 self.send_igmp_leave(self.groups[:self.num_groups],
408 src_list = self.src_list,
409 iface = 'veth0', delay = 0)
410 self.iterations += 1
411 v ^= 1
412 reactor.callLater(1.0 + 0.5*self.num_groups,
413 igmp_srp_task, v)
414 else:
415 self.df.callback(0)
416
417 reactor.callLater(0, igmp_srp_task, 1)
418 return df
419
420 def igmp_join_task(self, intf, groups, state, src_list = ['1.2.3.4']):
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700421 #self.onos_ssm_table_load(groups, src_list)
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800422 igmp = IGMPv3(type = IGMP_TYPE_V3_MEMBERSHIP_REPORT, max_resp_code=30,
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700423 gaddr=self.IP_DST)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800424 for g in groups:
Chetan Gaonker38737f82016-05-11 17:44:17 -0700425 gr = IGMPv3gr(rtype = IGMP_V3_GR_TYPE_INCLUDE, mcaddr = g)
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800426 gr.sources = src_list
427 igmp.grps.append(gr)
428
429 for g in groups:
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800430 state.group_map[g][0].update(1, t = monotonic.monotonic())
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800431
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700432 pkt = self.igmp_eth/self.igmp_ip/igmp
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800433 IGMPv3.fixup(pkt)
434 sendp(pkt, iface=intf)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800435 log.debug('Returning from join task')
436
437 def igmp_recv_task(self, intf, groups, join_state):
438 recv_socket = L3PacketSocket(iface = intf, type = ETH_P_IP)
439 group_map = {}
440 for g in groups:
441 group_map[g] = [0,0]
442
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700443 log.info('Verifying join interface should receive multicast data')
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800444 while True:
445 p = recv_socket.recv()
446 if p.dst in groups and group_map[p.dst][0] == 0:
447 group_map[p.dst][0] += 1
448 group_map[p.dst][1] = monotonic.monotonic()
449 c = 0
450 for g in groups:
451 c += group_map[g][0]
452 if c == len(groups):
453 break
454 for g in groups:
455 join_start = join_state.group_map[g][0].start
456 recv_time = group_map[g][1] * 1000000
457 delta = (recv_time - join_start)
458 log.info('Join for group %s received in %.3f usecs' %
459 (g, delta))
460
461 recv_socket.close()
462 log.debug('Returning from recv task')
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700463
464 def igmp_not_recv_task(self, intf, groups, join_state):
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800465 log.info('Entering igmp not recv task loop')
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700466 recv_socket = L2Socket(iface = intf, type = ETH_P_IP)
467 group_map = {}
468 for g in groups:
469 group_map[g] = [0,0]
470
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800471 log.info('Verifying join interface, should not receive any multicast data')
Chetan Gaonker7791bda2016-05-12 17:36:52 -0700472 self.NEGATIVE_TRAFFIC_STATUS = 1
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700473 def igmp_recv_cb(pkt):
474 log.info('Multicast packet %s received for left groups %s' %(pkt[IP].dst, groups))
Chetan Gaonker7791bda2016-05-12 17:36:52 -0700475 self.NEGATIVE_TRAFFIC_STATUS = 2
Chetan Gaonker38737f82016-05-11 17:44:17 -0700476 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 -0700477 timeout = 3, opened_socket = recv_socket)
478 recv_socket.close()
A.R Karthick95d044e2016-06-10 18:44:36 -0700479 return self.NEGATIVE_TRAFFIC_STATUS
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700480
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800481 def group_latency_check(self, groups):
482 tasks = []
483 self.send_igmp_leave(groups = groups)
484 join_state = IGMPTestState(groups = groups)
485 tasks.append(threading.Thread(target=self.igmp_join_task, args = ('veth0', groups, join_state,)))
486 traffic_state = IGMPTestState(groups = groups)
A.R Karthick95d044e2016-06-10 18:44:36 -0700487 mcast_traffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb,
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800488 arg = traffic_state)
489 mcast_traffic.start()
490 tasks.append(threading.Thread(target=self.igmp_recv_task, args = ('veth0', groups, join_state)))
491 for t in tasks:
492 t.start()
493 for t in tasks:
494 t.join()
495
496 mcast_traffic.stop()
497 self.send_igmp_leave(groups = groups)
498 return
499
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700500 @deferred(timeout=IGMP_QUERY_TIMEOUT + 10)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800501 def test_igmp_1group_join_latency(self):
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700502 groups = ['239.0.1.1']
503 df = defer.Deferred()
504 def igmp_1group_join_latency():
505 self.group_latency_check(groups)
506 df.callback(0)
507 reactor.callLater(0, igmp_1group_join_latency)
508 return df
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800509
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700510 @deferred(timeout=IGMP_QUERY_TIMEOUT + 10)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800511 def test_igmp_2group_join_latency(self):
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700512 groups = ['239.0.1.1', '240.0.1.1']
513 df = defer.Deferred()
514 def igmp_2group_join_latency():
515 self.group_latency_check(groups)
516 df.callback(0)
517 reactor.callLater(0, igmp_2group_join_latency)
518 return df
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800519
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700520 @deferred(timeout=IGMP_QUERY_TIMEOUT + 10)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800521 def test_igmp_Ngroup_join_latency(self):
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700522 groups = ['239.0.1.1', '240.0.1.1', '241.0.1.1', '242.0.1.1']
523 df = defer.Deferred()
524 def igmp_Ngroup_join_latency():
525 self.group_latency_check(groups)
526 df.callback(0)
527 reactor.callLater(0, igmp_Ngroup_join_latency)
528 return df
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800529
A R Karthick2b93d6a2016-09-06 15:19:09 -0700530 def test_igmp_join_rover_all(self):
Chetan Gaonker1f7c3f82016-03-08 12:17:37 -0800531 s = (224 << 24) | 1
532 #e = (225 << 24) | (255 << 16) | (255 << 16) | 255
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700533 e = (224 << 24) | 10
Chetan Gaonker1f7c3f82016-03-08 12:17:37 -0800534 for i in xrange(s, e+1):
535 if i&0xff:
536 ip = '%d.%d.%d.%d'%((i>>24)&0xff, (i>>16)&0xff, (i>>8)&0xff, i&0xff)
537 self.send_igmp_join([ip], delay = 0)
538
A R Karthick2b93d6a2016-09-06 15:19:09 -0700539 @deferred(timeout=ROVER_TEST_TIMEOUT)
540 def test_igmp_join_rover(self):
541 df = defer.Deferred()
542 iface = self.get_igmp_intf()
543 self.df = df
544 self.count = 0
545 self.timeout = 0
546 self.complete = False
547 def igmp_join_timer():
548 self.timeout += self.ROVER_JOIN_TIMEOUT
549 log.info('IGMP joins sent: %d' %self.count)
A R Karthick2b93d6a2016-09-06 15:19:09 -0700550 if self.timeout >= self.ROVER_TIMEOUT:
551 self.complete = True
552 reactor.callLater(self.ROVER_JOIN_TIMEOUT, igmp_join_timer)
553
554 reactor.callLater(self.ROVER_JOIN_TIMEOUT, igmp_join_timer)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800555 self.start_channel = (224 << 24) | 1
556 self.end_channel = (224 << 24) | 200 #(225 << 24) | (255 << 16) | (255 << 16) | 255
A R Karthick2b93d6a2016-09-06 15:19:09 -0700557 self.current_channel = self.start_channel
558 def igmp_join_rover(self):
559 #e = (224 << 24) | 10
560 chan = self.current_channel
561 self.current_channel += 1
562 if self.current_channel >= self.end_channel:
563 chan = self.current_channel = self.start_channel
564 if chan&0xff:
565 ip = '%d.%d.%d.%d'%((chan>>24)&0xff, (chan>>16)&0xff, (chan>>8)&0xff, chan&0xff)
566 self.send_igmp_join([ip], delay = 0, ssm_load = False, iface = iface)
567 self.count += 1
568 if self.complete == True:
569 log.info('%d IGMP joins sent in %d seconds over %s' %(self.count, self.timeout, iface))
570 self.df.callback(0)
571 else:
572 reactor.callLater(0, igmp_join_rover, self)
573 reactor.callLater(0, igmp_join_rover, self)
574 return df
575
Chetan Gaonker1f7c3f82016-03-08 12:17:37 -0800576 @deferred(timeout=IGMP_QUERY_TIMEOUT + 10)
577 def test_igmp_query(self):
578 groups = ['224.0.0.1'] ##igmp query group
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700579 self.onos_ssm_table_load(groups)
Chetan Gaonker1f7c3f82016-03-08 12:17:37 -0800580 df = defer.Deferred()
581 self.df = df
582 self.recv_socket = L2Socket(iface = 'veth0', type = ETH_P_IP)
A.R Karthick95d044e2016-06-10 18:44:36 -0700583
Chetan Gaonker1f7c3f82016-03-08 12:17:37 -0800584 def igmp_query_timeout():
Chetan Gaonker1f7c3f82016-03-08 12:17:37 -0800585 def igmp_query_cb(pkt):
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700586 log.info('received igmp query packet is %s'%pkt.show())
Chetan Gaonkerbd4390f2016-03-09 18:56:52 -0800587 log.info('Got IGMP query packet from %s for %s' %(pkt[IP].src, pkt[IP].dst))
588 assert_equal(pkt[IP].dst, '224.0.0.1')
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700589 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 -0800590 opened_socket = self.recv_socket)
Chetan Gaonker1f7c3f82016-03-08 12:17:37 -0800591 self.recv_socket.close()
592 self.df.callback(0)
593
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700594 #self.send_igmp_join(groups)
Chetan Gaonker1f7c3f82016-03-08 12:17:37 -0800595 self.test_timer = reactor.callLater(self.IGMP_QUERY_TIMEOUT, igmp_query_timeout)
596 return df
597
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700598 def igmp_send_joins_different_groups_srclist(self, groups, sources, intf = V_INF1, delay = 2, ip_src = None):
599 g1 = groups[0]
600 g2 = groups[1]
601 sourcelist1 = sources[0]
602 sourcelist2 = sources[1]
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700603 eth = Ether(dst = self.IGMP_DST_MAC,type = ETH_P_IP)
604 ip = IP(dst = self.IP_DST)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700605 log.info('Sending join message for the group %s' %g1)
606 self.send_igmp_join((g1,), src_list = sourcelist1, ip_pkt = eth/ip, iface = intf, delay = 2)
607 eth = Ether(dst = self.MMACGROUP2, src = self.IGMP_SRC_MAC, type = ETH_P_IP)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700608 ip = IP(dst = g2)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700609 log.info('Sending join message for group %s' %g2)
610 self.send_igmp_join((g2,), src_list = sourcelist2, ip_pkt = eth/ip, iface = intf, delay = 2)
Chetan Gaonker7791bda2016-05-12 17:36:52 -0700611 log.info('Done with igmp_send_joins_different_groups_srclist')
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700612
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700613 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):
614 g1 = groups[0]
615 g2 = groups[1]
616 sourcelist1 = sources[0]
617 sourcelist2 = sources[1]
618 eth = Ether(dst = self.MMACGROUP1, src = self.IGMP_SRC_MAC, type = ETH_P_IP)
619 src_ip = ip_src or self.IP_SRC
620 ip = IP(dst = g1, src = src_ip)
621 if query_group1 is 'group1':
622 log.info('Sending join message for the group %s and waiting for a query packet on join interface' %g1)
623 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 -0700624 else:
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700625 log.info('Sending join message for the group %s' %g1)
626 self.send_igmp_join((g1,), src_list = sourcelist1, ip_pkt = eth/ip, iface = intf, delay = 2)
627 eth = Ether(dst = self.MMACGROUP2, src = self.IGMP_SRC_MAC, type = ETH_P_IP)
628 ip = IP(dst = g2, src = src_ip)
629 if query_group2 is 'group2':
630 log.info('Sending join message for the group %s and waiting for a query packet on join interface' %g2)
631 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 -0700632 else:
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700633 log.info('Sending join message for group %s' %g2)
634 self.send_igmp_join((g2,), src_list = sourcelist2, ip_pkt = eth/ip, iface = intf, delay = 2)
635
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700636 def igmp_joins_leave(self,groups,src_list,again_join = False, df = None):
637 groups1 = [groups[0]]
638 groups2 = [groups[1]]
639 src1 = [src_list[0]]
640 src2 = [src_list[1]]
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700641 self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700642 (src1, src2), intf = self.V_INF1, delay = 2)
643
644 src_ip = src1[0]
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700645 if df is None:
646 df = defer.Deferred()
647 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800648 IGMPTestState(groups = groups1, df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700649
650 igmpState2 = IGMPTestState(groups = groups2, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800651 IGMPTestState(groups = groups2, df = df)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700652 dst_mac = self.iptomac(groups1[0])
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700653 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
654 src_ip = src_ip, cb = self.send_mcast_cb,
655 arg = igmpState1)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700656 src_ip = src2[0]
657 dst_mac = self.iptomac(groups1[0])
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700658 mcastTraffic2 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
659 src_ip = src_ip, cb = self.send_mcast_cb,
660 arg = igmpState2)
661 mcastTraffic1.start()
662 mcastTraffic2.start()
663 join_state1 = IGMPTestState(groups = groups1)
664 join_state2 = IGMPTestState(groups = groups2)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800665 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700666 log.info('Interface is receiving multicast groups %s' %groups1)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800667 self.igmp_recv_task(self.V_INF1, groups2, join_state2)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700668 log.info('Interface is receiving multicast groups %s' %groups2)
669 log.info('Interface is sending leave message for groups %s now' %groups2)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700670 self.send_igmp_leave(groups = groups2, src_list = src2, iface = self.V_INF1, delay = 2)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800671 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700672 target4 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state2)
673 assert target4 == 1, 'EXPECTED FAILURE'
674 if again_join:
675 dst_mac = '01:00:5e:02:02:03'
676 ip_dst = '239.2.2.3'
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700677 eth = Ether(dst = dst_mac, type = ETH_P_IP)
678 ip = IP(dst = ip_dst)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700679 log.info('Interface sending join message again for the groups %s' %groups2)
680 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 -0800681 self.igmp_recv_task(self.V_INF1, groups2, join_state2)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700682 log.info('Interface is receiving multicast groups %s again' %groups2)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800683 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700684 log.info('Interface is still receiving from multicast groups %s' %groups1)
685 else:
686 log.info('Ended test case')
687 mcastTraffic1.stop()
688 mcastTraffic2.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -0700689
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700690
691 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700692 def test_igmp_2joins_1leave(self):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700693 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700694 def igmp_2joins_1leave():
695 groups = ['234.2.3.4','236.8.7.9']
696 src_list = ['2.3.4.5','5.4.3.2']
697 self.onos_ssm_table_load(groups,src_list = src_list)
698 self.igmp_joins_leave(groups,src_list,again_join = False, df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700699 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700700 reactor.callLater(0, igmp_2joins_1leave)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700701 return df
702
703 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+25)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700704 def test_igmp_2joins_1leave_and_join_again(self):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700705 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700706 def igmp_2joins_1leave_join_again():
707 groups = ['234.2.3.4','236.8.7.9']
708 src_list = ['2.3.4.5','5.4.3.2']
709 self.onos_ssm_table_load(groups,src_list = src_list)
710 self.igmp_joins_leave(groups,src_list,again_join = True, df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700711 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700712 reactor.callLater(0, igmp_2joins_1leave_join_again)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700713 return df
714
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700715 def igmp_not_in_src_list(self, df = None):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700716 groups1 = (self.MGROUP1,)
717 groups2 = (self.MGROUP2,)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700718 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 -0700719 self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
720 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
721 intf = self.V_INF1, delay = 2)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700722 src_ip = '6.6.6.6'
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700723 dst_mac = self.iptomac(groups1[0])
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700724 if df is None:
725 df = defer.Deferred()
726 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800727 IGMPTestState(groups = groups1, df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700728 mcastTraffic1 = McastTraffic(groups1, iface = 'veth2', dst_mac = dst_mac,
729 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
730 mcastTraffic1.start()
731 join_state1 = IGMPTestState(groups = groups1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700732 log.info('Interface should not receive from multicast groups %s from an interface, which is expected' %groups1)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700733 target1 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
Chetan Gaonker7791bda2016-05-12 17:36:52 -0700734 assert target1 == 2, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700735 log.info('Interface is not receiving traffic from multicast groups %s, working as expected' %groups1)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700736 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -0700737
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700738 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700739 def test_igmp_not_in_src_list(self):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700740 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700741 def igmp_not_in_src_list():
742 self.igmp_not_in_src_list(df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700743 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700744 reactor.callLater(0, igmp_not_in_src_list)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700745 return df
746
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700747 def igmp_change_to_exclude_src_list(self, df = None):
748 groups1 = [self.random_mcast_ip()]
749 groups2 = [self.random_mcast_ip()]
750 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 -0700751 self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
752 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
753 intf = self.V_INF1, delay = 2)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700754 src_ip = '2.2.2.2'
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700755 dst_mac=self.iptomac(groups1[0])
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700756 if df is None:
757 df = defer.Deferred()
758 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800759 IGMPTestState(groups = groups1, df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700760 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
761 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
762 mcastTraffic1.start()
763 join_state1 = IGMPTestState(groups = groups1)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800764 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700765 self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2'], iface = self.V_INF1, delay =2)
766 target2 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
Chetan Gaonker7791bda2016-05-12 17:36:52 -0700767 assert target2 == 2, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700768 log.info('Interface is not receiving traffic from multicast groups %s after sending CHANGE_TO_EXCLUDE' %groups1)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700769 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -0700770
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700771 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700772 def test_igmp_change_to_exclude_src_list(self):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700773 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700774 def igmp_change_to_exclude_src_list():
775 self.igmp_change_to_exclude_src_list(df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700776 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700777 reactor.callLater(0, igmp_change_to_exclude_src_list)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700778 return df
779
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700780 def igmp_include_to_allow_src_list(self, df = None):
781 groups1 = [self.random_mcast_ip()] #(self.MGROUP1,)
782 self.onos_ssm_table_load(groups1,src_list = ['4.4.4.4','6.6.6.6'])
783 self.send_igmp_join(groups = groups1, src_list = ['4.4.4.4'],record_type = IGMP_V3_GR_TYPE_INCLUDE,
784 iface = self.V_INF1)
785 src_ip = '4.4.4.4'
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700786 if df is None:
787 df = defer.Deferred()
788 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800789 IGMPTestState(groups = groups1, df = df)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700790 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2',src_ip = src_ip,
791 cb = self.send_mcast_cb, arg = igmpState1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700792 mcastTraffic1.start()
793 join_state1 = IGMPTestState(groups = groups1)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800794 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700795 mcastTraffic1.stop()
796 mcastTraffic2 = McastTraffic(groups1, iface= 'veth2',src_ip = '6.6.6.6',
797 cb = self.send_mcast_cb, arg = igmpState1)
798 self.send_igmp_join(groups = groups1, src_list = ['6.6.6.6'],record_type = IGMP_V3_GR_TYPE_ALLOW_NEW,
799 iface = self.V_INF1)
800 mcastTraffic2.start()
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800801 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700802 mcastTraffic2.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -0700803
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700804 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+30)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700805 def test_igmp_include_to_allow_src_list(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700806 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700807 def igmp_include_to_allow_src_list():
808 self.igmp_include_to_allow_src_list(df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700809 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700810 reactor.callLater(0, igmp_include_to_allow_src_list)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700811 return df
812
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700813 def igmp_include_to_block_src_list(self, df = None):
814 groups1 = [self.random_mcast_ip()] #groups1 = (self.MGROUP1,)
815 self.onos_ssm_table_load(groups1,src_list = ['4.4.4.4','6.6.6.6'])
816 self.send_igmp_join(groups = groups1, src_list = ['4.4.4.4','6.6.6.6'],record_type = IGMP_V3_GR_TYPE_INCLUDE,
817 iface = self.V_INF1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700818 if df is None:
819 df = defer.Deferred()
820 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800821 IGMPTestState(groups = groups1, df = df)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700822 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2',src_ip = '6.6.6.6',
823 cb = self.send_mcast_cb, arg = igmpState1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700824 mcastTraffic1.start()
825 join_state1 = IGMPTestState(groups = groups1)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800826 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700827 mcastTraffic1.stop()
828 self.send_igmp_join(groups = groups1, src_list = ['6.6.6.6'],record_type = IGMP_V3_GR_TYPE_BLOCK_OLD,
829 iface = self.V_INF1)
830 mcastTraffic2 = McastTraffic(groups1, iface= 'veth2',src_ip = '6.6.6.6',
831 cb = self.send_mcast_cb, arg = igmpState1)
832 mcastTraffic2.start()
833 target1 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
834 assert target1 == 1, 'EXPECTED FAILURE'
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800835 log.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 -0700836 mcastTraffic2.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -0700837
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700838 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+30)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700839 def test_igmp_include_to_block_src_list(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700840 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700841 def igmp_include_to_block_src_list():
842 self.igmp_include_to_block_src_list(df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700843 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700844 reactor.callLater(0, igmp_include_to_block_src_list)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700845 return df
846
847
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700848 def igmp_change_to_include_src_list(self, df = None):
849 groups1 = [self.random_mcast_ip()]
850 src_list = ['4.4.4.4','6.6.6.6']
851 self.onos_ssm_table_load(groups1,src_list = src_list)
852 self.send_igmp_leave(groups = groups1, src_list = src_list,
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700853 iface = self.V_INF1, delay = 2)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700854 if df is None:
855 df = defer.Deferred()
856 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800857 IGMPTestState(groups = groups1, df = df)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700858 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2',src_ip = src_list[0],
859 cb = self.send_mcast_cb, arg = igmpState1)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700860 mcastTraffic1.start()
861 join_state1 = IGMPTestState(groups = groups1)
862 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
863 assert target1 == 1, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700864 log.info('Interface is not receiving traffic from multicast groups %s' %groups1)
865 mcastTraffic1.stop()
866 self.send_igmp_join(groups = groups1, src_list = src_list,record_type = IGMP_V3_GR_TYPE_INCLUDE,
867 iface = self.V_INF1)
868 mcastTraffic2 = McastTraffic(groups1, iface= 'veth2',src_ip = src_list[1],
869 cb = self.send_mcast_cb, arg = igmpState1)
870 mcastTraffic2.start()
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800871 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700872 mcastTraffic2.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -0700873
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700874 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700875 def test_igmp_change_to_include_src_list(self):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700876 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700877 def igmp_change_to_include_src_list():
878 self.igmp_change_to_include_src_list(df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700879 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700880 reactor.callLater(0, igmp_change_to_include_src_list)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700881 return df
882
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700883 #this test case failing because group in include receiving multicast traffic from any of the source
884 def igmp_exclude_to_allow_src_list(self, df = None):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700885 groups1 = (self.MGROUP1,)
886 groups2 = (self.MGROUP2,)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700887 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 -0700888 self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4'],
889 iface = self.V_INF1, delay = 2)
A.R Karthick95d044e2016-06-10 18:44:36 -0700890
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700891 dst_mac = '01:00:5e:01:02:03'
892 src_ip = '2.2.2.2'
893 if df is None:
894 df = defer.Deferred()
895 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800896 IGMPTestState(groups = groups1, df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700897 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
898 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
899 mcastTraffic1.start()
900 join_state1 = IGMPTestState(groups = groups1)
901 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
902 assert target1 == 1, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700903 log.info('Interface is not receiving traffic from multicast groups %s' %groups1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700904 self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
905 (['6.6.6.6', '7.7.7.7', '8.8.8.8'], ['6.6.6.6', '5.5.5.5']),
906 intf = self.V_INF1, delay = 2)
907 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
908 assert target1 == 1, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700909 log.info('Interface is not receiving traffic from multicast groups %s' %groups1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700910 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -0700911
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700912 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700913 def test_igmp_exclude_to_allow_src_list(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700914 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700915 def igmp_exclude_to_allow_src_list():
916 self.igmp_exclude_to_allow_src_list(df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700917 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700918 reactor.callLater(0, igmp_exclude_to_allow_src_list)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700919 return df
920
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700921 def igmp_exclude_to_block_src_list(self, df = None):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700922 groups1 = (self.MGROUP1,)
923 groups2 = (self.MGROUP2,)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700924 self.onos_ssm_table_load(groups1+groups2,src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4','7.7.7.7','5.5.5.5'])
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700925 self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4'],
926 iface = self.V_INF1, delay = 2)
A.R Karthick95d044e2016-06-10 18:44:36 -0700927
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700928 dst_mac = '01:00:5e:01:02:03'
929 src_ip = '2.2.2.2'
930 if df is None:
931 df = defer.Deferred()
932 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800933 IGMPTestState(groups = groups1, df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700934 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
935 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
936 mcastTraffic1.start()
937 join_state1 = IGMPTestState(groups = groups1)
938 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
939 assert target1 == 1, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700940 log.info('Interface is not receiving traffic from multicast groups %s' %groups1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700941 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'],
942 iface = self.V_INF1, delay = 2)
943 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
944 assert target1 == 1, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700945 log.info('Interface is not receiving traffic from multicast groups %s' %groups1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700946 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -0700947
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700948 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700949 def test_igmp_exclude_to_block_src_list(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700950 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700951 def igmp_exclude_to_block_src_list():
952 self.igmp_exclude_to_block_src_list(df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700953 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700954 reactor.callLater(0, igmp_exclude_to_block_src_list)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700955 return df
956
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700957 #this test case failing because group in include mode recieves traffic from other sources also.
958 def igmp_new_src_list(self, df = None):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700959 groups1 = (self.MGROUP1,)
960 groups2 = (self.MGROUP2,)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700961 self.onos_ssm_table_load(groups1+groups2,src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4','5.5.5.5','6.6.6.6'])
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700962 self.igmp_send_joins_different_groups_srclist(groups1+groups2,
963 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
964 intf = self.V_INF1, delay = 2)
965 dst_mac = '01:00:5e:01:02:03'
966 src_ip = '6.6.6.6'
967 if df is None:
968 df = defer.Deferred()
969 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800970 IGMPTestState(groups = groups1, df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700971 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
972 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
973 mcastTraffic1.start()
974 join_state1 = IGMPTestState(groups = groups1)
975 target1 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
976 assert target1 == 1, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700977 log.info('Interface is not receiving traffic from multicast groups %s' %groups1)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700978 self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700979 (['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 -0700980 intf = self.V_INF1, delay = 2)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800981 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700982 log.info('Interface is receiving traffic from multicast groups %s after sending join with new source list' %groups1)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700983 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -0700984
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700985 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700986 def test_igmp_new_src_list(self):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700987 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700988 def igmp_new_src_list():
989 self.igmp_new_src_list(df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700990 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700991 reactor.callLater(0, igmp_new_src_list)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700992 return df
993
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700994 def igmp_block_old_src_list(self, df = None):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700995 groups1 = (self.MGROUP1,)
996 groups2 = (self.MGROUP2,)
997 groups = groups1 + groups2
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700998 self.onos_ssm_table_load(groups1+groups2,src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4','5.5.5.5','6.6.6.6','7.7.7.7'])
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700999 self.igmp_send_joins_different_groups_srclist(groups,
1000 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
1001 intf = self.V_INF1, delay = 2)
1002 dst_mac = '01:00:5e:02:02:03'
1003 src_ip = '5.5.5.5'
1004 if df is None:
1005 df = defer.Deferred()
1006 igmpState1 = IGMPTestState(groups = groups2, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001007 IGMPTestState(groups = groups2, df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001008 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1009 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1010 mcastTraffic1.start()
1011 join_state1 = IGMPTestState(groups = groups2)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001012 self.igmp_recv_task(self.V_INF1, groups2, join_state1)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001013 log.info('Interface is receiving traffic from multicast groups %s' %groups2)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001014 self.igmp_send_joins_different_groups_srclist(groups,
1015 (['6.6.6.6', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '7.7.7.7']),
1016 intf = self.V_INF1, delay = 2)
1017 target2 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1)
Chetan Gaonker7791bda2016-05-12 17:36:52 -07001018 assert target2 == 2, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001019 log.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 -07001020 mcastTraffic1.stop()
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001021
1022 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001023 def test_igmp_block_old_src_list(self):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001024 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001025 def igmp_block_old_src_list():
1026 self.igmp_block_old_src_list(df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001027 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001028 reactor.callLater(0, igmp_block_old_src_list)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001029 return df
1030
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001031 def igmp_include_empty_src_list(self, df = None):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001032 groups1 = (self.MGROUP1,)
1033 groups2 = (self.MGROUP2,)
1034 groups = groups1 + groups2
1035 self.igmp_send_joins_different_groups_srclist(groups,
Thangavelu K S790ad332016-12-14 12:54:58 +05301036 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['0']),
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001037 intf = self.V_INF1, delay = 2)
1038 dst_mac = '01:00:5e:02:02:03'
1039 src_ip = '5.5.5.5'
1040 if df is None:
1041 df = defer.Deferred()
1042 igmpState1 = IGMPTestState(groups = groups2, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001043 IGMPTestState(groups = groups2, df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001044 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1045 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1046 mcastTraffic1.start()
1047 join_state1 = IGMPTestState(groups = groups2)
1048 target1 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1)
1049 assert target1==1, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001050 log.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 -07001051 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001052
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001053 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001054 def test_igmp_include_empty_src_list(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001055 ## '''Disabling this test as scapy IGMP doesn't work with empty source lists'''
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001056 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001057 def igmp_include_empty_src_list():
1058 self.igmp_include_empty_src_list(df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001059 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001060 reactor.callLater(0, igmp_include_empty_src_list)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001061 return df
1062
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001063 def igmp_exclude_empty_src_list(self, df = None):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001064 groups2 = (self.MGROUP2,)
Thangavelu K S790ad332016-12-14 12:54:58 +05301065 self.send_igmp_leave(groups = groups2, src_list = ['0'], iface = self.V_INF1, delay = 2)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001066 dst_mac = '01:00:5e:02:02:03'
1067 src_ip = '5.5.5.5'
1068 if df is None:
1069 df = defer.Deferred()
1070 igmpState1 = IGMPTestState(groups = groups2, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001071 IGMPTestState(groups = groups2, df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001072 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1073 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1074 mcastTraffic1.start()
1075 join_state1 = IGMPTestState(groups = groups2)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001076 self.igmp_recv_task(self.V_INF1, groups2, join_state1)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001077 log.info('Interface is receiving multicast groups %s' %groups2)
1078 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001079
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001080 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001081 def test_igmp_exclude_empty_src_list(self):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001082 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001083 def igmp_exclude_empty_src_list():
1084 self.igmp_exclude_empty_src_list()
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001085 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001086 reactor.callLater(0, igmp_exclude_empty_src_list)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001087 return df
1088
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001089 def igmp_join_sourceip_0_0_0_0(self, df = None):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001090 groups1 = (self.MGROUP1,)
1091 groups2 = (self.MGROUP2,)
1092 groups = groups1 + groups2
1093 ip_src = '0.0.0.0'
1094 self.igmp_send_joins_different_groups_srclist(groups,
1095 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['5.5.5.5']),
1096 intf = self.V_INF1, delay = 2, ip_src = ip_src)
1097 ip_src = self.IP_SRC
1098 dst_mac = '01:00:5e:02:02:03'
1099 src_ip = '5.5.5.5'
1100 if df is None:
1101 df = defer.Deferred()
1102 igmpState1 = IGMPTestState(groups = groups2, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001103 IGMPTestState(groups = groups2, df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001104 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1105 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1106 mcastTraffic1.start()
1107 join_state1 = IGMPTestState(groups = groups2)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001108 self.igmp_recv_task(self.V_INF1, groups2, join_state1)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001109 log.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 -07001110 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001111
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001112 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001113 def test_igmp_join_sourceip_0_0_0_0(self):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001114 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001115 def igmp_join_sourceip_0_0_0_0():
1116 self.igmp_join_sourceip_0_0_0_0(df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001117 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001118 reactor.callLater(0, igmp_join_sourceip_0_0_0_0)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001119 return df
1120
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001121 def igmp_invalid_join_packet(self, df = None):
Chetan Gaonker586fec32016-04-29 17:33:54 -07001122 groups1 = (self.MGROUP1,)
1123 groups2 = (self.MINVALIDGROUP1,)
1124 groups = groups1 + groups2
1125 ip_src = '1.1.1.1'
1126 self.igmp_send_joins_different_groups_srclist(groups,
1127 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['5.5.5.5']),
1128 intf = self.V_INF1, delay = 2, ip_src = ip_src)
1129 ip_src = self.IP_SRC
1130 dst_mac = '01:00:5e:02:02:03'
1131 src_ip = '5.5.5.5'
1132 if df is None:
1133 df = defer.Deferred()
1134 igmpState1 = IGMPTestState(groups = groups2, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001135 IGMPTestState(groups = groups2, df = df)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001136 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1137 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1138 mcastTraffic1.start()
1139 join_state1 = IGMPTestState(groups = groups2)
1140 target1 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1)
1141 assert target1==1, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001142 log.info('Interface is not receiving traffic from multicast groups %s when we sent invalid join packet ' %groups2)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001143 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001144
Chetan Gaonker586fec32016-04-29 17:33:54 -07001145 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001146 def test_igmp_invalid_join_packet(self):
Chetan Gaonker586fec32016-04-29 17:33:54 -07001147 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001148 def igmp_invalid_join_packet():
1149 self.igmp_invalid_join_packet(df = df)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001150 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001151 reactor.callLater(0, igmp_invalid_join_packet)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001152 return df
1153
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001154 def igmp_join_data_receiving_during_subscriber_link_toggle(self, df = None):
Chetan Gaonker586fec32016-04-29 17:33:54 -07001155 groups1 = (self.MGROUP1,)
1156 groups2 = (self.MGROUP2,)
1157 groups = groups1 + groups2
1158 ip_src = '1.1.1.1'
1159 self.igmp_send_joins_different_groups_srclist(groups,
1160 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['5.5.5.5']),
1161 intf = self.V_INF1, delay = 2, ip_src = ip_src)
1162 ip_src = self.IP_SRC
1163 dst_mac = '01:00:5e:02:02:03'
1164 src_ip = '5.5.5.5'
1165 if df is None:
1166 df = defer.Deferred()
1167 igmpState1 = IGMPTestState(groups = groups2, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001168 IGMPTestState(groups = groups2, df = df)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001169 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1170 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1171 mcastTraffic1.start()
1172 join_state1 = IGMPTestState(groups = groups2)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001173 self.igmp_recv_task(self.V_INF1, groups2, join_state1)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001174 log.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 -07001175 os.system('ifconfig '+self.V_INF1+' down')
1176 log.info(' the self.V_INF1 %s is down now ' %self.V_INF1)
1177 os.system('ifconfig '+self.V_INF1)
1178 time.sleep(10)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001179 os.system('ifconfig '+self.V_INF1+' up')
1180 os.system('ifconfig '+self.V_INF1)
1181 log.info(' the self.V_INF1 %s is up now ' %self.V_INF1)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001182 self.igmp_recv_task(self.V_INF1, groups2, join_state1)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001183 log.info('Interface is receiving traffic from multicast groups %s when we nterface up after down ' %groups2)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001184 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001185
Chetan Gaonker586fec32016-04-29 17:33:54 -07001186 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001187 def test_igmp_join_data_received_during_subscriber_link_toggle(self):
Chetan Gaonker586fec32016-04-29 17:33:54 -07001188 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001189 def igmp_join_data_received_during_subscriber_link_toggle():
1190 self.igmp_join_data_received_during_subscriber_link_toggle(df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001191 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001192 reactor.callLater(0, igmp_join_data_received_during_subscriber_link_toggle)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001193 return df
1194
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001195 def igmp_join_data_received_during_channel_distributor_link_toggle(self, df = None):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001196 groups1 = (self.MGROUP1,)
1197 groups2 = (self.MGROUP2,)
1198 groups = groups1 + groups2
1199 ip_src = '1.1.1.1'
1200 self.igmp_send_joins_different_groups_srclist(groups,
1201 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['5.5.5.5', '6.6.6.6']),
1202 intf = self.V_INF1, delay = 2, ip_src = ip_src)
1203 ip_src = self.IP_SRC
1204 dst_mac1 = '01:00:5e:01:02:03'
1205 dst_mac2 = '01:00:5e:02:02:03'
1206 src_ip2 = '5.5.5.5'
1207 src_ip1 = '2.2.2.2'
1208 if df is None:
1209 df = defer.Deferred()
1210 igmpState1 = IGMPTestState(groups = groups1, df = df)
1211 igmpState2 = IGMPTestState(groups = groups2, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001212 IGMPTestState(groups = groups1, df = df)
1213 IGMPTestState(groups = groups2, df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001214 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac1,
1215 src_ip = src_ip1, cb = self.send_mcast_cb, arg = igmpState1)
1216 mcastTraffic2 = McastTraffic(groups2, iface= 'veth3', dst_mac = dst_mac2,
1217 src_ip = src_ip2, cb = self.send_mcast_cb, arg = igmpState2)
1218 mcastTraffic1.start()
1219 mcastTraffic2.start()
1220 join_state1 = IGMPTestState(groups = groups1)
1221 join_state2 = IGMPTestState(groups = groups2)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001222 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
1223 self.igmp_recv_task(self.V_INF1, groups2, join_state2)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001224 mcastTraffic1.stop()
1225 os.system('ifconfig '+'veth2'+' down')
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001226 os.system('ifconfig '+'veth2')
1227 time.sleep(10)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001228 self.igmp_not_recv_task(self.V_INF1, groups2, join_state1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001229 target1 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
1230 assert target1==1, 'EXPECTED FAILURE'
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001231 os.system('ifconfig '+'veth2'+' up')
1232 os.system('ifconfig '+'veth2')
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001233 time.sleep(10)
1234 mcastTraffic1.start()
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001235 self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
1236 self.igmp_recv_task(self.V_INF1, groups2, join_state2)
1237 self.igmp_recv_task(self.V_INF1, groups2, join_state2)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001238 mcastTraffic2.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001239
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001240 ## This test case is failing to receive traffic from multicast data from defferent channel interfaces TO-DO
1241 ###### TO DO scenario #######
1242 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+60)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001243 def test_igmp_join_data_received_during_channel_distributors_link_toggle(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001244 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001245 def igmp_join_data_receiving_during_channel_distributor_link_toggle():
Thangavelu K S790ad332016-12-14 12:54:58 +05301246 self.igmp_join_data_received_during_channel_distributor_link_toggle(df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001247 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001248 reactor.callLater(0, igmp_join_data_receiving_during_channel_distributor_link_toggle)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001249 return df
Chetan Gaonker586fec32016-04-29 17:33:54 -07001250
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001251 def igmp_invalidClassD_IP_join_packet(self, df = None):
Chetan Gaonker586fec32016-04-29 17:33:54 -07001252 groups1 = (self.MGROUP1,)
1253 groups2 = (self.MINVALIDGROUP2,)
1254 groups = groups1 + groups2
1255 ip_src = '1.1.1.1'
1256 self.igmp_send_joins_different_groups_srclist(groups,
1257 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['5.5.5.5']),
1258 intf = self.V_INF1, delay = 2, ip_src = ip_src)
1259 ip_src = self.IP_SRC
1260 dst_mac = '01:00:5e:02:02:03'
1261 src_ip = '5.5.5.5'
1262 if df is None:
1263 df = defer.Deferred()
1264 igmpState1 = IGMPTestState(groups = groups2, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001265 IGMPTestState(groups = groups2, df = df)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001266 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1267 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1268 mcastTraffic1.start()
1269 join_state1 = IGMPTestState(groups = groups2)
1270 target1 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1)
1271 assert target1==1, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001272 log.info('Interface is not receiving traffic from multicast groups %s when we sent invalid join packet ' %groups2)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001273 mcastTraffic1.stop()
Chetan Gaonker586fec32016-04-29 17:33:54 -07001274
1275 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001276 def test_igmp_invalid_class_d_ip_for_join_packet(self):
Chetan Gaonker586fec32016-04-29 17:33:54 -07001277 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001278 def igmp_invalidClass_D_IP_join_packet():
Thangavelu K S790ad332016-12-14 12:54:58 +05301279 self.igmp_invalidClassD_IP_join_packet(df = df)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001280 df.callback(0)
Thangavelu K S790ad332016-12-14 12:54:58 +05301281 reactor.callLater(0, igmp_invalidClass_D_IP_join_packet)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001282 return df
1283
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001284 def igmp_invalidClassD_IP_as_srclistIP_join_packet(self, df = None):
Chetan Gaonker586fec32016-04-29 17:33:54 -07001285 groups1 = (self.MGROUP1,)
1286 groups2 = (self.MGROUP2,)
1287 groups = groups1 + groups2
1288 ip_src = '1.1.1.1'
1289 self.igmp_send_joins_different_groups_srclist(groups,
1290 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['239.5.5.5']),
1291 intf = self.V_INF1, delay = 2, ip_src = ip_src)
1292 ip_src = self.IP_SRC
1293 dst_mac = '01:00:5e:02:02:03'
1294 src_ip = '5.5.5.5'
1295 if df is None:
1296 df = defer.Deferred()
1297 igmpState1 = IGMPTestState(groups = groups2, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001298 IGMPTestState(groups = groups2, df = df)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001299 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1300 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1301 mcastTraffic1.start()
1302 join_state1 = IGMPTestState(groups = groups2)
1303 target1 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1)
1304 assert target1==1, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001305 log.info('Interface is not receiving traffic from multicast groups %s when we sent invalid join packet ' %groups2)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001306 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001307
Chetan Gaonker586fec32016-04-29 17:33:54 -07001308 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001309 def test_igmp_invalid_class_d_ip_as_srclist_ip_for_join_packet(self):
Chetan Gaonker586fec32016-04-29 17:33:54 -07001310 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001311 def igmp_invalidClassD_IP_as_srclistIP_join_packet():
1312 self.igmp_invalidClassD_IP_as_srclistIP_join_packet(df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001313 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001314 reactor.callLater(0, igmp_invalidClassD_IP_as_srclistIP_join_packet)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001315 return df
Chetan Gaonkerf72ca402016-05-02 16:29:32 -07001316
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001317 def igmp_general_query_recv_packet(self, df = None):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001318 groups1 = (self.MGROUP1,)
1319 groups2 = (self.MGROUP2,)
1320 groups = groups1 + groups2
1321 ip_src = '1.1.1.1'
1322 self.igmp_send_joins_different_groups_srclist(groups,
1323 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['5.5.5.5']),
1324 intf = self.V_INF1, delay = 2, ip_src = ip_src)
1325 ip_src = self.IP_SRC
1326 dst_mac = '01:00:5e:02:02:03'
1327 src_ip = '5.5.5.5'
1328 if df is None:
1329 df = defer.Deferred()
1330 igmpState1 = IGMPTestState(groups = groups2, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001331 IGMPTestState(groups = groups2, df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001332 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1333 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1334 mcastTraffic1.start()
1335 join_state1 = IGMPTestState(groups = groups2)
1336 log.info('Started delay to verify multicast data taraffic for group %s is received or not for 180 sec ' %groups2)
1337 time.sleep(100)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001338 self.igmp_recv_task(self.V_INF1, groups2, join_state1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001339 log.info('Verified that multicast data for group %s is received after 100 sec ' %groups2)
1340 time.sleep(50)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001341 self.igmp_recv_task(self.V_INF1, groups2, join_state1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001342 log.info('Verified that multicast data for group %s is received after 150 sec ' %groups2)
1343 time.sleep(30)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001344 self.igmp_recv_task(self.V_INF1, groups2, join_state1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001345 log.info('Verified that multicast data for group %s is received after 180 sec ' %groups2)
1346 time.sleep(10)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001347 self.igmp_recv_task(self.V_INF1, groups2, join_state1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001348 log.info('Verified that multicast data for group %s is received after 190 sec ' %groups2)
1349 target3 = mcastTraffic1.isRecvStopped()
1350 assert target3==False, 'EXPECTED FAILURE'
1351 log.info('Verified that multicast data for a group %s is still transmitting from a data interface' %groups2)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001352 log.info('Now checking join interface is receiving a multicast data for group %s after 190 sec' %groups2)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001353 target1 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1)
1354 assert target1==1, 'EXPECTED FAILURE'
1355 log.info('Interface is not receiving multicast data for group %s' %groups2)
1356 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001357
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001358 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+250)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001359 def test_igmp_general_query_received_traffic(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001360 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001361 def igmp_general_query_recv_packet():
1362 self.igmp_general_query_recv_packet(df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001363 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001364 reactor.callLater(0, igmp_general_query_recv_packet)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001365 return df
A.R Karthick95d044e2016-06-10 18:44:36 -07001366
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001367 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+100)
1368 def test_igmp_query_received_on_joining_interface(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001369 groups = ['224.0.1.10', '225.0.0.10']
1370 leave_groups = ['224.0.1.10']
1371 df = defer.Deferred()
1372 igmpState = IGMPTestState(groups = groups, df = df)
1373 igmpStateRecv = IGMPTestState(groups = groups, df = df)
1374 igmpStateList = (igmpState, igmpStateRecv)
A.R Karthick95d044e2016-06-10 18:44:36 -07001375 mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb,
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001376 arg = igmpState)
1377 self.df = df
1378 self.mcastTraffic = mcastTraffic
1379 self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP)
A.R Karthick95d044e2016-06-10 18:44:36 -07001380
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001381 def igmp_srp_task(stateList):
1382 igmpSendState, igmpRecvState = stateList
1383 if not mcastTraffic.isRecvStopped():
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001384 self.igmp_recv(igmpRecvState)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001385 reactor.callLater(0, igmp_srp_task, stateList)
1386 else:
1387 self.mcastTraffic.stop()
1388 self.recv_socket.close()
1389 self.igmp_verify_leave(stateList, leave_groups)
1390 self.df.callback(0)
1391
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001392 log.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 -07001393 self.send_igmp_join_recvQuery(groups)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001394 log.info('Received a general query packet for multicast %s group on joing interface and sending traffic' %groups)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001395 mcastTraffic.start()
1396 self.test_timer = reactor.callLater(self.MCAST_TRAFFIC_TIMEOUT, self.mcast_traffic_timer)
1397 reactor.callLater(0, igmp_srp_task, igmpStateList)
1398 return df
1399
1400 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+190)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001401 def test_igmp_for_periodic_query_received_on_joining_interface(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001402 groups = ['224.0.1.10', '225.0.0.10']
1403 leave_groups = ['224.0.1.10']
1404 df = defer.Deferred()
1405 igmpState = IGMPTestState(groups = groups, df = df)
A.R Karthick95d044e2016-06-10 18:44:36 -07001406 mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb,
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001407 arg = igmpState)
1408 self.df = df
1409 self.mcastTraffic = mcastTraffic
1410 self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP)
A.R Karthick95d044e2016-06-10 18:44:36 -07001411
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001412 def igmp_srp_task(stateList):
1413 igmpSendState, igmpRecvState = stateList
1414 if not mcastTraffic.isRecvStopped():
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001415 self.igmp_recv(igmpRecvState)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001416 reactor.callLater(0, igmp_srp_task, stateList)
1417 else:
1418 self.mcastTraffic.stop()
1419 self.recv_socket.close()
1420 self.igmp_verify_leave(stateList, leave_groups)
1421 self.df.callback(0)
1422
1423 self.send_igmp_join_recvQuery(groups,3)
1424 return df
1425
1426 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+190)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001427 def test_igmp_for_periodic_query_received_and_checking_entry_deleted(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001428 groups = ['224.0.1.10', '225.0.0.10']
1429 leave_groups = ['224.0.1.10']
1430 df = defer.Deferred()
1431 igmpState = IGMPTestState(groups = groups, df = df)
1432 igmpStateRecv = IGMPTestState(groups = groups, df = df)
1433 igmpStateList = (igmpState, igmpStateRecv)
A.R Karthick95d044e2016-06-10 18:44:36 -07001434 mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb,
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001435 arg = igmpState)
1436 self.df = df
1437 self.mcastTraffic = mcastTraffic
1438 self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP)
A.R Karthick95d044e2016-06-10 18:44:36 -07001439
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001440 def igmp_srp_task(stateList):
1441 igmpSendState, igmpRecvState = stateList
1442 if not mcastTraffic.isRecvStopped():
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001443 self.igmp_recv(igmpRecvState)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001444 reactor.callLater(0, igmp_srp_task, stateList)
1445 else:
1446 self.mcastTraffic.stop()
1447 self.recv_socket.close()
1448 self.igmp_verify_leave(stateList, leave_groups)
1449 self.df.callback(0)
1450
1451 self.send_igmp_join_recvQuery(groups,3)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001452 log.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 -07001453 mcastTraffic.start()
1454 self.test_timer = reactor.callLater(self.MCAST_TRAFFIC_TIMEOUT, self.mcast_traffic_timer)
1455 reactor.callLater(0, igmp_srp_task, igmpStateList)
1456 return df
1457
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001458 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+190)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001459 def test_igmp_member_query_interval_and_expiry_for_rejoining_interface(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001460 groups = ['224.0.1.10', '225.0.0.10']
1461 leave_groups = ['224.0.1.10']
1462 df = defer.Deferred()
1463 igmpState = IGMPTestState(groups = groups, df = df)
1464 igmpStateRecv = IGMPTestState(groups = groups, df = df)
1465 igmpStateList = (igmpState, igmpStateRecv)
A.R Karthick95d044e2016-06-10 18:44:36 -07001466 mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb,
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001467 arg = igmpState)
1468 self.df = df
1469 self.mcastTraffic = mcastTraffic
1470 self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP)
A.R Karthick95d044e2016-06-10 18:44:36 -07001471
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001472 def igmp_srp_task(stateList):
1473 igmpSendState, igmpRecvState = stateList
1474 if not mcastTraffic.isRecvStopped():
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001475 self.igmp_recv(igmpRecvState)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001476 reactor.callLater(0, igmp_srp_task, stateList)
1477 else:
1478 self.mcastTraffic.stop()
1479 self.recv_socket.close()
1480 self.igmp_verify_leave(stateList, leave_groups)
1481 self.df.callback(0)
1482
1483 self.send_igmp_join_recvQuery(groups,3)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001484 log.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 -07001485 self.send_igmp_join(groups)
1486 mcastTraffic.start()
1487 self.test_timer = reactor.callLater(self.MCAST_TRAFFIC_TIMEOUT, self.mcast_traffic_timer)
1488 reactor.callLater(0, igmp_srp_task, igmpStateList)
1489 return df
1490
1491 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+50)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001492 def test_igmp_leave_received_group_and_source_specific_query(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001493 groups = ['224.0.1.10', '225.0.0.10']
1494 leave_groups = ['224.0.1.10']
1495 df = defer.Deferred()
1496 igmpState = IGMPTestState(groups = groups, df = df)
A.R Karthick95d044e2016-06-10 18:44:36 -07001497 mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb,
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001498 arg = igmpState)
1499 self.df = df
1500 self.mcastTraffic = mcastTraffic
1501 self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP)
A.R Karthick95d044e2016-06-10 18:44:36 -07001502
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001503 def igmp_srp_task(stateList):
1504 igmpSendState, igmpRecvState = stateList
1505 if not mcastTraffic.isRecvStopped():
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001506 self.igmp_recv(igmpRecvState)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001507 reactor.callLater(0, igmp_srp_task, stateList)
1508 else:
1509 self.mcastTraffic.stop()
1510 self.recv_socket.close()
1511 self.igmp_verify_leave(stateList, leave_groups)
1512 self.df.callback(0)
1513
1514 self.send_igmp_join(groups)
1515 self.send_igmp_leave_listening_group_specific_query(leave_groups, delay = 3)
1516 return df
1517
1518 def igmp_change_to_exclude_src_list_check_for_group_source_specific_query(self, df = None):
1519 groups1 = (self.MGROUP1,)
1520 groups2 = (self.MGROUP2,)
1521 self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
1522 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
1523 intf = self.V_INF1, delay = 2)
1524 dst_mac = '01:00:5e:01:02:03'
1525 src_ip = '2.2.2.2'
1526 if df is None:
1527 df = defer.Deferred()
1528 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001529 IGMPTestState(groups = groups1, df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001530 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
1531 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1532 mcastTraffic1.start()
1533 join_state1 = IGMPTestState(groups = groups1)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001534 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001535 self.send_igmp_leave_listening_group_specific_query(groups = groups1, src_list = ['2.2.2.2'], iface = self.V_INF1, delay =2)
1536 time.sleep(10)
1537 target2 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
1538 assert target2 == 1, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001539 log.info('Interface is not receiving traffic from multicast groups %s after sending CHANGE_TO_EXCLUDE' %groups2)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001540 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001541
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001542 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+60)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001543 def test_igmp_change_to_exclude_src_list_and_check_for_group_source_specific_query(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001544 df = defer.Deferred()
1545 def igmp_change_to_exclude_src_list_check_for_group_source_specific_query():
1546 self.igmp_change_to_exclude_src_list_check_for_group_source_specific_query(df = df)
1547 df.callback(0)
1548 reactor.callLater(0, igmp_change_to_exclude_src_list_check_for_group_source_specific_query)
1549 return df
1550
1551 def igmp_change_to_include_src_list_check_for_general_query(self, df = None):
1552 groups1 = (self.MGROUP1,)
1553 groups2 = (self.MGROUP2,)
1554 self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4'],
1555 iface = self.V_INF1, delay = 2)
1556 dst_mac = '01:00:5e:01:02:03'
1557 src_ip = '2.2.2.2'
1558 if df is None:
1559 df = defer.Deferred()
1560 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001561 IGMPTestState(groups = groups1, df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001562 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
1563 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1564 mcastTraffic1.start()
1565 join_state1 = IGMPTestState(groups = groups1)
1566 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
1567 assert target1 == 1, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001568 log.info('Interface is not receiving traffic from multicast groups %s' %groups1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001569 self.igmp_send_joins_different_groups_srclist_wait_query_packets(groups1 + groups2,
1570 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['6.6.6.6', '5.5.5.5']),
1571 intf = self.V_INF1, delay = 2,query_group1 = 'group1', query_group2 = None)
1572 time.sleep(10)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001573 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001574 log.info('Interface is receiving traffic from multicast groups %s after send Change to include message' %groups1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001575 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001576
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001577 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+80)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001578 def test_igmp_change_to_include_src_list_and_check_for_general_query(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001579 df = defer.Deferred()
1580 def igmp_change_to_include_src_list_check_for_general_query():
1581 self.igmp_change_to_include_src_list_check_for_general_query(df = df)
1582 df.callback(0)
1583 reactor.callLater(0, igmp_change_to_include_src_list_check_for_general_query)
1584 return df
1585
1586 def igmp_allow_new_src_list_check_for_general_query(self, df = None):
1587 groups1 = (self.MGROUP1,)
1588 groups2 = (self.MGROUP2,)
1589 self.igmp_send_joins_different_groups_srclist(groups1+groups2,
1590 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
1591 intf = self.V_INF1, delay = 2)
1592 dst_mac = '01:00:5e:01:02:03'
1593 src_ip = '6.6.6.6'
1594 if df is None:
1595 df = defer.Deferred()
1596 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001597 IGMPTestState(groups = groups1, df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001598 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
1599 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1600 mcastTraffic1.start()
1601 join_state1 = IGMPTestState(groups = groups1)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001602 self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001603 log.info('Interface is not receiving traffic from multicast groups %s' %groups1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001604 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']),
1605 intf = self.V_INF1, delay = 2, query_group1 = 'group1', query_group2 = None)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001606 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001607 log.info('Interface is receiving traffic from multicast groups %s after sending join with new source list' %groups1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001608 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001609
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001610 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+80)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001611 def test_igmp_allow_new_src_list_and_check_for_general_query(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001612 df = defer.Deferred()
1613 def igmp_allow_new_src_list_check_for_general_query():
1614 self.igmp_allow_new_src_list_check_for_general_query(df = df)
1615 df.callback(0)
1616 reactor.callLater(0, igmp_allow_new_src_list_check_for_general_query)
1617 return df
1618
1619 def igmp_block_old_src_list_check_for_group_source_specific_query(self, df = None):
1620 groups1 = (self.MGROUP1,)
1621 groups2 = (self.MGROUP2,)
1622 groups = groups1 + groups2
1623 self.igmp_send_joins_different_groups_srclist(groups,
1624 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
1625 intf = self.V_INF1, delay = 2)
1626 dst_mac = '01:00:5e:02:02:03'
1627 src_ip = '5.5.5.5'
1628 if df is None:
1629 df = defer.Deferred()
1630 igmpState1 = IGMPTestState(groups = groups2, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001631 IGMPTestState(groups = groups2, df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001632 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1633 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1634 mcastTraffic1.start()
1635 join_state1 = IGMPTestState(groups = groups2)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001636 self.igmp_recv_task(self.V_INF1, groups2, join_state1)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001637 log.info('Interface is receiving traffic from multicast groups %s' %groups2)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001638 self.igmp_send_joins_different_groups_srclist_wait_query_packets(groups,
1639 (['6.6.6.6', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '7.7.7.7']),
1640 intf = self.V_INF1, delay = 2, query_group1 = 'group1', query_group2 = None)
1641 target2 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1)
1642 assert target2 == 1, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001643 log.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 -07001644 mcastTraffic1.stop()
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001645
1646 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+90)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001647 def test_igmp_block_old_src_list_and_check_for_group_source_specific_query(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001648 df = defer.Deferred()
1649 def igmp_block_old_src_list_check_for_group_source_specific_query():
1650 self.igmp_block_old_src_list_check_for_group_source_specific_query(df = df)
1651 df.callback(0)
1652 reactor.callLater(0, igmp_block_old_src_list_check_for_group_source_specific_query)
1653 return df
1654
1655 def igmp_include_to_allow_src_list_check_for_general_query(self, df = None):
1656 groups1 = (self.MGROUP1,)
1657 groups2 = (self.MGROUP2,)
1658 self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
1659 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
1660 intf = self.V_INF1, delay = 2)
1661 dst_mac = '01:00:5e:01:02:03'
1662 src_ip = '2.2.2.2'
1663 if df is None:
1664 df = defer.Deferred()
1665 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001666 IGMPTestState(groups = groups1, df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001667 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
1668 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1669 mcastTraffic1.start()
1670 join_state1 = IGMPTestState(groups = groups1)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001671 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001672 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 -08001673 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001674 mcastTraffic1.stop()
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001675
1676 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+40)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001677 def test_igmp_include_to_allow_src_list_and_check_for_general_query(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001678 df = defer.Deferred()
1679 def igmp_include_to_allow_src_list_check_for_general_query():
1680 self.igmp_include_to_allow_src_list_check_for_general_query(df = df)
1681 df.callback(0)
1682 reactor.callLater(0, igmp_include_to_allow_src_list_check_for_general_query)
1683 return df
1684
1685 def igmp_include_to_block_src_list_check_for_group_source_specific_query(self, df = None):
1686 groups1 = (self.MGROUP1,)
1687 groups2 = (self.MGROUP2,)
1688 self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
1689 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
1690 intf = self.V_INF1, delay = 2)
1691 dst_mac = '01:00:5e:01:02:03'
1692 src_ip = '2.2.2.2'
1693 if df is None:
1694 df = defer.Deferred()
1695 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001696 IGMPTestState(groups = groups1, df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001697 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
1698 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1699 mcastTraffic1.start()
1700 join_state1 = IGMPTestState(groups = groups1)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001701 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001702 self.send_igmp_leave_listening_group_specific_query(groups = groups1, src_list = ['6.6.6.6','7.7.7.7'],
1703 iface = self.V_INF1, delay = 2)
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 mcastTraffic1.stop()
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001706
1707 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+40)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001708 def test_igmp_include_to_block_src_list_and_check_for_group_source_specific_query(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001709 df = defer.Deferred()
1710 def igmp_include_to_block_src_list_check_for_group_source_specific_query():
1711 self.igmp_include_to_block_src_list_check_for_group_source_specific_query(df = df)
1712 df.callback(0)
1713 reactor.callLater(0, igmp_include_to_block_src_list_check_for_group_source_specific_query)
1714 return df
1715
1716 def igmp_exclude_to_allow_src_list_check_for_general_query(self, df = None):
1717 groups1 = (self.MGROUP1,)
1718 groups2 = (self.MGROUP2,)
1719 self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4'],
1720 iface = self.V_INF1, delay = 2)
A.R Karthick95d044e2016-06-10 18:44:36 -07001721
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001722 dst_mac = '01:00:5e:01:02:03'
1723 src_ip = '2.2.2.2'
1724 if df is None:
1725 df = defer.Deferred()
1726 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001727 IGMPTestState(groups = groups1, df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001728 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
1729 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1730 mcastTraffic1.start()
1731 join_state1 = IGMPTestState(groups = groups1)
1732 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
1733 assert target1 == 1, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001734 log.info('Interface is not receiving traffic from multicast groups %s' %groups1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001735 self.igmp_send_joins_different_groups_srclist_wait_query_packets(groups1 + groups2,
1736 (['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)
1737 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
1738 assert target1 == 1, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001739 log.info('Interface is not receiving traffic from multicast groups %s' %groups1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001740 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001741
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001742 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+90)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001743 def test_igmp_exclude_to_allow_src_list_and_check_for_general_query(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001744 df = defer.Deferred()
1745 def igmp_exclude_to_allow_src_list_check_for_general_query():
1746 self.igmp_exclude_to_allow_src_list_check_for_general_query(df = df)
1747 df.callback(0)
1748 reactor.callLater(0, igmp_exclude_to_allow_src_list_check_for_general_query)
1749 return df
1750
1751 def igmp_exclude_to_block_src_list_check_for_group_source_specific_query(self, df = None):
1752 groups1 = (self.MGROUP1,)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001753 self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4'],
1754 iface = self.V_INF1, delay = 2)
A.R Karthick95d044e2016-06-10 18:44:36 -07001755
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001756 dst_mac = '01:00:5e:01:02:03'
1757 src_ip = '2.2.2.2'
1758 if df is None:
1759 df = defer.Deferred()
1760 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001761 IGMPTestState(groups = groups1, df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001762 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
1763 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1764 mcastTraffic1.start()
1765 join_state1 = IGMPTestState(groups = groups1)
1766 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
1767 assert target1 == 1, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001768 log.info('Interface is not receiving traffic from multicast groups %s' %groups1)
A.R Karthick95d044e2016-06-10 18:44:36 -07001769 self.send_igmp_leave_listening_group_specific_query(groups = groups1,
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001770 src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4', '5.5.5.5', '7.7.7.7'],
1771 iface = self.V_INF1, delay = 2)
1772 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
1773 assert target1 == 1, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001774 log.info('Interface is not receiving traffic from multicast groups %s' %groups1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001775 mcastTraffic1.stop()
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001776
1777 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+40)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001778 def test_igmp_exclude_to_block_src_list_and_check_for_group_source_specific_query(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001779 df = defer.Deferred()
1780 def igmp_exclude_to_block_src_list_check_for_group_source_specific_query():
1781 self.igmp_exclude_to_block_src_list_check_for_group_source_specific_query(df = df)
1782 df.callback(0)
1783 reactor.callLater(0, igmp_exclude_to_block_src_list_check_for_group_source_specific_query)
1784 return df
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001785
1786 def iptomac(self, mcast_ip):
1787 mcast_mac = '01:00:5e:'
1788 octets = mcast_ip.split('.')
1789 second_oct = int(octets[1]) & 127
1790 third_oct = int(octets[2])
1791 fourth_oct = int(octets[3])
1792 mcast_mac = mcast_mac + format(second_oct,'02x') + ':' + format(third_oct, '02x') + ':' + format(fourth_oct, '02x')
1793 return mcast_mac
1794
1795 def send_multicast_data_traffic(self, group, intf= 'veth2',source = '1.2.3.4'):
1796 dst_mac = self.iptomac(group)
1797 eth = Ether(dst= dst_mac)
1798 ip = IP(dst=group,src=source)
1799 data = repr(monotonic.monotonic())
1800 sendp(eth/ip/data,count=20, iface = intf)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001801
1802 def verify_igmp_data_traffic(self, group, intf='veth0', source='1.2.3.4' ):
1803 log.info('verifying multicast traffic for group %s from source %s'%(group,source))
1804 self.success = False
1805 def recv_task():
1806 def igmp_recv_cb(pkt):
1807 #log.info('received multicast data packet is %s'%pkt.show())
1808 log.info('multicast data received for group %s from source %s'%(group,source))
1809 self.success = True
1810 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')
1811 t = threading.Thread(target = recv_task)
1812 t.start()
1813 self.send_multicast_data_traffic(group,source=source)
1814 t.join()
1815 return self.success
1816
1817 def test_igmp_include_exclude_modes(self):
1818 groups = ['224.2.3.4','230.5.6.7']
1819 src_list = ['2.2.2.2','3.3.3.3']
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001820 self.onos_ssm_table_load(groups, src_list=src_list)
1821 self.send_igmp_join(groups = [groups[0]], src_list = src_list,record_type = IGMP_V3_GR_TYPE_INCLUDE,
1822 iface = self.V_INF1, delay = 2)
1823 self.send_igmp_join(groups = [groups[1]], src_list = src_list,record_type = IGMP_V3_GR_TYPE_EXCLUDE,
1824 iface = self.V_INF1, delay = 2)
1825 status = self.verify_igmp_data_traffic(groups[0],intf=self.V_INF1,source=src_list[0])
1826 assert_equal(status,True)
1827 status = self.verify_igmp_data_traffic(groups[1],intf = self.V_INF1,source= src_list[1])
1828 assert_equal(status,False)
1829
1830 def test_igmp_allow_new_source_mode(self):
1831 group = ['224.8.9.3']
1832 src_list = ['2.2.2.2','3.3.3.3']
1833 #dst_mac = self.iptomac(group[0])
1834 self.onos_ssm_table_load(group, src_list)
1835 self.send_igmp_join(groups = group, src_list = src_list[0],record_type = IGMP_V3_GR_TYPE_INCLUDE,
1836 iface = self.V_INF1, delay = 1)
1837 status = self.verify_igmp_data_traffic(group[0], intf=self.V_INF1,source = src_list[0])
1838 assert_equal(status,True) # expecting igmp data traffic from source src_list[0]
1839 self.send_igmp_join(groups = group, src_list = src_list[1],record_type = IGMP_V3_GR_TYPE_ALLOW_NEW,
1840 iface = self.V_INF1, delay = 1)
1841 for src in src_list:
1842 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1, source=src)
1843 assert_equal(status,True) # expecting igmp data traffic from both sources
1844
1845
1846 def test_igmp_include_to_exclude_mode_change(self):
1847 group = ['224.2.3.4']
1848 src_list = ['2.2.2.2','3.3.3.3']
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001849 self.onos_ssm_table_load(group, src_list)
1850 self.send_igmp_join(groups = group, src_list = src_list[0],record_type = IGMP_V3_GR_TYPE_INCLUDE,
1851 iface = self.V_INF1, delay = 1)
1852 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source= src_list[0])
1853 assert_equal(status,True) # expecting igmp data traffic from source src_list[0]
1854 self.send_igmp_join(groups = group, src_list = src_list[1],record_type = IGMP_V3_GR_TYPE_EXCLUDE,
1855 iface = self.V_INF1, delay = 1)
1856 for src in src_list:
1857 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source= src)
1858 assert_equal(status,False) # expecting igmp data traffic from both sources
1859
1860 def test_igmp_exclude_to_include_mode_change(self):
1861 group = ['224.2.3.4']
1862 src = ['2.2.2.2']
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001863 self.onos_ssm_table_load(group, src)
1864 self.send_igmp_join(groups = group, src_list = src,record_type = IGMP_V3_GR_TYPE_EXCLUDE,
1865 iface = self.V_INF1, delay = 1)
1866 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source=src[0])
1867 assert_equal(status,False) # not expecting igmp data traffic from source src_list[0]
1868 self.send_igmp_join(groups = group, src_list = src,record_type = IGMP_V3_GR_TYPE_INCLUDE,
1869 iface = self.V_INF1, delay = 1)
1870 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source = src[0])
1871 assert_equal(status,True) # expecting igmp data traffic from both sources
1872
1873 #this test case wotks properly if the snooping device(ONOS) have multicast router connected.
1874 def test_igmp_to_include_mode_with_null_source(self):
1875 groups = ['224.2.3.4','230.7.9.8']
1876 src = ['192.168.12.34']
1877 dst_mac = []
1878 dst_mac.append(self.iptomac(groups[0]))
1879 dst_mac.append(self.iptomac(groups[1]))
1880 self.onos_ssm_table_load(groups, src)
1881 self.send_igmp_join(groups = groups, src_list = src,record_type = IGMP_V3_GR_TYPE_INCLUDE,
1882 iface = self.V_INF1, delay = 1)
1883 for grp in groups:
1884 status = self.verify_igmp_data_traffic(grp,intf=self.V_INF1,source= src[0])
1885 assert_equal(status,True) # not expecting igmp data traffic from source src_list[0]
1886 #sending leave packet for group groups[1]
1887 self.send_igmp_join(groups = [groups[1]], src_list = [],record_type = IGMP_V3_GR_TYPE_CHANGE_TO_INCLUDE,
1888 iface = self.V_INF1, delay = 1)
1889 for grp in groups:
1890 status = self.verify_igmp_data_traffic(grp,intf=self.V_INF1,source= src[0])
1891 if grp is groups[0]:
1892 assert_equal(status,True) # expecting igmp data traffic to group groups[0]
1893 else:
1894 assert_equal(status,False) # not expecting igmp data traffic to group groups[1]
1895
1896 def test_igmp_to_include_mode(self):
1897 group = ['229.9.3.6']
1898 src_list = ['192.168.12.34','192.18.1.34']
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001899 self.onos_ssm_table_load(group, src_list)
1900 self.send_igmp_join(groups = group, src_list = [src_list[0]],record_type = IGMP_V3_GR_TYPE_INCLUDE,
1901 iface = self.V_INF1, delay = 1)
1902 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source=src_list[0])
1903 assert_equal(status,True) # not expecting igmp data traffic from source src_list[0]
1904 self.send_igmp_join(groups = group, src_list = src_list,record_type = IGMP_V3_GR_TYPE_CHANGE_TO_INCLUDE,
1905 iface = self.V_INF1, delay = 1)
1906 for src in src_list:
1907 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source= src)
1908 assert_equal(status,True) # expecting igmp data traffic to group groups[0]
1909
1910 #this test case passed only if mulitcast router connected to ONOS.
1911 def test_igmp_blocking_old_source_mode(self):
1912 group = ['224.2.3.4']
1913 src_list = ['2.2.2.2','3.3.3.3']
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001914 self.onos_ssm_table_load(group, src_list)
1915 self.send_igmp_join(groups = group, src_list = src_list,record_type = IGMP_V3_GR_TYPE_INCLUDE,
1916 iface = self.V_INF1, delay = 1)
1917 for src in src_list:
1918 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1, source=src)
1919 assert_equal(status,True) # expecting igmp data traffic from source src_list[0]
1920 self.send_igmp_join(groups = group, src_list = [src_list[1]],record_type = IGMP_V3_GR_TYPE_BLOCK_OLD,
1921 iface = self.V_INF1, delay = 1)
1922 for src in src_list:
1923 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1, source=src)
1924 if src is src_list[0]:
1925 assert_equal(status,True) # expecting igmp data traffic from source src_list[0]
1926 else:
1927 assert_equal(status,False) # not expecting igmp data traffic from source src_list[1]
1928
1929 def test_igmp_multiple_joins_and_data_verification_with_100_groups(self):
1930 groups = []
1931 sources = []
1932 count = 1
1933 mcastips = self.mcast_ip_range(start_ip = '226.0.0.1',end_ip = '226.0.5.254')
1934 sourceips = self.source_ip_range(start_ip = '10.10.0.1',end_ip = '10.10.5.254')
1935 while count<=100:
1936 group = random.choice(mcastips)
1937 source = random.choice(sourceips)
1938 if group in groups:
1939 pass
1940 else:
1941 log.info('group and source are %s and %s'%(group,source))
1942 groups.append(group)
1943 sources.append(source)
1944 count += 1
1945 self.onos_ssm_table_load(groups,src_list=sources,flag=True)
1946 for i in range(100):
1947 self.send_igmp_join(groups = [groups[i]], src_list = [sources[i]],record_type = IGMP_V3_GR_TYPE_INCLUDE,
1948 iface = self.V_INF1)
1949 status = self.verify_igmp_data_traffic(groups[i],intf=self.V_INF1,source=sources[i])
1950 assert_equal(status, True)
1951 log.info('data received for group %s from source %s'%(groups[i],sources[i]))
1952
1953 def test_igmp_multiple_joins_with_data_verification_and_leaving_100_groups(self):
1954 groups = []
1955 sources = []
1956 count = 1
1957 mcastips = self.mcast_ip_range(start_ip = '226.0.0.1',end_ip = '226.0.5.254')
1958 sourceips = self.source_ip_range(start_ip = '10.10.0.1',end_ip = '10.10.5.254')
1959 while count<=100:
1960 group = random.choice(mcastips)
1961 source = random.choice(sourceips)
1962 if group in groups:
1963 pass
1964 else:
1965 log.info('group and source are %s and %s'%(group,source))
1966 groups.append(group)
1967 sources.append(source)
1968 count += 1
1969 self.onos_ssm_table_load(groups,src_list=sources,flag=True)
1970 for i in range(100):
1971 self.send_igmp_join(groups = [groups[i]], src_list = [sources[i]],record_type = IGMP_V3_GR_TYPE_INCLUDE,
1972 iface = self.V_INF1)
1973 status = self.verify_igmp_data_traffic(groups[i],intf=self.V_INF1,source=sources[i])
1974 assert_equal(status, True)
1975 log.info('data received for group %s from source %s'%(groups[i],sources[i]))
1976 self.send_igmp_join(groups = [groups[i]], src_list = [sources[i]],record_type = IGMP_V3_GR_TYPE_CHANGE_TO_EXCLUDE,
1977 iface = self.V_INF1, delay = 1)
1978 status = self.verify_igmp_data_traffic(groups[i],intf=self.V_INF1,source=sources[i])
1979 assert_equal(status, False)
1980 log.info("data not received for group %s from source %s after changing group mode to 'TO-EXCLUDE' mode"%(groups[i],sources[i]))
1981
1982 def test_igmp_group_source_for_only_config_with_1000_entries(self):
1983 groups = []
1984 sources = []
1985 count = 1
1986 mcastips = self.mcast_ip_range(start_ip = '229.0.0.1',end_ip = '229.0.50.254')
1987 sourceips = self.source_ip_range(start_ip = '10.10.0.1',end_ip = '10.10.50.254')
1988 while count<=1000:
1989 group = random.choice(mcastips)
1990 source = random.choice(sourceips)
1991 if group in groups:
1992 pass
1993 else:
1994 log.info('group and source are %s and %s'%(group,source))
1995 groups.append(group)
1996 sources.append(source)
1997 count += 1
1998 self.onos_ssm_table_load(groups,src_list=sources,flag=True)
1999
2000 def test_igmp_from_exclude_to_include_mode_with_100_groups(self):
2001 groups = []
2002 sources = []
2003 count = 1
2004 mcastips = self.mcast_ip_range(start_ip = '229.0.0.1',end_ip = '229.0.10.254')
2005 sourceips = self.source_ip_range(start_ip = '10.10.0.1',end_ip = '10.10.10.254')
2006 while count<=100:
2007 group = random.choice(mcastips)
2008 source = random.choice(sourceips)
2009 if group in groups:
2010 pass
2011 else:
2012 log.info('group and source are %s and %s'%(group,source))
2013 groups.append(group)
2014 sources.append(source)
2015 count += 1
2016 self.onos_ssm_table_load(groups,src_list=sources,flag=True)
2017 for i in range(100):
2018 self.send_igmp_join(groups = [groups[i]], src_list = [sources[i]],record_type = IGMP_V3_GR_TYPE_EXCLUDE,
2019 iface = self.V_INF1)
2020 status = self.verify_igmp_data_traffic(groups[i],intf=self.V_INF1,source=sources[i])
2021 assert_equal(status, False)
2022 log.info('data not received for group %s from source %s as expected'%(groups[i],sources[i]))
2023 self.send_igmp_join(groups = [groups[i]], src_list = [sources[i]],record_type = IGMP_V3_GR_TYPE_INCLUDE,
2024 iface = self.V_INF1)
2025 status = self.verify_igmp_data_traffic(groups[i],intf=self.V_INF1,source=sources[i])
2026 assert_equal(status, True)
2027 log.info("data received for group %s from source %s after changing group mode to 'TO-INCLUDE' mode"%(groups[i],sources[i]))
2028
2029 def test_igmp_with_multiple_joins_and_data_verify_with_1000_groups(self):
2030 groups = []
2031 sources = []
2032 count = 1
2033 mcastips = self.mcast_ip_range(start_ip = '229.0.0.1',end_ip = '229.0.30.254')
2034 sourceips = self.source_ip_range(start_ip = '10.10.0.1',end_ip = '10.10.30.254')
2035 while count<=1000:
2036 group = random.choice(mcastips)
2037 source = random.choice(sourceips)
2038 if group in groups:
2039 pass
2040 else:
2041 log.info('group and source are %s and %s'%(group,source))
2042 groups.append(group)
2043 sources.append(source)
2044 count += 1
2045 self.onos_ssm_table_load(groups,src_list=sources,flag=True)
2046 for i in range(1000):
2047 self.send_igmp_join(groups = [groups[i]], src_list = [sources[i]],record_type = IGMP_V3_GR_TYPE_INCLUDE,
2048 iface = self.V_INF1)
2049 status = self.verify_igmp_data_traffic(groups[i],intf=self.V_INF1,source=sources[i])
2050 assert_equal(status, True)
2051 log.info('data received for group %s from source %s - %d'%(groups[i],sources[i],i))
2052
2053 def test_igmp_with_multiple_joins_and_data_verify_with_5000_groups(self):
2054 groups = []
2055 sources = []
2056 count = 1
2057 mcastips = self.mcast_ip_range(start_ip = '231.39.19.121',end_ip = '231.40.30.25')
2058 sourceips = self.source_ip_range(start_ip = '192.168.56.43',end_ip = '192.169.110.30')
2059 while count<=5000:
2060 group = random.choice(mcastips)
2061 source = random.choice(sourceips)
2062 if group in groups:
2063 pass
2064 else:
2065 log.info('group and source are %s and %s'%(group,source))
2066 groups.append(group)
2067 sources.append(source)
2068 count += 1
2069 self.onos_ssm_table_load(groups,src_list=sources,flag=True)
2070 for i in range(5000):
2071 self.send_igmp_join(groups = [groups[i]], src_list = [sources[i]],record_type = IGMP_V3_GR_TYPE_INCLUDE,
2072 iface = self.V_INF1)
2073 status = self.verify_igmp_data_traffic(groups[i],intf=self.V_INF1,source=sources[i])
2074 assert_equal(status, True)
2075 log.info('data received for group %s from source %s - %d'%(groups[i],sources[i],i))
2076
2077 """def test_igmp_join_from_multiple_infts(self):
2078 groups = ['229.9.3.6','234.20.56.2']
2079 src_list = ['192.168.12.34','192.18.1.34']
2080 self.onos_ssm_table_load(groups, src_list=src_list)
2081 self.send_igmp_join(groups = [groups[0]], src_list = src_list,record_type = IGMP_V3_GR_TYPE_INCLUDE,
2082 iface = 'veth0')
2083 self.send_igmp_join(groups = [groups[1]], src_list = src_list,record_type = IGMP_V3_GR_TYPE_INCLUDE,
2084 iface = 'veth2')
2085 status = self.verify_igmp_data_traffic(groups[0],intf='veth0',source=src_list[0])
2086 assert_equal(status,True)
2087 status = self.verify_igmp_data_traffic(groups[1],intf='veth2',source=src_list[1])
2088 assert_equal(status,True) # not expecting igmp data traffic from source src_list[0]
2089 """
2090
2091 def test_igmp_send_data_to_non_registered_group(self):
2092 group = ['224.2.3.4']
2093 src = ['2.2.2.2']
2094 self.onos_ssm_table_load(group,src_list= src)
2095 self.send_igmp_join(groups = ['239.0.0.1'], src_list = src,record_type = IGMP_V3_GR_TYPE_INCLUDE,
2096 iface = self.V_INF1, delay = 1)
2097 status = self.verify_igmp_data_traffic('239.0.0.1',intf=self.V_INF1,source=src[0])
2098 assert_equal(status,False) # not expecting igmp data traffic from source src_list[0]
2099
2100 def test_igmp_traffic_verification_for_registered_group_with_no_join_sent(self):
2101 group = ['227.12.3.40']
2102 src = ['190.4.19.67']
2103 self.onos_ssm_table_load(group,src_list= src)
2104 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source=src[0])
2105 assert_equal(status,False) # not expecting igmp data traffic from source src_list[0]
2106
2107 def test_igmp_toggling_app_activation(self):
2108 group = [self.random_mcast_ip()]
2109 src = [self.randomsourceip()]
2110 self.onos_ssm_table_load(group,src_list= src)
2111 self.send_igmp_join(groups = group, src_list = src,record_type = IGMP_V3_GR_TYPE_INCLUDE,
2112 iface = self.V_INF1)
2113 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source=src[0])
2114 assert_equal(status,True) # expecting igmp data traffic from source src_list[0]
2115 log.info('Multicast traffic received for group %s from source %s before the app is deactivated'%(group[0],src[0]))
2116 self.onos_ctrl.deactivate()
2117 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source=src[0])
2118 assert_equal(status,False) #not expecting igmp data traffic from source src_list[0]
2119 log.info('Multicast traffic not received for group %s from source %s after the app is deactivated'%(group[0],src[0]))
2120 self.onos_ctrl.activate()
2121 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source=src[0])
2122 assert_equal(status,True) # expecting igmp data traffic from source src_list[0]
2123 log.info('Multicast traffic received for group %s from source %s the app is re-activated'%(group[0],src[0]))
2124
2125 def test_igmp_with_mismatch_for_dst_ip_and_mac_in_data_packets(self):
2126 group = ['228.18.19.29']
2127 source = [self.randomsourceip()]
2128 self.onos_ssm_table_load(group,src_list= source)
2129 self.send_igmp_join(groups = group, src_list = source,record_type = IGMP_V3_GR_TYPE_INCLUDE,
2130 iface = self.V_INF1)
2131 dst_mac = '01:00:5e:0A:12:09'
2132 eth = Ether(dst= dst_mac)
2133 ip = IP(dst=group[0],src=source[0])
2134 data = repr(monotonic.monotonic())
2135 pkt = (eth/ip/data)
2136 log.info('Multicast traffic packet %s'%pkt.show())
2137 self.success = False
2138 def recv_task():
2139 def igmp_recv_cb(pkt):
2140 #log.info('received multicast data packet is %s'%pkt.show())
2141 log.info('multicast data received for group %s from source %s'%(group[0],source[0]))
2142 self.success = True
2143 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')
2144 t = threading.Thread(target = recv_task)
2145 t.start()
2146 sendp(eth/ip/data,count=20, iface = 'veth2')
2147 t.join()
2148 assert_equal(status,False) # not expecting igmp data traffic from source src_list[0]
2149
2150 #test case failing, ONOS registering unicast ip also as an igmp join
2151 def test_igmp_registering_invalid_group(self):
ChetanGaonkerb99538a2016-12-02 13:53:35 -08002152 groups = ['218.18.19.29']
ChetanGaonkera7e2b412016-09-01 23:19:07 -07002153 source = [self.randomsourceip()]
2154 ssm_dict = {'apps' : { 'org.onosproject.igmp' : { 'ssmTranslate' : [] } } }
2155 ssm_xlate_list = ssm_dict['apps']['org.onosproject.igmp']['ssmTranslate']
2156 for g in groups:
2157 for s in source:
2158 d = {}
2159 d['source'] = s or '0.0.0.0'
2160 d['group'] = g
2161 ssm_xlate_list.append(d)
2162 log.info('onos load config is %s'%ssm_dict)
2163 status, code = OnosCtrl.config(ssm_dict)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08002164 self.send_igmp_join(groups, src_list = source, record_type = IGMP_V3_GR_TYPE_INCLUDE,
2165 iface = self.V_INF1, delay = 1)
2166 status = self.verify_igmp_data_traffic(groups[0],intf=self.V_INF1, source=source[0])
2167 assert_equal(status,False) # not expecting igmp data traffic from source src_list[0]
ChetanGaonkera7e2b412016-09-01 23:19:07 -07002168
2169 def test_igmp_registering_invalid_source(self):
2170 groups = [self.random_mcast_ip()]
2171 sources = ['224.10.28.34','193.73.219.257']
2172 ssm_dict = {'apps' : { 'org.onosproject.igmp' : { 'ssmTranslate' : [] } } }
2173 ssm_xlate_list = ssm_dict['apps']['org.onosproject.igmp']['ssmTranslate']
2174 for g in groups:
2175 for s in sources:
2176 d = {}
2177 d['source'] = s or '0.0.0.0'
2178 d['group'] = g
2179 ssm_xlate_list.append(d)
2180 log.info('onos load config is %s'%ssm_dict)
2181 status, code = OnosCtrl.config(ssm_dict)
2182 assert_equal(status,False)
2183