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