Chetan Gaonker | cfcce78 | 2016-05-10 10:10:42 -0700 | [diff] [blame] | 1 | # |
| 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 |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 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 |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 32 | log.setLevel('INFO') |
Chetan Gaonker | 2547097 | 2016-02-26 08:52:15 -0800 | [diff] [blame] | 33 | |
| 34 | class IGMPTestState: |
| 35 | |
| 36 | def __init__(self, groups = [], df = None, state = 0): |
| 37 | self.df = df |
| 38 | self.state = state |
| 39 | self.counter = 0 |
| 40 | self.groups = groups |
| 41 | self.group_map = {} ##create a send/recv count map |
| 42 | for g in groups: |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 43 | self.group_map[g] = (Stats(), Stats()) |
| 44 | |
| 45 | def update(self, group, tx = 0, rx = 0, t = 0): |
| 46 | self.counter += 1 |
Chetan Gaonker | 2547097 | 2016-02-26 08:52:15 -0800 | [diff] [blame] | 47 | index = 0 if rx == 0 else 1 |
| 48 | v = tx if rx == 0 else rx |
| 49 | if self.group_map.has_key(group): |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 50 | self.group_map[group][index].update(packets = v, t = t) |
Chetan Gaonker | 2547097 | 2016-02-26 08:52:15 -0800 | [diff] [blame] | 51 | |
| 52 | def update_state(self): |
| 53 | self.state = self.state ^ 1 |
Chetan Gaonker | 2547097 | 2016-02-26 08:52:15 -0800 | [diff] [blame] | 54 | |
| 55 | class igmp_exchange(unittest.TestCase): |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 56 | |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 57 | V_INF1 = 'veth0' |
| 58 | V_INF2 = 'veth1' |
| 59 | MGROUP1 = '239.1.2.3' |
| 60 | MGROUP2 = '239.2.2.3' |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 61 | MINVALIDGROUP1 = '255.255.255.255' |
| 62 | MINVALIDGROUP2 = '239.255.255.255' |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 63 | MMACGROUP1 = "01:00:5e:01:02:03" |
| 64 | MMACGROUP2 = "01:00:5e:02:02:03" |
| 65 | IGMP_DST_MAC = "01:00:5e:00:01:01" |
| 66 | IGMP_SRC_MAC = "5a:e1:ac:ec:4d:a1" |
| 67 | IP_SRC = '1.2.3.4' |
| 68 | IP_DST = '224.0.1.1' |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 69 | NEGATIVE_TRAFFIC_STATUS = 1 |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 70 | igmp_eth = Ether(dst = IGMP_DST_MAC, src = IGMP_SRC_MAC, type = ETH_P_IP) |
| 71 | igmp_ip = IP(dst = IP_DST, src = IP_SRC) |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 72 | IGMP_TEST_TIMEOUT = 5 |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 73 | IGMP_QUERY_TIMEOUT = 60 |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 74 | MCAST_TRAFFIC_TIMEOUT = 10 |
Chetan Gaonker | 4eb1207 | 2016-03-28 15:04:15 -0700 | [diff] [blame] | 75 | PORT_TX_DEFAULT = 2 |
| 76 | PORT_RX_DEFAULT = 1 |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 77 | max_packets = 100 |
Chetan Gaonker | 4a25e2b | 2016-03-04 14:45:15 -0800 | [diff] [blame] | 78 | app = 'org.onosproject.igmp' |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 79 | olt_conf_file = os.path.join(os.path.dirname(os.path.realpath(__file__)), '../setup/olt_config.json') |
Chetan Gaonker | 4a25e2b | 2016-03-04 14:45:15 -0800 | [diff] [blame] | 80 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 81 | @classmethod |
| 82 | def setUpClass(cls): |
| 83 | cls.olt = OltConfig(olt_conf_file = cls.olt_conf_file) |
| 84 | OnosCtrl.cord_olt_config(cls.olt.olt_device_data()) |
| 85 | |
| 86 | @classmethod |
| 87 | def tearDownClass(cls): pass |
| 88 | |
Chetan Gaonker | 4a25e2b | 2016-03-04 14:45:15 -0800 | [diff] [blame] | 89 | def setUp(self): |
| 90 | ''' Activate the dhcp app''' |
| 91 | self.onos_ctrl = OnosCtrl(self.app) |
Chetan Gaonker | 4eb1207 | 2016-03-28 15:04:15 -0700 | [diff] [blame] | 92 | self.igmp_channel = IgmpChannel() |
Chetan Gaonker | 4a25e2b | 2016-03-04 14:45:15 -0800 | [diff] [blame] | 93 | |
A R Karthick | 31152b2 | 2016-05-13 11:25:14 -0700 | [diff] [blame] | 94 | def tearDown(self): pass |
Chetan Gaonker | 4a25e2b | 2016-03-04 14:45:15 -0800 | [diff] [blame] | 95 | |
| 96 | def onos_load_config(self, config): |
Chetan Gaonker | a2b87df | 2016-03-31 15:41:31 -0700 | [diff] [blame] | 97 | status, code = OnosCtrl.config(config) |
Chetan Gaonker | 4a25e2b | 2016-03-04 14:45:15 -0800 | [diff] [blame] | 98 | if status is False: |
| 99 | log.info('JSON request returned status %d' %code) |
| 100 | assert_equal(status, True) |
| 101 | time.sleep(2) |
| 102 | |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 103 | def onos_ssm_table_load(self, groups, src_list): |
| 104 | ssm_dict = {'apps' : { 'org.onosproject.igmp' : { 'ssmTranslate' : [] } } } |
| 105 | ssm_xlate_list = ssm_dict['apps']['org.onosproject.igmp']['ssmTranslate'] |
| 106 | for g in groups: |
| 107 | for s in src_list: |
| 108 | d = {} |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 109 | d['source'] = s or '0.0.0.0' |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 110 | d['group'] = g |
| 111 | ssm_xlate_list.append(d) |
Chetan Gaonker | 4a25e2b | 2016-03-04 14:45:15 -0800 | [diff] [blame] | 112 | self.onos_load_config(ssm_dict) |
Chetan Gaonker | 4eb1207 | 2016-03-28 15:04:15 -0700 | [diff] [blame] | 113 | cord_port_map = {} |
| 114 | for g in groups: |
| 115 | cord_port_map[g] = (self.PORT_TX_DEFAULT, self.PORT_RX_DEFAULT) |
| 116 | self.igmp_channel.cord_port_table_load(cord_port_map) |
Chetan Gaonker | 5a5204e | 2016-03-02 01:35:13 -0800 | [diff] [blame] | 117 | time.sleep(2) |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 118 | |
| 119 | def igmp_verify_join(self, igmpStateList): |
| 120 | sendState, recvState = igmpStateList |
Chetan Gaonker | 2547097 | 2016-02-26 08:52:15 -0800 | [diff] [blame] | 121 | ## check if the send is received for the groups |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 122 | for g in sendState.groups: |
| 123 | tx_stats = sendState.group_map[g][0] |
| 124 | tx = tx_stats.count |
Chetan Gaonker | 2547097 | 2016-02-26 08:52:15 -0800 | [diff] [blame] | 125 | assert_greater(tx, 0) |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 126 | rx_stats = recvState.group_map[g][1] |
| 127 | rx = rx_stats.count |
| 128 | assert_greater(rx, 0) |
| 129 | log.info('Receive stats %s for group %s' %(rx_stats, g)) |
| 130 | |
| 131 | log.info('IGMP test verification success') |
Chetan Gaonker | 2547097 | 2016-02-26 08:52:15 -0800 | [diff] [blame] | 132 | |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 133 | def igmp_verify_leave(self, igmpStateList, leave_groups): |
| 134 | sendState, recvState = igmpStateList[0], igmpStateList[1] |
| 135 | ## check if the send is received for the groups |
| 136 | for g in sendState.groups: |
| 137 | tx_stats = sendState.group_map[g][0] |
| 138 | rx_stats = recvState.group_map[g][1] |
| 139 | tx = tx_stats.count |
| 140 | rx = rx_stats.count |
| 141 | assert_greater(tx, 0) |
| 142 | if g not in leave_groups: |
| 143 | log.info('Received %d packets for group %s' %(rx, g)) |
| 144 | for g in leave_groups: |
| 145 | rx = recvState.group_map[g][1].count |
| 146 | assert_equal(rx, 0) |
| 147 | |
| 148 | log.info('IGMP test verification success') |
Chetan Gaonker | 2547097 | 2016-02-26 08:52:15 -0800 | [diff] [blame] | 149 | |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 150 | def mcast_traffic_timer(self): |
| 151 | self.mcastTraffic.stopReceives() |
| 152 | |
| 153 | def send_mcast_cb(self, send_state): |
| 154 | for g in send_state.groups: |
| 155 | send_state.update(g, tx = 1) |
Chetan Gaonker | 2547097 | 2016-02-26 08:52:15 -0800 | [diff] [blame] | 156 | return 0 |
| 157 | |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 158 | ##Runs in the context of twisted reactor thread |
Chetan Gaonker | 2547097 | 2016-02-26 08:52:15 -0800 | [diff] [blame] | 159 | def igmp_recv(self, igmpState, iface = 'veth0'): |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 160 | p = self.recv_socket.recv() |
Chetan Gaonker | f1b9e32 | 2016-05-09 15:49:15 -0700 | [diff] [blame] | 161 | try: |
| 162 | send_time = float(p.payload.load) |
| 163 | recv_time = monotonic.monotonic() |
| 164 | except: |
| 165 | log.info('Unexpected Payload received: %s' %p.payload.load) |
| 166 | return 0 |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 167 | #log.info( 'Recv in %.6f secs' %(recv_time - send_time)) |
| 168 | igmpState.update(p.dst, rx = 1, t = recv_time - send_time) |
Chetan Gaonker | 2547097 | 2016-02-26 08:52:15 -0800 | [diff] [blame] | 169 | return 0 |
| 170 | |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 171 | def send_igmp_join(self, groups, src_list = ['1.2.3.4'], ip_pkt = None, iface = 'veth0', delay = 2): |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 172 | self.onos_ssm_table_load(groups, src_list) |
Chetan Gaonker | 5a5204e | 2016-03-02 01:35:13 -0800 | [diff] [blame] | 173 | igmp = IGMPv3(type = IGMP_TYPE_V3_MEMBERSHIP_REPORT, max_resp_code=30, |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 174 | gaddr=self.IP_DST) |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 175 | for g in groups: |
Chetan Gaonker | 38737f8 | 2016-05-11 17:44:17 -0700 | [diff] [blame] | 176 | gr = IGMPv3gr(rtype=IGMP_V3_GR_TYPE_INCLUDE, mcaddr=g) |
Chetan Gaonker | 5a5204e | 2016-03-02 01:35:13 -0800 | [diff] [blame] | 177 | gr.sources = src_list |
| 178 | igmp.grps.append(gr) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 179 | if ip_pkt is None: |
| 180 | ip_pkt = self.igmp_eth/self.igmp_ip |
| 181 | pkt = ip_pkt/igmp |
Chetan Gaonker | 5a5204e | 2016-03-02 01:35:13 -0800 | [diff] [blame] | 182 | IGMPv3.fixup(pkt) |
| 183 | sendp(pkt, iface=iface) |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 184 | if delay != 0: |
| 185 | time.sleep(delay) |
| 186 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 187 | def send_igmp_join_recvQuery(self, groups, rec_queryCount = None, src_list = ['1.2.3.4'], ip_pkt = None, iface = 'veth0', delay = 2): |
| 188 | self.onos_ssm_table_load(groups, src_list) |
| 189 | igmp = IGMPv3(type = IGMP_TYPE_V3_MEMBERSHIP_REPORT, max_resp_code=30, |
| 190 | gaddr=self.IP_DST) |
| 191 | for g in groups: |
Chetan Gaonker | 38737f8 | 2016-05-11 17:44:17 -0700 | [diff] [blame] | 192 | gr = IGMPv3gr(rtype=IGMP_V3_GR_TYPE_INCLUDE, mcaddr=g) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 193 | gr.sources = src_list |
| 194 | gr.sources = src_list |
| 195 | igmp.grps.append(gr) |
| 196 | if ip_pkt is None: |
| 197 | ip_pkt = self.igmp_eth/self.igmp_ip |
| 198 | pkt = ip_pkt/igmp |
| 199 | IGMPv3.fixup(pkt) |
| 200 | if rec_queryCount == None: |
| 201 | log.info('Sending IGMP join for group %s and waiting for one query packet and printing the packet' %groups) |
| 202 | resp = srp1(pkt, iface=iface) |
| 203 | else: |
| 204 | log.info('Sending IGMP join for group %s and waiting for periodic query packets and printing one packet' %groups) |
| 205 | resp = srp3(pkt, iface=iface) |
| 206 | # resp = srp1(pkt, iface=iface) if rec_queryCount else srp3(pkt, iface=iface) |
| 207 | resp[0].summary() |
| 208 | log.info('Sent IGMP join for group %s and received a query packet and printing packet' %groups) |
| 209 | if delay != 0: |
| 210 | time.sleep(delay) |
| 211 | |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 212 | def send_igmp_leave(self, groups, src_list = ['1.2.3.4'], ip_pkt = None, iface = 'veth0', delay = 2): |
Chetan Gaonker | 5a5204e | 2016-03-02 01:35:13 -0800 | [diff] [blame] | 213 | igmp = IGMPv3(type = IGMP_TYPE_V3_MEMBERSHIP_REPORT, max_resp_code=30, |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 214 | gaddr=self.IP_DST) |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 215 | for g in groups: |
Chetan Gaonker | 38737f8 | 2016-05-11 17:44:17 -0700 | [diff] [blame] | 216 | gr = IGMPv3gr(rtype=IGMP_V3_GR_TYPE_EXCLUDE, mcaddr=g) |
Chetan Gaonker | 5a5204e | 2016-03-02 01:35:13 -0800 | [diff] [blame] | 217 | gr.sources = src_list |
| 218 | igmp.grps.append(gr) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 219 | if ip_pkt is None: |
| 220 | ip_pkt = self.igmp_eth/self.igmp_ip |
| 221 | pkt = ip_pkt/igmp |
Chetan Gaonker | 5a5204e | 2016-03-02 01:35:13 -0800 | [diff] [blame] | 222 | IGMPv3.fixup(pkt) |
| 223 | sendp(pkt, iface = iface) |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 224 | if delay != 0: |
| 225 | time.sleep(delay) |
Chetan Gaonker | 2547097 | 2016-02-26 08:52:15 -0800 | [diff] [blame] | 226 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 227 | def send_igmp_leave_listening_group_specific_query(self, groups, src_list = ['1.2.3.4'], ip_pkt = None, iface = 'veth0', delay = 2): |
| 228 | igmp = IGMPv3(type = IGMP_TYPE_V3_MEMBERSHIP_REPORT, max_resp_code=30, |
| 229 | gaddr=self.IP_DST) |
| 230 | for g in groups: |
Chetan Gaonker | 38737f8 | 2016-05-11 17:44:17 -0700 | [diff] [blame] | 231 | gr = IGMPv3gr(rtype=IGMP_V3_GR_TYPE_EXCLUDE, mcaddr=g) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 232 | gr.sources = src_list |
| 233 | igmp.grps.append(gr) |
| 234 | if ip_pkt is None: |
| 235 | ip_pkt = self.igmp_eth/self.igmp_ip |
| 236 | pkt = ip_pkt/igmp |
| 237 | IGMPv3.fixup(pkt) |
| 238 | log.info('Sending IGMP leave for group %s and waiting for one group specific query packet and printing the packet' %groups) |
| 239 | resp = srp1(pkt, iface=iface) |
| 240 | resp[0].summary() |
| 241 | log.info('Sent IGMP leave for group %s and received a group specific query packet and printing packet' %groups) |
| 242 | if delay != 0: |
| 243 | time.sleep(delay) |
| 244 | |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 245 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10) |
| 246 | def test_igmp_join_verify_traffic(self): |
Chetan Gaonker | 2547097 | 2016-02-26 08:52:15 -0800 | [diff] [blame] | 247 | groups = ['224.0.1.1', '225.0.0.1'] |
Chetan Gaonker | 2547097 | 2016-02-26 08:52:15 -0800 | [diff] [blame] | 248 | df = defer.Deferred() |
| 249 | igmpState = IGMPTestState(groups = groups, df = df) |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 250 | igmpStateRecv = IGMPTestState(groups = groups, df = df) |
| 251 | igmpStateList = (igmpState, igmpStateRecv) |
| 252 | mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb, arg = igmpState) |
| 253 | self.df = df |
| 254 | self.mcastTraffic = mcastTraffic |
| 255 | self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP) |
| 256 | |
| 257 | def igmp_srp_task(stateList): |
| 258 | igmpSendState, igmpRecvState = stateList |
| 259 | if not mcastTraffic.isRecvStopped(): |
| 260 | result = self.igmp_recv(igmpRecvState) |
| 261 | reactor.callLater(0, igmp_srp_task, stateList) |
| 262 | else: |
| 263 | self.mcastTraffic.stop() |
| 264 | self.recv_socket.close() |
| 265 | self.igmp_verify_join(stateList) |
| 266 | self.df.callback(0) |
| 267 | |
| 268 | self.send_igmp_join(groups) |
| 269 | mcastTraffic.start() |
| 270 | self.test_timer = reactor.callLater(self.MCAST_TRAFFIC_TIMEOUT, self.mcast_traffic_timer) |
| 271 | reactor.callLater(0, igmp_srp_task, igmpStateList) |
Chetan Gaonker | 2547097 | 2016-02-26 08:52:15 -0800 | [diff] [blame] | 272 | return df |
| 273 | |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 274 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10) |
| 275 | def test_igmp_leave_verify_traffic(self): |
| 276 | groups = ['224.0.1.10', '225.0.0.10'] |
| 277 | leave_groups = ['224.0.1.10'] |
| 278 | df = defer.Deferred() |
| 279 | igmpState = IGMPTestState(groups = groups, df = df) |
| 280 | igmpStateRecv = IGMPTestState(groups = groups, df = df) |
| 281 | igmpStateList = (igmpState, igmpStateRecv) |
| 282 | mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb, |
| 283 | arg = igmpState) |
| 284 | self.df = df |
| 285 | self.mcastTraffic = mcastTraffic |
| 286 | self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP) |
| 287 | |
| 288 | def igmp_srp_task(stateList): |
| 289 | igmpSendState, igmpRecvState = stateList |
| 290 | if not mcastTraffic.isRecvStopped(): |
| 291 | result = self.igmp_recv(igmpRecvState) |
| 292 | reactor.callLater(0, igmp_srp_task, stateList) |
| 293 | else: |
| 294 | self.mcastTraffic.stop() |
| 295 | self.recv_socket.close() |
| 296 | self.igmp_verify_leave(stateList, leave_groups) |
| 297 | self.df.callback(0) |
| 298 | |
| 299 | self.send_igmp_join(groups) |
| 300 | self.send_igmp_leave(leave_groups, delay = 3) |
| 301 | mcastTraffic.start() |
| 302 | self.test_timer = reactor.callLater(self.MCAST_TRAFFIC_TIMEOUT, self.mcast_traffic_timer) |
| 303 | reactor.callLater(0, igmp_srp_task, igmpStateList) |
| 304 | return df |
| 305 | |
| 306 | @deferred(timeout=100) |
| 307 | def test_igmp_leave_join_loop(self): |
| 308 | self.groups = ['226.0.1.1', '227.0.0.1', '228.0.0.1', '229.0.0.1', '230.0.0.1' ] |
| 309 | self.src_list = ['3.4.5.6', '7.8.9.10'] |
| 310 | df = defer.Deferred() |
| 311 | self.df = df |
| 312 | self.iterations = 0 |
| 313 | self.num_groups = len(self.groups) |
| 314 | self.MAX_TEST_ITERATIONS = 10 |
| 315 | |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 316 | def igmp_srp_task(v): |
| 317 | if self.iterations < self.MAX_TEST_ITERATIONS: |
| 318 | if v == 1: |
| 319 | ##join test |
| 320 | self.num_groups = random.randint(0, len(self.groups)) |
| 321 | self.send_igmp_join(self.groups[:self.num_groups], |
| 322 | src_list = self.src_list, |
| 323 | iface = 'veth0', delay = 0) |
| 324 | else: |
| 325 | self.send_igmp_leave(self.groups[:self.num_groups], |
| 326 | src_list = self.src_list, |
| 327 | iface = 'veth0', delay = 0) |
| 328 | self.iterations += 1 |
| 329 | v ^= 1 |
| 330 | reactor.callLater(1.0 + 0.5*self.num_groups, |
| 331 | igmp_srp_task, v) |
| 332 | else: |
| 333 | self.df.callback(0) |
| 334 | |
| 335 | reactor.callLater(0, igmp_srp_task, 1) |
| 336 | return df |
| 337 | |
| 338 | def igmp_join_task(self, intf, groups, state, src_list = ['1.2.3.4']): |
| 339 | self.onos_ssm_table_load(groups, src_list) |
Chetan Gaonker | 5a5204e | 2016-03-02 01:35:13 -0800 | [diff] [blame] | 340 | igmp = IGMPv3(type = IGMP_TYPE_V3_MEMBERSHIP_REPORT, max_resp_code=30, |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 341 | gaddr=self.IP_DST) |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 342 | for g in groups: |
Chetan Gaonker | 38737f8 | 2016-05-11 17:44:17 -0700 | [diff] [blame] | 343 | gr = IGMPv3gr(rtype = IGMP_V3_GR_TYPE_INCLUDE, mcaddr = g) |
Chetan Gaonker | 5a5204e | 2016-03-02 01:35:13 -0800 | [diff] [blame] | 344 | gr.sources = src_list |
| 345 | igmp.grps.append(gr) |
| 346 | |
| 347 | for g in groups: |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 348 | state.group_map[g][0].update(1, t = monotonic.monotonic()) |
Chetan Gaonker | 5a5204e | 2016-03-02 01:35:13 -0800 | [diff] [blame] | 349 | |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 350 | pkt = self.igmp_eth/self.igmp_ip/igmp |
Chetan Gaonker | 5a5204e | 2016-03-02 01:35:13 -0800 | [diff] [blame] | 351 | IGMPv3.fixup(pkt) |
| 352 | sendp(pkt, iface=intf) |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 353 | log.debug('Returning from join task') |
| 354 | |
| 355 | def igmp_recv_task(self, intf, groups, join_state): |
| 356 | recv_socket = L3PacketSocket(iface = intf, type = ETH_P_IP) |
| 357 | group_map = {} |
| 358 | for g in groups: |
| 359 | group_map[g] = [0,0] |
| 360 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 361 | log.info('Verifying join interface should receive multicast data') |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 362 | while True: |
| 363 | p = recv_socket.recv() |
| 364 | if p.dst in groups and group_map[p.dst][0] == 0: |
| 365 | group_map[p.dst][0] += 1 |
| 366 | group_map[p.dst][1] = monotonic.monotonic() |
| 367 | c = 0 |
| 368 | for g in groups: |
| 369 | c += group_map[g][0] |
| 370 | if c == len(groups): |
| 371 | break |
| 372 | for g in groups: |
| 373 | join_start = join_state.group_map[g][0].start |
| 374 | recv_time = group_map[g][1] * 1000000 |
| 375 | delta = (recv_time - join_start) |
| 376 | log.info('Join for group %s received in %.3f usecs' % |
| 377 | (g, delta)) |
| 378 | |
| 379 | recv_socket.close() |
| 380 | log.debug('Returning from recv task') |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 381 | |
| 382 | def igmp_not_recv_task(self, intf, groups, join_state): |
| 383 | recv_socket = L2Socket(iface = intf, type = ETH_P_IP) |
| 384 | group_map = {} |
| 385 | for g in groups: |
| 386 | group_map[g] = [0,0] |
| 387 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 388 | log.info('Verifying join interface should not receive any multicast data') |
Chetan Gaonker | 7791bda | 2016-05-12 17:36:52 -0700 | [diff] [blame] | 389 | self.NEGATIVE_TRAFFIC_STATUS = 1 |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 390 | def igmp_recv_cb(pkt): |
| 391 | 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] | 392 | self.NEGATIVE_TRAFFIC_STATUS = 2 |
Chetan Gaonker | 38737f8 | 2016-05-11 17:44:17 -0700 | [diff] [blame] | 393 | 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] | 394 | timeout = 3, opened_socket = recv_socket) |
| 395 | recv_socket.close() |
Chetan Gaonker | 7791bda | 2016-05-12 17:36:52 -0700 | [diff] [blame] | 396 | return self.NEGATIVE_TRAFFIC_STATUS |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 397 | |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 398 | def group_latency_check(self, groups): |
| 399 | tasks = [] |
| 400 | self.send_igmp_leave(groups = groups) |
| 401 | join_state = IGMPTestState(groups = groups) |
| 402 | tasks.append(threading.Thread(target=self.igmp_join_task, args = ('veth0', groups, join_state,))) |
| 403 | traffic_state = IGMPTestState(groups = groups) |
| 404 | mcast_traffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb, |
| 405 | arg = traffic_state) |
| 406 | mcast_traffic.start() |
| 407 | tasks.append(threading.Thread(target=self.igmp_recv_task, args = ('veth0', groups, join_state))) |
| 408 | for t in tasks: |
| 409 | t.start() |
| 410 | for t in tasks: |
| 411 | t.join() |
| 412 | |
| 413 | mcast_traffic.stop() |
| 414 | self.send_igmp_leave(groups = groups) |
| 415 | return |
| 416 | |
| 417 | def test_igmp_1group_join_latency(self): |
| 418 | groups = ['239.0.1.1'] |
| 419 | self.group_latency_check(groups) |
| 420 | |
| 421 | def test_igmp_2group_join_latency(self): |
| 422 | groups = ['239.0.1.1', '240.0.1.1'] |
| 423 | self.group_latency_check(groups) |
| 424 | |
| 425 | def test_igmp_Ngroup_join_latency(self): |
| 426 | groups = ['239.0.1.1', '240.0.1.1', '241.0.1.1', '242.0.1.1'] |
| 427 | self.group_latency_check(groups) |
| 428 | |
Chetan Gaonker | 1f7c3f8 | 2016-03-08 12:17:37 -0800 | [diff] [blame] | 429 | def test_igmp_join_rover(self): |
Chetan Gaonker | 1f7c3f8 | 2016-03-08 12:17:37 -0800 | [diff] [blame] | 430 | s = (224 << 24) | 1 |
| 431 | #e = (225 << 24) | (255 << 16) | (255 << 16) | 255 |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 432 | e = (224 << 24) | 10 |
Chetan Gaonker | 1f7c3f8 | 2016-03-08 12:17:37 -0800 | [diff] [blame] | 433 | for i in xrange(s, e+1): |
| 434 | if i&0xff: |
| 435 | ip = '%d.%d.%d.%d'%((i>>24)&0xff, (i>>16)&0xff, (i>>8)&0xff, i&0xff) |
| 436 | self.send_igmp_join([ip], delay = 0) |
| 437 | |
| 438 | @deferred(timeout=IGMP_QUERY_TIMEOUT + 10) |
| 439 | def test_igmp_query(self): |
| 440 | groups = ['224.0.0.1'] ##igmp query group |
| 441 | df = defer.Deferred() |
| 442 | self.df = df |
| 443 | self.recv_socket = L2Socket(iface = 'veth0', type = ETH_P_IP) |
| 444 | |
| 445 | def igmp_query_timeout(): |
Chetan Gaonker | 1f7c3f8 | 2016-03-08 12:17:37 -0800 | [diff] [blame] | 446 | def igmp_query_cb(pkt): |
Chetan Gaonker | bd4390f | 2016-03-09 18:56:52 -0800 | [diff] [blame] | 447 | log.info('Got IGMP query packet from %s for %s' %(pkt[IP].src, pkt[IP].dst)) |
| 448 | assert_equal(pkt[IP].dst, '224.0.0.1') |
| 449 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 450 | 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] | 451 | opened_socket = self.recv_socket) |
Chetan Gaonker | 1f7c3f8 | 2016-03-08 12:17:37 -0800 | [diff] [blame] | 452 | self.recv_socket.close() |
| 453 | self.df.callback(0) |
| 454 | |
| 455 | self.send_igmp_join(groups) |
| 456 | self.test_timer = reactor.callLater(self.IGMP_QUERY_TIMEOUT, igmp_query_timeout) |
| 457 | return df |
| 458 | |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 459 | def igmp_send_joins_different_groups_srclist(self, groups, sources, intf = V_INF1, delay = 2, ip_src = None): |
| 460 | g1 = groups[0] |
| 461 | g2 = groups[1] |
| 462 | sourcelist1 = sources[0] |
| 463 | sourcelist2 = sources[1] |
| 464 | eth = Ether(dst = self.MMACGROUP1, src = self.IGMP_SRC_MAC, type = ETH_P_IP) |
| 465 | src_ip = ip_src or self.IP_SRC |
| 466 | ip = IP(dst = g1, src = src_ip) |
| 467 | log.info('Sending join message for the group %s' %g1) |
| 468 | self.send_igmp_join((g1,), src_list = sourcelist1, ip_pkt = eth/ip, iface = intf, delay = 2) |
| 469 | eth = Ether(dst = self.MMACGROUP2, src = self.IGMP_SRC_MAC, type = ETH_P_IP) |
| 470 | ip = IP(dst = g2, src = src_ip) |
| 471 | log.info('Sending join message for group %s' %g2) |
| 472 | 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] | 473 | log.info('Done with igmp_send_joins_different_groups_srclist') |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 474 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 475 | 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): |
| 476 | g1 = groups[0] |
| 477 | g2 = groups[1] |
| 478 | sourcelist1 = sources[0] |
| 479 | sourcelist2 = sources[1] |
| 480 | eth = Ether(dst = self.MMACGROUP1, src = self.IGMP_SRC_MAC, type = ETH_P_IP) |
| 481 | src_ip = ip_src or self.IP_SRC |
| 482 | ip = IP(dst = g1, src = src_ip) |
| 483 | if query_group1 is 'group1': |
| 484 | log.info('Sending join message for the group %s and waiting for a query packet on join interface' %g1) |
| 485 | self.send_igmp_join_recvQuery((g1,), None, src_list = sourcelist1, ip_pkt = eth/ip, iface = intf, delay = 2) |
| 486 | else: |
| 487 | log.info('Sending join message for the group %s' %g1) |
| 488 | self.send_igmp_join((g1,), src_list = sourcelist1, ip_pkt = eth/ip, iface = intf, delay = 2) |
| 489 | eth = Ether(dst = self.MMACGROUP2, src = self.IGMP_SRC_MAC, type = ETH_P_IP) |
| 490 | ip = IP(dst = g2, src = src_ip) |
| 491 | if query_group2 is 'group2': |
| 492 | log.info('Sending join message for the group %s and waiting for a query packet on join interface' %g2) |
| 493 | self.send_igmp_join_recvQuery((g2,), None, src_list = sourcelist2, ip_pkt = eth/ip, iface = intf, delay = 2) |
| 494 | else: |
| 495 | log.info('Sending join message for group %s' %g2) |
| 496 | self.send_igmp_join((g2,), src_list = sourcelist2, ip_pkt = eth/ip, iface = intf, delay = 2) |
| 497 | |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 498 | def igmp_joins_leave_functionality(self, again_join = False, df = None): |
| 499 | groups1 = (self.MGROUP1,) |
| 500 | groups2 = (self.MGROUP2,) |
| 501 | self.igmp_send_joins_different_groups_srclist(groups1 + groups2, |
| 502 | (['2.2.2.2'], ['2.2.2.2']), intf = self.V_INF1, delay = 2) |
| 503 | dst_mac = '01:00:5e:01:02:03' |
| 504 | src_ip = '2.2.2.2' |
| 505 | if df is None: |
| 506 | df = defer.Deferred() |
| 507 | igmpState1 = IGMPTestState(groups = groups1, df = df) |
| 508 | igmpStateRecv1 = IGMPTestState(groups = groups1, df = df) |
| 509 | igmpStateList1 = (igmpState1, igmpStateRecv1) |
| 510 | |
| 511 | igmpState2 = IGMPTestState(groups = groups2, df = df) |
| 512 | igmpStateRecv2 = IGMPTestState(groups = groups2, df = df) |
| 513 | igmpStateList2 = (igmpState2, igmpStateRecv2) |
| 514 | mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac, |
| 515 | src_ip = src_ip, cb = self.send_mcast_cb, |
| 516 | arg = igmpState1) |
| 517 | dst_mac = '01:00:5e:02:02:03' |
| 518 | src_ip = '2.2.2.2' |
| 519 | mcastTraffic2 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac, |
| 520 | src_ip = src_ip, cb = self.send_mcast_cb, |
| 521 | arg = igmpState2) |
| 522 | mcastTraffic1.start() |
| 523 | mcastTraffic2.start() |
| 524 | join_state1 = IGMPTestState(groups = groups1) |
| 525 | join_state2 = IGMPTestState(groups = groups2) |
| 526 | target1 = self.igmp_recv_task(self.V_INF1, groups1, join_state1) |
| 527 | log.info('Interface is receiving multicast groups %s' %groups1) |
| 528 | target2 = self.igmp_recv_task(self.V_INF1, groups2, join_state2) |
| 529 | log.info('Interface is receiving multicast groups %s' %groups2) |
| 530 | log.info('Interface is sending leave message for groups %s now' %groups2) |
| 531 | self.send_igmp_leave(groups = groups2, src_list = ['2.2.2.2'], iface = self.V_INF1, delay = 2) |
| 532 | target3 = self.igmp_recv_task(self.V_INF1, groups1, join_state1) |
| 533 | target4 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state2) |
| 534 | assert target4 == 1, 'EXPECTED FAILURE' |
| 535 | if again_join: |
| 536 | dst_mac = '01:00:5e:02:02:03' |
| 537 | ip_dst = '239.2.2.3' |
| 538 | eth = Ether(dst = dst_mac, src = self.IGMP_SRC_MAC, type = ETH_P_IP) |
| 539 | ip = IP(dst = ip_dst, src = self.IP_SRC) |
| 540 | log.info('Interface sending join message again for the groups %s' %groups2) |
| 541 | self.send_igmp_join(groups2, src_list = [src_ip], ip_pkt = eth/ip, iface = self.V_INF1, delay = 2) |
| 542 | target5 = self.igmp_recv_task(self.V_INF1, groups2, join_state2) |
| 543 | log.info('Interface is receiving multicast groups %s again' %groups2) |
| 544 | target6 = self.igmp_recv_task(self.V_INF1, groups1, join_state1) |
| 545 | log.info('Interface is still receiving from multicast groups %s' %groups1) |
| 546 | else: |
| 547 | log.info('Ended test case') |
| 548 | mcastTraffic1.stop() |
| 549 | mcastTraffic2.stop() |
A R Karthick | 31152b2 | 2016-05-13 11:25:14 -0700 | [diff] [blame] | 550 | |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 551 | |
| 552 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20) |
| 553 | def test_igmp_2joins_1leave_functionality(self): |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 554 | df = defer.Deferred() |
| 555 | def test_igmp_2joins_1leave(): |
| 556 | self.igmp_joins_leave_functionality(again_join = False, df = df) |
| 557 | df.callback(0) |
| 558 | reactor.callLater(0, test_igmp_2joins_1leave) |
| 559 | return df |
| 560 | |
| 561 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+25) |
| 562 | def test_igmp_2joins_1leave_again_joins_functionality(self): |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 563 | df = defer.Deferred() |
| 564 | def test_igmp_2joins_1leave_join_again(): |
| 565 | self.igmp_joins_leave_functionality(again_join = True, df = df) |
| 566 | df.callback(0) |
| 567 | reactor.callLater(0, test_igmp_2joins_1leave_join_again) |
| 568 | return df |
| 569 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 570 | def igmp_not_in_src_list_functionality(self, df = None): |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 571 | groups1 = (self.MGROUP1,) |
| 572 | groups2 = (self.MGROUP2,) |
| 573 | self.igmp_send_joins_different_groups_srclist(groups1 + groups2, |
| 574 | (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']), |
| 575 | intf = self.V_INF1, delay = 2) |
| 576 | dst_mac = '01:00:5e:01:02:03' |
| 577 | src_ip = '6.6.6.6' |
| 578 | if df is None: |
| 579 | df = defer.Deferred() |
| 580 | igmpState1 = IGMPTestState(groups = groups1, df = df) |
| 581 | igmpStateRecv1 = IGMPTestState(groups = groups1, df = df) |
| 582 | mcastTraffic1 = McastTraffic(groups1, iface = 'veth2', dst_mac = dst_mac, |
| 583 | src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1) |
| 584 | mcastTraffic1.start() |
| 585 | join_state1 = IGMPTestState(groups = groups1) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 586 | 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] | 587 | target1 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1) |
Chetan Gaonker | 7791bda | 2016-05-12 17:36:52 -0700 | [diff] [blame] | 588 | assert target1 == 2, 'EXPECTED FAILURE' |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 589 | log.info('Interface is not receiving from multicast groups %s, working as expected' %groups1) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 590 | mcastTraffic1.stop() |
A R Karthick | 31152b2 | 2016-05-13 11:25:14 -0700 | [diff] [blame] | 591 | |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 592 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 593 | def test_igmp_not_in_src_list_functionality(self): |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 594 | df = defer.Deferred() |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 595 | def igmp_not_in_src_list_functionality(): |
| 596 | self.igmp_not_in_src_list_functionality(df = df) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 597 | df.callback(0) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 598 | reactor.callLater(0, igmp_not_in_src_list_functionality) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 599 | return df |
| 600 | |
| 601 | def igmp_change_to_exclude_src_list_functionality(self, df = None): |
| 602 | groups1 = (self.MGROUP1,) |
| 603 | groups2 = (self.MGROUP2,) |
| 604 | self.igmp_send_joins_different_groups_srclist(groups1 + groups2, |
| 605 | (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']), |
| 606 | intf = self.V_INF1, delay = 2) |
| 607 | dst_mac = '01:00:5e:01:02:03' |
| 608 | src_ip = '2.2.2.2' |
| 609 | if df is None: |
| 610 | df = defer.Deferred() |
| 611 | igmpState1 = IGMPTestState(groups = groups1, df = df) |
| 612 | igmpStateRecv1 = IGMPTestState(groups = groups1, df = df) |
| 613 | mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac, |
| 614 | src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1) |
| 615 | mcastTraffic1.start() |
| 616 | join_state1 = IGMPTestState(groups = groups1) |
| 617 | target1 = self.igmp_recv_task(self.V_INF1, groups1, join_state1) |
| 618 | self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2'], iface = self.V_INF1, delay =2) |
| 619 | target2 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1) |
Chetan Gaonker | 7791bda | 2016-05-12 17:36:52 -0700 | [diff] [blame] | 620 | assert target2 == 2, 'EXPECTED FAILURE' |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 621 | log.info('Interface is not receiving from multicast groups %s after sending CHANGE_TO_EXCLUDE' %groups1) |
| 622 | mcastTraffic1.stop() |
A R Karthick | 31152b2 | 2016-05-13 11:25:14 -0700 | [diff] [blame] | 623 | |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 624 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10) |
| 625 | def test_igmp_change_to_exclude_src_list_functionality(self): |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 626 | df = defer.Deferred() |
| 627 | def igmp_change_to_exclude_src_list_functionality(): |
| 628 | self.igmp_change_to_exclude_src_list_functionality(df = df) |
| 629 | df.callback(0) |
| 630 | reactor.callLater(0, igmp_change_to_exclude_src_list_functionality) |
| 631 | return df |
| 632 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 633 | def igmp_include_to_allow_src_list_functionality(self, df = None): |
| 634 | groups1 = (self.MGROUP1,) |
| 635 | groups2 = (self.MGROUP2,) |
| 636 | self.igmp_send_joins_different_groups_srclist(groups1 + groups2, |
| 637 | (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']), |
| 638 | intf = self.V_INF1, delay = 2) |
| 639 | dst_mac = '01:00:5e:01:02:03' |
| 640 | src_ip = '2.2.2.2' |
| 641 | if df is None: |
| 642 | df = defer.Deferred() |
| 643 | igmpState1 = IGMPTestState(groups = groups1, df = df) |
| 644 | igmpStateRecv1 = IGMPTestState(groups = groups1, df = df) |
| 645 | mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac, |
| 646 | src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1) |
| 647 | mcastTraffic1.start() |
| 648 | join_state1 = IGMPTestState(groups = groups1) |
| 649 | target1 = self.igmp_recv_task(self.V_INF1, groups1, join_state1) |
| 650 | self.igmp_send_joins_different_groups_srclist(groups1 + groups2, |
| 651 | (['2.2.2.2', '3.3.3.3', '4.4.4.4', '6.6.6.6'], ['2.2.2.2', '5.5.5.5']), |
| 652 | intf = self.V_INF1, delay = 2) |
| 653 | target1 = self.igmp_recv_task(self.V_INF1, groups1, join_state1) |
| 654 | mcastTraffic1.stop() |
A R Karthick | 31152b2 | 2016-05-13 11:25:14 -0700 | [diff] [blame] | 655 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 656 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+30) |
| 657 | def test_igmp_include_to_allow_src_list_functionality(self): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 658 | df = defer.Deferred() |
| 659 | def igmp_include_to_allow_src_list_functionality(): |
| 660 | self.igmp_include_to_allow_src_list_functionality(df = df) |
| 661 | df.callback(0) |
| 662 | reactor.callLater(0, igmp_include_to_allow_src_list_functionality) |
| 663 | return df |
| 664 | |
| 665 | def igmp_include_to_block_src_list_functionality(self, df = None): |
| 666 | groups1 = (self.MGROUP1,) |
| 667 | groups2 = (self.MGROUP2,) |
| 668 | self.igmp_send_joins_different_groups_srclist(groups1 + groups2, |
| 669 | (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']), |
| 670 | intf = self.V_INF1, delay = 2) |
| 671 | dst_mac = '01:00:5e:01:02:03' |
| 672 | src_ip = '2.2.2.2' |
| 673 | if df is None: |
| 674 | df = defer.Deferred() |
| 675 | igmpState1 = IGMPTestState(groups = groups1, df = df) |
| 676 | igmpStateRecv1 = IGMPTestState(groups = groups1, df = df) |
| 677 | mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac, |
| 678 | src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1) |
| 679 | mcastTraffic1.start() |
| 680 | join_state1 = IGMPTestState(groups = groups1) |
| 681 | target1 = self.igmp_recv_task(self.V_INF1, groups1, join_state1) |
| 682 | self.send_igmp_leave(groups = groups1, src_list = ['6.6.6.6','7.7.7.7'], |
| 683 | iface = self.V_INF1, delay = 2) |
| 684 | target1 = self.igmp_recv_task(self.V_INF1, groups1, join_state1) |
Chetan Gaonker | 717b294 | 2016-05-13 17:42:59 -0700 | [diff] [blame] | 685 | log.info('Interface is still receiving from old multicast group data %s even after we send block list' %groups1) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 686 | mcastTraffic1.stop() |
A R Karthick | 31152b2 | 2016-05-13 11:25:14 -0700 | [diff] [blame] | 687 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 688 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+30) |
| 689 | def test_igmp_include_to_block_src_list_functionality(self): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 690 | df = defer.Deferred() |
| 691 | def igmp_include_to_block_src_list_functionality(): |
| 692 | self.igmp_include_to_block_src_list_functionality(df = df) |
| 693 | df.callback(0) |
| 694 | reactor.callLater(0, igmp_include_to_block_src_list_functionality) |
| 695 | return df |
| 696 | |
| 697 | |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 698 | def igmp_change_to_include_src_list_functionality(self, df = None): |
| 699 | groups1 = (self.MGROUP1,) |
| 700 | groups2 = (self.MGROUP2,) |
| 701 | self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4'], |
| 702 | iface = self.V_INF1, delay = 2) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 703 | |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 704 | dst_mac = '01:00:5e:01:02:03' |
| 705 | src_ip = '2.2.2.2' |
| 706 | if df is None: |
| 707 | df = defer.Deferred() |
| 708 | igmpState1 = IGMPTestState(groups = groups1, df = df) |
| 709 | igmpStateRecv1 = IGMPTestState(groups = groups1, df = df) |
| 710 | mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac, |
| 711 | src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1) |
| 712 | mcastTraffic1.start() |
| 713 | join_state1 = IGMPTestState(groups = groups1) |
| 714 | target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1) |
| 715 | assert target1 == 1, 'EXPECTED FAILURE' |
| 716 | log.info('Interface is not receiving from multicast groups %s' %groups1) |
| 717 | self.igmp_send_joins_different_groups_srclist(groups1 + groups2, |
| 718 | (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['6.6.6.6', '5.5.5.5']), |
| 719 | intf = self.V_INF1, delay = 2) |
| 720 | target2 = self.igmp_recv_task(self.V_INF1, groups1, join_state1) |
| 721 | log.info('Interface is receiving from multicast groups %s after send Change to include message' %groups1) |
| 722 | mcastTraffic1.stop() |
A R Karthick | 31152b2 | 2016-05-13 11:25:14 -0700 | [diff] [blame] | 723 | |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 724 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10) |
| 725 | def test_igmp_change_to_include_src_list_functionality(self): |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 726 | df = defer.Deferred() |
| 727 | def igmp_change_to_include_src_list_functionality(): |
| 728 | self.igmp_change_to_include_src_list_functionality(df = df) |
| 729 | df.callback(0) |
| 730 | reactor.callLater(0, igmp_change_to_include_src_list_functionality) |
| 731 | return df |
| 732 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 733 | def igmp_exclude_to_allow_src_list_functionality(self, df = None): |
| 734 | groups1 = (self.MGROUP1,) |
| 735 | groups2 = (self.MGROUP2,) |
| 736 | self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4'], |
| 737 | iface = self.V_INF1, delay = 2) |
| 738 | |
| 739 | dst_mac = '01:00:5e:01:02:03' |
| 740 | src_ip = '2.2.2.2' |
| 741 | if df is None: |
| 742 | df = defer.Deferred() |
| 743 | igmpState1 = IGMPTestState(groups = groups1, df = df) |
| 744 | igmpStateRecv1 = IGMPTestState(groups = groups1, df = df) |
| 745 | mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac, |
| 746 | src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1) |
| 747 | mcastTraffic1.start() |
| 748 | join_state1 = IGMPTestState(groups = groups1) |
| 749 | target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1) |
| 750 | assert target1 == 1, 'EXPECTED FAILURE' |
| 751 | log.info('Interface is not receiving from multicast groups %s' %groups1) |
| 752 | self.igmp_send_joins_different_groups_srclist(groups1 + groups2, |
| 753 | (['6.6.6.6', '7.7.7.7', '8.8.8.8'], ['6.6.6.6', '5.5.5.5']), |
| 754 | intf = self.V_INF1, delay = 2) |
| 755 | target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1) |
| 756 | assert target1 == 1, 'EXPECTED FAILURE' |
| 757 | log.info('Interface is not receiving from multicast groups %s' %groups1) |
| 758 | mcastTraffic1.stop() |
A R Karthick | 31152b2 | 2016-05-13 11:25:14 -0700 | [diff] [blame] | 759 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 760 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10) |
| 761 | def test_igmp_exclude_to_allow_src_list_functionality(self): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 762 | df = defer.Deferred() |
| 763 | def igmp_exclude_to_allow_src_list_functionality(): |
| 764 | self.igmp_exclude_to_allow_src_list_functionality(df = df) |
| 765 | df.callback(0) |
| 766 | reactor.callLater(0, igmp_exclude_to_allow_src_list_functionality) |
| 767 | return df |
| 768 | |
| 769 | def igmp_exclude_to_block_src_list_functionality(self, df = None): |
| 770 | groups1 = (self.MGROUP1,) |
| 771 | groups2 = (self.MGROUP2,) |
| 772 | self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4'], |
| 773 | iface = self.V_INF1, delay = 2) |
| 774 | |
| 775 | dst_mac = '01:00:5e:01:02:03' |
| 776 | src_ip = '2.2.2.2' |
| 777 | if df is None: |
| 778 | df = defer.Deferred() |
| 779 | igmpState1 = IGMPTestState(groups = groups1, df = df) |
| 780 | igmpStateRecv1 = IGMPTestState(groups = groups1, df = df) |
| 781 | mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac, |
| 782 | src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1) |
| 783 | mcastTraffic1.start() |
| 784 | join_state1 = IGMPTestState(groups = groups1) |
| 785 | target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1) |
| 786 | assert target1 == 1, 'EXPECTED FAILURE' |
| 787 | log.info('Interface is not receiving from multicast groups %s' %groups1) |
| 788 | 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'], |
| 789 | iface = self.V_INF1, delay = 2) |
| 790 | target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1) |
| 791 | assert target1 == 1, 'EXPECTED FAILURE' |
| 792 | log.info('Interface is not receiving from multicast groups %s' %groups1) |
| 793 | mcastTraffic1.stop() |
A R Karthick | 31152b2 | 2016-05-13 11:25:14 -0700 | [diff] [blame] | 794 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 795 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10) |
| 796 | def test_igmp_exclude_to_block_src_list_functionality(self): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 797 | df = defer.Deferred() |
| 798 | def igmp_exclude_to_block_src_list_functionality(): |
| 799 | self.igmp_exclude_to_block_src_list_functionality(df = df) |
| 800 | df.callback(0) |
| 801 | reactor.callLater(0, igmp_exclude_to_block_src_list_functionality) |
| 802 | return df |
| 803 | |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 804 | def igmp_new_src_list_functionality(self, df = None): |
| 805 | groups1 = (self.MGROUP1,) |
| 806 | groups2 = (self.MGROUP2,) |
| 807 | self.igmp_send_joins_different_groups_srclist(groups1+groups2, |
| 808 | (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']), |
| 809 | intf = self.V_INF1, delay = 2) |
| 810 | dst_mac = '01:00:5e:01:02:03' |
| 811 | src_ip = '6.6.6.6' |
| 812 | if df is None: |
| 813 | df = defer.Deferred() |
| 814 | igmpState1 = IGMPTestState(groups = groups1, df = df) |
| 815 | igmpStateRecv1 = IGMPTestState(groups = groups1, df = df) |
| 816 | mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac, |
| 817 | src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1) |
| 818 | mcastTraffic1.start() |
| 819 | join_state1 = IGMPTestState(groups = groups1) |
| 820 | target1 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1) |
| 821 | assert target1 == 1, 'EXPECTED FAILURE' |
| 822 | log.info('Interface is not receiving from multicast groups %s' %groups1) |
| 823 | self.igmp_send_joins_different_groups_srclist(groups1 + groups2, |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 824 | (['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] | 825 | intf = self.V_INF1, delay = 2) |
| 826 | target2 = self.igmp_recv_task(self.V_INF1, groups1, join_state1) |
| 827 | log.info('Interface is receiving from multicast groups %s after sending join with new source list' %groups1) |
| 828 | mcastTraffic1.stop() |
A R Karthick | 31152b2 | 2016-05-13 11:25:14 -0700 | [diff] [blame] | 829 | |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 830 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10) |
| 831 | def test_igmp_new_src_list_functionality(self): |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 832 | df = defer.Deferred() |
| 833 | def igmp_new_src_list_functionality(): |
| 834 | self.igmp_new_src_list_functionality(df = df) |
| 835 | df.callback(0) |
| 836 | reactor.callLater(0, igmp_new_src_list_functionality) |
| 837 | return df |
| 838 | |
| 839 | def igmp_block_old_src_list_functionality(self, df = None): |
| 840 | groups1 = (self.MGROUP1,) |
| 841 | groups2 = (self.MGROUP2,) |
| 842 | groups = groups1 + groups2 |
| 843 | self.igmp_send_joins_different_groups_srclist(groups, |
| 844 | (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']), |
| 845 | intf = self.V_INF1, delay = 2) |
| 846 | dst_mac = '01:00:5e:02:02:03' |
| 847 | src_ip = '5.5.5.5' |
| 848 | if df is None: |
| 849 | df = defer.Deferred() |
| 850 | igmpState1 = IGMPTestState(groups = groups2, df = df) |
| 851 | igmpStateRecv1 = IGMPTestState(groups = groups2, df = df) |
| 852 | mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac, |
| 853 | src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1) |
| 854 | mcastTraffic1.start() |
| 855 | join_state1 = IGMPTestState(groups = groups2) |
| 856 | target1 = self.igmp_recv_task(self.V_INF1, groups2, join_state1) |
| 857 | log.info('Interface is receiving from multicast groups %s' %groups2) |
| 858 | self.igmp_send_joins_different_groups_srclist(groups, |
| 859 | (['6.6.6.6', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '7.7.7.7']), |
| 860 | intf = self.V_INF1, delay = 2) |
| 861 | target2 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1) |
Chetan Gaonker | 7791bda | 2016-05-12 17:36:52 -0700 | [diff] [blame] | 862 | assert target2 == 2, 'EXPECTED FAILURE' |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 863 | log.info('Interface is not receiving from multicast groups %s after sending join with block old source list' %groups2) |
| 864 | mcastTraffic1.stop() |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 865 | |
| 866 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20) |
| 867 | def test_igmp_block_old_src_list_functionality(self): |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 868 | df = defer.Deferred() |
| 869 | def igmp_block_old_src_list_functionality(): |
| 870 | self.igmp_block_old_src_list_functionality(df = df) |
| 871 | df.callback(0) |
| 872 | reactor.callLater(0, igmp_block_old_src_list_functionality) |
| 873 | return df |
| 874 | |
| 875 | def igmp_include_empty_src_list_functionality(self, df = None): |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 876 | groups1 = (self.MGROUP1,) |
| 877 | groups2 = (self.MGROUP2,) |
| 878 | groups = groups1 + groups2 |
| 879 | self.igmp_send_joins_different_groups_srclist(groups, |
| 880 | (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['']), |
| 881 | intf = self.V_INF1, delay = 2) |
| 882 | dst_mac = '01:00:5e:02:02:03' |
| 883 | src_ip = '5.5.5.5' |
| 884 | if df is None: |
| 885 | df = defer.Deferred() |
| 886 | igmpState1 = IGMPTestState(groups = groups2, df = df) |
| 887 | igmpStateRecv1 = IGMPTestState(groups = groups2, df = df) |
| 888 | mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac, |
| 889 | src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1) |
| 890 | mcastTraffic1.start() |
| 891 | join_state1 = IGMPTestState(groups = groups2) |
| 892 | target1 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1) |
| 893 | assert target1==1, 'EXPECTED FAILURE' |
| 894 | log.info('Interface is not receiving from multicast groups %s when we sent join with source list is empty' %groups2) |
| 895 | mcastTraffic1.stop() |
A R Karthick | 31152b2 | 2016-05-13 11:25:14 -0700 | [diff] [blame] | 896 | |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 897 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20) |
| 898 | def ztest_igmp_include_empty_src_list_functionality(self): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 899 | ## '''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] | 900 | df = defer.Deferred() |
| 901 | def igmp_include_empty_src_list_functionality(): |
| 902 | self.igmp_include_empty_src_list_functionality(df = df) |
| 903 | df.callback(0) |
| 904 | reactor.callLater(0, igmp_include_empty_src_list_functionality) |
| 905 | return df |
| 906 | |
| 907 | def igmp_exclude_empty_src_list_functionality(self, df = None): |
| 908 | groups1 = (self.MGROUP1,) |
| 909 | groups2 = (self.MGROUP2,) |
| 910 | groups = groups1 + groups2 |
| 911 | self.send_igmp_leave(groups = groups2, src_list = [''], iface = self.V_INF1, delay = 2) |
| 912 | dst_mac = '01:00:5e:02:02:03' |
| 913 | src_ip = '5.5.5.5' |
| 914 | if df is None: |
| 915 | df = defer.Deferred() |
| 916 | igmpState1 = IGMPTestState(groups = groups2, df = df) |
| 917 | igmpStateRecv1 = IGMPTestState(groups = groups2, df = df) |
| 918 | mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac, |
| 919 | src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1) |
| 920 | mcastTraffic1.start() |
| 921 | join_state1 = IGMPTestState(groups = groups2) |
| 922 | target1 = self.igmp_recv_task(self.V_INF1, groups2, join_state1) |
| 923 | log.info('Interface is receiving multicast groups %s' %groups2) |
| 924 | mcastTraffic1.stop() |
A R Karthick | 31152b2 | 2016-05-13 11:25:14 -0700 | [diff] [blame] | 925 | |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 926 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20) |
| 927 | def ztest_igmp_exclude_empty_src_list_functionality(self): |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 928 | df = defer.Deferred() |
| 929 | def igmp_exclude_empty_src_list_functionality(): |
| 930 | self.igmp_exclude_empty_src_list_functionality() |
| 931 | df.callback(0) |
| 932 | reactor.callLater(0, igmp_exclude_empty_src_list_functionality) |
| 933 | return df |
| 934 | |
| 935 | def igmp_join_sourceip_0_0_0_0_functionality(self, df = None): |
| 936 | groups1 = (self.MGROUP1,) |
| 937 | groups2 = (self.MGROUP2,) |
| 938 | groups = groups1 + groups2 |
| 939 | ip_src = '0.0.0.0' |
| 940 | self.igmp_send_joins_different_groups_srclist(groups, |
| 941 | (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['5.5.5.5']), |
| 942 | intf = self.V_INF1, delay = 2, ip_src = ip_src) |
| 943 | ip_src = self.IP_SRC |
| 944 | dst_mac = '01:00:5e:02:02:03' |
| 945 | src_ip = '5.5.5.5' |
| 946 | if df is None: |
| 947 | df = defer.Deferred() |
| 948 | igmpState1 = IGMPTestState(groups = groups2, df = df) |
| 949 | igmpStateRecv1 = IGMPTestState(groups = groups2, df = df) |
| 950 | mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac, |
| 951 | src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1) |
| 952 | mcastTraffic1.start() |
| 953 | join_state1 = IGMPTestState(groups = groups2) |
| 954 | target1 = self.igmp_recv_task(self.V_INF1, groups2, join_state1) |
| 955 | log.info('Interface is receiving from multicast groups %s when we sent join with source IP is 0.0.0.0' %groups2) |
| 956 | mcastTraffic1.stop() |
A R Karthick | 31152b2 | 2016-05-13 11:25:14 -0700 | [diff] [blame] | 957 | |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 958 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20) |
| 959 | def test_igmp_join_sourceip_0_0_0_0_functionality(self): |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 960 | df = defer.Deferred() |
| 961 | def igmp_join_sourceip_0_0_0_0_functionality(): |
| 962 | self.igmp_join_sourceip_0_0_0_0_functionality(df = df) |
| 963 | df.callback(0) |
| 964 | reactor.callLater(0, igmp_join_sourceip_0_0_0_0_functionality) |
| 965 | return df |
| 966 | |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 967 | def igmp_invalid_join_packet_functionality(self, df = None): |
| 968 | groups1 = (self.MGROUP1,) |
| 969 | groups2 = (self.MINVALIDGROUP1,) |
| 970 | groups = groups1 + groups2 |
| 971 | ip_src = '1.1.1.1' |
| 972 | self.igmp_send_joins_different_groups_srclist(groups, |
| 973 | (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['5.5.5.5']), |
| 974 | intf = self.V_INF1, delay = 2, ip_src = ip_src) |
| 975 | ip_src = self.IP_SRC |
| 976 | dst_mac = '01:00:5e:02:02:03' |
| 977 | src_ip = '5.5.5.5' |
| 978 | if df is None: |
| 979 | df = defer.Deferred() |
| 980 | igmpState1 = IGMPTestState(groups = groups2, df = df) |
| 981 | igmpStateRecv1 = IGMPTestState(groups = groups2, df = df) |
| 982 | mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac, |
| 983 | src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1) |
| 984 | mcastTraffic1.start() |
| 985 | join_state1 = IGMPTestState(groups = groups2) |
| 986 | target1 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1) |
| 987 | assert target1==1, 'EXPECTED FAILURE' |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 988 | log.info('Interface is not receiving from multicast groups %s when we sent invalid join packet ' %groups2) |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 989 | mcastTraffic1.stop() |
A R Karthick | 31152b2 | 2016-05-13 11:25:14 -0700 | [diff] [blame] | 990 | |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 991 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20) |
| 992 | def test_igmp_invalid_join_packet_functionality(self): |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 993 | df = defer.Deferred() |
| 994 | def igmp_invalid_join_packet_functionality(): |
| 995 | self.igmp_invalid_join_packet_functionality(df = df) |
| 996 | df.callback(0) |
| 997 | reactor.callLater(0, igmp_invalid_join_packet_functionality) |
| 998 | return df |
| 999 | |
| 1000 | def igmp_join_data_receiving_during_subscriber_link_down_up_functionality(self, df = None): |
| 1001 | groups1 = (self.MGROUP1,) |
| 1002 | groups2 = (self.MGROUP2,) |
| 1003 | groups = groups1 + groups2 |
| 1004 | ip_src = '1.1.1.1' |
| 1005 | self.igmp_send_joins_different_groups_srclist(groups, |
| 1006 | (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['5.5.5.5']), |
| 1007 | intf = self.V_INF1, delay = 2, ip_src = ip_src) |
| 1008 | ip_src = self.IP_SRC |
| 1009 | dst_mac = '01:00:5e:02:02:03' |
| 1010 | src_ip = '5.5.5.5' |
| 1011 | if df is None: |
| 1012 | df = defer.Deferred() |
| 1013 | igmpState1 = IGMPTestState(groups = groups2, df = df) |
| 1014 | igmpStateRecv1 = IGMPTestState(groups = groups2, df = df) |
| 1015 | mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac, |
| 1016 | src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1) |
| 1017 | mcastTraffic1.start() |
| 1018 | join_state1 = IGMPTestState(groups = groups2) |
| 1019 | target1 = self.igmp_recv_task(self.V_INF1, groups2, join_state1) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1020 | log.info('Interface is receiving 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] | 1021 | os.system('ifconfig '+self.V_INF1+' down') |
| 1022 | log.info(' the self.V_INF1 %s is down now ' %self.V_INF1) |
| 1023 | os.system('ifconfig '+self.V_INF1) |
| 1024 | time.sleep(10) |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1025 | os.system('ifconfig '+self.V_INF1+' up') |
| 1026 | os.system('ifconfig '+self.V_INF1) |
| 1027 | 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] | 1028 | target1 = self.igmp_recv_task(self.V_INF1, groups2, join_state1) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1029 | log.info('Interface is receiving from multicast groups %s when we bringup interface up after down ' %groups2) |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1030 | mcastTraffic1.stop() |
A R Karthick | 31152b2 | 2016-05-13 11:25:14 -0700 | [diff] [blame] | 1031 | |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1032 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1033 | def test_igmp_join_data_receiving_during_subscriber_link_up_down_functionality(self): |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1034 | df = defer.Deferred() |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1035 | def igmp_join_data_receiving_during_subscriber_link_up_down_functionality(): |
| 1036 | self.igmp_join_data_receiving_during_subscriber_link_down_up_functionality(df = df) |
| 1037 | df.callback(0) |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1038 | reactor.callLater(0, igmp_join_data_receiving_during_subscriber_link_down_up_functionality) |
| 1039 | return df |
| 1040 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1041 | def igmp_join_data_receiving_during_channel_distributor_link_up_down_functionality(self, df = None): |
| 1042 | groups1 = (self.MGROUP1,) |
| 1043 | groups2 = (self.MGROUP2,) |
| 1044 | groups = groups1 + groups2 |
| 1045 | ip_src = '1.1.1.1' |
| 1046 | self.igmp_send_joins_different_groups_srclist(groups, |
| 1047 | (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['5.5.5.5', '6.6.6.6']), |
| 1048 | intf = self.V_INF1, delay = 2, ip_src = ip_src) |
| 1049 | ip_src = self.IP_SRC |
| 1050 | dst_mac1 = '01:00:5e:01:02:03' |
| 1051 | dst_mac2 = '01:00:5e:02:02:03' |
| 1052 | src_ip2 = '5.5.5.5' |
| 1053 | src_ip1 = '2.2.2.2' |
| 1054 | if df is None: |
| 1055 | df = defer.Deferred() |
| 1056 | igmpState1 = IGMPTestState(groups = groups1, df = df) |
| 1057 | igmpState2 = IGMPTestState(groups = groups2, df = df) |
| 1058 | igmpStateRecv1 = IGMPTestState(groups = groups1, df = df) |
| 1059 | igmpStateRecv2 = IGMPTestState(groups = groups2, df = df) |
| 1060 | mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac1, |
| 1061 | src_ip = src_ip1, cb = self.send_mcast_cb, arg = igmpState1) |
| 1062 | mcastTraffic2 = McastTraffic(groups2, iface= 'veth3', dst_mac = dst_mac2, |
| 1063 | src_ip = src_ip2, cb = self.send_mcast_cb, arg = igmpState2) |
| 1064 | mcastTraffic1.start() |
| 1065 | mcastTraffic2.start() |
| 1066 | join_state1 = IGMPTestState(groups = groups1) |
| 1067 | join_state2 = IGMPTestState(groups = groups2) |
| 1068 | target1 = self.igmp_recv_task(self.V_INF1, groups1, join_state1) |
| 1069 | target2 = self.igmp_recv_task(self.V_INF1, groups2, join_state2) |
| 1070 | log.info('Interface is receiving from multicast groups, before bring down the veth2 and subscriber link is self.V_INF1=%s up ' %self.V_INF1) |
| 1071 | mcastTraffic1.stop() |
| 1072 | os.system('ifconfig '+'veth2'+' down') |
| 1073 | log.info(' the channel distributor interface veth2 is down now ' ) |
| 1074 | os.system('ifconfig '+'veth2') |
| 1075 | time.sleep(10) |
| 1076 | log.info('Verifying interface is still receiving a multicast groups2 %s traffic even though other group traffic sending interface goes down' %groups2) |
| 1077 | target2 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1) |
| 1078 | log.info('Verified that interface is still receiving a multicast groups2 %s traffic even though other group traffic sending interface goes down' %groups2) |
| 1079 | target1 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1) |
| 1080 | assert target1==1, 'EXPECTED FAILURE' |
| 1081 | log.info('Interface is not receiving from multicast groups1 %s when we shutdown the subscriber interface ' %groups1) |
| 1082 | os.system('ifconfig '+'veth2'+' up') |
| 1083 | os.system('ifconfig '+'veth2') |
| 1084 | log.info(' the channel distributor interface veth2 is up now ') |
| 1085 | time.sleep(10) |
| 1086 | mcastTraffic1.start() |
| 1087 | log.info('Verifying interface is receiving from both multicast groups data %s when we bringup interface up after down ' %groups2) |
| 1088 | target1 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1) |
| 1089 | target2 = self.igmp_recv_task(self.V_INF1, groups2, join_state2) |
| 1090 | target2 = self.igmp_recv_task(self.V_INF1, groups2, join_state2) |
| 1091 | log.info('Interface is receiving from multicast groups %s when we bringup interface up after down ' %groups2) |
| 1092 | mcastTraffic2.stop() |
A R Karthick | 31152b2 | 2016-05-13 11:25:14 -0700 | [diff] [blame] | 1093 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1094 | ## This test case is failing to receive traffic from multicast data from defferent channel interfaces TO-DO |
| 1095 | ###### TO DO scenario ####### |
| 1096 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+60) |
Chetan Gaonker | 7791bda | 2016-05-12 17:36:52 -0700 | [diff] [blame] | 1097 | def test_igmp_join_data_receiving_during_channel_distributor_link_down_up_functionality(self): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1098 | df = defer.Deferred() |
| 1099 | def igmp_join_data_receiving_during_channel_distributor_link_down_up_functionality(): |
| 1100 | self.igmp_join_data_receiving_during_channel_distributor_link_down_up_functionality(df = df) |
| 1101 | df.callback(0) |
| 1102 | reactor.callLater(0, igmp_join_data_receiving_during_channel_distributor_link_down_up_functionality) |
| 1103 | return df |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1104 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1105 | def igmp_invalidClassD_IP_join_packet_functionality(self, df = None): |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1106 | groups1 = (self.MGROUP1,) |
| 1107 | groups2 = (self.MINVALIDGROUP2,) |
| 1108 | groups = groups1 + groups2 |
| 1109 | ip_src = '1.1.1.1' |
| 1110 | self.igmp_send_joins_different_groups_srclist(groups, |
| 1111 | (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['5.5.5.5']), |
| 1112 | intf = self.V_INF1, delay = 2, ip_src = ip_src) |
| 1113 | ip_src = self.IP_SRC |
| 1114 | dst_mac = '01:00:5e:02:02:03' |
| 1115 | src_ip = '5.5.5.5' |
| 1116 | if df is None: |
| 1117 | df = defer.Deferred() |
| 1118 | igmpState1 = IGMPTestState(groups = groups2, df = df) |
| 1119 | igmpStateRecv1 = IGMPTestState(groups = groups2, df = df) |
| 1120 | mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac, |
| 1121 | src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1) |
| 1122 | mcastTraffic1.start() |
| 1123 | join_state1 = IGMPTestState(groups = groups2) |
| 1124 | target1 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1) |
| 1125 | assert target1==1, 'EXPECTED FAILURE' |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1126 | log.info('Interface is not receiving from multicast groups %s when we sent invalid join packet ' %groups2) |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1127 | mcastTraffic1.stop() |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1128 | |
| 1129 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1130 | def test_igmp_invalidClassD_IP_join_packet_functionality(self): |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1131 | df = defer.Deferred() |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1132 | def igmp_invalidClass_D_IP_join_packet_functionality(): |
| 1133 | self.igmp_invalidClass_D_IP_join_packet_functionality(df = df) |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1134 | df.callback(0) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1135 | reactor.callLater(0, igmp_invalidClassD_IP_join_packet_functionality) |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1136 | return df |
| 1137 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1138 | def igmp_invalidClassD_IP_as_srclistIP_join_packet_functionality(self, df = None): |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1139 | groups1 = (self.MGROUP1,) |
| 1140 | groups2 = (self.MGROUP2,) |
| 1141 | groups = groups1 + groups2 |
| 1142 | ip_src = '1.1.1.1' |
| 1143 | self.igmp_send_joins_different_groups_srclist(groups, |
| 1144 | (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['239.5.5.5']), |
| 1145 | intf = self.V_INF1, delay = 2, ip_src = ip_src) |
| 1146 | ip_src = self.IP_SRC |
| 1147 | dst_mac = '01:00:5e:02:02:03' |
| 1148 | src_ip = '5.5.5.5' |
| 1149 | if df is None: |
| 1150 | df = defer.Deferred() |
| 1151 | igmpState1 = IGMPTestState(groups = groups2, df = df) |
| 1152 | igmpStateRecv1 = IGMPTestState(groups = groups2, df = df) |
| 1153 | mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac, |
| 1154 | src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1) |
| 1155 | mcastTraffic1.start() |
| 1156 | join_state1 = IGMPTestState(groups = groups2) |
| 1157 | target1 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1) |
| 1158 | assert target1==1, 'EXPECTED FAILURE' |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1159 | log.info('Interface is not receiving from multicast groups %s when we sent invalid join packet ' %groups2) |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1160 | mcastTraffic1.stop() |
A R Karthick | 31152b2 | 2016-05-13 11:25:14 -0700 | [diff] [blame] | 1161 | |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1162 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1163 | def test_igmp_invalidClassD_IP_as_srclistIP_join_packet_functionality(self): |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1164 | df = defer.Deferred() |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1165 | def igmp_invalidClassD_IP_as_srclistIP_join_packet_functionality(): |
| 1166 | self.igmp_invalidClassD_IP_as_srclistIP_join_packet_functionality(df = df) |
| 1167 | df.callback(0) |
| 1168 | reactor.callLater(0, igmp_invalidClassD_IP_as_srclistIP_join_packet_functionality) |
| 1169 | return df |
Chetan Gaonker | f72ca40 | 2016-05-02 16:29:32 -0700 | [diff] [blame] | 1170 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1171 | def igmp_general_query_recv_packet_functionality(self, df = None): |
| 1172 | groups1 = (self.MGROUP1,) |
| 1173 | groups2 = (self.MGROUP2,) |
| 1174 | groups = groups1 + groups2 |
| 1175 | ip_src = '1.1.1.1' |
| 1176 | self.igmp_send_joins_different_groups_srclist(groups, |
| 1177 | (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['5.5.5.5']), |
| 1178 | intf = self.V_INF1, delay = 2, ip_src = ip_src) |
| 1179 | ip_src = self.IP_SRC |
| 1180 | dst_mac = '01:00:5e:02:02:03' |
| 1181 | src_ip = '5.5.5.5' |
| 1182 | if df is None: |
| 1183 | df = defer.Deferred() |
| 1184 | igmpState1 = IGMPTestState(groups = groups2, df = df) |
| 1185 | igmpStateRecv1 = IGMPTestState(groups = groups2, df = df) |
| 1186 | mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac, |
| 1187 | src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1) |
| 1188 | mcastTraffic1.start() |
| 1189 | join_state1 = IGMPTestState(groups = groups2) |
| 1190 | log.info('Started delay to verify multicast data taraffic for group %s is received or not for 180 sec ' %groups2) |
| 1191 | time.sleep(100) |
| 1192 | target2 = self.igmp_recv_task(self.V_INF1, groups2, join_state1) |
| 1193 | log.info('Verified that multicast data for group %s is received after 100 sec ' %groups2) |
| 1194 | time.sleep(50) |
| 1195 | target2 = self.igmp_recv_task(self.V_INF1, groups2, join_state1) |
| 1196 | log.info('Verified that multicast data for group %s is received after 150 sec ' %groups2) |
| 1197 | time.sleep(30) |
| 1198 | target2 = self.igmp_recv_task(self.V_INF1, groups2, join_state1) |
| 1199 | log.info('Verified that multicast data for group %s is received after 180 sec ' %groups2) |
| 1200 | time.sleep(10) |
| 1201 | target2 = self.igmp_recv_task(self.V_INF1, groups2, join_state1) |
| 1202 | log.info('Verified that multicast data for group %s is received after 190 sec ' %groups2) |
| 1203 | target3 = mcastTraffic1.isRecvStopped() |
| 1204 | assert target3==False, 'EXPECTED FAILURE' |
| 1205 | log.info('Verified that multicast data for a group %s is still transmitting from a data interface' %groups2) |
| 1206 | log.info('Now checking joining interface is receiving a multicast data for group %s after 190 sec' %groups2) |
| 1207 | target1 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1) |
| 1208 | assert target1==1, 'EXPECTED FAILURE' |
| 1209 | log.info('Interface is not receiving multicast data for group %s' %groups2) |
| 1210 | mcastTraffic1.stop() |
A R Karthick | 31152b2 | 2016-05-13 11:25:14 -0700 | [diff] [blame] | 1211 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1212 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+250) |
| 1213 | def test_igmp_general_query_recv_packet_traffic_functionality(self): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1214 | df = defer.Deferred() |
| 1215 | def igmp_general_query_recv_packet_functionality(): |
| 1216 | self.igmp_general_query_recv_packet_functionality(df = df) |
| 1217 | df.callback(0) |
| 1218 | reactor.callLater(0, igmp_general_query_recv_packet_functionality) |
| 1219 | return df |
| 1220 | |
| 1221 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+80) |
| 1222 | def test_igmp_query_packet_received_on_joining_interface(self): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1223 | groups = ['224.0.1.10', '225.0.0.10'] |
| 1224 | leave_groups = ['224.0.1.10'] |
| 1225 | df = defer.Deferred() |
| 1226 | igmpState = IGMPTestState(groups = groups, df = df) |
| 1227 | igmpStateRecv = IGMPTestState(groups = groups, df = df) |
| 1228 | igmpStateList = (igmpState, igmpStateRecv) |
| 1229 | mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb, |
| 1230 | arg = igmpState) |
| 1231 | self.df = df |
| 1232 | self.mcastTraffic = mcastTraffic |
| 1233 | self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP) |
| 1234 | |
| 1235 | def igmp_srp_task(stateList): |
| 1236 | igmpSendState, igmpRecvState = stateList |
| 1237 | if not mcastTraffic.isRecvStopped(): |
| 1238 | result = self.igmp_recv(igmpRecvState) |
| 1239 | reactor.callLater(0, igmp_srp_task, stateList) |
| 1240 | else: |
| 1241 | self.mcastTraffic.stop() |
| 1242 | self.recv_socket.close() |
| 1243 | self.igmp_verify_leave(stateList, leave_groups) |
| 1244 | self.df.callback(0) |
| 1245 | |
| 1246 | log.info('Sending join packet and expected to receive on egeneral query packet after 60 sec for multicast %s ' %groups) |
| 1247 | self.send_igmp_join_recvQuery(groups) |
| 1248 | log.info('Received a egeneral query packet for multicast %s group on joing interface and sending traffic' %groups) |
| 1249 | mcastTraffic.start() |
| 1250 | self.test_timer = reactor.callLater(self.MCAST_TRAFFIC_TIMEOUT, self.mcast_traffic_timer) |
| 1251 | reactor.callLater(0, igmp_srp_task, igmpStateList) |
| 1252 | return df |
| 1253 | |
| 1254 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+190) |
| 1255 | def test_igmp_periodic_query_packet_received_on_joining_interface(self): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1256 | groups = ['224.0.1.10', '225.0.0.10'] |
| 1257 | leave_groups = ['224.0.1.10'] |
| 1258 | df = defer.Deferred() |
| 1259 | igmpState = IGMPTestState(groups = groups, df = df) |
| 1260 | igmpStateRecv = IGMPTestState(groups = groups, df = df) |
| 1261 | igmpStateList = (igmpState, igmpStateRecv) |
| 1262 | mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb, |
| 1263 | arg = igmpState) |
| 1264 | self.df = df |
| 1265 | self.mcastTraffic = mcastTraffic |
| 1266 | self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP) |
| 1267 | |
| 1268 | def igmp_srp_task(stateList): |
| 1269 | igmpSendState, igmpRecvState = stateList |
| 1270 | if not mcastTraffic.isRecvStopped(): |
| 1271 | result = self.igmp_recv(igmpRecvState) |
| 1272 | reactor.callLater(0, igmp_srp_task, stateList) |
| 1273 | else: |
| 1274 | self.mcastTraffic.stop() |
| 1275 | self.recv_socket.close() |
| 1276 | self.igmp_verify_leave(stateList, leave_groups) |
| 1277 | self.df.callback(0) |
| 1278 | |
| 1279 | self.send_igmp_join_recvQuery(groups,3) |
| 1280 | return df |
| 1281 | |
| 1282 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+190) |
| 1283 | def test_igmp_periodic_query_packet_received_and_checking_entry_deleted(self): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1284 | groups = ['224.0.1.10', '225.0.0.10'] |
| 1285 | leave_groups = ['224.0.1.10'] |
| 1286 | df = defer.Deferred() |
| 1287 | igmpState = IGMPTestState(groups = groups, df = df) |
| 1288 | igmpStateRecv = IGMPTestState(groups = groups, df = df) |
| 1289 | igmpStateList = (igmpState, igmpStateRecv) |
| 1290 | mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb, |
| 1291 | arg = igmpState) |
| 1292 | self.df = df |
| 1293 | self.mcastTraffic = mcastTraffic |
| 1294 | self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP) |
| 1295 | |
| 1296 | def igmp_srp_task(stateList): |
| 1297 | igmpSendState, igmpRecvState = stateList |
| 1298 | if not mcastTraffic.isRecvStopped(): |
| 1299 | result = self.igmp_recv(igmpRecvState) |
| 1300 | reactor.callLater(0, igmp_srp_task, stateList) |
| 1301 | else: |
| 1302 | self.mcastTraffic.stop() |
| 1303 | self.recv_socket.close() |
| 1304 | self.igmp_verify_leave(stateList, leave_groups) |
| 1305 | self.df.callback(0) |
| 1306 | |
| 1307 | self.send_igmp_join_recvQuery(groups,3) |
| 1308 | log.info('Received periodic egeneral query packets for multicast %s, now checking entry is deleted from tabel by sending traffic for that group' %groups) |
| 1309 | mcastTraffic.start() |
| 1310 | self.test_timer = reactor.callLater(self.MCAST_TRAFFIC_TIMEOUT, self.mcast_traffic_timer) |
| 1311 | reactor.callLater(0, igmp_srp_task, igmpStateList) |
| 1312 | return df |
| 1313 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1314 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+190) |
| 1315 | def test_igmp_member_query_interval_expire_re_joining_interface(self): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1316 | groups = ['224.0.1.10', '225.0.0.10'] |
| 1317 | leave_groups = ['224.0.1.10'] |
| 1318 | df = defer.Deferred() |
| 1319 | igmpState = IGMPTestState(groups = groups, df = df) |
| 1320 | igmpStateRecv = IGMPTestState(groups = groups, df = df) |
| 1321 | igmpStateList = (igmpState, igmpStateRecv) |
| 1322 | mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb, |
| 1323 | arg = igmpState) |
| 1324 | self.df = df |
| 1325 | self.mcastTraffic = mcastTraffic |
| 1326 | self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP) |
| 1327 | |
| 1328 | def igmp_srp_task(stateList): |
| 1329 | igmpSendState, igmpRecvState = stateList |
| 1330 | if not mcastTraffic.isRecvStopped(): |
| 1331 | result = self.igmp_recv(igmpRecvState) |
| 1332 | reactor.callLater(0, igmp_srp_task, stateList) |
| 1333 | else: |
| 1334 | self.mcastTraffic.stop() |
| 1335 | self.recv_socket.close() |
| 1336 | self.igmp_verify_leave(stateList, leave_groups) |
| 1337 | self.df.callback(0) |
| 1338 | |
| 1339 | self.send_igmp_join_recvQuery(groups,3) |
| 1340 | log.info('Received periodic egeneral query packets for multicast %s, now sending join packet again and verifying traffic for that group is received or not on joining interface' %groups) |
| 1341 | self.send_igmp_join(groups) |
| 1342 | mcastTraffic.start() |
| 1343 | self.test_timer = reactor.callLater(self.MCAST_TRAFFIC_TIMEOUT, self.mcast_traffic_timer) |
| 1344 | reactor.callLater(0, igmp_srp_task, igmpStateList) |
| 1345 | return df |
| 1346 | |
| 1347 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+50) |
| 1348 | def test_igmp_leave_verify_received_group_source_specific_query(self): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1349 | groups = ['224.0.1.10', '225.0.0.10'] |
| 1350 | leave_groups = ['224.0.1.10'] |
| 1351 | df = defer.Deferred() |
| 1352 | igmpState = IGMPTestState(groups = groups, df = df) |
| 1353 | igmpStateRecv = IGMPTestState(groups = groups, df = df) |
| 1354 | igmpStateList = (igmpState, igmpStateRecv) |
| 1355 | mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb, |
| 1356 | arg = igmpState) |
| 1357 | self.df = df |
| 1358 | self.mcastTraffic = mcastTraffic |
| 1359 | self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP) |
| 1360 | |
| 1361 | def igmp_srp_task(stateList): |
| 1362 | igmpSendState, igmpRecvState = stateList |
| 1363 | if not mcastTraffic.isRecvStopped(): |
| 1364 | result = self.igmp_recv(igmpRecvState) |
| 1365 | reactor.callLater(0, igmp_srp_task, stateList) |
| 1366 | else: |
| 1367 | self.mcastTraffic.stop() |
| 1368 | self.recv_socket.close() |
| 1369 | self.igmp_verify_leave(stateList, leave_groups) |
| 1370 | self.df.callback(0) |
| 1371 | |
| 1372 | self.send_igmp_join(groups) |
| 1373 | self.send_igmp_leave_listening_group_specific_query(leave_groups, delay = 3) |
| 1374 | return df |
| 1375 | |
| 1376 | def igmp_change_to_exclude_src_list_check_for_group_source_specific_query(self, df = None): |
| 1377 | groups1 = (self.MGROUP1,) |
| 1378 | groups2 = (self.MGROUP2,) |
| 1379 | self.igmp_send_joins_different_groups_srclist(groups1 + groups2, |
| 1380 | (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']), |
| 1381 | intf = self.V_INF1, delay = 2) |
| 1382 | dst_mac = '01:00:5e:01:02:03' |
| 1383 | src_ip = '2.2.2.2' |
| 1384 | if df is None: |
| 1385 | df = defer.Deferred() |
| 1386 | igmpState1 = IGMPTestState(groups = groups1, df = df) |
| 1387 | igmpStateRecv1 = IGMPTestState(groups = groups1, df = df) |
| 1388 | mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac, |
| 1389 | src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1) |
| 1390 | mcastTraffic1.start() |
| 1391 | join_state1 = IGMPTestState(groups = groups1) |
| 1392 | target1 = self.igmp_recv_task(self.V_INF1, groups1, join_state1) |
| 1393 | self.send_igmp_leave_listening_group_specific_query(groups = groups1, src_list = ['2.2.2.2'], iface = self.V_INF1, delay =2) |
| 1394 | time.sleep(10) |
| 1395 | target2 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1) |
| 1396 | assert target2 == 1, 'EXPECTED FAILURE' |
| 1397 | log.info('Interface is not receiving from multicast groups %s after sending CHANGE_TO_EXCLUDE' %groups2) |
| 1398 | mcastTraffic1.stop() |
A R Karthick | 31152b2 | 2016-05-13 11:25:14 -0700 | [diff] [blame] | 1399 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1400 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+60) |
| 1401 | def test_igmp_change_to_exclude_src_list_check_for_group_source_specific_query(self): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1402 | df = defer.Deferred() |
| 1403 | def igmp_change_to_exclude_src_list_check_for_group_source_specific_query(): |
| 1404 | self.igmp_change_to_exclude_src_list_check_for_group_source_specific_query(df = df) |
| 1405 | df.callback(0) |
| 1406 | reactor.callLater(0, igmp_change_to_exclude_src_list_check_for_group_source_specific_query) |
| 1407 | return df |
| 1408 | |
| 1409 | def igmp_change_to_include_src_list_check_for_general_query(self, df = None): |
| 1410 | groups1 = (self.MGROUP1,) |
| 1411 | groups2 = (self.MGROUP2,) |
| 1412 | self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4'], |
| 1413 | iface = self.V_INF1, delay = 2) |
| 1414 | dst_mac = '01:00:5e:01:02:03' |
| 1415 | src_ip = '2.2.2.2' |
| 1416 | if df is None: |
| 1417 | df = defer.Deferred() |
| 1418 | igmpState1 = IGMPTestState(groups = groups1, df = df) |
| 1419 | igmpStateRecv1 = IGMPTestState(groups = groups1, df = df) |
| 1420 | mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac, |
| 1421 | src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1) |
| 1422 | mcastTraffic1.start() |
| 1423 | join_state1 = IGMPTestState(groups = groups1) |
| 1424 | target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1) |
| 1425 | assert target1 == 1, 'EXPECTED FAILURE' |
| 1426 | log.info('Interface is not receiving from multicast groups %s' %groups1) |
| 1427 | self.igmp_send_joins_different_groups_srclist_wait_query_packets(groups1 + groups2, |
| 1428 | (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['6.6.6.6', '5.5.5.5']), |
| 1429 | intf = self.V_INF1, delay = 2,query_group1 = 'group1', query_group2 = None) |
| 1430 | time.sleep(10) |
| 1431 | target2 = self.igmp_recv_task(self.V_INF1, groups1, join_state1) |
| 1432 | log.info('Interface is receiving from multicast groups %s after send Change to include message' %groups1) |
| 1433 | mcastTraffic1.stop() |
A R Karthick | 31152b2 | 2016-05-13 11:25:14 -0700 | [diff] [blame] | 1434 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1435 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+80) |
| 1436 | def test_igmp_change_to_include_src_list_check_for_general_query(self): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1437 | df = defer.Deferred() |
| 1438 | def igmp_change_to_include_src_list_check_for_general_query(): |
| 1439 | self.igmp_change_to_include_src_list_check_for_general_query(df = df) |
| 1440 | df.callback(0) |
| 1441 | reactor.callLater(0, igmp_change_to_include_src_list_check_for_general_query) |
| 1442 | return df |
| 1443 | |
| 1444 | def igmp_allow_new_src_list_check_for_general_query(self, df = None): |
| 1445 | groups1 = (self.MGROUP1,) |
| 1446 | groups2 = (self.MGROUP2,) |
| 1447 | self.igmp_send_joins_different_groups_srclist(groups1+groups2, |
| 1448 | (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']), |
| 1449 | intf = self.V_INF1, delay = 2) |
| 1450 | dst_mac = '01:00:5e:01:02:03' |
| 1451 | src_ip = '6.6.6.6' |
| 1452 | if df is None: |
| 1453 | df = defer.Deferred() |
| 1454 | igmpState1 = IGMPTestState(groups = groups1, df = df) |
| 1455 | igmpStateRecv1 = IGMPTestState(groups = groups1, df = df) |
| 1456 | mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac, |
| 1457 | src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1) |
| 1458 | mcastTraffic1.start() |
| 1459 | join_state1 = IGMPTestState(groups = groups1) |
| 1460 | target1 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1) |
| 1461 | #assert target1 == 1, 'EXPECTED FAILURE' |
| 1462 | log.info('Interface is not receiving from multicast groups %s' %groups1) |
| 1463 | 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']), |
| 1464 | intf = self.V_INF1, delay = 2, query_group1 = 'group1', query_group2 = None) |
| 1465 | target2 = self.igmp_recv_task(self.V_INF1, groups1, join_state1) |
| 1466 | log.info('Interface is receiving from multicast groups %s after sending join with new source list' %groups1) |
| 1467 | mcastTraffic1.stop() |
A R Karthick | 31152b2 | 2016-05-13 11:25:14 -0700 | [diff] [blame] | 1468 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1469 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+80) |
| 1470 | def test_igmp_allow_new_src_list_check_for_general_query(self): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1471 | df = defer.Deferred() |
| 1472 | def igmp_allow_new_src_list_check_for_general_query(): |
| 1473 | self.igmp_allow_new_src_list_check_for_general_query(df = df) |
| 1474 | df.callback(0) |
| 1475 | reactor.callLater(0, igmp_allow_new_src_list_check_for_general_query) |
| 1476 | return df |
| 1477 | |
| 1478 | def igmp_block_old_src_list_check_for_group_source_specific_query(self, df = None): |
| 1479 | groups1 = (self.MGROUP1,) |
| 1480 | groups2 = (self.MGROUP2,) |
| 1481 | groups = groups1 + groups2 |
| 1482 | self.igmp_send_joins_different_groups_srclist(groups, |
| 1483 | (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']), |
| 1484 | intf = self.V_INF1, delay = 2) |
| 1485 | dst_mac = '01:00:5e:02:02:03' |
| 1486 | src_ip = '5.5.5.5' |
| 1487 | if df is None: |
| 1488 | df = defer.Deferred() |
| 1489 | igmpState1 = IGMPTestState(groups = groups2, df = df) |
| 1490 | igmpStateRecv1 = IGMPTestState(groups = groups2, df = df) |
| 1491 | mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac, |
| 1492 | src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1) |
| 1493 | mcastTraffic1.start() |
| 1494 | join_state1 = IGMPTestState(groups = groups2) |
| 1495 | target1 = self.igmp_recv_task(self.V_INF1, groups2, join_state1) |
| 1496 | log.info('Interface is receiving from multicast groups %s' %groups2) |
| 1497 | self.igmp_send_joins_different_groups_srclist_wait_query_packets(groups, |
| 1498 | (['6.6.6.6', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '7.7.7.7']), |
| 1499 | intf = self.V_INF1, delay = 2, query_group1 = 'group1', query_group2 = None) |
| 1500 | target2 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1) |
| 1501 | assert target2 == 1, 'EXPECTED FAILURE' |
| 1502 | log.info('Interface is not receiving from multicast groups %s after sending join with block old source list' %groups2) |
| 1503 | mcastTraffic1.stop() |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1504 | |
| 1505 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+90) |
| 1506 | def test_igmp_block_old_src_list_check_for_group_source_specific_query(self): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1507 | df = defer.Deferred() |
| 1508 | def igmp_block_old_src_list_check_for_group_source_specific_query(): |
| 1509 | self.igmp_block_old_src_list_check_for_group_source_specific_query(df = df) |
| 1510 | df.callback(0) |
| 1511 | reactor.callLater(0, igmp_block_old_src_list_check_for_group_source_specific_query) |
| 1512 | return df |
| 1513 | |
| 1514 | def igmp_include_to_allow_src_list_check_for_general_query(self, df = None): |
| 1515 | groups1 = (self.MGROUP1,) |
| 1516 | groups2 = (self.MGROUP2,) |
| 1517 | self.igmp_send_joins_different_groups_srclist(groups1 + groups2, |
| 1518 | (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']), |
| 1519 | intf = self.V_INF1, delay = 2) |
| 1520 | dst_mac = '01:00:5e:01:02:03' |
| 1521 | src_ip = '2.2.2.2' |
| 1522 | if df is None: |
| 1523 | df = defer.Deferred() |
| 1524 | igmpState1 = IGMPTestState(groups = groups1, df = df) |
| 1525 | igmpStateRecv1 = IGMPTestState(groups = groups1, df = df) |
| 1526 | mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac, |
| 1527 | src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1) |
| 1528 | mcastTraffic1.start() |
| 1529 | join_state1 = IGMPTestState(groups = groups1) |
| 1530 | target1 = self.igmp_recv_task(self.V_INF1, groups1, join_state1) |
| 1531 | 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) |
| 1532 | target1 = self.igmp_recv_task(self.V_INF1, groups1, join_state1) |
| 1533 | mcastTraffic1.stop() |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1534 | |
| 1535 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+40) |
| 1536 | def test_igmp_include_to_allow_src_list_check_for_general_query(self): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1537 | df = defer.Deferred() |
| 1538 | def igmp_include_to_allow_src_list_check_for_general_query(): |
| 1539 | self.igmp_include_to_allow_src_list_check_for_general_query(df = df) |
| 1540 | df.callback(0) |
| 1541 | reactor.callLater(0, igmp_include_to_allow_src_list_check_for_general_query) |
| 1542 | return df |
| 1543 | |
| 1544 | def igmp_include_to_block_src_list_check_for_group_source_specific_query(self, df = None): |
| 1545 | groups1 = (self.MGROUP1,) |
| 1546 | groups2 = (self.MGROUP2,) |
| 1547 | self.igmp_send_joins_different_groups_srclist(groups1 + groups2, |
| 1548 | (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']), |
| 1549 | intf = self.V_INF1, delay = 2) |
| 1550 | dst_mac = '01:00:5e:01:02:03' |
| 1551 | src_ip = '2.2.2.2' |
| 1552 | if df is None: |
| 1553 | df = defer.Deferred() |
| 1554 | igmpState1 = IGMPTestState(groups = groups1, df = df) |
| 1555 | igmpStateRecv1 = IGMPTestState(groups = groups1, df = df) |
| 1556 | mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac, |
| 1557 | src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1) |
| 1558 | mcastTraffic1.start() |
| 1559 | join_state1 = IGMPTestState(groups = groups1) |
| 1560 | target1 = self.igmp_recv_task(self.V_INF1, groups1, join_state1) |
| 1561 | self.send_igmp_leave_listening_group_specific_query(groups = groups1, src_list = ['6.6.6.6','7.7.7.7'], |
| 1562 | iface = self.V_INF1, delay = 2) |
| 1563 | target1 = self.igmp_recv_task(self.V_INF1, groups1, join_state1) |
| 1564 | mcastTraffic1.stop() |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1565 | |
| 1566 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+40) |
| 1567 | def test_igmp_include_to_block_src_list_check_for_group_source_specific_query(self): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1568 | df = defer.Deferred() |
| 1569 | def igmp_include_to_block_src_list_check_for_group_source_specific_query(): |
| 1570 | self.igmp_include_to_block_src_list_check_for_group_source_specific_query(df = df) |
| 1571 | df.callback(0) |
| 1572 | reactor.callLater(0, igmp_include_to_block_src_list_check_for_group_source_specific_query) |
| 1573 | return df |
| 1574 | |
| 1575 | def igmp_exclude_to_allow_src_list_check_for_general_query(self, df = None): |
| 1576 | groups1 = (self.MGROUP1,) |
| 1577 | groups2 = (self.MGROUP2,) |
| 1578 | self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4'], |
| 1579 | iface = self.V_INF1, delay = 2) |
| 1580 | |
| 1581 | dst_mac = '01:00:5e:01:02:03' |
| 1582 | src_ip = '2.2.2.2' |
| 1583 | if df is None: |
| 1584 | df = defer.Deferred() |
| 1585 | igmpState1 = IGMPTestState(groups = groups1, df = df) |
| 1586 | igmpStateRecv1 = IGMPTestState(groups = groups1, df = df) |
| 1587 | mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac, |
| 1588 | src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1) |
| 1589 | mcastTraffic1.start() |
| 1590 | join_state1 = IGMPTestState(groups = groups1) |
| 1591 | target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1) |
| 1592 | assert target1 == 1, 'EXPECTED FAILURE' |
| 1593 | log.info('Interface is not receiving from multicast groups %s' %groups1) |
| 1594 | self.igmp_send_joins_different_groups_srclist_wait_query_packets(groups1 + groups2, |
| 1595 | (['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) |
| 1596 | target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1) |
| 1597 | assert target1 == 1, 'EXPECTED FAILURE' |
| 1598 | log.info('Interface is not receiving from multicast groups %s' %groups1) |
| 1599 | mcastTraffic1.stop() |
A R Karthick | 31152b2 | 2016-05-13 11:25:14 -0700 | [diff] [blame] | 1600 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1601 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+90) |
| 1602 | def test_igmp_exclude_to_allow_src_list_check_for_general_query(self): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1603 | df = defer.Deferred() |
| 1604 | def igmp_exclude_to_allow_src_list_check_for_general_query(): |
| 1605 | self.igmp_exclude_to_allow_src_list_check_for_general_query(df = df) |
| 1606 | df.callback(0) |
| 1607 | reactor.callLater(0, igmp_exclude_to_allow_src_list_check_for_general_query) |
| 1608 | return df |
| 1609 | |
| 1610 | def igmp_exclude_to_block_src_list_check_for_group_source_specific_query(self, df = None): |
| 1611 | groups1 = (self.MGROUP1,) |
| 1612 | groups2 = (self.MGROUP2,) |
| 1613 | self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4'], |
| 1614 | iface = self.V_INF1, delay = 2) |
| 1615 | |
| 1616 | dst_mac = '01:00:5e:01:02:03' |
| 1617 | src_ip = '2.2.2.2' |
| 1618 | if df is None: |
| 1619 | df = defer.Deferred() |
| 1620 | igmpState1 = IGMPTestState(groups = groups1, df = df) |
| 1621 | igmpStateRecv1 = IGMPTestState(groups = groups1, df = df) |
| 1622 | mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac, |
| 1623 | src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1) |
| 1624 | mcastTraffic1.start() |
| 1625 | join_state1 = IGMPTestState(groups = groups1) |
| 1626 | target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1) |
| 1627 | assert target1 == 1, 'EXPECTED FAILURE' |
| 1628 | log.info('Interface is not receiving from multicast groups %s' %groups1) |
| 1629 | self.send_igmp_leave_listening_group_specific_query(groups = groups1, |
| 1630 | src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4', '5.5.5.5', '7.7.7.7'], |
| 1631 | iface = self.V_INF1, delay = 2) |
| 1632 | target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1) |
| 1633 | assert target1 == 1, 'EXPECTED FAILURE' |
| 1634 | log.info('Interface is not receiving from multicast groups %s' %groups1) |
| 1635 | mcastTraffic1.stop() |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1636 | |
| 1637 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+40) |
| 1638 | def test_igmp_exclude_to_block_src_list_check_for_group_source_specific_query(self): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1639 | df = defer.Deferred() |
| 1640 | def igmp_exclude_to_block_src_list_check_for_group_source_specific_query(): |
| 1641 | self.igmp_exclude_to_block_src_list_check_for_group_source_specific_query(df = df) |
| 1642 | df.callback(0) |
| 1643 | reactor.callLater(0, igmp_exclude_to_block_src_list_check_for_group_source_specific_query) |
| 1644 | return df |
| 1645 | |
| 1646 | |