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