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