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