blob: b42af1ad3c83f4b6bb6530cc2e3895de09f419e6 [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
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -080032log.setLevel('INFO')
Chetan Gaonker25470972016-02-26 08:52:15 -080033
34class IGMPTestState:
35
36 def __init__(self, groups = [], df = None, state = 0):
37 self.df = df
38 self.state = state
39 self.counter = 0
40 self.groups = groups
41 self.group_map = {} ##create a send/recv count map
42 for g in groups:
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -080043 self.group_map[g] = (Stats(), Stats())
A.R Karthick95d044e2016-06-10 18:44:36 -070044
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -080045 def update(self, group, tx = 0, rx = 0, t = 0):
46 self.counter += 1
Chetan Gaonker25470972016-02-26 08:52:15 -080047 index = 0 if rx == 0 else 1
48 v = tx if rx == 0 else rx
49 if self.group_map.has_key(group):
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -080050 self.group_map[group][index].update(packets = v, t = t)
Chetan Gaonker25470972016-02-26 08:52:15 -080051
52 def update_state(self):
53 self.state = self.state ^ 1
Chetan Gaonker25470972016-02-26 08:52:15 -080054
55class igmp_exchange(unittest.TestCase):
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -080056
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -070057 V_INF1 = 'veth0'
58 V_INF2 = 'veth1'
59 MGROUP1 = '239.1.2.3'
60 MGROUP2 = '239.2.2.3'
Chetan Gaonker441c9ac2016-05-06 10:30:13 -070061 MINVALIDGROUP1 = '255.255.255.255'
62 MINVALIDGROUP2 = '239.255.255.255'
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -070063 MMACGROUP1 = "01:00:5e:01:02:03"
64 MMACGROUP2 = "01:00:5e:02:02:03"
ChetanGaonkera7e2b412016-09-01 23:19:07 -070065 IGMP_DST_MAC = "01:00:5e:00:00:16"
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -070066 IGMP_SRC_MAC = "5a:e1:ac:ec:4d:a1"
67 IP_SRC = '1.2.3.4'
ChetanGaonkera7e2b412016-09-01 23:19:07 -070068 IP_DST = '224.0.0.22'
Chetan Gaonker441c9ac2016-05-06 10:30:13 -070069 NEGATIVE_TRAFFIC_STATUS = 1
ChetanGaonkera7e2b412016-09-01 23:19:07 -070070 igmp_eth = Ether(dst = IGMP_DST_MAC, type = ETH_P_IP)
71 igmp_ip = IP(dst = IP_DST)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -080072 IGMP_TEST_TIMEOUT = 5
Chetan Gaonker441c9ac2016-05-06 10:30:13 -070073 IGMP_QUERY_TIMEOUT = 60
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -080074 MCAST_TRAFFIC_TIMEOUT = 10
Chetan Gaonker4eb12072016-03-28 15:04:15 -070075 PORT_TX_DEFAULT = 2
76 PORT_RX_DEFAULT = 1
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -080077 max_packets = 100
A.R Karthick95d044e2016-06-10 18:44:36 -070078 app = 'org.opencord.igmp'
Chetan Gaonker441c9ac2016-05-06 10:30:13 -070079 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 -070080 ROVER_TEST_TIMEOUT = 300 #3600*86
81 ROVER_TIMEOUT = (ROVER_TEST_TIMEOUT - 100)
82 ROVER_JOIN_TIMEOUT = 60
Chetan Gaonker4a25e2b2016-03-04 14:45:15 -080083
Chetan Gaonker441c9ac2016-05-06 10:30:13 -070084 @classmethod
85 def setUpClass(cls):
86 cls.olt = OltConfig(olt_conf_file = cls.olt_conf_file)
A R Karthick2b93d6a2016-09-06 15:19:09 -070087 cls.port_map, _ = cls.olt.olt_port_map()
Chetan Gaonker441c9ac2016-05-06 10:30:13 -070088 OnosCtrl.cord_olt_config(cls.olt.olt_device_data())
89
90 @classmethod
91 def tearDownClass(cls): pass
A.R Karthick95d044e2016-06-10 18:44:36 -070092
Chetan Gaonker4a25e2b2016-03-04 14:45:15 -080093 def setUp(self):
ChetanGaonkera7e2b412016-09-01 23:19:07 -070094 ''' Activate the igmp app'''
Chetan Gaonker4a25e2b2016-03-04 14:45:15 -080095 self.onos_ctrl = OnosCtrl(self.app)
ChetanGaonkera7e2b412016-09-01 23:19:07 -070096 self.onos_ctrl.activate()
Chetan Gaonker4eb12072016-03-28 15:04:15 -070097 self.igmp_channel = IgmpChannel()
Chetan Gaonker4a25e2b2016-03-04 14:45:15 -080098
A R Karthick31152b22016-05-13 11:25:14 -070099 def tearDown(self): pass
Chetan Gaonker4a25e2b2016-03-04 14:45:15 -0800100
101 def onos_load_config(self, config):
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700102 log.info('onos load config is %s'%config)
Chetan Gaonkera2b87df2016-03-31 15:41:31 -0700103 status, code = OnosCtrl.config(config)
Chetan Gaonker4a25e2b2016-03-04 14:45:15 -0800104 if status is False:
105 log.info('JSON request returned status %d' %code)
106 assert_equal(status, True)
107 time.sleep(2)
A.R Karthick95d044e2016-06-10 18:44:36 -0700108
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700109 def onos_ssm_table_load(self, groups, src_list = ['1.2.3.4'],flag = False):
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800110 ssm_dict = {'apps' : { 'org.onosproject.igmp' : { 'ssmTranslate' : [] } } }
111 ssm_xlate_list = ssm_dict['apps']['org.onosproject.igmp']['ssmTranslate']
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700112 if flag: #to maintain seperate group-source pair.
113 for i in range(len(groups)):
114 d = {}
115 d['source'] = src_list[i] or '0.0.0.0'
116 d['group'] = groups[i]
117 ssm_xlate_list.append(d)
118 else:
119 for g in groups:
120 for s in src_list:
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800121 d = {}
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700122 d['source'] = s or '0.0.0.0'
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800123 d['group'] = g
124 ssm_xlate_list.append(d)
Chetan Gaonker4a25e2b2016-03-04 14:45:15 -0800125 self.onos_load_config(ssm_dict)
Chetan Gaonker4eb12072016-03-28 15:04:15 -0700126 cord_port_map = {}
127 for g in groups:
128 cord_port_map[g] = (self.PORT_TX_DEFAULT, self.PORT_RX_DEFAULT)
129 self.igmp_channel.cord_port_table_load(cord_port_map)
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800130 time.sleep(2)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800131
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700132 def mcast_ip_range(self,start_ip = '224.0.1.0', end_ip = '224.0.1.100'):
133 start = list(map(int, start_ip.split(".")))
134 end = list(map(int, end_ip.split(".")))
135 temp = start
136 ip_range = []
137 ip_range.append(start_ip)
138 while temp != end:
139 start[3] += 1
140 for i in (3, 2, 1):
141 if temp[i] == 255:
142 temp[i] = 0
143 temp[i-1] += 1
144 ip_range.append(".".join(map(str, temp)))
145 return ip_range
146
147 def random_mcast_ip(self,start_ip = '224.0.1.0', end_ip = '224.0.1.100'):
148 start = list(map(int, start_ip.split(".")))
149 end = list(map(int, end_ip.split(".")))
150 temp = start
151 ip_range = []
152 ip_range.append(start_ip)
153 while temp != end:
154 start[3] += 1
155 for i in (3, 2, 1):
156 if temp[i] == 255:
157 temp[i] = 0
158 temp[i-1] += 1
159 ip_range.append(".".join(map(str, temp)))
160 return random.choice(ip_range)
161
162 def source_ip_range(self,start_ip = '10.10.0.1', end_ip = '10.10.0.100'):
163 start = list(map(int, start_ip.split(".")))
164 end = list(map(int, end_ip.split(".")))
165 temp = start
166 ip_range = []
167 ip_range.append(start_ip)
168 while temp != end:
169 start[3] += 1
170 for i in (3, 2, 1):
171 if temp[i] == 255:
172 temp[i] = 0
173 temp[i-1] += 1
174 ip_range.append(".".join(map(str, temp)))
175 return ip_range
176
177 def randomsourceip(self,start_ip = '10.10.0.1', end_ip = '10.10.0.100'):
178 start = list(map(int, start_ip.split(".")))
179 end = list(map(int, end_ip.split(".")))
180 temp = start
181 ip_range = []
182 ip_range.append(start_ip)
183 while temp != end:
184 start[3] += 1
185 for i in (3, 2, 1):
186 if temp[i] == 255:
187 temp[i] = 0
188 temp[i-1] += 1
189 ip_range.append(".".join(map(str, temp)))
190 return random.choice(ip_range)
191
A R Karthick2b93d6a2016-09-06 15:19:09 -0700192 def get_igmp_intf(self):
193 inst = os.getenv('TEST_INSTANCE', None)
194 if not inst:
195 return 'veth0'
196 inst = int(inst) + 1
197 if inst >= self.port_map['uplink']:
198 inst += 1
199 if self.port_map.has_key(inst):
200 return self.port_map[inst]
201 return 'veth0'
202
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800203 def igmp_verify_join(self, igmpStateList):
204 sendState, recvState = igmpStateList
Chetan Gaonker25470972016-02-26 08:52:15 -0800205 ## check if the send is received for the groups
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800206 for g in sendState.groups:
A.R Karthick95d044e2016-06-10 18:44:36 -0700207 tx_stats = sendState.group_map[g][0]
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800208 tx = tx_stats.count
Chetan Gaonker25470972016-02-26 08:52:15 -0800209 assert_greater(tx, 0)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800210 rx_stats = recvState.group_map[g][1]
211 rx = rx_stats.count
212 assert_greater(rx, 0)
213 log.info('Receive stats %s for group %s' %(rx_stats, g))
A.R Karthick95d044e2016-06-10 18:44:36 -0700214
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800215 log.info('IGMP test verification success')
Chetan Gaonker25470972016-02-26 08:52:15 -0800216
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800217 def igmp_verify_leave(self, igmpStateList, leave_groups):
218 sendState, recvState = igmpStateList[0], igmpStateList[1]
219 ## check if the send is received for the groups
220 for g in sendState.groups:
221 tx_stats = sendState.group_map[g][0]
222 rx_stats = recvState.group_map[g][1]
223 tx = tx_stats.count
A.R Karthick95d044e2016-06-10 18:44:36 -0700224 rx = rx_stats.count
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800225 assert_greater(tx, 0)
226 if g not in leave_groups:
227 log.info('Received %d packets for group %s' %(rx, g))
228 for g in leave_groups:
229 rx = recvState.group_map[g][1].count
230 assert_equal(rx, 0)
A.R Karthick95d044e2016-06-10 18:44:36 -0700231
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800232 log.info('IGMP test verification success')
Chetan Gaonker25470972016-02-26 08:52:15 -0800233
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800234 def mcast_traffic_timer(self):
235 self.mcastTraffic.stopReceives()
236
237 def send_mcast_cb(self, send_state):
238 for g in send_state.groups:
239 send_state.update(g, tx = 1)
Chetan Gaonker25470972016-02-26 08:52:15 -0800240 return 0
241
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800242 ##Runs in the context of twisted reactor thread
Chetan Gaonker25470972016-02-26 08:52:15 -0800243 def igmp_recv(self, igmpState, iface = 'veth0'):
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800244 p = self.recv_socket.recv()
Chetan Gaonkerf1b9e322016-05-09 15:49:15 -0700245 try:
246 send_time = float(p.payload.load)
247 recv_time = monotonic.monotonic()
248 except:
249 log.info('Unexpected Payload received: %s' %p.payload.load)
250 return 0
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800251 #log.info( 'Recv in %.6f secs' %(recv_time - send_time))
252 igmpState.update(p.dst, rx = 1, t = recv_time - send_time)
Chetan Gaonker25470972016-02-26 08:52:15 -0800253 return 0
254
A R Karthick2b93d6a2016-09-06 15:19:09 -0700255 def send_igmp_join(self, groups, src_list = ['1.2.3.4'], record_type=IGMP_V3_GR_TYPE_INCLUDE,
256 ip_pkt = None, iface = 'veth0', ssm_load = False, delay = 1):
257 if ssm_load is True:
258 self.onos_ssm_table_load(groups, src_list)
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800259 igmp = IGMPv3(type = IGMP_TYPE_V3_MEMBERSHIP_REPORT, max_resp_code=30,
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700260 gaddr=self.IP_DST)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800261 for g in groups:
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700262 gr = IGMPv3gr(rtype= record_type, mcaddr=g)
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800263 gr.sources = src_list
264 igmp.grps.append(gr)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700265 if ip_pkt is None:
266 ip_pkt = self.igmp_eth/self.igmp_ip
267 pkt = ip_pkt/igmp
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800268 IGMPv3.fixup(pkt)
269 sendp(pkt, iface=iface)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800270 if delay != 0:
271 time.sleep(delay)
272
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700273 def send_igmp_join_recvQuery(self, groups, rec_queryCount = None, src_list = ['1.2.3.4'], ip_pkt = None, iface = 'veth0', delay = 2):
274 self.onos_ssm_table_load(groups, src_list)
275 igmp = IGMPv3(type = IGMP_TYPE_V3_MEMBERSHIP_REPORT, max_resp_code=30,
276 gaddr=self.IP_DST)
277 for g in groups:
Chetan Gaonker38737f82016-05-11 17:44:17 -0700278 gr = IGMPv3gr(rtype=IGMP_V3_GR_TYPE_INCLUDE, mcaddr=g)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700279 gr.sources = src_list
280 gr.sources = src_list
281 igmp.grps.append(gr)
282 if ip_pkt is None:
283 ip_pkt = self.igmp_eth/self.igmp_ip
284 pkt = ip_pkt/igmp
285 IGMPv3.fixup(pkt)
286 if rec_queryCount == None:
287 log.info('Sending IGMP join for group %s and waiting for one query packet and printing the packet' %groups)
288 resp = srp1(pkt, iface=iface)
289 else:
290 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 -0700291 resp = srp1(pkt, iface=iface)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700292# resp = srp1(pkt, iface=iface) if rec_queryCount else srp3(pkt, iface=iface)
293 resp[0].summary()
294 log.info('Sent IGMP join for group %s and received a query packet and printing packet' %groups)
295 if delay != 0:
296 time.sleep(delay)
297
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700298 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 -0700299 log.info('entering into igmp leave function')
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800300 igmp = IGMPv3(type = IGMP_TYPE_V3_MEMBERSHIP_REPORT, max_resp_code=30,
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700301 gaddr=self.IP_DST)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800302 for g in groups:
Chetan Gaonker38737f82016-05-11 17:44:17 -0700303 gr = IGMPv3gr(rtype=IGMP_V3_GR_TYPE_EXCLUDE, mcaddr=g)
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800304 gr.sources = src_list
305 igmp.grps.append(gr)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700306 if ip_pkt is None:
307 ip_pkt = self.igmp_eth/self.igmp_ip
308 pkt = ip_pkt/igmp
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800309 IGMPv3.fixup(pkt)
310 sendp(pkt, iface = iface)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800311 if delay != 0:
312 time.sleep(delay)
Chetan Gaonker25470972016-02-26 08:52:15 -0800313
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700314 def send_igmp_leave_listening_group_specific_query(self, groups, src_list = ['1.2.3.4'], ip_pkt = None, iface = 'veth0', delay = 2):
315 igmp = IGMPv3(type = IGMP_TYPE_V3_MEMBERSHIP_REPORT, max_resp_code=30,
316 gaddr=self.IP_DST)
317 for g in groups:
Chetan Gaonker38737f82016-05-11 17:44:17 -0700318 gr = IGMPv3gr(rtype=IGMP_V3_GR_TYPE_EXCLUDE, mcaddr=g)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700319 gr.sources = src_list
320 igmp.grps.append(gr)
321 if ip_pkt is None:
322 ip_pkt = self.igmp_eth/self.igmp_ip
323 pkt = ip_pkt/igmp
324 IGMPv3.fixup(pkt)
325 log.info('Sending IGMP leave for group %s and waiting for one group specific query packet and printing the packet' %groups)
326 resp = srp1(pkt, iface=iface)
327 resp[0].summary()
328 log.info('Sent IGMP leave for group %s and received a group specific query packet and printing packet' %groups)
329 if delay != 0:
330 time.sleep(delay)
331
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800332 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10)
333 def test_igmp_join_verify_traffic(self):
Chetan Gaonker25470972016-02-26 08:52:15 -0800334 groups = ['224.0.1.1', '225.0.0.1']
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700335 self.onos_ssm_table_load(groups)
Chetan Gaonker25470972016-02-26 08:52:15 -0800336 df = defer.Deferred()
337 igmpState = IGMPTestState(groups = groups, df = df)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800338 igmpStateRecv = IGMPTestState(groups = groups, df = df)
339 igmpStateList = (igmpState, igmpStateRecv)
340 mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb, arg = igmpState)
341 self.df = df
342 self.mcastTraffic = mcastTraffic
343 self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP)
344
345 def igmp_srp_task(stateList):
346 igmpSendState, igmpRecvState = stateList
347 if not mcastTraffic.isRecvStopped():
348 result = self.igmp_recv(igmpRecvState)
349 reactor.callLater(0, igmp_srp_task, stateList)
350 else:
351 self.mcastTraffic.stop()
352 self.recv_socket.close()
353 self.igmp_verify_join(stateList)
354 self.df.callback(0)
355
356 self.send_igmp_join(groups)
357 mcastTraffic.start()
358 self.test_timer = reactor.callLater(self.MCAST_TRAFFIC_TIMEOUT, self.mcast_traffic_timer)
359 reactor.callLater(0, igmp_srp_task, igmpStateList)
Chetan Gaonker25470972016-02-26 08:52:15 -0800360 return df
361
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700362 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+40)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800363 def test_igmp_leave_verify_traffic(self):
364 groups = ['224.0.1.10', '225.0.0.10']
365 leave_groups = ['224.0.1.10']
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700366 self.onos_ssm_table_load(groups)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800367 df = defer.Deferred()
368 igmpState = IGMPTestState(groups = groups, df = df)
369 igmpStateRecv = IGMPTestState(groups = groups, df = df)
370 igmpStateList = (igmpState, igmpStateRecv)
A.R Karthick95d044e2016-06-10 18:44:36 -0700371 mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb,
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800372 arg = igmpState)
373 self.df = df
374 self.mcastTraffic = mcastTraffic
375 self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP)
A.R Karthick95d044e2016-06-10 18:44:36 -0700376
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700377 mcastTraffic.start()
378 self.send_igmp_join(groups)
379 self.send_igmp_leave(leave_groups, delay = 3)
380 join_state = IGMPTestState(groups = leave_groups)
381 status = self.igmp_not_recv_task(self.V_INF1,leave_groups, join_state)
382 log.info('verified status for igmp recv task %s'%status)
383 assert status == 1 , 'EXPECTED RESULT'
384 self.df.callback(0)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800385 return df
386
387 @deferred(timeout=100)
388 def test_igmp_leave_join_loop(self):
389 self.groups = ['226.0.1.1', '227.0.0.1', '228.0.0.1', '229.0.0.1', '230.0.0.1' ]
390 self.src_list = ['3.4.5.6', '7.8.9.10']
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700391 self.onos_ssm_table_load(self.groups,src_list=self.src_list)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800392 df = defer.Deferred()
393 self.df = df
394 self.iterations = 0
395 self.num_groups = len(self.groups)
396 self.MAX_TEST_ITERATIONS = 10
397
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800398 def igmp_srp_task(v):
399 if self.iterations < self.MAX_TEST_ITERATIONS:
400 if v == 1:
401 ##join test
402 self.num_groups = random.randint(0, len(self.groups))
403 self.send_igmp_join(self.groups[:self.num_groups],
404 src_list = self.src_list,
405 iface = 'veth0', delay = 0)
406 else:
407 self.send_igmp_leave(self.groups[:self.num_groups],
408 src_list = self.src_list,
409 iface = 'veth0', delay = 0)
410 self.iterations += 1
411 v ^= 1
412 reactor.callLater(1.0 + 0.5*self.num_groups,
413 igmp_srp_task, v)
414 else:
415 self.df.callback(0)
416
417 reactor.callLater(0, igmp_srp_task, 1)
418 return df
419
420 def igmp_join_task(self, intf, groups, state, src_list = ['1.2.3.4']):
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700421 #self.onos_ssm_table_load(groups, src_list)
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800422 igmp = IGMPv3(type = IGMP_TYPE_V3_MEMBERSHIP_REPORT, max_resp_code=30,
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700423 gaddr=self.IP_DST)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800424 for g in groups:
Chetan Gaonker38737f82016-05-11 17:44:17 -0700425 gr = IGMPv3gr(rtype = IGMP_V3_GR_TYPE_INCLUDE, mcaddr = g)
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800426 gr.sources = src_list
427 igmp.grps.append(gr)
428
429 for g in groups:
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800430 state.group_map[g][0].update(1, t = monotonic.monotonic())
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800431
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700432 pkt = self.igmp_eth/self.igmp_ip/igmp
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800433 IGMPv3.fixup(pkt)
434 sendp(pkt, iface=intf)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800435 log.debug('Returning from join task')
436
437 def igmp_recv_task(self, intf, groups, join_state):
438 recv_socket = L3PacketSocket(iface = intf, type = ETH_P_IP)
439 group_map = {}
440 for g in groups:
441 group_map[g] = [0,0]
442
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700443 log.info('Verifying join interface should receive multicast data')
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800444 while True:
445 p = recv_socket.recv()
446 if p.dst in groups and group_map[p.dst][0] == 0:
447 group_map[p.dst][0] += 1
448 group_map[p.dst][1] = monotonic.monotonic()
449 c = 0
450 for g in groups:
451 c += group_map[g][0]
452 if c == len(groups):
453 break
454 for g in groups:
455 join_start = join_state.group_map[g][0].start
456 recv_time = group_map[g][1] * 1000000
457 delta = (recv_time - join_start)
458 log.info('Join for group %s received in %.3f usecs' %
459 (g, delta))
460
461 recv_socket.close()
462 log.debug('Returning from recv task')
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700463
464 def igmp_not_recv_task(self, intf, groups, join_state):
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700465 log.info('entering igmp not recv task loop')
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700466 recv_socket = L2Socket(iface = intf, type = ETH_P_IP)
467 group_map = {}
468 for g in groups:
469 group_map[g] = [0,0]
470
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700471 log.info('Verifying join interface should not receive any multicast data')
Chetan Gaonker7791bda2016-05-12 17:36:52 -0700472 self.NEGATIVE_TRAFFIC_STATUS = 1
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700473 def igmp_recv_cb(pkt):
474 log.info('Multicast packet %s received for left groups %s' %(pkt[IP].dst, groups))
Chetan Gaonker7791bda2016-05-12 17:36:52 -0700475 self.NEGATIVE_TRAFFIC_STATUS = 2
Chetan Gaonker38737f82016-05-11 17:44:17 -0700476 sniff(prn = igmp_recv_cb, count = 1, lfilter = lambda p: IP in p and p[IP].dst in groups,
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700477 timeout = 3, opened_socket = recv_socket)
478 recv_socket.close()
A.R Karthick95d044e2016-06-10 18:44:36 -0700479 return self.NEGATIVE_TRAFFIC_STATUS
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700480
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800481 def group_latency_check(self, groups):
482 tasks = []
483 self.send_igmp_leave(groups = groups)
484 join_state = IGMPTestState(groups = groups)
485 tasks.append(threading.Thread(target=self.igmp_join_task, args = ('veth0', groups, join_state,)))
486 traffic_state = IGMPTestState(groups = groups)
A.R Karthick95d044e2016-06-10 18:44:36 -0700487 mcast_traffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb,
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800488 arg = traffic_state)
489 mcast_traffic.start()
490 tasks.append(threading.Thread(target=self.igmp_recv_task, args = ('veth0', groups, join_state)))
491 for t in tasks:
492 t.start()
493 for t in tasks:
494 t.join()
495
496 mcast_traffic.stop()
497 self.send_igmp_leave(groups = groups)
498 return
499
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700500 @deferred(timeout=IGMP_QUERY_TIMEOUT + 10)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800501 def test_igmp_1group_join_latency(self):
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700502 groups = ['239.0.1.1']
503 df = defer.Deferred()
504 def igmp_1group_join_latency():
505 self.group_latency_check(groups)
506 df.callback(0)
507 reactor.callLater(0, igmp_1group_join_latency)
508 return df
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800509
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700510 @deferred(timeout=IGMP_QUERY_TIMEOUT + 10)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800511 def test_igmp_2group_join_latency(self):
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700512 groups = ['239.0.1.1', '240.0.1.1']
513 df = defer.Deferred()
514 def igmp_2group_join_latency():
515 self.group_latency_check(groups)
516 df.callback(0)
517 reactor.callLater(0, igmp_2group_join_latency)
518 return df
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800519
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700520 @deferred(timeout=IGMP_QUERY_TIMEOUT + 10)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800521 def test_igmp_Ngroup_join_latency(self):
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700522 groups = ['239.0.1.1', '240.0.1.1', '241.0.1.1', '242.0.1.1']
523 df = defer.Deferred()
524 def igmp_Ngroup_join_latency():
525 self.group_latency_check(groups)
526 df.callback(0)
527 reactor.callLater(0, igmp_Ngroup_join_latency)
528 return df
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800529
A R Karthick2b93d6a2016-09-06 15:19:09 -0700530 def test_igmp_join_rover_all(self):
Chetan Gaonker1f7c3f82016-03-08 12:17:37 -0800531 s = (224 << 24) | 1
532 #e = (225 << 24) | (255 << 16) | (255 << 16) | 255
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700533 e = (224 << 24) | 10
Chetan Gaonker1f7c3f82016-03-08 12:17:37 -0800534 for i in xrange(s, e+1):
535 if i&0xff:
536 ip = '%d.%d.%d.%d'%((i>>24)&0xff, (i>>16)&0xff, (i>>8)&0xff, i&0xff)
537 self.send_igmp_join([ip], delay = 0)
538
A R Karthick2b93d6a2016-09-06 15:19:09 -0700539 @deferred(timeout=ROVER_TEST_TIMEOUT)
540 def test_igmp_join_rover(self):
541 df = defer.Deferred()
542 iface = self.get_igmp_intf()
543 self.df = df
544 self.count = 0
545 self.timeout = 0
546 self.complete = False
547 def igmp_join_timer():
548 self.timeout += self.ROVER_JOIN_TIMEOUT
549 log.info('IGMP joins sent: %d' %self.count)
550 did = OnosCtrl.get_device_id()
551 if self.timeout >= self.ROVER_TIMEOUT:
552 self.complete = True
553 reactor.callLater(self.ROVER_JOIN_TIMEOUT, igmp_join_timer)
554
555 reactor.callLater(self.ROVER_JOIN_TIMEOUT, igmp_join_timer)
556 self.start_channel = s = (224 << 24) | 1
557 self.end_channel = e = (224 << 24) | 200 #(225 << 24) | (255 << 16) | (255 << 16) | 255
558 self.current_channel = self.start_channel
559 def igmp_join_rover(self):
560 #e = (224 << 24) | 10
561 chan = self.current_channel
562 self.current_channel += 1
563 if self.current_channel >= self.end_channel:
564 chan = self.current_channel = self.start_channel
565 if chan&0xff:
566 ip = '%d.%d.%d.%d'%((chan>>24)&0xff, (chan>>16)&0xff, (chan>>8)&0xff, chan&0xff)
567 self.send_igmp_join([ip], delay = 0, ssm_load = False, iface = iface)
568 self.count += 1
569 if self.complete == True:
570 log.info('%d IGMP joins sent in %d seconds over %s' %(self.count, self.timeout, iface))
571 self.df.callback(0)
572 else:
573 reactor.callLater(0, igmp_join_rover, self)
574 reactor.callLater(0, igmp_join_rover, self)
575 return df
576
Chetan Gaonker1f7c3f82016-03-08 12:17:37 -0800577 @deferred(timeout=IGMP_QUERY_TIMEOUT + 10)
578 def test_igmp_query(self):
579 groups = ['224.0.0.1'] ##igmp query group
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700580 self.onos_ssm_table_load(groups)
Chetan Gaonker1f7c3f82016-03-08 12:17:37 -0800581 df = defer.Deferred()
582 self.df = df
583 self.recv_socket = L2Socket(iface = 'veth0', type = ETH_P_IP)
A.R Karthick95d044e2016-06-10 18:44:36 -0700584
Chetan Gaonker1f7c3f82016-03-08 12:17:37 -0800585 def igmp_query_timeout():
Chetan Gaonker1f7c3f82016-03-08 12:17:37 -0800586 def igmp_query_cb(pkt):
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700587 log.info('received igmp query packet is %s'%pkt.show())
Chetan Gaonkerbd4390f2016-03-09 18:56:52 -0800588 log.info('Got IGMP query packet from %s for %s' %(pkt[IP].src, pkt[IP].dst))
589 assert_equal(pkt[IP].dst, '224.0.0.1')
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700590 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 -0800591 opened_socket = self.recv_socket)
Chetan Gaonker1f7c3f82016-03-08 12:17:37 -0800592 self.recv_socket.close()
593 self.df.callback(0)
594
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700595 #self.send_igmp_join(groups)
Chetan Gaonker1f7c3f82016-03-08 12:17:37 -0800596 self.test_timer = reactor.callLater(self.IGMP_QUERY_TIMEOUT, igmp_query_timeout)
597 return df
598
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700599 def igmp_send_joins_different_groups_srclist(self, groups, sources, intf = V_INF1, delay = 2, ip_src = None):
600 g1 = groups[0]
601 g2 = groups[1]
602 sourcelist1 = sources[0]
603 sourcelist2 = sources[1]
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700604 eth = Ether(dst = self.IGMP_DST_MAC,type = ETH_P_IP)
605 ip = IP(dst = self.IP_DST)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700606 log.info('Sending join message for the group %s' %g1)
607 self.send_igmp_join((g1,), src_list = sourcelist1, ip_pkt = eth/ip, iface = intf, delay = 2)
608 eth = Ether(dst = self.MMACGROUP2, src = self.IGMP_SRC_MAC, type = ETH_P_IP)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700609 ip = IP(dst = g2)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700610 log.info('Sending join message for group %s' %g2)
611 self.send_igmp_join((g2,), src_list = sourcelist2, ip_pkt = eth/ip, iface = intf, delay = 2)
Chetan Gaonker7791bda2016-05-12 17:36:52 -0700612 log.info('Done with igmp_send_joins_different_groups_srclist')
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700613
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700614 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):
615 g1 = groups[0]
616 g2 = groups[1]
617 sourcelist1 = sources[0]
618 sourcelist2 = sources[1]
619 eth = Ether(dst = self.MMACGROUP1, src = self.IGMP_SRC_MAC, type = ETH_P_IP)
620 src_ip = ip_src or self.IP_SRC
621 ip = IP(dst = g1, src = src_ip)
622 if query_group1 is 'group1':
623 log.info('Sending join message for the group %s and waiting for a query packet on join interface' %g1)
624 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 -0700625 else:
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700626 log.info('Sending join message for the group %s' %g1)
627 self.send_igmp_join((g1,), src_list = sourcelist1, ip_pkt = eth/ip, iface = intf, delay = 2)
628 eth = Ether(dst = self.MMACGROUP2, src = self.IGMP_SRC_MAC, type = ETH_P_IP)
629 ip = IP(dst = g2, src = src_ip)
630 if query_group2 is 'group2':
631 log.info('Sending join message for the group %s and waiting for a query packet on join interface' %g2)
632 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 -0700633 else:
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700634 log.info('Sending join message for group %s' %g2)
635 self.send_igmp_join((g2,), src_list = sourcelist2, ip_pkt = eth/ip, iface = intf, delay = 2)
636
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700637 def igmp_joins_leave(self,groups,src_list,again_join = False, df = None):
638 groups1 = [groups[0]]
639 groups2 = [groups[1]]
640 src1 = [src_list[0]]
641 src2 = [src_list[1]]
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700642 self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700643 (src1, src2), intf = self.V_INF1, delay = 2)
644
645 src_ip = src1[0]
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700646 if df is None:
647 df = defer.Deferred()
648 igmpState1 = IGMPTestState(groups = groups1, df = df)
649 igmpStateRecv1 = IGMPTestState(groups = groups1, df = df)
650 igmpStateList1 = (igmpState1, igmpStateRecv1)
651
652 igmpState2 = IGMPTestState(groups = groups2, df = df)
653 igmpStateRecv2 = IGMPTestState(groups = groups2, df = df)
654 igmpStateList2 = (igmpState2, igmpStateRecv2)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700655 dst_mac = self.iptomac(groups1[0])
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700656 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
657 src_ip = src_ip, cb = self.send_mcast_cb,
658 arg = igmpState1)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700659 src_ip = src2[0]
660 dst_mac = self.iptomac(groups1[0])
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700661 mcastTraffic2 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
662 src_ip = src_ip, cb = self.send_mcast_cb,
663 arg = igmpState2)
664 mcastTraffic1.start()
665 mcastTraffic2.start()
666 join_state1 = IGMPTestState(groups = groups1)
667 join_state2 = IGMPTestState(groups = groups2)
668 target1 = self.igmp_recv_task(self.V_INF1, groups1, join_state1)
669 log.info('Interface is receiving multicast groups %s' %groups1)
670 target2 = self.igmp_recv_task(self.V_INF1, groups2, join_state2)
671 log.info('Interface is receiving multicast groups %s' %groups2)
672 log.info('Interface is sending leave message for groups %s now' %groups2)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700673 self.send_igmp_leave(groups = groups2, src_list = src2, iface = self.V_INF1, delay = 2)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700674 target3 = self.igmp_recv_task(self.V_INF1, groups1, join_state1)
675 target4 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state2)
676 assert target4 == 1, 'EXPECTED FAILURE'
677 if again_join:
678 dst_mac = '01:00:5e:02:02:03'
679 ip_dst = '239.2.2.3'
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700680 eth = Ether(dst = dst_mac, type = ETH_P_IP)
681 ip = IP(dst = ip_dst)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700682 log.info('Interface sending join message again for the groups %s' %groups2)
683 self.send_igmp_join(groups2, src_list = [src_ip], ip_pkt = eth/ip, iface = self.V_INF1, delay = 2)
684 target5 = self.igmp_recv_task(self.V_INF1, groups2, join_state2)
685 log.info('Interface is receiving multicast groups %s again' %groups2)
686 target6 = self.igmp_recv_task(self.V_INF1, groups1, join_state1)
687 log.info('Interface is still receiving from multicast groups %s' %groups1)
688 else:
689 log.info('Ended test case')
690 mcastTraffic1.stop()
691 mcastTraffic2.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -0700692
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700693
694 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700695 def test_igmp_2joins_1leave(self):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700696 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700697 def igmp_2joins_1leave():
698 groups = ['234.2.3.4','236.8.7.9']
699 src_list = ['2.3.4.5','5.4.3.2']
700 self.onos_ssm_table_load(groups,src_list = src_list)
701 self.igmp_joins_leave(groups,src_list,again_join = False, df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700702 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700703 reactor.callLater(0, igmp_2joins_1leave)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700704 return df
705
706 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+25)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700707 def test_igmp_2joins_1leave_and_join_again(self):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700708 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700709 def igmp_2joins_1leave_join_again():
710 groups = ['234.2.3.4','236.8.7.9']
711 src_list = ['2.3.4.5','5.4.3.2']
712 self.onos_ssm_table_load(groups,src_list = src_list)
713 self.igmp_joins_leave(groups,src_list,again_join = True, df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700714 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700715 reactor.callLater(0, igmp_2joins_1leave_join_again)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700716 return df
717
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700718 def igmp_not_in_src_list(self, df = None):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700719 groups1 = (self.MGROUP1,)
720 groups2 = (self.MGROUP2,)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700721 self.onos_ssm_table_load(groups1 + groups2,src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4','2.2.2.2', '5.5.5.5'])
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700722 self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
723 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
724 intf = self.V_INF1, delay = 2)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700725 src_ip = '6.6.6.6'
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700726 dst_mac = self.iptomac(groups1[0])
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700727 if df is None:
728 df = defer.Deferred()
729 igmpState1 = IGMPTestState(groups = groups1, df = df)
730 igmpStateRecv1 = IGMPTestState(groups = groups1, df = df)
731 mcastTraffic1 = McastTraffic(groups1, iface = 'veth2', dst_mac = dst_mac,
732 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
733 mcastTraffic1.start()
734 join_state1 = IGMPTestState(groups = groups1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700735 log.info('Interface should not receive from multicast groups %s from an interface, which is expected' %groups1)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700736 target1 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
Chetan Gaonker7791bda2016-05-12 17:36:52 -0700737 assert target1 == 2, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700738 log.info('Interface is not receiving traffic from multicast groups %s, working as expected' %groups1)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700739 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -0700740
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700741 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700742 def test_igmp_not_in_src_list(self):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700743 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700744 def igmp_not_in_src_list():
745 self.igmp_not_in_src_list(df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700746 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700747 reactor.callLater(0, igmp_not_in_src_list)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700748 return df
749
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700750 def igmp_change_to_exclude_src_list(self, df = None):
751 groups1 = [self.random_mcast_ip()]
752 groups2 = [self.random_mcast_ip()]
753 self.onos_ssm_table_load(groups1 + groups2,src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4','2.2.2.2', '5.5.5.5'])
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700754 self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
755 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
756 intf = self.V_INF1, delay = 2)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700757 src_ip = '2.2.2.2'
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700758 dst_mac=self.iptomac(groups1[0])
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700759 if df is None:
760 df = defer.Deferred()
761 igmpState1 = IGMPTestState(groups = groups1, df = df)
762 igmpStateRecv1 = IGMPTestState(groups = groups1, df = df)
763 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
764 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
765 mcastTraffic1.start()
766 join_state1 = IGMPTestState(groups = groups1)
767 target1 = self.igmp_recv_task(self.V_INF1, groups1, join_state1)
768 self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2'], iface = self.V_INF1, delay =2)
769 target2 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
Chetan Gaonker7791bda2016-05-12 17:36:52 -0700770 assert target2 == 2, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700771 log.info('Interface is not receiving traffic from multicast groups %s after sending CHANGE_TO_EXCLUDE' %groups1)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700772 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -0700773
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700774 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700775 def test_igmp_change_to_exclude_src_list(self):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700776 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700777 def igmp_change_to_exclude_src_list():
778 self.igmp_change_to_exclude_src_list(df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700779 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700780 reactor.callLater(0, igmp_change_to_exclude_src_list)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700781 return df
782
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700783 def igmp_include_to_allow_src_list(self, df = None):
784 groups1 = [self.random_mcast_ip()] #(self.MGROUP1,)
785 self.onos_ssm_table_load(groups1,src_list = ['4.4.4.4','6.6.6.6'])
786 self.send_igmp_join(groups = groups1, src_list = ['4.4.4.4'],record_type = IGMP_V3_GR_TYPE_INCLUDE,
787 iface = self.V_INF1)
788 src_ip = '4.4.4.4'
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700789 if df is None:
790 df = defer.Deferred()
791 igmpState1 = IGMPTestState(groups = groups1, df = df)
792 igmpStateRecv1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700793 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2',src_ip = src_ip,
794 cb = self.send_mcast_cb, arg = igmpState1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700795 mcastTraffic1.start()
796 join_state1 = IGMPTestState(groups = groups1)
797 target1 = self.igmp_recv_task(self.V_INF1, groups1, join_state1)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700798 mcastTraffic1.stop()
799 mcastTraffic2 = McastTraffic(groups1, iface= 'veth2',src_ip = '6.6.6.6',
800 cb = self.send_mcast_cb, arg = igmpState1)
801 self.send_igmp_join(groups = groups1, src_list = ['6.6.6.6'],record_type = IGMP_V3_GR_TYPE_ALLOW_NEW,
802 iface = self.V_INF1)
803 mcastTraffic2.start()
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700804 target1 = self.igmp_recv_task(self.V_INF1, groups1, join_state1)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700805 mcastTraffic2.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -0700806
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700807 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+30)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700808 def test_igmp_include_to_allow_src_list(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700809 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700810 def igmp_include_to_allow_src_list():
811 self.igmp_include_to_allow_src_list(df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700812 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700813 reactor.callLater(0, igmp_include_to_allow_src_list)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700814 return df
815
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700816 def igmp_include_to_block_src_list(self, df = None):
817 groups1 = [self.random_mcast_ip()] #groups1 = (self.MGROUP1,)
818 self.onos_ssm_table_load(groups1,src_list = ['4.4.4.4','6.6.6.6'])
819 self.send_igmp_join(groups = groups1, src_list = ['4.4.4.4','6.6.6.6'],record_type = IGMP_V3_GR_TYPE_INCLUDE,
820 iface = self.V_INF1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700821 if df is None:
822 df = defer.Deferred()
823 igmpState1 = IGMPTestState(groups = groups1, df = df)
824 igmpStateRecv1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700825 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2',src_ip = '6.6.6.6',
826 cb = self.send_mcast_cb, arg = igmpState1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700827 mcastTraffic1.start()
828 join_state1 = IGMPTestState(groups = groups1)
829 target1 = self.igmp_recv_task(self.V_INF1, groups1, join_state1)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700830 mcastTraffic1.stop()
831 self.send_igmp_join(groups = groups1, src_list = ['6.6.6.6'],record_type = IGMP_V3_GR_TYPE_BLOCK_OLD,
832 iface = self.V_INF1)
833 mcastTraffic2 = McastTraffic(groups1, iface= 'veth2',src_ip = '6.6.6.6',
834 cb = self.send_mcast_cb, arg = igmpState1)
835 mcastTraffic2.start()
836 target1 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
837 assert target1 == 1, 'EXPECTED FAILURE'
Chetan Gaonker717b2942016-05-13 17:42:59 -0700838 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 -0700839 mcastTraffic2.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -0700840
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700841 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+30)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700842 def test_igmp_include_to_block_src_list(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700843 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700844 def igmp_include_to_block_src_list():
845 self.igmp_include_to_block_src_list(df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700846 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700847 reactor.callLater(0, igmp_include_to_block_src_list)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700848 return df
849
850
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700851 def igmp_change_to_include_src_list(self, df = None):
852 groups1 = [self.random_mcast_ip()]
853 src_list = ['4.4.4.4','6.6.6.6']
854 self.onos_ssm_table_load(groups1,src_list = src_list)
855 self.send_igmp_leave(groups = groups1, src_list = src_list,
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700856 iface = self.V_INF1, delay = 2)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700857 if df is None:
858 df = defer.Deferred()
859 igmpState1 = IGMPTestState(groups = groups1, df = df)
860 igmpStateRecv1 = IGMPTestState(groups = groups1, df = df)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700861 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2',src_ip = src_list[0],
862 cb = self.send_mcast_cb, arg = igmpState1)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700863 mcastTraffic1.start()
864 join_state1 = IGMPTestState(groups = groups1)
865 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
866 assert target1 == 1, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700867 log.info('Interface is not receiving traffic from multicast groups %s' %groups1)
868 mcastTraffic1.stop()
869 self.send_igmp_join(groups = groups1, src_list = src_list,record_type = IGMP_V3_GR_TYPE_INCLUDE,
870 iface = self.V_INF1)
871 mcastTraffic2 = McastTraffic(groups1, iface= 'veth2',src_ip = src_list[1],
872 cb = self.send_mcast_cb, arg = igmpState1)
873 mcastTraffic2.start()
874 target1 = self.igmp_recv_task(self.V_INF1, groups1, join_state1)
875 mcastTraffic2.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -0700876
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700877 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700878 def test_igmp_change_to_include_src_list(self):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700879 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700880 def igmp_change_to_include_src_list():
881 self.igmp_change_to_include_src_list(df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700882 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700883 reactor.callLater(0, igmp_change_to_include_src_list)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700884 return df
885
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700886 #this test case failing because group in include receiving multicast traffic from any of the source
887 def igmp_exclude_to_allow_src_list(self, df = None):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700888 groups1 = (self.MGROUP1,)
889 groups2 = (self.MGROUP2,)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700890 self.onos_ssm_table_load(groups1+groups2,src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4','6.6.6.6', '7.7.7.7', '8.8.8.8','5.5.5.5'])
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700891 self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4'],
892 iface = self.V_INF1, delay = 2)
A.R Karthick95d044e2016-06-10 18:44:36 -0700893
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700894 dst_mac = '01:00:5e:01:02:03'
895 src_ip = '2.2.2.2'
896 if df is None:
897 df = defer.Deferred()
898 igmpState1 = IGMPTestState(groups = groups1, df = df)
899 igmpStateRecv1 = IGMPTestState(groups = groups1, df = df)
900 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
901 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
902 mcastTraffic1.start()
903 join_state1 = IGMPTestState(groups = groups1)
904 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
905 assert target1 == 1, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700906 log.info('Interface is not receiving traffic from multicast groups %s' %groups1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700907 self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
908 (['6.6.6.6', '7.7.7.7', '8.8.8.8'], ['6.6.6.6', '5.5.5.5']),
909 intf = self.V_INF1, delay = 2)
910 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
911 assert target1 == 1, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700912 log.info('Interface is not receiving traffic from multicast groups %s' %groups1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700913 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -0700914
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700915 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700916 def test_igmp_exclude_to_allow_src_list(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700917 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700918 def igmp_exclude_to_allow_src_list():
919 self.igmp_exclude_to_allow_src_list(df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700920 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700921 reactor.callLater(0, igmp_exclude_to_allow_src_list)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700922 return df
923
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700924 def igmp_exclude_to_block_src_list(self, df = None):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700925 groups1 = (self.MGROUP1,)
926 groups2 = (self.MGROUP2,)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700927 self.onos_ssm_table_load(groups1+groups2,src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4','7.7.7.7','5.5.5.5'])
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700928 self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4'],
929 iface = self.V_INF1, delay = 2)
A.R Karthick95d044e2016-06-10 18:44:36 -0700930
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700931 dst_mac = '01:00:5e:01:02:03'
932 src_ip = '2.2.2.2'
933 if df is None:
934 df = defer.Deferred()
935 igmpState1 = IGMPTestState(groups = groups1, df = df)
936 igmpStateRecv1 = IGMPTestState(groups = groups1, df = df)
937 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
938 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
939 mcastTraffic1.start()
940 join_state1 = IGMPTestState(groups = groups1)
941 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
942 assert target1 == 1, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700943 log.info('Interface is not receiving traffic from multicast groups %s' %groups1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700944 self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4', '5.5.5.5', '7.7.7.7'],
945 iface = self.V_INF1, delay = 2)
946 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
947 assert target1 == 1, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700948 log.info('Interface is not receiving traffic from multicast groups %s' %groups1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700949 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -0700950
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700951 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700952 def test_igmp_exclude_to_block_src_list(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700953 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700954 def igmp_exclude_to_block_src_list():
955 self.igmp_exclude_to_block_src_list(df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700956 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700957 reactor.callLater(0, igmp_exclude_to_block_src_list)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700958 return df
959
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700960 #this test case failing because group in include mode recieves traffic from other sources also.
961 def igmp_new_src_list(self, df = None):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700962 groups1 = (self.MGROUP1,)
963 groups2 = (self.MGROUP2,)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700964 self.onos_ssm_table_load(groups1+groups2,src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4','5.5.5.5','6.6.6.6'])
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700965 self.igmp_send_joins_different_groups_srclist(groups1+groups2,
966 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
967 intf = self.V_INF1, delay = 2)
968 dst_mac = '01:00:5e:01:02:03'
969 src_ip = '6.6.6.6'
970 if df is None:
971 df = defer.Deferred()
972 igmpState1 = IGMPTestState(groups = groups1, df = df)
973 igmpStateRecv1 = IGMPTestState(groups = groups1, df = df)
974 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
975 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
976 mcastTraffic1.start()
977 join_state1 = IGMPTestState(groups = groups1)
978 target1 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
979 assert target1 == 1, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700980 log.info('Interface is not receiving traffic from multicast groups %s' %groups1)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700981 self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700982 (['2.2.2.2', '6.6.6.6', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700983 intf = self.V_INF1, delay = 2)
984 target2 = self.igmp_recv_task(self.V_INF1, groups1, join_state1)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700985 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 -0700986 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -0700987
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700988 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700989 def test_igmp_new_src_list(self):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700990 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700991 def igmp_new_src_list():
992 self.igmp_new_src_list(df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700993 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700994 reactor.callLater(0, igmp_new_src_list)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700995 return df
996
ChetanGaonkera7e2b412016-09-01 23:19:07 -0700997 def igmp_block_old_src_list(self, df = None):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700998 groups1 = (self.MGROUP1,)
999 groups2 = (self.MGROUP2,)
1000 groups = groups1 + groups2
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001001 self.onos_ssm_table_load(groups1+groups2,src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4','5.5.5.5','6.6.6.6','7.7.7.7'])
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001002 self.igmp_send_joins_different_groups_srclist(groups,
1003 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
1004 intf = self.V_INF1, delay = 2)
1005 dst_mac = '01:00:5e:02:02:03'
1006 src_ip = '5.5.5.5'
1007 if df is None:
1008 df = defer.Deferred()
1009 igmpState1 = IGMPTestState(groups = groups2, df = df)
1010 igmpStateRecv1 = IGMPTestState(groups = groups2, df = df)
1011 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1012 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1013 mcastTraffic1.start()
1014 join_state1 = IGMPTestState(groups = groups2)
1015 target1 = self.igmp_recv_task(self.V_INF1, groups2, join_state1)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001016 log.info('Interface is receiving traffic from multicast groups %s' %groups2)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001017 self.igmp_send_joins_different_groups_srclist(groups,
1018 (['6.6.6.6', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '7.7.7.7']),
1019 intf = self.V_INF1, delay = 2)
1020 target2 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1)
Chetan Gaonker7791bda2016-05-12 17:36:52 -07001021 assert target2 == 2, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001022 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 -07001023 mcastTraffic1.stop()
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001024
1025 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001026 def test_igmp_block_old_src_list(self):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001027 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001028 def igmp_block_old_src_list():
1029 self.igmp_block_old_src_list(df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001030 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001031 reactor.callLater(0, igmp_block_old_src_list)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001032 return df
1033
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001034 def igmp_include_empty_src_list(self, df = None):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001035 groups1 = (self.MGROUP1,)
1036 groups2 = (self.MGROUP2,)
1037 groups = groups1 + groups2
1038 self.igmp_send_joins_different_groups_srclist(groups,
1039 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['']),
1040 intf = self.V_INF1, delay = 2)
1041 dst_mac = '01:00:5e:02:02:03'
1042 src_ip = '5.5.5.5'
1043 if df is None:
1044 df = defer.Deferred()
1045 igmpState1 = IGMPTestState(groups = groups2, df = df)
1046 igmpStateRecv1 = IGMPTestState(groups = groups2, df = df)
1047 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1048 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1049 mcastTraffic1.start()
1050 join_state1 = IGMPTestState(groups = groups2)
1051 target1 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1)
1052 assert target1==1, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001053 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 -07001054 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001055
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001056 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001057 def test_igmp_include_empty_src_list(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001058 ## '''Disabling this test as scapy IGMP doesn't work with empty source lists'''
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001059 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001060 def igmp_include_empty_src_list():
1061 self.igmp_include_empty_src_list(df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001062 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001063 reactor.callLater(0, igmp_include_empty_src_list)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001064 return df
1065
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001066 def igmp_exclude_empty_src_list(self, df = None):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001067 groups1 = (self.MGROUP1,)
1068 groups2 = (self.MGROUP2,)
1069 groups = groups1 + groups2
1070 self.send_igmp_leave(groups = groups2, src_list = [''], iface = self.V_INF1, delay = 2)
1071 dst_mac = '01:00:5e:02:02:03'
1072 src_ip = '5.5.5.5'
1073 if df is None:
1074 df = defer.Deferred()
1075 igmpState1 = IGMPTestState(groups = groups2, df = df)
1076 igmpStateRecv1 = IGMPTestState(groups = groups2, df = df)
1077 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1078 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1079 mcastTraffic1.start()
1080 join_state1 = IGMPTestState(groups = groups2)
1081 target1 = self.igmp_recv_task(self.V_INF1, groups2, join_state1)
1082 log.info('Interface is receiving multicast groups %s' %groups2)
1083 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001084
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001085 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001086 def test_igmp_exclude_empty_src_list(self):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001087 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001088 def igmp_exclude_empty_src_list():
1089 self.igmp_exclude_empty_src_list()
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001090 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001091 reactor.callLater(0, igmp_exclude_empty_src_list)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001092 return df
1093
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001094 def igmp_join_sourceip_0_0_0_0(self, df = None):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001095 groups1 = (self.MGROUP1,)
1096 groups2 = (self.MGROUP2,)
1097 groups = groups1 + groups2
1098 ip_src = '0.0.0.0'
1099 self.igmp_send_joins_different_groups_srclist(groups,
1100 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['5.5.5.5']),
1101 intf = self.V_INF1, delay = 2, ip_src = ip_src)
1102 ip_src = self.IP_SRC
1103 dst_mac = '01:00:5e:02:02:03'
1104 src_ip = '5.5.5.5'
1105 if df is None:
1106 df = defer.Deferred()
1107 igmpState1 = IGMPTestState(groups = groups2, df = df)
1108 igmpStateRecv1 = IGMPTestState(groups = groups2, df = df)
1109 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1110 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1111 mcastTraffic1.start()
1112 join_state1 = IGMPTestState(groups = groups2)
1113 target1 = self.igmp_recv_task(self.V_INF1, groups2, join_state1)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001114 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 -07001115 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001116
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001117 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001118 def test_igmp_join_sourceip_0_0_0_0(self):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001119 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001120 def igmp_join_sourceip_0_0_0_0():
1121 self.igmp_join_sourceip_0_0_0_0(df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001122 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001123 reactor.callLater(0, igmp_join_sourceip_0_0_0_0)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -07001124 return df
1125
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001126 def igmp_invalid_join_packet(self, df = None):
Chetan Gaonker586fec32016-04-29 17:33:54 -07001127 groups1 = (self.MGROUP1,)
1128 groups2 = (self.MINVALIDGROUP1,)
1129 groups = groups1 + groups2
1130 ip_src = '1.1.1.1'
1131 self.igmp_send_joins_different_groups_srclist(groups,
1132 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['5.5.5.5']),
1133 intf = self.V_INF1, delay = 2, ip_src = ip_src)
1134 ip_src = self.IP_SRC
1135 dst_mac = '01:00:5e:02:02:03'
1136 src_ip = '5.5.5.5'
1137 if df is None:
1138 df = defer.Deferred()
1139 igmpState1 = IGMPTestState(groups = groups2, df = df)
1140 igmpStateRecv1 = IGMPTestState(groups = groups2, df = df)
1141 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1142 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1143 mcastTraffic1.start()
1144 join_state1 = IGMPTestState(groups = groups2)
1145 target1 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1)
1146 assert target1==1, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001147 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 -07001148 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001149
Chetan Gaonker586fec32016-04-29 17:33:54 -07001150 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001151 def test_igmp_invalid_join_packet(self):
Chetan Gaonker586fec32016-04-29 17:33:54 -07001152 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001153 def igmp_invalid_join_packet():
1154 self.igmp_invalid_join_packet(df = df)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001155 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001156 reactor.callLater(0, igmp_invalid_join_packet)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001157 return df
1158
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001159 def igmp_join_data_receiving_during_subscriber_link_toggle(self, df = None):
Chetan Gaonker586fec32016-04-29 17:33:54 -07001160 groups1 = (self.MGROUP1,)
1161 groups2 = (self.MGROUP2,)
1162 groups = groups1 + groups2
1163 ip_src = '1.1.1.1'
1164 self.igmp_send_joins_different_groups_srclist(groups,
1165 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['5.5.5.5']),
1166 intf = self.V_INF1, delay = 2, ip_src = ip_src)
1167 ip_src = self.IP_SRC
1168 dst_mac = '01:00:5e:02:02:03'
1169 src_ip = '5.5.5.5'
1170 if df is None:
1171 df = defer.Deferred()
1172 igmpState1 = IGMPTestState(groups = groups2, df = df)
1173 igmpStateRecv1 = IGMPTestState(groups = groups2, df = df)
1174 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1175 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1176 mcastTraffic1.start()
1177 join_state1 = IGMPTestState(groups = groups2)
1178 target1 = self.igmp_recv_task(self.V_INF1, groups2, join_state1)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001179 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 -07001180 os.system('ifconfig '+self.V_INF1+' down')
1181 log.info(' the self.V_INF1 %s is down now ' %self.V_INF1)
1182 os.system('ifconfig '+self.V_INF1)
1183 time.sleep(10)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001184 os.system('ifconfig '+self.V_INF1+' up')
1185 os.system('ifconfig '+self.V_INF1)
1186 log.info(' the self.V_INF1 %s is up now ' %self.V_INF1)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001187 target1 = self.igmp_recv_task(self.V_INF1, groups2, join_state1)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001188 log.info('Interface is receiving traffic from multicast groups %s when we nterface up after down ' %groups2)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001189 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001190
Chetan Gaonker586fec32016-04-29 17:33:54 -07001191 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001192 def test_igmp_join_data_received_during_subscriber_link_toggle(self):
Chetan Gaonker586fec32016-04-29 17:33:54 -07001193 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001194 def igmp_join_data_received_during_subscriber_link_toggle():
1195 self.igmp_join_data_received_during_subscriber_link_toggle(df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001196 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001197 reactor.callLater(0, igmp_join_data_received_during_subscriber_link_toggle)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001198 return df
1199
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001200 def igmp_join_data_received_during_channel_distributor_link_toggle(self, df = None):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001201 groups1 = (self.MGROUP1,)
1202 groups2 = (self.MGROUP2,)
1203 groups = groups1 + groups2
1204 ip_src = '1.1.1.1'
1205 self.igmp_send_joins_different_groups_srclist(groups,
1206 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['5.5.5.5', '6.6.6.6']),
1207 intf = self.V_INF1, delay = 2, ip_src = ip_src)
1208 ip_src = self.IP_SRC
1209 dst_mac1 = '01:00:5e:01:02:03'
1210 dst_mac2 = '01:00:5e:02:02:03'
1211 src_ip2 = '5.5.5.5'
1212 src_ip1 = '2.2.2.2'
1213 if df is None:
1214 df = defer.Deferred()
1215 igmpState1 = IGMPTestState(groups = groups1, df = df)
1216 igmpState2 = IGMPTestState(groups = groups2, df = df)
1217 igmpStateRecv1 = IGMPTestState(groups = groups1, df = df)
1218 igmpStateRecv2 = IGMPTestState(groups = groups2, df = df)
1219 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac1,
1220 src_ip = src_ip1, cb = self.send_mcast_cb, arg = igmpState1)
1221 mcastTraffic2 = McastTraffic(groups2, iface= 'veth3', dst_mac = dst_mac2,
1222 src_ip = src_ip2, cb = self.send_mcast_cb, arg = igmpState2)
1223 mcastTraffic1.start()
1224 mcastTraffic2.start()
1225 join_state1 = IGMPTestState(groups = groups1)
1226 join_state2 = IGMPTestState(groups = groups2)
1227 target1 = self.igmp_recv_task(self.V_INF1, groups1, join_state1)
1228 target2 = self.igmp_recv_task(self.V_INF1, groups2, join_state2)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001229 mcastTraffic1.stop()
1230 os.system('ifconfig '+'veth2'+' down')
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001231 os.system('ifconfig '+'veth2')
1232 time.sleep(10)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001233 target2 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001234 target1 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
1235 assert target1==1, 'EXPECTED FAILURE'
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001236 os.system('ifconfig '+'veth2'+' up')
1237 os.system('ifconfig '+'veth2')
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001238 time.sleep(10)
1239 mcastTraffic1.start()
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001240 target1 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
1241 target2 = self.igmp_recv_task(self.V_INF1, groups2, join_state2)
1242 target2 = self.igmp_recv_task(self.V_INF1, groups2, join_state2)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001243 mcastTraffic2.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001244
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001245 ## This test case is failing to receive traffic from multicast data from defferent channel interfaces TO-DO
1246 ###### TO DO scenario #######
1247 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+60)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001248 def test_igmp_join_data_received_during_channel_distributors_link_toggle(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001249 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001250 def igmp_join_data_receiving_during_channel_distributor_link_toggle():
1251 self.igmp_join_data_receiving_during_channel_distributor_link_toggle(df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001252 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001253 reactor.callLater(0, igmp_join_data_receiving_during_channel_distributor_link_toggle)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001254 return df
Chetan Gaonker586fec32016-04-29 17:33:54 -07001255
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001256 def igmp_invalidClassD_IP_join_packet(self, df = None):
Chetan Gaonker586fec32016-04-29 17:33:54 -07001257 groups1 = (self.MGROUP1,)
1258 groups2 = (self.MINVALIDGROUP2,)
1259 groups = groups1 + groups2
1260 ip_src = '1.1.1.1'
1261 self.igmp_send_joins_different_groups_srclist(groups,
1262 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['5.5.5.5']),
1263 intf = self.V_INF1, delay = 2, ip_src = ip_src)
1264 ip_src = self.IP_SRC
1265 dst_mac = '01:00:5e:02:02:03'
1266 src_ip = '5.5.5.5'
1267 if df is None:
1268 df = defer.Deferred()
1269 igmpState1 = IGMPTestState(groups = groups2, df = df)
1270 igmpStateRecv1 = IGMPTestState(groups = groups2, df = df)
1271 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1272 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1273 mcastTraffic1.start()
1274 join_state1 = IGMPTestState(groups = groups2)
1275 target1 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1)
1276 assert target1==1, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001277 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 -07001278 mcastTraffic1.stop()
Chetan Gaonker586fec32016-04-29 17:33:54 -07001279
1280 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001281 def test_igmp_invalid_class_d_ip_for_join_packet(self):
Chetan Gaonker586fec32016-04-29 17:33:54 -07001282 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001283 def igmp_invalidClass_D_IP_join_packet():
1284 self.igmp_invalidClass_D_IP_join_packet(df = df)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001285 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001286 reactor.callLater(0, igmp_invalidClassD_IP_join_packet)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001287 return df
1288
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001289 def igmp_invalidClassD_IP_as_srclistIP_join_packet(self, df = None):
Chetan Gaonker586fec32016-04-29 17:33:54 -07001290 groups1 = (self.MGROUP1,)
1291 groups2 = (self.MGROUP2,)
1292 groups = groups1 + groups2
1293 ip_src = '1.1.1.1'
1294 self.igmp_send_joins_different_groups_srclist(groups,
1295 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['239.5.5.5']),
1296 intf = self.V_INF1, delay = 2, ip_src = ip_src)
1297 ip_src = self.IP_SRC
1298 dst_mac = '01:00:5e:02:02:03'
1299 src_ip = '5.5.5.5'
1300 if df is None:
1301 df = defer.Deferred()
1302 igmpState1 = IGMPTestState(groups = groups2, df = df)
1303 igmpStateRecv1 = IGMPTestState(groups = groups2, df = df)
1304 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1305 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1306 mcastTraffic1.start()
1307 join_state1 = IGMPTestState(groups = groups2)
1308 target1 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1)
1309 assert target1==1, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001310 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 -07001311 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001312
Chetan Gaonker586fec32016-04-29 17:33:54 -07001313 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001314 def test_igmp_invalid_class_d_ip_as_srclist_ip_for_join_packet(self):
Chetan Gaonker586fec32016-04-29 17:33:54 -07001315 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001316 def igmp_invalidClassD_IP_as_srclistIP_join_packet():
1317 self.igmp_invalidClassD_IP_as_srclistIP_join_packet(df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001318 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001319 reactor.callLater(0, igmp_invalidClassD_IP_as_srclistIP_join_packet)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001320 return df
Chetan Gaonkerf72ca402016-05-02 16:29:32 -07001321
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001322 def igmp_general_query_recv_packet(self, df = None):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001323 groups1 = (self.MGROUP1,)
1324 groups2 = (self.MGROUP2,)
1325 groups = groups1 + groups2
1326 ip_src = '1.1.1.1'
1327 self.igmp_send_joins_different_groups_srclist(groups,
1328 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['5.5.5.5']),
1329 intf = self.V_INF1, delay = 2, ip_src = ip_src)
1330 ip_src = self.IP_SRC
1331 dst_mac = '01:00:5e:02:02:03'
1332 src_ip = '5.5.5.5'
1333 if df is None:
1334 df = defer.Deferred()
1335 igmpState1 = IGMPTestState(groups = groups2, df = df)
1336 igmpStateRecv1 = IGMPTestState(groups = groups2, df = df)
1337 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1338 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1339 mcastTraffic1.start()
1340 join_state1 = IGMPTestState(groups = groups2)
1341 log.info('Started delay to verify multicast data taraffic for group %s is received or not for 180 sec ' %groups2)
1342 time.sleep(100)
1343 target2 = self.igmp_recv_task(self.V_INF1, groups2, join_state1)
1344 log.info('Verified that multicast data for group %s is received after 100 sec ' %groups2)
1345 time.sleep(50)
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 150 sec ' %groups2)
1348 time.sleep(30)
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 180 sec ' %groups2)
1351 time.sleep(10)
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 190 sec ' %groups2)
1354 target3 = mcastTraffic1.isRecvStopped()
1355 assert target3==False, 'EXPECTED FAILURE'
1356 log.info('Verified that multicast data for a group %s is still transmitting from a data interface' %groups2)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001357 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 -07001358 target1 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1)
1359 assert target1==1, 'EXPECTED FAILURE'
1360 log.info('Interface is not receiving multicast data for group %s' %groups2)
1361 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001362
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001363 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+250)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001364 def test_igmp_general_query_received_traffic(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001365 df = defer.Deferred()
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001366 def igmp_general_query_recv_packet():
1367 self.igmp_general_query_recv_packet(df = df)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001368 df.callback(0)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001369 reactor.callLater(0, igmp_general_query_recv_packet)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001370 return df
A.R Karthick95d044e2016-06-10 18:44:36 -07001371
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001372 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+100)
1373 def test_igmp_query_received_on_joining_interface(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001374 groups = ['224.0.1.10', '225.0.0.10']
1375 leave_groups = ['224.0.1.10']
1376 df = defer.Deferred()
1377 igmpState = IGMPTestState(groups = groups, df = df)
1378 igmpStateRecv = IGMPTestState(groups = groups, df = df)
1379 igmpStateList = (igmpState, igmpStateRecv)
A.R Karthick95d044e2016-06-10 18:44:36 -07001380 mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb,
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001381 arg = igmpState)
1382 self.df = df
1383 self.mcastTraffic = mcastTraffic
1384 self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP)
A.R Karthick95d044e2016-06-10 18:44:36 -07001385
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001386 def igmp_srp_task(stateList):
1387 igmpSendState, igmpRecvState = stateList
1388 if not mcastTraffic.isRecvStopped():
1389 result = self.igmp_recv(igmpRecvState)
1390 reactor.callLater(0, igmp_srp_task, stateList)
1391 else:
1392 self.mcastTraffic.stop()
1393 self.recv_socket.close()
1394 self.igmp_verify_leave(stateList, leave_groups)
1395 self.df.callback(0)
1396
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001397 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 -07001398 self.send_igmp_join_recvQuery(groups)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001399 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 -07001400 mcastTraffic.start()
1401 self.test_timer = reactor.callLater(self.MCAST_TRAFFIC_TIMEOUT, self.mcast_traffic_timer)
1402 reactor.callLater(0, igmp_srp_task, igmpStateList)
1403 return df
1404
1405 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+190)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001406 def test_igmp_for_periodic_query_received_on_joining_interface(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001407 groups = ['224.0.1.10', '225.0.0.10']
1408 leave_groups = ['224.0.1.10']
1409 df = defer.Deferred()
1410 igmpState = IGMPTestState(groups = groups, df = df)
1411 igmpStateRecv = IGMPTestState(groups = groups, df = df)
1412 igmpStateList = (igmpState, igmpStateRecv)
A.R Karthick95d044e2016-06-10 18:44:36 -07001413 mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb,
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001414 arg = igmpState)
1415 self.df = df
1416 self.mcastTraffic = mcastTraffic
1417 self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP)
A.R Karthick95d044e2016-06-10 18:44:36 -07001418
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001419 def igmp_srp_task(stateList):
1420 igmpSendState, igmpRecvState = stateList
1421 if not mcastTraffic.isRecvStopped():
1422 result = self.igmp_recv(igmpRecvState)
1423 reactor.callLater(0, igmp_srp_task, stateList)
1424 else:
1425 self.mcastTraffic.stop()
1426 self.recv_socket.close()
1427 self.igmp_verify_leave(stateList, leave_groups)
1428 self.df.callback(0)
1429
1430 self.send_igmp_join_recvQuery(groups,3)
1431 return df
1432
1433 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+190)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001434 def test_igmp_for_periodic_query_received_and_checking_entry_deleted(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001435 groups = ['224.0.1.10', '225.0.0.10']
1436 leave_groups = ['224.0.1.10']
1437 df = defer.Deferred()
1438 igmpState = IGMPTestState(groups = groups, df = df)
1439 igmpStateRecv = IGMPTestState(groups = groups, df = df)
1440 igmpStateList = (igmpState, igmpStateRecv)
A.R Karthick95d044e2016-06-10 18:44:36 -07001441 mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb,
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001442 arg = igmpState)
1443 self.df = df
1444 self.mcastTraffic = mcastTraffic
1445 self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP)
A.R Karthick95d044e2016-06-10 18:44:36 -07001446
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001447 def igmp_srp_task(stateList):
1448 igmpSendState, igmpRecvState = stateList
1449 if not mcastTraffic.isRecvStopped():
1450 result = self.igmp_recv(igmpRecvState)
1451 reactor.callLater(0, igmp_srp_task, stateList)
1452 else:
1453 self.mcastTraffic.stop()
1454 self.recv_socket.close()
1455 self.igmp_verify_leave(stateList, leave_groups)
1456 self.df.callback(0)
1457
1458 self.send_igmp_join_recvQuery(groups,3)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001459 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 -07001460 mcastTraffic.start()
1461 self.test_timer = reactor.callLater(self.MCAST_TRAFFIC_TIMEOUT, self.mcast_traffic_timer)
1462 reactor.callLater(0, igmp_srp_task, igmpStateList)
1463 return df
1464
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001465 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+190)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001466 def test_igmp_member_query_interval_and_expiry_for_rejoining_interface(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001467 groups = ['224.0.1.10', '225.0.0.10']
1468 leave_groups = ['224.0.1.10']
1469 df = defer.Deferred()
1470 igmpState = IGMPTestState(groups = groups, df = df)
1471 igmpStateRecv = IGMPTestState(groups = groups, df = df)
1472 igmpStateList = (igmpState, igmpStateRecv)
A.R Karthick95d044e2016-06-10 18:44:36 -07001473 mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb,
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001474 arg = igmpState)
1475 self.df = df
1476 self.mcastTraffic = mcastTraffic
1477 self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP)
A.R Karthick95d044e2016-06-10 18:44:36 -07001478
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001479 def igmp_srp_task(stateList):
1480 igmpSendState, igmpRecvState = stateList
1481 if not mcastTraffic.isRecvStopped():
1482 result = self.igmp_recv(igmpRecvState)
1483 reactor.callLater(0, igmp_srp_task, stateList)
1484 else:
1485 self.mcastTraffic.stop()
1486 self.recv_socket.close()
1487 self.igmp_verify_leave(stateList, leave_groups)
1488 self.df.callback(0)
1489
1490 self.send_igmp_join_recvQuery(groups,3)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001491 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 -07001492 self.send_igmp_join(groups)
1493 mcastTraffic.start()
1494 self.test_timer = reactor.callLater(self.MCAST_TRAFFIC_TIMEOUT, self.mcast_traffic_timer)
1495 reactor.callLater(0, igmp_srp_task, igmpStateList)
1496 return df
1497
1498 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+50)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001499 def test_igmp_leave_received_group_and_source_specific_query(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001500 groups = ['224.0.1.10', '225.0.0.10']
1501 leave_groups = ['224.0.1.10']
1502 df = defer.Deferred()
1503 igmpState = IGMPTestState(groups = groups, df = df)
1504 igmpStateRecv = IGMPTestState(groups = groups, df = df)
1505 igmpStateList = (igmpState, igmpStateRecv)
A.R Karthick95d044e2016-06-10 18:44:36 -07001506 mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb,
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001507 arg = igmpState)
1508 self.df = df
1509 self.mcastTraffic = mcastTraffic
1510 self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP)
A.R Karthick95d044e2016-06-10 18:44:36 -07001511
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001512 def igmp_srp_task(stateList):
1513 igmpSendState, igmpRecvState = stateList
1514 if not mcastTraffic.isRecvStopped():
1515 result = self.igmp_recv(igmpRecvState)
1516 reactor.callLater(0, igmp_srp_task, stateList)
1517 else:
1518 self.mcastTraffic.stop()
1519 self.recv_socket.close()
1520 self.igmp_verify_leave(stateList, leave_groups)
1521 self.df.callback(0)
1522
1523 self.send_igmp_join(groups)
1524 self.send_igmp_leave_listening_group_specific_query(leave_groups, delay = 3)
1525 return df
1526
1527 def igmp_change_to_exclude_src_list_check_for_group_source_specific_query(self, df = None):
1528 groups1 = (self.MGROUP1,)
1529 groups2 = (self.MGROUP2,)
1530 self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
1531 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
1532 intf = self.V_INF1, delay = 2)
1533 dst_mac = '01:00:5e:01:02:03'
1534 src_ip = '2.2.2.2'
1535 if df is None:
1536 df = defer.Deferred()
1537 igmpState1 = IGMPTestState(groups = groups1, df = df)
1538 igmpStateRecv1 = IGMPTestState(groups = groups1, df = df)
1539 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
1540 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1541 mcastTraffic1.start()
1542 join_state1 = IGMPTestState(groups = groups1)
1543 target1 = self.igmp_recv_task(self.V_INF1, groups1, join_state1)
1544 self.send_igmp_leave_listening_group_specific_query(groups = groups1, src_list = ['2.2.2.2'], iface = self.V_INF1, delay =2)
1545 time.sleep(10)
1546 target2 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
1547 assert target2 == 1, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001548 log.info('Interface is not receiving traffic from multicast groups %s after sending CHANGE_TO_EXCLUDE' %groups2)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001549 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001550
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001551 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+60)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001552 def test_igmp_change_to_exclude_src_list_and_check_for_group_source_specific_query(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001553 df = defer.Deferred()
1554 def igmp_change_to_exclude_src_list_check_for_group_source_specific_query():
1555 self.igmp_change_to_exclude_src_list_check_for_group_source_specific_query(df = df)
1556 df.callback(0)
1557 reactor.callLater(0, igmp_change_to_exclude_src_list_check_for_group_source_specific_query)
1558 return df
1559
1560 def igmp_change_to_include_src_list_check_for_general_query(self, df = None):
1561 groups1 = (self.MGROUP1,)
1562 groups2 = (self.MGROUP2,)
1563 self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4'],
1564 iface = self.V_INF1, delay = 2)
1565 dst_mac = '01:00:5e:01:02:03'
1566 src_ip = '2.2.2.2'
1567 if df is None:
1568 df = defer.Deferred()
1569 igmpState1 = IGMPTestState(groups = groups1, df = df)
1570 igmpStateRecv1 = IGMPTestState(groups = groups1, df = df)
1571 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
1572 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1573 mcastTraffic1.start()
1574 join_state1 = IGMPTestState(groups = groups1)
1575 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
1576 assert target1 == 1, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001577 log.info('Interface is not receiving traffic from multicast groups %s' %groups1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001578 self.igmp_send_joins_different_groups_srclist_wait_query_packets(groups1 + groups2,
1579 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['6.6.6.6', '5.5.5.5']),
1580 intf = self.V_INF1, delay = 2,query_group1 = 'group1', query_group2 = None)
1581 time.sleep(10)
1582 target2 = self.igmp_recv_task(self.V_INF1, groups1, join_state1)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001583 log.info('Interface is receiving traffic from multicast groups %s after send Change to include message' %groups1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001584 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001585
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001586 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+80)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001587 def test_igmp_change_to_include_src_list_and_check_for_general_query(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001588 df = defer.Deferred()
1589 def igmp_change_to_include_src_list_check_for_general_query():
1590 self.igmp_change_to_include_src_list_check_for_general_query(df = df)
1591 df.callback(0)
1592 reactor.callLater(0, igmp_change_to_include_src_list_check_for_general_query)
1593 return df
1594
1595 def igmp_allow_new_src_list_check_for_general_query(self, df = None):
1596 groups1 = (self.MGROUP1,)
1597 groups2 = (self.MGROUP2,)
1598 self.igmp_send_joins_different_groups_srclist(groups1+groups2,
1599 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
1600 intf = self.V_INF1, delay = 2)
1601 dst_mac = '01:00:5e:01:02:03'
1602 src_ip = '6.6.6.6'
1603 if df is None:
1604 df = defer.Deferred()
1605 igmpState1 = IGMPTestState(groups = groups1, df = df)
1606 igmpStateRecv1 = IGMPTestState(groups = groups1, df = df)
1607 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
1608 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1609 mcastTraffic1.start()
1610 join_state1 = IGMPTestState(groups = groups1)
1611 target1 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
1612 #assert target1 == 1, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001613 log.info('Interface is not receiving traffic from multicast groups %s' %groups1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001614 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']),
1615 intf = self.V_INF1, delay = 2, query_group1 = 'group1', query_group2 = None)
1616 target2 = self.igmp_recv_task(self.V_INF1, groups1, join_state1)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001617 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 -07001618 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001619
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001620 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+80)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001621 def test_igmp_allow_new_src_list_and_check_for_general_query(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001622 df = defer.Deferred()
1623 def igmp_allow_new_src_list_check_for_general_query():
1624 self.igmp_allow_new_src_list_check_for_general_query(df = df)
1625 df.callback(0)
1626 reactor.callLater(0, igmp_allow_new_src_list_check_for_general_query)
1627 return df
1628
1629 def igmp_block_old_src_list_check_for_group_source_specific_query(self, df = None):
1630 groups1 = (self.MGROUP1,)
1631 groups2 = (self.MGROUP2,)
1632 groups = groups1 + groups2
1633 self.igmp_send_joins_different_groups_srclist(groups,
1634 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
1635 intf = self.V_INF1, delay = 2)
1636 dst_mac = '01:00:5e:02:02:03'
1637 src_ip = '5.5.5.5'
1638 if df is None:
1639 df = defer.Deferred()
1640 igmpState1 = IGMPTestState(groups = groups2, df = df)
1641 igmpStateRecv1 = IGMPTestState(groups = groups2, df = df)
1642 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1643 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1644 mcastTraffic1.start()
1645 join_state1 = IGMPTestState(groups = groups2)
1646 target1 = self.igmp_recv_task(self.V_INF1, groups2, join_state1)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001647 log.info('Interface is receiving traffic from multicast groups %s' %groups2)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001648 self.igmp_send_joins_different_groups_srclist_wait_query_packets(groups,
1649 (['6.6.6.6', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '7.7.7.7']),
1650 intf = self.V_INF1, delay = 2, query_group1 = 'group1', query_group2 = None)
1651 target2 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1)
1652 assert target2 == 1, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001653 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 -07001654 mcastTraffic1.stop()
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001655
1656 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+90)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001657 def test_igmp_block_old_src_list_and_check_for_group_source_specific_query(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001658 df = defer.Deferred()
1659 def igmp_block_old_src_list_check_for_group_source_specific_query():
1660 self.igmp_block_old_src_list_check_for_group_source_specific_query(df = df)
1661 df.callback(0)
1662 reactor.callLater(0, igmp_block_old_src_list_check_for_group_source_specific_query)
1663 return df
1664
1665 def igmp_include_to_allow_src_list_check_for_general_query(self, df = None):
1666 groups1 = (self.MGROUP1,)
1667 groups2 = (self.MGROUP2,)
1668 self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
1669 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
1670 intf = self.V_INF1, delay = 2)
1671 dst_mac = '01:00:5e:01:02:03'
1672 src_ip = '2.2.2.2'
1673 if df is None:
1674 df = defer.Deferred()
1675 igmpState1 = IGMPTestState(groups = groups1, df = df)
1676 igmpStateRecv1 = IGMPTestState(groups = groups1, df = df)
1677 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
1678 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1679 mcastTraffic1.start()
1680 join_state1 = IGMPTestState(groups = groups1)
1681 target1 = self.igmp_recv_task(self.V_INF1, groups1, join_state1)
1682 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)
1683 target1 = self.igmp_recv_task(self.V_INF1, groups1, join_state1)
1684 mcastTraffic1.stop()
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001685
1686 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+40)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001687 def test_igmp_include_to_allow_src_list_and_check_for_general_query(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001688 df = defer.Deferred()
1689 def igmp_include_to_allow_src_list_check_for_general_query():
1690 self.igmp_include_to_allow_src_list_check_for_general_query(df = df)
1691 df.callback(0)
1692 reactor.callLater(0, igmp_include_to_allow_src_list_check_for_general_query)
1693 return df
1694
1695 def igmp_include_to_block_src_list_check_for_group_source_specific_query(self, df = None):
1696 groups1 = (self.MGROUP1,)
1697 groups2 = (self.MGROUP2,)
1698 self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
1699 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
1700 intf = self.V_INF1, delay = 2)
1701 dst_mac = '01:00:5e:01:02:03'
1702 src_ip = '2.2.2.2'
1703 if df is None:
1704 df = defer.Deferred()
1705 igmpState1 = IGMPTestState(groups = groups1, df = df)
1706 igmpStateRecv1 = IGMPTestState(groups = groups1, df = df)
1707 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
1708 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1709 mcastTraffic1.start()
1710 join_state1 = IGMPTestState(groups = groups1)
1711 target1 = self.igmp_recv_task(self.V_INF1, groups1, join_state1)
1712 self.send_igmp_leave_listening_group_specific_query(groups = groups1, src_list = ['6.6.6.6','7.7.7.7'],
1713 iface = self.V_INF1, delay = 2)
1714 target1 = self.igmp_recv_task(self.V_INF1, groups1, join_state1)
1715 mcastTraffic1.stop()
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001716
1717 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+40)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001718 def test_igmp_include_to_block_src_list_and_check_for_group_source_specific_query(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001719 df = defer.Deferred()
1720 def igmp_include_to_block_src_list_check_for_group_source_specific_query():
1721 self.igmp_include_to_block_src_list_check_for_group_source_specific_query(df = df)
1722 df.callback(0)
1723 reactor.callLater(0, igmp_include_to_block_src_list_check_for_group_source_specific_query)
1724 return df
1725
1726 def igmp_exclude_to_allow_src_list_check_for_general_query(self, df = None):
1727 groups1 = (self.MGROUP1,)
1728 groups2 = (self.MGROUP2,)
1729 self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4'],
1730 iface = self.V_INF1, delay = 2)
A.R Karthick95d044e2016-06-10 18:44:36 -07001731
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001732 dst_mac = '01:00:5e:01:02:03'
1733 src_ip = '2.2.2.2'
1734 if df is None:
1735 df = defer.Deferred()
1736 igmpState1 = IGMPTestState(groups = groups1, df = df)
1737 igmpStateRecv1 = IGMPTestState(groups = groups1, df = df)
1738 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
1739 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1740 mcastTraffic1.start()
1741 join_state1 = IGMPTestState(groups = groups1)
1742 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
1743 assert target1 == 1, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001744 log.info('Interface is not receiving traffic from multicast groups %s' %groups1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001745 self.igmp_send_joins_different_groups_srclist_wait_query_packets(groups1 + groups2,
1746 (['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)
1747 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
1748 assert target1 == 1, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001749 log.info('Interface is not receiving traffic from multicast groups %s' %groups1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001750 mcastTraffic1.stop()
A.R Karthick95d044e2016-06-10 18:44:36 -07001751
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001752 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+90)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001753 def test_igmp_exclude_to_allow_src_list_and_check_for_general_query(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001754 df = defer.Deferred()
1755 def igmp_exclude_to_allow_src_list_check_for_general_query():
1756 self.igmp_exclude_to_allow_src_list_check_for_general_query(df = df)
1757 df.callback(0)
1758 reactor.callLater(0, igmp_exclude_to_allow_src_list_check_for_general_query)
1759 return df
1760
1761 def igmp_exclude_to_block_src_list_check_for_group_source_specific_query(self, df = None):
1762 groups1 = (self.MGROUP1,)
1763 groups2 = (self.MGROUP2,)
1764 self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4'],
1765 iface = self.V_INF1, delay = 2)
A.R Karthick95d044e2016-06-10 18:44:36 -07001766
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001767 dst_mac = '01:00:5e:01:02:03'
1768 src_ip = '2.2.2.2'
1769 if df is None:
1770 df = defer.Deferred()
1771 igmpState1 = IGMPTestState(groups = groups1, df = df)
1772 igmpStateRecv1 = IGMPTestState(groups = groups1, df = df)
1773 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
1774 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1775 mcastTraffic1.start()
1776 join_state1 = IGMPTestState(groups = groups1)
1777 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
1778 assert target1 == 1, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001779 log.info('Interface is not receiving traffic from multicast groups %s' %groups1)
A.R Karthick95d044e2016-06-10 18:44:36 -07001780 self.send_igmp_leave_listening_group_specific_query(groups = groups1,
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001781 src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4', '5.5.5.5', '7.7.7.7'],
1782 iface = self.V_INF1, delay = 2)
1783 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
1784 assert target1 == 1, 'EXPECTED FAILURE'
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001785 log.info('Interface is not receiving traffic from multicast groups %s' %groups1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001786 mcastTraffic1.stop()
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001787
1788 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+40)
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001789 def test_igmp_exclude_to_block_src_list_and_check_for_group_source_specific_query(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001790 df = defer.Deferred()
1791 def igmp_exclude_to_block_src_list_check_for_group_source_specific_query():
1792 self.igmp_exclude_to_block_src_list_check_for_group_source_specific_query(df = df)
1793 df.callback(0)
1794 reactor.callLater(0, igmp_exclude_to_block_src_list_check_for_group_source_specific_query)
1795 return df
ChetanGaonkera7e2b412016-09-01 23:19:07 -07001796
1797 def iptomac(self, mcast_ip):
1798 mcast_mac = '01:00:5e:'
1799 octets = mcast_ip.split('.')
1800 second_oct = int(octets[1]) & 127
1801 third_oct = int(octets[2])
1802 fourth_oct = int(octets[3])
1803 mcast_mac = mcast_mac + format(second_oct,'02x') + ':' + format(third_oct, '02x') + ':' + format(fourth_oct, '02x')
1804 return mcast_mac
1805
1806 def send_multicast_data_traffic(self, group, intf= 'veth2',source = '1.2.3.4'):
1807 dst_mac = self.iptomac(group)
1808 eth = Ether(dst= dst_mac)
1809 ip = IP(dst=group,src=source)
1810 data = repr(monotonic.monotonic())
1811 sendp(eth/ip/data,count=20, iface = intf)
1812 pkt = (eth/ip/data)
1813 #log.info('multicast traffic packet %s'%pkt.show())
1814
1815 def verify_igmp_data_traffic(self, group, intf='veth0', source='1.2.3.4' ):
1816 log.info('verifying multicast traffic for group %s from source %s'%(group,source))
1817 self.success = False
1818 def recv_task():
1819 def igmp_recv_cb(pkt):
1820 #log.info('received multicast data packet is %s'%pkt.show())
1821 log.info('multicast data received for group %s from source %s'%(group,source))
1822 self.success = True
1823 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')
1824 t = threading.Thread(target = recv_task)
1825 t.start()
1826 self.send_multicast_data_traffic(group,source=source)
1827 t.join()
1828 return self.success
1829
1830 def test_igmp_include_exclude_modes(self):
1831 groups = ['224.2.3.4','230.5.6.7']
1832 src_list = ['2.2.2.2','3.3.3.3']
1833 dst_mac1 = self.iptomac(groups[0])
1834 dst_mac2 = self.iptomac(groups[1])
1835 self.onos_ssm_table_load(groups, src_list=src_list)
1836 self.send_igmp_join(groups = [groups[0]], src_list = src_list,record_type = IGMP_V3_GR_TYPE_INCLUDE,
1837 iface = self.V_INF1, delay = 2)
1838 self.send_igmp_join(groups = [groups[1]], src_list = src_list,record_type = IGMP_V3_GR_TYPE_EXCLUDE,
1839 iface = self.V_INF1, delay = 2)
1840 status = self.verify_igmp_data_traffic(groups[0],intf=self.V_INF1,source=src_list[0])
1841 assert_equal(status,True)
1842 status = self.verify_igmp_data_traffic(groups[1],intf = self.V_INF1,source= src_list[1])
1843 assert_equal(status,False)
1844
1845 def test_igmp_allow_new_source_mode(self):
1846 group = ['224.8.9.3']
1847 src_list = ['2.2.2.2','3.3.3.3']
1848 #dst_mac = self.iptomac(group[0])
1849 self.onos_ssm_table_load(group, src_list)
1850 self.send_igmp_join(groups = group, src_list = src_list[0],record_type = IGMP_V3_GR_TYPE_INCLUDE,
1851 iface = self.V_INF1, delay = 1)
1852 status = self.verify_igmp_data_traffic(group[0], intf=self.V_INF1,source = src_list[0])
1853 assert_equal(status,True) # expecting igmp data traffic from source src_list[0]
1854 self.send_igmp_join(groups = group, src_list = src_list[1],record_type = IGMP_V3_GR_TYPE_ALLOW_NEW,
1855 iface = self.V_INF1, delay = 1)
1856 for src in src_list:
1857 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1, source=src)
1858 assert_equal(status,True) # expecting igmp data traffic from both sources
1859
1860
1861 def test_igmp_include_to_exclude_mode_change(self):
1862 group = ['224.2.3.4']
1863 src_list = ['2.2.2.2','3.3.3.3']
1864 dst_mac = self.iptomac(group[0])
1865 self.onos_ssm_table_load(group, src_list)
1866 self.send_igmp_join(groups = group, src_list = src_list[0],record_type = IGMP_V3_GR_TYPE_INCLUDE,
1867 iface = self.V_INF1, delay = 1)
1868 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source= src_list[0])
1869 assert_equal(status,True) # expecting igmp data traffic from source src_list[0]
1870 self.send_igmp_join(groups = group, src_list = src_list[1],record_type = IGMP_V3_GR_TYPE_EXCLUDE,
1871 iface = self.V_INF1, delay = 1)
1872 for src in src_list:
1873 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source= src)
1874 assert_equal(status,False) # expecting igmp data traffic from both sources
1875
1876 def test_igmp_exclude_to_include_mode_change(self):
1877 group = ['224.2.3.4']
1878 src = ['2.2.2.2']
1879 dst_mac = self.iptomac(group[0])
1880 self.onos_ssm_table_load(group, src)
1881 self.send_igmp_join(groups = group, src_list = src,record_type = IGMP_V3_GR_TYPE_EXCLUDE,
1882 iface = self.V_INF1, delay = 1)
1883 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source=src[0])
1884 assert_equal(status,False) # not expecting igmp data traffic from source src_list[0]
1885 self.send_igmp_join(groups = group, src_list = src,record_type = IGMP_V3_GR_TYPE_INCLUDE,
1886 iface = self.V_INF1, delay = 1)
1887 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source = src[0])
1888 assert_equal(status,True) # expecting igmp data traffic from both sources
1889
1890 #this test case wotks properly if the snooping device(ONOS) have multicast router connected.
1891 def test_igmp_to_include_mode_with_null_source(self):
1892 groups = ['224.2.3.4','230.7.9.8']
1893 src = ['192.168.12.34']
1894 dst_mac = []
1895 dst_mac.append(self.iptomac(groups[0]))
1896 dst_mac.append(self.iptomac(groups[1]))
1897 self.onos_ssm_table_load(groups, src)
1898 self.send_igmp_join(groups = groups, src_list = src,record_type = IGMP_V3_GR_TYPE_INCLUDE,
1899 iface = self.V_INF1, delay = 1)
1900 for grp in groups:
1901 status = self.verify_igmp_data_traffic(grp,intf=self.V_INF1,source= src[0])
1902 assert_equal(status,True) # not expecting igmp data traffic from source src_list[0]
1903 #sending leave packet for group groups[1]
1904 self.send_igmp_join(groups = [groups[1]], src_list = [],record_type = IGMP_V3_GR_TYPE_CHANGE_TO_INCLUDE,
1905 iface = self.V_INF1, delay = 1)
1906 for grp in groups:
1907 status = self.verify_igmp_data_traffic(grp,intf=self.V_INF1,source= src[0])
1908 if grp is groups[0]:
1909 assert_equal(status,True) # expecting igmp data traffic to group groups[0]
1910 else:
1911 assert_equal(status,False) # not expecting igmp data traffic to group groups[1]
1912
1913 def test_igmp_to_include_mode(self):
1914 group = ['229.9.3.6']
1915 src_list = ['192.168.12.34','192.18.1.34']
1916 dst_mac = []
1917 dst_mac = self.iptomac(group[0])
1918 self.onos_ssm_table_load(group, src_list)
1919 self.send_igmp_join(groups = group, src_list = [src_list[0]],record_type = IGMP_V3_GR_TYPE_INCLUDE,
1920 iface = self.V_INF1, delay = 1)
1921 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source=src_list[0])
1922 assert_equal(status,True) # not expecting igmp data traffic from source src_list[0]
1923 self.send_igmp_join(groups = group, src_list = src_list,record_type = IGMP_V3_GR_TYPE_CHANGE_TO_INCLUDE,
1924 iface = self.V_INF1, delay = 1)
1925 for src in src_list:
1926 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source= src)
1927 assert_equal(status,True) # expecting igmp data traffic to group groups[0]
1928
1929 #this test case passed only if mulitcast router connected to ONOS.
1930 def test_igmp_blocking_old_source_mode(self):
1931 group = ['224.2.3.4']
1932 src_list = ['2.2.2.2','3.3.3.3']
1933 dst_mac = self.iptomac(group[0])
1934 self.onos_ssm_table_load(group, src_list)
1935 self.send_igmp_join(groups = group, src_list = src_list,record_type = IGMP_V3_GR_TYPE_INCLUDE,
1936 iface = self.V_INF1, delay = 1)
1937 for src in src_list:
1938 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1, source=src)
1939 assert_equal(status,True) # expecting igmp data traffic from source src_list[0]
1940 self.send_igmp_join(groups = group, src_list = [src_list[1]],record_type = IGMP_V3_GR_TYPE_BLOCK_OLD,
1941 iface = self.V_INF1, delay = 1)
1942 for src in src_list:
1943 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1, source=src)
1944 if src is src_list[0]:
1945 assert_equal(status,True) # expecting igmp data traffic from source src_list[0]
1946 else:
1947 assert_equal(status,False) # not expecting igmp data traffic from source src_list[1]
1948
1949 def test_igmp_multiple_joins_and_data_verification_with_100_groups(self):
1950 groups = []
1951 sources = []
1952 count = 1
1953 mcastips = self.mcast_ip_range(start_ip = '226.0.0.1',end_ip = '226.0.5.254')
1954 sourceips = self.source_ip_range(start_ip = '10.10.0.1',end_ip = '10.10.5.254')
1955 while count<=100:
1956 group = random.choice(mcastips)
1957 source = random.choice(sourceips)
1958 if group in groups:
1959 pass
1960 else:
1961 log.info('group and source are %s and %s'%(group,source))
1962 groups.append(group)
1963 sources.append(source)
1964 count += 1
1965 self.onos_ssm_table_load(groups,src_list=sources,flag=True)
1966 for i in range(100):
1967 self.send_igmp_join(groups = [groups[i]], src_list = [sources[i]],record_type = IGMP_V3_GR_TYPE_INCLUDE,
1968 iface = self.V_INF1)
1969 status = self.verify_igmp_data_traffic(groups[i],intf=self.V_INF1,source=sources[i])
1970 assert_equal(status, True)
1971 log.info('data received for group %s from source %s'%(groups[i],sources[i]))
1972
1973 def test_igmp_multiple_joins_with_data_verification_and_leaving_100_groups(self):
1974 groups = []
1975 sources = []
1976 count = 1
1977 mcastips = self.mcast_ip_range(start_ip = '226.0.0.1',end_ip = '226.0.5.254')
1978 sourceips = self.source_ip_range(start_ip = '10.10.0.1',end_ip = '10.10.5.254')
1979 while count<=100:
1980 group = random.choice(mcastips)
1981 source = random.choice(sourceips)
1982 if group in groups:
1983 pass
1984 else:
1985 log.info('group and source are %s and %s'%(group,source))
1986 groups.append(group)
1987 sources.append(source)
1988 count += 1
1989 self.onos_ssm_table_load(groups,src_list=sources,flag=True)
1990 for i in range(100):
1991 self.send_igmp_join(groups = [groups[i]], src_list = [sources[i]],record_type = IGMP_V3_GR_TYPE_INCLUDE,
1992 iface = self.V_INF1)
1993 status = self.verify_igmp_data_traffic(groups[i],intf=self.V_INF1,source=sources[i])
1994 assert_equal(status, True)
1995 log.info('data received for group %s from source %s'%(groups[i],sources[i]))
1996 self.send_igmp_join(groups = [groups[i]], src_list = [sources[i]],record_type = IGMP_V3_GR_TYPE_CHANGE_TO_EXCLUDE,
1997 iface = self.V_INF1, delay = 1)
1998 status = self.verify_igmp_data_traffic(groups[i],intf=self.V_INF1,source=sources[i])
1999 assert_equal(status, False)
2000 log.info("data not received for group %s from source %s after changing group mode to 'TO-EXCLUDE' mode"%(groups[i],sources[i]))
2001
2002 def test_igmp_group_source_for_only_config_with_1000_entries(self):
2003 groups = []
2004 sources = []
2005 count = 1
2006 mcastips = self.mcast_ip_range(start_ip = '229.0.0.1',end_ip = '229.0.50.254')
2007 sourceips = self.source_ip_range(start_ip = '10.10.0.1',end_ip = '10.10.50.254')
2008 while count<=1000:
2009 group = random.choice(mcastips)
2010 source = random.choice(sourceips)
2011 if group in groups:
2012 pass
2013 else:
2014 log.info('group and source are %s and %s'%(group,source))
2015 groups.append(group)
2016 sources.append(source)
2017 count += 1
2018 self.onos_ssm_table_load(groups,src_list=sources,flag=True)
2019
2020 def test_igmp_from_exclude_to_include_mode_with_100_groups(self):
2021 groups = []
2022 sources = []
2023 count = 1
2024 mcastips = self.mcast_ip_range(start_ip = '229.0.0.1',end_ip = '229.0.10.254')
2025 sourceips = self.source_ip_range(start_ip = '10.10.0.1',end_ip = '10.10.10.254')
2026 while count<=100:
2027 group = random.choice(mcastips)
2028 source = random.choice(sourceips)
2029 if group in groups:
2030 pass
2031 else:
2032 log.info('group and source are %s and %s'%(group,source))
2033 groups.append(group)
2034 sources.append(source)
2035 count += 1
2036 self.onos_ssm_table_load(groups,src_list=sources,flag=True)
2037 for i in range(100):
2038 self.send_igmp_join(groups = [groups[i]], src_list = [sources[i]],record_type = IGMP_V3_GR_TYPE_EXCLUDE,
2039 iface = self.V_INF1)
2040 status = self.verify_igmp_data_traffic(groups[i],intf=self.V_INF1,source=sources[i])
2041 assert_equal(status, False)
2042 log.info('data not received for group %s from source %s as expected'%(groups[i],sources[i]))
2043 self.send_igmp_join(groups = [groups[i]], src_list = [sources[i]],record_type = IGMP_V3_GR_TYPE_INCLUDE,
2044 iface = self.V_INF1)
2045 status = self.verify_igmp_data_traffic(groups[i],intf=self.V_INF1,source=sources[i])
2046 assert_equal(status, True)
2047 log.info("data received for group %s from source %s after changing group mode to 'TO-INCLUDE' mode"%(groups[i],sources[i]))
2048
2049 def test_igmp_with_multiple_joins_and_data_verify_with_1000_groups(self):
2050 groups = []
2051 sources = []
2052 count = 1
2053 mcastips = self.mcast_ip_range(start_ip = '229.0.0.1',end_ip = '229.0.30.254')
2054 sourceips = self.source_ip_range(start_ip = '10.10.0.1',end_ip = '10.10.30.254')
2055 while count<=1000:
2056 group = random.choice(mcastips)
2057 source = random.choice(sourceips)
2058 if group in groups:
2059 pass
2060 else:
2061 log.info('group and source are %s and %s'%(group,source))
2062 groups.append(group)
2063 sources.append(source)
2064 count += 1
2065 self.onos_ssm_table_load(groups,src_list=sources,flag=True)
2066 for i in range(1000):
2067 self.send_igmp_join(groups = [groups[i]], src_list = [sources[i]],record_type = IGMP_V3_GR_TYPE_INCLUDE,
2068 iface = self.V_INF1)
2069 status = self.verify_igmp_data_traffic(groups[i],intf=self.V_INF1,source=sources[i])
2070 assert_equal(status, True)
2071 log.info('data received for group %s from source %s - %d'%(groups[i],sources[i],i))
2072
2073 def test_igmp_with_multiple_joins_and_data_verify_with_5000_groups(self):
2074 groups = []
2075 sources = []
2076 count = 1
2077 mcastips = self.mcast_ip_range(start_ip = '231.39.19.121',end_ip = '231.40.30.25')
2078 sourceips = self.source_ip_range(start_ip = '192.168.56.43',end_ip = '192.169.110.30')
2079 while count<=5000:
2080 group = random.choice(mcastips)
2081 source = random.choice(sourceips)
2082 if group in groups:
2083 pass
2084 else:
2085 log.info('group and source are %s and %s'%(group,source))
2086 groups.append(group)
2087 sources.append(source)
2088 count += 1
2089 self.onos_ssm_table_load(groups,src_list=sources,flag=True)
2090 for i in range(5000):
2091 self.send_igmp_join(groups = [groups[i]], src_list = [sources[i]],record_type = IGMP_V3_GR_TYPE_INCLUDE,
2092 iface = self.V_INF1)
2093 status = self.verify_igmp_data_traffic(groups[i],intf=self.V_INF1,source=sources[i])
2094 assert_equal(status, True)
2095 log.info('data received for group %s from source %s - %d'%(groups[i],sources[i],i))
2096
2097 """def test_igmp_join_from_multiple_infts(self):
2098 groups = ['229.9.3.6','234.20.56.2']
2099 src_list = ['192.168.12.34','192.18.1.34']
2100 self.onos_ssm_table_load(groups, src_list=src_list)
2101 self.send_igmp_join(groups = [groups[0]], src_list = src_list,record_type = IGMP_V3_GR_TYPE_INCLUDE,
2102 iface = 'veth0')
2103 self.send_igmp_join(groups = [groups[1]], src_list = src_list,record_type = IGMP_V3_GR_TYPE_INCLUDE,
2104 iface = 'veth2')
2105 status = self.verify_igmp_data_traffic(groups[0],intf='veth0',source=src_list[0])
2106 assert_equal(status,True)
2107 status = self.verify_igmp_data_traffic(groups[1],intf='veth2',source=src_list[1])
2108 assert_equal(status,True) # not expecting igmp data traffic from source src_list[0]
2109 """
2110
2111 def test_igmp_send_data_to_non_registered_group(self):
2112 group = ['224.2.3.4']
2113 src = ['2.2.2.2']
2114 self.onos_ssm_table_load(group,src_list= src)
2115 self.send_igmp_join(groups = ['239.0.0.1'], src_list = src,record_type = IGMP_V3_GR_TYPE_INCLUDE,
2116 iface = self.V_INF1, delay = 1)
2117 status = self.verify_igmp_data_traffic('239.0.0.1',intf=self.V_INF1,source=src[0])
2118 assert_equal(status,False) # not expecting igmp data traffic from source src_list[0]
2119
2120 def test_igmp_traffic_verification_for_registered_group_with_no_join_sent(self):
2121 group = ['227.12.3.40']
2122 src = ['190.4.19.67']
2123 self.onos_ssm_table_load(group,src_list= src)
2124 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source=src[0])
2125 assert_equal(status,False) # not expecting igmp data traffic from source src_list[0]
2126
2127 def test_igmp_toggling_app_activation(self):
2128 group = [self.random_mcast_ip()]
2129 src = [self.randomsourceip()]
2130 self.onos_ssm_table_load(group,src_list= src)
2131 self.send_igmp_join(groups = group, src_list = src,record_type = IGMP_V3_GR_TYPE_INCLUDE,
2132 iface = self.V_INF1)
2133 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source=src[0])
2134 assert_equal(status,True) # expecting igmp data traffic from source src_list[0]
2135 log.info('Multicast traffic received for group %s from source %s before the app is deactivated'%(group[0],src[0]))
2136 self.onos_ctrl.deactivate()
2137 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source=src[0])
2138 assert_equal(status,False) #not expecting igmp data traffic from source src_list[0]
2139 log.info('Multicast traffic not received for group %s from source %s after the app is deactivated'%(group[0],src[0]))
2140 self.onos_ctrl.activate()
2141 status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source=src[0])
2142 assert_equal(status,True) # expecting igmp data traffic from source src_list[0]
2143 log.info('Multicast traffic received for group %s from source %s the app is re-activated'%(group[0],src[0]))
2144
2145 def test_igmp_with_mismatch_for_dst_ip_and_mac_in_data_packets(self):
2146 group = ['228.18.19.29']
2147 source = [self.randomsourceip()]
2148 self.onos_ssm_table_load(group,src_list= source)
2149 self.send_igmp_join(groups = group, src_list = source,record_type = IGMP_V3_GR_TYPE_INCLUDE,
2150 iface = self.V_INF1)
2151 dst_mac = '01:00:5e:0A:12:09'
2152 eth = Ether(dst= dst_mac)
2153 ip = IP(dst=group[0],src=source[0])
2154 data = repr(monotonic.monotonic())
2155 pkt = (eth/ip/data)
2156 log.info('Multicast traffic packet %s'%pkt.show())
2157 self.success = False
2158 def recv_task():
2159 def igmp_recv_cb(pkt):
2160 #log.info('received multicast data packet is %s'%pkt.show())
2161 log.info('multicast data received for group %s from source %s'%(group[0],source[0]))
2162 self.success = True
2163 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')
2164 t = threading.Thread(target = recv_task)
2165 t.start()
2166 sendp(eth/ip/data,count=20, iface = 'veth2')
2167 t.join()
2168 assert_equal(status,False) # not expecting igmp data traffic from source src_list[0]
2169
2170 #test case failing, ONOS registering unicast ip also as an igmp join
2171 def test_igmp_registering_invalid_group(self):
2172 groups = ['218.18.19.29','240.10.34.94','224.19.256.10']
2173 source = [self.randomsourceip()]
2174 ssm_dict = {'apps' : { 'org.onosproject.igmp' : { 'ssmTranslate' : [] } } }
2175 ssm_xlate_list = ssm_dict['apps']['org.onosproject.igmp']['ssmTranslate']
2176 for g in groups:
2177 for s in source:
2178 d = {}
2179 d['source'] = s or '0.0.0.0'
2180 d['group'] = g
2181 ssm_xlate_list.append(d)
2182 log.info('onos load config is %s'%ssm_dict)
2183 status, code = OnosCtrl.config(ssm_dict)
2184 assert_equal(status,False)
2185
2186 def test_igmp_registering_invalid_source(self):
2187 groups = [self.random_mcast_ip()]
2188 sources = ['224.10.28.34','193.73.219.257']
2189 ssm_dict = {'apps' : { 'org.onosproject.igmp' : { 'ssmTranslate' : [] } } }
2190 ssm_xlate_list = ssm_dict['apps']['org.onosproject.igmp']['ssmTranslate']
2191 for g in groups:
2192 for s in sources:
2193 d = {}
2194 d['source'] = s or '0.0.0.0'
2195 d['group'] = g
2196 ssm_xlate_list.append(d)
2197 log.info('onos load config is %s'%ssm_dict)
2198 status, code = OnosCtrl.config(ssm_dict)
2199 assert_equal(status,False)
2200