A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 1 | # |
Chetan Gaonker | cfcce78 | 2016-05-10 10:10:42 -0700 | [diff] [blame] | 2 | # 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 Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 7 | # |
Chetan Gaonker | cfcce78 | 2016-05-10 10:10:42 -0700 | [diff] [blame] | 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 9 | # |
Chetan Gaonker | cfcce78 | 2016-05-10 10:10:42 -0700 | [diff] [blame] | 10 | # 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 Gaonker | 2547097 | 2016-02-26 08:52:15 -0800 | [diff] [blame] | 16 | import unittest |
| 17 | from nose.tools import * |
| 18 | from nose.twistedtools import reactor, deferred |
| 19 | from twisted.internet import defer |
| 20 | from scapy.all import * |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 21 | import time, monotonic |
Chetan Gaonker | 2547097 | 2016-02-26 08:52:15 -0800 | [diff] [blame] | 22 | import os, sys |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 23 | import tempfile |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 24 | import random |
| 25 | import threading |
Chetan Gaonker | e88c95c | 2016-03-02 05:21:47 -0800 | [diff] [blame] | 26 | from IGMP import * |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 27 | from McastTraffic import * |
| 28 | from Stats import Stats |
Chetan Gaonker | 4a25e2b | 2016-03-04 14:45:15 -0800 | [diff] [blame] | 29 | from OnosCtrl import OnosCtrl |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 30 | from OltConfig import OltConfig |
Chetan Gaonker | 4eb1207 | 2016-03-28 15:04:15 -0700 | [diff] [blame] | 31 | from Channels import IgmpChannel |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 32 | log.setLevel('INFO') |
Chetan Gaonker | 2547097 | 2016-02-26 08:52:15 -0800 | [diff] [blame] | 33 | |
| 34 | class 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 Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 43 | self.group_map[g] = (Stats(), Stats()) |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 44 | |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 45 | def update(self, group, tx = 0, rx = 0, t = 0): |
| 46 | self.counter += 1 |
Chetan Gaonker | 2547097 | 2016-02-26 08:52:15 -0800 | [diff] [blame] | 47 | index = 0 if rx == 0 else 1 |
| 48 | v = tx if rx == 0 else rx |
| 49 | if self.group_map.has_key(group): |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 50 | self.group_map[group][index].update(packets = v, t = t) |
Chetan Gaonker | 2547097 | 2016-02-26 08:52:15 -0800 | [diff] [blame] | 51 | |
| 52 | def update_state(self): |
| 53 | self.state = self.state ^ 1 |
Chetan Gaonker | 2547097 | 2016-02-26 08:52:15 -0800 | [diff] [blame] | 54 | |
| 55 | class igmp_exchange(unittest.TestCase): |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 56 | |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 57 | V_INF1 = 'veth0' |
| 58 | V_INF2 = 'veth1' |
| 59 | MGROUP1 = '239.1.2.3' |
| 60 | MGROUP2 = '239.2.2.3' |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 61 | MINVALIDGROUP1 = '255.255.255.255' |
| 62 | MINVALIDGROUP2 = '239.255.255.255' |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 63 | MMACGROUP1 = "01:00:5e:01:02:03" |
| 64 | MMACGROUP2 = "01:00:5e:02:02:03" |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 65 | IGMP_DST_MAC = "01:00:5e:00:00:16" |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 66 | IGMP_SRC_MAC = "5a:e1:ac:ec:4d:a1" |
| 67 | IP_SRC = '1.2.3.4' |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 68 | IP_DST = '224.0.0.22' |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 69 | NEGATIVE_TRAFFIC_STATUS = 1 |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 70 | igmp_eth = Ether(dst = IGMP_DST_MAC, type = ETH_P_IP) |
| 71 | igmp_ip = IP(dst = IP_DST) |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 72 | IGMP_TEST_TIMEOUT = 5 |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 73 | IGMP_QUERY_TIMEOUT = 60 |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 74 | MCAST_TRAFFIC_TIMEOUT = 10 |
Chetan Gaonker | 4eb1207 | 2016-03-28 15:04:15 -0700 | [diff] [blame] | 75 | PORT_TX_DEFAULT = 2 |
| 76 | PORT_RX_DEFAULT = 1 |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 77 | max_packets = 100 |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 78 | app = 'org.opencord.igmp' |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 79 | olt_conf_file = os.path.join(os.path.dirname(os.path.realpath(__file__)), '../setup/olt_config.json') |
A R Karthick | 2b93d6a | 2016-09-06 15:19:09 -0700 | [diff] [blame] | 80 | ROVER_TEST_TIMEOUT = 300 #3600*86 |
| 81 | ROVER_TIMEOUT = (ROVER_TEST_TIMEOUT - 100) |
| 82 | ROVER_JOIN_TIMEOUT = 60 |
Chetan Gaonker | 4a25e2b | 2016-03-04 14:45:15 -0800 | [diff] [blame] | 83 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 84 | @classmethod |
| 85 | def setUpClass(cls): |
| 86 | cls.olt = OltConfig(olt_conf_file = cls.olt_conf_file) |
A R Karthick | 2b93d6a | 2016-09-06 15:19:09 -0700 | [diff] [blame] | 87 | cls.port_map, _ = cls.olt.olt_port_map() |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 88 | OnosCtrl.cord_olt_config(cls.olt.olt_device_data()) |
| 89 | |
| 90 | @classmethod |
| 91 | def tearDownClass(cls): pass |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 92 | |
Chetan Gaonker | 4a25e2b | 2016-03-04 14:45:15 -0800 | [diff] [blame] | 93 | def setUp(self): |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 94 | ''' Activate the igmp app''' |
Chetan Gaonker | 4a25e2b | 2016-03-04 14:45:15 -0800 | [diff] [blame] | 95 | self.onos_ctrl = OnosCtrl(self.app) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 96 | self.onos_ctrl.activate() |
Chetan Gaonker | 4eb1207 | 2016-03-28 15:04:15 -0700 | [diff] [blame] | 97 | self.igmp_channel = IgmpChannel() |
Chetan Gaonker | 4a25e2b | 2016-03-04 14:45:15 -0800 | [diff] [blame] | 98 | |
A R Karthick | 31152b2 | 2016-05-13 11:25:14 -0700 | [diff] [blame] | 99 | def tearDown(self): pass |
Chetan Gaonker | 4a25e2b | 2016-03-04 14:45:15 -0800 | [diff] [blame] | 100 | |
| 101 | def onos_load_config(self, config): |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 102 | log.info('onos load config is %s'%config) |
Chetan Gaonker | a2b87df | 2016-03-31 15:41:31 -0700 | [diff] [blame] | 103 | status, code = OnosCtrl.config(config) |
Chetan Gaonker | 4a25e2b | 2016-03-04 14:45:15 -0800 | [diff] [blame] | 104 | if status is False: |
| 105 | log.info('JSON request returned status %d' %code) |
| 106 | assert_equal(status, True) |
| 107 | time.sleep(2) |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 108 | |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 109 | def onos_ssm_table_load(self, groups, src_list = ['1.2.3.4'],flag = False): |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 110 | ssm_dict = {'apps' : { 'org.onosproject.igmp' : { 'ssmTranslate' : [] } } } |
| 111 | ssm_xlate_list = ssm_dict['apps']['org.onosproject.igmp']['ssmTranslate'] |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 112 | 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 Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 121 | d = {} |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 122 | d['source'] = s or '0.0.0.0' |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 123 | d['group'] = g |
| 124 | ssm_xlate_list.append(d) |
Chetan Gaonker | 4a25e2b | 2016-03-04 14:45:15 -0800 | [diff] [blame] | 125 | self.onos_load_config(ssm_dict) |
Chetan Gaonker | 4eb1207 | 2016-03-28 15:04:15 -0700 | [diff] [blame] | 126 | 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 Gaonker | 5a5204e | 2016-03-02 01:35:13 -0800 | [diff] [blame] | 130 | time.sleep(2) |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 131 | |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 132 | 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 Karthick | 2b93d6a | 2016-09-06 15:19:09 -0700 | [diff] [blame] | 192 | 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 Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 203 | def igmp_verify_join(self, igmpStateList): |
| 204 | sendState, recvState = igmpStateList |
Chetan Gaonker | 2547097 | 2016-02-26 08:52:15 -0800 | [diff] [blame] | 205 | ## check if the send is received for the groups |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 206 | for g in sendState.groups: |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 207 | tx_stats = sendState.group_map[g][0] |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 208 | tx = tx_stats.count |
Chetan Gaonker | 2547097 | 2016-02-26 08:52:15 -0800 | [diff] [blame] | 209 | assert_greater(tx, 0) |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 210 | 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 Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 214 | |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 215 | log.info('IGMP test verification success') |
Chetan Gaonker | 2547097 | 2016-02-26 08:52:15 -0800 | [diff] [blame] | 216 | |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 217 | 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 Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 224 | rx = rx_stats.count |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 225 | 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 Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 231 | |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 232 | log.info('IGMP test verification success') |
Chetan Gaonker | 2547097 | 2016-02-26 08:52:15 -0800 | [diff] [blame] | 233 | |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 234 | 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 Gaonker | 2547097 | 2016-02-26 08:52:15 -0800 | [diff] [blame] | 240 | return 0 |
| 241 | |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 242 | ##Runs in the context of twisted reactor thread |
Chetan Gaonker | 2547097 | 2016-02-26 08:52:15 -0800 | [diff] [blame] | 243 | def igmp_recv(self, igmpState, iface = 'veth0'): |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 244 | p = self.recv_socket.recv() |
Chetan Gaonker | f1b9e32 | 2016-05-09 15:49:15 -0700 | [diff] [blame] | 245 | 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 Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 251 | #log.info( 'Recv in %.6f secs' %(recv_time - send_time)) |
| 252 | igmpState.update(p.dst, rx = 1, t = recv_time - send_time) |
Chetan Gaonker | 2547097 | 2016-02-26 08:52:15 -0800 | [diff] [blame] | 253 | return 0 |
| 254 | |
A R Karthick | 2b93d6a | 2016-09-06 15:19:09 -0700 | [diff] [blame] | 255 | 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 Gaonker | 5a5204e | 2016-03-02 01:35:13 -0800 | [diff] [blame] | 259 | igmp = IGMPv3(type = IGMP_TYPE_V3_MEMBERSHIP_REPORT, max_resp_code=30, |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 260 | gaddr=self.IP_DST) |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 261 | for g in groups: |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 262 | gr = IGMPv3gr(rtype= record_type, mcaddr=g) |
Chetan Gaonker | 5a5204e | 2016-03-02 01:35:13 -0800 | [diff] [blame] | 263 | gr.sources = src_list |
| 264 | igmp.grps.append(gr) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 265 | if ip_pkt is None: |
| 266 | ip_pkt = self.igmp_eth/self.igmp_ip |
| 267 | pkt = ip_pkt/igmp |
Chetan Gaonker | 5a5204e | 2016-03-02 01:35:13 -0800 | [diff] [blame] | 268 | IGMPv3.fixup(pkt) |
| 269 | sendp(pkt, iface=iface) |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 270 | if delay != 0: |
| 271 | time.sleep(delay) |
| 272 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 273 | 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 Gaonker | 38737f8 | 2016-05-11 17:44:17 -0700 | [diff] [blame] | 278 | gr = IGMPv3gr(rtype=IGMP_V3_GR_TYPE_INCLUDE, mcaddr=g) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 279 | 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) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 291 | resp = srp1(pkt, iface=iface) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 292 | # 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 Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 298 | def send_igmp_leave(self, groups, src_list = ['1.2.3.4'], ip_pkt = None, iface = 'veth0', delay = 2): |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 299 | log.info('entering into igmp leave function') |
Chetan Gaonker | 5a5204e | 2016-03-02 01:35:13 -0800 | [diff] [blame] | 300 | igmp = IGMPv3(type = IGMP_TYPE_V3_MEMBERSHIP_REPORT, max_resp_code=30, |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 301 | gaddr=self.IP_DST) |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 302 | for g in groups: |
Chetan Gaonker | 38737f8 | 2016-05-11 17:44:17 -0700 | [diff] [blame] | 303 | gr = IGMPv3gr(rtype=IGMP_V3_GR_TYPE_EXCLUDE, mcaddr=g) |
Chetan Gaonker | 5a5204e | 2016-03-02 01:35:13 -0800 | [diff] [blame] | 304 | gr.sources = src_list |
| 305 | igmp.grps.append(gr) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 306 | if ip_pkt is None: |
| 307 | ip_pkt = self.igmp_eth/self.igmp_ip |
| 308 | pkt = ip_pkt/igmp |
Chetan Gaonker | 5a5204e | 2016-03-02 01:35:13 -0800 | [diff] [blame] | 309 | IGMPv3.fixup(pkt) |
| 310 | sendp(pkt, iface = iface) |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 311 | if delay != 0: |
| 312 | time.sleep(delay) |
Chetan Gaonker | 2547097 | 2016-02-26 08:52:15 -0800 | [diff] [blame] | 313 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 314 | 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 Gaonker | 38737f8 | 2016-05-11 17:44:17 -0700 | [diff] [blame] | 318 | gr = IGMPv3gr(rtype=IGMP_V3_GR_TYPE_EXCLUDE, mcaddr=g) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 319 | 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 Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 332 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10) |
| 333 | def test_igmp_join_verify_traffic(self): |
Chetan Gaonker | 2547097 | 2016-02-26 08:52:15 -0800 | [diff] [blame] | 334 | groups = ['224.0.1.1', '225.0.0.1'] |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 335 | self.onos_ssm_table_load(groups) |
Chetan Gaonker | 2547097 | 2016-02-26 08:52:15 -0800 | [diff] [blame] | 336 | df = defer.Deferred() |
| 337 | igmpState = IGMPTestState(groups = groups, df = df) |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 338 | 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 Gaonker | 2547097 | 2016-02-26 08:52:15 -0800 | [diff] [blame] | 360 | return df |
| 361 | |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 362 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+40) |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 363 | def test_igmp_leave_verify_traffic(self): |
| 364 | groups = ['224.0.1.10', '225.0.0.10'] |
| 365 | leave_groups = ['224.0.1.10'] |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 366 | self.onos_ssm_table_load(groups) |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 367 | df = defer.Deferred() |
| 368 | igmpState = IGMPTestState(groups = groups, df = df) |
| 369 | igmpStateRecv = IGMPTestState(groups = groups, df = df) |
| 370 | igmpStateList = (igmpState, igmpStateRecv) |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 371 | mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb, |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 372 | arg = igmpState) |
| 373 | self.df = df |
| 374 | self.mcastTraffic = mcastTraffic |
| 375 | self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP) |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 376 | |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 377 | 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 Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 385 | 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'] |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 391 | self.onos_ssm_table_load(self.groups,src_list=self.src_list) |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 392 | 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 Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 398 | 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']): |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 421 | #self.onos_ssm_table_load(groups, src_list) |
Chetan Gaonker | 5a5204e | 2016-03-02 01:35:13 -0800 | [diff] [blame] | 422 | igmp = IGMPv3(type = IGMP_TYPE_V3_MEMBERSHIP_REPORT, max_resp_code=30, |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 423 | gaddr=self.IP_DST) |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 424 | for g in groups: |
Chetan Gaonker | 38737f8 | 2016-05-11 17:44:17 -0700 | [diff] [blame] | 425 | gr = IGMPv3gr(rtype = IGMP_V3_GR_TYPE_INCLUDE, mcaddr = g) |
Chetan Gaonker | 5a5204e | 2016-03-02 01:35:13 -0800 | [diff] [blame] | 426 | gr.sources = src_list |
| 427 | igmp.grps.append(gr) |
| 428 | |
| 429 | for g in groups: |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 430 | state.group_map[g][0].update(1, t = monotonic.monotonic()) |
Chetan Gaonker | 5a5204e | 2016-03-02 01:35:13 -0800 | [diff] [blame] | 431 | |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 432 | pkt = self.igmp_eth/self.igmp_ip/igmp |
Chetan Gaonker | 5a5204e | 2016-03-02 01:35:13 -0800 | [diff] [blame] | 433 | IGMPv3.fixup(pkt) |
| 434 | sendp(pkt, iface=intf) |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 435 | 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 Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 443 | log.info('Verifying join interface should receive multicast data') |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 444 | 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 Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 463 | |
| 464 | def igmp_not_recv_task(self, intf, groups, join_state): |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 465 | log.info('entering igmp not recv task loop') |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 466 | 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 Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 471 | log.info('Verifying join interface should not receive any multicast data') |
Chetan Gaonker | 7791bda | 2016-05-12 17:36:52 -0700 | [diff] [blame] | 472 | self.NEGATIVE_TRAFFIC_STATUS = 1 |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 473 | def igmp_recv_cb(pkt): |
| 474 | log.info('Multicast packet %s received for left groups %s' %(pkt[IP].dst, groups)) |
Chetan Gaonker | 7791bda | 2016-05-12 17:36:52 -0700 | [diff] [blame] | 475 | self.NEGATIVE_TRAFFIC_STATUS = 2 |
Chetan Gaonker | 38737f8 | 2016-05-11 17:44:17 -0700 | [diff] [blame] | 476 | sniff(prn = igmp_recv_cb, count = 1, lfilter = lambda p: IP in p and p[IP].dst in groups, |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 477 | timeout = 3, opened_socket = recv_socket) |
| 478 | recv_socket.close() |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 479 | return self.NEGATIVE_TRAFFIC_STATUS |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 480 | |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 481 | 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 Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 487 | mcast_traffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb, |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 488 | 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 | |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 500 | @deferred(timeout=IGMP_QUERY_TIMEOUT + 10) |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 501 | def test_igmp_1group_join_latency(self): |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 502 | 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 Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 509 | |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 510 | @deferred(timeout=IGMP_QUERY_TIMEOUT + 10) |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 511 | def test_igmp_2group_join_latency(self): |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 512 | 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 Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 519 | |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 520 | @deferred(timeout=IGMP_QUERY_TIMEOUT + 10) |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 521 | def test_igmp_Ngroup_join_latency(self): |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 522 | 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 Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 529 | |
A R Karthick | 2b93d6a | 2016-09-06 15:19:09 -0700 | [diff] [blame] | 530 | def test_igmp_join_rover_all(self): |
Chetan Gaonker | 1f7c3f8 | 2016-03-08 12:17:37 -0800 | [diff] [blame] | 531 | s = (224 << 24) | 1 |
| 532 | #e = (225 << 24) | (255 << 16) | (255 << 16) | 255 |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 533 | e = (224 << 24) | 10 |
Chetan Gaonker | 1f7c3f8 | 2016-03-08 12:17:37 -0800 | [diff] [blame] | 534 | 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 Karthick | 2b93d6a | 2016-09-06 15:19:09 -0700 | [diff] [blame] | 539 | @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 Gaonker | 1f7c3f8 | 2016-03-08 12:17:37 -0800 | [diff] [blame] | 577 | @deferred(timeout=IGMP_QUERY_TIMEOUT + 10) |
| 578 | def test_igmp_query(self): |
| 579 | groups = ['224.0.0.1'] ##igmp query group |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 580 | self.onos_ssm_table_load(groups) |
Chetan Gaonker | 1f7c3f8 | 2016-03-08 12:17:37 -0800 | [diff] [blame] | 581 | df = defer.Deferred() |
| 582 | self.df = df |
| 583 | self.recv_socket = L2Socket(iface = 'veth0', type = ETH_P_IP) |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 584 | |
Chetan Gaonker | 1f7c3f8 | 2016-03-08 12:17:37 -0800 | [diff] [blame] | 585 | def igmp_query_timeout(): |
Chetan Gaonker | 1f7c3f8 | 2016-03-08 12:17:37 -0800 | [diff] [blame] | 586 | def igmp_query_cb(pkt): |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 587 | log.info('received igmp query packet is %s'%pkt.show()) |
Chetan Gaonker | bd4390f | 2016-03-09 18:56:52 -0800 | [diff] [blame] | 588 | 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 Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 590 | sniff(prn = igmp_query_cb, count=1, lfilter = lambda p: IP in p and p[IP].dst in groups, |
Chetan Gaonker | bd4390f | 2016-03-09 18:56:52 -0800 | [diff] [blame] | 591 | opened_socket = self.recv_socket) |
Chetan Gaonker | 1f7c3f8 | 2016-03-08 12:17:37 -0800 | [diff] [blame] | 592 | self.recv_socket.close() |
| 593 | self.df.callback(0) |
| 594 | |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 595 | #self.send_igmp_join(groups) |
Chetan Gaonker | 1f7c3f8 | 2016-03-08 12:17:37 -0800 | [diff] [blame] | 596 | self.test_timer = reactor.callLater(self.IGMP_QUERY_TIMEOUT, igmp_query_timeout) |
| 597 | return df |
| 598 | |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 599 | 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] |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 604 | eth = Ether(dst = self.IGMP_DST_MAC,type = ETH_P_IP) |
| 605 | ip = IP(dst = self.IP_DST) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 606 | 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) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 609 | ip = IP(dst = g2) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 610 | 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 Gaonker | 7791bda | 2016-05-12 17:36:52 -0700 | [diff] [blame] | 612 | log.info('Done with igmp_send_joins_different_groups_srclist') |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 613 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 614 | 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 Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 625 | else: |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 626 | 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 Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 633 | else: |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 634 | 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 | |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 637 | 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 Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 642 | self.igmp_send_joins_different_groups_srclist(groups1 + groups2, |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 643 | (src1, src2), intf = self.V_INF1, delay = 2) |
| 644 | |
| 645 | src_ip = src1[0] |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 646 | 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) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 655 | dst_mac = self.iptomac(groups1[0]) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 656 | mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac, |
| 657 | src_ip = src_ip, cb = self.send_mcast_cb, |
| 658 | arg = igmpState1) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 659 | src_ip = src2[0] |
| 660 | dst_mac = self.iptomac(groups1[0]) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 661 | 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) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 673 | self.send_igmp_leave(groups = groups2, src_list = src2, iface = self.V_INF1, delay = 2) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 674 | 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' |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 680 | eth = Ether(dst = dst_mac, type = ETH_P_IP) |
| 681 | ip = IP(dst = ip_dst) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 682 | 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 Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 692 | |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 693 | |
| 694 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 695 | def test_igmp_2joins_1leave(self): |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 696 | df = defer.Deferred() |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 697 | 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 Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 702 | df.callback(0) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 703 | reactor.callLater(0, igmp_2joins_1leave) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 704 | return df |
| 705 | |
| 706 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+25) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 707 | def test_igmp_2joins_1leave_and_join_again(self): |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 708 | df = defer.Deferred() |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 709 | 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 Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 714 | df.callback(0) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 715 | reactor.callLater(0, igmp_2joins_1leave_join_again) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 716 | return df |
| 717 | |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 718 | def igmp_not_in_src_list(self, df = None): |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 719 | groups1 = (self.MGROUP1,) |
| 720 | groups2 = (self.MGROUP2,) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 721 | 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 Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 722 | 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 Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 725 | src_ip = '6.6.6.6' |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 726 | dst_mac = self.iptomac(groups1[0]) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 727 | 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 Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 735 | log.info('Interface should not receive from multicast groups %s from an interface, which is expected' %groups1) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 736 | target1 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1) |
Chetan Gaonker | 7791bda | 2016-05-12 17:36:52 -0700 | [diff] [blame] | 737 | assert target1 == 2, 'EXPECTED FAILURE' |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 738 | log.info('Interface is not receiving traffic from multicast groups %s, working as expected' %groups1) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 739 | mcastTraffic1.stop() |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 740 | |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 741 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 742 | def test_igmp_not_in_src_list(self): |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 743 | df = defer.Deferred() |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 744 | def igmp_not_in_src_list(): |
| 745 | self.igmp_not_in_src_list(df = df) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 746 | df.callback(0) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 747 | reactor.callLater(0, igmp_not_in_src_list) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 748 | return df |
| 749 | |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 750 | 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 Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 754 | 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 Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 757 | src_ip = '2.2.2.2' |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 758 | dst_mac=self.iptomac(groups1[0]) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 759 | 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 Gaonker | 7791bda | 2016-05-12 17:36:52 -0700 | [diff] [blame] | 770 | assert target2 == 2, 'EXPECTED FAILURE' |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 771 | log.info('Interface is not receiving traffic from multicast groups %s after sending CHANGE_TO_EXCLUDE' %groups1) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 772 | mcastTraffic1.stop() |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 773 | |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 774 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 775 | def test_igmp_change_to_exclude_src_list(self): |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 776 | df = defer.Deferred() |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 777 | def igmp_change_to_exclude_src_list(): |
| 778 | self.igmp_change_to_exclude_src_list(df = df) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 779 | df.callback(0) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 780 | reactor.callLater(0, igmp_change_to_exclude_src_list) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 781 | return df |
| 782 | |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 783 | 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 Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 789 | if df is None: |
| 790 | df = defer.Deferred() |
| 791 | igmpState1 = IGMPTestState(groups = groups1, df = df) |
| 792 | igmpStateRecv1 = IGMPTestState(groups = groups1, df = df) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 793 | mcastTraffic1 = McastTraffic(groups1, iface= 'veth2',src_ip = src_ip, |
| 794 | cb = self.send_mcast_cb, arg = igmpState1) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 795 | mcastTraffic1.start() |
| 796 | join_state1 = IGMPTestState(groups = groups1) |
| 797 | target1 = self.igmp_recv_task(self.V_INF1, groups1, join_state1) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 798 | 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 Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 804 | target1 = self.igmp_recv_task(self.V_INF1, groups1, join_state1) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 805 | mcastTraffic2.stop() |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 806 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 807 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+30) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 808 | def test_igmp_include_to_allow_src_list(self): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 809 | df = defer.Deferred() |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 810 | def igmp_include_to_allow_src_list(): |
| 811 | self.igmp_include_to_allow_src_list(df = df) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 812 | df.callback(0) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 813 | reactor.callLater(0, igmp_include_to_allow_src_list) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 814 | return df |
| 815 | |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 816 | 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 Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 821 | if df is None: |
| 822 | df = defer.Deferred() |
| 823 | igmpState1 = IGMPTestState(groups = groups1, df = df) |
| 824 | igmpStateRecv1 = IGMPTestState(groups = groups1, df = df) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 825 | mcastTraffic1 = McastTraffic(groups1, iface= 'veth2',src_ip = '6.6.6.6', |
| 826 | cb = self.send_mcast_cb, arg = igmpState1) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 827 | mcastTraffic1.start() |
| 828 | join_state1 = IGMPTestState(groups = groups1) |
| 829 | target1 = self.igmp_recv_task(self.V_INF1, groups1, join_state1) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 830 | 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 Gaonker | 717b294 | 2016-05-13 17:42:59 -0700 | [diff] [blame] | 838 | log.info('Interface is still receiving from old multicast group data %s even after we send block list' %groups1) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 839 | mcastTraffic2.stop() |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 840 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 841 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+30) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 842 | def test_igmp_include_to_block_src_list(self): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 843 | df = defer.Deferred() |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 844 | def igmp_include_to_block_src_list(): |
| 845 | self.igmp_include_to_block_src_list(df = df) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 846 | df.callback(0) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 847 | reactor.callLater(0, igmp_include_to_block_src_list) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 848 | return df |
| 849 | |
| 850 | |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 851 | 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 Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 856 | iface = self.V_INF1, delay = 2) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 857 | if df is None: |
| 858 | df = defer.Deferred() |
| 859 | igmpState1 = IGMPTestState(groups = groups1, df = df) |
| 860 | igmpStateRecv1 = IGMPTestState(groups = groups1, df = df) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 861 | mcastTraffic1 = McastTraffic(groups1, iface= 'veth2',src_ip = src_list[0], |
| 862 | cb = self.send_mcast_cb, arg = igmpState1) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 863 | 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' |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 867 | 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 Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 876 | |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 877 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 878 | def test_igmp_change_to_include_src_list(self): |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 879 | df = defer.Deferred() |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 880 | def igmp_change_to_include_src_list(): |
| 881 | self.igmp_change_to_include_src_list(df = df) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 882 | df.callback(0) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 883 | reactor.callLater(0, igmp_change_to_include_src_list) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 884 | return df |
| 885 | |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 886 | #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 Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 888 | groups1 = (self.MGROUP1,) |
| 889 | groups2 = (self.MGROUP2,) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 890 | 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 Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 891 | 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 Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 893 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 894 | 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' |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 906 | log.info('Interface is not receiving traffic from multicast groups %s' %groups1) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 907 | 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' |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 912 | log.info('Interface is not receiving traffic from multicast groups %s' %groups1) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 913 | mcastTraffic1.stop() |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 914 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 915 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 916 | def test_igmp_exclude_to_allow_src_list(self): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 917 | df = defer.Deferred() |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 918 | def igmp_exclude_to_allow_src_list(): |
| 919 | self.igmp_exclude_to_allow_src_list(df = df) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 920 | df.callback(0) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 921 | reactor.callLater(0, igmp_exclude_to_allow_src_list) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 922 | return df |
| 923 | |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 924 | def igmp_exclude_to_block_src_list(self, df = None): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 925 | groups1 = (self.MGROUP1,) |
| 926 | groups2 = (self.MGROUP2,) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 927 | 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 Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 928 | 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 Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 930 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 931 | 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' |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 943 | log.info('Interface is not receiving traffic from multicast groups %s' %groups1) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 944 | 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' |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 948 | log.info('Interface is not receiving traffic from multicast groups %s' %groups1) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 949 | mcastTraffic1.stop() |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 950 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 951 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 952 | def test_igmp_exclude_to_block_src_list(self): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 953 | df = defer.Deferred() |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 954 | def igmp_exclude_to_block_src_list(): |
| 955 | self.igmp_exclude_to_block_src_list(df = df) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 956 | df.callback(0) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 957 | reactor.callLater(0, igmp_exclude_to_block_src_list) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 958 | return df |
| 959 | |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 960 | #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 Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 962 | groups1 = (self.MGROUP1,) |
| 963 | groups2 = (self.MGROUP2,) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 964 | 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 Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 965 | 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' |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 980 | log.info('Interface is not receiving traffic from multicast groups %s' %groups1) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 981 | self.igmp_send_joins_different_groups_srclist(groups1 + groups2, |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 982 | (['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 Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 983 | intf = self.V_INF1, delay = 2) |
| 984 | target2 = self.igmp_recv_task(self.V_INF1, groups1, join_state1) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 985 | log.info('Interface is receiving traffic from multicast groups %s after sending join with new source list' %groups1) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 986 | mcastTraffic1.stop() |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 987 | |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 988 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 989 | def test_igmp_new_src_list(self): |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 990 | df = defer.Deferred() |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 991 | def igmp_new_src_list(): |
| 992 | self.igmp_new_src_list(df = df) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 993 | df.callback(0) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 994 | reactor.callLater(0, igmp_new_src_list) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 995 | return df |
| 996 | |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 997 | def igmp_block_old_src_list(self, df = None): |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 998 | groups1 = (self.MGROUP1,) |
| 999 | groups2 = (self.MGROUP2,) |
| 1000 | groups = groups1 + groups2 |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1001 | 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 Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 1002 | 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) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1016 | log.info('Interface is receiving traffic from multicast groups %s' %groups2) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 1017 | 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 Gaonker | 7791bda | 2016-05-12 17:36:52 -0700 | [diff] [blame] | 1021 | assert target2 == 2, 'EXPECTED FAILURE' |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1022 | log.info('Interface is not receiving traffic from multicast groups %s after sending join with block old source list' %groups2) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 1023 | mcastTraffic1.stop() |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 1024 | |
| 1025 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1026 | def test_igmp_block_old_src_list(self): |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 1027 | df = defer.Deferred() |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1028 | def igmp_block_old_src_list(): |
| 1029 | self.igmp_block_old_src_list(df = df) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 1030 | df.callback(0) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1031 | reactor.callLater(0, igmp_block_old_src_list) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 1032 | return df |
| 1033 | |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1034 | def igmp_include_empty_src_list(self, df = None): |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 1035 | 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' |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1053 | log.info('Interface is not receiving traffic from multicast groups %s when we sent join with source list is empty' %groups2) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 1054 | mcastTraffic1.stop() |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 1055 | |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 1056 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1057 | def test_igmp_include_empty_src_list(self): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1058 | ## '''Disabling this test as scapy IGMP doesn't work with empty source lists''' |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 1059 | df = defer.Deferred() |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1060 | def igmp_include_empty_src_list(): |
| 1061 | self.igmp_include_empty_src_list(df = df) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 1062 | df.callback(0) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1063 | reactor.callLater(0, igmp_include_empty_src_list) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 1064 | return df |
| 1065 | |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1066 | def igmp_exclude_empty_src_list(self, df = None): |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 1067 | 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 Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 1084 | |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 1085 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1086 | def test_igmp_exclude_empty_src_list(self): |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 1087 | df = defer.Deferred() |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1088 | def igmp_exclude_empty_src_list(): |
| 1089 | self.igmp_exclude_empty_src_list() |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 1090 | df.callback(0) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1091 | reactor.callLater(0, igmp_exclude_empty_src_list) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 1092 | return df |
| 1093 | |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1094 | def igmp_join_sourceip_0_0_0_0(self, df = None): |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 1095 | 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) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1114 | log.info('Interface is receiving traffic from multicast groups %s when we sent join with source IP is 0.0.0.0' %groups2) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 1115 | mcastTraffic1.stop() |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 1116 | |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 1117 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1118 | def test_igmp_join_sourceip_0_0_0_0(self): |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 1119 | df = defer.Deferred() |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1120 | def igmp_join_sourceip_0_0_0_0(): |
| 1121 | self.igmp_join_sourceip_0_0_0_0(df = df) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 1122 | df.callback(0) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1123 | reactor.callLater(0, igmp_join_sourceip_0_0_0_0) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 1124 | return df |
| 1125 | |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1126 | def igmp_invalid_join_packet(self, df = None): |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1127 | 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' |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1147 | log.info('Interface is not receiving traffic from multicast groups %s when we sent invalid join packet ' %groups2) |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1148 | mcastTraffic1.stop() |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 1149 | |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1150 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1151 | def test_igmp_invalid_join_packet(self): |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1152 | df = defer.Deferred() |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1153 | def igmp_invalid_join_packet(): |
| 1154 | self.igmp_invalid_join_packet(df = df) |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1155 | df.callback(0) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1156 | reactor.callLater(0, igmp_invalid_join_packet) |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1157 | return df |
| 1158 | |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1159 | def igmp_join_data_receiving_during_subscriber_link_toggle(self, df = None): |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1160 | 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) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1179 | log.info('Interface is receiving traffic from multicast groups, before bring down the self.V_INF1=%s ' %self.V_INF1) |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1180 | 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 Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1184 | 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 Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1187 | target1 = self.igmp_recv_task(self.V_INF1, groups2, join_state1) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1188 | log.info('Interface is receiving traffic from multicast groups %s when we nterface up after down ' %groups2) |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1189 | mcastTraffic1.stop() |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 1190 | |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1191 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1192 | def test_igmp_join_data_received_during_subscriber_link_toggle(self): |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1193 | df = defer.Deferred() |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1194 | def igmp_join_data_received_during_subscriber_link_toggle(): |
| 1195 | self.igmp_join_data_received_during_subscriber_link_toggle(df = df) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1196 | df.callback(0) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1197 | reactor.callLater(0, igmp_join_data_received_during_subscriber_link_toggle) |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1198 | return df |
| 1199 | |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1200 | def igmp_join_data_received_during_channel_distributor_link_toggle(self, df = None): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1201 | 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 Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1229 | mcastTraffic1.stop() |
| 1230 | os.system('ifconfig '+'veth2'+' down') |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1231 | os.system('ifconfig '+'veth2') |
| 1232 | time.sleep(10) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1233 | target2 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1234 | target1 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1) |
| 1235 | assert target1==1, 'EXPECTED FAILURE' |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1236 | os.system('ifconfig '+'veth2'+' up') |
| 1237 | os.system('ifconfig '+'veth2') |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1238 | time.sleep(10) |
| 1239 | mcastTraffic1.start() |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1240 | 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 Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1243 | mcastTraffic2.stop() |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 1244 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1245 | ## 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) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1248 | def test_igmp_join_data_received_during_channel_distributors_link_toggle(self): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1249 | df = defer.Deferred() |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1250 | def igmp_join_data_receiving_during_channel_distributor_link_toggle(): |
| 1251 | self.igmp_join_data_receiving_during_channel_distributor_link_toggle(df = df) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1252 | df.callback(0) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1253 | reactor.callLater(0, igmp_join_data_receiving_during_channel_distributor_link_toggle) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1254 | return df |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1255 | |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1256 | def igmp_invalidClassD_IP_join_packet(self, df = None): |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1257 | 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' |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1277 | log.info('Interface is not receiving traffic from multicast groups %s when we sent invalid join packet ' %groups2) |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1278 | mcastTraffic1.stop() |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1279 | |
| 1280 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1281 | def test_igmp_invalid_class_d_ip_for_join_packet(self): |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1282 | df = defer.Deferred() |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1283 | def igmp_invalidClass_D_IP_join_packet(): |
| 1284 | self.igmp_invalidClass_D_IP_join_packet(df = df) |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1285 | df.callback(0) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1286 | reactor.callLater(0, igmp_invalidClassD_IP_join_packet) |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1287 | return df |
| 1288 | |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1289 | def igmp_invalidClassD_IP_as_srclistIP_join_packet(self, df = None): |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1290 | 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' |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1310 | log.info('Interface is not receiving traffic from multicast groups %s when we sent invalid join packet ' %groups2) |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1311 | mcastTraffic1.stop() |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 1312 | |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1313 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1314 | def test_igmp_invalid_class_d_ip_as_srclist_ip_for_join_packet(self): |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1315 | df = defer.Deferred() |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1316 | def igmp_invalidClassD_IP_as_srclistIP_join_packet(): |
| 1317 | self.igmp_invalidClassD_IP_as_srclistIP_join_packet(df = df) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1318 | df.callback(0) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1319 | reactor.callLater(0, igmp_invalidClassD_IP_as_srclistIP_join_packet) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1320 | return df |
Chetan Gaonker | f72ca40 | 2016-05-02 16:29:32 -0700 | [diff] [blame] | 1321 | |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1322 | def igmp_general_query_recv_packet(self, df = None): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1323 | 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) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1357 | log.info('Now checking join interface is receiving a multicast data for group %s after 190 sec' %groups2) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1358 | 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 Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 1362 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1363 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+250) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1364 | def test_igmp_general_query_received_traffic(self): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1365 | df = defer.Deferred() |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1366 | def igmp_general_query_recv_packet(): |
| 1367 | self.igmp_general_query_recv_packet(df = df) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1368 | df.callback(0) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1369 | reactor.callLater(0, igmp_general_query_recv_packet) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1370 | return df |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 1371 | |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1372 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+100) |
| 1373 | def test_igmp_query_received_on_joining_interface(self): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1374 | 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 Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 1380 | mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb, |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1381 | arg = igmpState) |
| 1382 | self.df = df |
| 1383 | self.mcastTraffic = mcastTraffic |
| 1384 | self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP) |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 1385 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1386 | 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 | |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1397 | log.info('Sending join packet and expect to receive on general query packet after 60 sec for multicast %s ' %groups) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1398 | self.send_igmp_join_recvQuery(groups) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1399 | log.info('Received a general query packet for multicast %s group on joing interface and sending traffic' %groups) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1400 | 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) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1406 | def test_igmp_for_periodic_query_received_on_joining_interface(self): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1407 | 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 Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 1413 | mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb, |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1414 | arg = igmpState) |
| 1415 | self.df = df |
| 1416 | self.mcastTraffic = mcastTraffic |
| 1417 | self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP) |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 1418 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1419 | 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) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1434 | def test_igmp_for_periodic_query_received_and_checking_entry_deleted(self): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1435 | 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 Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 1441 | mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb, |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1442 | arg = igmpState) |
| 1443 | self.df = df |
| 1444 | self.mcastTraffic = mcastTraffic |
| 1445 | self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP) |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 1446 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1447 | 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) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1459 | 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 Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1460 | 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 Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1465 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+190) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1466 | def test_igmp_member_query_interval_and_expiry_for_rejoining_interface(self): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1467 | 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 Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 1473 | mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb, |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1474 | arg = igmpState) |
| 1475 | self.df = df |
| 1476 | self.mcastTraffic = mcastTraffic |
| 1477 | self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP) |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 1478 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1479 | 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) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1491 | 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 Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1492 | 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) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1499 | def test_igmp_leave_received_group_and_source_specific_query(self): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1500 | 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 Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 1506 | mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb, |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1507 | arg = igmpState) |
| 1508 | self.df = df |
| 1509 | self.mcastTraffic = mcastTraffic |
| 1510 | self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP) |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 1511 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1512 | 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' |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1548 | log.info('Interface is not receiving traffic from multicast groups %s after sending CHANGE_TO_EXCLUDE' %groups2) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1549 | mcastTraffic1.stop() |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 1550 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1551 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+60) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1552 | def test_igmp_change_to_exclude_src_list_and_check_for_group_source_specific_query(self): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1553 | 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' |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1577 | log.info('Interface is not receiving traffic from multicast groups %s' %groups1) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1578 | 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) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1583 | log.info('Interface is receiving traffic from multicast groups %s after send Change to include message' %groups1) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1584 | mcastTraffic1.stop() |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 1585 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1586 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+80) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1587 | def test_igmp_change_to_include_src_list_and_check_for_general_query(self): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1588 | 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' |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1613 | log.info('Interface is not receiving traffic from multicast groups %s' %groups1) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1614 | 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) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1617 | log.info('Interface is receiving traffic from multicast groups %s after sending join with new source list' %groups1) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1618 | mcastTraffic1.stop() |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 1619 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1620 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+80) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1621 | def test_igmp_allow_new_src_list_and_check_for_general_query(self): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1622 | 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) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1647 | log.info('Interface is receiving traffic from multicast groups %s' %groups2) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1648 | 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' |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1653 | log.info('Interface is not receiving traffic from multicast groups %s after sending join with block old source list' %groups2) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1654 | mcastTraffic1.stop() |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1655 | |
| 1656 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+90) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1657 | def test_igmp_block_old_src_list_and_check_for_group_source_specific_query(self): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1658 | 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 Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1685 | |
| 1686 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+40) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1687 | def test_igmp_include_to_allow_src_list_and_check_for_general_query(self): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1688 | 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 Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1716 | |
| 1717 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+40) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1718 | def test_igmp_include_to_block_src_list_and_check_for_group_source_specific_query(self): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1719 | 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 Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 1731 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1732 | 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' |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1744 | log.info('Interface is not receiving traffic from multicast groups %s' %groups1) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1745 | 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' |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1749 | log.info('Interface is not receiving traffic from multicast groups %s' %groups1) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1750 | mcastTraffic1.stop() |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 1751 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1752 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+90) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1753 | def test_igmp_exclude_to_allow_src_list_and_check_for_general_query(self): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1754 | 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 Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 1766 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1767 | 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' |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1779 | log.info('Interface is not receiving traffic from multicast groups %s' %groups1) |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 1780 | self.send_igmp_leave_listening_group_specific_query(groups = groups1, |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1781 | 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' |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1785 | log.info('Interface is not receiving traffic from multicast groups %s' %groups1) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1786 | mcastTraffic1.stop() |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1787 | |
| 1788 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+40) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1789 | def test_igmp_exclude_to_block_src_list_and_check_for_group_source_specific_query(self): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1790 | 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 |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1796 | |
| 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 | |