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