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