blob: 676565b37fb5645843eeac666693ca853bd2ca62 [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 -080016import unittest
17from nose.tools import *
18from nose.twistedtools import reactor, deferred
19from twisted.internet import defer
20from scapy.all import *
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -080021import time, monotonic
Chetan Gaonker25470972016-02-26 08:52:15 -080022import os, sys
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -080023import tempfile
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -080024import random
25import threading
Chetan Gaonkere88c95c2016-03-02 05:21:47 -080026from IGMP import *
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -080027from McastTraffic import *
28from Stats import Stats
Chetan Gaonker4a25e2b2016-03-04 14:45:15 -080029from OnosCtrl import OnosCtrl
Chetan Gaonker441c9ac2016-05-06 10:30:13 -070030from OltConfig import OltConfig
Chetan Gaonker4eb12072016-03-28 15:04:15 -070031from Channels import IgmpChannel
A R Karthick9313b762016-11-07 13:14:35 -080032from CordLogger import CordLogger
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()
Chetan Gaonker441c9ac2016-05-06 10:30:13 -070089 OnosCtrl.cord_olt_config(cls.olt.olt_device_data())
90
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():
351 result = self.igmp_recv(igmpRecvState)
352 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)
372 igmpStateRecv = IGMPTestState(groups = groups, df = df)
373 igmpStateList = (igmpState, igmpStateRecv)
A.R Karthick95d044e2016-06-10 18:44:36 -0700374 mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb,
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800375 arg = igmpState)
376 self.df = df
377 self.mcastTraffic = mcastTraffic
378 self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP)
A.R Karthick95d044e2016-06-10 18:44:36 -0700379
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700380 mcastTraffic.start()
381 self.send_igmp_join(groups)
382 self.send_igmp_leave(leave_groups, delay = 3)
383 join_state = IGMPTestState(groups = leave_groups)
384 status = self.igmp_not_recv_task(self.V_INF1,leave_groups, join_state)
385 log.info('verified status for igmp recv task %s'%status)
386 assert status == 1 , 'EXPECTED RESULT'
387 self.df.callback(0)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800388 return df
389
390 @deferred(timeout=100)
391 def test_igmp_leave_join_loop(self):
392 self.groups = ['226.0.1.1', '227.0.0.1', '228.0.0.1', '229.0.0.1', '230.0.0.1' ]
393 self.src_list = ['3.4.5.6', '7.8.9.10']
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700394 self.onos_ssm_table_load(self.groups,src_list=self.src_list)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800395 df = defer.Deferred()
396 self.df = df
397 self.iterations = 0
398 self.num_groups = len(self.groups)
399 self.MAX_TEST_ITERATIONS = 10
400
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800401 def igmp_srp_task(v):
402 if self.iterations < self.MAX_TEST_ITERATIONS:
403 if v == 1:
404 ##join test
405 self.num_groups = random.randint(0, len(self.groups))
406 self.send_igmp_join(self.groups[:self.num_groups],
407 src_list = self.src_list,
408 iface = 'veth0', delay = 0)
409 else:
410 self.send_igmp_leave(self.groups[:self.num_groups],
411 src_list = self.src_list,
412 iface = 'veth0', delay = 0)
413 self.iterations += 1
414 v ^= 1
415 reactor.callLater(1.0 + 0.5*self.num_groups,
416 igmp_srp_task, v)
417 else:
418 self.df.callback(0)
419
420 reactor.callLater(0, igmp_srp_task, 1)
421 return df
422
423 def igmp_join_task(self, intf, groups, state, src_list = ['1.2.3.4']):
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700424 #self.onos_ssm_table_load(groups, src_list)
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800425 igmp = IGMPv3(type = IGMP_TYPE_V3_MEMBERSHIP_REPORT, max_resp_code=30,
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700426 gaddr=self.IP_DST)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800427 for g in groups:
Chetan Gaonker38737f82016-05-11 17:44:17 -0700428 gr = IGMPv3gr(rtype = IGMP_V3_GR_TYPE_INCLUDE, mcaddr = g)
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800429 gr.sources = src_list
430 igmp.grps.append(gr)
431
432 for g in groups:
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800433 state.group_map[g][0].update(1, t = monotonic.monotonic())
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800434
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700435 pkt = self.igmp_eth/self.igmp_ip/igmp
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800436 IGMPv3.fixup(pkt)
437 sendp(pkt, iface=intf)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800438 log.debug('Returning from join task')
439
440 def igmp_recv_task(self, intf, groups, join_state):
441 recv_socket = L3PacketSocket(iface = intf, type = ETH_P_IP)
442 group_map = {}
443 for g in groups:
444 group_map[g] = [0,0]
445
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700446 log.info('Verifying join interface should receive multicast data')
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800447 while True:
448 p = recv_socket.recv()
449 if p.dst in groups and group_map[p.dst][0] == 0:
450 group_map[p.dst][0] += 1
451 group_map[p.dst][1] = monotonic.monotonic()
452 c = 0
453 for g in groups:
454 c += group_map[g][0]
455 if c == len(groups):
456 break
457 for g in groups:
458 join_start = join_state.group_map[g][0].start
459 recv_time = group_map[g][1] * 1000000
460 delta = (recv_time - join_start)
461 log.info('Join for group %s received in %.3f usecs' %
462 (g, delta))
463
464 recv_socket.close()
465 log.debug('Returning from recv task')
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700466
467 def igmp_not_recv_task(self, intf, groups, join_state):
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700468 log.info('entering igmp not recv task loop')
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700469 recv_socket = L2Socket(iface = intf, type = ETH_P_IP)
470 group_map = {}
471 for g in groups:
472 group_map[g] = [0,0]
473
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700474 log.info('Verifying join interface should not receive any multicast data')
Chetan Gaonker7791bda2016-05-12 17:36:52 -0700475 self.NEGATIVE_TRAFFIC_STATUS = 1
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700476 def igmp_recv_cb(pkt):
477 log.info('Multicast packet %s received for left groups %s' %(pkt[IP].dst, groups))
Chetan Gaonker7791bda2016-05-12 17:36:52 -0700478 self.NEGATIVE_TRAFFIC_STATUS = 2
Chetan Gaonker38737f82016-05-11 17:44:17 -0700479 sniff(prn = igmp_recv_cb, count = 1, lfilter = lambda p: IP in p and p[IP].dst in groups,
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700480 timeout = 3, opened_socket = recv_socket)
481 recv_socket.close()
A.R Karthick95d044e2016-06-10 18:44:36 -0700482 return self.NEGATIVE_TRAFFIC_STATUS
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700483
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800484 def group_latency_check(self, groups):
485 tasks = []
486 self.send_igmp_leave(groups = groups)
487 join_state = IGMPTestState(groups = groups)
488 tasks.append(threading.Thread(target=self.igmp_join_task, args = ('veth0', groups, join_state,)))
489 traffic_state = IGMPTestState(groups = groups)
A.R Karthick95d044e2016-06-10 18:44:36 -0700490 mcast_traffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb,
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800491 arg = traffic_state)
492 mcast_traffic.start()
493 tasks.append(threading.Thread(target=self.igmp_recv_task, args = ('veth0', groups, join_state)))
494 for t in tasks:
495 t.start()
496 for t in tasks:
497 t.join()
498
499 mcast_traffic.stop()
500 self.send_igmp_leave(groups = groups)
501 return
502
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700503 @deferred(timeout=IGMP_QUERY_TIMEOUT + 10)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800504 def test_igmp_1group_join_latency(self):
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700505 groups = ['239.0.1.1']
506 df = defer.Deferred()
507 def igmp_1group_join_latency():
508 self.group_latency_check(groups)
509 df.callback(0)
510 reactor.callLater(0, igmp_1group_join_latency)
511 return df
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800512
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700513 @deferred(timeout=IGMP_QUERY_TIMEOUT + 10)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800514 def test_igmp_2group_join_latency(self):
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700515 groups = ['239.0.1.1', '240.0.1.1']
516 df = defer.Deferred()
517 def igmp_2group_join_latency():
518 self.group_latency_check(groups)
519 df.callback(0)
520 reactor.callLater(0, igmp_2group_join_latency)
521 return df
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800522
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700523 @deferred(timeout=IGMP_QUERY_TIMEOUT + 10)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800524 def test_igmp_Ngroup_join_latency(self):
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700525 groups = ['239.0.1.1', '240.0.1.1', '241.0.1.1', '242.0.1.1']
526 df = defer.Deferred()
527 def igmp_Ngroup_join_latency():
528 self.group_latency_check(groups)
529 df.callback(0)
530 reactor.callLater(0, igmp_Ngroup_join_latency)
531 return df
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800532
A R Karthick2b93d6a2016-09-06 15:19:09 -0700533 def test_igmp_join_rover_all(self):
Chetan Gaonker1f7c3f82016-03-08 12:17:37 -0800534 s = (224 << 24) | 1
535 #e = (225 << 24) | (255 << 16) | (255 << 16) | 255
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700536 e = (224 << 24) | 10
Chetan Gaonker1f7c3f82016-03-08 12:17:37 -0800537 for i in xrange(s, e+1):
538 if i&0xff:
539 ip = '%d.%d.%d.%d'%((i>>24)&0xff, (i>>16)&0xff, (i>>8)&0xff, i&0xff)
540 self.send_igmp_join([ip], delay = 0)
541
A R Karthick2b93d6a2016-09-06 15:19:09 -0700542 @deferred(timeout=ROVER_TEST_TIMEOUT)
543 def test_igmp_join_rover(self):
544 df = defer.Deferred()
545 iface = self.get_igmp_intf()
546 self.df = df
547 self.count = 0
548 self.timeout = 0
549 self.complete = False
550 def igmp_join_timer():
551 self.timeout += self.ROVER_JOIN_TIMEOUT
552 log.info('IGMP joins sent: %d' %self.count)
553 did = OnosCtrl.get_device_id()
554 if self.timeout >= self.ROVER_TIMEOUT:
555 self.complete = True
556 reactor.callLater(self.ROVER_JOIN_TIMEOUT, igmp_join_timer)
557
558 reactor.callLater(self.ROVER_JOIN_TIMEOUT, igmp_join_timer)
559 self.start_channel = s = (224 << 24) | 1
560 self.end_channel = e = (224 << 24) | 200 #(225 << 24) | (255 << 16) | (255 << 16) | 255
561 self.current_channel = self.start_channel
562 def igmp_join_rover(self):
563 #e = (224 << 24) | 10
564 chan = self.current_channel
565 self.current_channel += 1
566 if self.current_channel >= self.end_channel:
567 chan = self.current_channel = self.start_channel
568 if chan&0xff:
569 ip = '%d.%d.%d.%d'%((chan>>24)&0xff, (chan>>16)&0xff, (chan>>8)&0xff, chan&0xff)
570 self.send_igmp_join([ip], delay = 0, ssm_load = False, iface = iface)
571 self.count += 1
572 if self.complete == True:
573 log.info('%d IGMP joins sent in %d seconds over %s' %(self.count, self.timeout, iface))
574 self.df.callback(0)
575 else:
576 reactor.callLater(0, igmp_join_rover, self)
577 reactor.callLater(0, igmp_join_rover, self)
578 return df
579
Chetan Gaonker1f7c3f82016-03-08 12:17:37 -0800580 @deferred(timeout=IGMP_QUERY_TIMEOUT + 10)
581 def test_igmp_query(self):
582 groups = ['224.0.0.1'] ##igmp query group
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700583 self.onos_ssm_table_load(groups)
Chetan Gaonker1f7c3f82016-03-08 12:17:37 -0800584 df = defer.Deferred()
585 self.df = df
586 self.recv_socket = L2Socket(iface = 'veth0', type = ETH_P_IP)
A.R Karthick95d044e2016-06-10 18:44:36 -0700587
Chetan Gaonker1f7c3f82016-03-08 12:17:37 -0800588 def igmp_query_timeout():
Chetan Gaonker1f7c3f82016-03-08 12:17:37 -0800589 def igmp_query_cb(pkt):
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700590 log.info('received igmp query packet is %s'%pkt.show())
Chetan Gaonkerbd4390f2016-03-09 18:56:52 -0800591 log.info('Got IGMP query packet from %s for %s' %(pkt[IP].src, pkt[IP].dst))
592 assert_equal(pkt[IP].dst, '224.0.0.1')
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700593 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 -0800594 opened_socket = self.recv_socket)
Chetan Gaonker1f7c3f82016-03-08 12:17:37 -0800595 self.recv_socket.close()
596 self.df.callback(0)
597
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700598 #self.send_igmp_join(groups)
Chetan Gaonker1f7c3f82016-03-08 12:17:37 -0800599 self.test_timer = reactor.callLater(self.IGMP_QUERY_TIMEOUT, igmp_query_timeout)
600 return df
601
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700602 def igmp_send_joins_different_groups_srclist(self, groups, sources, intf = V_INF1, delay = 2, ip_src = None):
603 g1 = groups[0]
604 g2 = groups[1]
605 sourcelist1 = sources[0]
606 sourcelist2 = sources[1]
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700607 eth = Ether(dst = self.IGMP_DST_MAC,type = ETH_P_IP)
608 ip = IP(dst = self.IP_DST)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700609 log.info('Sending join message for the group %s' %g1)
610 self.send_igmp_join((g1,), src_list = sourcelist1, ip_pkt = eth/ip, iface = intf, delay = 2)
611 eth = Ether(dst = self.MMACGROUP2, src = self.IGMP_SRC_MAC, type = ETH_P_IP)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700612 ip = IP(dst = g2)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700613 log.info('Sending join message for group %s' %g2)
614 self.send_igmp_join((g2,), src_list = sourcelist2, ip_pkt = eth/ip, iface = intf, delay = 2)
Chetan Gaonker7791bda2016-05-12 17:36:52 -0700615 log.info('Done with igmp_send_joins_different_groups_srclist')
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700616
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700617 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):
618 g1 = groups[0]
619 g2 = groups[1]
620 sourcelist1 = sources[0]
621 sourcelist2 = sources[1]
622 eth = Ether(dst = self.MMACGROUP1, src = self.IGMP_SRC_MAC, type = ETH_P_IP)
623 src_ip = ip_src or self.IP_SRC
624 ip = IP(dst = g1, src = src_ip)
625 if query_group1 is 'group1':
626 log.info('Sending join message for the group %s and waiting for a query packet on join interface' %g1)
627 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 -0700628 else:
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700629 log.info('Sending join message for the group %s' %g1)
630 self.send_igmp_join((g1,), src_list = sourcelist1, ip_pkt = eth/ip, iface = intf, delay = 2)
631 eth = Ether(dst = self.MMACGROUP2, src = self.IGMP_SRC_MAC, type = ETH_P_IP)
632 ip = IP(dst = g2, src = src_ip)
633 if query_group2 is 'group2':
634 log.info('Sending join message for the group %s and waiting for a query packet on join interface' %g2)
635 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 -0700636 else:
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700637 log.info('Sending join message for group %s' %g2)
638 self.send_igmp_join((g2,), src_list = sourcelist2, ip_pkt = eth/ip, iface = intf, delay = 2)
639
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700640 def igmp_joins_leave(self,groups,src_list,again_join = False, df = None):
641 groups1 = [groups[0]]
642 groups2 = [groups[1]]
643 src1 = [src_list[0]]
644 src2 = [src_list[1]]
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700645 self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700646 (src1, src2), intf = self.V_INF1, delay = 2)
647
648 src_ip = src1[0]
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700649 if df is None:
650 df = defer.Deferred()
651 igmpState1 = IGMPTestState(groups = groups1, df = df)
652 igmpStateRecv1 = IGMPTestState(groups = groups1, df = df)
653 igmpStateList1 = (igmpState1, igmpStateRecv1)
654
655 igmpState2 = IGMPTestState(groups = groups2, df = df)
656 igmpStateRecv2 = IGMPTestState(groups = groups2, df = df)
657 igmpStateList2 = (igmpState2, igmpStateRecv2)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700658 dst_mac = self.iptomac(groups1[0])
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700659 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
660 src_ip = src_ip, cb = self.send_mcast_cb,
661 arg = igmpState1)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700662 src_ip = src2[0]
663 dst_mac = self.iptomac(groups1[0])
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700664 mcastTraffic2 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
665 src_ip = src_ip, cb = self.send_mcast_cb,
666 arg = igmpState2)
667 mcastTraffic1.start()
668 mcastTraffic2.start()
669 join_state1 = IGMPTestState(groups = groups1)
670 join_state2 = IGMPTestState(groups = groups2)
671 target1 = self.igmp_recv_task(self.V_INF1, groups1, join_state1)
672 log.info('Interface is receiving multicast groups %s' %groups1)
673 target2 = self.igmp_recv_task(self.V_INF1, groups2, join_state2)
674 log.info('Interface is receiving multicast groups %s' %groups2)
675 log.info('Interface is sending leave message for groups %s now' %groups2)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700676 self.send_igmp_leave(groups = groups2, src_list = src2, iface = self.V_INF1, delay = 2)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700677 target3 = self.igmp_recv_task(self.V_INF1, groups1, join_state1)
678 target4 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state2)
679 assert target4 == 1, 'EXPECTED FAILURE'
680 if again_join:
681 dst_mac = '01:00:5e:02:02:03'
682 ip_dst = '239.2.2.3'
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700683 eth = Ether(dst = dst_mac, type = ETH_P_IP)
684 ip = IP(dst = ip_dst)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700685 log.info('Interface sending join message again for the groups %s' %groups2)
686 self.send_igmp_join(groups2, src_list = [src_ip], ip_pkt = eth/ip, iface = self.V_INF1, delay = 2)
687 target5 = self.igmp_recv_task(self.V_INF1, groups2, join_state2)
688 log.info('Interface is receiving multicast groups %s again' %groups2)
689 target6 = self.igmp_recv_task(self.V_INF1, groups1, join_state1)
690 log.info('Interface is still receiving from multicast groups %s' %groups1)
691 else:
692 log.info('Ended test case')
693 mcastTraffic1.stop()
694 mcastTraffic2.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -0700695
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700696
697 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700698 def test_igmp_2joins_1leave(self):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700699 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700700 def igmp_2joins_1leave():
701 groups = ['234.2.3.4','236.8.7.9']
702 src_list = ['2.3.4.5','5.4.3.2']
703 self.onos_ssm_table_load(groups,src_list = src_list)
704 self.igmp_joins_leave(groups,src_list,again_join = False, df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700705 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700706 reactor.callLater(0, igmp_2joins_1leave)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700707 return df
708
709 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+25)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700710 def test_igmp_2joins_1leave_and_join_again(self):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700711 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700712 def igmp_2joins_1leave_join_again():
713 groups = ['234.2.3.4','236.8.7.9']
714 src_list = ['2.3.4.5','5.4.3.2']
715 self.onos_ssm_table_load(groups,src_list = src_list)
716 self.igmp_joins_leave(groups,src_list,again_join = True, df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700717 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700718 reactor.callLater(0, igmp_2joins_1leave_join_again)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700719 return df
720
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700721 def igmp_not_in_src_list(self, df = None):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700722 groups1 = (self.MGROUP1,)
723 groups2 = (self.MGROUP2,)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700724 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 -0700725 self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
726 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
727 intf = self.V_INF1, delay = 2)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700728 src_ip = '6.6.6.6'
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700729 dst_mac = self.iptomac(groups1[0])
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700730 if df is None:
731 df = defer.Deferred()
732 igmpState1 = IGMPTestState(groups = groups1, df = df)
733 igmpStateRecv1 = IGMPTestState(groups = groups1, df = df)
734 mcastTraffic1 = McastTraffic(groups1, iface = 'veth2', dst_mac = dst_mac,
735 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
736 mcastTraffic1.start()
737 join_state1 = IGMPTestState(groups = groups1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700738 log.info('Interface should not receive from multicast groups %s from an interface, which is expected' %groups1)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700739 target1 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
Chetan Gaonker7791bda2016-05-12 17:36:52 -0700740 assert target1 == 2, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700741 log.info('Interface is not receiving traffic from multicast groups %s, working as expected' %groups1)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700742 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -0700743
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700744 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700745 def test_igmp_not_in_src_list(self):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700746 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700747 def igmp_not_in_src_list():
748 self.igmp_not_in_src_list(df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700749 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700750 reactor.callLater(0, igmp_not_in_src_list)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700751 return df
752
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700753 def igmp_change_to_exclude_src_list(self, df = None):
754 groups1 = [self.random_mcast_ip()]
755 groups2 = [self.random_mcast_ip()]
756 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 -0700757 self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
758 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
759 intf = self.V_INF1, delay = 2)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700760 src_ip = '2.2.2.2'
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700761 dst_mac=self.iptomac(groups1[0])
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700762 if df is None:
763 df = defer.Deferred()
764 igmpState1 = IGMPTestState(groups = groups1, df = df)
765 igmpStateRecv1 = IGMPTestState(groups = groups1, df = df)
766 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
767 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
768 mcastTraffic1.start()
769 join_state1 = IGMPTestState(groups = groups1)
770 target1 = self.igmp_recv_task(self.V_INF1, groups1, join_state1)
771 self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2'], iface = self.V_INF1, delay =2)
772 target2 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
Chetan Gaonker7791bda2016-05-12 17:36:52 -0700773 assert target2 == 2, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700774 log.info('Interface is not receiving traffic from multicast groups %s after sending CHANGE_TO_EXCLUDE' %groups1)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700775 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -0700776
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700777 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700778 def test_igmp_change_to_exclude_src_list(self):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700779 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700780 def igmp_change_to_exclude_src_list():
781 self.igmp_change_to_exclude_src_list(df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700782 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700783 reactor.callLater(0, igmp_change_to_exclude_src_list)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700784 return df
785
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700786 def igmp_include_to_allow_src_list(self, df = None):
787 groups1 = [self.random_mcast_ip()] #(self.MGROUP1,)
788 self.onos_ssm_table_load(groups1,src_list = ['4.4.4.4','6.6.6.6'])
789 self.send_igmp_join(groups = groups1, src_list = ['4.4.4.4'],record_type = IGMP_V3_GR_TYPE_INCLUDE,
790 iface = self.V_INF1)
791 src_ip = '4.4.4.4'
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700792 if df is None:
793 df = defer.Deferred()
794 igmpState1 = IGMPTestState(groups = groups1, df = df)
795 igmpStateRecv1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700796 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2',src_ip = src_ip,
797 cb = self.send_mcast_cb, arg = igmpState1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700798 mcastTraffic1.start()
799 join_state1 = IGMPTestState(groups = groups1)
800 target1 = self.igmp_recv_task(self.V_INF1, groups1, join_state1)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700801 mcastTraffic1.stop()
802 mcastTraffic2 = McastTraffic(groups1, iface= 'veth2',src_ip = '6.6.6.6',
803 cb = self.send_mcast_cb, arg = igmpState1)
804 self.send_igmp_join(groups = groups1, src_list = ['6.6.6.6'],record_type = IGMP_V3_GR_TYPE_ALLOW_NEW,
805 iface = self.V_INF1)
806 mcastTraffic2.start()
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700807 target1 = self.igmp_recv_task(self.V_INF1, groups1, join_state1)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700808 mcastTraffic2.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -0700809
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700810 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+30)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700811 def test_igmp_include_to_allow_src_list(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700812 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700813 def igmp_include_to_allow_src_list():
814 self.igmp_include_to_allow_src_list(df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700815 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700816 reactor.callLater(0, igmp_include_to_allow_src_list)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700817 return df
818
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700819 def igmp_include_to_block_src_list(self, df = None):
820 groups1 = [self.random_mcast_ip()] #groups1 = (self.MGROUP1,)
821 self.onos_ssm_table_load(groups1,src_list = ['4.4.4.4','6.6.6.6'])
822 self.send_igmp_join(groups = groups1, src_list = ['4.4.4.4','6.6.6.6'],record_type = IGMP_V3_GR_TYPE_INCLUDE,
823 iface = self.V_INF1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700824 if df is None:
825 df = defer.Deferred()
826 igmpState1 = IGMPTestState(groups = groups1, df = df)
827 igmpStateRecv1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700828 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2',src_ip = '6.6.6.6',
829 cb = self.send_mcast_cb, arg = igmpState1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700830 mcastTraffic1.start()
831 join_state1 = IGMPTestState(groups = groups1)
832 target1 = self.igmp_recv_task(self.V_INF1, groups1, join_state1)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700833 mcastTraffic1.stop()
834 self.send_igmp_join(groups = groups1, src_list = ['6.6.6.6'],record_type = IGMP_V3_GR_TYPE_BLOCK_OLD,
835 iface = self.V_INF1)
836 mcastTraffic2 = McastTraffic(groups1, iface= 'veth2',src_ip = '6.6.6.6',
837 cb = self.send_mcast_cb, arg = igmpState1)
838 mcastTraffic2.start()
839 target1 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
840 assert target1 == 1, 'EXPECTED FAILURE'
Chetan Gaonker717b2942016-05-13 17:42:59 -0700841 log.info('Interface is still receiving from old multicast group data %s even after we send block list' %groups1)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700842 mcastTraffic2.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -0700843
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700844 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+30)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700845 def test_igmp_include_to_block_src_list(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700846 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700847 def igmp_include_to_block_src_list():
848 self.igmp_include_to_block_src_list(df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700849 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700850 reactor.callLater(0, igmp_include_to_block_src_list)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700851 return df
852
853
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700854 def igmp_change_to_include_src_list(self, df = None):
855 groups1 = [self.random_mcast_ip()]
856 src_list = ['4.4.4.4','6.6.6.6']
857 self.onos_ssm_table_load(groups1,src_list = src_list)
858 self.send_igmp_leave(groups = groups1, src_list = src_list,
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700859 iface = self.V_INF1, delay = 2)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700860 if df is None:
861 df = defer.Deferred()
862 igmpState1 = IGMPTestState(groups = groups1, df = df)
863 igmpStateRecv1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700864 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2',src_ip = src_list[0],
865 cb = self.send_mcast_cb, arg = igmpState1)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700866 mcastTraffic1.start()
867 join_state1 = IGMPTestState(groups = groups1)
868 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
869 assert target1 == 1, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700870 log.info('Interface is not receiving traffic from multicast groups %s' %groups1)
871 mcastTraffic1.stop()
872 self.send_igmp_join(groups = groups1, src_list = src_list,record_type = IGMP_V3_GR_TYPE_INCLUDE,
873 iface = self.V_INF1)
874 mcastTraffic2 = McastTraffic(groups1, iface= 'veth2',src_ip = src_list[1],
875 cb = self.send_mcast_cb, arg = igmpState1)
876 mcastTraffic2.start()
877 target1 = self.igmp_recv_task(self.V_INF1, groups1, join_state1)
878 mcastTraffic2.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -0700879
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700880 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700881 def test_igmp_change_to_include_src_list(self):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700882 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700883 def igmp_change_to_include_src_list():
884 self.igmp_change_to_include_src_list(df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700885 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700886 reactor.callLater(0, igmp_change_to_include_src_list)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700887 return df
888
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700889 #this test case failing because group in include receiving multicast traffic from any of the source
890 def igmp_exclude_to_allow_src_list(self, df = None):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700891 groups1 = (self.MGROUP1,)
892 groups2 = (self.MGROUP2,)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700893 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 -0700894 self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4'],
895 iface = self.V_INF1, delay = 2)
A.R Karthick95d044e2016-06-10 18:44:36 -0700896
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700897 dst_mac = '01:00:5e:01:02:03'
898 src_ip = '2.2.2.2'
899 if df is None:
900 df = defer.Deferred()
901 igmpState1 = IGMPTestState(groups = groups1, df = df)
902 igmpStateRecv1 = IGMPTestState(groups = groups1, df = df)
903 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
904 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
905 mcastTraffic1.start()
906 join_state1 = IGMPTestState(groups = groups1)
907 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
908 assert target1 == 1, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700909 log.info('Interface is not receiving traffic from multicast groups %s' %groups1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700910 self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
911 (['6.6.6.6', '7.7.7.7', '8.8.8.8'], ['6.6.6.6', '5.5.5.5']),
912 intf = self.V_INF1, delay = 2)
913 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
914 assert target1 == 1, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700915 log.info('Interface is not receiving traffic from multicast groups %s' %groups1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700916 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -0700917
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700918 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700919 def test_igmp_exclude_to_allow_src_list(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700920 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700921 def igmp_exclude_to_allow_src_list():
922 self.igmp_exclude_to_allow_src_list(df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700923 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700924 reactor.callLater(0, igmp_exclude_to_allow_src_list)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700925 return df
926
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700927 def igmp_exclude_to_block_src_list(self, df = None):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700928 groups1 = (self.MGROUP1,)
929 groups2 = (self.MGROUP2,)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700930 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 -0700931 self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4'],
932 iface = self.V_INF1, delay = 2)
A.R Karthick95d044e2016-06-10 18:44:36 -0700933
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700934 dst_mac = '01:00:5e:01:02:03'
935 src_ip = '2.2.2.2'
936 if df is None:
937 df = defer.Deferred()
938 igmpState1 = IGMPTestState(groups = groups1, df = df)
939 igmpStateRecv1 = IGMPTestState(groups = groups1, df = df)
940 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
941 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
942 mcastTraffic1.start()
943 join_state1 = IGMPTestState(groups = groups1)
944 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
945 assert target1 == 1, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700946 log.info('Interface is not receiving traffic from multicast groups %s' %groups1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700947 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'],
948 iface = self.V_INF1, delay = 2)
949 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
950 assert target1 == 1, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700951 log.info('Interface is not receiving traffic from multicast groups %s' %groups1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700952 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -0700953
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700954 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700955 def test_igmp_exclude_to_block_src_list(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700956 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700957 def igmp_exclude_to_block_src_list():
958 self.igmp_exclude_to_block_src_list(df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700959 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700960 reactor.callLater(0, igmp_exclude_to_block_src_list)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700961 return df
962
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700963 #this test case failing because group in include mode recieves traffic from other sources also.
964 def igmp_new_src_list(self, df = None):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700965 groups1 = (self.MGROUP1,)
966 groups2 = (self.MGROUP2,)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700967 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 -0700968 self.igmp_send_joins_different_groups_srclist(groups1+groups2,
969 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
970 intf = self.V_INF1, delay = 2)
971 dst_mac = '01:00:5e:01:02:03'
972 src_ip = '6.6.6.6'
973 if df is None:
974 df = defer.Deferred()
975 igmpState1 = IGMPTestState(groups = groups1, df = df)
976 igmpStateRecv1 = IGMPTestState(groups = groups1, df = df)
977 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
978 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
979 mcastTraffic1.start()
980 join_state1 = IGMPTestState(groups = groups1)
981 target1 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
982 assert target1 == 1, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700983 log.info('Interface is not receiving traffic from multicast groups %s' %groups1)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700984 self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700985 (['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 -0700986 intf = self.V_INF1, delay = 2)
987 target2 = self.igmp_recv_task(self.V_INF1, groups1, join_state1)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700988 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 -0700989 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -0700990
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700991 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700992 def test_igmp_new_src_list(self):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700993 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700994 def igmp_new_src_list():
995 self.igmp_new_src_list(df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700996 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700997 reactor.callLater(0, igmp_new_src_list)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700998 return df
999
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001000 def igmp_block_old_src_list(self, df = None):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001001 groups1 = (self.MGROUP1,)
1002 groups2 = (self.MGROUP2,)
1003 groups = groups1 + groups2
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001004 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 -07001005 self.igmp_send_joins_different_groups_srclist(groups,
1006 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
1007 intf = self.V_INF1, delay = 2)
1008 dst_mac = '01:00:5e:02:02:03'
1009 src_ip = '5.5.5.5'
1010 if df is None:
1011 df = defer.Deferred()
1012 igmpState1 = IGMPTestState(groups = groups2, df = df)
1013 igmpStateRecv1 = IGMPTestState(groups = groups2, df = df)
1014 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1015 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1016 mcastTraffic1.start()
1017 join_state1 = IGMPTestState(groups = groups2)
1018 target1 = self.igmp_recv_task(self.V_INF1, groups2, join_state1)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001019 log.info('Interface is receiving traffic from multicast groups %s' %groups2)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001020 self.igmp_send_joins_different_groups_srclist(groups,
1021 (['6.6.6.6', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '7.7.7.7']),
1022 intf = self.V_INF1, delay = 2)
1023 target2 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1)
Chetan Gaonker7791bda2016-05-12 17:36:52 -07001024 assert target2 == 2, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001025 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 -07001026 mcastTraffic1.stop()
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001027
1028 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001029 def test_igmp_block_old_src_list(self):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001030 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001031 def igmp_block_old_src_list():
1032 self.igmp_block_old_src_list(df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001033 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001034 reactor.callLater(0, igmp_block_old_src_list)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001035 return df
1036
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001037 def igmp_include_empty_src_list(self, df = None):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001038 groups1 = (self.MGROUP1,)
1039 groups2 = (self.MGROUP2,)
1040 groups = groups1 + groups2
1041 self.igmp_send_joins_different_groups_srclist(groups,
1042 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['']),
1043 intf = self.V_INF1, delay = 2)
1044 dst_mac = '01:00:5e:02:02:03'
1045 src_ip = '5.5.5.5'
1046 if df is None:
1047 df = defer.Deferred()
1048 igmpState1 = IGMPTestState(groups = groups2, df = df)
1049 igmpStateRecv1 = IGMPTestState(groups = groups2, df = df)
1050 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1051 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1052 mcastTraffic1.start()
1053 join_state1 = IGMPTestState(groups = groups2)
1054 target1 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1)
1055 assert target1==1, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001056 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 -07001057 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001058
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001059 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001060 def test_igmp_include_empty_src_list(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001061 ## '''Disabling this test as scapy IGMP doesn't work with empty source lists'''
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001062 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001063 def igmp_include_empty_src_list():
1064 self.igmp_include_empty_src_list(df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001065 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001066 reactor.callLater(0, igmp_include_empty_src_list)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001067 return df
1068
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001069 def igmp_exclude_empty_src_list(self, df = None):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001070 groups1 = (self.MGROUP1,)
1071 groups2 = (self.MGROUP2,)
1072 groups = groups1 + groups2
1073 self.send_igmp_leave(groups = groups2, src_list = [''], iface = self.V_INF1, delay = 2)
1074 dst_mac = '01:00:5e:02:02:03'
1075 src_ip = '5.5.5.5'
1076 if df is None:
1077 df = defer.Deferred()
1078 igmpState1 = IGMPTestState(groups = groups2, df = df)
1079 igmpStateRecv1 = IGMPTestState(groups = groups2, df = df)
1080 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1081 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1082 mcastTraffic1.start()
1083 join_state1 = IGMPTestState(groups = groups2)
1084 target1 = self.igmp_recv_task(self.V_INF1, groups2, join_state1)
1085 log.info('Interface is receiving multicast groups %s' %groups2)
1086 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001087
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001088 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001089 def test_igmp_exclude_empty_src_list(self):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001090 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001091 def igmp_exclude_empty_src_list():
1092 self.igmp_exclude_empty_src_list()
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001093 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001094 reactor.callLater(0, igmp_exclude_empty_src_list)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001095 return df
1096
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001097 def igmp_join_sourceip_0_0_0_0(self, df = None):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001098 groups1 = (self.MGROUP1,)
1099 groups2 = (self.MGROUP2,)
1100 groups = groups1 + groups2
1101 ip_src = '0.0.0.0'
1102 self.igmp_send_joins_different_groups_srclist(groups,
1103 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['5.5.5.5']),
1104 intf = self.V_INF1, delay = 2, ip_src = ip_src)
1105 ip_src = self.IP_SRC
1106 dst_mac = '01:00:5e:02:02:03'
1107 src_ip = '5.5.5.5'
1108 if df is None:
1109 df = defer.Deferred()
1110 igmpState1 = IGMPTestState(groups = groups2, df = df)
1111 igmpStateRecv1 = IGMPTestState(groups = groups2, df = df)
1112 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1113 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1114 mcastTraffic1.start()
1115 join_state1 = IGMPTestState(groups = groups2)
1116 target1 = self.igmp_recv_task(self.V_INF1, groups2, join_state1)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001117 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 -07001118 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001119
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001120 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001121 def test_igmp_join_sourceip_0_0_0_0(self):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001122 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001123 def igmp_join_sourceip_0_0_0_0():
1124 self.igmp_join_sourceip_0_0_0_0(df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001125 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001126 reactor.callLater(0, igmp_join_sourceip_0_0_0_0)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001127 return df
1128
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001129 def igmp_invalid_join_packet(self, df = None):
Chetan Gaonker586fec32016-04-29 17:33:54 -07001130 groups1 = (self.MGROUP1,)
1131 groups2 = (self.MINVALIDGROUP1,)
1132 groups = groups1 + groups2
1133 ip_src = '1.1.1.1'
1134 self.igmp_send_joins_different_groups_srclist(groups,
1135 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['5.5.5.5']),
1136 intf = self.V_INF1, delay = 2, ip_src = ip_src)
1137 ip_src = self.IP_SRC
1138 dst_mac = '01:00:5e:02:02:03'
1139 src_ip = '5.5.5.5'
1140 if df is None:
1141 df = defer.Deferred()
1142 igmpState1 = IGMPTestState(groups = groups2, df = df)
1143 igmpStateRecv1 = IGMPTestState(groups = groups2, df = df)
1144 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1145 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1146 mcastTraffic1.start()
1147 join_state1 = IGMPTestState(groups = groups2)
1148 target1 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1)
1149 assert target1==1, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001150 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 -07001151 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001152
Chetan Gaonker586fec32016-04-29 17:33:54 -07001153 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001154 def test_igmp_invalid_join_packet(self):
Chetan Gaonker586fec32016-04-29 17:33:54 -07001155 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001156 def igmp_invalid_join_packet():
1157 self.igmp_invalid_join_packet(df = df)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001158 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001159 reactor.callLater(0, igmp_invalid_join_packet)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001160 return df
1161
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001162 def igmp_join_data_receiving_during_subscriber_link_toggle(self, df = None):
Chetan Gaonker586fec32016-04-29 17:33:54 -07001163 groups1 = (self.MGROUP1,)
1164 groups2 = (self.MGROUP2,)
1165 groups = groups1 + groups2
1166 ip_src = '1.1.1.1'
1167 self.igmp_send_joins_different_groups_srclist(groups,
1168 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['5.5.5.5']),
1169 intf = self.V_INF1, delay = 2, ip_src = ip_src)
1170 ip_src = self.IP_SRC
1171 dst_mac = '01:00:5e:02:02:03'
1172 src_ip = '5.5.5.5'
1173 if df is None:
1174 df = defer.Deferred()
1175 igmpState1 = IGMPTestState(groups = groups2, df = df)
1176 igmpStateRecv1 = IGMPTestState(groups = groups2, df = df)
1177 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1178 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1179 mcastTraffic1.start()
1180 join_state1 = IGMPTestState(groups = groups2)
1181 target1 = self.igmp_recv_task(self.V_INF1, groups2, join_state1)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001182 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 -07001183 os.system('ifconfig '+self.V_INF1+' down')
1184 log.info(' the self.V_INF1 %s is down now ' %self.V_INF1)
1185 os.system('ifconfig '+self.V_INF1)
1186 time.sleep(10)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001187 os.system('ifconfig '+self.V_INF1+' up')
1188 os.system('ifconfig '+self.V_INF1)
1189 log.info(' the self.V_INF1 %s is up now ' %self.V_INF1)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001190 target1 = self.igmp_recv_task(self.V_INF1, groups2, join_state1)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001191 log.info('Interface is receiving traffic from multicast groups %s when we nterface up after down ' %groups2)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001192 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001193
Chetan Gaonker586fec32016-04-29 17:33:54 -07001194 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001195 def test_igmp_join_data_received_during_subscriber_link_toggle(self):
Chetan Gaonker586fec32016-04-29 17:33:54 -07001196 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001197 def igmp_join_data_received_during_subscriber_link_toggle():
1198 self.igmp_join_data_received_during_subscriber_link_toggle(df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001199 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001200 reactor.callLater(0, igmp_join_data_received_during_subscriber_link_toggle)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001201 return df
1202
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001203 def igmp_join_data_received_during_channel_distributor_link_toggle(self, df = None):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001204 groups1 = (self.MGROUP1,)
1205 groups2 = (self.MGROUP2,)
1206 groups = groups1 + groups2
1207 ip_src = '1.1.1.1'
1208 self.igmp_send_joins_different_groups_srclist(groups,
1209 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['5.5.5.5', '6.6.6.6']),
1210 intf = self.V_INF1, delay = 2, ip_src = ip_src)
1211 ip_src = self.IP_SRC
1212 dst_mac1 = '01:00:5e:01:02:03'
1213 dst_mac2 = '01:00:5e:02:02:03'
1214 src_ip2 = '5.5.5.5'
1215 src_ip1 = '2.2.2.2'
1216 if df is None:
1217 df = defer.Deferred()
1218 igmpState1 = IGMPTestState(groups = groups1, df = df)
1219 igmpState2 = IGMPTestState(groups = groups2, df = df)
1220 igmpStateRecv1 = IGMPTestState(groups = groups1, df = df)
1221 igmpStateRecv2 = IGMPTestState(groups = groups2, df = df)
1222 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac1,
1223 src_ip = src_ip1, cb = self.send_mcast_cb, arg = igmpState1)
1224 mcastTraffic2 = McastTraffic(groups2, iface= 'veth3', dst_mac = dst_mac2,
1225 src_ip = src_ip2, cb = self.send_mcast_cb, arg = igmpState2)
1226 mcastTraffic1.start()
1227 mcastTraffic2.start()
1228 join_state1 = IGMPTestState(groups = groups1)
1229 join_state2 = IGMPTestState(groups = groups2)
1230 target1 = self.igmp_recv_task(self.V_INF1, groups1, join_state1)
1231 target2 = self.igmp_recv_task(self.V_INF1, groups2, join_state2)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001232 mcastTraffic1.stop()
1233 os.system('ifconfig '+'veth2'+' down')
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001234 os.system('ifconfig '+'veth2')
1235 time.sleep(10)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001236 target2 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001237 target1 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
1238 assert target1==1, 'EXPECTED FAILURE'
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001239 os.system('ifconfig '+'veth2'+' up')
1240 os.system('ifconfig '+'veth2')
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001241 time.sleep(10)
1242 mcastTraffic1.start()
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001243 target1 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
1244 target2 = self.igmp_recv_task(self.V_INF1, groups2, join_state2)
1245 target2 = self.igmp_recv_task(self.V_INF1, groups2, join_state2)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001246 mcastTraffic2.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001247
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001248 ## This test case is failing to receive traffic from multicast data from defferent channel interfaces TO-DO
1249 ###### TO DO scenario #######
1250 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+60)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001251 def test_igmp_join_data_received_during_channel_distributors_link_toggle(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001252 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001253 def igmp_join_data_receiving_during_channel_distributor_link_toggle():
1254 self.igmp_join_data_receiving_during_channel_distributor_link_toggle(df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001255 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001256 reactor.callLater(0, igmp_join_data_receiving_during_channel_distributor_link_toggle)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001257 return df
Chetan Gaonker586fec32016-04-29 17:33:54 -07001258
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001259 def igmp_invalidClassD_IP_join_packet(self, df = None):
Chetan Gaonker586fec32016-04-29 17:33:54 -07001260 groups1 = (self.MGROUP1,)
1261 groups2 = (self.MINVALIDGROUP2,)
1262 groups = groups1 + groups2
1263 ip_src = '1.1.1.1'
1264 self.igmp_send_joins_different_groups_srclist(groups,
1265 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['5.5.5.5']),
1266 intf = self.V_INF1, delay = 2, ip_src = ip_src)
1267 ip_src = self.IP_SRC
1268 dst_mac = '01:00:5e:02:02:03'
1269 src_ip = '5.5.5.5'
1270 if df is None:
1271 df = defer.Deferred()
1272 igmpState1 = IGMPTestState(groups = groups2, df = df)
1273 igmpStateRecv1 = IGMPTestState(groups = groups2, df = df)
1274 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1275 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1276 mcastTraffic1.start()
1277 join_state1 = IGMPTestState(groups = groups2)
1278 target1 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1)
1279 assert target1==1, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001280 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 -07001281 mcastTraffic1.stop()
Chetan Gaonker586fec32016-04-29 17:33:54 -07001282
1283 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001284 def test_igmp_invalid_class_d_ip_for_join_packet(self):
Chetan Gaonker586fec32016-04-29 17:33:54 -07001285 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001286 def igmp_invalidClass_D_IP_join_packet():
1287 self.igmp_invalidClass_D_IP_join_packet(df = df)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001288 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001289 reactor.callLater(0, igmp_invalidClassD_IP_join_packet)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001290 return df
1291
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001292 def igmp_invalidClassD_IP_as_srclistIP_join_packet(self, df = None):
Chetan Gaonker586fec32016-04-29 17:33:54 -07001293 groups1 = (self.MGROUP1,)
1294 groups2 = (self.MGROUP2,)
1295 groups = groups1 + groups2
1296 ip_src = '1.1.1.1'
1297 self.igmp_send_joins_different_groups_srclist(groups,
1298 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['239.5.5.5']),
1299 intf = self.V_INF1, delay = 2, ip_src = ip_src)
1300 ip_src = self.IP_SRC
1301 dst_mac = '01:00:5e:02:02:03'
1302 src_ip = '5.5.5.5'
1303 if df is None:
1304 df = defer.Deferred()
1305 igmpState1 = IGMPTestState(groups = groups2, df = df)
1306 igmpStateRecv1 = IGMPTestState(groups = groups2, df = df)
1307 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1308 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1309 mcastTraffic1.start()
1310 join_state1 = IGMPTestState(groups = groups2)
1311 target1 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1)
1312 assert target1==1, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001313 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 -07001314 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001315
Chetan Gaonker586fec32016-04-29 17:33:54 -07001316 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001317 def test_igmp_invalid_class_d_ip_as_srclist_ip_for_join_packet(self):
Chetan Gaonker586fec32016-04-29 17:33:54 -07001318 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001319 def igmp_invalidClassD_IP_as_srclistIP_join_packet():
1320 self.igmp_invalidClassD_IP_as_srclistIP_join_packet(df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001321 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001322 reactor.callLater(0, igmp_invalidClassD_IP_as_srclistIP_join_packet)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001323 return df
Chetan Gaonkerf72ca402016-05-02 16:29:32 -07001324
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001325 def igmp_general_query_recv_packet(self, df = None):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001326 groups1 = (self.MGROUP1,)
1327 groups2 = (self.MGROUP2,)
1328 groups = groups1 + groups2
1329 ip_src = '1.1.1.1'
1330 self.igmp_send_joins_different_groups_srclist(groups,
1331 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['5.5.5.5']),
1332 intf = self.V_INF1, delay = 2, ip_src = ip_src)
1333 ip_src = self.IP_SRC
1334 dst_mac = '01:00:5e:02:02:03'
1335 src_ip = '5.5.5.5'
1336 if df is None:
1337 df = defer.Deferred()
1338 igmpState1 = IGMPTestState(groups = groups2, df = df)
1339 igmpStateRecv1 = IGMPTestState(groups = groups2, df = df)
1340 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1341 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1342 mcastTraffic1.start()
1343 join_state1 = IGMPTestState(groups = groups2)
1344 log.info('Started delay to verify multicast data taraffic for group %s is received or not for 180 sec ' %groups2)
1345 time.sleep(100)
1346 target2 = self.igmp_recv_task(self.V_INF1, groups2, join_state1)
1347 log.info('Verified that multicast data for group %s is received after 100 sec ' %groups2)
1348 time.sleep(50)
1349 target2 = self.igmp_recv_task(self.V_INF1, groups2, join_state1)
1350 log.info('Verified that multicast data for group %s is received after 150 sec ' %groups2)
1351 time.sleep(30)
1352 target2 = self.igmp_recv_task(self.V_INF1, groups2, join_state1)
1353 log.info('Verified that multicast data for group %s is received after 180 sec ' %groups2)
1354 time.sleep(10)
1355 target2 = self.igmp_recv_task(self.V_INF1, groups2, join_state1)
1356 log.info('Verified that multicast data for group %s is received after 190 sec ' %groups2)
1357 target3 = mcastTraffic1.isRecvStopped()
1358 assert target3==False, 'EXPECTED FAILURE'
1359 log.info('Verified that multicast data for a group %s is still transmitting from a data interface' %groups2)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001360 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 -07001361 target1 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1)
1362 assert target1==1, 'EXPECTED FAILURE'
1363 log.info('Interface is not receiving multicast data for group %s' %groups2)
1364 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001365
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001366 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+250)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001367 def test_igmp_general_query_received_traffic(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001368 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001369 def igmp_general_query_recv_packet():
1370 self.igmp_general_query_recv_packet(df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001371 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001372 reactor.callLater(0, igmp_general_query_recv_packet)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001373 return df
A.R Karthick95d044e2016-06-10 18:44:36 -07001374
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001375 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+100)
1376 def test_igmp_query_received_on_joining_interface(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001377 groups = ['224.0.1.10', '225.0.0.10']
1378 leave_groups = ['224.0.1.10']
1379 df = defer.Deferred()
1380 igmpState = IGMPTestState(groups = groups, df = df)
1381 igmpStateRecv = IGMPTestState(groups = groups, df = df)
1382 igmpStateList = (igmpState, igmpStateRecv)
A.R Karthick95d044e2016-06-10 18:44:36 -07001383 mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb,
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001384 arg = igmpState)
1385 self.df = df
1386 self.mcastTraffic = mcastTraffic
1387 self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP)
A.R Karthick95d044e2016-06-10 18:44:36 -07001388
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001389 def igmp_srp_task(stateList):
1390 igmpSendState, igmpRecvState = stateList
1391 if not mcastTraffic.isRecvStopped():
1392 result = self.igmp_recv(igmpRecvState)
1393 reactor.callLater(0, igmp_srp_task, stateList)
1394 else:
1395 self.mcastTraffic.stop()
1396 self.recv_socket.close()
1397 self.igmp_verify_leave(stateList, leave_groups)
1398 self.df.callback(0)
1399
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001400 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 -07001401 self.send_igmp_join_recvQuery(groups)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001402 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 -07001403 mcastTraffic.start()
1404 self.test_timer = reactor.callLater(self.MCAST_TRAFFIC_TIMEOUT, self.mcast_traffic_timer)
1405 reactor.callLater(0, igmp_srp_task, igmpStateList)
1406 return df
1407
1408 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+190)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001409 def test_igmp_for_periodic_query_received_on_joining_interface(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001410 groups = ['224.0.1.10', '225.0.0.10']
1411 leave_groups = ['224.0.1.10']
1412 df = defer.Deferred()
1413 igmpState = IGMPTestState(groups = groups, df = df)
1414 igmpStateRecv = IGMPTestState(groups = groups, df = df)
1415 igmpStateList = (igmpState, igmpStateRecv)
A.R Karthick95d044e2016-06-10 18:44:36 -07001416 mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb,
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001417 arg = igmpState)
1418 self.df = df
1419 self.mcastTraffic = mcastTraffic
1420 self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP)
A.R Karthick95d044e2016-06-10 18:44:36 -07001421
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001422 def igmp_srp_task(stateList):
1423 igmpSendState, igmpRecvState = stateList
1424 if not mcastTraffic.isRecvStopped():
1425 result = self.igmp_recv(igmpRecvState)
1426 reactor.callLater(0, igmp_srp_task, stateList)
1427 else:
1428 self.mcastTraffic.stop()
1429 self.recv_socket.close()
1430 self.igmp_verify_leave(stateList, leave_groups)
1431 self.df.callback(0)
1432
1433 self.send_igmp_join_recvQuery(groups,3)
1434 return df
1435
1436 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+190)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001437 def test_igmp_for_periodic_query_received_and_checking_entry_deleted(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001438 groups = ['224.0.1.10', '225.0.0.10']
1439 leave_groups = ['224.0.1.10']
1440 df = defer.Deferred()
1441 igmpState = IGMPTestState(groups = groups, df = df)
1442 igmpStateRecv = IGMPTestState(groups = groups, df = df)
1443 igmpStateList = (igmpState, igmpStateRecv)
A.R Karthick95d044e2016-06-10 18:44:36 -07001444 mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb,
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001445 arg = igmpState)
1446 self.df = df
1447 self.mcastTraffic = mcastTraffic
1448 self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP)
A.R Karthick95d044e2016-06-10 18:44:36 -07001449
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001450 def igmp_srp_task(stateList):
1451 igmpSendState, igmpRecvState = stateList
1452 if not mcastTraffic.isRecvStopped():
1453 result = self.igmp_recv(igmpRecvState)
1454 reactor.callLater(0, igmp_srp_task, stateList)
1455 else:
1456 self.mcastTraffic.stop()
1457 self.recv_socket.close()
1458 self.igmp_verify_leave(stateList, leave_groups)
1459 self.df.callback(0)
1460
1461 self.send_igmp_join_recvQuery(groups,3)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001462 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 -07001463 mcastTraffic.start()
1464 self.test_timer = reactor.callLater(self.MCAST_TRAFFIC_TIMEOUT, self.mcast_traffic_timer)
1465 reactor.callLater(0, igmp_srp_task, igmpStateList)
1466 return df
1467
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001468 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+190)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001469 def test_igmp_member_query_interval_and_expiry_for_rejoining_interface(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001470 groups = ['224.0.1.10', '225.0.0.10']
1471 leave_groups = ['224.0.1.10']
1472 df = defer.Deferred()
1473 igmpState = IGMPTestState(groups = groups, df = df)
1474 igmpStateRecv = IGMPTestState(groups = groups, df = df)
1475 igmpStateList = (igmpState, igmpStateRecv)
A.R Karthick95d044e2016-06-10 18:44:36 -07001476 mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb,
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001477 arg = igmpState)
1478 self.df = df
1479 self.mcastTraffic = mcastTraffic
1480 self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP)
A.R Karthick95d044e2016-06-10 18:44:36 -07001481
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001482 def igmp_srp_task(stateList):
1483 igmpSendState, igmpRecvState = stateList
1484 if not mcastTraffic.isRecvStopped():
1485 result = self.igmp_recv(igmpRecvState)
1486 reactor.callLater(0, igmp_srp_task, stateList)
1487 else:
1488 self.mcastTraffic.stop()
1489 self.recv_socket.close()
1490 self.igmp_verify_leave(stateList, leave_groups)
1491 self.df.callback(0)
1492
1493 self.send_igmp_join_recvQuery(groups,3)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001494 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 -07001495 self.send_igmp_join(groups)
1496 mcastTraffic.start()
1497 self.test_timer = reactor.callLater(self.MCAST_TRAFFIC_TIMEOUT, self.mcast_traffic_timer)
1498 reactor.callLater(0, igmp_srp_task, igmpStateList)
1499 return df
1500
1501 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+50)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001502 def test_igmp_leave_received_group_and_source_specific_query(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001503 groups = ['224.0.1.10', '225.0.0.10']
1504 leave_groups = ['224.0.1.10']
1505 df = defer.Deferred()
1506 igmpState = IGMPTestState(groups = groups, df = df)
1507 igmpStateRecv = IGMPTestState(groups = groups, df = df)
1508 igmpStateList = (igmpState, igmpStateRecv)
A.R Karthick95d044e2016-06-10 18:44:36 -07001509 mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb,
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001510 arg = igmpState)
1511 self.df = df
1512 self.mcastTraffic = mcastTraffic
1513 self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP)
A.R Karthick95d044e2016-06-10 18:44:36 -07001514
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001515 def igmp_srp_task(stateList):
1516 igmpSendState, igmpRecvState = stateList
1517 if not mcastTraffic.isRecvStopped():
1518 result = self.igmp_recv(igmpRecvState)
1519 reactor.callLater(0, igmp_srp_task, stateList)
1520 else:
1521 self.mcastTraffic.stop()
1522 self.recv_socket.close()
1523 self.igmp_verify_leave(stateList, leave_groups)
1524 self.df.callback(0)
1525
1526 self.send_igmp_join(groups)
1527 self.send_igmp_leave_listening_group_specific_query(leave_groups, delay = 3)
1528 return df
1529
1530 def igmp_change_to_exclude_src_list_check_for_group_source_specific_query(self, df = None):
1531 groups1 = (self.MGROUP1,)
1532 groups2 = (self.MGROUP2,)
1533 self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
1534 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
1535 intf = self.V_INF1, delay = 2)
1536 dst_mac = '01:00:5e:01:02:03'
1537 src_ip = '2.2.2.2'
1538 if df is None:
1539 df = defer.Deferred()
1540 igmpState1 = IGMPTestState(groups = groups1, df = df)
1541 igmpStateRecv1 = IGMPTestState(groups = groups1, df = df)
1542 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
1543 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1544 mcastTraffic1.start()
1545 join_state1 = IGMPTestState(groups = groups1)
1546 target1 = self.igmp_recv_task(self.V_INF1, groups1, join_state1)
1547 self.send_igmp_leave_listening_group_specific_query(groups = groups1, src_list = ['2.2.2.2'], iface = self.V_INF1, delay =2)
1548 time.sleep(10)
1549 target2 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
1550 assert target2 == 1, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001551 log.info('Interface is not receiving traffic from multicast groups %s after sending CHANGE_TO_EXCLUDE' %groups2)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001552 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001553
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001554 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+60)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001555 def test_igmp_change_to_exclude_src_list_and_check_for_group_source_specific_query(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001556 df = defer.Deferred()
1557 def igmp_change_to_exclude_src_list_check_for_group_source_specific_query():
1558 self.igmp_change_to_exclude_src_list_check_for_group_source_specific_query(df = df)
1559 df.callback(0)
1560 reactor.callLater(0, igmp_change_to_exclude_src_list_check_for_group_source_specific_query)
1561 return df
1562
1563 def igmp_change_to_include_src_list_check_for_general_query(self, df = None):
1564 groups1 = (self.MGROUP1,)
1565 groups2 = (self.MGROUP2,)
1566 self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4'],
1567 iface = self.V_INF1, delay = 2)
1568 dst_mac = '01:00:5e:01:02:03'
1569 src_ip = '2.2.2.2'
1570 if df is None:
1571 df = defer.Deferred()
1572 igmpState1 = IGMPTestState(groups = groups1, df = df)
1573 igmpStateRecv1 = IGMPTestState(groups = groups1, df = df)
1574 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
1575 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1576 mcastTraffic1.start()
1577 join_state1 = IGMPTestState(groups = groups1)
1578 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
1579 assert target1 == 1, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001580 log.info('Interface is not receiving traffic from multicast groups %s' %groups1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001581 self.igmp_send_joins_different_groups_srclist_wait_query_packets(groups1 + groups2,
1582 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['6.6.6.6', '5.5.5.5']),
1583 intf = self.V_INF1, delay = 2,query_group1 = 'group1', query_group2 = None)
1584 time.sleep(10)
1585 target2 = self.igmp_recv_task(self.V_INF1, groups1, join_state1)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001586 log.info('Interface is receiving traffic from multicast groups %s after send Change to include message' %groups1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001587 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001588
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001589 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+80)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001590 def test_igmp_change_to_include_src_list_and_check_for_general_query(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001591 df = defer.Deferred()
1592 def igmp_change_to_include_src_list_check_for_general_query():
1593 self.igmp_change_to_include_src_list_check_for_general_query(df = df)
1594 df.callback(0)
1595 reactor.callLater(0, igmp_change_to_include_src_list_check_for_general_query)
1596 return df
1597
1598 def igmp_allow_new_src_list_check_for_general_query(self, df = None):
1599 groups1 = (self.MGROUP1,)
1600 groups2 = (self.MGROUP2,)
1601 self.igmp_send_joins_different_groups_srclist(groups1+groups2,
1602 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
1603 intf = self.V_INF1, delay = 2)
1604 dst_mac = '01:00:5e:01:02:03'
1605 src_ip = '6.6.6.6'
1606 if df is None:
1607 df = defer.Deferred()
1608 igmpState1 = IGMPTestState(groups = groups1, df = df)
1609 igmpStateRecv1 = IGMPTestState(groups = groups1, df = df)
1610 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
1611 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1612 mcastTraffic1.start()
1613 join_state1 = IGMPTestState(groups = groups1)
1614 target1 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
1615 #assert target1 == 1, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001616 log.info('Interface is not receiving traffic from multicast groups %s' %groups1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001617 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']),
1618 intf = self.V_INF1, delay = 2, query_group1 = 'group1', query_group2 = None)
1619 target2 = self.igmp_recv_task(self.V_INF1, groups1, join_state1)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001620 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 -07001621 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001622
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001623 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+80)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001624 def test_igmp_allow_new_src_list_and_check_for_general_query(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001625 df = defer.Deferred()
1626 def igmp_allow_new_src_list_check_for_general_query():
1627 self.igmp_allow_new_src_list_check_for_general_query(df = df)
1628 df.callback(0)
1629 reactor.callLater(0, igmp_allow_new_src_list_check_for_general_query)
1630 return df
1631
1632 def igmp_block_old_src_list_check_for_group_source_specific_query(self, df = None):
1633 groups1 = (self.MGROUP1,)
1634 groups2 = (self.MGROUP2,)
1635 groups = groups1 + groups2
1636 self.igmp_send_joins_different_groups_srclist(groups,
1637 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
1638 intf = self.V_INF1, delay = 2)
1639 dst_mac = '01:00:5e:02:02:03'
1640 src_ip = '5.5.5.5'
1641 if df is None:
1642 df = defer.Deferred()
1643 igmpState1 = IGMPTestState(groups = groups2, df = df)
1644 igmpStateRecv1 = IGMPTestState(groups = groups2, df = df)
1645 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1646 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1647 mcastTraffic1.start()
1648 join_state1 = IGMPTestState(groups = groups2)
1649 target1 = self.igmp_recv_task(self.V_INF1, groups2, join_state1)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001650 log.info('Interface is receiving traffic from multicast groups %s' %groups2)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001651 self.igmp_send_joins_different_groups_srclist_wait_query_packets(groups,
1652 (['6.6.6.6', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '7.7.7.7']),
1653 intf = self.V_INF1, delay = 2, query_group1 = 'group1', query_group2 = None)
1654 target2 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1)
1655 assert target2 == 1, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001656 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 -07001657 mcastTraffic1.stop()
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001658
1659 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+90)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001660 def test_igmp_block_old_src_list_and_check_for_group_source_specific_query(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001661 df = defer.Deferred()
1662 def igmp_block_old_src_list_check_for_group_source_specific_query():
1663 self.igmp_block_old_src_list_check_for_group_source_specific_query(df = df)
1664 df.callback(0)
1665 reactor.callLater(0, igmp_block_old_src_list_check_for_group_source_specific_query)
1666 return df
1667
1668 def igmp_include_to_allow_src_list_check_for_general_query(self, df = None):
1669 groups1 = (self.MGROUP1,)
1670 groups2 = (self.MGROUP2,)
1671 self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
1672 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
1673 intf = self.V_INF1, delay = 2)
1674 dst_mac = '01:00:5e:01:02:03'
1675 src_ip = '2.2.2.2'
1676 if df is None:
1677 df = defer.Deferred()
1678 igmpState1 = IGMPTestState(groups = groups1, df = df)
1679 igmpStateRecv1 = IGMPTestState(groups = groups1, df = df)
1680 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
1681 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1682 mcastTraffic1.start()
1683 join_state1 = IGMPTestState(groups = groups1)
1684 target1 = self.igmp_recv_task(self.V_INF1, groups1, join_state1)
1685 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)
1686 target1 = self.igmp_recv_task(self.V_INF1, groups1, join_state1)
1687 mcastTraffic1.stop()
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001688
1689 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+40)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001690 def test_igmp_include_to_allow_src_list_and_check_for_general_query(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001691 df = defer.Deferred()
1692 def igmp_include_to_allow_src_list_check_for_general_query():
1693 self.igmp_include_to_allow_src_list_check_for_general_query(df = df)
1694 df.callback(0)
1695 reactor.callLater(0, igmp_include_to_allow_src_list_check_for_general_query)
1696 return df
1697
1698 def igmp_include_to_block_src_list_check_for_group_source_specific_query(self, df = None):
1699 groups1 = (self.MGROUP1,)
1700 groups2 = (self.MGROUP2,)
1701 self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
1702 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
1703 intf = self.V_INF1, delay = 2)
1704 dst_mac = '01:00:5e:01:02:03'
1705 src_ip = '2.2.2.2'
1706 if df is None:
1707 df = defer.Deferred()
1708 igmpState1 = IGMPTestState(groups = groups1, df = df)
1709 igmpStateRecv1 = IGMPTestState(groups = groups1, df = df)
1710 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
1711 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1712 mcastTraffic1.start()
1713 join_state1 = IGMPTestState(groups = groups1)
1714 target1 = self.igmp_recv_task(self.V_INF1, groups1, join_state1)
1715 self.send_igmp_leave_listening_group_specific_query(groups = groups1, src_list = ['6.6.6.6','7.7.7.7'],
1716 iface = self.V_INF1, delay = 2)
1717 target1 = self.igmp_recv_task(self.V_INF1, groups1, join_state1)
1718 mcastTraffic1.stop()
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001719
1720 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+40)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001721 def test_igmp_include_to_block_src_list_and_check_for_group_source_specific_query(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001722 df = defer.Deferred()
1723 def igmp_include_to_block_src_list_check_for_group_source_specific_query():
1724 self.igmp_include_to_block_src_list_check_for_group_source_specific_query(df = df)
1725 df.callback(0)
1726 reactor.callLater(0, igmp_include_to_block_src_list_check_for_group_source_specific_query)
1727 return df
1728
1729 def igmp_exclude_to_allow_src_list_check_for_general_query(self, df = None):
1730 groups1 = (self.MGROUP1,)
1731 groups2 = (self.MGROUP2,)
1732 self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4'],
1733 iface = self.V_INF1, delay = 2)
A.R Karthick95d044e2016-06-10 18:44:36 -07001734
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001735 dst_mac = '01:00:5e:01:02:03'
1736 src_ip = '2.2.2.2'
1737 if df is None:
1738 df = defer.Deferred()
1739 igmpState1 = IGMPTestState(groups = groups1, df = df)
1740 igmpStateRecv1 = IGMPTestState(groups = groups1, df = df)
1741 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
1742 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1743 mcastTraffic1.start()
1744 join_state1 = IGMPTestState(groups = groups1)
1745 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
1746 assert target1 == 1, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001747 log.info('Interface is not receiving traffic from multicast groups %s' %groups1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001748 self.igmp_send_joins_different_groups_srclist_wait_query_packets(groups1 + groups2,
1749 (['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)
1750 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
1751 assert target1 == 1, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001752 log.info('Interface is not receiving traffic from multicast groups %s' %groups1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001753 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001754
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001755 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+90)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001756 def test_igmp_exclude_to_allow_src_list_and_check_for_general_query(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001757 df = defer.Deferred()
1758 def igmp_exclude_to_allow_src_list_check_for_general_query():
1759 self.igmp_exclude_to_allow_src_list_check_for_general_query(df = df)
1760 df.callback(0)
1761 reactor.callLater(0, igmp_exclude_to_allow_src_list_check_for_general_query)
1762 return df
1763
1764 def igmp_exclude_to_block_src_list_check_for_group_source_specific_query(self, df = None):
1765 groups1 = (self.MGROUP1,)
1766 groups2 = (self.MGROUP2,)
1767 self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4'],
1768 iface = self.V_INF1, delay = 2)
A.R Karthick95d044e2016-06-10 18:44:36 -07001769
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001770 dst_mac = '01:00:5e:01:02:03'
1771 src_ip = '2.2.2.2'
1772 if df is None:
1773 df = defer.Deferred()
1774 igmpState1 = IGMPTestState(groups = groups1, df = df)
1775 igmpStateRecv1 = IGMPTestState(groups = groups1, df = df)
1776 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
1777 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1778 mcastTraffic1.start()
1779 join_state1 = IGMPTestState(groups = groups1)
1780 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
1781 assert target1 == 1, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001782 log.info('Interface is not receiving traffic from multicast groups %s' %groups1)
A.R Karthick95d044e2016-06-10 18:44:36 -07001783 self.send_igmp_leave_listening_group_specific_query(groups = groups1,
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001784 src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4', '5.5.5.5', '7.7.7.7'],
1785 iface = self.V_INF1, delay = 2)
1786 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
1787 assert target1 == 1, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001788 log.info('Interface is not receiving traffic from multicast groups %s' %groups1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001789 mcastTraffic1.stop()
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001790
1791 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+40)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001792 def test_igmp_exclude_to_block_src_list_and_check_for_group_source_specific_query(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001793 df = defer.Deferred()
1794 def igmp_exclude_to_block_src_list_check_for_group_source_specific_query():
1795 self.igmp_exclude_to_block_src_list_check_for_group_source_specific_query(df = df)
1796 df.callback(0)
1797 reactor.callLater(0, igmp_exclude_to_block_src_list_check_for_group_source_specific_query)
1798 return df
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001799
1800 def iptomac(self, mcast_ip):
1801 mcast_mac = '01:00:5e:'
1802 octets = mcast_ip.split('.')
1803 second_oct = int(octets[1]) & 127
1804 third_oct = int(octets[2])
1805 fourth_oct = int(octets[3])
1806 mcast_mac = mcast_mac + format(second_oct,'02x') + ':' + format(third_oct, '02x') + ':' + format(fourth_oct, '02x')
1807 return mcast_mac
1808
1809 def send_multicast_data_traffic(self, group, intf= 'veth2',source = '1.2.3.4'):
1810 dst_mac = self.iptomac(group)
1811 eth = Ether(dst= dst_mac)
1812 ip = IP(dst=group,src=source)
1813 data = repr(monotonic.monotonic())
1814 sendp(eth/ip/data,count=20, iface = intf)
1815 pkt = (eth/ip/data)
1816 #log.info('multicast traffic packet %s'%pkt.show())
1817
1818 def verify_igmp_data_traffic(self, group, intf='veth0', source='1.2.3.4' ):
1819 log.info('verifying multicast traffic for group %s from source %s'%(group,source))
1820 self.success = False
1821 def recv_task():
1822 def igmp_recv_cb(pkt):
1823 #log.info('received multicast data packet is %s'%pkt.show())
1824 log.info('multicast data received for group %s from source %s'%(group,source))
1825 self.success = True
1826 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')
1827 t = threading.Thread(target = recv_task)
1828 t.start()
1829 self.send_multicast_data_traffic(group,source=source)
1830 t.join()
1831 return self.success
1832
1833 def test_igmp_include_exclude_modes(self):
1834 groups = ['224.2.3.4','230.5.6.7']
1835 src_list = ['2.2.2.2','3.3.3.3']
1836 dst_mac1 = self.iptomac(groups[0])
1837 dst_mac2 = self.iptomac(groups[1])
1838 self.onos_ssm_table_load(groups, src_list=src_list)
1839 self.send_igmp_join(groups = [groups[0]], src_list = src_list,record_type = IGMP_V3_GR_TYPE_INCLUDE,
1840 iface = self.V_INF1, delay = 2)
1841 self.send_igmp_join(groups = [groups[1]], src_list = src_list,record_type = IGMP_V3_GR_TYPE_EXCLUDE,
1842 iface = self.V_INF1, delay = 2)
1843 status = self.verify_igmp_data_traffic(groups[0],intf=self.V_INF1,source=src_list[0])
1844 assert_equal(status,True)
1845 status = self.verify_igmp_data_traffic(groups[1],intf = self.V_INF1,source= src_list[1])
1846 assert_equal(status,False)
1847
1848 def test_igmp_allow_new_source_mode(self):
1849 group = ['224.8.9.3']
1850 src_list = ['2.2.2.2','3.3.3.3']
1851 #dst_mac = self.iptomac(group[0])
1852 self.onos_ssm_table_load(group, src_list)
1853 self.send_igmp_join(groups = group, src_list = src_list[0],record_type = IGMP_V3_GR_TYPE_INCLUDE,
1854 iface = self.V_INF1, delay = 1)
1855 status = self.verify_igmp_data_traffic(group[0], intf=self.V_INF1,source = src_list[0])
1856 assert_equal(status,True) # expecting igmp data traffic from source src_list[0]
1857 self.send_igmp_join(groups = group, src_list = src_list[1],record_type = IGMP_V3_GR_TYPE_ALLOW_NEW,
1858 iface = self.V_INF1, delay = 1)
1859 for src in src_list:
1860 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1, source=src)
1861 assert_equal(status,True) # expecting igmp data traffic from both sources
1862
1863
1864 def test_igmp_include_to_exclude_mode_change(self):
1865 group = ['224.2.3.4']
1866 src_list = ['2.2.2.2','3.3.3.3']
1867 dst_mac = self.iptomac(group[0])
1868 self.onos_ssm_table_load(group, src_list)
1869 self.send_igmp_join(groups = group, src_list = src_list[0],record_type = IGMP_V3_GR_TYPE_INCLUDE,
1870 iface = self.V_INF1, delay = 1)
1871 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source= src_list[0])
1872 assert_equal(status,True) # expecting igmp data traffic from source src_list[0]
1873 self.send_igmp_join(groups = group, src_list = src_list[1],record_type = IGMP_V3_GR_TYPE_EXCLUDE,
1874 iface = self.V_INF1, delay = 1)
1875 for src in src_list:
1876 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source= src)
1877 assert_equal(status,False) # expecting igmp data traffic from both sources
1878
1879 def test_igmp_exclude_to_include_mode_change(self):
1880 group = ['224.2.3.4']
1881 src = ['2.2.2.2']
1882 dst_mac = self.iptomac(group[0])
1883 self.onos_ssm_table_load(group, src)
1884 self.send_igmp_join(groups = group, src_list = src,record_type = IGMP_V3_GR_TYPE_EXCLUDE,
1885 iface = self.V_INF1, delay = 1)
1886 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source=src[0])
1887 assert_equal(status,False) # not expecting igmp data traffic from source src_list[0]
1888 self.send_igmp_join(groups = group, src_list = src,record_type = IGMP_V3_GR_TYPE_INCLUDE,
1889 iface = self.V_INF1, delay = 1)
1890 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source = src[0])
1891 assert_equal(status,True) # expecting igmp data traffic from both sources
1892
1893 #this test case wotks properly if the snooping device(ONOS) have multicast router connected.
1894 def test_igmp_to_include_mode_with_null_source(self):
1895 groups = ['224.2.3.4','230.7.9.8']
1896 src = ['192.168.12.34']
1897 dst_mac = []
1898 dst_mac.append(self.iptomac(groups[0]))
1899 dst_mac.append(self.iptomac(groups[1]))
1900 self.onos_ssm_table_load(groups, src)
1901 self.send_igmp_join(groups = groups, src_list = src,record_type = IGMP_V3_GR_TYPE_INCLUDE,
1902 iface = self.V_INF1, delay = 1)
1903 for grp in groups:
1904 status = self.verify_igmp_data_traffic(grp,intf=self.V_INF1,source= src[0])
1905 assert_equal(status,True) # not expecting igmp data traffic from source src_list[0]
1906 #sending leave packet for group groups[1]
1907 self.send_igmp_join(groups = [groups[1]], src_list = [],record_type = IGMP_V3_GR_TYPE_CHANGE_TO_INCLUDE,
1908 iface = self.V_INF1, delay = 1)
1909 for grp in groups:
1910 status = self.verify_igmp_data_traffic(grp,intf=self.V_INF1,source= src[0])
1911 if grp is groups[0]:
1912 assert_equal(status,True) # expecting igmp data traffic to group groups[0]
1913 else:
1914 assert_equal(status,False) # not expecting igmp data traffic to group groups[1]
1915
1916 def test_igmp_to_include_mode(self):
1917 group = ['229.9.3.6']
1918 src_list = ['192.168.12.34','192.18.1.34']
1919 dst_mac = []
1920 dst_mac = self.iptomac(group[0])
1921 self.onos_ssm_table_load(group, src_list)
1922 self.send_igmp_join(groups = group, src_list = [src_list[0]],record_type = IGMP_V3_GR_TYPE_INCLUDE,
1923 iface = self.V_INF1, delay = 1)
1924 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source=src_list[0])
1925 assert_equal(status,True) # not expecting igmp data traffic from source src_list[0]
1926 self.send_igmp_join(groups = group, src_list = src_list,record_type = IGMP_V3_GR_TYPE_CHANGE_TO_INCLUDE,
1927 iface = self.V_INF1, delay = 1)
1928 for src in src_list:
1929 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source= src)
1930 assert_equal(status,True) # expecting igmp data traffic to group groups[0]
1931
1932 #this test case passed only if mulitcast router connected to ONOS.
1933 def test_igmp_blocking_old_source_mode(self):
1934 group = ['224.2.3.4']
1935 src_list = ['2.2.2.2','3.3.3.3']
1936 dst_mac = self.iptomac(group[0])
1937 self.onos_ssm_table_load(group, src_list)
1938 self.send_igmp_join(groups = group, src_list = src_list,record_type = IGMP_V3_GR_TYPE_INCLUDE,
1939 iface = self.V_INF1, delay = 1)
1940 for src in src_list:
1941 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1, source=src)
1942 assert_equal(status,True) # expecting igmp data traffic from source src_list[0]
1943 self.send_igmp_join(groups = group, src_list = [src_list[1]],record_type = IGMP_V3_GR_TYPE_BLOCK_OLD,
1944 iface = self.V_INF1, delay = 1)
1945 for src in src_list:
1946 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1, source=src)
1947 if src is src_list[0]:
1948 assert_equal(status,True) # expecting igmp data traffic from source src_list[0]
1949 else:
1950 assert_equal(status,False) # not expecting igmp data traffic from source src_list[1]
1951
1952 def test_igmp_multiple_joins_and_data_verification_with_100_groups(self):
1953 groups = []
1954 sources = []
1955 count = 1
1956 mcastips = self.mcast_ip_range(start_ip = '226.0.0.1',end_ip = '226.0.5.254')
1957 sourceips = self.source_ip_range(start_ip = '10.10.0.1',end_ip = '10.10.5.254')
1958 while count<=100:
1959 group = random.choice(mcastips)
1960 source = random.choice(sourceips)
1961 if group in groups:
1962 pass
1963 else:
1964 log.info('group and source are %s and %s'%(group,source))
1965 groups.append(group)
1966 sources.append(source)
1967 count += 1
1968 self.onos_ssm_table_load(groups,src_list=sources,flag=True)
1969 for i in range(100):
1970 self.send_igmp_join(groups = [groups[i]], src_list = [sources[i]],record_type = IGMP_V3_GR_TYPE_INCLUDE,
1971 iface = self.V_INF1)
1972 status = self.verify_igmp_data_traffic(groups[i],intf=self.V_INF1,source=sources[i])
1973 assert_equal(status, True)
1974 log.info('data received for group %s from source %s'%(groups[i],sources[i]))
1975
1976 def test_igmp_multiple_joins_with_data_verification_and_leaving_100_groups(self):
1977 groups = []
1978 sources = []
1979 count = 1
1980 mcastips = self.mcast_ip_range(start_ip = '226.0.0.1',end_ip = '226.0.5.254')
1981 sourceips = self.source_ip_range(start_ip = '10.10.0.1',end_ip = '10.10.5.254')
1982 while count<=100:
1983 group = random.choice(mcastips)
1984 source = random.choice(sourceips)
1985 if group in groups:
1986 pass
1987 else:
1988 log.info('group and source are %s and %s'%(group,source))
1989 groups.append(group)
1990 sources.append(source)
1991 count += 1
1992 self.onos_ssm_table_load(groups,src_list=sources,flag=True)
1993 for i in range(100):
1994 self.send_igmp_join(groups = [groups[i]], src_list = [sources[i]],record_type = IGMP_V3_GR_TYPE_INCLUDE,
1995 iface = self.V_INF1)
1996 status = self.verify_igmp_data_traffic(groups[i],intf=self.V_INF1,source=sources[i])
1997 assert_equal(status, True)
1998 log.info('data received for group %s from source %s'%(groups[i],sources[i]))
1999 self.send_igmp_join(groups = [groups[i]], src_list = [sources[i]],record_type = IGMP_V3_GR_TYPE_CHANGE_TO_EXCLUDE,
2000 iface = self.V_INF1, delay = 1)
2001 status = self.verify_igmp_data_traffic(groups[i],intf=self.V_INF1,source=sources[i])
2002 assert_equal(status, False)
2003 log.info("data not received for group %s from source %s after changing group mode to 'TO-EXCLUDE' mode"%(groups[i],sources[i]))
2004
2005 def test_igmp_group_source_for_only_config_with_1000_entries(self):
2006 groups = []
2007 sources = []
2008 count = 1
2009 mcastips = self.mcast_ip_range(start_ip = '229.0.0.1',end_ip = '229.0.50.254')
2010 sourceips = self.source_ip_range(start_ip = '10.10.0.1',end_ip = '10.10.50.254')
2011 while count<=1000:
2012 group = random.choice(mcastips)
2013 source = random.choice(sourceips)
2014 if group in groups:
2015 pass
2016 else:
2017 log.info('group and source are %s and %s'%(group,source))
2018 groups.append(group)
2019 sources.append(source)
2020 count += 1
2021 self.onos_ssm_table_load(groups,src_list=sources,flag=True)
2022
2023 def test_igmp_from_exclude_to_include_mode_with_100_groups(self):
2024 groups = []
2025 sources = []
2026 count = 1
2027 mcastips = self.mcast_ip_range(start_ip = '229.0.0.1',end_ip = '229.0.10.254')
2028 sourceips = self.source_ip_range(start_ip = '10.10.0.1',end_ip = '10.10.10.254')
2029 while count<=100:
2030 group = random.choice(mcastips)
2031 source = random.choice(sourceips)
2032 if group in groups:
2033 pass
2034 else:
2035 log.info('group and source are %s and %s'%(group,source))
2036 groups.append(group)
2037 sources.append(source)
2038 count += 1
2039 self.onos_ssm_table_load(groups,src_list=sources,flag=True)
2040 for i in range(100):
2041 self.send_igmp_join(groups = [groups[i]], src_list = [sources[i]],record_type = IGMP_V3_GR_TYPE_EXCLUDE,
2042 iface = self.V_INF1)
2043 status = self.verify_igmp_data_traffic(groups[i],intf=self.V_INF1,source=sources[i])
2044 assert_equal(status, False)
2045 log.info('data not received for group %s from source %s as expected'%(groups[i],sources[i]))
2046 self.send_igmp_join(groups = [groups[i]], src_list = [sources[i]],record_type = IGMP_V3_GR_TYPE_INCLUDE,
2047 iface = self.V_INF1)
2048 status = self.verify_igmp_data_traffic(groups[i],intf=self.V_INF1,source=sources[i])
2049 assert_equal(status, True)
2050 log.info("data received for group %s from source %s after changing group mode to 'TO-INCLUDE' mode"%(groups[i],sources[i]))
2051
2052 def test_igmp_with_multiple_joins_and_data_verify_with_1000_groups(self):
2053 groups = []
2054 sources = []
2055 count = 1
2056 mcastips = self.mcast_ip_range(start_ip = '229.0.0.1',end_ip = '229.0.30.254')
2057 sourceips = self.source_ip_range(start_ip = '10.10.0.1',end_ip = '10.10.30.254')
2058 while count<=1000:
2059 group = random.choice(mcastips)
2060 source = random.choice(sourceips)
2061 if group in groups:
2062 pass
2063 else:
2064 log.info('group and source are %s and %s'%(group,source))
2065 groups.append(group)
2066 sources.append(source)
2067 count += 1
2068 self.onos_ssm_table_load(groups,src_list=sources,flag=True)
2069 for i in range(1000):
2070 self.send_igmp_join(groups = [groups[i]], src_list = [sources[i]],record_type = IGMP_V3_GR_TYPE_INCLUDE,
2071 iface = self.V_INF1)
2072 status = self.verify_igmp_data_traffic(groups[i],intf=self.V_INF1,source=sources[i])
2073 assert_equal(status, True)
2074 log.info('data received for group %s from source %s - %d'%(groups[i],sources[i],i))
2075
2076 def test_igmp_with_multiple_joins_and_data_verify_with_5000_groups(self):
2077 groups = []
2078 sources = []
2079 count = 1
2080 mcastips = self.mcast_ip_range(start_ip = '231.39.19.121',end_ip = '231.40.30.25')
2081 sourceips = self.source_ip_range(start_ip = '192.168.56.43',end_ip = '192.169.110.30')
2082 while count<=5000:
2083 group = random.choice(mcastips)
2084 source = random.choice(sourceips)
2085 if group in groups:
2086 pass
2087 else:
2088 log.info('group and source are %s and %s'%(group,source))
2089 groups.append(group)
2090 sources.append(source)
2091 count += 1
2092 self.onos_ssm_table_load(groups,src_list=sources,flag=True)
2093 for i in range(5000):
2094 self.send_igmp_join(groups = [groups[i]], src_list = [sources[i]],record_type = IGMP_V3_GR_TYPE_INCLUDE,
2095 iface = self.V_INF1)
2096 status = self.verify_igmp_data_traffic(groups[i],intf=self.V_INF1,source=sources[i])
2097 assert_equal(status, True)
2098 log.info('data received for group %s from source %s - %d'%(groups[i],sources[i],i))
2099
2100 """def test_igmp_join_from_multiple_infts(self):
2101 groups = ['229.9.3.6','234.20.56.2']
2102 src_list = ['192.168.12.34','192.18.1.34']
2103 self.onos_ssm_table_load(groups, src_list=src_list)
2104 self.send_igmp_join(groups = [groups[0]], src_list = src_list,record_type = IGMP_V3_GR_TYPE_INCLUDE,
2105 iface = 'veth0')
2106 self.send_igmp_join(groups = [groups[1]], src_list = src_list,record_type = IGMP_V3_GR_TYPE_INCLUDE,
2107 iface = 'veth2')
2108 status = self.verify_igmp_data_traffic(groups[0],intf='veth0',source=src_list[0])
2109 assert_equal(status,True)
2110 status = self.verify_igmp_data_traffic(groups[1],intf='veth2',source=src_list[1])
2111 assert_equal(status,True) # not expecting igmp data traffic from source src_list[0]
2112 """
2113
2114 def test_igmp_send_data_to_non_registered_group(self):
2115 group = ['224.2.3.4']
2116 src = ['2.2.2.2']
2117 self.onos_ssm_table_load(group,src_list= src)
2118 self.send_igmp_join(groups = ['239.0.0.1'], src_list = src,record_type = IGMP_V3_GR_TYPE_INCLUDE,
2119 iface = self.V_INF1, delay = 1)
2120 status = self.verify_igmp_data_traffic('239.0.0.1',intf=self.V_INF1,source=src[0])
2121 assert_equal(status,False) # not expecting igmp data traffic from source src_list[0]
2122
2123 def test_igmp_traffic_verification_for_registered_group_with_no_join_sent(self):
2124 group = ['227.12.3.40']
2125 src = ['190.4.19.67']
2126 self.onos_ssm_table_load(group,src_list= src)
2127 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source=src[0])
2128 assert_equal(status,False) # not expecting igmp data traffic from source src_list[0]
2129
2130 def test_igmp_toggling_app_activation(self):
2131 group = [self.random_mcast_ip()]
2132 src = [self.randomsourceip()]
2133 self.onos_ssm_table_load(group,src_list= src)
2134 self.send_igmp_join(groups = group, src_list = src,record_type = IGMP_V3_GR_TYPE_INCLUDE,
2135 iface = self.V_INF1)
2136 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source=src[0])
2137 assert_equal(status,True) # expecting igmp data traffic from source src_list[0]
2138 log.info('Multicast traffic received for group %s from source %s before the app is deactivated'%(group[0],src[0]))
2139 self.onos_ctrl.deactivate()
2140 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source=src[0])
2141 assert_equal(status,False) #not expecting igmp data traffic from source src_list[0]
2142 log.info('Multicast traffic not received for group %s from source %s after the app is deactivated'%(group[0],src[0]))
2143 self.onos_ctrl.activate()
2144 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source=src[0])
2145 assert_equal(status,True) # expecting igmp data traffic from source src_list[0]
2146 log.info('Multicast traffic received for group %s from source %s the app is re-activated'%(group[0],src[0]))
2147
2148 def test_igmp_with_mismatch_for_dst_ip_and_mac_in_data_packets(self):
2149 group = ['228.18.19.29']
2150 source = [self.randomsourceip()]
2151 self.onos_ssm_table_load(group,src_list= source)
2152 self.send_igmp_join(groups = group, src_list = source,record_type = IGMP_V3_GR_TYPE_INCLUDE,
2153 iface = self.V_INF1)
2154 dst_mac = '01:00:5e:0A:12:09'
2155 eth = Ether(dst= dst_mac)
2156 ip = IP(dst=group[0],src=source[0])
2157 data = repr(monotonic.monotonic())
2158 pkt = (eth/ip/data)
2159 log.info('Multicast traffic packet %s'%pkt.show())
2160 self.success = False
2161 def recv_task():
2162 def igmp_recv_cb(pkt):
2163 #log.info('received multicast data packet is %s'%pkt.show())
2164 log.info('multicast data received for group %s from source %s'%(group[0],source[0]))
2165 self.success = True
2166 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')
2167 t = threading.Thread(target = recv_task)
2168 t.start()
2169 sendp(eth/ip/data,count=20, iface = 'veth2')
2170 t.join()
2171 assert_equal(status,False) # not expecting igmp data traffic from source src_list[0]
2172
2173 #test case failing, ONOS registering unicast ip also as an igmp join
2174 def test_igmp_registering_invalid_group(self):
2175 groups = ['218.18.19.29','240.10.34.94','224.19.256.10']
2176 source = [self.randomsourceip()]
2177 ssm_dict = {'apps' : { 'org.onosproject.igmp' : { 'ssmTranslate' : [] } } }
2178 ssm_xlate_list = ssm_dict['apps']['org.onosproject.igmp']['ssmTranslate']
2179 for g in groups:
2180 for s in source:
2181 d = {}
2182 d['source'] = s or '0.0.0.0'
2183 d['group'] = g
2184 ssm_xlate_list.append(d)
2185 log.info('onos load config is %s'%ssm_dict)
2186 status, code = OnosCtrl.config(ssm_dict)
2187 assert_equal(status,False)
2188
2189 def test_igmp_registering_invalid_source(self):
2190 groups = [self.random_mcast_ip()]
2191 sources = ['224.10.28.34','193.73.219.257']
2192 ssm_dict = {'apps' : { 'org.onosproject.igmp' : { 'ssmTranslate' : [] } } }
2193 ssm_xlate_list = ssm_dict['apps']['org.onosproject.igmp']['ssmTranslate']
2194 for g in groups:
2195 for s in sources:
2196 d = {}
2197 d['source'] = s or '0.0.0.0'
2198 d['group'] = g
2199 ssm_xlate_list.append(d)
2200 log.info('onos load config is %s'%ssm_dict)
2201 status, code = OnosCtrl.config(ssm_dict)
2202 assert_equal(status,False)
2203