Matteo Scandolo | 48d3d2d | 2017-08-08 13:05:27 -0700 | [diff] [blame] | 1 | |
| 2 | # Copyright 2017-present Open Networking Foundation |
| 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 |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 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 | |
| 16 | |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 17 | # |
Chetan Gaonker | cfcce78 | 2016-05-10 10:10:42 -0700 | [diff] [blame] | 18 | # Copyright 2016-present Ciena Corporation |
| 19 | # |
| 20 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 21 | # you may not use this file except in compliance with the License. |
| 22 | # You may obtain a copy of the License at |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 23 | # |
Chetan Gaonker | cfcce78 | 2016-05-10 10:10:42 -0700 | [diff] [blame] | 24 | # http://www.apache.org/licenses/LICENSE-2.0 |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 25 | # |
Chetan Gaonker | cfcce78 | 2016-05-10 10:10:42 -0700 | [diff] [blame] | 26 | # Unless required by applicable law or agreed to in writing, software |
| 27 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 28 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 29 | # See the License for the specific language governing permissions and |
| 30 | # limitations under the License. |
| 31 | # |
A R Karthick | bd69867 | 2017-07-13 16:48:24 -0700 | [diff] [blame] | 32 | from twisted.internet import defer |
Chetan Gaonker | 2547097 | 2016-02-26 08:52:15 -0800 | [diff] [blame] | 33 | from nose.tools import * |
| 34 | from nose.twistedtools import reactor, deferred |
Chetan Gaonker | 2547097 | 2016-02-26 08:52:15 -0800 | [diff] [blame] | 35 | from scapy.all import * |
A R Karthick | bd69867 | 2017-07-13 16:48:24 -0700 | [diff] [blame] | 36 | from select import select as socket_select |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 37 | import time, monotonic |
ChetanGaonker | b99538a | 2016-12-02 13:53:35 -0800 | [diff] [blame] | 38 | import os |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 39 | import random |
| 40 | import threading |
Chetan Gaonker | e88c95c | 2016-03-02 05:21:47 -0800 | [diff] [blame] | 41 | from IGMP import * |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 42 | from McastTraffic import * |
| 43 | from Stats import Stats |
Chetan Gaonker | 4a25e2b | 2016-03-04 14:45:15 -0800 | [diff] [blame] | 44 | from OnosCtrl import OnosCtrl |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 45 | from OltConfig import OltConfig |
Chetan Gaonker | 4eb1207 | 2016-03-28 15:04:15 -0700 | [diff] [blame] | 46 | from Channels import IgmpChannel |
A R Karthick | 9313b76 | 2016-11-07 13:14:35 -0800 | [diff] [blame] | 47 | from CordLogger import CordLogger |
A R Karthick | 9dc6e92 | 2017-07-12 14:40:16 -0700 | [diff] [blame] | 48 | from CordTestConfig import setup_module, teardown_module |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 49 | from CordTestUtils import log_test |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 50 | log_test.setLevel('INFO') |
Chetan Gaonker | 2547097 | 2016-02-26 08:52:15 -0800 | [diff] [blame] | 51 | |
| 52 | class IGMPTestState: |
| 53 | |
| 54 | def __init__(self, groups = [], df = None, state = 0): |
| 55 | self.df = df |
| 56 | self.state = state |
| 57 | self.counter = 0 |
| 58 | self.groups = groups |
| 59 | self.group_map = {} ##create a send/recv count map |
| 60 | for g in groups: |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 61 | self.group_map[g] = (Stats(), Stats()) |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 62 | |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 63 | def update(self, group, tx = 0, rx = 0, t = 0): |
| 64 | self.counter += 1 |
Chetan Gaonker | 2547097 | 2016-02-26 08:52:15 -0800 | [diff] [blame] | 65 | index = 0 if rx == 0 else 1 |
| 66 | v = tx if rx == 0 else rx |
| 67 | if self.group_map.has_key(group): |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 68 | self.group_map[group][index].update(packets = v, t = t) |
Chetan Gaonker | 2547097 | 2016-02-26 08:52:15 -0800 | [diff] [blame] | 69 | |
| 70 | def update_state(self): |
| 71 | self.state = self.state ^ 1 |
Chetan Gaonker | 2547097 | 2016-02-26 08:52:15 -0800 | [diff] [blame] | 72 | |
A R Karthick | 9313b76 | 2016-11-07 13:14:35 -0800 | [diff] [blame] | 73 | class igmp_exchange(CordLogger): |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 74 | |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 75 | V_INF1 = 'veth0' |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 76 | MGROUP1 = '239.1.2.3' |
| 77 | MGROUP2 = '239.2.2.3' |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 78 | MINVALIDGROUP1 = '255.255.255.255' |
| 79 | MINVALIDGROUP2 = '239.255.255.255' |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 80 | MMACGROUP1 = "01:00:5e:01:02:03" |
| 81 | MMACGROUP2 = "01:00:5e:02:02:03" |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 82 | IGMP_DST_MAC = "01:00:5e:00:00:16" |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 83 | IGMP_SRC_MAC = "5a:e1:ac:ec:4d:a1" |
| 84 | IP_SRC = '1.2.3.4' |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 85 | IP_DST = '224.0.0.22' |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 86 | NEGATIVE_TRAFFIC_STATUS = 1 |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 87 | igmp_eth = Ether(dst = IGMP_DST_MAC, type = ETH_P_IP) |
| 88 | igmp_ip = IP(dst = IP_DST) |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 89 | IGMP_TEST_TIMEOUT = 5 |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 90 | IGMP_QUERY_TIMEOUT = 60 |
A R Karthick | a93fdee | 2017-07-14 17:27:35 -0700 | [diff] [blame] | 91 | MCAST_TRAFFIC_TIMEOUT = 20 |
Chetan Gaonker | 4eb1207 | 2016-03-28 15:04:15 -0700 | [diff] [blame] | 92 | PORT_TX_DEFAULT = 2 |
| 93 | PORT_RX_DEFAULT = 1 |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 94 | max_packets = 100 |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 95 | app = 'org.opencord.igmp' |
A.R Karthick | 5968e0d | 2017-05-16 14:50:46 -0700 | [diff] [blame] | 96 | olt_conf_file = os.getenv('OLT_CONFIG_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] | 97 | ROVER_TEST_TIMEOUT = 300 #3600*86 |
| 98 | ROVER_TIMEOUT = (ROVER_TEST_TIMEOUT - 100) |
| 99 | ROVER_JOIN_TIMEOUT = 60 |
A R Karthick | bd69867 | 2017-07-13 16:48:24 -0700 | [diff] [blame] | 100 | VOLTHA_ENABLED = bool(int(os.getenv('VOLTHA_ENABLED', 0))) |
Chetan Gaonker | 4a25e2b | 2016-03-04 14:45:15 -0800 | [diff] [blame] | 101 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 102 | @classmethod |
| 103 | def setUpClass(cls): |
A R Karthick | 38d5df4 | 2017-07-10 13:33:26 -0700 | [diff] [blame] | 104 | cls.olt = OltConfig(olt_conf_file = cls.olt_conf_file) |
| 105 | cls.port_map, _ = cls.olt.olt_port_map() |
A R Karthick | bd69867 | 2017-07-13 16:48:24 -0700 | [diff] [blame] | 106 | if cls.VOLTHA_ENABLED is False: |
| 107 | OnosCtrl.config_device_driver() |
| 108 | OnosCtrl.cord_olt_config(cls.olt) |
A R Karthick | 38d5df4 | 2017-07-10 13:33:26 -0700 | [diff] [blame] | 109 | time.sleep(2) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 110 | |
| 111 | @classmethod |
A R Karthick | 38d5df4 | 2017-07-10 13:33:26 -0700 | [diff] [blame] | 112 | def tearDownClass(cls): |
A R Karthick | bd69867 | 2017-07-13 16:48:24 -0700 | [diff] [blame] | 113 | if cls.VOLTHA_ENABLED is False: |
| 114 | OnosCtrl.config_device_driver(driver = 'ovs') |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 115 | |
Chetan Gaonker | 4a25e2b | 2016-03-04 14:45:15 -0800 | [diff] [blame] | 116 | def setUp(self): |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 117 | ''' Activate the igmp app''' |
A R Karthick | 9313b76 | 2016-11-07 13:14:35 -0800 | [diff] [blame] | 118 | super(igmp_exchange, self).setUp() |
Chetan Gaonker | 4a25e2b | 2016-03-04 14:45:15 -0800 | [diff] [blame] | 119 | self.onos_ctrl = OnosCtrl(self.app) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 120 | self.onos_ctrl.activate() |
Chetan Gaonker | 4eb1207 | 2016-03-28 15:04:15 -0700 | [diff] [blame] | 121 | self.igmp_channel = IgmpChannel() |
Chetan Gaonker | 4a25e2b | 2016-03-04 14:45:15 -0800 | [diff] [blame] | 122 | |
A R Karthick | 9313b76 | 2016-11-07 13:14:35 -0800 | [diff] [blame] | 123 | def tearDown(self): |
| 124 | super(igmp_exchange, self).tearDown() |
Chetan Gaonker | 4a25e2b | 2016-03-04 14:45:15 -0800 | [diff] [blame] | 125 | |
| 126 | def onos_load_config(self, config): |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 127 | log_test.info('onos load config is %s'%config) |
Chetan Gaonker | a2b87df | 2016-03-31 15:41:31 -0700 | [diff] [blame] | 128 | status, code = OnosCtrl.config(config) |
Chetan Gaonker | 4a25e2b | 2016-03-04 14:45:15 -0800 | [diff] [blame] | 129 | if status is False: |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 130 | log_test.info('JSON request returned status %d' %code) |
Chetan Gaonker | 4a25e2b | 2016-03-04 14:45:15 -0800 | [diff] [blame] | 131 | assert_equal(status, True) |
| 132 | time.sleep(2) |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 133 | |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 134 | def onos_ssm_table_load(self, groups, src_list = ['1.2.3.4'],flag = False): |
A R Karthick | 38d5df4 | 2017-07-10 13:33:26 -0700 | [diff] [blame] | 135 | return |
A.R Karthick | 401a1ed | 2017-05-18 11:08:27 -0700 | [diff] [blame] | 136 | ssm_dict = {'apps' : { 'org.opencord.igmp' : { 'ssmTranslate' : [] } } } |
| 137 | ssm_xlate_list = ssm_dict['apps']['org.opencord.igmp']['ssmTranslate'] |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 138 | if flag: #to maintain seperate group-source pair. |
| 139 | for i in range(len(groups)): |
| 140 | d = {} |
| 141 | d['source'] = src_list[i] or '0.0.0.0' |
| 142 | d['group'] = groups[i] |
| 143 | ssm_xlate_list.append(d) |
| 144 | else: |
| 145 | for g in groups: |
| 146 | for s in src_list: |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 147 | d = {} |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 148 | d['source'] = s or '0.0.0.0' |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 149 | d['group'] = g |
| 150 | ssm_xlate_list.append(d) |
Chetan Gaonker | 4a25e2b | 2016-03-04 14:45:15 -0800 | [diff] [blame] | 151 | self.onos_load_config(ssm_dict) |
Chetan Gaonker | 4eb1207 | 2016-03-28 15:04:15 -0700 | [diff] [blame] | 152 | cord_port_map = {} |
| 153 | for g in groups: |
| 154 | cord_port_map[g] = (self.PORT_TX_DEFAULT, self.PORT_RX_DEFAULT) |
| 155 | self.igmp_channel.cord_port_table_load(cord_port_map) |
Chetan Gaonker | 5a5204e | 2016-03-02 01:35:13 -0800 | [diff] [blame] | 156 | time.sleep(2) |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 157 | |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 158 | def mcast_ip_range(self,start_ip = '224.0.1.0', end_ip = '224.0.1.100'): |
| 159 | start = list(map(int, start_ip.split("."))) |
| 160 | end = list(map(int, end_ip.split("."))) |
| 161 | temp = start |
| 162 | ip_range = [] |
| 163 | ip_range.append(start_ip) |
| 164 | while temp != end: |
| 165 | start[3] += 1 |
| 166 | for i in (3, 2, 1): |
| 167 | if temp[i] == 255: |
| 168 | temp[i] = 0 |
| 169 | temp[i-1] += 1 |
| 170 | ip_range.append(".".join(map(str, temp))) |
| 171 | return ip_range |
| 172 | |
| 173 | def random_mcast_ip(self,start_ip = '224.0.1.0', end_ip = '224.0.1.100'): |
| 174 | start = list(map(int, start_ip.split("."))) |
| 175 | end = list(map(int, end_ip.split("."))) |
| 176 | temp = start |
| 177 | ip_range = [] |
| 178 | ip_range.append(start_ip) |
| 179 | while temp != end: |
| 180 | start[3] += 1 |
| 181 | for i in (3, 2, 1): |
| 182 | if temp[i] == 255: |
| 183 | temp[i] = 0 |
| 184 | temp[i-1] += 1 |
| 185 | ip_range.append(".".join(map(str, temp))) |
| 186 | return random.choice(ip_range) |
| 187 | |
| 188 | def source_ip_range(self,start_ip = '10.10.0.1', end_ip = '10.10.0.100'): |
| 189 | start = list(map(int, start_ip.split("."))) |
| 190 | end = list(map(int, end_ip.split("."))) |
| 191 | temp = start |
| 192 | ip_range = [] |
| 193 | ip_range.append(start_ip) |
| 194 | while temp != end: |
| 195 | start[3] += 1 |
| 196 | for i in (3, 2, 1): |
| 197 | if temp[i] == 255: |
| 198 | temp[i] = 0 |
| 199 | temp[i-1] += 1 |
| 200 | ip_range.append(".".join(map(str, temp))) |
| 201 | return ip_range |
| 202 | |
| 203 | def randomsourceip(self,start_ip = '10.10.0.1', end_ip = '10.10.0.100'): |
| 204 | start = list(map(int, start_ip.split("."))) |
| 205 | end = list(map(int, end_ip.split("."))) |
| 206 | temp = start |
| 207 | ip_range = [] |
| 208 | ip_range.append(start_ip) |
| 209 | while temp != end: |
| 210 | start[3] += 1 |
| 211 | for i in (3, 2, 1): |
| 212 | if temp[i] == 255: |
| 213 | temp[i] = 0 |
| 214 | temp[i-1] += 1 |
| 215 | ip_range.append(".".join(map(str, temp))) |
| 216 | return random.choice(ip_range) |
| 217 | |
A R Karthick | 2b93d6a | 2016-09-06 15:19:09 -0700 | [diff] [blame] | 218 | def get_igmp_intf(self): |
| 219 | inst = os.getenv('TEST_INSTANCE', None) |
| 220 | if not inst: |
| 221 | return 'veth0' |
| 222 | inst = int(inst) + 1 |
| 223 | if inst >= self.port_map['uplink']: |
| 224 | inst += 1 |
| 225 | if self.port_map.has_key(inst): |
| 226 | return self.port_map[inst] |
| 227 | return 'veth0' |
| 228 | |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 229 | def igmp_verify_join(self, igmpStateList): |
| 230 | sendState, recvState = igmpStateList |
Chetan Gaonker | 2547097 | 2016-02-26 08:52:15 -0800 | [diff] [blame] | 231 | ## check if the send is received for the groups |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 232 | for g in sendState.groups: |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 233 | tx_stats = sendState.group_map[g][0] |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 234 | tx = tx_stats.count |
Chetan Gaonker | 2547097 | 2016-02-26 08:52:15 -0800 | [diff] [blame] | 235 | assert_greater(tx, 0) |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 236 | rx_stats = recvState.group_map[g][1] |
| 237 | rx = rx_stats.count |
| 238 | assert_greater(rx, 0) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 239 | log_test.info('Receive stats %s for group %s' %(rx_stats, g)) |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 240 | |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 241 | log_test.info('IGMP test verification success') |
Chetan Gaonker | 2547097 | 2016-02-26 08:52:15 -0800 | [diff] [blame] | 242 | |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 243 | def igmp_verify_leave(self, igmpStateList, leave_groups): |
| 244 | sendState, recvState = igmpStateList[0], igmpStateList[1] |
| 245 | ## check if the send is received for the groups |
| 246 | for g in sendState.groups: |
| 247 | tx_stats = sendState.group_map[g][0] |
| 248 | rx_stats = recvState.group_map[g][1] |
| 249 | tx = tx_stats.count |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 250 | rx = rx_stats.count |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 251 | assert_greater(tx, 0) |
| 252 | if g not in leave_groups: |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 253 | log_test.info('Received %d packets for group %s' %(rx, g)) |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 254 | for g in leave_groups: |
| 255 | rx = recvState.group_map[g][1].count |
| 256 | assert_equal(rx, 0) |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 257 | |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 258 | log_test.info('IGMP test verification success') |
Chetan Gaonker | 2547097 | 2016-02-26 08:52:15 -0800 | [diff] [blame] | 259 | |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 260 | def mcast_traffic_timer(self): |
A R Karthick | bd69867 | 2017-07-13 16:48:24 -0700 | [diff] [blame] | 261 | log_test.info('MCAST traffic timer expiry') |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 262 | self.mcastTraffic.stopReceives() |
| 263 | |
| 264 | def send_mcast_cb(self, send_state): |
| 265 | for g in send_state.groups: |
| 266 | send_state.update(g, tx = 1) |
Chetan Gaonker | 2547097 | 2016-02-26 08:52:15 -0800 | [diff] [blame] | 267 | return 0 |
| 268 | |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 269 | ##Runs in the context of twisted reactor thread |
A R Karthick | bd69867 | 2017-07-13 16:48:24 -0700 | [diff] [blame] | 270 | def igmp_recv(self, igmpState): |
| 271 | s = socket_select([self.recv_socket], [], [], 1.0) |
| 272 | if self.recv_socket in s[0]: |
| 273 | p = self.recv_socket.recv() |
| 274 | try: |
| 275 | send_time = float(p.payload.load) |
| 276 | recv_time = monotonic.monotonic() |
| 277 | except: |
| 278 | log_test.info('Unexpected Payload received: %s' %p.payload.load) |
| 279 | return 0 |
| 280 | #log_test.info( 'Recv in %.6f secs' %(recv_time - send_time)) |
| 281 | igmpState.update(p.dst, rx = 1, t = recv_time - send_time) |
Chetan Gaonker | 2547097 | 2016-02-26 08:52:15 -0800 | [diff] [blame] | 282 | return 0 |
| 283 | |
A R Karthick | 2b93d6a | 2016-09-06 15:19:09 -0700 | [diff] [blame] | 284 | def send_igmp_join(self, groups, src_list = ['1.2.3.4'], record_type=IGMP_V3_GR_TYPE_INCLUDE, |
| 285 | ip_pkt = None, iface = 'veth0', ssm_load = False, delay = 1): |
| 286 | if ssm_load is True: |
| 287 | self.onos_ssm_table_load(groups, src_list) |
Chetan Gaonker | 5a5204e | 2016-03-02 01:35:13 -0800 | [diff] [blame] | 288 | igmp = IGMPv3(type = IGMP_TYPE_V3_MEMBERSHIP_REPORT, max_resp_code=30, |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 289 | gaddr=self.IP_DST) |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 290 | for g in groups: |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 291 | gr = IGMPv3gr(rtype= record_type, mcaddr=g) |
Chetan Gaonker | 5a5204e | 2016-03-02 01:35:13 -0800 | [diff] [blame] | 292 | gr.sources = src_list |
| 293 | igmp.grps.append(gr) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 294 | if ip_pkt is None: |
| 295 | ip_pkt = self.igmp_eth/self.igmp_ip |
| 296 | pkt = ip_pkt/igmp |
Chetan Gaonker | 5a5204e | 2016-03-02 01:35:13 -0800 | [diff] [blame] | 297 | IGMPv3.fixup(pkt) |
| 298 | sendp(pkt, iface=iface) |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 299 | if delay != 0: |
| 300 | time.sleep(delay) |
| 301 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 302 | def send_igmp_join_recvQuery(self, groups, rec_queryCount = None, src_list = ['1.2.3.4'], ip_pkt = None, iface = 'veth0', delay = 2): |
| 303 | self.onos_ssm_table_load(groups, src_list) |
| 304 | igmp = IGMPv3(type = IGMP_TYPE_V3_MEMBERSHIP_REPORT, max_resp_code=30, |
| 305 | gaddr=self.IP_DST) |
| 306 | for g in groups: |
Chetan Gaonker | 38737f8 | 2016-05-11 17:44:17 -0700 | [diff] [blame] | 307 | gr = IGMPv3gr(rtype=IGMP_V3_GR_TYPE_INCLUDE, mcaddr=g) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 308 | gr.sources = src_list |
| 309 | gr.sources = src_list |
| 310 | igmp.grps.append(gr) |
| 311 | if ip_pkt is None: |
| 312 | ip_pkt = self.igmp_eth/self.igmp_ip |
| 313 | pkt = ip_pkt/igmp |
| 314 | IGMPv3.fixup(pkt) |
| 315 | if rec_queryCount == None: |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 316 | log_test.info('Sending IGMP join for group %s and waiting for one query packet and printing the packet' %groups) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 317 | resp = srp1(pkt, iface=iface) |
| 318 | else: |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 319 | log_test.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] | 320 | resp = srp1(pkt, iface=iface) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 321 | # resp = srp1(pkt, iface=iface) if rec_queryCount else srp3(pkt, iface=iface) |
| 322 | resp[0].summary() |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 323 | log_test.info('Sent IGMP join for group %s and received a query packet and printing packet' %groups) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 324 | if delay != 0: |
| 325 | time.sleep(delay) |
| 326 | |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 327 | def send_igmp_leave(self, groups, src_list = ['1.2.3.4'], ip_pkt = None, iface = 'veth0', delay = 2): |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 328 | log_test.info('entering into igmp leave function') |
Chetan Gaonker | 5a5204e | 2016-03-02 01:35:13 -0800 | [diff] [blame] | 329 | igmp = IGMPv3(type = IGMP_TYPE_V3_MEMBERSHIP_REPORT, max_resp_code=30, |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 330 | gaddr=self.IP_DST) |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 331 | for g in groups: |
Chetan Gaonker | 38737f8 | 2016-05-11 17:44:17 -0700 | [diff] [blame] | 332 | gr = IGMPv3gr(rtype=IGMP_V3_GR_TYPE_EXCLUDE, mcaddr=g) |
Chetan Gaonker | 5a5204e | 2016-03-02 01:35:13 -0800 | [diff] [blame] | 333 | gr.sources = src_list |
| 334 | igmp.grps.append(gr) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 335 | if ip_pkt is None: |
| 336 | ip_pkt = self.igmp_eth/self.igmp_ip |
| 337 | pkt = ip_pkt/igmp |
Chetan Gaonker | 5a5204e | 2016-03-02 01:35:13 -0800 | [diff] [blame] | 338 | IGMPv3.fixup(pkt) |
| 339 | sendp(pkt, iface = iface) |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 340 | if delay != 0: |
| 341 | time.sleep(delay) |
Chetan Gaonker | 2547097 | 2016-02-26 08:52:15 -0800 | [diff] [blame] | 342 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 343 | def send_igmp_leave_listening_group_specific_query(self, groups, src_list = ['1.2.3.4'], ip_pkt = None, iface = 'veth0', delay = 2): |
| 344 | igmp = IGMPv3(type = IGMP_TYPE_V3_MEMBERSHIP_REPORT, max_resp_code=30, |
| 345 | gaddr=self.IP_DST) |
| 346 | for g in groups: |
Chetan Gaonker | 38737f8 | 2016-05-11 17:44:17 -0700 | [diff] [blame] | 347 | gr = IGMPv3gr(rtype=IGMP_V3_GR_TYPE_EXCLUDE, mcaddr=g) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 348 | gr.sources = src_list |
| 349 | igmp.grps.append(gr) |
| 350 | if ip_pkt is None: |
| 351 | ip_pkt = self.igmp_eth/self.igmp_ip |
| 352 | pkt = ip_pkt/igmp |
| 353 | IGMPv3.fixup(pkt) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 354 | log_test.info('Sending IGMP leave for group %s and waiting for one group specific query packet and printing the packet' %groups) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 355 | resp = srp1(pkt, iface=iface) |
| 356 | resp[0].summary() |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 357 | log_test.info('Sent IGMP leave for group %s and received a group specific query packet and printing packet' %groups) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 358 | if delay != 0: |
| 359 | time.sleep(delay) |
| 360 | |
A R Karthick | a93fdee | 2017-07-14 17:27:35 -0700 | [diff] [blame] | 361 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10) |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 362 | def test_igmp_join_verify_traffic(self): |
Chetan Gaonker | ddfdc52 | 2017-04-04 01:15:04 +0000 | [diff] [blame] | 363 | groups = [self.MGROUP1, self.MGROUP1] |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 364 | self.onos_ssm_table_load(groups) |
Chetan Gaonker | 2547097 | 2016-02-26 08:52:15 -0800 | [diff] [blame] | 365 | df = defer.Deferred() |
| 366 | igmpState = IGMPTestState(groups = groups, df = df) |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 367 | igmpStateRecv = IGMPTestState(groups = groups, df = df) |
| 368 | igmpStateList = (igmpState, igmpStateRecv) |
A R Karthick | 38d5df4 | 2017-07-10 13:33:26 -0700 | [diff] [blame] | 369 | tx_intf = self.port_map[self.PORT_TX_DEFAULT] |
| 370 | rx_intf = self.port_map[self.PORT_RX_DEFAULT] |
| 371 | mcastTraffic = McastTraffic(groups, iface= tx_intf, cb = self.send_mcast_cb, arg = igmpState) |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 372 | self.df = df |
| 373 | self.mcastTraffic = mcastTraffic |
A R Karthick | 38d5df4 | 2017-07-10 13:33:26 -0700 | [diff] [blame] | 374 | self.recv_socket = L3PacketSocket(iface = rx_intf, type = ETH_P_IP) |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 375 | |
| 376 | def igmp_srp_task(stateList): |
| 377 | igmpSendState, igmpRecvState = stateList |
| 378 | if not mcastTraffic.isRecvStopped(): |
ChetanGaonker | b99538a | 2016-12-02 13:53:35 -0800 | [diff] [blame] | 379 | self.igmp_recv(igmpRecvState) |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 380 | reactor.callLater(0, igmp_srp_task, stateList) |
| 381 | else: |
| 382 | self.mcastTraffic.stop() |
A R Karthick | bd69867 | 2017-07-13 16:48:24 -0700 | [diff] [blame] | 383 | #log_test.info('Sending IGMP leave for groups: %s' %groups) |
| 384 | self.send_igmp_leave(groups, iface = rx_intf, delay = 2) |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 385 | self.recv_socket.close() |
| 386 | self.igmp_verify_join(stateList) |
| 387 | self.df.callback(0) |
| 388 | |
A R Karthick | 38d5df4 | 2017-07-10 13:33:26 -0700 | [diff] [blame] | 389 | self.send_igmp_join(groups, iface = rx_intf) |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 390 | mcastTraffic.start() |
| 391 | self.test_timer = reactor.callLater(self.MCAST_TRAFFIC_TIMEOUT, self.mcast_traffic_timer) |
| 392 | reactor.callLater(0, igmp_srp_task, igmpStateList) |
Chetan Gaonker | 2547097 | 2016-02-26 08:52:15 -0800 | [diff] [blame] | 393 | return df |
| 394 | |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 395 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+40) |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 396 | def test_igmp_leave_verify_traffic(self): |
A R Karthick | 38d5df4 | 2017-07-10 13:33:26 -0700 | [diff] [blame] | 397 | groups = [self.MGROUP1] |
| 398 | leave_groups = [self.MGROUP1] |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 399 | self.onos_ssm_table_load(groups) |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 400 | df = defer.Deferred() |
| 401 | igmpState = IGMPTestState(groups = groups, df = df) |
ChetanGaonker | b99538a | 2016-12-02 13:53:35 -0800 | [diff] [blame] | 402 | IGMPTestState(groups = groups, df = df) |
A R Karthick | 38d5df4 | 2017-07-10 13:33:26 -0700 | [diff] [blame] | 403 | tx_intf = self.port_map[self.PORT_TX_DEFAULT] |
| 404 | rx_intf = self.port_map[self.PORT_RX_DEFAULT] |
| 405 | mcastTraffic = McastTraffic(groups, iface= tx_intf, cb = self.send_mcast_cb, |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 406 | arg = igmpState) |
| 407 | self.df = df |
| 408 | self.mcastTraffic = mcastTraffic |
A R Karthick | 38d5df4 | 2017-07-10 13:33:26 -0700 | [diff] [blame] | 409 | self.recv_socket = L3PacketSocket(iface = rx_intf, type = ETH_P_IP) |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 410 | |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 411 | mcastTraffic.start() |
A R Karthick | 38d5df4 | 2017-07-10 13:33:26 -0700 | [diff] [blame] | 412 | self.send_igmp_join(groups, iface = rx_intf) |
| 413 | time.sleep(5) |
| 414 | self.send_igmp_leave(leave_groups, delay = 3, iface = rx_intf) |
| 415 | time.sleep(10) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 416 | join_state = IGMPTestState(groups = leave_groups) |
A R Karthick | 38d5df4 | 2017-07-10 13:33:26 -0700 | [diff] [blame] | 417 | status = self.igmp_not_recv_task(rx_intf, leave_groups, join_state) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 418 | log_test.info('verified status for igmp recv task %s'%status) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 419 | assert status == 1 , 'EXPECTED RESULT' |
| 420 | self.df.callback(0) |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 421 | return df |
| 422 | |
| 423 | @deferred(timeout=100) |
| 424 | def test_igmp_leave_join_loop(self): |
| 425 | self.groups = ['226.0.1.1', '227.0.0.1', '228.0.0.1', '229.0.0.1', '230.0.0.1' ] |
| 426 | self.src_list = ['3.4.5.6', '7.8.9.10'] |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 427 | self.onos_ssm_table_load(self.groups,src_list=self.src_list) |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 428 | df = defer.Deferred() |
| 429 | self.df = df |
| 430 | self.iterations = 0 |
| 431 | self.num_groups = len(self.groups) |
| 432 | self.MAX_TEST_ITERATIONS = 10 |
A R Karthick | 38d5df4 | 2017-07-10 13:33:26 -0700 | [diff] [blame] | 433 | rx_intf = self.port_map[self.PORT_RX_DEFAULT] |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 434 | |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 435 | def igmp_srp_task(v): |
| 436 | if self.iterations < self.MAX_TEST_ITERATIONS: |
| 437 | if v == 1: |
| 438 | ##join test |
| 439 | self.num_groups = random.randint(0, len(self.groups)) |
| 440 | self.send_igmp_join(self.groups[:self.num_groups], |
| 441 | src_list = self.src_list, |
A R Karthick | 38d5df4 | 2017-07-10 13:33:26 -0700 | [diff] [blame] | 442 | iface = rx_intf, delay = 0) |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 443 | else: |
| 444 | self.send_igmp_leave(self.groups[:self.num_groups], |
| 445 | src_list = self.src_list, |
A R Karthick | 38d5df4 | 2017-07-10 13:33:26 -0700 | [diff] [blame] | 446 | iface = rx_intf, delay = 0) |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 447 | self.iterations += 1 |
| 448 | v ^= 1 |
| 449 | reactor.callLater(1.0 + 0.5*self.num_groups, |
| 450 | igmp_srp_task, v) |
| 451 | else: |
| 452 | self.df.callback(0) |
| 453 | |
| 454 | reactor.callLater(0, igmp_srp_task, 1) |
| 455 | return df |
| 456 | |
| 457 | 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] | 458 | #self.onos_ssm_table_load(groups, src_list) |
Chetan Gaonker | 5a5204e | 2016-03-02 01:35:13 -0800 | [diff] [blame] | 459 | igmp = IGMPv3(type = IGMP_TYPE_V3_MEMBERSHIP_REPORT, max_resp_code=30, |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 460 | gaddr=self.IP_DST) |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 461 | for g in groups: |
Chetan Gaonker | 38737f8 | 2016-05-11 17:44:17 -0700 | [diff] [blame] | 462 | gr = IGMPv3gr(rtype = IGMP_V3_GR_TYPE_INCLUDE, mcaddr = g) |
Chetan Gaonker | 5a5204e | 2016-03-02 01:35:13 -0800 | [diff] [blame] | 463 | gr.sources = src_list |
| 464 | igmp.grps.append(gr) |
| 465 | |
| 466 | for g in groups: |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 467 | state.group_map[g][0].update(1, t = monotonic.monotonic()) |
Chetan Gaonker | 5a5204e | 2016-03-02 01:35:13 -0800 | [diff] [blame] | 468 | |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 469 | pkt = self.igmp_eth/self.igmp_ip/igmp |
Chetan Gaonker | 5a5204e | 2016-03-02 01:35:13 -0800 | [diff] [blame] | 470 | IGMPv3.fixup(pkt) |
| 471 | sendp(pkt, iface=intf) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 472 | log_test.debug('Returning from join task') |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 473 | |
| 474 | def igmp_recv_task(self, intf, groups, join_state): |
| 475 | recv_socket = L3PacketSocket(iface = intf, type = ETH_P_IP) |
| 476 | group_map = {} |
| 477 | for g in groups: |
| 478 | group_map[g] = [0,0] |
| 479 | |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 480 | log_test.info('Verifying join interface should receive multicast data') |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 481 | while True: |
| 482 | p = recv_socket.recv() |
| 483 | if p.dst in groups and group_map[p.dst][0] == 0: |
| 484 | group_map[p.dst][0] += 1 |
| 485 | group_map[p.dst][1] = monotonic.monotonic() |
| 486 | c = 0 |
| 487 | for g in groups: |
| 488 | c += group_map[g][0] |
| 489 | if c == len(groups): |
| 490 | break |
| 491 | for g in groups: |
| 492 | join_start = join_state.group_map[g][0].start |
| 493 | recv_time = group_map[g][1] * 1000000 |
| 494 | delta = (recv_time - join_start) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 495 | log_test.info('Join for group %s received in %.3f usecs' % |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 496 | (g, delta)) |
| 497 | |
| 498 | recv_socket.close() |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 499 | log_test.debug('Returning from recv task') |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 500 | |
| 501 | def igmp_not_recv_task(self, intf, groups, join_state): |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 502 | log_test.info('Entering igmp not recv task loop') |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 503 | recv_socket = L2Socket(iface = intf, type = ETH_P_IP) |
| 504 | group_map = {} |
| 505 | for g in groups: |
| 506 | group_map[g] = [0,0] |
| 507 | |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 508 | log_test.info('Verifying join interface, should not receive any multicast data') |
Chetan Gaonker | 7791bda | 2016-05-12 17:36:52 -0700 | [diff] [blame] | 509 | self.NEGATIVE_TRAFFIC_STATUS = 1 |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 510 | def igmp_recv_cb(pkt): |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 511 | log_test.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] | 512 | self.NEGATIVE_TRAFFIC_STATUS = 2 |
Chetan Gaonker | 38737f8 | 2016-05-11 17:44:17 -0700 | [diff] [blame] | 513 | 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] | 514 | timeout = 3, opened_socket = recv_socket) |
| 515 | recv_socket.close() |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 516 | return self.NEGATIVE_TRAFFIC_STATUS |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 517 | |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 518 | def group_latency_check(self, groups): |
| 519 | tasks = [] |
| 520 | self.send_igmp_leave(groups = groups) |
| 521 | join_state = IGMPTestState(groups = groups) |
| 522 | tasks.append(threading.Thread(target=self.igmp_join_task, args = ('veth0', groups, join_state,))) |
| 523 | traffic_state = IGMPTestState(groups = groups) |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 524 | mcast_traffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb, |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 525 | arg = traffic_state) |
| 526 | mcast_traffic.start() |
| 527 | tasks.append(threading.Thread(target=self.igmp_recv_task, args = ('veth0', groups, join_state))) |
| 528 | for t in tasks: |
| 529 | t.start() |
| 530 | for t in tasks: |
| 531 | t.join() |
| 532 | |
| 533 | mcast_traffic.stop() |
| 534 | self.send_igmp_leave(groups = groups) |
| 535 | return |
| 536 | |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 537 | @deferred(timeout=IGMP_QUERY_TIMEOUT + 10) |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 538 | def test_igmp_1group_join_latency(self): |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 539 | groups = ['239.0.1.1'] |
| 540 | df = defer.Deferred() |
| 541 | def igmp_1group_join_latency(): |
| 542 | self.group_latency_check(groups) |
| 543 | df.callback(0) |
| 544 | reactor.callLater(0, igmp_1group_join_latency) |
| 545 | return df |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 546 | |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 547 | @deferred(timeout=IGMP_QUERY_TIMEOUT + 10) |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 548 | def test_igmp_2group_join_latency(self): |
Chetan Gaonker | ddfdc52 | 2017-04-04 01:15:04 +0000 | [diff] [blame] | 549 | groups = [self.MGROUP1, self.MGROUP1] |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 550 | df = defer.Deferred() |
| 551 | def igmp_2group_join_latency(): |
| 552 | self.group_latency_check(groups) |
| 553 | df.callback(0) |
| 554 | reactor.callLater(0, igmp_2group_join_latency) |
| 555 | return df |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 556 | |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 557 | @deferred(timeout=IGMP_QUERY_TIMEOUT + 10) |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 558 | def test_igmp_Ngroup_join_latency(self): |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 559 | groups = ['239.0.1.1', '240.0.1.1', '241.0.1.1', '242.0.1.1'] |
| 560 | df = defer.Deferred() |
| 561 | def igmp_Ngroup_join_latency(): |
| 562 | self.group_latency_check(groups) |
| 563 | df.callback(0) |
| 564 | reactor.callLater(0, igmp_Ngroup_join_latency) |
| 565 | return df |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 566 | |
A R Karthick | 2b93d6a | 2016-09-06 15:19:09 -0700 | [diff] [blame] | 567 | def test_igmp_join_rover_all(self): |
Chetan Gaonker | 1f7c3f8 | 2016-03-08 12:17:37 -0800 | [diff] [blame] | 568 | s = (224 << 24) | 1 |
| 569 | #e = (225 << 24) | (255 << 16) | (255 << 16) | 255 |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 570 | e = (224 << 24) | 10 |
Chetan Gaonker | 1f7c3f8 | 2016-03-08 12:17:37 -0800 | [diff] [blame] | 571 | for i in xrange(s, e+1): |
| 572 | if i&0xff: |
| 573 | ip = '%d.%d.%d.%d'%((i>>24)&0xff, (i>>16)&0xff, (i>>8)&0xff, i&0xff) |
| 574 | self.send_igmp_join([ip], delay = 0) |
| 575 | |
A R Karthick | 2b93d6a | 2016-09-06 15:19:09 -0700 | [diff] [blame] | 576 | @deferred(timeout=ROVER_TEST_TIMEOUT) |
| 577 | def test_igmp_join_rover(self): |
| 578 | df = defer.Deferred() |
| 579 | iface = self.get_igmp_intf() |
| 580 | self.df = df |
| 581 | self.count = 0 |
| 582 | self.timeout = 0 |
| 583 | self.complete = False |
| 584 | def igmp_join_timer(): |
| 585 | self.timeout += self.ROVER_JOIN_TIMEOUT |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 586 | log_test.info('IGMP joins sent: %d' %self.count) |
A R Karthick | 2b93d6a | 2016-09-06 15:19:09 -0700 | [diff] [blame] | 587 | if self.timeout >= self.ROVER_TIMEOUT: |
| 588 | self.complete = True |
| 589 | reactor.callLater(self.ROVER_JOIN_TIMEOUT, igmp_join_timer) |
| 590 | |
| 591 | reactor.callLater(self.ROVER_JOIN_TIMEOUT, igmp_join_timer) |
ChetanGaonker | b99538a | 2016-12-02 13:53:35 -0800 | [diff] [blame] | 592 | self.start_channel = (224 << 24) | 1 |
| 593 | self.end_channel = (224 << 24) | 200 #(225 << 24) | (255 << 16) | (255 << 16) | 255 |
A R Karthick | 2b93d6a | 2016-09-06 15:19:09 -0700 | [diff] [blame] | 594 | self.current_channel = self.start_channel |
| 595 | def igmp_join_rover(self): |
| 596 | #e = (224 << 24) | 10 |
| 597 | chan = self.current_channel |
| 598 | self.current_channel += 1 |
| 599 | if self.current_channel >= self.end_channel: |
| 600 | chan = self.current_channel = self.start_channel |
| 601 | if chan&0xff: |
| 602 | ip = '%d.%d.%d.%d'%((chan>>24)&0xff, (chan>>16)&0xff, (chan>>8)&0xff, chan&0xff) |
| 603 | self.send_igmp_join([ip], delay = 0, ssm_load = False, iface = iface) |
| 604 | self.count += 1 |
| 605 | if self.complete == True: |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 606 | log_test.info('%d IGMP joins sent in %d seconds over %s' %(self.count, self.timeout, iface)) |
A R Karthick | 2b93d6a | 2016-09-06 15:19:09 -0700 | [diff] [blame] | 607 | self.df.callback(0) |
| 608 | else: |
| 609 | reactor.callLater(0, igmp_join_rover, self) |
| 610 | reactor.callLater(0, igmp_join_rover, self) |
| 611 | return df |
| 612 | |
Chetan Gaonker | 1f7c3f8 | 2016-03-08 12:17:37 -0800 | [diff] [blame] | 613 | @deferred(timeout=IGMP_QUERY_TIMEOUT + 10) |
| 614 | def test_igmp_query(self): |
| 615 | groups = ['224.0.0.1'] ##igmp query group |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 616 | self.onos_ssm_table_load(groups) |
Chetan Gaonker | 1f7c3f8 | 2016-03-08 12:17:37 -0800 | [diff] [blame] | 617 | df = defer.Deferred() |
| 618 | self.df = df |
| 619 | self.recv_socket = L2Socket(iface = 'veth0', type = ETH_P_IP) |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 620 | |
Chetan Gaonker | 1f7c3f8 | 2016-03-08 12:17:37 -0800 | [diff] [blame] | 621 | def igmp_query_timeout(): |
Chetan Gaonker | 1f7c3f8 | 2016-03-08 12:17:37 -0800 | [diff] [blame] | 622 | def igmp_query_cb(pkt): |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 623 | log_test.info('received igmp query packet is %s'%pkt.show()) |
| 624 | log_test.info('Got IGMP query packet from %s for %s' %(pkt[IP].src, pkt[IP].dst)) |
Chetan Gaonker | bd4390f | 2016-03-09 18:56:52 -0800 | [diff] [blame] | 625 | assert_equal(pkt[IP].dst, '224.0.0.1') |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 626 | 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] | 627 | opened_socket = self.recv_socket) |
Chetan Gaonker | 1f7c3f8 | 2016-03-08 12:17:37 -0800 | [diff] [blame] | 628 | self.recv_socket.close() |
| 629 | self.df.callback(0) |
| 630 | |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 631 | #self.send_igmp_join(groups) |
Chetan Gaonker | 1f7c3f8 | 2016-03-08 12:17:37 -0800 | [diff] [blame] | 632 | self.test_timer = reactor.callLater(self.IGMP_QUERY_TIMEOUT, igmp_query_timeout) |
| 633 | return df |
| 634 | |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 635 | def igmp_send_joins_different_groups_srclist(self, groups, sources, intf = V_INF1, delay = 2, ip_src = None): |
| 636 | g1 = groups[0] |
| 637 | g2 = groups[1] |
| 638 | sourcelist1 = sources[0] |
| 639 | sourcelist2 = sources[1] |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 640 | eth = Ether(dst = self.IGMP_DST_MAC,type = ETH_P_IP) |
| 641 | ip = IP(dst = self.IP_DST) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 642 | log_test.info('Sending join message for the group %s' %g1) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 643 | self.send_igmp_join((g1,), src_list = sourcelist1, ip_pkt = eth/ip, iface = intf, delay = 2) |
| 644 | 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] | 645 | ip = IP(dst = g2) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 646 | log_test.info('Sending join message for group %s' %g2) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 647 | self.send_igmp_join((g2,), src_list = sourcelist2, ip_pkt = eth/ip, iface = intf, delay = 2) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 648 | log_test.info('Done with igmp_send_joins_different_groups_srclist') |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 649 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 650 | 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): |
| 651 | g1 = groups[0] |
| 652 | g2 = groups[1] |
| 653 | sourcelist1 = sources[0] |
| 654 | sourcelist2 = sources[1] |
| 655 | eth = Ether(dst = self.MMACGROUP1, src = self.IGMP_SRC_MAC, type = ETH_P_IP) |
| 656 | src_ip = ip_src or self.IP_SRC |
| 657 | ip = IP(dst = g1, src = src_ip) |
| 658 | if query_group1 is 'group1': |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 659 | log_test.info('Sending join message for the group %s and waiting for a query packet on join interface' %g1) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 660 | 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] | 661 | else: |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 662 | log_test.info('Sending join message for the group %s' %g1) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 663 | self.send_igmp_join((g1,), src_list = sourcelist1, ip_pkt = eth/ip, iface = intf, delay = 2) |
| 664 | eth = Ether(dst = self.MMACGROUP2, src = self.IGMP_SRC_MAC, type = ETH_P_IP) |
| 665 | ip = IP(dst = g2, src = src_ip) |
| 666 | if query_group2 is 'group2': |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 667 | log_test.info('Sending join message for the group %s and waiting for a query packet on join interface' %g2) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 668 | 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] | 669 | else: |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 670 | log_test.info('Sending join message for group %s' %g2) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 671 | self.send_igmp_join((g2,), src_list = sourcelist2, ip_pkt = eth/ip, iface = intf, delay = 2) |
| 672 | |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 673 | def igmp_joins_leave(self,groups,src_list,again_join = False, df = None): |
| 674 | groups1 = [groups[0]] |
| 675 | groups2 = [groups[1]] |
| 676 | src1 = [src_list[0]] |
| 677 | src2 = [src_list[1]] |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 678 | self.igmp_send_joins_different_groups_srclist(groups1 + groups2, |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 679 | (src1, src2), intf = self.V_INF1, delay = 2) |
| 680 | |
| 681 | src_ip = src1[0] |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 682 | if df is None: |
| 683 | df = defer.Deferred() |
| 684 | igmpState1 = IGMPTestState(groups = groups1, df = df) |
ChetanGaonker | b99538a | 2016-12-02 13:53:35 -0800 | [diff] [blame] | 685 | IGMPTestState(groups = groups1, df = df) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 686 | |
| 687 | igmpState2 = IGMPTestState(groups = groups2, df = df) |
ChetanGaonker | b99538a | 2016-12-02 13:53:35 -0800 | [diff] [blame] | 688 | IGMPTestState(groups = groups2, df = df) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 689 | dst_mac = self.iptomac(groups1[0]) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 690 | mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac, |
| 691 | src_ip = src_ip, cb = self.send_mcast_cb, |
| 692 | arg = igmpState1) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 693 | src_ip = src2[0] |
| 694 | dst_mac = self.iptomac(groups1[0]) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 695 | mcastTraffic2 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac, |
| 696 | src_ip = src_ip, cb = self.send_mcast_cb, |
| 697 | arg = igmpState2) |
| 698 | mcastTraffic1.start() |
| 699 | mcastTraffic2.start() |
| 700 | join_state1 = IGMPTestState(groups = groups1) |
| 701 | join_state2 = IGMPTestState(groups = groups2) |
ChetanGaonker | b99538a | 2016-12-02 13:53:35 -0800 | [diff] [blame] | 702 | self.igmp_recv_task(self.V_INF1, groups1, join_state1) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 703 | log_test.info('Interface is receiving multicast groups %s' %groups1) |
ChetanGaonker | b99538a | 2016-12-02 13:53:35 -0800 | [diff] [blame] | 704 | self.igmp_recv_task(self.V_INF1, groups2, join_state2) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 705 | log_test.info('Interface is receiving multicast groups %s' %groups2) |
| 706 | log_test.info('Interface is sending leave message for groups %s now' %groups2) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 707 | self.send_igmp_leave(groups = groups2, src_list = src2, iface = self.V_INF1, delay = 2) |
ChetanGaonker | b99538a | 2016-12-02 13:53:35 -0800 | [diff] [blame] | 708 | self.igmp_recv_task(self.V_INF1, groups1, join_state1) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 709 | target4 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state2) |
| 710 | assert target4 == 1, 'EXPECTED FAILURE' |
| 711 | if again_join: |
| 712 | dst_mac = '01:00:5e:02:02:03' |
| 713 | ip_dst = '239.2.2.3' |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 714 | eth = Ether(dst = dst_mac, type = ETH_P_IP) |
| 715 | ip = IP(dst = ip_dst) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 716 | log_test.info('Interface sending join message again for the groups %s' %groups2) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 717 | self.send_igmp_join(groups2, src_list = [src_ip], ip_pkt = eth/ip, iface = self.V_INF1, delay = 2) |
ChetanGaonker | b99538a | 2016-12-02 13:53:35 -0800 | [diff] [blame] | 718 | self.igmp_recv_task(self.V_INF1, groups2, join_state2) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 719 | log_test.info('Interface is receiving multicast groups %s again' %groups2) |
ChetanGaonker | b99538a | 2016-12-02 13:53:35 -0800 | [diff] [blame] | 720 | self.igmp_recv_task(self.V_INF1, groups1, join_state1) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 721 | log_test.info('Interface is still receiving from multicast groups %s' %groups1) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 722 | else: |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 723 | log_test.info('Ended test case') |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 724 | mcastTraffic1.stop() |
| 725 | mcastTraffic2.stop() |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 726 | |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 727 | |
| 728 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 729 | def test_igmp_2joins_1leave(self): |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 730 | df = defer.Deferred() |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 731 | def igmp_2joins_1leave(): |
| 732 | groups = ['234.2.3.4','236.8.7.9'] |
| 733 | src_list = ['2.3.4.5','5.4.3.2'] |
| 734 | self.onos_ssm_table_load(groups,src_list = src_list) |
| 735 | self.igmp_joins_leave(groups,src_list,again_join = False, df = df) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 736 | df.callback(0) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 737 | reactor.callLater(0, igmp_2joins_1leave) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 738 | return df |
| 739 | |
| 740 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+25) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 741 | def test_igmp_2joins_1leave_and_join_again(self): |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 742 | df = defer.Deferred() |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 743 | def igmp_2joins_1leave_join_again(): |
| 744 | groups = ['234.2.3.4','236.8.7.9'] |
| 745 | src_list = ['2.3.4.5','5.4.3.2'] |
| 746 | self.onos_ssm_table_load(groups,src_list = src_list) |
| 747 | self.igmp_joins_leave(groups,src_list,again_join = True, df = df) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 748 | df.callback(0) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 749 | reactor.callLater(0, igmp_2joins_1leave_join_again) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 750 | return df |
| 751 | |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 752 | def igmp_not_in_src_list(self, df = None): |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 753 | groups1 = (self.MGROUP1,) |
| 754 | groups2 = (self.MGROUP2,) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 755 | 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] | 756 | self.igmp_send_joins_different_groups_srclist(groups1 + groups2, |
| 757 | (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']), |
| 758 | intf = self.V_INF1, delay = 2) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 759 | src_ip = '6.6.6.6' |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 760 | dst_mac = self.iptomac(groups1[0]) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 761 | if df is None: |
| 762 | df = defer.Deferred() |
| 763 | igmpState1 = IGMPTestState(groups = groups1, df = df) |
ChetanGaonker | b99538a | 2016-12-02 13:53:35 -0800 | [diff] [blame] | 764 | IGMPTestState(groups = groups1, df = df) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 765 | mcastTraffic1 = McastTraffic(groups1, iface = 'veth2', dst_mac = dst_mac, |
| 766 | src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1) |
| 767 | mcastTraffic1.start() |
| 768 | join_state1 = IGMPTestState(groups = groups1) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 769 | log_test.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] | 770 | target1 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1) |
Chetan Gaonker | 7791bda | 2016-05-12 17:36:52 -0700 | [diff] [blame] | 771 | assert target1 == 2, 'EXPECTED FAILURE' |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 772 | log_test.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] | 773 | mcastTraffic1.stop() |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 774 | |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 775 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 776 | def test_igmp_not_in_src_list(self): |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 777 | df = defer.Deferred() |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 778 | def igmp_not_in_src_list(): |
| 779 | self.igmp_not_in_src_list(df = df) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 780 | df.callback(0) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 781 | reactor.callLater(0, igmp_not_in_src_list) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 782 | return df |
| 783 | |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 784 | def igmp_change_to_exclude_src_list(self, df = None): |
| 785 | groups1 = [self.random_mcast_ip()] |
| 786 | groups2 = [self.random_mcast_ip()] |
| 787 | 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] | 788 | self.igmp_send_joins_different_groups_srclist(groups1 + groups2, |
| 789 | (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']), |
| 790 | intf = self.V_INF1, delay = 2) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 791 | src_ip = '2.2.2.2' |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 792 | dst_mac=self.iptomac(groups1[0]) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 793 | if df is None: |
| 794 | df = defer.Deferred() |
| 795 | igmpState1 = IGMPTestState(groups = groups1, df = df) |
ChetanGaonker | b99538a | 2016-12-02 13:53:35 -0800 | [diff] [blame] | 796 | IGMPTestState(groups = groups1, df = df) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 797 | mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac, |
| 798 | src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1) |
| 799 | mcastTraffic1.start() |
| 800 | join_state1 = IGMPTestState(groups = groups1) |
ChetanGaonker | b99538a | 2016-12-02 13:53:35 -0800 | [diff] [blame] | 801 | self.igmp_recv_task(self.V_INF1, groups1, join_state1) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 802 | self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2'], iface = self.V_INF1, delay =2) |
| 803 | target2 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1) |
Chetan Gaonker | 7791bda | 2016-05-12 17:36:52 -0700 | [diff] [blame] | 804 | assert target2 == 2, 'EXPECTED FAILURE' |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 805 | log_test.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] | 806 | mcastTraffic1.stop() |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 807 | |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 808 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 809 | def test_igmp_change_to_exclude_src_list(self): |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 810 | df = defer.Deferred() |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 811 | def igmp_change_to_exclude_src_list(): |
| 812 | self.igmp_change_to_exclude_src_list(df = df) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 813 | df.callback(0) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 814 | reactor.callLater(0, igmp_change_to_exclude_src_list) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 815 | return df |
| 816 | |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 817 | def igmp_include_to_allow_src_list(self, df = None): |
| 818 | groups1 = [self.random_mcast_ip()] #(self.MGROUP1,) |
| 819 | self.onos_ssm_table_load(groups1,src_list = ['4.4.4.4','6.6.6.6']) |
| 820 | self.send_igmp_join(groups = groups1, src_list = ['4.4.4.4'],record_type = IGMP_V3_GR_TYPE_INCLUDE, |
| 821 | iface = self.V_INF1) |
| 822 | src_ip = '4.4.4.4' |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 823 | if df is None: |
| 824 | df = defer.Deferred() |
| 825 | igmpState1 = IGMPTestState(groups = groups1, df = df) |
ChetanGaonker | b99538a | 2016-12-02 13:53:35 -0800 | [diff] [blame] | 826 | IGMPTestState(groups = groups1, df = df) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 827 | mcastTraffic1 = McastTraffic(groups1, iface= 'veth2',src_ip = src_ip, |
| 828 | cb = self.send_mcast_cb, arg = igmpState1) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 829 | mcastTraffic1.start() |
| 830 | join_state1 = IGMPTestState(groups = groups1) |
ChetanGaonker | b99538a | 2016-12-02 13:53:35 -0800 | [diff] [blame] | 831 | self.igmp_recv_task(self.V_INF1, groups1, join_state1) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 832 | mcastTraffic1.stop() |
| 833 | mcastTraffic2 = McastTraffic(groups1, iface= 'veth2',src_ip = '6.6.6.6', |
| 834 | cb = self.send_mcast_cb, arg = igmpState1) |
| 835 | self.send_igmp_join(groups = groups1, src_list = ['6.6.6.6'],record_type = IGMP_V3_GR_TYPE_ALLOW_NEW, |
| 836 | iface = self.V_INF1) |
| 837 | mcastTraffic2.start() |
ChetanGaonker | b99538a | 2016-12-02 13:53:35 -0800 | [diff] [blame] | 838 | self.igmp_recv_task(self.V_INF1, groups1, join_state1) |
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_allow_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_allow_src_list(): |
| 845 | self.igmp_include_to_allow_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_allow_src_list) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 848 | return df |
| 849 | |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 850 | def igmp_include_to_block_src_list(self, df = None): |
| 851 | groups1 = [self.random_mcast_ip()] #groups1 = (self.MGROUP1,) |
| 852 | self.onos_ssm_table_load(groups1,src_list = ['4.4.4.4','6.6.6.6']) |
| 853 | self.send_igmp_join(groups = groups1, src_list = ['4.4.4.4','6.6.6.6'],record_type = IGMP_V3_GR_TYPE_INCLUDE, |
| 854 | iface = self.V_INF1) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 855 | if df is None: |
| 856 | df = defer.Deferred() |
| 857 | igmpState1 = IGMPTestState(groups = groups1, df = df) |
ChetanGaonker | b99538a | 2016-12-02 13:53:35 -0800 | [diff] [blame] | 858 | IGMPTestState(groups = groups1, df = df) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 859 | mcastTraffic1 = McastTraffic(groups1, iface= 'veth2',src_ip = '6.6.6.6', |
| 860 | cb = self.send_mcast_cb, arg = igmpState1) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 861 | mcastTraffic1.start() |
| 862 | join_state1 = IGMPTestState(groups = groups1) |
ChetanGaonker | b99538a | 2016-12-02 13:53:35 -0800 | [diff] [blame] | 863 | self.igmp_recv_task(self.V_INF1, groups1, join_state1) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 864 | mcastTraffic1.stop() |
| 865 | self.send_igmp_join(groups = groups1, src_list = ['6.6.6.6'],record_type = IGMP_V3_GR_TYPE_BLOCK_OLD, |
| 866 | iface = self.V_INF1) |
| 867 | mcastTraffic2 = McastTraffic(groups1, iface= 'veth2',src_ip = '6.6.6.6', |
| 868 | cb = self.send_mcast_cb, arg = igmpState1) |
| 869 | mcastTraffic2.start() |
| 870 | target1 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1) |
| 871 | assert target1 == 1, 'EXPECTED FAILURE' |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 872 | log_test.info('Interface is still receiving traffic from old multicast group %s even after we send block for source list' %groups1) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 873 | mcastTraffic2.stop() |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 874 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 875 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+30) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 876 | def test_igmp_include_to_block_src_list(self): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 877 | df = defer.Deferred() |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 878 | def igmp_include_to_block_src_list(): |
| 879 | self.igmp_include_to_block_src_list(df = df) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 880 | df.callback(0) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 881 | reactor.callLater(0, igmp_include_to_block_src_list) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 882 | return df |
| 883 | |
| 884 | |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 885 | def igmp_change_to_include_src_list(self, df = None): |
| 886 | groups1 = [self.random_mcast_ip()] |
| 887 | src_list = ['4.4.4.4','6.6.6.6'] |
| 888 | self.onos_ssm_table_load(groups1,src_list = src_list) |
| 889 | self.send_igmp_leave(groups = groups1, src_list = src_list, |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 890 | iface = self.V_INF1, delay = 2) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 891 | if df is None: |
| 892 | df = defer.Deferred() |
| 893 | igmpState1 = IGMPTestState(groups = groups1, df = df) |
ChetanGaonker | b99538a | 2016-12-02 13:53:35 -0800 | [diff] [blame] | 894 | IGMPTestState(groups = groups1, df = df) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 895 | mcastTraffic1 = McastTraffic(groups1, iface= 'veth2',src_ip = src_list[0], |
| 896 | cb = self.send_mcast_cb, arg = igmpState1) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 897 | mcastTraffic1.start() |
| 898 | join_state1 = IGMPTestState(groups = groups1) |
| 899 | target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1) |
| 900 | assert target1 == 1, 'EXPECTED FAILURE' |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 901 | log_test.info('Interface is not receiving traffic from multicast groups %s' %groups1) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 902 | mcastTraffic1.stop() |
| 903 | self.send_igmp_join(groups = groups1, src_list = src_list,record_type = IGMP_V3_GR_TYPE_INCLUDE, |
| 904 | iface = self.V_INF1) |
| 905 | mcastTraffic2 = McastTraffic(groups1, iface= 'veth2',src_ip = src_list[1], |
| 906 | cb = self.send_mcast_cb, arg = igmpState1) |
| 907 | mcastTraffic2.start() |
ChetanGaonker | b99538a | 2016-12-02 13:53:35 -0800 | [diff] [blame] | 908 | self.igmp_recv_task(self.V_INF1, groups1, join_state1) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 909 | mcastTraffic2.stop() |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 910 | |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 911 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 912 | def test_igmp_change_to_include_src_list(self): |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 913 | df = defer.Deferred() |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 914 | def igmp_change_to_include_src_list(): |
| 915 | self.igmp_change_to_include_src_list(df = df) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 916 | df.callback(0) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 917 | reactor.callLater(0, igmp_change_to_include_src_list) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 918 | return df |
| 919 | |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 920 | #this test case failing because group in include receiving multicast traffic from any of the source |
| 921 | def igmp_exclude_to_allow_src_list(self, df = None): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 922 | groups1 = (self.MGROUP1,) |
| 923 | groups2 = (self.MGROUP2,) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 924 | 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] | 925 | self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4'], |
| 926 | iface = self.V_INF1, delay = 2) |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 927 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 928 | dst_mac = '01:00:5e:01:02:03' |
| 929 | src_ip = '2.2.2.2' |
| 930 | if df is None: |
| 931 | df = defer.Deferred() |
| 932 | igmpState1 = IGMPTestState(groups = groups1, df = df) |
ChetanGaonker | b99538a | 2016-12-02 13:53:35 -0800 | [diff] [blame] | 933 | IGMPTestState(groups = groups1, df = df) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 934 | mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac, |
| 935 | src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1) |
| 936 | mcastTraffic1.start() |
| 937 | join_state1 = IGMPTestState(groups = groups1) |
| 938 | target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1) |
| 939 | assert target1 == 1, 'EXPECTED FAILURE' |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 940 | log_test.info('Interface is not receiving traffic from multicast groups %s' %groups1) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 941 | self.igmp_send_joins_different_groups_srclist(groups1 + groups2, |
| 942 | (['6.6.6.6', '7.7.7.7', '8.8.8.8'], ['6.6.6.6', '5.5.5.5']), |
| 943 | intf = self.V_INF1, delay = 2) |
| 944 | target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1) |
| 945 | assert target1 == 1, 'EXPECTED FAILURE' |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 946 | log_test.info('Interface is not receiving traffic from multicast groups %s' %groups1) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 947 | mcastTraffic1.stop() |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 948 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 949 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 950 | def test_igmp_exclude_to_allow_src_list(self): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 951 | df = defer.Deferred() |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 952 | def igmp_exclude_to_allow_src_list(): |
| 953 | self.igmp_exclude_to_allow_src_list(df = df) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 954 | df.callback(0) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 955 | reactor.callLater(0, igmp_exclude_to_allow_src_list) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 956 | return df |
| 957 | |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 958 | def igmp_exclude_to_block_src_list(self, df = None): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 959 | groups1 = (self.MGROUP1,) |
| 960 | groups2 = (self.MGROUP2,) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 961 | 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] | 962 | self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4'], |
| 963 | iface = self.V_INF1, delay = 2) |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 964 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 965 | dst_mac = '01:00:5e:01:02:03' |
| 966 | src_ip = '2.2.2.2' |
| 967 | if df is None: |
| 968 | df = defer.Deferred() |
| 969 | igmpState1 = IGMPTestState(groups = groups1, df = df) |
ChetanGaonker | b99538a | 2016-12-02 13:53:35 -0800 | [diff] [blame] | 970 | IGMPTestState(groups = groups1, df = df) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 971 | mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac, |
| 972 | src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1) |
| 973 | mcastTraffic1.start() |
| 974 | join_state1 = IGMPTestState(groups = groups1) |
| 975 | target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1) |
| 976 | assert target1 == 1, 'EXPECTED FAILURE' |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 977 | log_test.info('Interface is not receiving traffic from multicast groups %s' %groups1) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 978 | 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'], |
| 979 | iface = self.V_INF1, delay = 2) |
| 980 | target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1) |
| 981 | assert target1 == 1, 'EXPECTED FAILURE' |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 982 | log_test.info('Interface is not receiving traffic from multicast groups %s' %groups1) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 983 | mcastTraffic1.stop() |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 984 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 985 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 986 | def test_igmp_exclude_to_block_src_list(self): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 987 | df = defer.Deferred() |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 988 | def igmp_exclude_to_block_src_list(): |
| 989 | self.igmp_exclude_to_block_src_list(df = df) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 990 | df.callback(0) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 991 | reactor.callLater(0, igmp_exclude_to_block_src_list) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 992 | return df |
| 993 | |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 994 | #this test case failing because group in include mode recieves traffic from other sources also. |
| 995 | def igmp_new_src_list(self, df = None): |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 996 | groups1 = (self.MGROUP1,) |
| 997 | groups2 = (self.MGROUP2,) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 998 | 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] | 999 | self.igmp_send_joins_different_groups_srclist(groups1+groups2, |
| 1000 | (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']), |
| 1001 | intf = self.V_INF1, delay = 2) |
| 1002 | dst_mac = '01:00:5e:01:02:03' |
| 1003 | src_ip = '6.6.6.6' |
| 1004 | if df is None: |
| 1005 | df = defer.Deferred() |
| 1006 | igmpState1 = IGMPTestState(groups = groups1, df = df) |
ChetanGaonker | b99538a | 2016-12-02 13:53:35 -0800 | [diff] [blame] | 1007 | IGMPTestState(groups = groups1, df = df) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 1008 | mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac, |
| 1009 | src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1) |
| 1010 | mcastTraffic1.start() |
| 1011 | join_state1 = IGMPTestState(groups = groups1) |
| 1012 | target1 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1) |
| 1013 | assert target1 == 1, 'EXPECTED FAILURE' |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1014 | log_test.info('Interface is not receiving traffic from multicast groups %s' %groups1) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 1015 | self.igmp_send_joins_different_groups_srclist(groups1 + groups2, |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1016 | (['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] | 1017 | intf = self.V_INF1, delay = 2) |
ChetanGaonker | b99538a | 2016-12-02 13:53:35 -0800 | [diff] [blame] | 1018 | self.igmp_recv_task(self.V_INF1, groups1, join_state1) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1019 | log_test.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] | 1020 | mcastTraffic1.stop() |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 1021 | |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 1022 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1023 | def test_igmp_new_src_list(self): |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 1024 | df = defer.Deferred() |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1025 | def igmp_new_src_list(): |
| 1026 | self.igmp_new_src_list(df = df) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 1027 | df.callback(0) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1028 | reactor.callLater(0, igmp_new_src_list) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 1029 | return df |
| 1030 | |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1031 | def igmp_block_old_src_list(self, df = None): |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 1032 | groups1 = (self.MGROUP1,) |
| 1033 | groups2 = (self.MGROUP2,) |
| 1034 | groups = groups1 + groups2 |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1035 | 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] | 1036 | self.igmp_send_joins_different_groups_srclist(groups, |
| 1037 | (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']), |
| 1038 | intf = self.V_INF1, delay = 2) |
| 1039 | dst_mac = '01:00:5e:02:02:03' |
| 1040 | src_ip = '5.5.5.5' |
| 1041 | if df is None: |
| 1042 | df = defer.Deferred() |
| 1043 | igmpState1 = IGMPTestState(groups = groups2, df = df) |
ChetanGaonker | b99538a | 2016-12-02 13:53:35 -0800 | [diff] [blame] | 1044 | IGMPTestState(groups = groups2, df = df) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 1045 | mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac, |
| 1046 | src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1) |
| 1047 | mcastTraffic1.start() |
| 1048 | join_state1 = IGMPTestState(groups = groups2) |
ChetanGaonker | b99538a | 2016-12-02 13:53:35 -0800 | [diff] [blame] | 1049 | self.igmp_recv_task(self.V_INF1, groups2, join_state1) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1050 | log_test.info('Interface is receiving traffic from multicast groups %s' %groups2) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 1051 | self.igmp_send_joins_different_groups_srclist(groups, |
| 1052 | (['6.6.6.6', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '7.7.7.7']), |
| 1053 | intf = self.V_INF1, delay = 2) |
| 1054 | target2 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1) |
Chetan Gaonker | 7791bda | 2016-05-12 17:36:52 -0700 | [diff] [blame] | 1055 | assert target2 == 2, 'EXPECTED FAILURE' |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1056 | log_test.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] | 1057 | mcastTraffic1.stop() |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 1058 | |
| 1059 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1060 | def test_igmp_block_old_src_list(self): |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 1061 | df = defer.Deferred() |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1062 | def igmp_block_old_src_list(): |
| 1063 | self.igmp_block_old_src_list(df = df) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 1064 | df.callback(0) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1065 | reactor.callLater(0, igmp_block_old_src_list) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 1066 | return df |
| 1067 | |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1068 | def igmp_include_empty_src_list(self, df = None): |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 1069 | groups1 = (self.MGROUP1,) |
| 1070 | groups2 = (self.MGROUP2,) |
| 1071 | groups = groups1 + groups2 |
| 1072 | self.igmp_send_joins_different_groups_srclist(groups, |
Thangavelu K S | 790ad33 | 2016-12-14 12:54:58 +0530 | [diff] [blame] | 1073 | (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['0']), |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 1074 | intf = self.V_INF1, delay = 2) |
| 1075 | dst_mac = '01:00:5e:02:02:03' |
| 1076 | src_ip = '5.5.5.5' |
| 1077 | if df is None: |
| 1078 | df = defer.Deferred() |
| 1079 | igmpState1 = IGMPTestState(groups = groups2, df = df) |
ChetanGaonker | b99538a | 2016-12-02 13:53:35 -0800 | [diff] [blame] | 1080 | IGMPTestState(groups = groups2, df = df) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 1081 | mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac, |
| 1082 | src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1) |
| 1083 | mcastTraffic1.start() |
| 1084 | join_state1 = IGMPTestState(groups = groups2) |
| 1085 | target1 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1) |
| 1086 | assert target1==1, 'EXPECTED FAILURE' |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1087 | log_test.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] | 1088 | mcastTraffic1.stop() |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 1089 | |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 1090 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1091 | def test_igmp_include_empty_src_list(self): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1092 | ## '''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] | 1093 | df = defer.Deferred() |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1094 | def igmp_include_empty_src_list(): |
| 1095 | self.igmp_include_empty_src_list(df = df) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 1096 | df.callback(0) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1097 | reactor.callLater(0, igmp_include_empty_src_list) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 1098 | return df |
| 1099 | |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1100 | def igmp_exclude_empty_src_list(self, df = None): |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 1101 | groups2 = (self.MGROUP2,) |
Thangavelu K S | 790ad33 | 2016-12-14 12:54:58 +0530 | [diff] [blame] | 1102 | self.send_igmp_leave(groups = groups2, src_list = ['0'], iface = self.V_INF1, delay = 2) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 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) |
ChetanGaonker | b99538a | 2016-12-02 13:53:35 -0800 | [diff] [blame] | 1108 | IGMPTestState(groups = groups2, df = df) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 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) |
ChetanGaonker | b99538a | 2016-12-02 13:53:35 -0800 | [diff] [blame] | 1113 | self.igmp_recv_task(self.V_INF1, groups2, join_state1) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1114 | log_test.info('Interface is receiving multicast groups %s' %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_exclude_empty_src_list(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_exclude_empty_src_list(): |
| 1121 | self.igmp_exclude_empty_src_list() |
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_exclude_empty_src_list) |
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_join_sourceip_0_0_0_0(self, df = None): |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 1127 | groups1 = (self.MGROUP1,) |
| 1128 | groups2 = (self.MGROUP2,) |
| 1129 | groups = groups1 + groups2 |
| 1130 | ip_src = '0.0.0.0' |
| 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) |
ChetanGaonker | b99538a | 2016-12-02 13:53:35 -0800 | [diff] [blame] | 1140 | IGMPTestState(groups = groups2, df = df) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 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) |
ChetanGaonker | b99538a | 2016-12-02 13:53:35 -0800 | [diff] [blame] | 1145 | self.igmp_recv_task(self.V_INF1, groups2, join_state1) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1146 | log_test.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] | 1147 | mcastTraffic1.stop() |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 1148 | |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 1149 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1150 | def test_igmp_join_sourceip_0_0_0_0(self): |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 1151 | df = defer.Deferred() |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1152 | def igmp_join_sourceip_0_0_0_0(): |
| 1153 | self.igmp_join_sourceip_0_0_0_0(df = df) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 1154 | df.callback(0) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1155 | reactor.callLater(0, igmp_join_sourceip_0_0_0_0) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 1156 | return df |
| 1157 | |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1158 | def igmp_invalid_join_packet(self, df = None): |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1159 | groups1 = (self.MGROUP1,) |
| 1160 | groups2 = (self.MINVALIDGROUP1,) |
| 1161 | groups = groups1 + groups2 |
| 1162 | ip_src = '1.1.1.1' |
| 1163 | self.igmp_send_joins_different_groups_srclist(groups, |
| 1164 | (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['5.5.5.5']), |
| 1165 | intf = self.V_INF1, delay = 2, ip_src = ip_src) |
| 1166 | ip_src = self.IP_SRC |
| 1167 | dst_mac = '01:00:5e:02:02:03' |
| 1168 | src_ip = '5.5.5.5' |
| 1169 | if df is None: |
| 1170 | df = defer.Deferred() |
| 1171 | igmpState1 = IGMPTestState(groups = groups2, df = df) |
ChetanGaonker | b99538a | 2016-12-02 13:53:35 -0800 | [diff] [blame] | 1172 | IGMPTestState(groups = groups2, df = df) |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1173 | mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac, |
| 1174 | src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1) |
| 1175 | mcastTraffic1.start() |
| 1176 | join_state1 = IGMPTestState(groups = groups2) |
| 1177 | target1 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1) |
| 1178 | assert target1==1, 'EXPECTED FAILURE' |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1179 | log_test.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] | 1180 | mcastTraffic1.stop() |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 1181 | |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1182 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1183 | def test_igmp_invalid_join_packet(self): |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1184 | df = defer.Deferred() |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1185 | def igmp_invalid_join_packet(): |
| 1186 | self.igmp_invalid_join_packet(df = df) |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1187 | df.callback(0) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1188 | reactor.callLater(0, igmp_invalid_join_packet) |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1189 | return df |
| 1190 | |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1191 | def igmp_join_data_receiving_during_subscriber_link_toggle(self, df = None): |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1192 | groups1 = (self.MGROUP1,) |
| 1193 | groups2 = (self.MGROUP2,) |
| 1194 | groups = groups1 + groups2 |
| 1195 | ip_src = '1.1.1.1' |
| 1196 | self.igmp_send_joins_different_groups_srclist(groups, |
| 1197 | (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['5.5.5.5']), |
| 1198 | intf = self.V_INF1, delay = 2, ip_src = ip_src) |
| 1199 | ip_src = self.IP_SRC |
| 1200 | dst_mac = '01:00:5e:02:02:03' |
| 1201 | src_ip = '5.5.5.5' |
| 1202 | if df is None: |
| 1203 | df = defer.Deferred() |
| 1204 | igmpState1 = IGMPTestState(groups = groups2, df = df) |
ChetanGaonker | b99538a | 2016-12-02 13:53:35 -0800 | [diff] [blame] | 1205 | IGMPTestState(groups = groups2, df = df) |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1206 | mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac, |
| 1207 | src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1) |
| 1208 | mcastTraffic1.start() |
| 1209 | join_state1 = IGMPTestState(groups = groups2) |
ChetanGaonker | b99538a | 2016-12-02 13:53:35 -0800 | [diff] [blame] | 1210 | self.igmp_recv_task(self.V_INF1, groups2, join_state1) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1211 | log_test.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] | 1212 | os.system('ifconfig '+self.V_INF1+' down') |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1213 | log_test.info(' the self.V_INF1 %s is down now ' %self.V_INF1) |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1214 | os.system('ifconfig '+self.V_INF1) |
| 1215 | time.sleep(10) |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1216 | os.system('ifconfig '+self.V_INF1+' up') |
| 1217 | os.system('ifconfig '+self.V_INF1) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1218 | log_test.info(' the self.V_INF1 %s is up now ' %self.V_INF1) |
ChetanGaonker | b99538a | 2016-12-02 13:53:35 -0800 | [diff] [blame] | 1219 | self.igmp_recv_task(self.V_INF1, groups2, join_state1) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1220 | log_test.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] | 1221 | mcastTraffic1.stop() |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 1222 | |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1223 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1224 | def test_igmp_join_data_received_during_subscriber_link_toggle(self): |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1225 | df = defer.Deferred() |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1226 | def igmp_join_data_received_during_subscriber_link_toggle(): |
| 1227 | self.igmp_join_data_received_during_subscriber_link_toggle(df = df) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1228 | df.callback(0) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1229 | reactor.callLater(0, igmp_join_data_received_during_subscriber_link_toggle) |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1230 | return df |
| 1231 | |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1232 | 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] | 1233 | groups1 = (self.MGROUP1,) |
| 1234 | groups2 = (self.MGROUP2,) |
| 1235 | groups = groups1 + groups2 |
| 1236 | ip_src = '1.1.1.1' |
| 1237 | self.igmp_send_joins_different_groups_srclist(groups, |
| 1238 | (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['5.5.5.5', '6.6.6.6']), |
| 1239 | intf = self.V_INF1, delay = 2, ip_src = ip_src) |
| 1240 | ip_src = self.IP_SRC |
| 1241 | dst_mac1 = '01:00:5e:01:02:03' |
| 1242 | dst_mac2 = '01:00:5e:02:02:03' |
| 1243 | src_ip2 = '5.5.5.5' |
| 1244 | src_ip1 = '2.2.2.2' |
| 1245 | if df is None: |
| 1246 | df = defer.Deferred() |
| 1247 | igmpState1 = IGMPTestState(groups = groups1, df = df) |
| 1248 | igmpState2 = IGMPTestState(groups = groups2, df = df) |
ChetanGaonker | b99538a | 2016-12-02 13:53:35 -0800 | [diff] [blame] | 1249 | IGMPTestState(groups = groups1, df = df) |
| 1250 | IGMPTestState(groups = groups2, df = df) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1251 | mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac1, |
| 1252 | src_ip = src_ip1, cb = self.send_mcast_cb, arg = igmpState1) |
| 1253 | mcastTraffic2 = McastTraffic(groups2, iface= 'veth3', dst_mac = dst_mac2, |
| 1254 | src_ip = src_ip2, cb = self.send_mcast_cb, arg = igmpState2) |
| 1255 | mcastTraffic1.start() |
| 1256 | mcastTraffic2.start() |
| 1257 | join_state1 = IGMPTestState(groups = groups1) |
| 1258 | join_state2 = IGMPTestState(groups = groups2) |
ChetanGaonker | b99538a | 2016-12-02 13:53:35 -0800 | [diff] [blame] | 1259 | self.igmp_recv_task(self.V_INF1, groups1, join_state1) |
| 1260 | self.igmp_recv_task(self.V_INF1, groups2, join_state2) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1261 | mcastTraffic1.stop() |
| 1262 | os.system('ifconfig '+'veth2'+' down') |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1263 | os.system('ifconfig '+'veth2') |
| 1264 | time.sleep(10) |
ChetanGaonker | b99538a | 2016-12-02 13:53:35 -0800 | [diff] [blame] | 1265 | self.igmp_not_recv_task(self.V_INF1, groups2, join_state1) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1266 | target1 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1) |
| 1267 | assert target1==1, 'EXPECTED FAILURE' |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1268 | os.system('ifconfig '+'veth2'+' up') |
| 1269 | os.system('ifconfig '+'veth2') |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1270 | time.sleep(10) |
| 1271 | mcastTraffic1.start() |
ChetanGaonker | b99538a | 2016-12-02 13:53:35 -0800 | [diff] [blame] | 1272 | self.igmp_not_recv_task(self.V_INF1, groups1, join_state1) |
| 1273 | self.igmp_recv_task(self.V_INF1, groups2, join_state2) |
| 1274 | self.igmp_recv_task(self.V_INF1, groups2, join_state2) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1275 | mcastTraffic2.stop() |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 1276 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1277 | ## This test case is failing to receive traffic from multicast data from defferent channel interfaces TO-DO |
| 1278 | ###### TO DO scenario ####### |
| 1279 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+60) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1280 | def test_igmp_join_data_received_during_channel_distributors_link_toggle(self): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1281 | df = defer.Deferred() |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1282 | def igmp_join_data_receiving_during_channel_distributor_link_toggle(): |
Thangavelu K S | 790ad33 | 2016-12-14 12:54:58 +0530 | [diff] [blame] | 1283 | self.igmp_join_data_received_during_channel_distributor_link_toggle(df = df) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1284 | df.callback(0) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1285 | reactor.callLater(0, igmp_join_data_receiving_during_channel_distributor_link_toggle) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1286 | return df |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1287 | |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1288 | def igmp_invalidClassD_IP_join_packet(self, df = None): |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1289 | groups1 = (self.MGROUP1,) |
| 1290 | groups2 = (self.MINVALIDGROUP2,) |
| 1291 | groups = groups1 + groups2 |
| 1292 | ip_src = '1.1.1.1' |
| 1293 | self.igmp_send_joins_different_groups_srclist(groups, |
| 1294 | (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['5.5.5.5']), |
| 1295 | intf = self.V_INF1, delay = 2, ip_src = ip_src) |
| 1296 | ip_src = self.IP_SRC |
| 1297 | dst_mac = '01:00:5e:02:02:03' |
| 1298 | src_ip = '5.5.5.5' |
| 1299 | if df is None: |
| 1300 | df = defer.Deferred() |
| 1301 | igmpState1 = IGMPTestState(groups = groups2, df = df) |
ChetanGaonker | b99538a | 2016-12-02 13:53:35 -0800 | [diff] [blame] | 1302 | IGMPTestState(groups = groups2, df = df) |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1303 | mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac, |
| 1304 | src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1) |
| 1305 | mcastTraffic1.start() |
| 1306 | join_state1 = IGMPTestState(groups = groups2) |
| 1307 | target1 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1) |
| 1308 | assert target1==1, 'EXPECTED FAILURE' |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1309 | log_test.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] | 1310 | mcastTraffic1.stop() |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1311 | |
| 1312 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1313 | def test_igmp_invalid_class_d_ip_for_join_packet(self): |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1314 | df = defer.Deferred() |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1315 | def igmp_invalidClass_D_IP_join_packet(): |
Thangavelu K S | 790ad33 | 2016-12-14 12:54:58 +0530 | [diff] [blame] | 1316 | self.igmp_invalidClassD_IP_join_packet(df = df) |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1317 | df.callback(0) |
Thangavelu K S | 790ad33 | 2016-12-14 12:54:58 +0530 | [diff] [blame] | 1318 | reactor.callLater(0, igmp_invalidClass_D_IP_join_packet) |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1319 | return df |
| 1320 | |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1321 | def igmp_invalidClassD_IP_as_srclistIP_join_packet(self, df = None): |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1322 | groups1 = (self.MGROUP1,) |
| 1323 | groups2 = (self.MGROUP2,) |
| 1324 | groups = groups1 + groups2 |
| 1325 | ip_src = '1.1.1.1' |
| 1326 | self.igmp_send_joins_different_groups_srclist(groups, |
| 1327 | (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['239.5.5.5']), |
| 1328 | intf = self.V_INF1, delay = 2, ip_src = ip_src) |
| 1329 | ip_src = self.IP_SRC |
| 1330 | dst_mac = '01:00:5e:02:02:03' |
| 1331 | src_ip = '5.5.5.5' |
| 1332 | if df is None: |
| 1333 | df = defer.Deferred() |
| 1334 | igmpState1 = IGMPTestState(groups = groups2, df = df) |
ChetanGaonker | b99538a | 2016-12-02 13:53:35 -0800 | [diff] [blame] | 1335 | IGMPTestState(groups = groups2, df = df) |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1336 | mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac, |
| 1337 | src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1) |
| 1338 | mcastTraffic1.start() |
| 1339 | join_state1 = IGMPTestState(groups = groups2) |
| 1340 | target1 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1) |
| 1341 | assert target1==1, 'EXPECTED FAILURE' |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1342 | log_test.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] | 1343 | mcastTraffic1.stop() |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 1344 | |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1345 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1346 | 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] | 1347 | df = defer.Deferred() |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1348 | def igmp_invalidClassD_IP_as_srclistIP_join_packet(): |
| 1349 | self.igmp_invalidClassD_IP_as_srclistIP_join_packet(df = df) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1350 | df.callback(0) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1351 | reactor.callLater(0, igmp_invalidClassD_IP_as_srclistIP_join_packet) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1352 | return df |
Chetan Gaonker | f72ca40 | 2016-05-02 16:29:32 -0700 | [diff] [blame] | 1353 | |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1354 | def igmp_general_query_recv_packet(self, df = None): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1355 | groups1 = (self.MGROUP1,) |
| 1356 | groups2 = (self.MGROUP2,) |
| 1357 | groups = groups1 + groups2 |
| 1358 | ip_src = '1.1.1.1' |
| 1359 | self.igmp_send_joins_different_groups_srclist(groups, |
| 1360 | (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['5.5.5.5']), |
| 1361 | intf = self.V_INF1, delay = 2, ip_src = ip_src) |
| 1362 | ip_src = self.IP_SRC |
| 1363 | dst_mac = '01:00:5e:02:02:03' |
| 1364 | src_ip = '5.5.5.5' |
| 1365 | if df is None: |
| 1366 | df = defer.Deferred() |
| 1367 | igmpState1 = IGMPTestState(groups = groups2, df = df) |
ChetanGaonker | b99538a | 2016-12-02 13:53:35 -0800 | [diff] [blame] | 1368 | IGMPTestState(groups = groups2, df = df) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1369 | mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac, |
| 1370 | src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1) |
| 1371 | mcastTraffic1.start() |
| 1372 | join_state1 = IGMPTestState(groups = groups2) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1373 | log_test.info('Started delay to verify multicast data taraffic for group %s is received or not for 180 sec ' %groups2) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1374 | time.sleep(100) |
ChetanGaonker | b99538a | 2016-12-02 13:53:35 -0800 | [diff] [blame] | 1375 | self.igmp_recv_task(self.V_INF1, groups2, join_state1) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1376 | log_test.info('Verified that multicast data for group %s is received after 100 sec ' %groups2) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1377 | time.sleep(50) |
ChetanGaonker | b99538a | 2016-12-02 13:53:35 -0800 | [diff] [blame] | 1378 | self.igmp_recv_task(self.V_INF1, groups2, join_state1) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1379 | log_test.info('Verified that multicast data for group %s is received after 150 sec ' %groups2) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1380 | time.sleep(30) |
ChetanGaonker | b99538a | 2016-12-02 13:53:35 -0800 | [diff] [blame] | 1381 | self.igmp_recv_task(self.V_INF1, groups2, join_state1) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1382 | log_test.info('Verified that multicast data for group %s is received after 180 sec ' %groups2) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1383 | time.sleep(10) |
ChetanGaonker | b99538a | 2016-12-02 13:53:35 -0800 | [diff] [blame] | 1384 | self.igmp_recv_task(self.V_INF1, groups2, join_state1) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1385 | log_test.info('Verified that multicast data for group %s is received after 190 sec ' %groups2) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1386 | target3 = mcastTraffic1.isRecvStopped() |
| 1387 | assert target3==False, 'EXPECTED FAILURE' |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1388 | log_test.info('Verified that multicast data for a group %s is still transmitting from a data interface' %groups2) |
| 1389 | log_test.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] | 1390 | target1 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1) |
| 1391 | assert target1==1, 'EXPECTED FAILURE' |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1392 | log_test.info('Interface is not receiving multicast data for group %s' %groups2) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1393 | mcastTraffic1.stop() |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 1394 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1395 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+250) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1396 | def test_igmp_general_query_received_traffic(self): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1397 | df = defer.Deferred() |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1398 | def igmp_general_query_recv_packet(): |
| 1399 | self.igmp_general_query_recv_packet(df = df) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1400 | df.callback(0) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1401 | reactor.callLater(0, igmp_general_query_recv_packet) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1402 | return df |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 1403 | |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1404 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+100) |
| 1405 | def test_igmp_query_received_on_joining_interface(self): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1406 | groups = ['224.0.1.10', '225.0.0.10'] |
| 1407 | leave_groups = ['224.0.1.10'] |
| 1408 | df = defer.Deferred() |
| 1409 | igmpState = IGMPTestState(groups = groups, df = df) |
| 1410 | igmpStateRecv = IGMPTestState(groups = groups, df = df) |
| 1411 | igmpStateList = (igmpState, igmpStateRecv) |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 1412 | mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb, |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1413 | arg = igmpState) |
| 1414 | self.df = df |
| 1415 | self.mcastTraffic = mcastTraffic |
| 1416 | self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP) |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 1417 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1418 | def igmp_srp_task(stateList): |
| 1419 | igmpSendState, igmpRecvState = stateList |
| 1420 | if not mcastTraffic.isRecvStopped(): |
ChetanGaonker | b99538a | 2016-12-02 13:53:35 -0800 | [diff] [blame] | 1421 | self.igmp_recv(igmpRecvState) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1422 | reactor.callLater(0, igmp_srp_task, stateList) |
| 1423 | else: |
| 1424 | self.mcastTraffic.stop() |
| 1425 | self.recv_socket.close() |
| 1426 | self.igmp_verify_leave(stateList, leave_groups) |
| 1427 | self.df.callback(0) |
| 1428 | |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1429 | log_test.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] | 1430 | self.send_igmp_join_recvQuery(groups) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1431 | log_test.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] | 1432 | mcastTraffic.start() |
| 1433 | self.test_timer = reactor.callLater(self.MCAST_TRAFFIC_TIMEOUT, self.mcast_traffic_timer) |
| 1434 | reactor.callLater(0, igmp_srp_task, igmpStateList) |
| 1435 | return df |
| 1436 | |
| 1437 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+190) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1438 | def test_igmp_for_periodic_query_received_on_joining_interface(self): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1439 | groups = ['224.0.1.10', '225.0.0.10'] |
| 1440 | leave_groups = ['224.0.1.10'] |
| 1441 | df = defer.Deferred() |
| 1442 | igmpState = IGMPTestState(groups = groups, df = df) |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 1443 | mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb, |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1444 | arg = igmpState) |
| 1445 | self.df = df |
| 1446 | self.mcastTraffic = mcastTraffic |
| 1447 | self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP) |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 1448 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1449 | def igmp_srp_task(stateList): |
| 1450 | igmpSendState, igmpRecvState = stateList |
| 1451 | if not mcastTraffic.isRecvStopped(): |
ChetanGaonker | b99538a | 2016-12-02 13:53:35 -0800 | [diff] [blame] | 1452 | self.igmp_recv(igmpRecvState) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1453 | reactor.callLater(0, igmp_srp_task, stateList) |
| 1454 | else: |
| 1455 | self.mcastTraffic.stop() |
| 1456 | self.recv_socket.close() |
| 1457 | self.igmp_verify_leave(stateList, leave_groups) |
| 1458 | self.df.callback(0) |
| 1459 | |
| 1460 | self.send_igmp_join_recvQuery(groups,3) |
| 1461 | return df |
| 1462 | |
| 1463 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+190) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1464 | def test_igmp_for_periodic_query_received_and_checking_entry_deleted(self): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1465 | groups = ['224.0.1.10', '225.0.0.10'] |
| 1466 | leave_groups = ['224.0.1.10'] |
| 1467 | df = defer.Deferred() |
| 1468 | igmpState = IGMPTestState(groups = groups, df = df) |
| 1469 | igmpStateRecv = IGMPTestState(groups = groups, df = df) |
| 1470 | igmpStateList = (igmpState, igmpStateRecv) |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 1471 | mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb, |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1472 | arg = igmpState) |
| 1473 | self.df = df |
| 1474 | self.mcastTraffic = mcastTraffic |
| 1475 | self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP) |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 1476 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1477 | def igmp_srp_task(stateList): |
| 1478 | igmpSendState, igmpRecvState = stateList |
| 1479 | if not mcastTraffic.isRecvStopped(): |
ChetanGaonker | b99538a | 2016-12-02 13:53:35 -0800 | [diff] [blame] | 1480 | self.igmp_recv(igmpRecvState) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1481 | reactor.callLater(0, igmp_srp_task, stateList) |
| 1482 | else: |
| 1483 | self.mcastTraffic.stop() |
| 1484 | self.recv_socket.close() |
| 1485 | self.igmp_verify_leave(stateList, leave_groups) |
| 1486 | self.df.callback(0) |
| 1487 | |
| 1488 | self.send_igmp_join_recvQuery(groups,3) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1489 | log_test.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] | 1490 | mcastTraffic.start() |
| 1491 | self.test_timer = reactor.callLater(self.MCAST_TRAFFIC_TIMEOUT, self.mcast_traffic_timer) |
| 1492 | reactor.callLater(0, igmp_srp_task, igmpStateList) |
| 1493 | return df |
| 1494 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1495 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+190) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1496 | def test_igmp_member_query_interval_and_expiry_for_rejoining_interface(self): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1497 | groups = ['224.0.1.10', '225.0.0.10'] |
| 1498 | leave_groups = ['224.0.1.10'] |
| 1499 | df = defer.Deferred() |
| 1500 | igmpState = IGMPTestState(groups = groups, df = df) |
| 1501 | igmpStateRecv = IGMPTestState(groups = groups, df = df) |
| 1502 | igmpStateList = (igmpState, igmpStateRecv) |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 1503 | mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb, |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1504 | arg = igmpState) |
| 1505 | self.df = df |
| 1506 | self.mcastTraffic = mcastTraffic |
| 1507 | self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP) |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 1508 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1509 | def igmp_srp_task(stateList): |
| 1510 | igmpSendState, igmpRecvState = stateList |
| 1511 | if not mcastTraffic.isRecvStopped(): |
ChetanGaonker | b99538a | 2016-12-02 13:53:35 -0800 | [diff] [blame] | 1512 | self.igmp_recv(igmpRecvState) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1513 | reactor.callLater(0, igmp_srp_task, stateList) |
| 1514 | else: |
| 1515 | self.mcastTraffic.stop() |
| 1516 | self.recv_socket.close() |
| 1517 | self.igmp_verify_leave(stateList, leave_groups) |
| 1518 | self.df.callback(0) |
| 1519 | |
| 1520 | self.send_igmp_join_recvQuery(groups,3) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1521 | log_test.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] | 1522 | self.send_igmp_join(groups) |
| 1523 | mcastTraffic.start() |
| 1524 | self.test_timer = reactor.callLater(self.MCAST_TRAFFIC_TIMEOUT, self.mcast_traffic_timer) |
| 1525 | reactor.callLater(0, igmp_srp_task, igmpStateList) |
| 1526 | return df |
| 1527 | |
| 1528 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+50) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1529 | def test_igmp_leave_received_group_and_source_specific_query(self): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1530 | groups = ['224.0.1.10', '225.0.0.10'] |
| 1531 | leave_groups = ['224.0.1.10'] |
| 1532 | df = defer.Deferred() |
| 1533 | igmpState = IGMPTestState(groups = groups, df = df) |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 1534 | mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb, |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1535 | arg = igmpState) |
| 1536 | self.df = df |
| 1537 | self.mcastTraffic = mcastTraffic |
| 1538 | self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP) |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 1539 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1540 | def igmp_srp_task(stateList): |
| 1541 | igmpSendState, igmpRecvState = stateList |
| 1542 | if not mcastTraffic.isRecvStopped(): |
ChetanGaonker | b99538a | 2016-12-02 13:53:35 -0800 | [diff] [blame] | 1543 | self.igmp_recv(igmpRecvState) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1544 | reactor.callLater(0, igmp_srp_task, stateList) |
| 1545 | else: |
| 1546 | self.mcastTraffic.stop() |
| 1547 | self.recv_socket.close() |
| 1548 | self.igmp_verify_leave(stateList, leave_groups) |
| 1549 | self.df.callback(0) |
| 1550 | |
| 1551 | self.send_igmp_join(groups) |
| 1552 | self.send_igmp_leave_listening_group_specific_query(leave_groups, delay = 3) |
| 1553 | return df |
| 1554 | |
| 1555 | def igmp_change_to_exclude_src_list_check_for_group_source_specific_query(self, df = None): |
| 1556 | groups1 = (self.MGROUP1,) |
| 1557 | groups2 = (self.MGROUP2,) |
| 1558 | self.igmp_send_joins_different_groups_srclist(groups1 + groups2, |
| 1559 | (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']), |
| 1560 | intf = self.V_INF1, delay = 2) |
| 1561 | dst_mac = '01:00:5e:01:02:03' |
| 1562 | src_ip = '2.2.2.2' |
| 1563 | if df is None: |
| 1564 | df = defer.Deferred() |
| 1565 | igmpState1 = IGMPTestState(groups = groups1, df = df) |
ChetanGaonker | b99538a | 2016-12-02 13:53:35 -0800 | [diff] [blame] | 1566 | IGMPTestState(groups = groups1, df = df) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1567 | mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac, |
| 1568 | src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1) |
| 1569 | mcastTraffic1.start() |
| 1570 | join_state1 = IGMPTestState(groups = groups1) |
ChetanGaonker | b99538a | 2016-12-02 13:53:35 -0800 | [diff] [blame] | 1571 | self.igmp_recv_task(self.V_INF1, groups1, join_state1) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1572 | self.send_igmp_leave_listening_group_specific_query(groups = groups1, src_list = ['2.2.2.2'], iface = self.V_INF1, delay =2) |
| 1573 | time.sleep(10) |
| 1574 | target2 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1) |
| 1575 | assert target2 == 1, 'EXPECTED FAILURE' |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1576 | log_test.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] | 1577 | mcastTraffic1.stop() |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 1578 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1579 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+60) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1580 | 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] | 1581 | df = defer.Deferred() |
| 1582 | def igmp_change_to_exclude_src_list_check_for_group_source_specific_query(): |
| 1583 | self.igmp_change_to_exclude_src_list_check_for_group_source_specific_query(df = df) |
| 1584 | df.callback(0) |
| 1585 | reactor.callLater(0, igmp_change_to_exclude_src_list_check_for_group_source_specific_query) |
| 1586 | return df |
| 1587 | |
| 1588 | def igmp_change_to_include_src_list_check_for_general_query(self, df = None): |
| 1589 | groups1 = (self.MGROUP1,) |
| 1590 | groups2 = (self.MGROUP2,) |
| 1591 | self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4'], |
| 1592 | iface = self.V_INF1, delay = 2) |
| 1593 | dst_mac = '01:00:5e:01:02:03' |
| 1594 | src_ip = '2.2.2.2' |
| 1595 | if df is None: |
| 1596 | df = defer.Deferred() |
| 1597 | igmpState1 = IGMPTestState(groups = groups1, df = df) |
ChetanGaonker | b99538a | 2016-12-02 13:53:35 -0800 | [diff] [blame] | 1598 | IGMPTestState(groups = groups1, df = df) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1599 | mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac, |
| 1600 | src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1) |
| 1601 | mcastTraffic1.start() |
| 1602 | join_state1 = IGMPTestState(groups = groups1) |
| 1603 | target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1) |
| 1604 | assert target1 == 1, 'EXPECTED FAILURE' |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1605 | log_test.info('Interface is not receiving traffic from multicast groups %s' %groups1) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1606 | self.igmp_send_joins_different_groups_srclist_wait_query_packets(groups1 + groups2, |
| 1607 | (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['6.6.6.6', '5.5.5.5']), |
| 1608 | intf = self.V_INF1, delay = 2,query_group1 = 'group1', query_group2 = None) |
| 1609 | time.sleep(10) |
ChetanGaonker | b99538a | 2016-12-02 13:53:35 -0800 | [diff] [blame] | 1610 | self.igmp_recv_task(self.V_INF1, groups1, join_state1) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1611 | log_test.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] | 1612 | mcastTraffic1.stop() |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 1613 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1614 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+80) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1615 | 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] | 1616 | df = defer.Deferred() |
| 1617 | def igmp_change_to_include_src_list_check_for_general_query(): |
| 1618 | self.igmp_change_to_include_src_list_check_for_general_query(df = df) |
| 1619 | df.callback(0) |
| 1620 | reactor.callLater(0, igmp_change_to_include_src_list_check_for_general_query) |
| 1621 | return df |
| 1622 | |
| 1623 | def igmp_allow_new_src_list_check_for_general_query(self, df = None): |
| 1624 | groups1 = (self.MGROUP1,) |
| 1625 | groups2 = (self.MGROUP2,) |
| 1626 | self.igmp_send_joins_different_groups_srclist(groups1+groups2, |
| 1627 | (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']), |
| 1628 | intf = self.V_INF1, delay = 2) |
| 1629 | dst_mac = '01:00:5e:01:02:03' |
| 1630 | src_ip = '6.6.6.6' |
| 1631 | if df is None: |
| 1632 | df = defer.Deferred() |
| 1633 | igmpState1 = IGMPTestState(groups = groups1, df = df) |
ChetanGaonker | b99538a | 2016-12-02 13:53:35 -0800 | [diff] [blame] | 1634 | IGMPTestState(groups = groups1, df = df) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1635 | mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac, |
| 1636 | src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1) |
| 1637 | mcastTraffic1.start() |
| 1638 | join_state1 = IGMPTestState(groups = groups1) |
ChetanGaonker | b99538a | 2016-12-02 13:53:35 -0800 | [diff] [blame] | 1639 | self.igmp_not_recv_task(self.V_INF1, groups1, join_state1) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1640 | log_test.info('Interface is not receiving traffic from multicast groups %s' %groups1) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1641 | 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']), |
| 1642 | intf = self.V_INF1, delay = 2, query_group1 = 'group1', query_group2 = None) |
ChetanGaonker | b99538a | 2016-12-02 13:53:35 -0800 | [diff] [blame] | 1643 | self.igmp_recv_task(self.V_INF1, groups1, join_state1) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1644 | log_test.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] | 1645 | mcastTraffic1.stop() |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 1646 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1647 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+80) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1648 | 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] | 1649 | df = defer.Deferred() |
| 1650 | def igmp_allow_new_src_list_check_for_general_query(): |
| 1651 | self.igmp_allow_new_src_list_check_for_general_query(df = df) |
| 1652 | df.callback(0) |
| 1653 | reactor.callLater(0, igmp_allow_new_src_list_check_for_general_query) |
| 1654 | return df |
| 1655 | |
| 1656 | def igmp_block_old_src_list_check_for_group_source_specific_query(self, df = None): |
| 1657 | groups1 = (self.MGROUP1,) |
| 1658 | groups2 = (self.MGROUP2,) |
| 1659 | groups = groups1 + groups2 |
| 1660 | self.igmp_send_joins_different_groups_srclist(groups, |
| 1661 | (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']), |
| 1662 | intf = self.V_INF1, delay = 2) |
| 1663 | dst_mac = '01:00:5e:02:02:03' |
| 1664 | src_ip = '5.5.5.5' |
| 1665 | if df is None: |
| 1666 | df = defer.Deferred() |
| 1667 | igmpState1 = IGMPTestState(groups = groups2, df = df) |
ChetanGaonker | b99538a | 2016-12-02 13:53:35 -0800 | [diff] [blame] | 1668 | IGMPTestState(groups = groups2, df = df) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1669 | mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac, |
| 1670 | src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1) |
| 1671 | mcastTraffic1.start() |
| 1672 | join_state1 = IGMPTestState(groups = groups2) |
ChetanGaonker | b99538a | 2016-12-02 13:53:35 -0800 | [diff] [blame] | 1673 | self.igmp_recv_task(self.V_INF1, groups2, join_state1) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1674 | log_test.info('Interface is receiving traffic from multicast groups %s' %groups2) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1675 | self.igmp_send_joins_different_groups_srclist_wait_query_packets(groups, |
| 1676 | (['6.6.6.6', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '7.7.7.7']), |
| 1677 | intf = self.V_INF1, delay = 2, query_group1 = 'group1', query_group2 = None) |
| 1678 | target2 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1) |
| 1679 | assert target2 == 1, 'EXPECTED FAILURE' |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1680 | log_test.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] | 1681 | mcastTraffic1.stop() |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1682 | |
| 1683 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+90) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1684 | 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] | 1685 | df = defer.Deferred() |
| 1686 | def igmp_block_old_src_list_check_for_group_source_specific_query(): |
| 1687 | self.igmp_block_old_src_list_check_for_group_source_specific_query(df = df) |
| 1688 | df.callback(0) |
| 1689 | reactor.callLater(0, igmp_block_old_src_list_check_for_group_source_specific_query) |
| 1690 | return df |
| 1691 | |
| 1692 | def igmp_include_to_allow_src_list_check_for_general_query(self, df = None): |
| 1693 | groups1 = (self.MGROUP1,) |
| 1694 | groups2 = (self.MGROUP2,) |
| 1695 | self.igmp_send_joins_different_groups_srclist(groups1 + groups2, |
| 1696 | (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']), |
| 1697 | intf = self.V_INF1, delay = 2) |
| 1698 | dst_mac = '01:00:5e:01:02:03' |
| 1699 | src_ip = '2.2.2.2' |
| 1700 | if df is None: |
| 1701 | df = defer.Deferred() |
| 1702 | igmpState1 = IGMPTestState(groups = groups1, df = df) |
ChetanGaonker | b99538a | 2016-12-02 13:53:35 -0800 | [diff] [blame] | 1703 | IGMPTestState(groups = groups1, df = df) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1704 | mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac, |
| 1705 | src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1) |
| 1706 | mcastTraffic1.start() |
| 1707 | join_state1 = IGMPTestState(groups = groups1) |
ChetanGaonker | b99538a | 2016-12-02 13:53:35 -0800 | [diff] [blame] | 1708 | self.igmp_recv_task(self.V_INF1, groups1, join_state1) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1709 | 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) |
ChetanGaonker | b99538a | 2016-12-02 13:53:35 -0800 | [diff] [blame] | 1710 | self.igmp_recv_task(self.V_INF1, groups1, join_state1) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1711 | mcastTraffic1.stop() |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1712 | |
| 1713 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+40) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1714 | 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] | 1715 | df = defer.Deferred() |
| 1716 | def igmp_include_to_allow_src_list_check_for_general_query(): |
| 1717 | self.igmp_include_to_allow_src_list_check_for_general_query(df = df) |
| 1718 | df.callback(0) |
| 1719 | reactor.callLater(0, igmp_include_to_allow_src_list_check_for_general_query) |
| 1720 | return df |
| 1721 | |
| 1722 | def igmp_include_to_block_src_list_check_for_group_source_specific_query(self, df = None): |
| 1723 | groups1 = (self.MGROUP1,) |
| 1724 | groups2 = (self.MGROUP2,) |
| 1725 | self.igmp_send_joins_different_groups_srclist(groups1 + groups2, |
| 1726 | (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']), |
| 1727 | intf = self.V_INF1, delay = 2) |
| 1728 | dst_mac = '01:00:5e:01:02:03' |
| 1729 | src_ip = '2.2.2.2' |
| 1730 | if df is None: |
| 1731 | df = defer.Deferred() |
| 1732 | igmpState1 = IGMPTestState(groups = groups1, df = df) |
ChetanGaonker | b99538a | 2016-12-02 13:53:35 -0800 | [diff] [blame] | 1733 | IGMPTestState(groups = groups1, df = df) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1734 | mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac, |
| 1735 | src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1) |
| 1736 | mcastTraffic1.start() |
| 1737 | join_state1 = IGMPTestState(groups = groups1) |
ChetanGaonker | b99538a | 2016-12-02 13:53:35 -0800 | [diff] [blame] | 1738 | self.igmp_recv_task(self.V_INF1, groups1, join_state1) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1739 | self.send_igmp_leave_listening_group_specific_query(groups = groups1, src_list = ['6.6.6.6','7.7.7.7'], |
| 1740 | iface = self.V_INF1, delay = 2) |
ChetanGaonker | b99538a | 2016-12-02 13:53:35 -0800 | [diff] [blame] | 1741 | self.igmp_recv_task(self.V_INF1, groups1, join_state1) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1742 | mcastTraffic1.stop() |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1743 | |
| 1744 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+40) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1745 | 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] | 1746 | df = defer.Deferred() |
| 1747 | def igmp_include_to_block_src_list_check_for_group_source_specific_query(): |
| 1748 | self.igmp_include_to_block_src_list_check_for_group_source_specific_query(df = df) |
| 1749 | df.callback(0) |
| 1750 | reactor.callLater(0, igmp_include_to_block_src_list_check_for_group_source_specific_query) |
| 1751 | return df |
| 1752 | |
| 1753 | def igmp_exclude_to_allow_src_list_check_for_general_query(self, df = None): |
| 1754 | groups1 = (self.MGROUP1,) |
| 1755 | groups2 = (self.MGROUP2,) |
| 1756 | self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4'], |
| 1757 | iface = self.V_INF1, delay = 2) |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 1758 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1759 | dst_mac = '01:00:5e:01:02:03' |
| 1760 | src_ip = '2.2.2.2' |
| 1761 | if df is None: |
| 1762 | df = defer.Deferred() |
| 1763 | igmpState1 = IGMPTestState(groups = groups1, df = df) |
ChetanGaonker | b99538a | 2016-12-02 13:53:35 -0800 | [diff] [blame] | 1764 | IGMPTestState(groups = groups1, df = df) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1765 | mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac, |
| 1766 | src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1) |
| 1767 | mcastTraffic1.start() |
| 1768 | join_state1 = IGMPTestState(groups = groups1) |
| 1769 | target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1) |
| 1770 | assert target1 == 1, 'EXPECTED FAILURE' |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1771 | log_test.info('Interface is not receiving traffic from multicast groups %s' %groups1) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1772 | self.igmp_send_joins_different_groups_srclist_wait_query_packets(groups1 + groups2, |
| 1773 | (['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) |
| 1774 | target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1) |
| 1775 | assert target1 == 1, 'EXPECTED FAILURE' |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1776 | log_test.info('Interface is not receiving traffic from multicast groups %s' %groups1) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1777 | mcastTraffic1.stop() |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 1778 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1779 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+90) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1780 | 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] | 1781 | df = defer.Deferred() |
| 1782 | def igmp_exclude_to_allow_src_list_check_for_general_query(): |
| 1783 | self.igmp_exclude_to_allow_src_list_check_for_general_query(df = df) |
| 1784 | df.callback(0) |
| 1785 | reactor.callLater(0, igmp_exclude_to_allow_src_list_check_for_general_query) |
| 1786 | return df |
| 1787 | |
| 1788 | def igmp_exclude_to_block_src_list_check_for_group_source_specific_query(self, df = None): |
| 1789 | groups1 = (self.MGROUP1,) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1790 | self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4'], |
| 1791 | iface = self.V_INF1, delay = 2) |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 1792 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1793 | dst_mac = '01:00:5e:01:02:03' |
| 1794 | src_ip = '2.2.2.2' |
| 1795 | if df is None: |
| 1796 | df = defer.Deferred() |
| 1797 | igmpState1 = IGMPTestState(groups = groups1, df = df) |
ChetanGaonker | b99538a | 2016-12-02 13:53:35 -0800 | [diff] [blame] | 1798 | IGMPTestState(groups = groups1, df = df) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1799 | mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac, |
| 1800 | src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1) |
| 1801 | mcastTraffic1.start() |
| 1802 | join_state1 = IGMPTestState(groups = groups1) |
| 1803 | target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1) |
| 1804 | assert target1 == 1, 'EXPECTED FAILURE' |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1805 | log_test.info('Interface is not receiving traffic from multicast groups %s' %groups1) |
A.R Karthick | 95d044e | 2016-06-10 18:44:36 -0700 | [diff] [blame] | 1806 | self.send_igmp_leave_listening_group_specific_query(groups = groups1, |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1807 | src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4', '5.5.5.5', '7.7.7.7'], |
| 1808 | iface = self.V_INF1, delay = 2) |
| 1809 | target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1) |
| 1810 | assert target1 == 1, 'EXPECTED FAILURE' |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1811 | log_test.info('Interface is not receiving traffic from multicast groups %s' %groups1) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1812 | mcastTraffic1.stop() |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1813 | |
| 1814 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+40) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1815 | 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] | 1816 | df = defer.Deferred() |
| 1817 | def igmp_exclude_to_block_src_list_check_for_group_source_specific_query(): |
| 1818 | self.igmp_exclude_to_block_src_list_check_for_group_source_specific_query(df = df) |
| 1819 | df.callback(0) |
| 1820 | reactor.callLater(0, igmp_exclude_to_block_src_list_check_for_group_source_specific_query) |
| 1821 | return df |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1822 | |
| 1823 | def iptomac(self, mcast_ip): |
| 1824 | mcast_mac = '01:00:5e:' |
| 1825 | octets = mcast_ip.split('.') |
| 1826 | second_oct = int(octets[1]) & 127 |
| 1827 | third_oct = int(octets[2]) |
| 1828 | fourth_oct = int(octets[3]) |
| 1829 | mcast_mac = mcast_mac + format(second_oct,'02x') + ':' + format(third_oct, '02x') + ':' + format(fourth_oct, '02x') |
| 1830 | return mcast_mac |
| 1831 | |
| 1832 | def send_multicast_data_traffic(self, group, intf= 'veth2',source = '1.2.3.4'): |
| 1833 | dst_mac = self.iptomac(group) |
| 1834 | eth = Ether(dst= dst_mac) |
| 1835 | ip = IP(dst=group,src=source) |
| 1836 | data = repr(monotonic.monotonic()) |
| 1837 | sendp(eth/ip/data,count=20, iface = intf) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1838 | |
| 1839 | def verify_igmp_data_traffic(self, group, intf='veth0', source='1.2.3.4' ): |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1840 | log_test.info('verifying multicast traffic for group %s from source %s'%(group,source)) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1841 | self.success = False |
| 1842 | def recv_task(): |
| 1843 | def igmp_recv_cb(pkt): |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1844 | #log_test.info('received multicast data packet is %s'%pkt.show()) |
| 1845 | log_test.info('multicast data received for group %s from source %s'%(group,source)) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1846 | self.success = True |
| 1847 | 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') |
| 1848 | t = threading.Thread(target = recv_task) |
| 1849 | t.start() |
| 1850 | self.send_multicast_data_traffic(group,source=source) |
| 1851 | t.join() |
| 1852 | return self.success |
| 1853 | |
| 1854 | def test_igmp_include_exclude_modes(self): |
| 1855 | groups = ['224.2.3.4','230.5.6.7'] |
| 1856 | src_list = ['2.2.2.2','3.3.3.3'] |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1857 | self.onos_ssm_table_load(groups, src_list=src_list) |
| 1858 | self.send_igmp_join(groups = [groups[0]], src_list = src_list,record_type = IGMP_V3_GR_TYPE_INCLUDE, |
| 1859 | iface = self.V_INF1, delay = 2) |
| 1860 | self.send_igmp_join(groups = [groups[1]], src_list = src_list,record_type = IGMP_V3_GR_TYPE_EXCLUDE, |
| 1861 | iface = self.V_INF1, delay = 2) |
| 1862 | status = self.verify_igmp_data_traffic(groups[0],intf=self.V_INF1,source=src_list[0]) |
| 1863 | assert_equal(status,True) |
| 1864 | status = self.verify_igmp_data_traffic(groups[1],intf = self.V_INF1,source= src_list[1]) |
| 1865 | assert_equal(status,False) |
| 1866 | |
| 1867 | def test_igmp_allow_new_source_mode(self): |
| 1868 | group = ['224.8.9.3'] |
| 1869 | src_list = ['2.2.2.2','3.3.3.3'] |
| 1870 | #dst_mac = self.iptomac(group[0]) |
| 1871 | self.onos_ssm_table_load(group, src_list) |
| 1872 | self.send_igmp_join(groups = group, src_list = src_list[0],record_type = IGMP_V3_GR_TYPE_INCLUDE, |
| 1873 | iface = self.V_INF1, delay = 1) |
| 1874 | status = self.verify_igmp_data_traffic(group[0], intf=self.V_INF1,source = src_list[0]) |
| 1875 | assert_equal(status,True) # expecting igmp data traffic from source src_list[0] |
| 1876 | self.send_igmp_join(groups = group, src_list = src_list[1],record_type = IGMP_V3_GR_TYPE_ALLOW_NEW, |
| 1877 | iface = self.V_INF1, delay = 1) |
| 1878 | for src in src_list: |
| 1879 | status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1, source=src) |
| 1880 | assert_equal(status,True) # expecting igmp data traffic from both sources |
| 1881 | |
| 1882 | |
| 1883 | def test_igmp_include_to_exclude_mode_change(self): |
| 1884 | group = ['224.2.3.4'] |
| 1885 | src_list = ['2.2.2.2','3.3.3.3'] |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1886 | self.onos_ssm_table_load(group, src_list) |
| 1887 | self.send_igmp_join(groups = group, src_list = src_list[0],record_type = IGMP_V3_GR_TYPE_INCLUDE, |
| 1888 | iface = self.V_INF1, delay = 1) |
| 1889 | status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source= src_list[0]) |
| 1890 | assert_equal(status,True) # expecting igmp data traffic from source src_list[0] |
| 1891 | self.send_igmp_join(groups = group, src_list = src_list[1],record_type = IGMP_V3_GR_TYPE_EXCLUDE, |
| 1892 | iface = self.V_INF1, delay = 1) |
| 1893 | for src in src_list: |
| 1894 | status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source= src) |
| 1895 | assert_equal(status,False) # expecting igmp data traffic from both sources |
| 1896 | |
| 1897 | def test_igmp_exclude_to_include_mode_change(self): |
| 1898 | group = ['224.2.3.4'] |
| 1899 | src = ['2.2.2.2'] |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1900 | self.onos_ssm_table_load(group, src) |
| 1901 | self.send_igmp_join(groups = group, src_list = src,record_type = IGMP_V3_GR_TYPE_EXCLUDE, |
| 1902 | iface = self.V_INF1, delay = 1) |
| 1903 | status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source=src[0]) |
| 1904 | assert_equal(status,False) # not expecting igmp data traffic from source src_list[0] |
| 1905 | self.send_igmp_join(groups = group, src_list = src,record_type = IGMP_V3_GR_TYPE_INCLUDE, |
| 1906 | iface = self.V_INF1, delay = 1) |
| 1907 | status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source = src[0]) |
| 1908 | assert_equal(status,True) # expecting igmp data traffic from both sources |
| 1909 | |
| 1910 | #this test case wotks properly if the snooping device(ONOS) have multicast router connected. |
| 1911 | def test_igmp_to_include_mode_with_null_source(self): |
| 1912 | groups = ['224.2.3.4','230.7.9.8'] |
| 1913 | src = ['192.168.12.34'] |
| 1914 | dst_mac = [] |
| 1915 | dst_mac.append(self.iptomac(groups[0])) |
| 1916 | dst_mac.append(self.iptomac(groups[1])) |
| 1917 | self.onos_ssm_table_load(groups, src) |
| 1918 | self.send_igmp_join(groups = groups, src_list = src,record_type = IGMP_V3_GR_TYPE_INCLUDE, |
| 1919 | iface = self.V_INF1, delay = 1) |
| 1920 | for grp in groups: |
| 1921 | status = self.verify_igmp_data_traffic(grp,intf=self.V_INF1,source= src[0]) |
| 1922 | assert_equal(status,True) # not expecting igmp data traffic from source src_list[0] |
| 1923 | #sending leave packet for group groups[1] |
| 1924 | self.send_igmp_join(groups = [groups[1]], src_list = [],record_type = IGMP_V3_GR_TYPE_CHANGE_TO_INCLUDE, |
| 1925 | iface = self.V_INF1, delay = 1) |
| 1926 | for grp in groups: |
| 1927 | status = self.verify_igmp_data_traffic(grp,intf=self.V_INF1,source= src[0]) |
| 1928 | if grp is groups[0]: |
| 1929 | assert_equal(status,True) # expecting igmp data traffic to group groups[0] |
| 1930 | else: |
| 1931 | assert_equal(status,False) # not expecting igmp data traffic to group groups[1] |
| 1932 | |
| 1933 | def test_igmp_to_include_mode(self): |
| 1934 | group = ['229.9.3.6'] |
| 1935 | src_list = ['192.168.12.34','192.18.1.34'] |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1936 | self.onos_ssm_table_load(group, src_list) |
| 1937 | self.send_igmp_join(groups = group, src_list = [src_list[0]],record_type = IGMP_V3_GR_TYPE_INCLUDE, |
| 1938 | iface = self.V_INF1, delay = 1) |
| 1939 | status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source=src_list[0]) |
| 1940 | assert_equal(status,True) # not expecting igmp data traffic from source src_list[0] |
| 1941 | self.send_igmp_join(groups = group, src_list = src_list,record_type = IGMP_V3_GR_TYPE_CHANGE_TO_INCLUDE, |
| 1942 | iface = self.V_INF1, delay = 1) |
| 1943 | for src in src_list: |
| 1944 | status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source= src) |
| 1945 | assert_equal(status,True) # expecting igmp data traffic to group groups[0] |
| 1946 | |
| 1947 | #this test case passed only if mulitcast router connected to ONOS. |
| 1948 | def test_igmp_blocking_old_source_mode(self): |
| 1949 | group = ['224.2.3.4'] |
| 1950 | src_list = ['2.2.2.2','3.3.3.3'] |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1951 | self.onos_ssm_table_load(group, src_list) |
| 1952 | self.send_igmp_join(groups = group, src_list = src_list,record_type = IGMP_V3_GR_TYPE_INCLUDE, |
| 1953 | iface = self.V_INF1, delay = 1) |
| 1954 | for src in src_list: |
| 1955 | status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1, source=src) |
| 1956 | assert_equal(status,True) # expecting igmp data traffic from source src_list[0] |
| 1957 | self.send_igmp_join(groups = group, src_list = [src_list[1]],record_type = IGMP_V3_GR_TYPE_BLOCK_OLD, |
| 1958 | iface = self.V_INF1, delay = 1) |
| 1959 | for src in src_list: |
| 1960 | status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1, source=src) |
| 1961 | if src is src_list[0]: |
| 1962 | assert_equal(status,True) # expecting igmp data traffic from source src_list[0] |
| 1963 | else: |
| 1964 | assert_equal(status,False) # not expecting igmp data traffic from source src_list[1] |
| 1965 | |
| 1966 | def test_igmp_multiple_joins_and_data_verification_with_100_groups(self): |
| 1967 | groups = [] |
| 1968 | sources = [] |
| 1969 | count = 1 |
| 1970 | mcastips = self.mcast_ip_range(start_ip = '226.0.0.1',end_ip = '226.0.5.254') |
| 1971 | sourceips = self.source_ip_range(start_ip = '10.10.0.1',end_ip = '10.10.5.254') |
| 1972 | while count<=100: |
| 1973 | group = random.choice(mcastips) |
| 1974 | source = random.choice(sourceips) |
| 1975 | if group in groups: |
| 1976 | pass |
| 1977 | else: |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1978 | log_test.info('group and source are %s and %s'%(group,source)) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1979 | groups.append(group) |
| 1980 | sources.append(source) |
| 1981 | count += 1 |
| 1982 | self.onos_ssm_table_load(groups,src_list=sources,flag=True) |
| 1983 | for i in range(100): |
| 1984 | self.send_igmp_join(groups = [groups[i]], src_list = [sources[i]],record_type = IGMP_V3_GR_TYPE_INCLUDE, |
| 1985 | iface = self.V_INF1) |
| 1986 | status = self.verify_igmp_data_traffic(groups[i],intf=self.V_INF1,source=sources[i]) |
| 1987 | assert_equal(status, True) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1988 | log_test.info('data received for group %s from source %s'%(groups[i],sources[i])) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 1989 | |
| 1990 | def test_igmp_multiple_joins_with_data_verification_and_leaving_100_groups(self): |
| 1991 | groups = [] |
| 1992 | sources = [] |
| 1993 | count = 1 |
| 1994 | mcastips = self.mcast_ip_range(start_ip = '226.0.0.1',end_ip = '226.0.5.254') |
| 1995 | sourceips = self.source_ip_range(start_ip = '10.10.0.1',end_ip = '10.10.5.254') |
| 1996 | while count<=100: |
| 1997 | group = random.choice(mcastips) |
| 1998 | source = random.choice(sourceips) |
| 1999 | if group in groups: |
| 2000 | pass |
| 2001 | else: |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 2002 | log_test.info('group and source are %s and %s'%(group,source)) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 2003 | groups.append(group) |
| 2004 | sources.append(source) |
| 2005 | count += 1 |
| 2006 | self.onos_ssm_table_load(groups,src_list=sources,flag=True) |
| 2007 | for i in range(100): |
| 2008 | self.send_igmp_join(groups = [groups[i]], src_list = [sources[i]],record_type = IGMP_V3_GR_TYPE_INCLUDE, |
| 2009 | iface = self.V_INF1) |
| 2010 | status = self.verify_igmp_data_traffic(groups[i],intf=self.V_INF1,source=sources[i]) |
| 2011 | assert_equal(status, True) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 2012 | log_test.info('data received for group %s from source %s'%(groups[i],sources[i])) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 2013 | self.send_igmp_join(groups = [groups[i]], src_list = [sources[i]],record_type = IGMP_V3_GR_TYPE_CHANGE_TO_EXCLUDE, |
| 2014 | iface = self.V_INF1, delay = 1) |
| 2015 | status = self.verify_igmp_data_traffic(groups[i],intf=self.V_INF1,source=sources[i]) |
| 2016 | assert_equal(status, False) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 2017 | log_test.info("data not received for group %s from source %s after changing group mode to 'TO-EXCLUDE' mode"%(groups[i],sources[i])) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 2018 | |
| 2019 | def test_igmp_group_source_for_only_config_with_1000_entries(self): |
| 2020 | groups = [] |
| 2021 | sources = [] |
| 2022 | count = 1 |
| 2023 | mcastips = self.mcast_ip_range(start_ip = '229.0.0.1',end_ip = '229.0.50.254') |
| 2024 | sourceips = self.source_ip_range(start_ip = '10.10.0.1',end_ip = '10.10.50.254') |
| 2025 | while count<=1000: |
| 2026 | group = random.choice(mcastips) |
| 2027 | source = random.choice(sourceips) |
| 2028 | if group in groups: |
| 2029 | pass |
| 2030 | else: |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 2031 | log_test.info('group and source are %s and %s'%(group,source)) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 2032 | groups.append(group) |
| 2033 | sources.append(source) |
| 2034 | count += 1 |
| 2035 | self.onos_ssm_table_load(groups,src_list=sources,flag=True) |
| 2036 | |
| 2037 | def test_igmp_from_exclude_to_include_mode_with_100_groups(self): |
| 2038 | groups = [] |
| 2039 | sources = [] |
| 2040 | count = 1 |
| 2041 | mcastips = self.mcast_ip_range(start_ip = '229.0.0.1',end_ip = '229.0.10.254') |
| 2042 | sourceips = self.source_ip_range(start_ip = '10.10.0.1',end_ip = '10.10.10.254') |
| 2043 | while count<=100: |
| 2044 | group = random.choice(mcastips) |
| 2045 | source = random.choice(sourceips) |
| 2046 | if group in groups: |
| 2047 | pass |
| 2048 | else: |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 2049 | log_test.info('group and source are %s and %s'%(group,source)) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 2050 | groups.append(group) |
| 2051 | sources.append(source) |
| 2052 | count += 1 |
| 2053 | self.onos_ssm_table_load(groups,src_list=sources,flag=True) |
| 2054 | for i in range(100): |
| 2055 | self.send_igmp_join(groups = [groups[i]], src_list = [sources[i]],record_type = IGMP_V3_GR_TYPE_EXCLUDE, |
| 2056 | iface = self.V_INF1) |
| 2057 | status = self.verify_igmp_data_traffic(groups[i],intf=self.V_INF1,source=sources[i]) |
| 2058 | assert_equal(status, False) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 2059 | log_test.info('data not received for group %s from source %s as expected'%(groups[i],sources[i])) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 2060 | self.send_igmp_join(groups = [groups[i]], src_list = [sources[i]],record_type = IGMP_V3_GR_TYPE_INCLUDE, |
| 2061 | iface = self.V_INF1) |
| 2062 | status = self.verify_igmp_data_traffic(groups[i],intf=self.V_INF1,source=sources[i]) |
| 2063 | assert_equal(status, True) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 2064 | log_test.info("data received for group %s from source %s after changing group mode to 'TO-INCLUDE' mode"%(groups[i],sources[i])) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 2065 | |
| 2066 | def test_igmp_with_multiple_joins_and_data_verify_with_1000_groups(self): |
| 2067 | groups = [] |
| 2068 | sources = [] |
| 2069 | count = 1 |
| 2070 | mcastips = self.mcast_ip_range(start_ip = '229.0.0.1',end_ip = '229.0.30.254') |
| 2071 | sourceips = self.source_ip_range(start_ip = '10.10.0.1',end_ip = '10.10.30.254') |
| 2072 | while count<=1000: |
| 2073 | group = random.choice(mcastips) |
| 2074 | source = random.choice(sourceips) |
| 2075 | if group in groups: |
| 2076 | pass |
| 2077 | else: |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 2078 | log_test.info('group and source are %s and %s'%(group,source)) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 2079 | groups.append(group) |
| 2080 | sources.append(source) |
| 2081 | count += 1 |
| 2082 | self.onos_ssm_table_load(groups,src_list=sources,flag=True) |
| 2083 | for i in range(1000): |
| 2084 | self.send_igmp_join(groups = [groups[i]], src_list = [sources[i]],record_type = IGMP_V3_GR_TYPE_INCLUDE, |
| 2085 | iface = self.V_INF1) |
| 2086 | status = self.verify_igmp_data_traffic(groups[i],intf=self.V_INF1,source=sources[i]) |
| 2087 | assert_equal(status, True) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 2088 | log_test.info('data received for group %s from source %s - %d'%(groups[i],sources[i],i)) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 2089 | |
| 2090 | def test_igmp_with_multiple_joins_and_data_verify_with_5000_groups(self): |
| 2091 | groups = [] |
| 2092 | sources = [] |
| 2093 | count = 1 |
| 2094 | mcastips = self.mcast_ip_range(start_ip = '231.39.19.121',end_ip = '231.40.30.25') |
| 2095 | sourceips = self.source_ip_range(start_ip = '192.168.56.43',end_ip = '192.169.110.30') |
| 2096 | while count<=5000: |
| 2097 | group = random.choice(mcastips) |
| 2098 | source = random.choice(sourceips) |
| 2099 | if group in groups: |
| 2100 | pass |
| 2101 | else: |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 2102 | log_test.info('group and source are %s and %s'%(group,source)) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 2103 | groups.append(group) |
| 2104 | sources.append(source) |
| 2105 | count += 1 |
| 2106 | self.onos_ssm_table_load(groups,src_list=sources,flag=True) |
| 2107 | for i in range(5000): |
| 2108 | self.send_igmp_join(groups = [groups[i]], src_list = [sources[i]],record_type = IGMP_V3_GR_TYPE_INCLUDE, |
| 2109 | iface = self.V_INF1) |
| 2110 | status = self.verify_igmp_data_traffic(groups[i],intf=self.V_INF1,source=sources[i]) |
| 2111 | assert_equal(status, True) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 2112 | log_test.info('data received for group %s from source %s - %d'%(groups[i],sources[i],i)) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 2113 | |
| 2114 | """def test_igmp_join_from_multiple_infts(self): |
| 2115 | groups = ['229.9.3.6','234.20.56.2'] |
| 2116 | src_list = ['192.168.12.34','192.18.1.34'] |
| 2117 | self.onos_ssm_table_load(groups, src_list=src_list) |
| 2118 | self.send_igmp_join(groups = [groups[0]], src_list = src_list,record_type = IGMP_V3_GR_TYPE_INCLUDE, |
| 2119 | iface = 'veth0') |
| 2120 | self.send_igmp_join(groups = [groups[1]], src_list = src_list,record_type = IGMP_V3_GR_TYPE_INCLUDE, |
| 2121 | iface = 'veth2') |
| 2122 | status = self.verify_igmp_data_traffic(groups[0],intf='veth0',source=src_list[0]) |
| 2123 | assert_equal(status,True) |
| 2124 | status = self.verify_igmp_data_traffic(groups[1],intf='veth2',source=src_list[1]) |
| 2125 | assert_equal(status,True) # not expecting igmp data traffic from source src_list[0] |
| 2126 | """ |
| 2127 | |
| 2128 | def test_igmp_send_data_to_non_registered_group(self): |
| 2129 | group = ['224.2.3.4'] |
| 2130 | src = ['2.2.2.2'] |
| 2131 | self.onos_ssm_table_load(group,src_list= src) |
| 2132 | self.send_igmp_join(groups = ['239.0.0.1'], src_list = src,record_type = IGMP_V3_GR_TYPE_INCLUDE, |
| 2133 | iface = self.V_INF1, delay = 1) |
| 2134 | status = self.verify_igmp_data_traffic('239.0.0.1',intf=self.V_INF1,source=src[0]) |
| 2135 | assert_equal(status,False) # not expecting igmp data traffic from source src_list[0] |
| 2136 | |
| 2137 | def test_igmp_traffic_verification_for_registered_group_with_no_join_sent(self): |
| 2138 | group = ['227.12.3.40'] |
| 2139 | src = ['190.4.19.67'] |
| 2140 | self.onos_ssm_table_load(group,src_list= src) |
| 2141 | status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source=src[0]) |
| 2142 | assert_equal(status,False) # not expecting igmp data traffic from source src_list[0] |
| 2143 | |
| 2144 | def test_igmp_toggling_app_activation(self): |
| 2145 | group = [self.random_mcast_ip()] |
| 2146 | src = [self.randomsourceip()] |
| 2147 | self.onos_ssm_table_load(group,src_list= src) |
| 2148 | self.send_igmp_join(groups = group, src_list = src,record_type = IGMP_V3_GR_TYPE_INCLUDE, |
| 2149 | iface = self.V_INF1) |
| 2150 | status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source=src[0]) |
| 2151 | assert_equal(status,True) # expecting igmp data traffic from source src_list[0] |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 2152 | log_test.info('Multicast traffic received for group %s from source %s before the app is deactivated'%(group[0],src[0])) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 2153 | self.onos_ctrl.deactivate() |
| 2154 | status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source=src[0]) |
| 2155 | assert_equal(status,False) #not expecting igmp data traffic from source src_list[0] |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 2156 | log_test.info('Multicast traffic not received for group %s from source %s after the app is deactivated'%(group[0],src[0])) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 2157 | self.onos_ctrl.activate() |
| 2158 | status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source=src[0]) |
| 2159 | assert_equal(status,True) # expecting igmp data traffic from source src_list[0] |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 2160 | log_test.info('Multicast traffic received for group %s from source %s the app is re-activated'%(group[0],src[0])) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 2161 | |
| 2162 | def test_igmp_with_mismatch_for_dst_ip_and_mac_in_data_packets(self): |
| 2163 | group = ['228.18.19.29'] |
| 2164 | source = [self.randomsourceip()] |
| 2165 | self.onos_ssm_table_load(group,src_list= source) |
| 2166 | self.send_igmp_join(groups = group, src_list = source,record_type = IGMP_V3_GR_TYPE_INCLUDE, |
| 2167 | iface = self.V_INF1) |
| 2168 | dst_mac = '01:00:5e:0A:12:09' |
| 2169 | eth = Ether(dst= dst_mac) |
| 2170 | ip = IP(dst=group[0],src=source[0]) |
| 2171 | data = repr(monotonic.monotonic()) |
| 2172 | pkt = (eth/ip/data) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 2173 | log_test.info('Multicast traffic packet %s'%pkt.show()) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 2174 | self.success = False |
| 2175 | def recv_task(): |
| 2176 | def igmp_recv_cb(pkt): |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 2177 | #log_test.info('received multicast data packet is %s'%pkt.show()) |
| 2178 | log_test.info('multicast data received for group %s from source %s'%(group[0],source[0])) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 2179 | self.success = True |
| 2180 | 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') |
| 2181 | t = threading.Thread(target = recv_task) |
| 2182 | t.start() |
| 2183 | sendp(eth/ip/data,count=20, iface = 'veth2') |
| 2184 | t.join() |
| 2185 | assert_equal(status,False) # not expecting igmp data traffic from source src_list[0] |
| 2186 | |
| 2187 | #test case failing, ONOS registering unicast ip also as an igmp join |
| 2188 | def test_igmp_registering_invalid_group(self): |
ChetanGaonker | b99538a | 2016-12-02 13:53:35 -0800 | [diff] [blame] | 2189 | groups = ['218.18.19.29'] |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 2190 | source = [self.randomsourceip()] |
A.R Karthick | 401a1ed | 2017-05-18 11:08:27 -0700 | [diff] [blame] | 2191 | ssm_dict = {'apps' : { 'org.opencord.igmp' : { 'ssmTranslate' : [] } } } |
| 2192 | ssm_xlate_list = ssm_dict['apps']['org.opencord.igmp']['ssmTranslate'] |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 2193 | for g in groups: |
| 2194 | for s in source: |
| 2195 | d = {} |
| 2196 | d['source'] = s or '0.0.0.0' |
| 2197 | d['group'] = g |
| 2198 | ssm_xlate_list.append(d) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 2199 | log_test.info('onos load config is %s'%ssm_dict) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 2200 | status, code = OnosCtrl.config(ssm_dict) |
ChetanGaonker | b99538a | 2016-12-02 13:53:35 -0800 | [diff] [blame] | 2201 | self.send_igmp_join(groups, src_list = source, record_type = IGMP_V3_GR_TYPE_INCLUDE, |
| 2202 | iface = self.V_INF1, delay = 1) |
| 2203 | status = self.verify_igmp_data_traffic(groups[0],intf=self.V_INF1, source=source[0]) |
| 2204 | assert_equal(status,False) # not expecting igmp data traffic from source src_list[0] |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 2205 | |
| 2206 | def test_igmp_registering_invalid_source(self): |
| 2207 | groups = [self.random_mcast_ip()] |
| 2208 | sources = ['224.10.28.34','193.73.219.257'] |
A.R Karthick | 401a1ed | 2017-05-18 11:08:27 -0700 | [diff] [blame] | 2209 | ssm_dict = {'apps' : { 'org.opencord.igmp' : { 'ssmTranslate' : [] } } } |
| 2210 | ssm_xlate_list = ssm_dict['apps']['org.opencord.igmp']['ssmTranslate'] |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 2211 | for g in groups: |
| 2212 | for s in sources: |
| 2213 | d = {} |
| 2214 | d['source'] = s or '0.0.0.0' |
| 2215 | d['group'] = g |
| 2216 | ssm_xlate_list.append(d) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 2217 | log_test.info('onos load config is %s'%ssm_dict) |
ChetanGaonker | a7e2b41 | 2016-09-01 23:19:07 -0700 | [diff] [blame] | 2218 | status, code = OnosCtrl.config(ssm_dict) |
| 2219 | assert_equal(status,False) |