blob: 19e10dca230a115592a3e225454b2693b0651f24 [file] [log] [blame]
A.R Karthick95d044e2016-06-10 18:44:36 -07001#
Chetan Gaonkercfcce782016-05-10 10:10:42 -07002# Copyright 2016-present Ciena Corporation
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
A.R Karthick95d044e2016-06-10 18:44:36 -07007#
Chetan Gaonkercfcce782016-05-10 10:10:42 -07008# http://www.apache.org/licenses/LICENSE-2.0
A.R Karthick95d044e2016-06-10 18:44:36 -07009#
Chetan Gaonkercfcce782016-05-10 10:10:42 -070010# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
Chetan Gaonker25470972016-02-26 08:52:15 -080016from nose.tools import *
17from nose.twistedtools import reactor, deferred
18from twisted.internet import defer
19from scapy.all import *
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -080020import time, monotonic
ChetanGaonkerb99538a2016-12-02 13:53:35 -080021import os
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -080022import random
23import threading
Chetan Gaonkere88c95c2016-03-02 05:21:47 -080024from IGMP import *
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -080025from McastTraffic import *
26from Stats import Stats
Chetan Gaonker4a25e2b2016-03-04 14:45:15 -080027from OnosCtrl import OnosCtrl
Chetan Gaonker441c9ac2016-05-06 10:30:13 -070028from OltConfig import OltConfig
Chetan Gaonker4eb12072016-03-28 15:04:15 -070029from Channels import IgmpChannel
A R Karthick9313b762016-11-07 13:14:35 -080030from CordLogger import CordLogger
A R Karthick861da962017-02-08 16:21:36 -080031from CordTestConfig import setup_module
32
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -080033log.setLevel('INFO')
Chetan Gaonker25470972016-02-26 08:52:15 -080034
35class IGMPTestState:
36
37 def __init__(self, groups = [], df = None, state = 0):
38 self.df = df
39 self.state = state
40 self.counter = 0
41 self.groups = groups
42 self.group_map = {} ##create a send/recv count map
43 for g in groups:
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -080044 self.group_map[g] = (Stats(), Stats())
A.R Karthick95d044e2016-06-10 18:44:36 -070045
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -080046 def update(self, group, tx = 0, rx = 0, t = 0):
47 self.counter += 1
Chetan Gaonker25470972016-02-26 08:52:15 -080048 index = 0 if rx == 0 else 1
49 v = tx if rx == 0 else rx
50 if self.group_map.has_key(group):
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -080051 self.group_map[group][index].update(packets = v, t = t)
Chetan Gaonker25470972016-02-26 08:52:15 -080052
53 def update_state(self):
54 self.state = self.state ^ 1
Chetan Gaonker25470972016-02-26 08:52:15 -080055
A R Karthick9313b762016-11-07 13:14:35 -080056class igmp_exchange(CordLogger):
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -080057
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -070058 V_INF1 = 'veth0'
59 V_INF2 = 'veth1'
60 MGROUP1 = '239.1.2.3'
61 MGROUP2 = '239.2.2.3'
Chetan Gaonker441c9ac2016-05-06 10:30:13 -070062 MINVALIDGROUP1 = '255.255.255.255'
63 MINVALIDGROUP2 = '239.255.255.255'
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -070064 MMACGROUP1 = "01:00:5e:01:02:03"
65 MMACGROUP2 = "01:00:5e:02:02:03"
ChetanGaonkera7e2b412016-09-01 23:19:07 -070066 IGMP_DST_MAC = "01:00:5e:00:00:16"
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -070067 IGMP_SRC_MAC = "5a:e1:ac:ec:4d:a1"
68 IP_SRC = '1.2.3.4'
ChetanGaonkera7e2b412016-09-01 23:19:07 -070069 IP_DST = '224.0.0.22'
Chetan Gaonker441c9ac2016-05-06 10:30:13 -070070 NEGATIVE_TRAFFIC_STATUS = 1
ChetanGaonkera7e2b412016-09-01 23:19:07 -070071 igmp_eth = Ether(dst = IGMP_DST_MAC, type = ETH_P_IP)
72 igmp_ip = IP(dst = IP_DST)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -080073 IGMP_TEST_TIMEOUT = 5
Chetan Gaonker441c9ac2016-05-06 10:30:13 -070074 IGMP_QUERY_TIMEOUT = 60
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -080075 MCAST_TRAFFIC_TIMEOUT = 10
Chetan Gaonker4eb12072016-03-28 15:04:15 -070076 PORT_TX_DEFAULT = 2
77 PORT_RX_DEFAULT = 1
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -080078 max_packets = 100
A.R Karthick95d044e2016-06-10 18:44:36 -070079 app = 'org.opencord.igmp'
Chetan Gaonker441c9ac2016-05-06 10:30:13 -070080 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 -070081 ROVER_TEST_TIMEOUT = 300 #3600*86
82 ROVER_TIMEOUT = (ROVER_TEST_TIMEOUT - 100)
83 ROVER_JOIN_TIMEOUT = 60
Chetan Gaonker4a25e2b2016-03-04 14:45:15 -080084
Chetan Gaonker441c9ac2016-05-06 10:30:13 -070085 @classmethod
86 def setUpClass(cls):
87 cls.olt = OltConfig(olt_conf_file = cls.olt_conf_file)
A R Karthick2b93d6a2016-09-06 15:19:09 -070088 cls.port_map, _ = cls.olt.olt_port_map()
A R Karthick0f6b6842016-12-06 17:17:44 -080089 OnosCtrl.cord_olt_config(cls.olt)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -070090
91 @classmethod
92 def tearDownClass(cls): pass
A.R Karthick95d044e2016-06-10 18:44:36 -070093
Chetan Gaonker4a25e2b2016-03-04 14:45:15 -080094 def setUp(self):
ChetanGaonkera7e2b412016-09-01 23:19:07 -070095 ''' Activate the igmp app'''
A R Karthick9313b762016-11-07 13:14:35 -080096 super(igmp_exchange, self).setUp()
Chetan Gaonker4a25e2b2016-03-04 14:45:15 -080097 self.onos_ctrl = OnosCtrl(self.app)
ChetanGaonkera7e2b412016-09-01 23:19:07 -070098 self.onos_ctrl.activate()
Chetan Gaonker4eb12072016-03-28 15:04:15 -070099 self.igmp_channel = IgmpChannel()
Chetan Gaonker4a25e2b2016-03-04 14:45:15 -0800100
A R Karthick9313b762016-11-07 13:14:35 -0800101 def tearDown(self):
102 super(igmp_exchange, self).tearDown()
Chetan Gaonker4a25e2b2016-03-04 14:45:15 -0800103
104 def onos_load_config(self, config):
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700105 log.info('onos load config is %s'%config)
Chetan Gaonkera2b87df2016-03-31 15:41:31 -0700106 status, code = OnosCtrl.config(config)
Chetan Gaonker4a25e2b2016-03-04 14:45:15 -0800107 if status is False:
108 log.info('JSON request returned status %d' %code)
109 assert_equal(status, True)
110 time.sleep(2)
A.R Karthick95d044e2016-06-10 18:44:36 -0700111
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700112 def onos_ssm_table_load(self, groups, src_list = ['1.2.3.4'],flag = False):
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800113 ssm_dict = {'apps' : { 'org.onosproject.igmp' : { 'ssmTranslate' : [] } } }
114 ssm_xlate_list = ssm_dict['apps']['org.onosproject.igmp']['ssmTranslate']
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700115 if flag: #to maintain seperate group-source pair.
116 for i in range(len(groups)):
117 d = {}
118 d['source'] = src_list[i] or '0.0.0.0'
119 d['group'] = groups[i]
120 ssm_xlate_list.append(d)
121 else:
122 for g in groups:
123 for s in src_list:
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800124 d = {}
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700125 d['source'] = s or '0.0.0.0'
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800126 d['group'] = g
127 ssm_xlate_list.append(d)
Chetan Gaonker4a25e2b2016-03-04 14:45:15 -0800128 self.onos_load_config(ssm_dict)
Chetan Gaonker4eb12072016-03-28 15:04:15 -0700129 cord_port_map = {}
130 for g in groups:
131 cord_port_map[g] = (self.PORT_TX_DEFAULT, self.PORT_RX_DEFAULT)
132 self.igmp_channel.cord_port_table_load(cord_port_map)
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800133 time.sleep(2)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800134
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700135 def mcast_ip_range(self,start_ip = '224.0.1.0', end_ip = '224.0.1.100'):
136 start = list(map(int, start_ip.split(".")))
137 end = list(map(int, end_ip.split(".")))
138 temp = start
139 ip_range = []
140 ip_range.append(start_ip)
141 while temp != end:
142 start[3] += 1
143 for i in (3, 2, 1):
144 if temp[i] == 255:
145 temp[i] = 0
146 temp[i-1] += 1
147 ip_range.append(".".join(map(str, temp)))
148 return ip_range
149
150 def random_mcast_ip(self,start_ip = '224.0.1.0', end_ip = '224.0.1.100'):
151 start = list(map(int, start_ip.split(".")))
152 end = list(map(int, end_ip.split(".")))
153 temp = start
154 ip_range = []
155 ip_range.append(start_ip)
156 while temp != end:
157 start[3] += 1
158 for i in (3, 2, 1):
159 if temp[i] == 255:
160 temp[i] = 0
161 temp[i-1] += 1
162 ip_range.append(".".join(map(str, temp)))
163 return random.choice(ip_range)
164
165 def source_ip_range(self,start_ip = '10.10.0.1', end_ip = '10.10.0.100'):
166 start = list(map(int, start_ip.split(".")))
167 end = list(map(int, end_ip.split(".")))
168 temp = start
169 ip_range = []
170 ip_range.append(start_ip)
171 while temp != end:
172 start[3] += 1
173 for i in (3, 2, 1):
174 if temp[i] == 255:
175 temp[i] = 0
176 temp[i-1] += 1
177 ip_range.append(".".join(map(str, temp)))
178 return ip_range
179
180 def randomsourceip(self,start_ip = '10.10.0.1', end_ip = '10.10.0.100'):
181 start = list(map(int, start_ip.split(".")))
182 end = list(map(int, end_ip.split(".")))
183 temp = start
184 ip_range = []
185 ip_range.append(start_ip)
186 while temp != end:
187 start[3] += 1
188 for i in (3, 2, 1):
189 if temp[i] == 255:
190 temp[i] = 0
191 temp[i-1] += 1
192 ip_range.append(".".join(map(str, temp)))
193 return random.choice(ip_range)
194
A R Karthick2b93d6a2016-09-06 15:19:09 -0700195 def get_igmp_intf(self):
196 inst = os.getenv('TEST_INSTANCE', None)
197 if not inst:
198 return 'veth0'
199 inst = int(inst) + 1
200 if inst >= self.port_map['uplink']:
201 inst += 1
202 if self.port_map.has_key(inst):
203 return self.port_map[inst]
204 return 'veth0'
205
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800206 def igmp_verify_join(self, igmpStateList):
207 sendState, recvState = igmpStateList
Chetan Gaonker25470972016-02-26 08:52:15 -0800208 ## check if the send is received for the groups
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800209 for g in sendState.groups:
A.R Karthick95d044e2016-06-10 18:44:36 -0700210 tx_stats = sendState.group_map[g][0]
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800211 tx = tx_stats.count
Chetan Gaonker25470972016-02-26 08:52:15 -0800212 assert_greater(tx, 0)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800213 rx_stats = recvState.group_map[g][1]
214 rx = rx_stats.count
215 assert_greater(rx, 0)
216 log.info('Receive stats %s for group %s' %(rx_stats, g))
A.R Karthick95d044e2016-06-10 18:44:36 -0700217
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800218 log.info('IGMP test verification success')
Chetan Gaonker25470972016-02-26 08:52:15 -0800219
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800220 def igmp_verify_leave(self, igmpStateList, leave_groups):
221 sendState, recvState = igmpStateList[0], igmpStateList[1]
222 ## check if the send is received for the groups
223 for g in sendState.groups:
224 tx_stats = sendState.group_map[g][0]
225 rx_stats = recvState.group_map[g][1]
226 tx = tx_stats.count
A.R Karthick95d044e2016-06-10 18:44:36 -0700227 rx = rx_stats.count
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800228 assert_greater(tx, 0)
229 if g not in leave_groups:
230 log.info('Received %d packets for group %s' %(rx, g))
231 for g in leave_groups:
232 rx = recvState.group_map[g][1].count
233 assert_equal(rx, 0)
A.R Karthick95d044e2016-06-10 18:44:36 -0700234
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800235 log.info('IGMP test verification success')
Chetan Gaonker25470972016-02-26 08:52:15 -0800236
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800237 def mcast_traffic_timer(self):
238 self.mcastTraffic.stopReceives()
239
240 def send_mcast_cb(self, send_state):
241 for g in send_state.groups:
242 send_state.update(g, tx = 1)
Chetan Gaonker25470972016-02-26 08:52:15 -0800243 return 0
244
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800245 ##Runs in the context of twisted reactor thread
Chetan Gaonker25470972016-02-26 08:52:15 -0800246 def igmp_recv(self, igmpState, iface = 'veth0'):
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800247 p = self.recv_socket.recv()
Chetan Gaonkerf1b9e322016-05-09 15:49:15 -0700248 try:
249 send_time = float(p.payload.load)
250 recv_time = monotonic.monotonic()
251 except:
252 log.info('Unexpected Payload received: %s' %p.payload.load)
253 return 0
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800254 #log.info( 'Recv in %.6f secs' %(recv_time - send_time))
255 igmpState.update(p.dst, rx = 1, t = recv_time - send_time)
Chetan Gaonker25470972016-02-26 08:52:15 -0800256 return 0
257
A R Karthick2b93d6a2016-09-06 15:19:09 -0700258 def send_igmp_join(self, groups, src_list = ['1.2.3.4'], record_type=IGMP_V3_GR_TYPE_INCLUDE,
259 ip_pkt = None, iface = 'veth0', ssm_load = False, delay = 1):
260 if ssm_load is True:
261 self.onos_ssm_table_load(groups, src_list)
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800262 igmp = IGMPv3(type = IGMP_TYPE_V3_MEMBERSHIP_REPORT, max_resp_code=30,
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700263 gaddr=self.IP_DST)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800264 for g in groups:
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700265 gr = IGMPv3gr(rtype= record_type, mcaddr=g)
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800266 gr.sources = src_list
267 igmp.grps.append(gr)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700268 if ip_pkt is None:
269 ip_pkt = self.igmp_eth/self.igmp_ip
270 pkt = ip_pkt/igmp
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800271 IGMPv3.fixup(pkt)
272 sendp(pkt, iface=iface)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800273 if delay != 0:
274 time.sleep(delay)
275
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700276 def send_igmp_join_recvQuery(self, groups, rec_queryCount = None, src_list = ['1.2.3.4'], ip_pkt = None, iface = 'veth0', delay = 2):
277 self.onos_ssm_table_load(groups, src_list)
278 igmp = IGMPv3(type = IGMP_TYPE_V3_MEMBERSHIP_REPORT, max_resp_code=30,
279 gaddr=self.IP_DST)
280 for g in groups:
Chetan Gaonker38737f82016-05-11 17:44:17 -0700281 gr = IGMPv3gr(rtype=IGMP_V3_GR_TYPE_INCLUDE, mcaddr=g)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700282 gr.sources = src_list
283 gr.sources = src_list
284 igmp.grps.append(gr)
285 if ip_pkt is None:
286 ip_pkt = self.igmp_eth/self.igmp_ip
287 pkt = ip_pkt/igmp
288 IGMPv3.fixup(pkt)
289 if rec_queryCount == None:
290 log.info('Sending IGMP join for group %s and waiting for one query packet and printing the packet' %groups)
291 resp = srp1(pkt, iface=iface)
292 else:
293 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 -0700294 resp = srp1(pkt, iface=iface)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700295# resp = srp1(pkt, iface=iface) if rec_queryCount else srp3(pkt, iface=iface)
296 resp[0].summary()
297 log.info('Sent IGMP join for group %s and received a query packet and printing packet' %groups)
298 if delay != 0:
299 time.sleep(delay)
300
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700301 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 -0700302 log.info('entering into igmp leave function')
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800303 igmp = IGMPv3(type = IGMP_TYPE_V3_MEMBERSHIP_REPORT, max_resp_code=30,
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700304 gaddr=self.IP_DST)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800305 for g in groups:
Chetan Gaonker38737f82016-05-11 17:44:17 -0700306 gr = IGMPv3gr(rtype=IGMP_V3_GR_TYPE_EXCLUDE, mcaddr=g)
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800307 gr.sources = src_list
308 igmp.grps.append(gr)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700309 if ip_pkt is None:
310 ip_pkt = self.igmp_eth/self.igmp_ip
311 pkt = ip_pkt/igmp
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800312 IGMPv3.fixup(pkt)
313 sendp(pkt, iface = iface)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800314 if delay != 0:
315 time.sleep(delay)
Chetan Gaonker25470972016-02-26 08:52:15 -0800316
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700317 def send_igmp_leave_listening_group_specific_query(self, groups, src_list = ['1.2.3.4'], ip_pkt = None, iface = 'veth0', delay = 2):
318 igmp = IGMPv3(type = IGMP_TYPE_V3_MEMBERSHIP_REPORT, max_resp_code=30,
319 gaddr=self.IP_DST)
320 for g in groups:
Chetan Gaonker38737f82016-05-11 17:44:17 -0700321 gr = IGMPv3gr(rtype=IGMP_V3_GR_TYPE_EXCLUDE, mcaddr=g)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700322 gr.sources = src_list
323 igmp.grps.append(gr)
324 if ip_pkt is None:
325 ip_pkt = self.igmp_eth/self.igmp_ip
326 pkt = ip_pkt/igmp
327 IGMPv3.fixup(pkt)
328 log.info('Sending IGMP leave for group %s and waiting for one group specific query packet and printing the packet' %groups)
329 resp = srp1(pkt, iface=iface)
330 resp[0].summary()
331 log.info('Sent IGMP leave for group %s and received a group specific query packet and printing packet' %groups)
332 if delay != 0:
333 time.sleep(delay)
334
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800335 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10)
336 def test_igmp_join_verify_traffic(self):
Chetan Gaonker25470972016-02-26 08:52:15 -0800337 groups = ['224.0.1.1', '225.0.0.1']
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700338 self.onos_ssm_table_load(groups)
Chetan Gaonker25470972016-02-26 08:52:15 -0800339 df = defer.Deferred()
340 igmpState = IGMPTestState(groups = groups, df = df)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800341 igmpStateRecv = IGMPTestState(groups = groups, df = df)
342 igmpStateList = (igmpState, igmpStateRecv)
343 mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb, arg = igmpState)
344 self.df = df
345 self.mcastTraffic = mcastTraffic
346 self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP)
347
348 def igmp_srp_task(stateList):
349 igmpSendState, igmpRecvState = stateList
350 if not mcastTraffic.isRecvStopped():
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800351 self.igmp_recv(igmpRecvState)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800352 reactor.callLater(0, igmp_srp_task, stateList)
353 else:
354 self.mcastTraffic.stop()
355 self.recv_socket.close()
356 self.igmp_verify_join(stateList)
357 self.df.callback(0)
358
359 self.send_igmp_join(groups)
360 mcastTraffic.start()
361 self.test_timer = reactor.callLater(self.MCAST_TRAFFIC_TIMEOUT, self.mcast_traffic_timer)
362 reactor.callLater(0, igmp_srp_task, igmpStateList)
Chetan Gaonker25470972016-02-26 08:52:15 -0800363 return df
364
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700365 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+40)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800366 def test_igmp_leave_verify_traffic(self):
367 groups = ['224.0.1.10', '225.0.0.10']
368 leave_groups = ['224.0.1.10']
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700369 self.onos_ssm_table_load(groups)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800370 df = defer.Deferred()
371 igmpState = IGMPTestState(groups = groups, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800372 IGMPTestState(groups = groups, df = df)
A.R Karthick95d044e2016-06-10 18:44:36 -0700373 mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb,
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800374 arg = igmpState)
375 self.df = df
376 self.mcastTraffic = mcastTraffic
377 self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP)
A.R Karthick95d044e2016-06-10 18:44:36 -0700378
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700379 mcastTraffic.start()
380 self.send_igmp_join(groups)
381 self.send_igmp_leave(leave_groups, delay = 3)
382 join_state = IGMPTestState(groups = leave_groups)
383 status = self.igmp_not_recv_task(self.V_INF1,leave_groups, join_state)
384 log.info('verified status for igmp recv task %s'%status)
385 assert status == 1 , 'EXPECTED RESULT'
386 self.df.callback(0)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800387 return df
388
389 @deferred(timeout=100)
390 def test_igmp_leave_join_loop(self):
391 self.groups = ['226.0.1.1', '227.0.0.1', '228.0.0.1', '229.0.0.1', '230.0.0.1' ]
392 self.src_list = ['3.4.5.6', '7.8.9.10']
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700393 self.onos_ssm_table_load(self.groups,src_list=self.src_list)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800394 df = defer.Deferred()
395 self.df = df
396 self.iterations = 0
397 self.num_groups = len(self.groups)
398 self.MAX_TEST_ITERATIONS = 10
399
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800400 def igmp_srp_task(v):
401 if self.iterations < self.MAX_TEST_ITERATIONS:
402 if v == 1:
403 ##join test
404 self.num_groups = random.randint(0, len(self.groups))
405 self.send_igmp_join(self.groups[:self.num_groups],
406 src_list = self.src_list,
407 iface = 'veth0', delay = 0)
408 else:
409 self.send_igmp_leave(self.groups[:self.num_groups],
410 src_list = self.src_list,
411 iface = 'veth0', delay = 0)
412 self.iterations += 1
413 v ^= 1
414 reactor.callLater(1.0 + 0.5*self.num_groups,
415 igmp_srp_task, v)
416 else:
417 self.df.callback(0)
418
419 reactor.callLater(0, igmp_srp_task, 1)
420 return df
421
422 def igmp_join_task(self, intf, groups, state, src_list = ['1.2.3.4']):
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700423 #self.onos_ssm_table_load(groups, src_list)
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800424 igmp = IGMPv3(type = IGMP_TYPE_V3_MEMBERSHIP_REPORT, max_resp_code=30,
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700425 gaddr=self.IP_DST)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800426 for g in groups:
Chetan Gaonker38737f82016-05-11 17:44:17 -0700427 gr = IGMPv3gr(rtype = IGMP_V3_GR_TYPE_INCLUDE, mcaddr = g)
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800428 gr.sources = src_list
429 igmp.grps.append(gr)
430
431 for g in groups:
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800432 state.group_map[g][0].update(1, t = monotonic.monotonic())
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800433
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700434 pkt = self.igmp_eth/self.igmp_ip/igmp
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800435 IGMPv3.fixup(pkt)
436 sendp(pkt, iface=intf)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800437 log.debug('Returning from join task')
438
439 def igmp_recv_task(self, intf, groups, join_state):
440 recv_socket = L3PacketSocket(iface = intf, type = ETH_P_IP)
441 group_map = {}
442 for g in groups:
443 group_map[g] = [0,0]
444
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700445 log.info('Verifying join interface should receive multicast data')
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800446 while True:
447 p = recv_socket.recv()
448 if p.dst in groups and group_map[p.dst][0] == 0:
449 group_map[p.dst][0] += 1
450 group_map[p.dst][1] = monotonic.monotonic()
451 c = 0
452 for g in groups:
453 c += group_map[g][0]
454 if c == len(groups):
455 break
456 for g in groups:
457 join_start = join_state.group_map[g][0].start
458 recv_time = group_map[g][1] * 1000000
459 delta = (recv_time - join_start)
460 log.info('Join for group %s received in %.3f usecs' %
461 (g, delta))
462
463 recv_socket.close()
464 log.debug('Returning from recv task')
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700465
466 def igmp_not_recv_task(self, intf, groups, join_state):
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800467 log.info('Entering igmp not recv task loop')
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700468 recv_socket = L2Socket(iface = intf, type = ETH_P_IP)
469 group_map = {}
470 for g in groups:
471 group_map[g] = [0,0]
472
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800473 log.info('Verifying join interface, should not receive any multicast data')
Chetan Gaonker7791bda2016-05-12 17:36:52 -0700474 self.NEGATIVE_TRAFFIC_STATUS = 1
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700475 def igmp_recv_cb(pkt):
476 log.info('Multicast packet %s received for left groups %s' %(pkt[IP].dst, groups))
Chetan Gaonker7791bda2016-05-12 17:36:52 -0700477 self.NEGATIVE_TRAFFIC_STATUS = 2
Chetan Gaonker38737f82016-05-11 17:44:17 -0700478 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 -0700479 timeout = 3, opened_socket = recv_socket)
480 recv_socket.close()
A.R Karthick95d044e2016-06-10 18:44:36 -0700481 return self.NEGATIVE_TRAFFIC_STATUS
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700482
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800483 def group_latency_check(self, groups):
484 tasks = []
485 self.send_igmp_leave(groups = groups)
486 join_state = IGMPTestState(groups = groups)
487 tasks.append(threading.Thread(target=self.igmp_join_task, args = ('veth0', groups, join_state,)))
488 traffic_state = IGMPTestState(groups = groups)
A.R Karthick95d044e2016-06-10 18:44:36 -0700489 mcast_traffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb,
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800490 arg = traffic_state)
491 mcast_traffic.start()
492 tasks.append(threading.Thread(target=self.igmp_recv_task, args = ('veth0', groups, join_state)))
493 for t in tasks:
494 t.start()
495 for t in tasks:
496 t.join()
497
498 mcast_traffic.stop()
499 self.send_igmp_leave(groups = groups)
500 return
501
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700502 @deferred(timeout=IGMP_QUERY_TIMEOUT + 10)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800503 def test_igmp_1group_join_latency(self):
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700504 groups = ['239.0.1.1']
505 df = defer.Deferred()
506 def igmp_1group_join_latency():
507 self.group_latency_check(groups)
508 df.callback(0)
509 reactor.callLater(0, igmp_1group_join_latency)
510 return df
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800511
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700512 @deferred(timeout=IGMP_QUERY_TIMEOUT + 10)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800513 def test_igmp_2group_join_latency(self):
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700514 groups = ['239.0.1.1', '240.0.1.1']
515 df = defer.Deferred()
516 def igmp_2group_join_latency():
517 self.group_latency_check(groups)
518 df.callback(0)
519 reactor.callLater(0, igmp_2group_join_latency)
520 return df
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800521
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700522 @deferred(timeout=IGMP_QUERY_TIMEOUT + 10)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800523 def test_igmp_Ngroup_join_latency(self):
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700524 groups = ['239.0.1.1', '240.0.1.1', '241.0.1.1', '242.0.1.1']
525 df = defer.Deferred()
526 def igmp_Ngroup_join_latency():
527 self.group_latency_check(groups)
528 df.callback(0)
529 reactor.callLater(0, igmp_Ngroup_join_latency)
530 return df
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800531
A R Karthick2b93d6a2016-09-06 15:19:09 -0700532 def test_igmp_join_rover_all(self):
Chetan Gaonker1f7c3f82016-03-08 12:17:37 -0800533 s = (224 << 24) | 1
534 #e = (225 << 24) | (255 << 16) | (255 << 16) | 255
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700535 e = (224 << 24) | 10
Chetan Gaonker1f7c3f82016-03-08 12:17:37 -0800536 for i in xrange(s, e+1):
537 if i&0xff:
538 ip = '%d.%d.%d.%d'%((i>>24)&0xff, (i>>16)&0xff, (i>>8)&0xff, i&0xff)
539 self.send_igmp_join([ip], delay = 0)
540
A R Karthick2b93d6a2016-09-06 15:19:09 -0700541 @deferred(timeout=ROVER_TEST_TIMEOUT)
542 def test_igmp_join_rover(self):
543 df = defer.Deferred()
544 iface = self.get_igmp_intf()
545 self.df = df
546 self.count = 0
547 self.timeout = 0
548 self.complete = False
549 def igmp_join_timer():
550 self.timeout += self.ROVER_JOIN_TIMEOUT
551 log.info('IGMP joins sent: %d' %self.count)
A R Karthick2b93d6a2016-09-06 15:19:09 -0700552 if self.timeout >= self.ROVER_TIMEOUT:
553 self.complete = True
554 reactor.callLater(self.ROVER_JOIN_TIMEOUT, igmp_join_timer)
555
556 reactor.callLater(self.ROVER_JOIN_TIMEOUT, igmp_join_timer)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800557 self.start_channel = (224 << 24) | 1
558 self.end_channel = (224 << 24) | 200 #(225 << 24) | (255 << 16) | (255 << 16) | 255
A R Karthick2b93d6a2016-09-06 15:19:09 -0700559 self.current_channel = self.start_channel
560 def igmp_join_rover(self):
561 #e = (224 << 24) | 10
562 chan = self.current_channel
563 self.current_channel += 1
564 if self.current_channel >= self.end_channel:
565 chan = self.current_channel = self.start_channel
566 if chan&0xff:
567 ip = '%d.%d.%d.%d'%((chan>>24)&0xff, (chan>>16)&0xff, (chan>>8)&0xff, chan&0xff)
568 self.send_igmp_join([ip], delay = 0, ssm_load = False, iface = iface)
569 self.count += 1
570 if self.complete == True:
571 log.info('%d IGMP joins sent in %d seconds over %s' %(self.count, self.timeout, iface))
572 self.df.callback(0)
573 else:
574 reactor.callLater(0, igmp_join_rover, self)
575 reactor.callLater(0, igmp_join_rover, self)
576 return df
577
Chetan Gaonker1f7c3f82016-03-08 12:17:37 -0800578 @deferred(timeout=IGMP_QUERY_TIMEOUT + 10)
579 def test_igmp_query(self):
580 groups = ['224.0.0.1'] ##igmp query group
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700581 self.onos_ssm_table_load(groups)
Chetan Gaonker1f7c3f82016-03-08 12:17:37 -0800582 df = defer.Deferred()
583 self.df = df
584 self.recv_socket = L2Socket(iface = 'veth0', type = ETH_P_IP)
A.R Karthick95d044e2016-06-10 18:44:36 -0700585
Chetan Gaonker1f7c3f82016-03-08 12:17:37 -0800586 def igmp_query_timeout():
Chetan Gaonker1f7c3f82016-03-08 12:17:37 -0800587 def igmp_query_cb(pkt):
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700588 log.info('received igmp query packet is %s'%pkt.show())
Chetan Gaonkerbd4390f2016-03-09 18:56:52 -0800589 log.info('Got IGMP query packet from %s for %s' %(pkt[IP].src, pkt[IP].dst))
590 assert_equal(pkt[IP].dst, '224.0.0.1')
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700591 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 -0800592 opened_socket = self.recv_socket)
Chetan Gaonker1f7c3f82016-03-08 12:17:37 -0800593 self.recv_socket.close()
594 self.df.callback(0)
595
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700596 #self.send_igmp_join(groups)
Chetan Gaonker1f7c3f82016-03-08 12:17:37 -0800597 self.test_timer = reactor.callLater(self.IGMP_QUERY_TIMEOUT, igmp_query_timeout)
598 return df
599
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700600 def igmp_send_joins_different_groups_srclist(self, groups, sources, intf = V_INF1, delay = 2, ip_src = None):
601 g1 = groups[0]
602 g2 = groups[1]
603 sourcelist1 = sources[0]
604 sourcelist2 = sources[1]
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700605 eth = Ether(dst = self.IGMP_DST_MAC,type = ETH_P_IP)
606 ip = IP(dst = self.IP_DST)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700607 log.info('Sending join message for the group %s' %g1)
608 self.send_igmp_join((g1,), src_list = sourcelist1, ip_pkt = eth/ip, iface = intf, delay = 2)
609 eth = Ether(dst = self.MMACGROUP2, src = self.IGMP_SRC_MAC, type = ETH_P_IP)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700610 ip = IP(dst = g2)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700611 log.info('Sending join message for group %s' %g2)
612 self.send_igmp_join((g2,), src_list = sourcelist2, ip_pkt = eth/ip, iface = intf, delay = 2)
Chetan Gaonker7791bda2016-05-12 17:36:52 -0700613 log.info('Done with igmp_send_joins_different_groups_srclist')
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700614
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700615 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):
616 g1 = groups[0]
617 g2 = groups[1]
618 sourcelist1 = sources[0]
619 sourcelist2 = sources[1]
620 eth = Ether(dst = self.MMACGROUP1, src = self.IGMP_SRC_MAC, type = ETH_P_IP)
621 src_ip = ip_src or self.IP_SRC
622 ip = IP(dst = g1, src = src_ip)
623 if query_group1 is 'group1':
624 log.info('Sending join message for the group %s and waiting for a query packet on join interface' %g1)
625 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 -0700626 else:
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700627 log.info('Sending join message for the group %s' %g1)
628 self.send_igmp_join((g1,), src_list = sourcelist1, ip_pkt = eth/ip, iface = intf, delay = 2)
629 eth = Ether(dst = self.MMACGROUP2, src = self.IGMP_SRC_MAC, type = ETH_P_IP)
630 ip = IP(dst = g2, src = src_ip)
631 if query_group2 is 'group2':
632 log.info('Sending join message for the group %s and waiting for a query packet on join interface' %g2)
633 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 -0700634 else:
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700635 log.info('Sending join message for group %s' %g2)
636 self.send_igmp_join((g2,), src_list = sourcelist2, ip_pkt = eth/ip, iface = intf, delay = 2)
637
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700638 def igmp_joins_leave(self,groups,src_list,again_join = False, df = None):
639 groups1 = [groups[0]]
640 groups2 = [groups[1]]
641 src1 = [src_list[0]]
642 src2 = [src_list[1]]
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700643 self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700644 (src1, src2), intf = self.V_INF1, delay = 2)
645
646 src_ip = src1[0]
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700647 if df is None:
648 df = defer.Deferred()
649 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800650 IGMPTestState(groups = groups1, df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700651
652 igmpState2 = IGMPTestState(groups = groups2, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800653 IGMPTestState(groups = groups2, df = df)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700654 dst_mac = self.iptomac(groups1[0])
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700655 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
656 src_ip = src_ip, cb = self.send_mcast_cb,
657 arg = igmpState1)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700658 src_ip = src2[0]
659 dst_mac = self.iptomac(groups1[0])
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700660 mcastTraffic2 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
661 src_ip = src_ip, cb = self.send_mcast_cb,
662 arg = igmpState2)
663 mcastTraffic1.start()
664 mcastTraffic2.start()
665 join_state1 = IGMPTestState(groups = groups1)
666 join_state2 = IGMPTestState(groups = groups2)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800667 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700668 log.info('Interface is receiving multicast groups %s' %groups1)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800669 self.igmp_recv_task(self.V_INF1, groups2, join_state2)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700670 log.info('Interface is receiving multicast groups %s' %groups2)
671 log.info('Interface is sending leave message for groups %s now' %groups2)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700672 self.send_igmp_leave(groups = groups2, src_list = src2, iface = self.V_INF1, delay = 2)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800673 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700674 target4 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state2)
675 assert target4 == 1, 'EXPECTED FAILURE'
676 if again_join:
677 dst_mac = '01:00:5e:02:02:03'
678 ip_dst = '239.2.2.3'
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700679 eth = Ether(dst = dst_mac, type = ETH_P_IP)
680 ip = IP(dst = ip_dst)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700681 log.info('Interface sending join message again for the groups %s' %groups2)
682 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 -0800683 self.igmp_recv_task(self.V_INF1, groups2, join_state2)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700684 log.info('Interface is receiving multicast groups %s again' %groups2)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800685 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700686 log.info('Interface is still receiving from multicast groups %s' %groups1)
687 else:
688 log.info('Ended test case')
689 mcastTraffic1.stop()
690 mcastTraffic2.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -0700691
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700692
693 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700694 def test_igmp_2joins_1leave(self):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700695 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700696 def igmp_2joins_1leave():
697 groups = ['234.2.3.4','236.8.7.9']
698 src_list = ['2.3.4.5','5.4.3.2']
699 self.onos_ssm_table_load(groups,src_list = src_list)
700 self.igmp_joins_leave(groups,src_list,again_join = False, df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700701 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700702 reactor.callLater(0, igmp_2joins_1leave)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700703 return df
704
705 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+25)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700706 def test_igmp_2joins_1leave_and_join_again(self):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700707 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700708 def igmp_2joins_1leave_join_again():
709 groups = ['234.2.3.4','236.8.7.9']
710 src_list = ['2.3.4.5','5.4.3.2']
711 self.onos_ssm_table_load(groups,src_list = src_list)
712 self.igmp_joins_leave(groups,src_list,again_join = True, df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700713 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700714 reactor.callLater(0, igmp_2joins_1leave_join_again)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700715 return df
716
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700717 def igmp_not_in_src_list(self, df = None):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700718 groups1 = (self.MGROUP1,)
719 groups2 = (self.MGROUP2,)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700720 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 -0700721 self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
722 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
723 intf = self.V_INF1, delay = 2)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700724 src_ip = '6.6.6.6'
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700725 dst_mac = self.iptomac(groups1[0])
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700726 if df is None:
727 df = defer.Deferred()
728 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800729 IGMPTestState(groups = groups1, df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700730 mcastTraffic1 = McastTraffic(groups1, iface = 'veth2', dst_mac = dst_mac,
731 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
732 mcastTraffic1.start()
733 join_state1 = IGMPTestState(groups = groups1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700734 log.info('Interface should not receive from multicast groups %s from an interface, which is expected' %groups1)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700735 target1 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
Chetan Gaonker7791bda2016-05-12 17:36:52 -0700736 assert target1 == 2, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700737 log.info('Interface is not receiving traffic from multicast groups %s, working as expected' %groups1)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700738 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -0700739
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700740 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700741 def test_igmp_not_in_src_list(self):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700742 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700743 def igmp_not_in_src_list():
744 self.igmp_not_in_src_list(df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700745 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700746 reactor.callLater(0, igmp_not_in_src_list)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700747 return df
748
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700749 def igmp_change_to_exclude_src_list(self, df = None):
750 groups1 = [self.random_mcast_ip()]
751 groups2 = [self.random_mcast_ip()]
752 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 -0700753 self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
754 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
755 intf = self.V_INF1, delay = 2)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700756 src_ip = '2.2.2.2'
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700757 dst_mac=self.iptomac(groups1[0])
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700758 if df is None:
759 df = defer.Deferred()
760 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800761 IGMPTestState(groups = groups1, df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700762 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
763 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
764 mcastTraffic1.start()
765 join_state1 = IGMPTestState(groups = groups1)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800766 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700767 self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2'], iface = self.V_INF1, delay =2)
768 target2 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
Chetan Gaonker7791bda2016-05-12 17:36:52 -0700769 assert target2 == 2, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700770 log.info('Interface is not receiving traffic from multicast groups %s after sending CHANGE_TO_EXCLUDE' %groups1)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700771 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -0700772
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700773 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700774 def test_igmp_change_to_exclude_src_list(self):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700775 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700776 def igmp_change_to_exclude_src_list():
777 self.igmp_change_to_exclude_src_list(df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700778 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700779 reactor.callLater(0, igmp_change_to_exclude_src_list)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700780 return df
781
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700782 def igmp_include_to_allow_src_list(self, df = None):
783 groups1 = [self.random_mcast_ip()] #(self.MGROUP1,)
784 self.onos_ssm_table_load(groups1,src_list = ['4.4.4.4','6.6.6.6'])
785 self.send_igmp_join(groups = groups1, src_list = ['4.4.4.4'],record_type = IGMP_V3_GR_TYPE_INCLUDE,
786 iface = self.V_INF1)
787 src_ip = '4.4.4.4'
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700788 if df is None:
789 df = defer.Deferred()
790 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800791 IGMPTestState(groups = groups1, df = df)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700792 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2',src_ip = src_ip,
793 cb = self.send_mcast_cb, arg = igmpState1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700794 mcastTraffic1.start()
795 join_state1 = IGMPTestState(groups = groups1)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800796 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700797 mcastTraffic1.stop()
798 mcastTraffic2 = McastTraffic(groups1, iface= 'veth2',src_ip = '6.6.6.6',
799 cb = self.send_mcast_cb, arg = igmpState1)
800 self.send_igmp_join(groups = groups1, src_list = ['6.6.6.6'],record_type = IGMP_V3_GR_TYPE_ALLOW_NEW,
801 iface = self.V_INF1)
802 mcastTraffic2.start()
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800803 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700804 mcastTraffic2.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -0700805
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700806 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+30)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700807 def test_igmp_include_to_allow_src_list(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700808 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700809 def igmp_include_to_allow_src_list():
810 self.igmp_include_to_allow_src_list(df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700811 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700812 reactor.callLater(0, igmp_include_to_allow_src_list)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700813 return df
814
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700815 def igmp_include_to_block_src_list(self, df = None):
816 groups1 = [self.random_mcast_ip()] #groups1 = (self.MGROUP1,)
817 self.onos_ssm_table_load(groups1,src_list = ['4.4.4.4','6.6.6.6'])
818 self.send_igmp_join(groups = groups1, src_list = ['4.4.4.4','6.6.6.6'],record_type = IGMP_V3_GR_TYPE_INCLUDE,
819 iface = self.V_INF1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700820 if df is None:
821 df = defer.Deferred()
822 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800823 IGMPTestState(groups = groups1, df = df)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700824 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2',src_ip = '6.6.6.6',
825 cb = self.send_mcast_cb, arg = igmpState1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700826 mcastTraffic1.start()
827 join_state1 = IGMPTestState(groups = groups1)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800828 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700829 mcastTraffic1.stop()
830 self.send_igmp_join(groups = groups1, src_list = ['6.6.6.6'],record_type = IGMP_V3_GR_TYPE_BLOCK_OLD,
831 iface = self.V_INF1)
832 mcastTraffic2 = McastTraffic(groups1, iface= 'veth2',src_ip = '6.6.6.6',
833 cb = self.send_mcast_cb, arg = igmpState1)
834 mcastTraffic2.start()
835 target1 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
836 assert target1 == 1, 'EXPECTED FAILURE'
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800837 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 -0700838 mcastTraffic2.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -0700839
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700840 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+30)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700841 def test_igmp_include_to_block_src_list(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700842 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700843 def igmp_include_to_block_src_list():
844 self.igmp_include_to_block_src_list(df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700845 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700846 reactor.callLater(0, igmp_include_to_block_src_list)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700847 return df
848
849
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700850 def igmp_change_to_include_src_list(self, df = None):
851 groups1 = [self.random_mcast_ip()]
852 src_list = ['4.4.4.4','6.6.6.6']
853 self.onos_ssm_table_load(groups1,src_list = src_list)
854 self.send_igmp_leave(groups = groups1, src_list = src_list,
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700855 iface = self.V_INF1, delay = 2)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700856 if df is None:
857 df = defer.Deferred()
858 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800859 IGMPTestState(groups = groups1, df = df)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700860 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2',src_ip = src_list[0],
861 cb = self.send_mcast_cb, arg = igmpState1)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700862 mcastTraffic1.start()
863 join_state1 = IGMPTestState(groups = groups1)
864 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
865 assert target1 == 1, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700866 log.info('Interface is not receiving traffic from multicast groups %s' %groups1)
867 mcastTraffic1.stop()
868 self.send_igmp_join(groups = groups1, src_list = src_list,record_type = IGMP_V3_GR_TYPE_INCLUDE,
869 iface = self.V_INF1)
870 mcastTraffic2 = McastTraffic(groups1, iface= 'veth2',src_ip = src_list[1],
871 cb = self.send_mcast_cb, arg = igmpState1)
872 mcastTraffic2.start()
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800873 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700874 mcastTraffic2.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -0700875
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700876 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700877 def test_igmp_change_to_include_src_list(self):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700878 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700879 def igmp_change_to_include_src_list():
880 self.igmp_change_to_include_src_list(df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700881 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700882 reactor.callLater(0, igmp_change_to_include_src_list)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700883 return df
884
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700885 #this test case failing because group in include receiving multicast traffic from any of the source
886 def igmp_exclude_to_allow_src_list(self, df = None):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700887 groups1 = (self.MGROUP1,)
888 groups2 = (self.MGROUP2,)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700889 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 -0700890 self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4'],
891 iface = self.V_INF1, delay = 2)
A.R Karthick95d044e2016-06-10 18:44:36 -0700892
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700893 dst_mac = '01:00:5e:01:02:03'
894 src_ip = '2.2.2.2'
895 if df is None:
896 df = defer.Deferred()
897 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800898 IGMPTestState(groups = groups1, df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700899 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
900 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
901 mcastTraffic1.start()
902 join_state1 = IGMPTestState(groups = groups1)
903 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
904 assert target1 == 1, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700905 log.info('Interface is not receiving traffic from multicast groups %s' %groups1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700906 self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
907 (['6.6.6.6', '7.7.7.7', '8.8.8.8'], ['6.6.6.6', '5.5.5.5']),
908 intf = self.V_INF1, delay = 2)
909 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
910 assert target1 == 1, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700911 log.info('Interface is not receiving traffic from multicast groups %s' %groups1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700912 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -0700913
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700914 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700915 def test_igmp_exclude_to_allow_src_list(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700916 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700917 def igmp_exclude_to_allow_src_list():
918 self.igmp_exclude_to_allow_src_list(df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700919 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700920 reactor.callLater(0, igmp_exclude_to_allow_src_list)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700921 return df
922
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700923 def igmp_exclude_to_block_src_list(self, df = None):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700924 groups1 = (self.MGROUP1,)
925 groups2 = (self.MGROUP2,)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700926 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 -0700927 self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4'],
928 iface = self.V_INF1, delay = 2)
A.R Karthick95d044e2016-06-10 18:44:36 -0700929
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700930 dst_mac = '01:00:5e:01:02:03'
931 src_ip = '2.2.2.2'
932 if df is None:
933 df = defer.Deferred()
934 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800935 IGMPTestState(groups = groups1, df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700936 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
937 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
938 mcastTraffic1.start()
939 join_state1 = IGMPTestState(groups = groups1)
940 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
941 assert target1 == 1, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700942 log.info('Interface is not receiving traffic from multicast groups %s' %groups1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700943 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'],
944 iface = self.V_INF1, delay = 2)
945 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
946 assert target1 == 1, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700947 log.info('Interface is not receiving traffic from multicast groups %s' %groups1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700948 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -0700949
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700950 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700951 def test_igmp_exclude_to_block_src_list(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700952 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700953 def igmp_exclude_to_block_src_list():
954 self.igmp_exclude_to_block_src_list(df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700955 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700956 reactor.callLater(0, igmp_exclude_to_block_src_list)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700957 return df
958
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700959 #this test case failing because group in include mode recieves traffic from other sources also.
960 def igmp_new_src_list(self, df = None):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700961 groups1 = (self.MGROUP1,)
962 groups2 = (self.MGROUP2,)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700963 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 -0700964 self.igmp_send_joins_different_groups_srclist(groups1+groups2,
965 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
966 intf = self.V_INF1, delay = 2)
967 dst_mac = '01:00:5e:01:02:03'
968 src_ip = '6.6.6.6'
969 if df is None:
970 df = defer.Deferred()
971 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800972 IGMPTestState(groups = groups1, df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700973 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
974 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
975 mcastTraffic1.start()
976 join_state1 = IGMPTestState(groups = groups1)
977 target1 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
978 assert target1 == 1, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700979 log.info('Interface is not receiving traffic from multicast groups %s' %groups1)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700980 self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700981 (['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 -0700982 intf = self.V_INF1, delay = 2)
ChetanGaonkerb99538a2016-12-02 13:53:35 -0800983 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700984 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 -0700985 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -0700986
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700987 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700988 def test_igmp_new_src_list(self):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700989 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700990 def igmp_new_src_list():
991 self.igmp_new_src_list(df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700992 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700993 reactor.callLater(0, igmp_new_src_list)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700994 return df
995
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700996 def igmp_block_old_src_list(self, df = None):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700997 groups1 = (self.MGROUP1,)
998 groups2 = (self.MGROUP2,)
999 groups = groups1 + groups2
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001000 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 -07001001 self.igmp_send_joins_different_groups_srclist(groups,
1002 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
1003 intf = self.V_INF1, delay = 2)
1004 dst_mac = '01:00:5e:02:02:03'
1005 src_ip = '5.5.5.5'
1006 if df is None:
1007 df = defer.Deferred()
1008 igmpState1 = IGMPTestState(groups = groups2, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001009 IGMPTestState(groups = groups2, df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001010 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1011 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1012 mcastTraffic1.start()
1013 join_state1 = IGMPTestState(groups = groups2)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001014 self.igmp_recv_task(self.V_INF1, groups2, join_state1)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001015 log.info('Interface is receiving traffic from multicast groups %s' %groups2)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001016 self.igmp_send_joins_different_groups_srclist(groups,
1017 (['6.6.6.6', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '7.7.7.7']),
1018 intf = self.V_INF1, delay = 2)
1019 target2 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1)
Chetan Gaonker7791bda2016-05-12 17:36:52 -07001020 assert target2 == 2, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001021 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 -07001022 mcastTraffic1.stop()
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001023
1024 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001025 def test_igmp_block_old_src_list(self):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001026 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001027 def igmp_block_old_src_list():
1028 self.igmp_block_old_src_list(df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001029 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001030 reactor.callLater(0, igmp_block_old_src_list)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001031 return df
1032
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001033 def igmp_include_empty_src_list(self, df = None):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001034 groups1 = (self.MGROUP1,)
1035 groups2 = (self.MGROUP2,)
1036 groups = groups1 + groups2
1037 self.igmp_send_joins_different_groups_srclist(groups,
Thangavelu K S790ad332016-12-14 12:54:58 +05301038 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['0']),
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001039 intf = self.V_INF1, delay = 2)
1040 dst_mac = '01:00:5e:02:02:03'
1041 src_ip = '5.5.5.5'
1042 if df is None:
1043 df = defer.Deferred()
1044 igmpState1 = IGMPTestState(groups = groups2, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001045 IGMPTestState(groups = groups2, df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001046 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1047 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1048 mcastTraffic1.start()
1049 join_state1 = IGMPTestState(groups = groups2)
1050 target1 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1)
1051 assert target1==1, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001052 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 -07001053 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001054
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001055 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001056 def test_igmp_include_empty_src_list(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001057 ## '''Disabling this test as scapy IGMP doesn't work with empty source lists'''
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001058 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001059 def igmp_include_empty_src_list():
1060 self.igmp_include_empty_src_list(df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001061 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001062 reactor.callLater(0, igmp_include_empty_src_list)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001063 return df
1064
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001065 def igmp_exclude_empty_src_list(self, df = None):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001066 groups2 = (self.MGROUP2,)
Thangavelu K S790ad332016-12-14 12:54:58 +05301067 self.send_igmp_leave(groups = groups2, src_list = ['0'], iface = self.V_INF1, delay = 2)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001068 dst_mac = '01:00:5e:02:02:03'
1069 src_ip = '5.5.5.5'
1070 if df is None:
1071 df = defer.Deferred()
1072 igmpState1 = IGMPTestState(groups = groups2, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001073 IGMPTestState(groups = groups2, df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001074 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1075 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1076 mcastTraffic1.start()
1077 join_state1 = IGMPTestState(groups = groups2)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001078 self.igmp_recv_task(self.V_INF1, groups2, join_state1)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001079 log.info('Interface is receiving multicast groups %s' %groups2)
1080 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001081
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001082 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001083 def test_igmp_exclude_empty_src_list(self):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001084 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001085 def igmp_exclude_empty_src_list():
1086 self.igmp_exclude_empty_src_list()
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001087 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001088 reactor.callLater(0, igmp_exclude_empty_src_list)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001089 return df
1090
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001091 def igmp_join_sourceip_0_0_0_0(self, df = None):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001092 groups1 = (self.MGROUP1,)
1093 groups2 = (self.MGROUP2,)
1094 groups = groups1 + groups2
1095 ip_src = '0.0.0.0'
1096 self.igmp_send_joins_different_groups_srclist(groups,
1097 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['5.5.5.5']),
1098 intf = self.V_INF1, delay = 2, ip_src = ip_src)
1099 ip_src = self.IP_SRC
1100 dst_mac = '01:00:5e:02:02:03'
1101 src_ip = '5.5.5.5'
1102 if df is None:
1103 df = defer.Deferred()
1104 igmpState1 = IGMPTestState(groups = groups2, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001105 IGMPTestState(groups = groups2, df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001106 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1107 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1108 mcastTraffic1.start()
1109 join_state1 = IGMPTestState(groups = groups2)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001110 self.igmp_recv_task(self.V_INF1, groups2, join_state1)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001111 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 -07001112 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001113
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001114 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001115 def test_igmp_join_sourceip_0_0_0_0(self):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001116 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001117 def igmp_join_sourceip_0_0_0_0():
1118 self.igmp_join_sourceip_0_0_0_0(df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001119 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001120 reactor.callLater(0, igmp_join_sourceip_0_0_0_0)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001121 return df
1122
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001123 def igmp_invalid_join_packet(self, df = None):
Chetan Gaonker586fec32016-04-29 17:33:54 -07001124 groups1 = (self.MGROUP1,)
1125 groups2 = (self.MINVALIDGROUP1,)
1126 groups = groups1 + groups2
1127 ip_src = '1.1.1.1'
1128 self.igmp_send_joins_different_groups_srclist(groups,
1129 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['5.5.5.5']),
1130 intf = self.V_INF1, delay = 2, ip_src = ip_src)
1131 ip_src = self.IP_SRC
1132 dst_mac = '01:00:5e:02:02:03'
1133 src_ip = '5.5.5.5'
1134 if df is None:
1135 df = defer.Deferred()
1136 igmpState1 = IGMPTestState(groups = groups2, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001137 IGMPTestState(groups = groups2, df = df)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001138 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1139 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1140 mcastTraffic1.start()
1141 join_state1 = IGMPTestState(groups = groups2)
1142 target1 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1)
1143 assert target1==1, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001144 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 -07001145 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001146
Chetan Gaonker586fec32016-04-29 17:33:54 -07001147 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001148 def test_igmp_invalid_join_packet(self):
Chetan Gaonker586fec32016-04-29 17:33:54 -07001149 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001150 def igmp_invalid_join_packet():
1151 self.igmp_invalid_join_packet(df = df)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001152 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001153 reactor.callLater(0, igmp_invalid_join_packet)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001154 return df
1155
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001156 def igmp_join_data_receiving_during_subscriber_link_toggle(self, df = None):
Chetan Gaonker586fec32016-04-29 17:33:54 -07001157 groups1 = (self.MGROUP1,)
1158 groups2 = (self.MGROUP2,)
1159 groups = groups1 + groups2
1160 ip_src = '1.1.1.1'
1161 self.igmp_send_joins_different_groups_srclist(groups,
1162 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['5.5.5.5']),
1163 intf = self.V_INF1, delay = 2, ip_src = ip_src)
1164 ip_src = self.IP_SRC
1165 dst_mac = '01:00:5e:02:02:03'
1166 src_ip = '5.5.5.5'
1167 if df is None:
1168 df = defer.Deferred()
1169 igmpState1 = IGMPTestState(groups = groups2, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001170 IGMPTestState(groups = groups2, df = df)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001171 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1172 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1173 mcastTraffic1.start()
1174 join_state1 = IGMPTestState(groups = groups2)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001175 self.igmp_recv_task(self.V_INF1, groups2, join_state1)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001176 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 -07001177 os.system('ifconfig '+self.V_INF1+' down')
1178 log.info(' the self.V_INF1 %s is down now ' %self.V_INF1)
1179 os.system('ifconfig '+self.V_INF1)
1180 time.sleep(10)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001181 os.system('ifconfig '+self.V_INF1+' up')
1182 os.system('ifconfig '+self.V_INF1)
1183 log.info(' the self.V_INF1 %s is up now ' %self.V_INF1)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001184 self.igmp_recv_task(self.V_INF1, groups2, join_state1)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001185 log.info('Interface is receiving traffic from multicast groups %s when we nterface up after down ' %groups2)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001186 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001187
Chetan Gaonker586fec32016-04-29 17:33:54 -07001188 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001189 def test_igmp_join_data_received_during_subscriber_link_toggle(self):
Chetan Gaonker586fec32016-04-29 17:33:54 -07001190 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001191 def igmp_join_data_received_during_subscriber_link_toggle():
1192 self.igmp_join_data_received_during_subscriber_link_toggle(df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001193 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001194 reactor.callLater(0, igmp_join_data_received_during_subscriber_link_toggle)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001195 return df
1196
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001197 def igmp_join_data_received_during_channel_distributor_link_toggle(self, df = None):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001198 groups1 = (self.MGROUP1,)
1199 groups2 = (self.MGROUP2,)
1200 groups = groups1 + groups2
1201 ip_src = '1.1.1.1'
1202 self.igmp_send_joins_different_groups_srclist(groups,
1203 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['5.5.5.5', '6.6.6.6']),
1204 intf = self.V_INF1, delay = 2, ip_src = ip_src)
1205 ip_src = self.IP_SRC
1206 dst_mac1 = '01:00:5e:01:02:03'
1207 dst_mac2 = '01:00:5e:02:02:03'
1208 src_ip2 = '5.5.5.5'
1209 src_ip1 = '2.2.2.2'
1210 if df is None:
1211 df = defer.Deferred()
1212 igmpState1 = IGMPTestState(groups = groups1, df = df)
1213 igmpState2 = IGMPTestState(groups = groups2, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001214 IGMPTestState(groups = groups1, df = df)
1215 IGMPTestState(groups = groups2, df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001216 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac1,
1217 src_ip = src_ip1, cb = self.send_mcast_cb, arg = igmpState1)
1218 mcastTraffic2 = McastTraffic(groups2, iface= 'veth3', dst_mac = dst_mac2,
1219 src_ip = src_ip2, cb = self.send_mcast_cb, arg = igmpState2)
1220 mcastTraffic1.start()
1221 mcastTraffic2.start()
1222 join_state1 = IGMPTestState(groups = groups1)
1223 join_state2 = IGMPTestState(groups = groups2)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001224 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
1225 self.igmp_recv_task(self.V_INF1, groups2, join_state2)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001226 mcastTraffic1.stop()
1227 os.system('ifconfig '+'veth2'+' down')
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001228 os.system('ifconfig '+'veth2')
1229 time.sleep(10)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001230 self.igmp_not_recv_task(self.V_INF1, groups2, join_state1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001231 target1 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
1232 assert target1==1, 'EXPECTED FAILURE'
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001233 os.system('ifconfig '+'veth2'+' up')
1234 os.system('ifconfig '+'veth2')
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001235 time.sleep(10)
1236 mcastTraffic1.start()
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001237 self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
1238 self.igmp_recv_task(self.V_INF1, groups2, join_state2)
1239 self.igmp_recv_task(self.V_INF1, groups2, join_state2)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001240 mcastTraffic2.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001241
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001242 ## This test case is failing to receive traffic from multicast data from defferent channel interfaces TO-DO
1243 ###### TO DO scenario #######
1244 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+60)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001245 def test_igmp_join_data_received_during_channel_distributors_link_toggle(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001246 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001247 def igmp_join_data_receiving_during_channel_distributor_link_toggle():
Thangavelu K S790ad332016-12-14 12:54:58 +05301248 self.igmp_join_data_received_during_channel_distributor_link_toggle(df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001249 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001250 reactor.callLater(0, igmp_join_data_receiving_during_channel_distributor_link_toggle)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001251 return df
Chetan Gaonker586fec32016-04-29 17:33:54 -07001252
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001253 def igmp_invalidClassD_IP_join_packet(self, df = None):
Chetan Gaonker586fec32016-04-29 17:33:54 -07001254 groups1 = (self.MGROUP1,)
1255 groups2 = (self.MINVALIDGROUP2,)
1256 groups = groups1 + groups2
1257 ip_src = '1.1.1.1'
1258 self.igmp_send_joins_different_groups_srclist(groups,
1259 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['5.5.5.5']),
1260 intf = self.V_INF1, delay = 2, ip_src = ip_src)
1261 ip_src = self.IP_SRC
1262 dst_mac = '01:00:5e:02:02:03'
1263 src_ip = '5.5.5.5'
1264 if df is None:
1265 df = defer.Deferred()
1266 igmpState1 = IGMPTestState(groups = groups2, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001267 IGMPTestState(groups = groups2, df = df)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001268 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1269 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1270 mcastTraffic1.start()
1271 join_state1 = IGMPTestState(groups = groups2)
1272 target1 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1)
1273 assert target1==1, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001274 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 -07001275 mcastTraffic1.stop()
Chetan Gaonker586fec32016-04-29 17:33:54 -07001276
1277 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001278 def test_igmp_invalid_class_d_ip_for_join_packet(self):
Chetan Gaonker586fec32016-04-29 17:33:54 -07001279 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001280 def igmp_invalidClass_D_IP_join_packet():
Thangavelu K S790ad332016-12-14 12:54:58 +05301281 self.igmp_invalidClassD_IP_join_packet(df = df)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001282 df.callback(0)
Thangavelu K S790ad332016-12-14 12:54:58 +05301283 reactor.callLater(0, igmp_invalidClass_D_IP_join_packet)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001284 return df
1285
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001286 def igmp_invalidClassD_IP_as_srclistIP_join_packet(self, df = None):
Chetan Gaonker586fec32016-04-29 17:33:54 -07001287 groups1 = (self.MGROUP1,)
1288 groups2 = (self.MGROUP2,)
1289 groups = groups1 + groups2
1290 ip_src = '1.1.1.1'
1291 self.igmp_send_joins_different_groups_srclist(groups,
1292 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['239.5.5.5']),
1293 intf = self.V_INF1, delay = 2, ip_src = ip_src)
1294 ip_src = self.IP_SRC
1295 dst_mac = '01:00:5e:02:02:03'
1296 src_ip = '5.5.5.5'
1297 if df is None:
1298 df = defer.Deferred()
1299 igmpState1 = IGMPTestState(groups = groups2, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001300 IGMPTestState(groups = groups2, df = df)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001301 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1302 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1303 mcastTraffic1.start()
1304 join_state1 = IGMPTestState(groups = groups2)
1305 target1 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1)
1306 assert target1==1, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001307 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 -07001308 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001309
Chetan Gaonker586fec32016-04-29 17:33:54 -07001310 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001311 def test_igmp_invalid_class_d_ip_as_srclist_ip_for_join_packet(self):
Chetan Gaonker586fec32016-04-29 17:33:54 -07001312 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001313 def igmp_invalidClassD_IP_as_srclistIP_join_packet():
1314 self.igmp_invalidClassD_IP_as_srclistIP_join_packet(df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001315 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001316 reactor.callLater(0, igmp_invalidClassD_IP_as_srclistIP_join_packet)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001317 return df
Chetan Gaonkerf72ca402016-05-02 16:29:32 -07001318
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001319 def igmp_general_query_recv_packet(self, df = None):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001320 groups1 = (self.MGROUP1,)
1321 groups2 = (self.MGROUP2,)
1322 groups = groups1 + groups2
1323 ip_src = '1.1.1.1'
1324 self.igmp_send_joins_different_groups_srclist(groups,
1325 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['5.5.5.5']),
1326 intf = self.V_INF1, delay = 2, ip_src = ip_src)
1327 ip_src = self.IP_SRC
1328 dst_mac = '01:00:5e:02:02:03'
1329 src_ip = '5.5.5.5'
1330 if df is None:
1331 df = defer.Deferred()
1332 igmpState1 = IGMPTestState(groups = groups2, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001333 IGMPTestState(groups = groups2, df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001334 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1335 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1336 mcastTraffic1.start()
1337 join_state1 = IGMPTestState(groups = groups2)
1338 log.info('Started delay to verify multicast data taraffic for group %s is received or not for 180 sec ' %groups2)
1339 time.sleep(100)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001340 self.igmp_recv_task(self.V_INF1, groups2, join_state1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001341 log.info('Verified that multicast data for group %s is received after 100 sec ' %groups2)
1342 time.sleep(50)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001343 self.igmp_recv_task(self.V_INF1, groups2, join_state1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001344 log.info('Verified that multicast data for group %s is received after 150 sec ' %groups2)
1345 time.sleep(30)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001346 self.igmp_recv_task(self.V_INF1, groups2, join_state1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001347 log.info('Verified that multicast data for group %s is received after 180 sec ' %groups2)
1348 time.sleep(10)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001349 self.igmp_recv_task(self.V_INF1, groups2, join_state1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001350 log.info('Verified that multicast data for group %s is received after 190 sec ' %groups2)
1351 target3 = mcastTraffic1.isRecvStopped()
1352 assert target3==False, 'EXPECTED FAILURE'
1353 log.info('Verified that multicast data for a group %s is still transmitting from a data interface' %groups2)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001354 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 -07001355 target1 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1)
1356 assert target1==1, 'EXPECTED FAILURE'
1357 log.info('Interface is not receiving multicast data for group %s' %groups2)
1358 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001359
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001360 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+250)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001361 def test_igmp_general_query_received_traffic(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001362 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001363 def igmp_general_query_recv_packet():
1364 self.igmp_general_query_recv_packet(df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001365 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001366 reactor.callLater(0, igmp_general_query_recv_packet)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001367 return df
A.R Karthick95d044e2016-06-10 18:44:36 -07001368
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001369 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+100)
1370 def test_igmp_query_received_on_joining_interface(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001371 groups = ['224.0.1.10', '225.0.0.10']
1372 leave_groups = ['224.0.1.10']
1373 df = defer.Deferred()
1374 igmpState = IGMPTestState(groups = groups, df = df)
1375 igmpStateRecv = IGMPTestState(groups = groups, df = df)
1376 igmpStateList = (igmpState, igmpStateRecv)
A.R Karthick95d044e2016-06-10 18:44:36 -07001377 mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb,
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001378 arg = igmpState)
1379 self.df = df
1380 self.mcastTraffic = mcastTraffic
1381 self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP)
A.R Karthick95d044e2016-06-10 18:44:36 -07001382
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001383 def igmp_srp_task(stateList):
1384 igmpSendState, igmpRecvState = stateList
1385 if not mcastTraffic.isRecvStopped():
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001386 self.igmp_recv(igmpRecvState)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001387 reactor.callLater(0, igmp_srp_task, stateList)
1388 else:
1389 self.mcastTraffic.stop()
1390 self.recv_socket.close()
1391 self.igmp_verify_leave(stateList, leave_groups)
1392 self.df.callback(0)
1393
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001394 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 -07001395 self.send_igmp_join_recvQuery(groups)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001396 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 -07001397 mcastTraffic.start()
1398 self.test_timer = reactor.callLater(self.MCAST_TRAFFIC_TIMEOUT, self.mcast_traffic_timer)
1399 reactor.callLater(0, igmp_srp_task, igmpStateList)
1400 return df
1401
1402 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+190)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001403 def test_igmp_for_periodic_query_received_on_joining_interface(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001404 groups = ['224.0.1.10', '225.0.0.10']
1405 leave_groups = ['224.0.1.10']
1406 df = defer.Deferred()
1407 igmpState = IGMPTestState(groups = groups, df = df)
A.R Karthick95d044e2016-06-10 18:44:36 -07001408 mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb,
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001409 arg = igmpState)
1410 self.df = df
1411 self.mcastTraffic = mcastTraffic
1412 self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP)
A.R Karthick95d044e2016-06-10 18:44:36 -07001413
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001414 def igmp_srp_task(stateList):
1415 igmpSendState, igmpRecvState = stateList
1416 if not mcastTraffic.isRecvStopped():
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001417 self.igmp_recv(igmpRecvState)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001418 reactor.callLater(0, igmp_srp_task, stateList)
1419 else:
1420 self.mcastTraffic.stop()
1421 self.recv_socket.close()
1422 self.igmp_verify_leave(stateList, leave_groups)
1423 self.df.callback(0)
1424
1425 self.send_igmp_join_recvQuery(groups,3)
1426 return df
1427
1428 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+190)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001429 def test_igmp_for_periodic_query_received_and_checking_entry_deleted(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001430 groups = ['224.0.1.10', '225.0.0.10']
1431 leave_groups = ['224.0.1.10']
1432 df = defer.Deferred()
1433 igmpState = IGMPTestState(groups = groups, df = df)
1434 igmpStateRecv = IGMPTestState(groups = groups, df = df)
1435 igmpStateList = (igmpState, igmpStateRecv)
A.R Karthick95d044e2016-06-10 18:44:36 -07001436 mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb,
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001437 arg = igmpState)
1438 self.df = df
1439 self.mcastTraffic = mcastTraffic
1440 self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP)
A.R Karthick95d044e2016-06-10 18:44:36 -07001441
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001442 def igmp_srp_task(stateList):
1443 igmpSendState, igmpRecvState = stateList
1444 if not mcastTraffic.isRecvStopped():
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001445 self.igmp_recv(igmpRecvState)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001446 reactor.callLater(0, igmp_srp_task, stateList)
1447 else:
1448 self.mcastTraffic.stop()
1449 self.recv_socket.close()
1450 self.igmp_verify_leave(stateList, leave_groups)
1451 self.df.callback(0)
1452
1453 self.send_igmp_join_recvQuery(groups,3)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001454 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 -07001455 mcastTraffic.start()
1456 self.test_timer = reactor.callLater(self.MCAST_TRAFFIC_TIMEOUT, self.mcast_traffic_timer)
1457 reactor.callLater(0, igmp_srp_task, igmpStateList)
1458 return df
1459
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001460 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+190)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001461 def test_igmp_member_query_interval_and_expiry_for_rejoining_interface(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001462 groups = ['224.0.1.10', '225.0.0.10']
1463 leave_groups = ['224.0.1.10']
1464 df = defer.Deferred()
1465 igmpState = IGMPTestState(groups = groups, df = df)
1466 igmpStateRecv = IGMPTestState(groups = groups, df = df)
1467 igmpStateList = (igmpState, igmpStateRecv)
A.R Karthick95d044e2016-06-10 18:44:36 -07001468 mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb,
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001469 arg = igmpState)
1470 self.df = df
1471 self.mcastTraffic = mcastTraffic
1472 self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP)
A.R Karthick95d044e2016-06-10 18:44:36 -07001473
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001474 def igmp_srp_task(stateList):
1475 igmpSendState, igmpRecvState = stateList
1476 if not mcastTraffic.isRecvStopped():
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001477 self.igmp_recv(igmpRecvState)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001478 reactor.callLater(0, igmp_srp_task, stateList)
1479 else:
1480 self.mcastTraffic.stop()
1481 self.recv_socket.close()
1482 self.igmp_verify_leave(stateList, leave_groups)
1483 self.df.callback(0)
1484
1485 self.send_igmp_join_recvQuery(groups,3)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001486 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 -07001487 self.send_igmp_join(groups)
1488 mcastTraffic.start()
1489 self.test_timer = reactor.callLater(self.MCAST_TRAFFIC_TIMEOUT, self.mcast_traffic_timer)
1490 reactor.callLater(0, igmp_srp_task, igmpStateList)
1491 return df
1492
1493 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+50)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001494 def test_igmp_leave_received_group_and_source_specific_query(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001495 groups = ['224.0.1.10', '225.0.0.10']
1496 leave_groups = ['224.0.1.10']
1497 df = defer.Deferred()
1498 igmpState = IGMPTestState(groups = groups, df = df)
A.R Karthick95d044e2016-06-10 18:44:36 -07001499 mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb,
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001500 arg = igmpState)
1501 self.df = df
1502 self.mcastTraffic = mcastTraffic
1503 self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP)
A.R Karthick95d044e2016-06-10 18:44:36 -07001504
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001505 def igmp_srp_task(stateList):
1506 igmpSendState, igmpRecvState = stateList
1507 if not mcastTraffic.isRecvStopped():
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001508 self.igmp_recv(igmpRecvState)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001509 reactor.callLater(0, igmp_srp_task, stateList)
1510 else:
1511 self.mcastTraffic.stop()
1512 self.recv_socket.close()
1513 self.igmp_verify_leave(stateList, leave_groups)
1514 self.df.callback(0)
1515
1516 self.send_igmp_join(groups)
1517 self.send_igmp_leave_listening_group_specific_query(leave_groups, delay = 3)
1518 return df
1519
1520 def igmp_change_to_exclude_src_list_check_for_group_source_specific_query(self, df = None):
1521 groups1 = (self.MGROUP1,)
1522 groups2 = (self.MGROUP2,)
1523 self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
1524 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
1525 intf = self.V_INF1, delay = 2)
1526 dst_mac = '01:00:5e:01:02:03'
1527 src_ip = '2.2.2.2'
1528 if df is None:
1529 df = defer.Deferred()
1530 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001531 IGMPTestState(groups = groups1, df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001532 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
1533 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1534 mcastTraffic1.start()
1535 join_state1 = IGMPTestState(groups = groups1)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001536 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001537 self.send_igmp_leave_listening_group_specific_query(groups = groups1, src_list = ['2.2.2.2'], iface = self.V_INF1, delay =2)
1538 time.sleep(10)
1539 target2 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
1540 assert target2 == 1, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001541 log.info('Interface is not receiving traffic from multicast groups %s after sending CHANGE_TO_EXCLUDE' %groups2)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001542 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001543
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001544 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+60)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001545 def test_igmp_change_to_exclude_src_list_and_check_for_group_source_specific_query(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001546 df = defer.Deferred()
1547 def igmp_change_to_exclude_src_list_check_for_group_source_specific_query():
1548 self.igmp_change_to_exclude_src_list_check_for_group_source_specific_query(df = df)
1549 df.callback(0)
1550 reactor.callLater(0, igmp_change_to_exclude_src_list_check_for_group_source_specific_query)
1551 return df
1552
1553 def igmp_change_to_include_src_list_check_for_general_query(self, df = None):
1554 groups1 = (self.MGROUP1,)
1555 groups2 = (self.MGROUP2,)
1556 self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4'],
1557 iface = self.V_INF1, delay = 2)
1558 dst_mac = '01:00:5e:01:02:03'
1559 src_ip = '2.2.2.2'
1560 if df is None:
1561 df = defer.Deferred()
1562 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001563 IGMPTestState(groups = groups1, df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001564 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
1565 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1566 mcastTraffic1.start()
1567 join_state1 = IGMPTestState(groups = groups1)
1568 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
1569 assert target1 == 1, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001570 log.info('Interface is not receiving traffic from multicast groups %s' %groups1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001571 self.igmp_send_joins_different_groups_srclist_wait_query_packets(groups1 + groups2,
1572 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['6.6.6.6', '5.5.5.5']),
1573 intf = self.V_INF1, delay = 2,query_group1 = 'group1', query_group2 = None)
1574 time.sleep(10)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001575 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001576 log.info('Interface is receiving traffic from multicast groups %s after send Change to include message' %groups1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001577 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001578
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001579 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+80)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001580 def test_igmp_change_to_include_src_list_and_check_for_general_query(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001581 df = defer.Deferred()
1582 def igmp_change_to_include_src_list_check_for_general_query():
1583 self.igmp_change_to_include_src_list_check_for_general_query(df = df)
1584 df.callback(0)
1585 reactor.callLater(0, igmp_change_to_include_src_list_check_for_general_query)
1586 return df
1587
1588 def igmp_allow_new_src_list_check_for_general_query(self, df = None):
1589 groups1 = (self.MGROUP1,)
1590 groups2 = (self.MGROUP2,)
1591 self.igmp_send_joins_different_groups_srclist(groups1+groups2,
1592 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
1593 intf = self.V_INF1, delay = 2)
1594 dst_mac = '01:00:5e:01:02:03'
1595 src_ip = '6.6.6.6'
1596 if df is None:
1597 df = defer.Deferred()
1598 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001599 IGMPTestState(groups = groups1, df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001600 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
1601 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1602 mcastTraffic1.start()
1603 join_state1 = IGMPTestState(groups = groups1)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001604 self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001605 log.info('Interface is not receiving traffic from multicast groups %s' %groups1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001606 self.igmp_send_joins_different_groups_srclist_wait_query_packets(groups1 + groups2, (['2.2.2.2', '6.6.6.6', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
1607 intf = self.V_INF1, delay = 2, query_group1 = 'group1', query_group2 = None)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001608 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001609 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 -07001610 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001611
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001612 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+80)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001613 def test_igmp_allow_new_src_list_and_check_for_general_query(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001614 df = defer.Deferred()
1615 def igmp_allow_new_src_list_check_for_general_query():
1616 self.igmp_allow_new_src_list_check_for_general_query(df = df)
1617 df.callback(0)
1618 reactor.callLater(0, igmp_allow_new_src_list_check_for_general_query)
1619 return df
1620
1621 def igmp_block_old_src_list_check_for_group_source_specific_query(self, df = None):
1622 groups1 = (self.MGROUP1,)
1623 groups2 = (self.MGROUP2,)
1624 groups = groups1 + groups2
1625 self.igmp_send_joins_different_groups_srclist(groups,
1626 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
1627 intf = self.V_INF1, delay = 2)
1628 dst_mac = '01:00:5e:02:02:03'
1629 src_ip = '5.5.5.5'
1630 if df is None:
1631 df = defer.Deferred()
1632 igmpState1 = IGMPTestState(groups = groups2, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001633 IGMPTestState(groups = groups2, df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001634 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1635 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1636 mcastTraffic1.start()
1637 join_state1 = IGMPTestState(groups = groups2)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001638 self.igmp_recv_task(self.V_INF1, groups2, join_state1)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001639 log.info('Interface is receiving traffic from multicast groups %s' %groups2)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001640 self.igmp_send_joins_different_groups_srclist_wait_query_packets(groups,
1641 (['6.6.6.6', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '7.7.7.7']),
1642 intf = self.V_INF1, delay = 2, query_group1 = 'group1', query_group2 = None)
1643 target2 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1)
1644 assert target2 == 1, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001645 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 -07001646 mcastTraffic1.stop()
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001647
1648 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+90)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001649 def test_igmp_block_old_src_list_and_check_for_group_source_specific_query(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001650 df = defer.Deferred()
1651 def igmp_block_old_src_list_check_for_group_source_specific_query():
1652 self.igmp_block_old_src_list_check_for_group_source_specific_query(df = df)
1653 df.callback(0)
1654 reactor.callLater(0, igmp_block_old_src_list_check_for_group_source_specific_query)
1655 return df
1656
1657 def igmp_include_to_allow_src_list_check_for_general_query(self, df = None):
1658 groups1 = (self.MGROUP1,)
1659 groups2 = (self.MGROUP2,)
1660 self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
1661 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
1662 intf = self.V_INF1, delay = 2)
1663 dst_mac = '01:00:5e:01:02:03'
1664 src_ip = '2.2.2.2'
1665 if df is None:
1666 df = defer.Deferred()
1667 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001668 IGMPTestState(groups = groups1, df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001669 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
1670 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1671 mcastTraffic1.start()
1672 join_state1 = IGMPTestState(groups = groups1)
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 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 -08001675 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001676 mcastTraffic1.stop()
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001677
1678 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+40)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001679 def test_igmp_include_to_allow_src_list_and_check_for_general_query(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001680 df = defer.Deferred()
1681 def igmp_include_to_allow_src_list_check_for_general_query():
1682 self.igmp_include_to_allow_src_list_check_for_general_query(df = df)
1683 df.callback(0)
1684 reactor.callLater(0, igmp_include_to_allow_src_list_check_for_general_query)
1685 return df
1686
1687 def igmp_include_to_block_src_list_check_for_group_source_specific_query(self, df = None):
1688 groups1 = (self.MGROUP1,)
1689 groups2 = (self.MGROUP2,)
1690 self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
1691 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
1692 intf = self.V_INF1, delay = 2)
1693 dst_mac = '01:00:5e:01:02:03'
1694 src_ip = '2.2.2.2'
1695 if df is None:
1696 df = defer.Deferred()
1697 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001698 IGMPTestState(groups = groups1, df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001699 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
1700 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1701 mcastTraffic1.start()
1702 join_state1 = IGMPTestState(groups = groups1)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001703 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001704 self.send_igmp_leave_listening_group_specific_query(groups = groups1, src_list = ['6.6.6.6','7.7.7.7'],
1705 iface = self.V_INF1, delay = 2)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001706 self.igmp_recv_task(self.V_INF1, groups1, join_state1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001707 mcastTraffic1.stop()
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001708
1709 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+40)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001710 def test_igmp_include_to_block_src_list_and_check_for_group_source_specific_query(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001711 df = defer.Deferred()
1712 def igmp_include_to_block_src_list_check_for_group_source_specific_query():
1713 self.igmp_include_to_block_src_list_check_for_group_source_specific_query(df = df)
1714 df.callback(0)
1715 reactor.callLater(0, igmp_include_to_block_src_list_check_for_group_source_specific_query)
1716 return df
1717
1718 def igmp_exclude_to_allow_src_list_check_for_general_query(self, df = None):
1719 groups1 = (self.MGROUP1,)
1720 groups2 = (self.MGROUP2,)
1721 self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4'],
1722 iface = self.V_INF1, delay = 2)
A.R Karthick95d044e2016-06-10 18:44:36 -07001723
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001724 dst_mac = '01:00:5e:01:02:03'
1725 src_ip = '2.2.2.2'
1726 if df is None:
1727 df = defer.Deferred()
1728 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001729 IGMPTestState(groups = groups1, df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001730 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
1731 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1732 mcastTraffic1.start()
1733 join_state1 = IGMPTestState(groups = groups1)
1734 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
1735 assert target1 == 1, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001736 log.info('Interface is not receiving traffic from multicast groups %s' %groups1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001737 self.igmp_send_joins_different_groups_srclist_wait_query_packets(groups1 + groups2,
1738 (['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)
1739 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
1740 assert target1 == 1, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001741 log.info('Interface is not receiving traffic from multicast groups %s' %groups1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001742 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001743
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001744 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+90)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001745 def test_igmp_exclude_to_allow_src_list_and_check_for_general_query(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001746 df = defer.Deferred()
1747 def igmp_exclude_to_allow_src_list_check_for_general_query():
1748 self.igmp_exclude_to_allow_src_list_check_for_general_query(df = df)
1749 df.callback(0)
1750 reactor.callLater(0, igmp_exclude_to_allow_src_list_check_for_general_query)
1751 return df
1752
1753 def igmp_exclude_to_block_src_list_check_for_group_source_specific_query(self, df = None):
1754 groups1 = (self.MGROUP1,)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001755 self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4'],
1756 iface = self.V_INF1, delay = 2)
A.R Karthick95d044e2016-06-10 18:44:36 -07001757
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001758 dst_mac = '01:00:5e:01:02:03'
1759 src_ip = '2.2.2.2'
1760 if df is None:
1761 df = defer.Deferred()
1762 igmpState1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08001763 IGMPTestState(groups = groups1, df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001764 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
1765 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1766 mcastTraffic1.start()
1767 join_state1 = IGMPTestState(groups = groups1)
1768 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
1769 assert target1 == 1, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001770 log.info('Interface is not receiving traffic from multicast groups %s' %groups1)
A.R Karthick95d044e2016-06-10 18:44:36 -07001771 self.send_igmp_leave_listening_group_specific_query(groups = groups1,
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001772 src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4', '5.5.5.5', '7.7.7.7'],
1773 iface = self.V_INF1, delay = 2)
1774 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
1775 assert target1 == 1, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001776 log.info('Interface is not receiving traffic from multicast groups %s' %groups1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001777 mcastTraffic1.stop()
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001778
1779 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+40)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001780 def test_igmp_exclude_to_block_src_list_and_check_for_group_source_specific_query(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001781 df = defer.Deferred()
1782 def igmp_exclude_to_block_src_list_check_for_group_source_specific_query():
1783 self.igmp_exclude_to_block_src_list_check_for_group_source_specific_query(df = df)
1784 df.callback(0)
1785 reactor.callLater(0, igmp_exclude_to_block_src_list_check_for_group_source_specific_query)
1786 return df
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001787
1788 def iptomac(self, mcast_ip):
1789 mcast_mac = '01:00:5e:'
1790 octets = mcast_ip.split('.')
1791 second_oct = int(octets[1]) & 127
1792 third_oct = int(octets[2])
1793 fourth_oct = int(octets[3])
1794 mcast_mac = mcast_mac + format(second_oct,'02x') + ':' + format(third_oct, '02x') + ':' + format(fourth_oct, '02x')
1795 return mcast_mac
1796
1797 def send_multicast_data_traffic(self, group, intf= 'veth2',source = '1.2.3.4'):
1798 dst_mac = self.iptomac(group)
1799 eth = Ether(dst= dst_mac)
1800 ip = IP(dst=group,src=source)
1801 data = repr(monotonic.monotonic())
1802 sendp(eth/ip/data,count=20, iface = intf)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001803
1804 def verify_igmp_data_traffic(self, group, intf='veth0', source='1.2.3.4' ):
1805 log.info('verifying multicast traffic for group %s from source %s'%(group,source))
1806 self.success = False
1807 def recv_task():
1808 def igmp_recv_cb(pkt):
1809 #log.info('received multicast data packet is %s'%pkt.show())
1810 log.info('multicast data received for group %s from source %s'%(group,source))
1811 self.success = True
1812 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')
1813 t = threading.Thread(target = recv_task)
1814 t.start()
1815 self.send_multicast_data_traffic(group,source=source)
1816 t.join()
1817 return self.success
1818
1819 def test_igmp_include_exclude_modes(self):
1820 groups = ['224.2.3.4','230.5.6.7']
1821 src_list = ['2.2.2.2','3.3.3.3']
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001822 self.onos_ssm_table_load(groups, src_list=src_list)
1823 self.send_igmp_join(groups = [groups[0]], src_list = src_list,record_type = IGMP_V3_GR_TYPE_INCLUDE,
1824 iface = self.V_INF1, delay = 2)
1825 self.send_igmp_join(groups = [groups[1]], src_list = src_list,record_type = IGMP_V3_GR_TYPE_EXCLUDE,
1826 iface = self.V_INF1, delay = 2)
1827 status = self.verify_igmp_data_traffic(groups[0],intf=self.V_INF1,source=src_list[0])
1828 assert_equal(status,True)
1829 status = self.verify_igmp_data_traffic(groups[1],intf = self.V_INF1,source= src_list[1])
1830 assert_equal(status,False)
1831
1832 def test_igmp_allow_new_source_mode(self):
1833 group = ['224.8.9.3']
1834 src_list = ['2.2.2.2','3.3.3.3']
1835 #dst_mac = self.iptomac(group[0])
1836 self.onos_ssm_table_load(group, src_list)
1837 self.send_igmp_join(groups = group, src_list = src_list[0],record_type = IGMP_V3_GR_TYPE_INCLUDE,
1838 iface = self.V_INF1, delay = 1)
1839 status = self.verify_igmp_data_traffic(group[0], intf=self.V_INF1,source = src_list[0])
1840 assert_equal(status,True) # expecting igmp data traffic from source src_list[0]
1841 self.send_igmp_join(groups = group, src_list = src_list[1],record_type = IGMP_V3_GR_TYPE_ALLOW_NEW,
1842 iface = self.V_INF1, delay = 1)
1843 for src in src_list:
1844 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1, source=src)
1845 assert_equal(status,True) # expecting igmp data traffic from both sources
1846
1847
1848 def test_igmp_include_to_exclude_mode_change(self):
1849 group = ['224.2.3.4']
1850 src_list = ['2.2.2.2','3.3.3.3']
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001851 self.onos_ssm_table_load(group, src_list)
1852 self.send_igmp_join(groups = group, src_list = src_list[0],record_type = IGMP_V3_GR_TYPE_INCLUDE,
1853 iface = self.V_INF1, delay = 1)
1854 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source= src_list[0])
1855 assert_equal(status,True) # expecting igmp data traffic from source src_list[0]
1856 self.send_igmp_join(groups = group, src_list = src_list[1],record_type = IGMP_V3_GR_TYPE_EXCLUDE,
1857 iface = self.V_INF1, delay = 1)
1858 for src in src_list:
1859 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source= src)
1860 assert_equal(status,False) # expecting igmp data traffic from both sources
1861
1862 def test_igmp_exclude_to_include_mode_change(self):
1863 group = ['224.2.3.4']
1864 src = ['2.2.2.2']
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001865 self.onos_ssm_table_load(group, src)
1866 self.send_igmp_join(groups = group, src_list = src,record_type = IGMP_V3_GR_TYPE_EXCLUDE,
1867 iface = self.V_INF1, delay = 1)
1868 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source=src[0])
1869 assert_equal(status,False) # not expecting igmp data traffic from source src_list[0]
1870 self.send_igmp_join(groups = group, src_list = src,record_type = IGMP_V3_GR_TYPE_INCLUDE,
1871 iface = self.V_INF1, delay = 1)
1872 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source = src[0])
1873 assert_equal(status,True) # expecting igmp data traffic from both sources
1874
1875 #this test case wotks properly if the snooping device(ONOS) have multicast router connected.
1876 def test_igmp_to_include_mode_with_null_source(self):
1877 groups = ['224.2.3.4','230.7.9.8']
1878 src = ['192.168.12.34']
1879 dst_mac = []
1880 dst_mac.append(self.iptomac(groups[0]))
1881 dst_mac.append(self.iptomac(groups[1]))
1882 self.onos_ssm_table_load(groups, src)
1883 self.send_igmp_join(groups = groups, src_list = src,record_type = IGMP_V3_GR_TYPE_INCLUDE,
1884 iface = self.V_INF1, delay = 1)
1885 for grp in groups:
1886 status = self.verify_igmp_data_traffic(grp,intf=self.V_INF1,source= src[0])
1887 assert_equal(status,True) # not expecting igmp data traffic from source src_list[0]
1888 #sending leave packet for group groups[1]
1889 self.send_igmp_join(groups = [groups[1]], src_list = [],record_type = IGMP_V3_GR_TYPE_CHANGE_TO_INCLUDE,
1890 iface = self.V_INF1, delay = 1)
1891 for grp in groups:
1892 status = self.verify_igmp_data_traffic(grp,intf=self.V_INF1,source= src[0])
1893 if grp is groups[0]:
1894 assert_equal(status,True) # expecting igmp data traffic to group groups[0]
1895 else:
1896 assert_equal(status,False) # not expecting igmp data traffic to group groups[1]
1897
1898 def test_igmp_to_include_mode(self):
1899 group = ['229.9.3.6']
1900 src_list = ['192.168.12.34','192.18.1.34']
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001901 self.onos_ssm_table_load(group, src_list)
1902 self.send_igmp_join(groups = group, src_list = [src_list[0]],record_type = IGMP_V3_GR_TYPE_INCLUDE,
1903 iface = self.V_INF1, delay = 1)
1904 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source=src_list[0])
1905 assert_equal(status,True) # not expecting igmp data traffic from source src_list[0]
1906 self.send_igmp_join(groups = group, src_list = src_list,record_type = IGMP_V3_GR_TYPE_CHANGE_TO_INCLUDE,
1907 iface = self.V_INF1, delay = 1)
1908 for src in src_list:
1909 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source= src)
1910 assert_equal(status,True) # expecting igmp data traffic to group groups[0]
1911
1912 #this test case passed only if mulitcast router connected to ONOS.
1913 def test_igmp_blocking_old_source_mode(self):
1914 group = ['224.2.3.4']
1915 src_list = ['2.2.2.2','3.3.3.3']
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001916 self.onos_ssm_table_load(group, src_list)
1917 self.send_igmp_join(groups = group, src_list = src_list,record_type = IGMP_V3_GR_TYPE_INCLUDE,
1918 iface = self.V_INF1, delay = 1)
1919 for src in src_list:
1920 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1, source=src)
1921 assert_equal(status,True) # expecting igmp data traffic from source src_list[0]
1922 self.send_igmp_join(groups = group, src_list = [src_list[1]],record_type = IGMP_V3_GR_TYPE_BLOCK_OLD,
1923 iface = self.V_INF1, delay = 1)
1924 for src in src_list:
1925 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1, source=src)
1926 if src is src_list[0]:
1927 assert_equal(status,True) # expecting igmp data traffic from source src_list[0]
1928 else:
1929 assert_equal(status,False) # not expecting igmp data traffic from source src_list[1]
1930
1931 def test_igmp_multiple_joins_and_data_verification_with_100_groups(self):
1932 groups = []
1933 sources = []
1934 count = 1
1935 mcastips = self.mcast_ip_range(start_ip = '226.0.0.1',end_ip = '226.0.5.254')
1936 sourceips = self.source_ip_range(start_ip = '10.10.0.1',end_ip = '10.10.5.254')
1937 while count<=100:
1938 group = random.choice(mcastips)
1939 source = random.choice(sourceips)
1940 if group in groups:
1941 pass
1942 else:
1943 log.info('group and source are %s and %s'%(group,source))
1944 groups.append(group)
1945 sources.append(source)
1946 count += 1
1947 self.onos_ssm_table_load(groups,src_list=sources,flag=True)
1948 for i in range(100):
1949 self.send_igmp_join(groups = [groups[i]], src_list = [sources[i]],record_type = IGMP_V3_GR_TYPE_INCLUDE,
1950 iface = self.V_INF1)
1951 status = self.verify_igmp_data_traffic(groups[i],intf=self.V_INF1,source=sources[i])
1952 assert_equal(status, True)
1953 log.info('data received for group %s from source %s'%(groups[i],sources[i]))
1954
1955 def test_igmp_multiple_joins_with_data_verification_and_leaving_100_groups(self):
1956 groups = []
1957 sources = []
1958 count = 1
1959 mcastips = self.mcast_ip_range(start_ip = '226.0.0.1',end_ip = '226.0.5.254')
1960 sourceips = self.source_ip_range(start_ip = '10.10.0.1',end_ip = '10.10.5.254')
1961 while count<=100:
1962 group = random.choice(mcastips)
1963 source = random.choice(sourceips)
1964 if group in groups:
1965 pass
1966 else:
1967 log.info('group and source are %s and %s'%(group,source))
1968 groups.append(group)
1969 sources.append(source)
1970 count += 1
1971 self.onos_ssm_table_load(groups,src_list=sources,flag=True)
1972 for i in range(100):
1973 self.send_igmp_join(groups = [groups[i]], src_list = [sources[i]],record_type = IGMP_V3_GR_TYPE_INCLUDE,
1974 iface = self.V_INF1)
1975 status = self.verify_igmp_data_traffic(groups[i],intf=self.V_INF1,source=sources[i])
1976 assert_equal(status, True)
1977 log.info('data received for group %s from source %s'%(groups[i],sources[i]))
1978 self.send_igmp_join(groups = [groups[i]], src_list = [sources[i]],record_type = IGMP_V3_GR_TYPE_CHANGE_TO_EXCLUDE,
1979 iface = self.V_INF1, delay = 1)
1980 status = self.verify_igmp_data_traffic(groups[i],intf=self.V_INF1,source=sources[i])
1981 assert_equal(status, False)
1982 log.info("data not received for group %s from source %s after changing group mode to 'TO-EXCLUDE' mode"%(groups[i],sources[i]))
1983
1984 def test_igmp_group_source_for_only_config_with_1000_entries(self):
1985 groups = []
1986 sources = []
1987 count = 1
1988 mcastips = self.mcast_ip_range(start_ip = '229.0.0.1',end_ip = '229.0.50.254')
1989 sourceips = self.source_ip_range(start_ip = '10.10.0.1',end_ip = '10.10.50.254')
1990 while count<=1000:
1991 group = random.choice(mcastips)
1992 source = random.choice(sourceips)
1993 if group in groups:
1994 pass
1995 else:
1996 log.info('group and source are %s and %s'%(group,source))
1997 groups.append(group)
1998 sources.append(source)
1999 count += 1
2000 self.onos_ssm_table_load(groups,src_list=sources,flag=True)
2001
2002 def test_igmp_from_exclude_to_include_mode_with_100_groups(self):
2003 groups = []
2004 sources = []
2005 count = 1
2006 mcastips = self.mcast_ip_range(start_ip = '229.0.0.1',end_ip = '229.0.10.254')
2007 sourceips = self.source_ip_range(start_ip = '10.10.0.1',end_ip = '10.10.10.254')
2008 while count<=100:
2009 group = random.choice(mcastips)
2010 source = random.choice(sourceips)
2011 if group in groups:
2012 pass
2013 else:
2014 log.info('group and source are %s and %s'%(group,source))
2015 groups.append(group)
2016 sources.append(source)
2017 count += 1
2018 self.onos_ssm_table_load(groups,src_list=sources,flag=True)
2019 for i in range(100):
2020 self.send_igmp_join(groups = [groups[i]], src_list = [sources[i]],record_type = IGMP_V3_GR_TYPE_EXCLUDE,
2021 iface = self.V_INF1)
2022 status = self.verify_igmp_data_traffic(groups[i],intf=self.V_INF1,source=sources[i])
2023 assert_equal(status, False)
2024 log.info('data not received for group %s from source %s as expected'%(groups[i],sources[i]))
2025 self.send_igmp_join(groups = [groups[i]], src_list = [sources[i]],record_type = IGMP_V3_GR_TYPE_INCLUDE,
2026 iface = self.V_INF1)
2027 status = self.verify_igmp_data_traffic(groups[i],intf=self.V_INF1,source=sources[i])
2028 assert_equal(status, True)
2029 log.info("data received for group %s from source %s after changing group mode to 'TO-INCLUDE' mode"%(groups[i],sources[i]))
2030
2031 def test_igmp_with_multiple_joins_and_data_verify_with_1000_groups(self):
2032 groups = []
2033 sources = []
2034 count = 1
2035 mcastips = self.mcast_ip_range(start_ip = '229.0.0.1',end_ip = '229.0.30.254')
2036 sourceips = self.source_ip_range(start_ip = '10.10.0.1',end_ip = '10.10.30.254')
2037 while count<=1000:
2038 group = random.choice(mcastips)
2039 source = random.choice(sourceips)
2040 if group in groups:
2041 pass
2042 else:
2043 log.info('group and source are %s and %s'%(group,source))
2044 groups.append(group)
2045 sources.append(source)
2046 count += 1
2047 self.onos_ssm_table_load(groups,src_list=sources,flag=True)
2048 for i in range(1000):
2049 self.send_igmp_join(groups = [groups[i]], src_list = [sources[i]],record_type = IGMP_V3_GR_TYPE_INCLUDE,
2050 iface = self.V_INF1)
2051 status = self.verify_igmp_data_traffic(groups[i],intf=self.V_INF1,source=sources[i])
2052 assert_equal(status, True)
2053 log.info('data received for group %s from source %s - %d'%(groups[i],sources[i],i))
2054
2055 def test_igmp_with_multiple_joins_and_data_verify_with_5000_groups(self):
2056 groups = []
2057 sources = []
2058 count = 1
2059 mcastips = self.mcast_ip_range(start_ip = '231.39.19.121',end_ip = '231.40.30.25')
2060 sourceips = self.source_ip_range(start_ip = '192.168.56.43',end_ip = '192.169.110.30')
2061 while count<=5000:
2062 group = random.choice(mcastips)
2063 source = random.choice(sourceips)
2064 if group in groups:
2065 pass
2066 else:
2067 log.info('group and source are %s and %s'%(group,source))
2068 groups.append(group)
2069 sources.append(source)
2070 count += 1
2071 self.onos_ssm_table_load(groups,src_list=sources,flag=True)
2072 for i in range(5000):
2073 self.send_igmp_join(groups = [groups[i]], src_list = [sources[i]],record_type = IGMP_V3_GR_TYPE_INCLUDE,
2074 iface = self.V_INF1)
2075 status = self.verify_igmp_data_traffic(groups[i],intf=self.V_INF1,source=sources[i])
2076 assert_equal(status, True)
2077 log.info('data received for group %s from source %s - %d'%(groups[i],sources[i],i))
2078
2079 """def test_igmp_join_from_multiple_infts(self):
2080 groups = ['229.9.3.6','234.20.56.2']
2081 src_list = ['192.168.12.34','192.18.1.34']
2082 self.onos_ssm_table_load(groups, src_list=src_list)
2083 self.send_igmp_join(groups = [groups[0]], src_list = src_list,record_type = IGMP_V3_GR_TYPE_INCLUDE,
2084 iface = 'veth0')
2085 self.send_igmp_join(groups = [groups[1]], src_list = src_list,record_type = IGMP_V3_GR_TYPE_INCLUDE,
2086 iface = 'veth2')
2087 status = self.verify_igmp_data_traffic(groups[0],intf='veth0',source=src_list[0])
2088 assert_equal(status,True)
2089 status = self.verify_igmp_data_traffic(groups[1],intf='veth2',source=src_list[1])
2090 assert_equal(status,True) # not expecting igmp data traffic from source src_list[0]
2091 """
2092
2093 def test_igmp_send_data_to_non_registered_group(self):
2094 group = ['224.2.3.4']
2095 src = ['2.2.2.2']
2096 self.onos_ssm_table_load(group,src_list= src)
2097 self.send_igmp_join(groups = ['239.0.0.1'], src_list = src,record_type = IGMP_V3_GR_TYPE_INCLUDE,
2098 iface = self.V_INF1, delay = 1)
2099 status = self.verify_igmp_data_traffic('239.0.0.1',intf=self.V_INF1,source=src[0])
2100 assert_equal(status,False) # not expecting igmp data traffic from source src_list[0]
2101
2102 def test_igmp_traffic_verification_for_registered_group_with_no_join_sent(self):
2103 group = ['227.12.3.40']
2104 src = ['190.4.19.67']
2105 self.onos_ssm_table_load(group,src_list= src)
2106 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source=src[0])
2107 assert_equal(status,False) # not expecting igmp data traffic from source src_list[0]
2108
2109 def test_igmp_toggling_app_activation(self):
2110 group = [self.random_mcast_ip()]
2111 src = [self.randomsourceip()]
2112 self.onos_ssm_table_load(group,src_list= src)
2113 self.send_igmp_join(groups = group, src_list = src,record_type = IGMP_V3_GR_TYPE_INCLUDE,
2114 iface = self.V_INF1)
2115 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source=src[0])
2116 assert_equal(status,True) # expecting igmp data traffic from source src_list[0]
2117 log.info('Multicast traffic received for group %s from source %s before the app is deactivated'%(group[0],src[0]))
2118 self.onos_ctrl.deactivate()
2119 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source=src[0])
2120 assert_equal(status,False) #not expecting igmp data traffic from source src_list[0]
2121 log.info('Multicast traffic not received for group %s from source %s after the app is deactivated'%(group[0],src[0]))
2122 self.onos_ctrl.activate()
2123 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source=src[0])
2124 assert_equal(status,True) # expecting igmp data traffic from source src_list[0]
2125 log.info('Multicast traffic received for group %s from source %s the app is re-activated'%(group[0],src[0]))
2126
2127 def test_igmp_with_mismatch_for_dst_ip_and_mac_in_data_packets(self):
2128 group = ['228.18.19.29']
2129 source = [self.randomsourceip()]
2130 self.onos_ssm_table_load(group,src_list= source)
2131 self.send_igmp_join(groups = group, src_list = source,record_type = IGMP_V3_GR_TYPE_INCLUDE,
2132 iface = self.V_INF1)
2133 dst_mac = '01:00:5e:0A:12:09'
2134 eth = Ether(dst= dst_mac)
2135 ip = IP(dst=group[0],src=source[0])
2136 data = repr(monotonic.monotonic())
2137 pkt = (eth/ip/data)
2138 log.info('Multicast traffic packet %s'%pkt.show())
2139 self.success = False
2140 def recv_task():
2141 def igmp_recv_cb(pkt):
2142 #log.info('received multicast data packet is %s'%pkt.show())
2143 log.info('multicast data received for group %s from source %s'%(group[0],source[0]))
2144 self.success = True
2145 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')
2146 t = threading.Thread(target = recv_task)
2147 t.start()
2148 sendp(eth/ip/data,count=20, iface = 'veth2')
2149 t.join()
2150 assert_equal(status,False) # not expecting igmp data traffic from source src_list[0]
2151
2152 #test case failing, ONOS registering unicast ip also as an igmp join
2153 def test_igmp_registering_invalid_group(self):
ChetanGaonkerb99538a2016-12-02 13:53:35 -08002154 groups = ['218.18.19.29']
ChetanGaonkera7e2b412016-09-01 23:19:07 -07002155 source = [self.randomsourceip()]
2156 ssm_dict = {'apps' : { 'org.onosproject.igmp' : { 'ssmTranslate' : [] } } }
2157 ssm_xlate_list = ssm_dict['apps']['org.onosproject.igmp']['ssmTranslate']
2158 for g in groups:
2159 for s in source:
2160 d = {}
2161 d['source'] = s or '0.0.0.0'
2162 d['group'] = g
2163 ssm_xlate_list.append(d)
2164 log.info('onos load config is %s'%ssm_dict)
2165 status, code = OnosCtrl.config(ssm_dict)
ChetanGaonkerb99538a2016-12-02 13:53:35 -08002166 self.send_igmp_join(groups, src_list = source, record_type = IGMP_V3_GR_TYPE_INCLUDE,
2167 iface = self.V_INF1, delay = 1)
2168 status = self.verify_igmp_data_traffic(groups[0],intf=self.V_INF1, source=source[0])
2169 assert_equal(status,False) # not expecting igmp data traffic from source src_list[0]
ChetanGaonkera7e2b412016-09-01 23:19:07 -07002170
2171 def test_igmp_registering_invalid_source(self):
2172 groups = [self.random_mcast_ip()]
2173 sources = ['224.10.28.34','193.73.219.257']
2174 ssm_dict = {'apps' : { 'org.onosproject.igmp' : { 'ssmTranslate' : [] } } }
2175 ssm_xlate_list = ssm_dict['apps']['org.onosproject.igmp']['ssmTranslate']
2176 for g in groups:
2177 for s in sources:
2178 d = {}
2179 d['source'] = s or '0.0.0.0'
2180 d['group'] = g
2181 ssm_xlate_list.append(d)
2182 log.info('onos load config is %s'%ssm_dict)
2183 status, code = OnosCtrl.config(ssm_dict)
2184 assert_equal(status,False)