blob: b6ad1a2763b4bfa70eb5060c999fcd37e04e2abd [file] [log] [blame]
Chetan Gaonker25470972016-02-26 08:52:15 -08001import unittest
2from nose.tools import *
3from nose.twistedtools import reactor, deferred
4from twisted.internet import defer
5from scapy.all import *
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -08006import time, monotonic
Chetan Gaonker25470972016-02-26 08:52:15 -08007import os, sys
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -08008import tempfile
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -08009import random
10import threading
Chetan Gaonkere88c95c2016-03-02 05:21:47 -080011from IGMP import *
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -080012from McastTraffic import *
13from Stats import Stats
Chetan Gaonker4a25e2b2016-03-04 14:45:15 -080014from OnosCtrl import OnosCtrl
Chetan Gaonker441c9ac2016-05-06 10:30:13 -070015from OltConfig import OltConfig
Chetan Gaonker4eb12072016-03-28 15:04:15 -070016from Channels import IgmpChannel
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -080017log.setLevel('INFO')
Chetan Gaonker25470972016-02-26 08:52:15 -080018
19class IGMPTestState:
20
21 def __init__(self, groups = [], df = None, state = 0):
22 self.df = df
23 self.state = state
24 self.counter = 0
25 self.groups = groups
26 self.group_map = {} ##create a send/recv count map
27 for g in groups:
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -080028 self.group_map[g] = (Stats(), Stats())
29
30 def update(self, group, tx = 0, rx = 0, t = 0):
31 self.counter += 1
Chetan Gaonker25470972016-02-26 08:52:15 -080032 index = 0 if rx == 0 else 1
33 v = tx if rx == 0 else rx
34 if self.group_map.has_key(group):
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -080035 self.group_map[group][index].update(packets = v, t = t)
Chetan Gaonker25470972016-02-26 08:52:15 -080036
37 def update_state(self):
38 self.state = self.state ^ 1
Chetan Gaonker25470972016-02-26 08:52:15 -080039
40class igmp_exchange(unittest.TestCase):
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -080041
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -070042 V_INF1 = 'veth0'
43 V_INF2 = 'veth1'
44 MGROUP1 = '239.1.2.3'
45 MGROUP2 = '239.2.2.3'
Chetan Gaonker441c9ac2016-05-06 10:30:13 -070046 MINVALIDGROUP1 = '255.255.255.255'
47 MINVALIDGROUP2 = '239.255.255.255'
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -070048 MMACGROUP1 = "01:00:5e:01:02:03"
49 MMACGROUP2 = "01:00:5e:02:02:03"
50 IGMP_DST_MAC = "01:00:5e:00:01:01"
51 IGMP_SRC_MAC = "5a:e1:ac:ec:4d:a1"
52 IP_SRC = '1.2.3.4'
53 IP_DST = '224.0.1.1'
Chetan Gaonker441c9ac2016-05-06 10:30:13 -070054 NEGATIVE_TRAFFIC_STATUS = 1
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -070055 igmp_eth = Ether(dst = IGMP_DST_MAC, src = IGMP_SRC_MAC, type = ETH_P_IP)
56 igmp_ip = IP(dst = IP_DST, src = IP_SRC)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -080057 IGMP_TEST_TIMEOUT = 5
Chetan Gaonker441c9ac2016-05-06 10:30:13 -070058 IGMP_QUERY_TIMEOUT = 60
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -080059 MCAST_TRAFFIC_TIMEOUT = 10
Chetan Gaonker4eb12072016-03-28 15:04:15 -070060 PORT_TX_DEFAULT = 2
61 PORT_RX_DEFAULT = 1
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -080062 max_packets = 100
Chetan Gaonker4a25e2b2016-03-04 14:45:15 -080063 app = 'org.onosproject.igmp'
Chetan Gaonker441c9ac2016-05-06 10:30:13 -070064 olt_conf_file = os.path.join(os.path.dirname(os.path.realpath(__file__)), '../setup/olt_config.json')
Chetan Gaonker4a25e2b2016-03-04 14:45:15 -080065
Chetan Gaonker441c9ac2016-05-06 10:30:13 -070066 @classmethod
67 def setUpClass(cls):
68 cls.olt = OltConfig(olt_conf_file = cls.olt_conf_file)
69 OnosCtrl.cord_olt_config(cls.olt.olt_device_data())
70
71 @classmethod
72 def tearDownClass(cls): pass
73
Chetan Gaonker4a25e2b2016-03-04 14:45:15 -080074 def setUp(self):
75 ''' Activate the dhcp app'''
76 self.onos_ctrl = OnosCtrl(self.app)
77 status, _ = self.onos_ctrl.activate()
78 assert_equal(status, True)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -070079 time.sleep(2)
Chetan Gaonker4eb12072016-03-28 15:04:15 -070080 self.igmp_channel = IgmpChannel()
Chetan Gaonker4a25e2b2016-03-04 14:45:15 -080081
82 def teardown(self):
83 '''Deactivate the dhcp app'''
84 self.onos_ctrl.deactivate()
85
86 def onos_load_config(self, config):
Chetan Gaonkera2b87df2016-03-31 15:41:31 -070087 status, code = OnosCtrl.config(config)
Chetan Gaonker4a25e2b2016-03-04 14:45:15 -080088 if status is False:
89 log.info('JSON request returned status %d' %code)
90 assert_equal(status, True)
91 time.sleep(2)
92
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -080093 def onos_ssm_table_load(self, groups, src_list):
94 ssm_dict = {'apps' : { 'org.onosproject.igmp' : { 'ssmTranslate' : [] } } }
95 ssm_xlate_list = ssm_dict['apps']['org.onosproject.igmp']['ssmTranslate']
96 for g in groups:
97 for s in src_list:
98 d = {}
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -070099 d['source'] = s or '0.0.0.0'
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800100 d['group'] = g
101 ssm_xlate_list.append(d)
Chetan Gaonker4a25e2b2016-03-04 14:45:15 -0800102 self.onos_load_config(ssm_dict)
Chetan Gaonker4eb12072016-03-28 15:04:15 -0700103 cord_port_map = {}
104 for g in groups:
105 cord_port_map[g] = (self.PORT_TX_DEFAULT, self.PORT_RX_DEFAULT)
106 self.igmp_channel.cord_port_table_load(cord_port_map)
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800107 time.sleep(2)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800108
109 def igmp_verify_join(self, igmpStateList):
110 sendState, recvState = igmpStateList
Chetan Gaonker25470972016-02-26 08:52:15 -0800111 ## check if the send is received for the groups
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800112 for g in sendState.groups:
113 tx_stats = sendState.group_map[g][0]
114 tx = tx_stats.count
Chetan Gaonker25470972016-02-26 08:52:15 -0800115 assert_greater(tx, 0)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800116 rx_stats = recvState.group_map[g][1]
117 rx = rx_stats.count
118 assert_greater(rx, 0)
119 log.info('Receive stats %s for group %s' %(rx_stats, g))
120
121 log.info('IGMP test verification success')
Chetan Gaonker25470972016-02-26 08:52:15 -0800122
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800123 def igmp_verify_leave(self, igmpStateList, leave_groups):
124 sendState, recvState = igmpStateList[0], igmpStateList[1]
125 ## check if the send is received for the groups
126 for g in sendState.groups:
127 tx_stats = sendState.group_map[g][0]
128 rx_stats = recvState.group_map[g][1]
129 tx = tx_stats.count
130 rx = rx_stats.count
131 assert_greater(tx, 0)
132 if g not in leave_groups:
133 log.info('Received %d packets for group %s' %(rx, g))
134 for g in leave_groups:
135 rx = recvState.group_map[g][1].count
136 assert_equal(rx, 0)
137
138 log.info('IGMP test verification success')
Chetan Gaonker25470972016-02-26 08:52:15 -0800139
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800140 def mcast_traffic_timer(self):
141 self.mcastTraffic.stopReceives()
142
143 def send_mcast_cb(self, send_state):
144 for g in send_state.groups:
145 send_state.update(g, tx = 1)
Chetan Gaonker25470972016-02-26 08:52:15 -0800146 return 0
147
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800148 ##Runs in the context of twisted reactor thread
Chetan Gaonker25470972016-02-26 08:52:15 -0800149 def igmp_recv(self, igmpState, iface = 'veth0'):
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800150 p = self.recv_socket.recv()
Chetan Gaonkerf1b9e322016-05-09 15:49:15 -0700151 try:
152 send_time = float(p.payload.load)
153 recv_time = monotonic.monotonic()
154 except:
155 log.info('Unexpected Payload received: %s' %p.payload.load)
156 return 0
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800157 #log.info( 'Recv in %.6f secs' %(recv_time - send_time))
158 igmpState.update(p.dst, rx = 1, t = recv_time - send_time)
Chetan Gaonker25470972016-02-26 08:52:15 -0800159 return 0
160
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700161 def send_igmp_join(self, groups, src_list = ['1.2.3.4'], ip_pkt = None, iface = 'veth0', delay = 2):
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800162 self.onos_ssm_table_load(groups, src_list)
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800163 igmp = IGMPv3(type = IGMP_TYPE_V3_MEMBERSHIP_REPORT, max_resp_code=30,
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700164 gaddr=self.IP_DST)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800165 for g in groups:
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800166 gr = IGMPv3gr(rtype=IGMP_V3_GR_TYPE_EXCLUDE, mcaddr=g)
167 gr.sources = src_list
168 igmp.grps.append(gr)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700169 if ip_pkt is None:
170 ip_pkt = self.igmp_eth/self.igmp_ip
171 pkt = ip_pkt/igmp
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800172 IGMPv3.fixup(pkt)
173 sendp(pkt, iface=iface)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800174 if delay != 0:
175 time.sleep(delay)
176
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700177 def send_igmp_join_recvQuery(self, groups, rec_queryCount = None, src_list = ['1.2.3.4'], ip_pkt = None, iface = 'veth0', delay = 2):
178 self.onos_ssm_table_load(groups, src_list)
179 igmp = IGMPv3(type = IGMP_TYPE_V3_MEMBERSHIP_REPORT, max_resp_code=30,
180 gaddr=self.IP_DST)
181 for g in groups:
182 gr = IGMPv3gr(rtype=IGMP_V3_GR_TYPE_EXCLUDE, mcaddr=g)
183 gr.sources = src_list
184 gr.sources = src_list
185 igmp.grps.append(gr)
186 if ip_pkt is None:
187 ip_pkt = self.igmp_eth/self.igmp_ip
188 pkt = ip_pkt/igmp
189 IGMPv3.fixup(pkt)
190 if rec_queryCount == None:
191 log.info('Sending IGMP join for group %s and waiting for one query packet and printing the packet' %groups)
192 resp = srp1(pkt, iface=iface)
193 else:
194 log.info('Sending IGMP join for group %s and waiting for periodic query packets and printing one packet' %groups)
195 resp = srp3(pkt, iface=iface)
196# resp = srp1(pkt, iface=iface) if rec_queryCount else srp3(pkt, iface=iface)
197 resp[0].summary()
198 log.info('Sent IGMP join for group %s and received a query packet and printing packet' %groups)
199 if delay != 0:
200 time.sleep(delay)
201
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700202 def send_igmp_leave(self, groups, src_list = ['1.2.3.4'], ip_pkt = None, iface = 'veth0', delay = 2):
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800203 igmp = IGMPv3(type = IGMP_TYPE_V3_MEMBERSHIP_REPORT, max_resp_code=30,
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700204 gaddr=self.IP_DST)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800205 for g in groups:
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800206 gr = IGMPv3gr(rtype=IGMP_V3_GR_TYPE_INCLUDE, mcaddr=g)
207 gr.sources = src_list
208 igmp.grps.append(gr)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700209 if ip_pkt is None:
210 ip_pkt = self.igmp_eth/self.igmp_ip
211 pkt = ip_pkt/igmp
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800212 IGMPv3.fixup(pkt)
213 sendp(pkt, iface = iface)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800214 if delay != 0:
215 time.sleep(delay)
Chetan Gaonker25470972016-02-26 08:52:15 -0800216
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700217 def send_igmp_leave_listening_group_specific_query(self, groups, src_list = ['1.2.3.4'], ip_pkt = None, iface = 'veth0', delay = 2):
218 igmp = IGMPv3(type = IGMP_TYPE_V3_MEMBERSHIP_REPORT, max_resp_code=30,
219 gaddr=self.IP_DST)
220 for g in groups:
221 gr = IGMPv3gr(rtype=IGMP_V3_GR_TYPE_INCLUDE, mcaddr=g)
222 gr.sources = src_list
223 igmp.grps.append(gr)
224 if ip_pkt is None:
225 ip_pkt = self.igmp_eth/self.igmp_ip
226 pkt = ip_pkt/igmp
227 IGMPv3.fixup(pkt)
228 log.info('Sending IGMP leave for group %s and waiting for one group specific query packet and printing the packet' %groups)
229 resp = srp1(pkt, iface=iface)
230 resp[0].summary()
231 log.info('Sent IGMP leave for group %s and received a group specific query packet and printing packet' %groups)
232 if delay != 0:
233 time.sleep(delay)
234
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800235 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10)
236 def test_igmp_join_verify_traffic(self):
Chetan Gaonker25470972016-02-26 08:52:15 -0800237 groups = ['224.0.1.1', '225.0.0.1']
Chetan Gaonker25470972016-02-26 08:52:15 -0800238 df = defer.Deferred()
239 igmpState = IGMPTestState(groups = groups, df = df)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800240 igmpStateRecv = IGMPTestState(groups = groups, df = df)
241 igmpStateList = (igmpState, igmpStateRecv)
242 mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb, arg = igmpState)
243 self.df = df
244 self.mcastTraffic = mcastTraffic
245 self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP)
246
247 def igmp_srp_task(stateList):
248 igmpSendState, igmpRecvState = stateList
249 if not mcastTraffic.isRecvStopped():
250 result = self.igmp_recv(igmpRecvState)
251 reactor.callLater(0, igmp_srp_task, stateList)
252 else:
253 self.mcastTraffic.stop()
254 self.recv_socket.close()
255 self.igmp_verify_join(stateList)
256 self.df.callback(0)
257
258 self.send_igmp_join(groups)
259 mcastTraffic.start()
260 self.test_timer = reactor.callLater(self.MCAST_TRAFFIC_TIMEOUT, self.mcast_traffic_timer)
261 reactor.callLater(0, igmp_srp_task, igmpStateList)
Chetan Gaonker25470972016-02-26 08:52:15 -0800262 return df
263
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800264 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10)
265 def test_igmp_leave_verify_traffic(self):
266 groups = ['224.0.1.10', '225.0.0.10']
267 leave_groups = ['224.0.1.10']
268 df = defer.Deferred()
269 igmpState = IGMPTestState(groups = groups, df = df)
270 igmpStateRecv = IGMPTestState(groups = groups, df = df)
271 igmpStateList = (igmpState, igmpStateRecv)
272 mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb,
273 arg = igmpState)
274 self.df = df
275 self.mcastTraffic = mcastTraffic
276 self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP)
277
278 def igmp_srp_task(stateList):
279 igmpSendState, igmpRecvState = stateList
280 if not mcastTraffic.isRecvStopped():
281 result = self.igmp_recv(igmpRecvState)
282 reactor.callLater(0, igmp_srp_task, stateList)
283 else:
284 self.mcastTraffic.stop()
285 self.recv_socket.close()
286 self.igmp_verify_leave(stateList, leave_groups)
287 self.df.callback(0)
288
289 self.send_igmp_join(groups)
290 self.send_igmp_leave(leave_groups, delay = 3)
291 mcastTraffic.start()
292 self.test_timer = reactor.callLater(self.MCAST_TRAFFIC_TIMEOUT, self.mcast_traffic_timer)
293 reactor.callLater(0, igmp_srp_task, igmpStateList)
294 return df
295
296 @deferred(timeout=100)
297 def test_igmp_leave_join_loop(self):
298 self.groups = ['226.0.1.1', '227.0.0.1', '228.0.0.1', '229.0.0.1', '230.0.0.1' ]
299 self.src_list = ['3.4.5.6', '7.8.9.10']
300 df = defer.Deferred()
301 self.df = df
302 self.iterations = 0
303 self.num_groups = len(self.groups)
304 self.MAX_TEST_ITERATIONS = 10
305
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800306 def igmp_srp_task(v):
307 if self.iterations < self.MAX_TEST_ITERATIONS:
308 if v == 1:
309 ##join test
310 self.num_groups = random.randint(0, len(self.groups))
311 self.send_igmp_join(self.groups[:self.num_groups],
312 src_list = self.src_list,
313 iface = 'veth0', delay = 0)
314 else:
315 self.send_igmp_leave(self.groups[:self.num_groups],
316 src_list = self.src_list,
317 iface = 'veth0', delay = 0)
318 self.iterations += 1
319 v ^= 1
320 reactor.callLater(1.0 + 0.5*self.num_groups,
321 igmp_srp_task, v)
322 else:
323 self.df.callback(0)
324
325 reactor.callLater(0, igmp_srp_task, 1)
326 return df
327
328 def igmp_join_task(self, intf, groups, state, src_list = ['1.2.3.4']):
329 self.onos_ssm_table_load(groups, src_list)
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800330 igmp = IGMPv3(type = IGMP_TYPE_V3_MEMBERSHIP_REPORT, max_resp_code=30,
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700331 gaddr=self.IP_DST)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800332 for g in groups:
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800333 gr = IGMPv3gr(rtype = IGMP_V3_GR_TYPE_EXCLUDE, mcaddr = g)
334 gr.sources = src_list
335 igmp.grps.append(gr)
336
337 for g in groups:
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800338 state.group_map[g][0].update(1, t = monotonic.monotonic())
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800339
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700340 pkt = self.igmp_eth/self.igmp_ip/igmp
Chetan Gaonker5a5204e2016-03-02 01:35:13 -0800341 IGMPv3.fixup(pkt)
342 sendp(pkt, iface=intf)
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800343 log.debug('Returning from join task')
344
345 def igmp_recv_task(self, intf, groups, join_state):
346 recv_socket = L3PacketSocket(iface = intf, type = ETH_P_IP)
347 group_map = {}
348 for g in groups:
349 group_map[g] = [0,0]
350
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700351 log.info('Verifying join interface should receive multicast data')
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800352 while True:
353 p = recv_socket.recv()
354 if p.dst in groups and group_map[p.dst][0] == 0:
355 group_map[p.dst][0] += 1
356 group_map[p.dst][1] = monotonic.monotonic()
357 c = 0
358 for g in groups:
359 c += group_map[g][0]
360 if c == len(groups):
361 break
362 for g in groups:
363 join_start = join_state.group_map[g][0].start
364 recv_time = group_map[g][1] * 1000000
365 delta = (recv_time - join_start)
366 log.info('Join for group %s received in %.3f usecs' %
367 (g, delta))
368
369 recv_socket.close()
370 log.debug('Returning from recv task')
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700371
372 def igmp_not_recv_task(self, intf, groups, join_state):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700373 global NEGATIVE_TRAFFIC_STATUS
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700374 recv_socket = L2Socket(iface = intf, type = ETH_P_IP)
375 group_map = {}
376 for g in groups:
377 group_map[g] = [0,0]
378
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700379 log.info('Verifying join interface should not receive any multicast data')
380 NEGATIVE_TRAFFIC_STATUS = 1
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700381 def igmp_recv_cb(pkt):
382 log.info('Multicast packet %s received for left groups %s' %(pkt[IP].dst, groups))
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700383 global NEGATIVE_TRAFFIC_STATUS
384 NEGATIVE_TRAFFIC_STATUS = 2
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700385 sniff(prn = igmp_recv_cb, count = 1, lfilter = lambda p: p[IP].dst in groups,
386 timeout = 3, opened_socket = recv_socket)
387 recv_socket.close()
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700388 return NEGATIVE_TRAFFIC_STATUS
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700389
Chetan Gaonkereb2b24b2016-03-01 14:04:45 -0800390 def group_latency_check(self, groups):
391 tasks = []
392 self.send_igmp_leave(groups = groups)
393 join_state = IGMPTestState(groups = groups)
394 tasks.append(threading.Thread(target=self.igmp_join_task, args = ('veth0', groups, join_state,)))
395 traffic_state = IGMPTestState(groups = groups)
396 mcast_traffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb,
397 arg = traffic_state)
398 mcast_traffic.start()
399 tasks.append(threading.Thread(target=self.igmp_recv_task, args = ('veth0', groups, join_state)))
400 for t in tasks:
401 t.start()
402 for t in tasks:
403 t.join()
404
405 mcast_traffic.stop()
406 self.send_igmp_leave(groups = groups)
407 return
408
409 def test_igmp_1group_join_latency(self):
410 groups = ['239.0.1.1']
411 self.group_latency_check(groups)
412
413 def test_igmp_2group_join_latency(self):
414 groups = ['239.0.1.1', '240.0.1.1']
415 self.group_latency_check(groups)
416
417 def test_igmp_Ngroup_join_latency(self):
418 groups = ['239.0.1.1', '240.0.1.1', '241.0.1.1', '242.0.1.1']
419 self.group_latency_check(groups)
420
421
Chetan Gaonker1f7c3f82016-03-08 12:17:37 -0800422 def test_igmp_join_rover(self):
423 '''Keep sending joins across multicast range of addresses'''
424 '''For now, restricting it to 50/100'''
425 s = (224 << 24) | 1
426 #e = (225 << 24) | (255 << 16) | (255 << 16) | 255
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700427 e = (224 << 24) | 10
Chetan Gaonker1f7c3f82016-03-08 12:17:37 -0800428 for i in xrange(s, e+1):
429 if i&0xff:
430 ip = '%d.%d.%d.%d'%((i>>24)&0xff, (i>>16)&0xff, (i>>8)&0xff, i&0xff)
431 self.send_igmp_join([ip], delay = 0)
432
433 @deferred(timeout=IGMP_QUERY_TIMEOUT + 10)
434 def test_igmp_query(self):
435 groups = ['224.0.0.1'] ##igmp query group
436 df = defer.Deferred()
437 self.df = df
438 self.recv_socket = L2Socket(iface = 'veth0', type = ETH_P_IP)
439
440 def igmp_query_timeout():
Chetan Gaonker1f7c3f82016-03-08 12:17:37 -0800441 def igmp_query_cb(pkt):
Chetan Gaonkerbd4390f2016-03-09 18:56:52 -0800442 log.info('Got IGMP query packet from %s for %s' %(pkt[IP].src, pkt[IP].dst))
443 assert_equal(pkt[IP].dst, '224.0.0.1')
444
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700445 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 -0800446 opened_socket = self.recv_socket)
Chetan Gaonker1f7c3f82016-03-08 12:17:37 -0800447 self.recv_socket.close()
448 self.df.callback(0)
449
450 self.send_igmp_join(groups)
451 self.test_timer = reactor.callLater(self.IGMP_QUERY_TIMEOUT, igmp_query_timeout)
452 return df
453
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700454 def igmp_send_joins_different_groups_srclist(self, groups, sources, intf = V_INF1, delay = 2, ip_src = None):
455 g1 = groups[0]
456 g2 = groups[1]
457 sourcelist1 = sources[0]
458 sourcelist2 = sources[1]
459 eth = Ether(dst = self.MMACGROUP1, src = self.IGMP_SRC_MAC, type = ETH_P_IP)
460 src_ip = ip_src or self.IP_SRC
461 ip = IP(dst = g1, src = src_ip)
462 log.info('Sending join message for the group %s' %g1)
463 self.send_igmp_join((g1,), src_list = sourcelist1, ip_pkt = eth/ip, iface = intf, delay = 2)
464 eth = Ether(dst = self.MMACGROUP2, src = self.IGMP_SRC_MAC, type = ETH_P_IP)
465 ip = IP(dst = g2, src = src_ip)
466 log.info('Sending join message for group %s' %g2)
467 self.send_igmp_join((g2,), src_list = sourcelist2, ip_pkt = eth/ip, iface = intf, delay = 2)
468
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700469 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):
470 g1 = groups[0]
471 g2 = groups[1]
472 sourcelist1 = sources[0]
473 sourcelist2 = sources[1]
474 eth = Ether(dst = self.MMACGROUP1, src = self.IGMP_SRC_MAC, type = ETH_P_IP)
475 src_ip = ip_src or self.IP_SRC
476 ip = IP(dst = g1, src = src_ip)
477 if query_group1 is 'group1':
478 log.info('Sending join message for the group %s and waiting for a query packet on join interface' %g1)
479 self.send_igmp_join_recvQuery((g1,), None, src_list = sourcelist1, ip_pkt = eth/ip, iface = intf, delay = 2)
480 else:
481 log.info('Sending join message for the group %s' %g1)
482 self.send_igmp_join((g1,), src_list = sourcelist1, ip_pkt = eth/ip, iface = intf, delay = 2)
483 eth = Ether(dst = self.MMACGROUP2, src = self.IGMP_SRC_MAC, type = ETH_P_IP)
484 ip = IP(dst = g2, src = src_ip)
485 if query_group2 is 'group2':
486 log.info('Sending join message for the group %s and waiting for a query packet on join interface' %g2)
487 self.send_igmp_join_recvQuery((g2,), None, src_list = sourcelist2, ip_pkt = eth/ip, iface = intf, delay = 2)
488 else:
489 log.info('Sending join message for group %s' %g2)
490 self.send_igmp_join((g2,), src_list = sourcelist2, ip_pkt = eth/ip, iface = intf, delay = 2)
491
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700492 def igmp_joins_leave_functionality(self, again_join = False, df = None):
493 groups1 = (self.MGROUP1,)
494 groups2 = (self.MGROUP2,)
495 self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
496 (['2.2.2.2'], ['2.2.2.2']), intf = self.V_INF1, delay = 2)
497 dst_mac = '01:00:5e:01:02:03'
498 src_ip = '2.2.2.2'
499 if df is None:
500 df = defer.Deferred()
501 igmpState1 = IGMPTestState(groups = groups1, df = df)
502 igmpStateRecv1 = IGMPTestState(groups = groups1, df = df)
503 igmpStateList1 = (igmpState1, igmpStateRecv1)
504
505 igmpState2 = IGMPTestState(groups = groups2, df = df)
506 igmpStateRecv2 = IGMPTestState(groups = groups2, df = df)
507 igmpStateList2 = (igmpState2, igmpStateRecv2)
508 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
509 src_ip = src_ip, cb = self.send_mcast_cb,
510 arg = igmpState1)
511 dst_mac = '01:00:5e:02:02:03'
512 src_ip = '2.2.2.2'
513 mcastTraffic2 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
514 src_ip = src_ip, cb = self.send_mcast_cb,
515 arg = igmpState2)
516 mcastTraffic1.start()
517 mcastTraffic2.start()
518 join_state1 = IGMPTestState(groups = groups1)
519 join_state2 = IGMPTestState(groups = groups2)
520 target1 = self.igmp_recv_task(self.V_INF1, groups1, join_state1)
521 log.info('Interface is receiving multicast groups %s' %groups1)
522 target2 = self.igmp_recv_task(self.V_INF1, groups2, join_state2)
523 log.info('Interface is receiving multicast groups %s' %groups2)
524 log.info('Interface is sending leave message for groups %s now' %groups2)
525 self.send_igmp_leave(groups = groups2, src_list = ['2.2.2.2'], iface = self.V_INF1, delay = 2)
526 target3 = self.igmp_recv_task(self.V_INF1, groups1, join_state1)
527 target4 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state2)
528 assert target4 == 1, 'EXPECTED FAILURE'
529 if again_join:
530 dst_mac = '01:00:5e:02:02:03'
531 ip_dst = '239.2.2.3'
532 eth = Ether(dst = dst_mac, src = self.IGMP_SRC_MAC, type = ETH_P_IP)
533 ip = IP(dst = ip_dst, src = self.IP_SRC)
534 log.info('Interface sending join message again for the groups %s' %groups2)
535 self.send_igmp_join(groups2, src_list = [src_ip], ip_pkt = eth/ip, iface = self.V_INF1, delay = 2)
536 target5 = self.igmp_recv_task(self.V_INF1, groups2, join_state2)
537 log.info('Interface is receiving multicast groups %s again' %groups2)
538 target6 = self.igmp_recv_task(self.V_INF1, groups1, join_state1)
539 log.info('Interface is still receiving from multicast groups %s' %groups1)
540 else:
541 log.info('Ended test case')
542 mcastTraffic1.stop()
543 mcastTraffic2.stop()
544 self.onos_ctrl.deactivate()
545
546 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
547 def test_igmp_2joins_1leave_functionality(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700548 ## '''This test is subscribing to two channels and sending leave for one channel'''
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700549 df = defer.Deferred()
550 def test_igmp_2joins_1leave():
551 self.igmp_joins_leave_functionality(again_join = False, df = df)
552 df.callback(0)
553 reactor.callLater(0, test_igmp_2joins_1leave)
554 return df
555
556 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+25)
557 def test_igmp_2joins_1leave_again_joins_functionality(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700558 ## '''This test is subscribing to two channels and sending leave for one channel,again join to the same group'''
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700559 df = defer.Deferred()
560 def test_igmp_2joins_1leave_join_again():
561 self.igmp_joins_leave_functionality(again_join = True, df = df)
562 df.callback(0)
563 reactor.callLater(0, test_igmp_2joins_1leave_join_again)
564 return df
565
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700566 def igmp_not_in_src_list_functionality(self, df = None):
567 ## '''This test is sending multicast data from source 6.6.6.6 which is not in joins report '''
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700568 groups1 = (self.MGROUP1,)
569 groups2 = (self.MGROUP2,)
570 self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
571 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
572 intf = self.V_INF1, delay = 2)
573 dst_mac = '01:00:5e:01:02:03'
574 src_ip = '6.6.6.6'
575 if df is None:
576 df = defer.Deferred()
577 igmpState1 = IGMPTestState(groups = groups1, df = df)
578 igmpStateRecv1 = IGMPTestState(groups = groups1, df = df)
579 mcastTraffic1 = McastTraffic(groups1, iface = 'veth2', dst_mac = dst_mac,
580 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
581 mcastTraffic1.start()
582 join_state1 = IGMPTestState(groups = groups1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700583 log.info('Interface should not receive from multicast groups %s from an interface, which is expected' %groups1)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700584 target1 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
585 assert target1 == 1, 'EXPECTED FAILURE'
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700586 log.info('Interface is not receiving from multicast groups %s, working as expected' %groups1)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700587 mcastTraffic1.stop()
588 self.onos_ctrl.deactivate()
589
590 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700591 def test_igmp_not_in_src_list_functionality(self):
592 ## '''This test is sending multicast data from source 6.6.6.6 which is not in joins report '''
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700593 df = defer.Deferred()
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700594 def igmp_not_in_src_list_functionality():
595 self.igmp_not_in_src_list_functionality(df = df)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700596 df.callback(0)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700597 reactor.callLater(0, igmp_not_in_src_list_functionality)
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700598 return df
599
600 def igmp_change_to_exclude_src_list_functionality(self, df = None):
601 groups1 = (self.MGROUP1,)
602 groups2 = (self.MGROUP2,)
603 self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
604 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
605 intf = self.V_INF1, delay = 2)
606 dst_mac = '01:00:5e:01:02:03'
607 src_ip = '2.2.2.2'
608 if df is None:
609 df = defer.Deferred()
610 igmpState1 = IGMPTestState(groups = groups1, df = df)
611 igmpStateRecv1 = IGMPTestState(groups = groups1, df = df)
612 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
613 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
614 mcastTraffic1.start()
615 join_state1 = IGMPTestState(groups = groups1)
616 target1 = self.igmp_recv_task(self.V_INF1, groups1, join_state1)
617 self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2'], iface = self.V_INF1, delay =2)
618 target2 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
619 assert target2 == 1, 'EXPECTED FAILURE'
620 log.info('Interface is not receiving from multicast groups %s after sending CHANGE_TO_EXCLUDE' %groups1)
621 mcastTraffic1.stop()
622 self.onos_ctrl.deactivate()
623
624 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10)
625 def test_igmp_change_to_exclude_src_list_functionality(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700626 ## '''This test is checking that change to exclude source list functionality '''
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700627 df = defer.Deferred()
628 def igmp_change_to_exclude_src_list_functionality():
629 self.igmp_change_to_exclude_src_list_functionality(df = df)
630 df.callback(0)
631 reactor.callLater(0, igmp_change_to_exclude_src_list_functionality)
632 return df
633
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700634 def igmp_include_to_allow_src_list_functionality(self, df = None):
635 groups1 = (self.MGROUP1,)
636 groups2 = (self.MGROUP2,)
637 self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
638 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
639 intf = self.V_INF1, delay = 2)
640 dst_mac = '01:00:5e:01:02:03'
641 src_ip = '2.2.2.2'
642 if df is None:
643 df = defer.Deferred()
644 igmpState1 = IGMPTestState(groups = groups1, df = df)
645 igmpStateRecv1 = IGMPTestState(groups = groups1, df = df)
646 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
647 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
648 mcastTraffic1.start()
649 join_state1 = IGMPTestState(groups = groups1)
650 target1 = self.igmp_recv_task(self.V_INF1, groups1, join_state1)
651 self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
652 (['2.2.2.2', '3.3.3.3', '4.4.4.4', '6.6.6.6'], ['2.2.2.2', '5.5.5.5']),
653 intf = self.V_INF1, delay = 2)
654 target1 = self.igmp_recv_task(self.V_INF1, groups1, join_state1)
655 mcastTraffic1.stop()
656 self.onos_ctrl.deactivate()
657
658 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+30)
659 def test_igmp_include_to_allow_src_list_functionality(self):
660 '''Verify join INCLUDE (A) and Allow(B) from both A and B source list should receive multicast traffic. '''
661 df = defer.Deferred()
662 def igmp_include_to_allow_src_list_functionality():
663 self.igmp_include_to_allow_src_list_functionality(df = df)
664 df.callback(0)
665 reactor.callLater(0, igmp_include_to_allow_src_list_functionality)
666 return df
667
668 def igmp_include_to_block_src_list_functionality(self, df = None):
669 groups1 = (self.MGROUP1,)
670 groups2 = (self.MGROUP2,)
671 self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
672 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
673 intf = self.V_INF1, delay = 2)
674 dst_mac = '01:00:5e:01:02:03'
675 src_ip = '2.2.2.2'
676 if df is None:
677 df = defer.Deferred()
678 igmpState1 = IGMPTestState(groups = groups1, df = df)
679 igmpStateRecv1 = IGMPTestState(groups = groups1, df = df)
680 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
681 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
682 mcastTraffic1.start()
683 join_state1 = IGMPTestState(groups = groups1)
684 target1 = self.igmp_recv_task(self.V_INF1, groups1, join_state1)
685 self.send_igmp_leave(groups = groups1, src_list = ['6.6.6.6','7.7.7.7'],
686 iface = self.V_INF1, delay = 2)
687 target1 = self.igmp_recv_task(self.V_INF1, groups1, join_state1)
688 log.info('Interface is still receiving from old multicast group data %s even after we send bolck list' %groups1)
689 mcastTraffic1.stop()
690 self.onos_ctrl.deactivate()
691
692 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+30)
693 def test_igmp_include_to_block_src_list_functionality(self):
694 '''Verify join INCLUDE (A) and Block(B) from A source list, should receive multicast traffic.'''
695 df = defer.Deferred()
696 def igmp_include_to_block_src_list_functionality():
697 self.igmp_include_to_block_src_list_functionality(df = df)
698 df.callback(0)
699 reactor.callLater(0, igmp_include_to_block_src_list_functionality)
700 return df
701
702
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700703 def igmp_change_to_include_src_list_functionality(self, df = None):
704 groups1 = (self.MGROUP1,)
705 groups2 = (self.MGROUP2,)
706 self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4'],
707 iface = self.V_INF1, delay = 2)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700708
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700709 dst_mac = '01:00:5e:01:02:03'
710 src_ip = '2.2.2.2'
711 if df is None:
712 df = defer.Deferred()
713 igmpState1 = IGMPTestState(groups = groups1, df = df)
714 igmpStateRecv1 = IGMPTestState(groups = groups1, df = df)
715 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
716 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
717 mcastTraffic1.start()
718 join_state1 = IGMPTestState(groups = groups1)
719 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
720 assert target1 == 1, 'EXPECTED FAILURE'
721 log.info('Interface is not receiving from multicast groups %s' %groups1)
722 self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
723 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['6.6.6.6', '5.5.5.5']),
724 intf = self.V_INF1, delay = 2)
725 target2 = self.igmp_recv_task(self.V_INF1, groups1, join_state1)
726 log.info('Interface is receiving from multicast groups %s after send Change to include message' %groups1)
727 mcastTraffic1.stop()
728 self.onos_ctrl.deactivate()
729
730 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10)
731 def test_igmp_change_to_include_src_list_functionality(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700732 ## '''This test is checking that change to include source list functionality '''
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700733 df = defer.Deferred()
734 def igmp_change_to_include_src_list_functionality():
735 self.igmp_change_to_include_src_list_functionality(df = df)
736 df.callback(0)
737 reactor.callLater(0, igmp_change_to_include_src_list_functionality)
738 return df
739
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700740 def igmp_exclude_to_allow_src_list_functionality(self, df = None):
741 groups1 = (self.MGROUP1,)
742 groups2 = (self.MGROUP2,)
743 self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4'],
744 iface = self.V_INF1, delay = 2)
745
746 dst_mac = '01:00:5e:01:02:03'
747 src_ip = '2.2.2.2'
748 if df is None:
749 df = defer.Deferred()
750 igmpState1 = IGMPTestState(groups = groups1, df = df)
751 igmpStateRecv1 = IGMPTestState(groups = groups1, df = df)
752 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
753 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
754 mcastTraffic1.start()
755 join_state1 = IGMPTestState(groups = groups1)
756 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
757 assert target1 == 1, 'EXPECTED FAILURE'
758 log.info('Interface is not receiving from multicast groups %s' %groups1)
759 self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
760 (['6.6.6.6', '7.7.7.7', '8.8.8.8'], ['6.6.6.6', '5.5.5.5']),
761 intf = self.V_INF1, delay = 2)
762 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
763 assert target1 == 1, 'EXPECTED FAILURE'
764 log.info('Interface is not receiving from multicast groups %s' %groups1)
765 mcastTraffic1.stop()
766 self.onos_ctrl.deactivate()
767
768 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10)
769 def test_igmp_exclude_to_allow_src_list_functionality(self):
770 '''Verify join EXCLUDE(A) and Allow(B) from both A and B source list, should receive multicast traffic. '''
771 df = defer.Deferred()
772 def igmp_exclude_to_allow_src_list_functionality():
773 self.igmp_exclude_to_allow_src_list_functionality(df = df)
774 df.callback(0)
775 reactor.callLater(0, igmp_exclude_to_allow_src_list_functionality)
776 return df
777
778 def igmp_exclude_to_block_src_list_functionality(self, df = None):
779 groups1 = (self.MGROUP1,)
780 groups2 = (self.MGROUP2,)
781 self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4'],
782 iface = self.V_INF1, delay = 2)
783
784 dst_mac = '01:00:5e:01:02:03'
785 src_ip = '2.2.2.2'
786 if df is None:
787 df = defer.Deferred()
788 igmpState1 = IGMPTestState(groups = groups1, df = df)
789 igmpStateRecv1 = IGMPTestState(groups = groups1, df = df)
790 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
791 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
792 mcastTraffic1.start()
793 join_state1 = IGMPTestState(groups = groups1)
794 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
795 assert target1 == 1, 'EXPECTED FAILURE'
796 log.info('Interface is not receiving from multicast groups %s' %groups1)
797 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'],
798 iface = self.V_INF1, delay = 2)
799 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
800 assert target1 == 1, 'EXPECTED FAILURE'
801 log.info('Interface is not receiving from multicast groups %s' %groups1)
802 mcastTraffic1.stop()
803 self.onos_ctrl.deactivate()
804
805 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10)
806 def test_igmp_exclude_to_block_src_list_functionality(self):
807 ''' Verify join EXCLUDE (A) and Block(B) from A source list, should receive multicast traffic. '''
808 df = defer.Deferred()
809 def igmp_exclude_to_block_src_list_functionality():
810 self.igmp_exclude_to_block_src_list_functionality(df = df)
811 df.callback(0)
812 reactor.callLater(0, igmp_exclude_to_block_src_list_functionality)
813 return df
814
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700815 def igmp_new_src_list_functionality(self, df = None):
816 groups1 = (self.MGROUP1,)
817 groups2 = (self.MGROUP2,)
818 self.igmp_send_joins_different_groups_srclist(groups1+groups2,
819 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
820 intf = self.V_INF1, delay = 2)
821 dst_mac = '01:00:5e:01:02:03'
822 src_ip = '6.6.6.6'
823 if df is None:
824 df = defer.Deferred()
825 igmpState1 = IGMPTestState(groups = groups1, df = df)
826 igmpStateRecv1 = IGMPTestState(groups = groups1, df = df)
827 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
828 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
829 mcastTraffic1.start()
830 join_state1 = IGMPTestState(groups = groups1)
831 target1 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
832 assert target1 == 1, 'EXPECTED FAILURE'
833 log.info('Interface is not receiving from multicast groups %s' %groups1)
834 self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700835 (['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 -0700836 intf = self.V_INF1, delay = 2)
837 target2 = self.igmp_recv_task(self.V_INF1, groups1, join_state1)
838 log.info('Interface is receiving from multicast groups %s after sending join with new source list' %groups1)
839 mcastTraffic1.stop()
840 self.onos_ctrl.deactivate()
841
842 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10)
843 def test_igmp_new_src_list_functionality(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700844 ## '''This test is checking that adding new source list to existing source list functionality '''
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700845 df = defer.Deferred()
846 def igmp_new_src_list_functionality():
847 self.igmp_new_src_list_functionality(df = df)
848 df.callback(0)
849 reactor.callLater(0, igmp_new_src_list_functionality)
850 return df
851
852 def igmp_block_old_src_list_functionality(self, df = None):
853 groups1 = (self.MGROUP1,)
854 groups2 = (self.MGROUP2,)
855 groups = groups1 + groups2
856 self.igmp_send_joins_different_groups_srclist(groups,
857 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
858 intf = self.V_INF1, delay = 2)
859 dst_mac = '01:00:5e:02:02:03'
860 src_ip = '5.5.5.5'
861 if df is None:
862 df = defer.Deferred()
863 igmpState1 = IGMPTestState(groups = groups2, df = df)
864 igmpStateRecv1 = IGMPTestState(groups = groups2, df = df)
865 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
866 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
867 mcastTraffic1.start()
868 join_state1 = IGMPTestState(groups = groups2)
869 target1 = self.igmp_recv_task(self.V_INF1, groups2, join_state1)
870 log.info('Interface is receiving from multicast groups %s' %groups2)
871 self.igmp_send_joins_different_groups_srclist(groups,
872 (['6.6.6.6', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '7.7.7.7']),
873 intf = self.V_INF1, delay = 2)
874 target2 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1)
875 assert target2 == 1, 'EXPECTED FAILURE'
876 log.info('Interface is not receiving from multicast groups %s after sending join with block old source list' %groups2)
877 mcastTraffic1.stop()
878 self.onos_ctrl.deactivate()
879
880 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
881 def test_igmp_block_old_src_list_functionality(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700882 ## '''This test is checking that block old source list from existing source list functionality '''
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700883 df = defer.Deferred()
884 def igmp_block_old_src_list_functionality():
885 self.igmp_block_old_src_list_functionality(df = df)
886 df.callback(0)
887 reactor.callLater(0, igmp_block_old_src_list_functionality)
888 return df
889
890 def igmp_include_empty_src_list_functionality(self, df = None):
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700891 groups1 = (self.MGROUP1,)
892 groups2 = (self.MGROUP2,)
893 groups = groups1 + groups2
894 self.igmp_send_joins_different_groups_srclist(groups,
895 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['']),
896 intf = self.V_INF1, delay = 2)
897 dst_mac = '01:00:5e:02:02:03'
898 src_ip = '5.5.5.5'
899 if df is None:
900 df = defer.Deferred()
901 igmpState1 = IGMPTestState(groups = groups2, df = df)
902 igmpStateRecv1 = IGMPTestState(groups = groups2, df = df)
903 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
904 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
905 mcastTraffic1.start()
906 join_state1 = IGMPTestState(groups = groups2)
907 target1 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1)
908 assert target1==1, 'EXPECTED FAILURE'
909 log.info('Interface is not receiving from multicast groups %s when we sent join with source list is empty' %groups2)
910 mcastTraffic1.stop()
911 self.onos_ctrl.deactivate()
912
913 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
914 def ztest_igmp_include_empty_src_list_functionality(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700915 ## '''This test is checking that multicast functionality by sending empty source list to include '''
916 ## '''Disabling this test as scapy IGMP doesn't work with empty source lists'''
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700917 df = defer.Deferred()
918 def igmp_include_empty_src_list_functionality():
919 self.igmp_include_empty_src_list_functionality(df = df)
920 df.callback(0)
921 reactor.callLater(0, igmp_include_empty_src_list_functionality)
922 return df
923
924 def igmp_exclude_empty_src_list_functionality(self, df = None):
925 groups1 = (self.MGROUP1,)
926 groups2 = (self.MGROUP2,)
927 groups = groups1 + groups2
928 self.send_igmp_leave(groups = groups2, src_list = [''], iface = self.V_INF1, delay = 2)
929 dst_mac = '01:00:5e:02:02:03'
930 src_ip = '5.5.5.5'
931 if df is None:
932 df = defer.Deferred()
933 igmpState1 = IGMPTestState(groups = groups2, df = df)
934 igmpStateRecv1 = IGMPTestState(groups = groups2, df = df)
935 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
936 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
937 mcastTraffic1.start()
938 join_state1 = IGMPTestState(groups = groups2)
939 target1 = self.igmp_recv_task(self.V_INF1, groups2, join_state1)
940 log.info('Interface is receiving multicast groups %s' %groups2)
941 mcastTraffic1.stop()
942 self.onos_ctrl.deactivate()
943
944 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
945 def ztest_igmp_exclude_empty_src_list_functionality(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700946 ## '''This test is checking that multicast functionality by sending empty source list to exclude '''
947 ## '''Disabling this test case since scapy IGMP doesn't work with empty src list'''
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700948 df = defer.Deferred()
949 def igmp_exclude_empty_src_list_functionality():
950 self.igmp_exclude_empty_src_list_functionality()
951 df.callback(0)
952 reactor.callLater(0, igmp_exclude_empty_src_list_functionality)
953 return df
954
955 def igmp_join_sourceip_0_0_0_0_functionality(self, df = None):
956 groups1 = (self.MGROUP1,)
957 groups2 = (self.MGROUP2,)
958 groups = groups1 + groups2
959 ip_src = '0.0.0.0'
960 self.igmp_send_joins_different_groups_srclist(groups,
961 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['5.5.5.5']),
962 intf = self.V_INF1, delay = 2, ip_src = ip_src)
963 ip_src = self.IP_SRC
964 dst_mac = '01:00:5e:02:02:03'
965 src_ip = '5.5.5.5'
966 if df is None:
967 df = defer.Deferred()
968 igmpState1 = IGMPTestState(groups = groups2, df = df)
969 igmpStateRecv1 = IGMPTestState(groups = groups2, df = df)
970 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
971 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
972 mcastTraffic1.start()
973 join_state1 = IGMPTestState(groups = groups2)
974 target1 = self.igmp_recv_task(self.V_INF1, groups2, join_state1)
975 log.info('Interface is receiving from multicast groups %s when we sent join with source IP is 0.0.0.0' %groups2)
976 mcastTraffic1.stop()
977 self.onos_ctrl.deactivate()
978
979 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
980 def test_igmp_join_sourceip_0_0_0_0_functionality(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700981 ## '''This test is sending join with source list A,B,C and exclude D,F,G with source IP as 0.0.0.0'''
Chetan Gaonker8bbc4d52016-03-29 16:59:45 -0700982 df = defer.Deferred()
983 def igmp_join_sourceip_0_0_0_0_functionality():
984 self.igmp_join_sourceip_0_0_0_0_functionality(df = df)
985 df.callback(0)
986 reactor.callLater(0, igmp_join_sourceip_0_0_0_0_functionality)
987 return df
988
Chetan Gaonker441c9ac2016-05-06 10:30:13 -0700989
Chetan Gaonker586fec32016-04-29 17:33:54 -0700990 def igmp_invalid_join_packet_functionality(self, df = None):
991 groups1 = (self.MGROUP1,)
992 groups2 = (self.MINVALIDGROUP1,)
993 groups = groups1 + groups2
994 ip_src = '1.1.1.1'
995 self.igmp_send_joins_different_groups_srclist(groups,
996 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['5.5.5.5']),
997 intf = self.V_INF1, delay = 2, ip_src = ip_src)
998 ip_src = self.IP_SRC
999 dst_mac = '01:00:5e:02:02:03'
1000 src_ip = '5.5.5.5'
1001 if df is None:
1002 df = defer.Deferred()
1003 igmpState1 = IGMPTestState(groups = groups2, df = df)
1004 igmpStateRecv1 = IGMPTestState(groups = groups2, df = df)
1005 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1006 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1007 mcastTraffic1.start()
1008 join_state1 = IGMPTestState(groups = groups2)
1009 target1 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1)
1010 assert target1==1, 'EXPECTED FAILURE'
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001011 log.info('Interface is not receiving from multicast groups %s when we sent invalid join packet ' %groups2)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001012 mcastTraffic1.stop()
1013 self.onos_ctrl.deactivate()
1014
1015 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
1016 def test_igmp_invalid_join_packet_functionality(self):
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001017 ## '''This test is sending invalid join with source list A,B,C and exclude D,F,G with multicast group as 255.255.255.255'''
Chetan Gaonker586fec32016-04-29 17:33:54 -07001018 df = defer.Deferred()
1019 def igmp_invalid_join_packet_functionality():
1020 self.igmp_invalid_join_packet_functionality(df = df)
1021 df.callback(0)
1022 reactor.callLater(0, igmp_invalid_join_packet_functionality)
1023 return df
1024
1025 def igmp_join_data_receiving_during_subscriber_link_down_up_functionality(self, df = None):
1026 groups1 = (self.MGROUP1,)
1027 groups2 = (self.MGROUP2,)
1028 groups = groups1 + groups2
1029 ip_src = '1.1.1.1'
1030 self.igmp_send_joins_different_groups_srclist(groups,
1031 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['5.5.5.5']),
1032 intf = self.V_INF1, delay = 2, ip_src = ip_src)
1033 ip_src = self.IP_SRC
1034 dst_mac = '01:00:5e:02:02:03'
1035 src_ip = '5.5.5.5'
1036 if df is None:
1037 df = defer.Deferred()
1038 igmpState1 = IGMPTestState(groups = groups2, df = df)
1039 igmpStateRecv1 = IGMPTestState(groups = groups2, df = df)
1040 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1041 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1042 mcastTraffic1.start()
1043 join_state1 = IGMPTestState(groups = groups2)
1044 target1 = self.igmp_recv_task(self.V_INF1, groups2, join_state1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001045 log.info('Interface is receiving from multicast groups, before bring down the self.V_INF1=%s ' %self.V_INF1)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001046 os.system('ifconfig '+self.V_INF1+' down')
1047 log.info(' the self.V_INF1 %s is down now ' %self.V_INF1)
1048 os.system('ifconfig '+self.V_INF1)
1049 time.sleep(10)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001050 os.system('ifconfig '+self.V_INF1+' up')
1051 os.system('ifconfig '+self.V_INF1)
1052 log.info(' the self.V_INF1 %s is up now ' %self.V_INF1)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001053 target1 = self.igmp_recv_task(self.V_INF1, groups2, join_state1)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001054 log.info('Interface is receiving from multicast groups %s when we bringup interface up after down ' %groups2)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001055 mcastTraffic1.stop()
1056 self.onos_ctrl.deactivate()
1057
Chetan Gaonker586fec32016-04-29 17:33:54 -07001058 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001059 def test_igmp_join_data_receiving_during_subscriber_link_up_down_functionality(self):
1060 ## '''This test is sending join with source list A,B,C and exclude D,F,G with valid multicast group during receiving data, shutdown on data receiving port'''
Chetan Gaonker586fec32016-04-29 17:33:54 -07001061 df = defer.Deferred()
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001062 def igmp_join_data_receiving_during_subscriber_link_up_down_functionality():
1063 self.igmp_join_data_receiving_during_subscriber_link_down_up_functionality(df = df)
1064 df.callback(0)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001065 reactor.callLater(0, igmp_join_data_receiving_during_subscriber_link_down_up_functionality)
1066 return df
1067
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001068 def igmp_join_data_receiving_during_channel_distributor_link_up_down_functionality(self, df = None):
1069 groups1 = (self.MGROUP1,)
1070 groups2 = (self.MGROUP2,)
1071 groups = groups1 + groups2
1072 ip_src = '1.1.1.1'
1073 self.igmp_send_joins_different_groups_srclist(groups,
1074 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['5.5.5.5', '6.6.6.6']),
1075 intf = self.V_INF1, delay = 2, ip_src = ip_src)
1076 ip_src = self.IP_SRC
1077 dst_mac1 = '01:00:5e:01:02:03'
1078 dst_mac2 = '01:00:5e:02:02:03'
1079 src_ip2 = '5.5.5.5'
1080 src_ip1 = '2.2.2.2'
1081 if df is None:
1082 df = defer.Deferred()
1083 igmpState1 = IGMPTestState(groups = groups1, df = df)
1084 igmpState2 = IGMPTestState(groups = groups2, df = df)
1085 igmpStateRecv1 = IGMPTestState(groups = groups1, df = df)
1086 igmpStateRecv2 = IGMPTestState(groups = groups2, df = df)
1087 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac1,
1088 src_ip = src_ip1, cb = self.send_mcast_cb, arg = igmpState1)
1089 mcastTraffic2 = McastTraffic(groups2, iface= 'veth3', dst_mac = dst_mac2,
1090 src_ip = src_ip2, cb = self.send_mcast_cb, arg = igmpState2)
1091 mcastTraffic1.start()
1092 mcastTraffic2.start()
1093 join_state1 = IGMPTestState(groups = groups1)
1094 join_state2 = IGMPTestState(groups = groups2)
1095 target1 = self.igmp_recv_task(self.V_INF1, groups1, join_state1)
1096 target2 = self.igmp_recv_task(self.V_INF1, groups2, join_state2)
1097 log.info('Interface is receiving from multicast groups, before bring down the veth2 and subscriber link is self.V_INF1=%s up ' %self.V_INF1)
1098 mcastTraffic1.stop()
1099 os.system('ifconfig '+'veth2'+' down')
1100 log.info(' the channel distributor interface veth2 is down now ' )
1101 os.system('ifconfig '+'veth2')
1102 time.sleep(10)
1103 log.info('Verifying interface is still receiving a multicast groups2 %s traffic even though other group traffic sending interface goes down' %groups2)
1104 target2 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1)
1105 log.info('Verified that interface is still receiving a multicast groups2 %s traffic even though other group traffic sending interface goes down' %groups2)
1106 target1 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
1107 assert target1==1, 'EXPECTED FAILURE'
1108 log.info('Interface is not receiving from multicast groups1 %s when we shutdown the subscriber interface ' %groups1)
1109 os.system('ifconfig '+'veth2'+' up')
1110 os.system('ifconfig '+'veth2')
1111 log.info(' the channel distributor interface veth2 is up now ')
1112 time.sleep(10)
1113 mcastTraffic1.start()
1114 log.info('Verifying interface is receiving from both multicast groups data %s when we bringup interface up after down ' %groups2)
1115 target1 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
1116 target2 = self.igmp_recv_task(self.V_INF1, groups2, join_state2)
1117 target2 = self.igmp_recv_task(self.V_INF1, groups2, join_state2)
1118 log.info('Interface is receiving from multicast groups %s when we bringup interface up after down ' %groups2)
1119 mcastTraffic2.stop()
1120 self.onos_ctrl.deactivate()
1121 ## This test case is failing to receive traffic from multicast data from defferent channel interfaces TO-DO
1122 ###### TO DO scenario #######
1123 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+60)
1124 def ztest_igmp_join_data_receiving_during_channel_distributor_link_down_up_functionality(self):
1125 ## '''This test is sending join with source list A,B,C with valid multicast group during receiving data, shutdown the data sending port'''
1126 df = defer.Deferred()
1127 def igmp_join_data_receiving_during_channel_distributor_link_down_up_functionality():
1128 self.igmp_join_data_receiving_during_channel_distributor_link_down_up_functionality(df = df)
1129 df.callback(0)
1130 reactor.callLater(0, igmp_join_data_receiving_during_channel_distributor_link_down_up_functionality)
1131 return df
Chetan Gaonker586fec32016-04-29 17:33:54 -07001132
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001133 def igmp_invalidClassD_IP_join_packet_functionality(self, df = None):
Chetan Gaonker586fec32016-04-29 17:33:54 -07001134 groups1 = (self.MGROUP1,)
1135 groups2 = (self.MINVALIDGROUP2,)
1136 groups = groups1 + groups2
1137 ip_src = '1.1.1.1'
1138 self.igmp_send_joins_different_groups_srclist(groups,
1139 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['5.5.5.5']),
1140 intf = self.V_INF1, delay = 2, ip_src = ip_src)
1141 ip_src = self.IP_SRC
1142 dst_mac = '01:00:5e:02:02:03'
1143 src_ip = '5.5.5.5'
1144 if df is None:
1145 df = defer.Deferred()
1146 igmpState1 = IGMPTestState(groups = groups2, df = df)
1147 igmpStateRecv1 = IGMPTestState(groups = groups2, df = df)
1148 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1149 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1150 mcastTraffic1.start()
1151 join_state1 = IGMPTestState(groups = groups2)
1152 target1 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1)
1153 assert target1==1, 'EXPECTED FAILURE'
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001154 log.info('Interface is not receiving from multicast groups %s when we sent invalid join packet ' %groups2)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001155 mcastTraffic1.stop()
1156 self.onos_ctrl.deactivate()
1157
1158 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001159 def test_igmp_invalidClassD_IP_join_packet_functionality(self):
1160 ## '''This test is sending invalid join with source list A,B,C with multicast group as 239.255.255.255'''
Chetan Gaonker586fec32016-04-29 17:33:54 -07001161 df = defer.Deferred()
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001162 def igmp_invalidClass_D_IP_join_packet_functionality():
1163 self.igmp_invalidClass_D_IP_join_packet_functionality(df = df)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001164 df.callback(0)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001165 reactor.callLater(0, igmp_invalidClassD_IP_join_packet_functionality)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001166 return df
1167
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001168 def igmp_invalidClassD_IP_as_srclistIP_join_packet_functionality(self, df = None):
Chetan Gaonker586fec32016-04-29 17:33:54 -07001169 groups1 = (self.MGROUP1,)
1170 groups2 = (self.MGROUP2,)
1171 groups = groups1 + groups2
1172 ip_src = '1.1.1.1'
1173 self.igmp_send_joins_different_groups_srclist(groups,
1174 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['239.5.5.5']),
1175 intf = self.V_INF1, delay = 2, ip_src = ip_src)
1176 ip_src = self.IP_SRC
1177 dst_mac = '01:00:5e:02:02:03'
1178 src_ip = '5.5.5.5'
1179 if df is None:
1180 df = defer.Deferred()
1181 igmpState1 = IGMPTestState(groups = groups2, df = df)
1182 igmpStateRecv1 = IGMPTestState(groups = groups2, df = df)
1183 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1184 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1185 mcastTraffic1.start()
1186 join_state1 = IGMPTestState(groups = groups2)
1187 target1 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1)
1188 assert target1==1, 'EXPECTED FAILURE'
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001189 log.info('Interface is not receiving from multicast groups %s when we sent invalid join packet ' %groups2)
Chetan Gaonker586fec32016-04-29 17:33:54 -07001190 mcastTraffic1.stop()
1191 self.onos_ctrl.deactivate()
1192
1193 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001194 def test_igmp_invalidClassD_IP_as_srclistIP_join_packet_functionality(self):
1195 ## '''This test is sending invalid join with source list A,B,C and exclude D,F,G with source list as 239.5.5.5'''
Chetan Gaonker586fec32016-04-29 17:33:54 -07001196 df = defer.Deferred()
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001197 def igmp_invalidClassD_IP_as_srclistIP_join_packet_functionality():
1198 self.igmp_invalidClassD_IP_as_srclistIP_join_packet_functionality(df = df)
1199 df.callback(0)
1200 reactor.callLater(0, igmp_invalidClassD_IP_as_srclistIP_join_packet_functionality)
1201 return df
Chetan Gaonkerf72ca402016-05-02 16:29:32 -07001202
Chetan Gaonker441c9ac2016-05-06 10:30:13 -07001203
1204 def igmp_general_query_recv_packet_functionality(self, df = None):
1205 groups1 = (self.MGROUP1,)
1206 groups2 = (self.MGROUP2,)
1207 groups = groups1 + groups2
1208 ip_src = '1.1.1.1'
1209 self.igmp_send_joins_different_groups_srclist(groups,
1210 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['5.5.5.5']),
1211 intf = self.V_INF1, delay = 2, ip_src = ip_src)
1212 ip_src = self.IP_SRC
1213 dst_mac = '01:00:5e:02:02:03'
1214 src_ip = '5.5.5.5'
1215 if df is None:
1216 df = defer.Deferred()
1217 igmpState1 = IGMPTestState(groups = groups2, df = df)
1218 igmpStateRecv1 = IGMPTestState(groups = groups2, df = df)
1219 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1220 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1221 mcastTraffic1.start()
1222 join_state1 = IGMPTestState(groups = groups2)
1223 log.info('Started delay to verify multicast data taraffic for group %s is received or not for 180 sec ' %groups2)
1224 time.sleep(100)
1225 target2 = self.igmp_recv_task(self.V_INF1, groups2, join_state1)
1226 log.info('Verified that multicast data for group %s is received after 100 sec ' %groups2)
1227 time.sleep(50)
1228 target2 = self.igmp_recv_task(self.V_INF1, groups2, join_state1)
1229 log.info('Verified that multicast data for group %s is received after 150 sec ' %groups2)
1230 time.sleep(30)
1231 target2 = self.igmp_recv_task(self.V_INF1, groups2, join_state1)
1232 log.info('Verified that multicast data for group %s is received after 180 sec ' %groups2)
1233 time.sleep(10)
1234 target2 = self.igmp_recv_task(self.V_INF1, groups2, join_state1)
1235 log.info('Verified that multicast data for group %s is received after 190 sec ' %groups2)
1236 target3 = mcastTraffic1.isRecvStopped()
1237 assert target3==False, 'EXPECTED FAILURE'
1238 log.info('Verified that multicast data for a group %s is still transmitting from a data interface' %groups2)
1239 log.info('Now checking joining interface is receiving a multicast data for group %s after 190 sec' %groups2)
1240 target1 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1)
1241 assert target1==1, 'EXPECTED FAILURE'
1242 log.info('Interface is not receiving multicast data for group %s' %groups2)
1243 mcastTraffic1.stop()
1244 self.onos_ctrl.deactivate()
1245
1246 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+250)
1247 def test_igmp_general_query_recv_packet_traffic_functionality(self):
1248 ## '''This test is verifying whether multicast data is stopped after 180 sec time if we dont respond to query packet which will generated by a querier router'''
1249 df = defer.Deferred()
1250 def igmp_general_query_recv_packet_functionality():
1251 self.igmp_general_query_recv_packet_functionality(df = df)
1252 df.callback(0)
1253 reactor.callLater(0, igmp_general_query_recv_packet_functionality)
1254 return df
1255
1256 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+80)
1257 def test_igmp_query_packet_received_on_joining_interface(self):
1258 ## '''This test is verifying whether joining interface is receiving general membership query packet from querier router '''
1259 groups = ['224.0.1.10', '225.0.0.10']
1260 leave_groups = ['224.0.1.10']
1261 df = defer.Deferred()
1262 igmpState = IGMPTestState(groups = groups, df = df)
1263 igmpStateRecv = IGMPTestState(groups = groups, df = df)
1264 igmpStateList = (igmpState, igmpStateRecv)
1265 mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb,
1266 arg = igmpState)
1267 self.df = df
1268 self.mcastTraffic = mcastTraffic
1269 self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP)
1270
1271 def igmp_srp_task(stateList):
1272 igmpSendState, igmpRecvState = stateList
1273 if not mcastTraffic.isRecvStopped():
1274 result = self.igmp_recv(igmpRecvState)
1275 reactor.callLater(0, igmp_srp_task, stateList)
1276 else:
1277 self.mcastTraffic.stop()
1278 self.recv_socket.close()
1279 self.igmp_verify_leave(stateList, leave_groups)
1280 self.df.callback(0)
1281
1282 log.info('Sending join packet and expected to receive on egeneral query packet after 60 sec for multicast %s ' %groups)
1283 self.send_igmp_join_recvQuery(groups)
1284 log.info('Received a egeneral query packet for multicast %s group on joing interface and sending traffic' %groups)
1285 mcastTraffic.start()
1286 self.test_timer = reactor.callLater(self.MCAST_TRAFFIC_TIMEOUT, self.mcast_traffic_timer)
1287 reactor.callLater(0, igmp_srp_task, igmpStateList)
1288 return df
1289
1290 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+190)
1291 def test_igmp_periodic_query_packet_received_on_joining_interface(self):
1292 ## '''This test is verifying whether joining interface is receiving periodic general membership query packets from querier router '''
1293 groups = ['224.0.1.10', '225.0.0.10']
1294 leave_groups = ['224.0.1.10']
1295 df = defer.Deferred()
1296 igmpState = IGMPTestState(groups = groups, df = df)
1297 igmpStateRecv = IGMPTestState(groups = groups, df = df)
1298 igmpStateList = (igmpState, igmpStateRecv)
1299 mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb,
1300 arg = igmpState)
1301 self.df = df
1302 self.mcastTraffic = mcastTraffic
1303 self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP)
1304
1305 def igmp_srp_task(stateList):
1306 igmpSendState, igmpRecvState = stateList
1307 if not mcastTraffic.isRecvStopped():
1308 result = self.igmp_recv(igmpRecvState)
1309 reactor.callLater(0, igmp_srp_task, stateList)
1310 else:
1311 self.mcastTraffic.stop()
1312 self.recv_socket.close()
1313 self.igmp_verify_leave(stateList, leave_groups)
1314 self.df.callback(0)
1315
1316 self.send_igmp_join_recvQuery(groups,3)
1317 return df
1318
1319 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+190)
1320 def test_igmp_periodic_query_packet_received_and_checking_entry_deleted(self):
1321 ## '''This test is verifying whether joining interface is receiving periodic general membership query packets from querier router, checking expire membership interval and traffic should not receive'''
1322 groups = ['224.0.1.10', '225.0.0.10']
1323 leave_groups = ['224.0.1.10']
1324 df = defer.Deferred()
1325 igmpState = IGMPTestState(groups = groups, df = df)
1326 igmpStateRecv = IGMPTestState(groups = groups, df = df)
1327 igmpStateList = (igmpState, igmpStateRecv)
1328 mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb,
1329 arg = igmpState)
1330 self.df = df
1331 self.mcastTraffic = mcastTraffic
1332 self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP)
1333
1334 def igmp_srp_task(stateList):
1335 igmpSendState, igmpRecvState = stateList
1336 if not mcastTraffic.isRecvStopped():
1337 result = self.igmp_recv(igmpRecvState)
1338 reactor.callLater(0, igmp_srp_task, stateList)
1339 else:
1340 self.mcastTraffic.stop()
1341 self.recv_socket.close()
1342 self.igmp_verify_leave(stateList, leave_groups)
1343 self.df.callback(0)
1344
1345 self.send_igmp_join_recvQuery(groups,3)
1346 log.info('Received periodic egeneral query packets for multicast %s, now checking entry is deleted from tabel by sending traffic for that group' %groups)
1347 mcastTraffic.start()
1348 self.test_timer = reactor.callLater(self.MCAST_TRAFFIC_TIMEOUT, self.mcast_traffic_timer)
1349 reactor.callLater(0, igmp_srp_task, igmpStateList)
1350 return df
1351
1352
1353 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+190)
1354 def test_igmp_member_query_interval_expire_re_joining_interface(self):
1355 ## '''This test is verifying whether joining interface is receiving multicast data even after group menership interval expire by sending again joining to that multicast data group'''
1356 groups = ['224.0.1.10', '225.0.0.10']
1357 leave_groups = ['224.0.1.10']
1358 df = defer.Deferred()
1359 igmpState = IGMPTestState(groups = groups, df = df)
1360 igmpStateRecv = IGMPTestState(groups = groups, df = df)
1361 igmpStateList = (igmpState, igmpStateRecv)
1362 mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb,
1363 arg = igmpState)
1364 self.df = df
1365 self.mcastTraffic = mcastTraffic
1366 self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP)
1367
1368 def igmp_srp_task(stateList):
1369 igmpSendState, igmpRecvState = stateList
1370 if not mcastTraffic.isRecvStopped():
1371 result = self.igmp_recv(igmpRecvState)
1372 reactor.callLater(0, igmp_srp_task, stateList)
1373 else:
1374 self.mcastTraffic.stop()
1375 self.recv_socket.close()
1376 self.igmp_verify_leave(stateList, leave_groups)
1377 self.df.callback(0)
1378
1379 self.send_igmp_join_recvQuery(groups,3)
1380 log.info('Received periodic egeneral query packets for multicast %s, now sending join packet again and verifying traffic for that group is received or not on joining interface' %groups)
1381 self.send_igmp_join(groups)
1382 mcastTraffic.start()
1383 self.test_timer = reactor.callLater(self.MCAST_TRAFFIC_TIMEOUT, self.mcast_traffic_timer)
1384 reactor.callLater(0, igmp_srp_task, igmpStateList)
1385 return df
1386
1387 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+50)
1388 def test_igmp_leave_verify_received_group_source_specific_query(self):
1389 ## '''This test is verfying when we send leave message we should get group-source specific query '''
1390 groups = ['224.0.1.10', '225.0.0.10']
1391 leave_groups = ['224.0.1.10']
1392 df = defer.Deferred()
1393 igmpState = IGMPTestState(groups = groups, df = df)
1394 igmpStateRecv = IGMPTestState(groups = groups, df = df)
1395 igmpStateList = (igmpState, igmpStateRecv)
1396 mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb,
1397 arg = igmpState)
1398 self.df = df
1399 self.mcastTraffic = mcastTraffic
1400 self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP)
1401
1402 def igmp_srp_task(stateList):
1403 igmpSendState, igmpRecvState = stateList
1404 if not mcastTraffic.isRecvStopped():
1405 result = self.igmp_recv(igmpRecvState)
1406 reactor.callLater(0, igmp_srp_task, stateList)
1407 else:
1408 self.mcastTraffic.stop()
1409 self.recv_socket.close()
1410 self.igmp_verify_leave(stateList, leave_groups)
1411 self.df.callback(0)
1412
1413 self.send_igmp_join(groups)
1414 self.send_igmp_leave_listening_group_specific_query(leave_groups, delay = 3)
1415 return df
1416
1417 def igmp_change_to_exclude_src_list_check_for_group_source_specific_query(self, df = None):
1418 groups1 = (self.MGROUP1,)
1419 groups2 = (self.MGROUP2,)
1420 self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
1421 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
1422 intf = self.V_INF1, delay = 2)
1423 dst_mac = '01:00:5e:01:02:03'
1424 src_ip = '2.2.2.2'
1425 if df is None:
1426 df = defer.Deferred()
1427 igmpState1 = IGMPTestState(groups = groups1, df = df)
1428 igmpStateRecv1 = IGMPTestState(groups = groups1, df = df)
1429 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
1430 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1431 mcastTraffic1.start()
1432 join_state1 = IGMPTestState(groups = groups1)
1433 target1 = self.igmp_recv_task(self.V_INF1, groups1, join_state1)
1434 self.send_igmp_leave_listening_group_specific_query(groups = groups1, src_list = ['2.2.2.2'], iface = self.V_INF1, delay =2)
1435 time.sleep(10)
1436 target2 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
1437 assert target2 == 1, 'EXPECTED FAILURE'
1438 log.info('Interface is not receiving from multicast groups %s after sending CHANGE_TO_EXCLUDE' %groups2)
1439 mcastTraffic1.stop()
1440 self.onos_ctrl.deactivate()
1441
1442 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+60)
1443 def test_igmp_change_to_exclude_src_list_check_for_group_source_specific_query(self):
1444 '''Verify join INCLUDE (A) and TO_EX(B) for a multicast group,
1445 we should receive group source specific membership query packet to A*B source list interface'''
1446 df = defer.Deferred()
1447 def igmp_change_to_exclude_src_list_check_for_group_source_specific_query():
1448 self.igmp_change_to_exclude_src_list_check_for_group_source_specific_query(df = df)
1449 df.callback(0)
1450 reactor.callLater(0, igmp_change_to_exclude_src_list_check_for_group_source_specific_query)
1451 return df
1452
1453 def igmp_change_to_include_src_list_check_for_general_query(self, df = None):
1454 groups1 = (self.MGROUP1,)
1455 groups2 = (self.MGROUP2,)
1456 self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4'],
1457 iface = self.V_INF1, delay = 2)
1458 dst_mac = '01:00:5e:01:02:03'
1459 src_ip = '2.2.2.2'
1460 if df is None:
1461 df = defer.Deferred()
1462 igmpState1 = IGMPTestState(groups = groups1, df = df)
1463 igmpStateRecv1 = IGMPTestState(groups = groups1, df = df)
1464 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
1465 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1466 mcastTraffic1.start()
1467 join_state1 = IGMPTestState(groups = groups1)
1468 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
1469 assert target1 == 1, 'EXPECTED FAILURE'
1470 log.info('Interface is not receiving from multicast groups %s' %groups1)
1471 self.igmp_send_joins_different_groups_srclist_wait_query_packets(groups1 + groups2,
1472 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['6.6.6.6', '5.5.5.5']),
1473 intf = self.V_INF1, delay = 2,query_group1 = 'group1', query_group2 = None)
1474 time.sleep(10)
1475 target2 = self.igmp_recv_task(self.V_INF1, groups1, join_state1)
1476 log.info('Interface is receiving from multicast groups %s after send Change to include message' %groups1)
1477 mcastTraffic1.stop()
1478 self.onos_ctrl.deactivate()
1479
1480 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+80)
1481 def test_igmp_change_to_include_src_list_check_for_general_query(self):
1482 '''Verify join EXCLUDE (A) and TO_IN(B) for a multicast group,
1483 we should receive general membership query packet. '''
1484 df = defer.Deferred()
1485 def igmp_change_to_include_src_list_check_for_general_query():
1486 self.igmp_change_to_include_src_list_check_for_general_query(df = df)
1487 df.callback(0)
1488 reactor.callLater(0, igmp_change_to_include_src_list_check_for_general_query)
1489 return df
1490
1491 def igmp_allow_new_src_list_check_for_general_query(self, df = None):
1492 groups1 = (self.MGROUP1,)
1493 groups2 = (self.MGROUP2,)
1494 self.igmp_send_joins_different_groups_srclist(groups1+groups2,
1495 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
1496 intf = self.V_INF1, delay = 2)
1497 dst_mac = '01:00:5e:01:02:03'
1498 src_ip = '6.6.6.6'
1499 if df is None:
1500 df = defer.Deferred()
1501 igmpState1 = IGMPTestState(groups = groups1, df = df)
1502 igmpStateRecv1 = IGMPTestState(groups = groups1, df = df)
1503 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
1504 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1505 mcastTraffic1.start()
1506 join_state1 = IGMPTestState(groups = groups1)
1507 target1 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
1508 #assert target1 == 1, 'EXPECTED FAILURE'
1509 log.info('Interface is not receiving from multicast groups %s' %groups1)
1510 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']),
1511 intf = self.V_INF1, delay = 2, query_group1 = 'group1', query_group2 = None)
1512 target2 = self.igmp_recv_task(self.V_INF1, groups1, join_state1)
1513 log.info('Interface is receiving from multicast groups %s after sending join with new source list' %groups1)
1514 mcastTraffic1.stop()
1515 self.onos_ctrl.deactivate()
1516
1517 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+80)
1518 def test_igmp_allow_new_src_list_check_for_general_query(self):
1519 '''Verify join INCLUDE (A) and ALLOW(B) for a multicast group, we
1520 should receive general membership query packet. '''
1521 df = defer.Deferred()
1522 def igmp_allow_new_src_list_check_for_general_query():
1523 self.igmp_allow_new_src_list_check_for_general_query(df = df)
1524 df.callback(0)
1525 reactor.callLater(0, igmp_allow_new_src_list_check_for_general_query)
1526 return df
1527
1528 def igmp_block_old_src_list_check_for_group_source_specific_query(self, df = None):
1529 groups1 = (self.MGROUP1,)
1530 groups2 = (self.MGROUP2,)
1531 groups = groups1 + groups2
1532 self.igmp_send_joins_different_groups_srclist(groups,
1533 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
1534 intf = self.V_INF1, delay = 2)
1535 dst_mac = '01:00:5e:02:02:03'
1536 src_ip = '5.5.5.5'
1537 if df is None:
1538 df = defer.Deferred()
1539 igmpState1 = IGMPTestState(groups = groups2, df = df)
1540 igmpStateRecv1 = IGMPTestState(groups = groups2, df = df)
1541 mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
1542 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1543 mcastTraffic1.start()
1544 join_state1 = IGMPTestState(groups = groups2)
1545 target1 = self.igmp_recv_task(self.V_INF1, groups2, join_state1)
1546 log.info('Interface is receiving from multicast groups %s' %groups2)
1547 self.igmp_send_joins_different_groups_srclist_wait_query_packets(groups,
1548 (['6.6.6.6', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '7.7.7.7']),
1549 intf = self.V_INF1, delay = 2, query_group1 = 'group1', query_group2 = None)
1550 target2 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1)
1551 assert target2 == 1, 'EXPECTED FAILURE'
1552 log.info('Interface is not receiving from multicast groups %s after sending join with block old source list' %groups2)
1553 mcastTraffic1.stop()
1554 self.onos_ctrl.deactivate()
1555
1556 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+90)
1557 def test_igmp_block_old_src_list_check_for_group_source_specific_query(self):
1558 """ Verify when we send join INCLUDE (A) and BLOCK(B) for a multicast group, we should receive
1559 group source specific membership query packet to A*B source list interface"""
1560 df = defer.Deferred()
1561 def igmp_block_old_src_list_check_for_group_source_specific_query():
1562 self.igmp_block_old_src_list_check_for_group_source_specific_query(df = df)
1563 df.callback(0)
1564 reactor.callLater(0, igmp_block_old_src_list_check_for_group_source_specific_query)
1565 return df
1566
1567 def igmp_include_to_allow_src_list_check_for_general_query(self, df = None):
1568 groups1 = (self.MGROUP1,)
1569 groups2 = (self.MGROUP2,)
1570 self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
1571 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
1572 intf = self.V_INF1, delay = 2)
1573 dst_mac = '01:00:5e:01:02:03'
1574 src_ip = '2.2.2.2'
1575 if df is None:
1576 df = defer.Deferred()
1577 igmpState1 = IGMPTestState(groups = groups1, df = df)
1578 igmpStateRecv1 = IGMPTestState(groups = groups1, df = df)
1579 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
1580 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1581 mcastTraffic1.start()
1582 join_state1 = IGMPTestState(groups = groups1)
1583 target1 = self.igmp_recv_task(self.V_INF1, groups1, join_state1)
1584 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)
1585 target1 = self.igmp_recv_task(self.V_INF1, groups1, join_state1)
1586 mcastTraffic1.stop()
1587 self.onos_ctrl.deactivate()
1588
1589 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+40)
1590 def test_igmp_include_to_allow_src_list_check_for_general_query(self):
1591 '''Verify join INCLUDE (A) and Allow(B) ,should receive general membership query packet '''
1592 df = defer.Deferred()
1593 def igmp_include_to_allow_src_list_check_for_general_query():
1594 self.igmp_include_to_allow_src_list_check_for_general_query(df = df)
1595 df.callback(0)
1596 reactor.callLater(0, igmp_include_to_allow_src_list_check_for_general_query)
1597 return df
1598
1599 def igmp_include_to_block_src_list_check_for_group_source_specific_query(self, df = None):
1600 groups1 = (self.MGROUP1,)
1601 groups2 = (self.MGROUP2,)
1602 self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
1603 (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
1604 intf = self.V_INF1, delay = 2)
1605 dst_mac = '01:00:5e:01:02:03'
1606 src_ip = '2.2.2.2'
1607 if df is None:
1608 df = defer.Deferred()
1609 igmpState1 = IGMPTestState(groups = groups1, df = df)
1610 igmpStateRecv1 = IGMPTestState(groups = groups1, df = df)
1611 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
1612 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1613 mcastTraffic1.start()
1614 join_state1 = IGMPTestState(groups = groups1)
1615 target1 = self.igmp_recv_task(self.V_INF1, groups1, join_state1)
1616 self.send_igmp_leave_listening_group_specific_query(groups = groups1, src_list = ['6.6.6.6','7.7.7.7'],
1617 iface = self.V_INF1, delay = 2)
1618 target1 = self.igmp_recv_task(self.V_INF1, groups1, join_state1)
1619 mcastTraffic1.stop()
1620 self.onos_ctrl.deactivate()
1621
1622 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+40)
1623 def test_igmp_include_to_block_src_list_check_for_group_source_specific_query(self):
1624 '''Verify join INCLUDE (A) and Block(B) ,should receive group source specific membership query packet. '''
1625 df = defer.Deferred()
1626 def igmp_include_to_block_src_list_check_for_group_source_specific_query():
1627 self.igmp_include_to_block_src_list_check_for_group_source_specific_query(df = df)
1628 df.callback(0)
1629 reactor.callLater(0, igmp_include_to_block_src_list_check_for_group_source_specific_query)
1630 return df
1631
1632 def igmp_exclude_to_allow_src_list_check_for_general_query(self, df = None):
1633 groups1 = (self.MGROUP1,)
1634 groups2 = (self.MGROUP2,)
1635 self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4'],
1636 iface = self.V_INF1, delay = 2)
1637
1638 dst_mac = '01:00:5e:01:02:03'
1639 src_ip = '2.2.2.2'
1640 if df is None:
1641 df = defer.Deferred()
1642 igmpState1 = IGMPTestState(groups = groups1, df = df)
1643 igmpStateRecv1 = IGMPTestState(groups = groups1, df = df)
1644 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
1645 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1646 mcastTraffic1.start()
1647 join_state1 = IGMPTestState(groups = groups1)
1648 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
1649 assert target1 == 1, 'EXPECTED FAILURE'
1650 log.info('Interface is not receiving from multicast groups %s' %groups1)
1651 self.igmp_send_joins_different_groups_srclist_wait_query_packets(groups1 + groups2,
1652 (['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)
1653 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
1654 assert target1 == 1, 'EXPECTED FAILURE'
1655 log.info('Interface is not receiving from multicast groups %s' %groups1)
1656 mcastTraffic1.stop()
1657 self.onos_ctrl.deactivate()
1658
1659 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+90)
1660 def test_igmp_exclude_to_allow_src_list_check_for_general_query(self):
1661 '''Verify join EXCLUDE(A) and Allow(B) ,should receive general membership query packet. '''
1662 df = defer.Deferred()
1663 def igmp_exclude_to_allow_src_list_check_for_general_query():
1664 self.igmp_exclude_to_allow_src_list_check_for_general_query(df = df)
1665 df.callback(0)
1666 reactor.callLater(0, igmp_exclude_to_allow_src_list_check_for_general_query)
1667 return df
1668
1669 def igmp_exclude_to_block_src_list_check_for_group_source_specific_query(self, df = None):
1670 groups1 = (self.MGROUP1,)
1671 groups2 = (self.MGROUP2,)
1672 self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4'],
1673 iface = self.V_INF1, delay = 2)
1674
1675 dst_mac = '01:00:5e:01:02:03'
1676 src_ip = '2.2.2.2'
1677 if df is None:
1678 df = defer.Deferred()
1679 igmpState1 = IGMPTestState(groups = groups1, df = df)
1680 igmpStateRecv1 = IGMPTestState(groups = groups1, df = df)
1681 mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
1682 src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
1683 mcastTraffic1.start()
1684 join_state1 = IGMPTestState(groups = groups1)
1685 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
1686 assert target1 == 1, 'EXPECTED FAILURE'
1687 log.info('Interface is not receiving from multicast groups %s' %groups1)
1688 self.send_igmp_leave_listening_group_specific_query(groups = groups1,
1689 src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4', '5.5.5.5', '7.7.7.7'],
1690 iface = self.V_INF1, delay = 2)
1691 target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
1692 assert target1 == 1, 'EXPECTED FAILURE'
1693 log.info('Interface is not receiving from multicast groups %s' %groups1)
1694 mcastTraffic1.stop()
1695 self.onos_ctrl.deactivate()
1696
1697 @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+40)
1698 def test_igmp_exclude_to_block_src_list_check_for_group_source_specific_query(self):
1699 '''Verify join EXCLUDE (A) and Block(B) ,should receive group source specific membership query packet.'''
1700 df = defer.Deferred()
1701 def igmp_exclude_to_block_src_list_check_for_group_source_specific_query():
1702 self.igmp_exclude_to_block_src_list_check_for_group_source_specific_query(df = df)
1703 df.callback(0)
1704 reactor.callLater(0, igmp_exclude_to_block_src_list_check_for_group_source_specific_query)
1705 return df
1706
1707