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 | 38737f8 | 2016-05-11 17:44:17 -0700 | [diff] [blame] | 181 | gr = IGMPv3gr(rtype=IGMP_V3_GR_TYPE_INCLUDE, mcaddr=g) |
Chetan Gaonker | 5a5204e | 2016-03-02 01:35:13 -0800 | [diff] [blame] | 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: |
Chetan Gaonker | 38737f8 | 2016-05-11 17:44:17 -0700 | [diff] [blame] | 197 | gr = IGMPv3gr(rtype=IGMP_V3_GR_TYPE_INCLUDE, mcaddr=g) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 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 | 38737f8 | 2016-05-11 17:44:17 -0700 | [diff] [blame] | 221 | gr = IGMPv3gr(rtype=IGMP_V3_GR_TYPE_EXCLUDE, mcaddr=g) |
Chetan Gaonker | 5a5204e | 2016-03-02 01:35:13 -0800 | [diff] [blame] | 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: |
Chetan Gaonker | 38737f8 | 2016-05-11 17:44:17 -0700 | [diff] [blame] | 236 | gr = IGMPv3gr(rtype=IGMP_V3_GR_TYPE_EXCLUDE, mcaddr=g) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 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 | 38737f8 | 2016-05-11 17:44:17 -0700 | [diff] [blame] | 348 | gr = IGMPv3gr(rtype = IGMP_V3_GR_TYPE_INCLUDE, mcaddr = g) |
Chetan Gaonker | 5a5204e | 2016-03-02 01:35:13 -0800 | [diff] [blame] | 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): |
| 388 | recv_socket = L2Socket(iface = intf, type = ETH_P_IP) |
| 389 | group_map = {} |
| 390 | for g in groups: |
| 391 | group_map[g] = [0,0] |
| 392 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 393 | log.info('Verifying join interface should not receive any multicast data') |
Chetan Gaonker | 7791bda | 2016-05-12 17:36:52 -0700 | [diff] [blame] | 394 | self.NEGATIVE_TRAFFIC_STATUS = 1 |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 395 | def igmp_recv_cb(pkt): |
| 396 | log.info('Multicast packet %s received for left groups %s' %(pkt[IP].dst, groups)) |
Chetan Gaonker | 7791bda | 2016-05-12 17:36:52 -0700 | [diff] [blame] | 397 | self.NEGATIVE_TRAFFIC_STATUS = 2 |
Chetan Gaonker | 38737f8 | 2016-05-11 17:44:17 -0700 | [diff] [blame] | 398 | sniff(prn = igmp_recv_cb, count = 1, lfilter = lambda p: IP in p and p[IP].dst in groups, |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 399 | timeout = 3, opened_socket = recv_socket) |
| 400 | recv_socket.close() |
Chetan Gaonker | 7791bda | 2016-05-12 17:36:52 -0700 | [diff] [blame] | 401 | return self.NEGATIVE_TRAFFIC_STATUS |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 402 | |
Chetan Gaonker | eb2b24b | 2016-03-01 14:04:45 -0800 | [diff] [blame] | 403 | def group_latency_check(self, groups): |
| 404 | tasks = [] |
| 405 | self.send_igmp_leave(groups = groups) |
| 406 | join_state = IGMPTestState(groups = groups) |
| 407 | tasks.append(threading.Thread(target=self.igmp_join_task, args = ('veth0', groups, join_state,))) |
| 408 | traffic_state = IGMPTestState(groups = groups) |
| 409 | mcast_traffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb, |
| 410 | arg = traffic_state) |
| 411 | mcast_traffic.start() |
| 412 | tasks.append(threading.Thread(target=self.igmp_recv_task, args = ('veth0', groups, join_state))) |
| 413 | for t in tasks: |
| 414 | t.start() |
| 415 | for t in tasks: |
| 416 | t.join() |
| 417 | |
| 418 | mcast_traffic.stop() |
| 419 | self.send_igmp_leave(groups = groups) |
| 420 | return |
| 421 | |
| 422 | def test_igmp_1group_join_latency(self): |
| 423 | groups = ['239.0.1.1'] |
| 424 | self.group_latency_check(groups) |
| 425 | |
| 426 | def test_igmp_2group_join_latency(self): |
| 427 | groups = ['239.0.1.1', '240.0.1.1'] |
| 428 | self.group_latency_check(groups) |
| 429 | |
| 430 | def test_igmp_Ngroup_join_latency(self): |
| 431 | groups = ['239.0.1.1', '240.0.1.1', '241.0.1.1', '242.0.1.1'] |
| 432 | self.group_latency_check(groups) |
| 433 | |
| 434 | |
Chetan Gaonker | 1f7c3f8 | 2016-03-08 12:17:37 -0800 | [diff] [blame] | 435 | def test_igmp_join_rover(self): |
Chetan Gaonker | 1f7c3f8 | 2016-03-08 12:17:37 -0800 | [diff] [blame] | 436 | s = (224 << 24) | 1 |
| 437 | #e = (225 << 24) | (255 << 16) | (255 << 16) | 255 |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 438 | e = (224 << 24) | 10 |
Chetan Gaonker | 1f7c3f8 | 2016-03-08 12:17:37 -0800 | [diff] [blame] | 439 | for i in xrange(s, e+1): |
| 440 | if i&0xff: |
| 441 | ip = '%d.%d.%d.%d'%((i>>24)&0xff, (i>>16)&0xff, (i>>8)&0xff, i&0xff) |
| 442 | self.send_igmp_join([ip], delay = 0) |
| 443 | |
| 444 | @deferred(timeout=IGMP_QUERY_TIMEOUT + 10) |
| 445 | def test_igmp_query(self): |
| 446 | groups = ['224.0.0.1'] ##igmp query group |
| 447 | df = defer.Deferred() |
| 448 | self.df = df |
| 449 | self.recv_socket = L2Socket(iface = 'veth0', type = ETH_P_IP) |
| 450 | |
| 451 | def igmp_query_timeout(): |
Chetan Gaonker | 1f7c3f8 | 2016-03-08 12:17:37 -0800 | [diff] [blame] | 452 | def igmp_query_cb(pkt): |
Chetan Gaonker | bd4390f | 2016-03-09 18:56:52 -0800 | [diff] [blame] | 453 | log.info('Got IGMP query packet from %s for %s' %(pkt[IP].src, pkt[IP].dst)) |
| 454 | assert_equal(pkt[IP].dst, '224.0.0.1') |
| 455 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 456 | 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] | 457 | opened_socket = self.recv_socket) |
Chetan Gaonker | 1f7c3f8 | 2016-03-08 12:17:37 -0800 | [diff] [blame] | 458 | self.recv_socket.close() |
| 459 | self.df.callback(0) |
| 460 | |
| 461 | self.send_igmp_join(groups) |
| 462 | self.test_timer = reactor.callLater(self.IGMP_QUERY_TIMEOUT, igmp_query_timeout) |
| 463 | return df |
| 464 | |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 465 | def igmp_send_joins_different_groups_srclist(self, groups, sources, intf = V_INF1, delay = 2, ip_src = None): |
| 466 | g1 = groups[0] |
| 467 | g2 = groups[1] |
| 468 | sourcelist1 = sources[0] |
| 469 | sourcelist2 = sources[1] |
| 470 | eth = Ether(dst = self.MMACGROUP1, src = self.IGMP_SRC_MAC, type = ETH_P_IP) |
| 471 | src_ip = ip_src or self.IP_SRC |
| 472 | ip = IP(dst = g1, src = src_ip) |
| 473 | log.info('Sending join message for the group %s' %g1) |
| 474 | self.send_igmp_join((g1,), src_list = sourcelist1, ip_pkt = eth/ip, iface = intf, delay = 2) |
| 475 | eth = Ether(dst = self.MMACGROUP2, src = self.IGMP_SRC_MAC, type = ETH_P_IP) |
| 476 | ip = IP(dst = g2, src = src_ip) |
| 477 | log.info('Sending join message for group %s' %g2) |
| 478 | self.send_igmp_join((g2,), src_list = sourcelist2, ip_pkt = eth/ip, iface = intf, delay = 2) |
Chetan Gaonker | 7791bda | 2016-05-12 17:36:52 -0700 | [diff] [blame] | 479 | log.info('Done with igmp_send_joins_different_groups_srclist') |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 480 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 481 | 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): |
| 482 | g1 = groups[0] |
| 483 | g2 = groups[1] |
| 484 | sourcelist1 = sources[0] |
| 485 | sourcelist2 = sources[1] |
| 486 | eth = Ether(dst = self.MMACGROUP1, src = self.IGMP_SRC_MAC, type = ETH_P_IP) |
| 487 | src_ip = ip_src or self.IP_SRC |
| 488 | ip = IP(dst = g1, src = src_ip) |
| 489 | if query_group1 is 'group1': |
| 490 | log.info('Sending join message for the group %s and waiting for a query packet on join interface' %g1) |
| 491 | self.send_igmp_join_recvQuery((g1,), None, src_list = sourcelist1, ip_pkt = eth/ip, iface = intf, delay = 2) |
| 492 | else: |
| 493 | log.info('Sending join message for the group %s' %g1) |
| 494 | self.send_igmp_join((g1,), src_list = sourcelist1, ip_pkt = eth/ip, iface = intf, delay = 2) |
| 495 | eth = Ether(dst = self.MMACGROUP2, src = self.IGMP_SRC_MAC, type = ETH_P_IP) |
| 496 | ip = IP(dst = g2, src = src_ip) |
| 497 | if query_group2 is 'group2': |
| 498 | log.info('Sending join message for the group %s and waiting for a query packet on join interface' %g2) |
| 499 | self.send_igmp_join_recvQuery((g2,), None, src_list = sourcelist2, ip_pkt = eth/ip, iface = intf, delay = 2) |
| 500 | else: |
| 501 | log.info('Sending join message for group %s' %g2) |
| 502 | self.send_igmp_join((g2,), src_list = sourcelist2, ip_pkt = eth/ip, iface = intf, delay = 2) |
| 503 | |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 504 | def igmp_joins_leave_functionality(self, again_join = False, df = None): |
| 505 | groups1 = (self.MGROUP1,) |
| 506 | groups2 = (self.MGROUP2,) |
| 507 | self.igmp_send_joins_different_groups_srclist(groups1 + groups2, |
| 508 | (['2.2.2.2'], ['2.2.2.2']), intf = self.V_INF1, delay = 2) |
| 509 | dst_mac = '01:00:5e:01:02:03' |
| 510 | src_ip = '2.2.2.2' |
| 511 | if df is None: |
| 512 | df = defer.Deferred() |
| 513 | igmpState1 = IGMPTestState(groups = groups1, df = df) |
| 514 | igmpStateRecv1 = IGMPTestState(groups = groups1, df = df) |
| 515 | igmpStateList1 = (igmpState1, igmpStateRecv1) |
| 516 | |
| 517 | igmpState2 = IGMPTestState(groups = groups2, df = df) |
| 518 | igmpStateRecv2 = IGMPTestState(groups = groups2, df = df) |
| 519 | igmpStateList2 = (igmpState2, igmpStateRecv2) |
| 520 | mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac, |
| 521 | src_ip = src_ip, cb = self.send_mcast_cb, |
| 522 | arg = igmpState1) |
| 523 | dst_mac = '01:00:5e:02:02:03' |
| 524 | src_ip = '2.2.2.2' |
| 525 | mcastTraffic2 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac, |
| 526 | src_ip = src_ip, cb = self.send_mcast_cb, |
| 527 | arg = igmpState2) |
| 528 | mcastTraffic1.start() |
| 529 | mcastTraffic2.start() |
| 530 | join_state1 = IGMPTestState(groups = groups1) |
| 531 | join_state2 = IGMPTestState(groups = groups2) |
| 532 | target1 = self.igmp_recv_task(self.V_INF1, groups1, join_state1) |
| 533 | log.info('Interface is receiving multicast groups %s' %groups1) |
| 534 | target2 = self.igmp_recv_task(self.V_INF1, groups2, join_state2) |
| 535 | log.info('Interface is receiving multicast groups %s' %groups2) |
| 536 | log.info('Interface is sending leave message for groups %s now' %groups2) |
| 537 | self.send_igmp_leave(groups = groups2, src_list = ['2.2.2.2'], iface = self.V_INF1, delay = 2) |
| 538 | target3 = self.igmp_recv_task(self.V_INF1, groups1, join_state1) |
| 539 | target4 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state2) |
| 540 | assert target4 == 1, 'EXPECTED FAILURE' |
| 541 | if again_join: |
| 542 | dst_mac = '01:00:5e:02:02:03' |
| 543 | ip_dst = '239.2.2.3' |
| 544 | eth = Ether(dst = dst_mac, src = self.IGMP_SRC_MAC, type = ETH_P_IP) |
| 545 | ip = IP(dst = ip_dst, src = self.IP_SRC) |
| 546 | log.info('Interface sending join message again for the groups %s' %groups2) |
| 547 | self.send_igmp_join(groups2, src_list = [src_ip], ip_pkt = eth/ip, iface = self.V_INF1, delay = 2) |
| 548 | target5 = self.igmp_recv_task(self.V_INF1, groups2, join_state2) |
| 549 | log.info('Interface is receiving multicast groups %s again' %groups2) |
| 550 | target6 = self.igmp_recv_task(self.V_INF1, groups1, join_state1) |
| 551 | log.info('Interface is still receiving from multicast groups %s' %groups1) |
| 552 | else: |
| 553 | log.info('Ended test case') |
| 554 | mcastTraffic1.stop() |
| 555 | mcastTraffic2.stop() |
| 556 | self.onos_ctrl.deactivate() |
| 557 | |
| 558 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20) |
| 559 | def test_igmp_2joins_1leave_functionality(self): |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 560 | df = defer.Deferred() |
| 561 | def test_igmp_2joins_1leave(): |
| 562 | self.igmp_joins_leave_functionality(again_join = False, df = df) |
| 563 | df.callback(0) |
| 564 | reactor.callLater(0, test_igmp_2joins_1leave) |
| 565 | return df |
| 566 | |
| 567 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+25) |
| 568 | def test_igmp_2joins_1leave_again_joins_functionality(self): |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 569 | df = defer.Deferred() |
| 570 | def test_igmp_2joins_1leave_join_again(): |
| 571 | self.igmp_joins_leave_functionality(again_join = True, df = df) |
| 572 | df.callback(0) |
| 573 | reactor.callLater(0, test_igmp_2joins_1leave_join_again) |
| 574 | return df |
| 575 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 576 | def igmp_not_in_src_list_functionality(self, df = None): |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 577 | groups1 = (self.MGROUP1,) |
| 578 | groups2 = (self.MGROUP2,) |
| 579 | self.igmp_send_joins_different_groups_srclist(groups1 + groups2, |
| 580 | (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']), |
| 581 | intf = self.V_INF1, delay = 2) |
| 582 | dst_mac = '01:00:5e:01:02:03' |
| 583 | src_ip = '6.6.6.6' |
| 584 | if df is None: |
| 585 | df = defer.Deferred() |
| 586 | igmpState1 = IGMPTestState(groups = groups1, df = df) |
| 587 | igmpStateRecv1 = IGMPTestState(groups = groups1, df = df) |
| 588 | mcastTraffic1 = McastTraffic(groups1, iface = 'veth2', dst_mac = dst_mac, |
| 589 | src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1) |
| 590 | mcastTraffic1.start() |
| 591 | join_state1 = IGMPTestState(groups = groups1) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 592 | 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] | 593 | target1 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1) |
Chetan Gaonker | 7791bda | 2016-05-12 17:36:52 -0700 | [diff] [blame] | 594 | assert target1 == 2, 'EXPECTED FAILURE' |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 595 | 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] | 596 | mcastTraffic1.stop() |
| 597 | self.onos_ctrl.deactivate() |
| 598 | |
| 599 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 600 | def test_igmp_not_in_src_list_functionality(self): |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 601 | df = defer.Deferred() |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 602 | def igmp_not_in_src_list_functionality(): |
| 603 | self.igmp_not_in_src_list_functionality(df = df) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 604 | df.callback(0) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 605 | reactor.callLater(0, igmp_not_in_src_list_functionality) |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 606 | return df |
| 607 | |
| 608 | def igmp_change_to_exclude_src_list_functionality(self, df = None): |
| 609 | groups1 = (self.MGROUP1,) |
| 610 | groups2 = (self.MGROUP2,) |
| 611 | self.igmp_send_joins_different_groups_srclist(groups1 + groups2, |
| 612 | (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']), |
| 613 | intf = self.V_INF1, delay = 2) |
| 614 | dst_mac = '01:00:5e:01:02:03' |
| 615 | src_ip = '2.2.2.2' |
| 616 | if df is None: |
| 617 | df = defer.Deferred() |
| 618 | igmpState1 = IGMPTestState(groups = groups1, df = df) |
| 619 | igmpStateRecv1 = IGMPTestState(groups = groups1, df = df) |
| 620 | mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac, |
| 621 | src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1) |
| 622 | mcastTraffic1.start() |
| 623 | join_state1 = IGMPTestState(groups = groups1) |
| 624 | target1 = self.igmp_recv_task(self.V_INF1, groups1, join_state1) |
| 625 | self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2'], iface = self.V_INF1, delay =2) |
| 626 | target2 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1) |
Chetan Gaonker | 7791bda | 2016-05-12 17:36:52 -0700 | [diff] [blame] | 627 | assert target2 == 2, 'EXPECTED FAILURE' |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 628 | log.info('Interface is not receiving from multicast groups %s after sending CHANGE_TO_EXCLUDE' %groups1) |
| 629 | mcastTraffic1.stop() |
| 630 | self.onos_ctrl.deactivate() |
| 631 | |
| 632 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10) |
| 633 | def test_igmp_change_to_exclude_src_list_functionality(self): |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 634 | df = defer.Deferred() |
| 635 | def igmp_change_to_exclude_src_list_functionality(): |
| 636 | self.igmp_change_to_exclude_src_list_functionality(df = df) |
| 637 | df.callback(0) |
| 638 | reactor.callLater(0, igmp_change_to_exclude_src_list_functionality) |
| 639 | return df |
| 640 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 641 | def igmp_include_to_allow_src_list_functionality(self, df = None): |
| 642 | groups1 = (self.MGROUP1,) |
| 643 | groups2 = (self.MGROUP2,) |
| 644 | self.igmp_send_joins_different_groups_srclist(groups1 + groups2, |
| 645 | (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']), |
| 646 | intf = self.V_INF1, delay = 2) |
| 647 | dst_mac = '01:00:5e:01:02:03' |
| 648 | src_ip = '2.2.2.2' |
| 649 | if df is None: |
| 650 | df = defer.Deferred() |
| 651 | igmpState1 = IGMPTestState(groups = groups1, df = df) |
| 652 | igmpStateRecv1 = IGMPTestState(groups = groups1, df = df) |
| 653 | mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac, |
| 654 | src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1) |
| 655 | mcastTraffic1.start() |
| 656 | join_state1 = IGMPTestState(groups = groups1) |
| 657 | target1 = self.igmp_recv_task(self.V_INF1, groups1, join_state1) |
| 658 | self.igmp_send_joins_different_groups_srclist(groups1 + groups2, |
| 659 | (['2.2.2.2', '3.3.3.3', '4.4.4.4', '6.6.6.6'], ['2.2.2.2', '5.5.5.5']), |
| 660 | intf = self.V_INF1, delay = 2) |
| 661 | target1 = self.igmp_recv_task(self.V_INF1, groups1, join_state1) |
| 662 | mcastTraffic1.stop() |
| 663 | self.onos_ctrl.deactivate() |
| 664 | |
| 665 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+30) |
| 666 | def test_igmp_include_to_allow_src_list_functionality(self): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 667 | df = defer.Deferred() |
| 668 | def igmp_include_to_allow_src_list_functionality(): |
| 669 | self.igmp_include_to_allow_src_list_functionality(df = df) |
| 670 | df.callback(0) |
| 671 | reactor.callLater(0, igmp_include_to_allow_src_list_functionality) |
| 672 | return df |
| 673 | |
| 674 | def igmp_include_to_block_src_list_functionality(self, df = None): |
| 675 | groups1 = (self.MGROUP1,) |
| 676 | groups2 = (self.MGROUP2,) |
| 677 | self.igmp_send_joins_different_groups_srclist(groups1 + groups2, |
| 678 | (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']), |
| 679 | intf = self.V_INF1, delay = 2) |
| 680 | dst_mac = '01:00:5e:01:02:03' |
| 681 | src_ip = '2.2.2.2' |
| 682 | if df is None: |
| 683 | df = defer.Deferred() |
| 684 | igmpState1 = IGMPTestState(groups = groups1, df = df) |
| 685 | igmpStateRecv1 = IGMPTestState(groups = groups1, df = df) |
| 686 | mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac, |
| 687 | src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1) |
| 688 | mcastTraffic1.start() |
| 689 | join_state1 = IGMPTestState(groups = groups1) |
| 690 | target1 = self.igmp_recv_task(self.V_INF1, groups1, join_state1) |
| 691 | self.send_igmp_leave(groups = groups1, src_list = ['6.6.6.6','7.7.7.7'], |
| 692 | iface = self.V_INF1, delay = 2) |
| 693 | target1 = self.igmp_recv_task(self.V_INF1, groups1, join_state1) |
| 694 | log.info('Interface is still receiving from old multicast group data %s even after we send bolck list' %groups1) |
| 695 | mcastTraffic1.stop() |
| 696 | self.onos_ctrl.deactivate() |
| 697 | |
| 698 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+30) |
| 699 | def test_igmp_include_to_block_src_list_functionality(self): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 700 | df = defer.Deferred() |
| 701 | def igmp_include_to_block_src_list_functionality(): |
| 702 | self.igmp_include_to_block_src_list_functionality(df = df) |
| 703 | df.callback(0) |
| 704 | reactor.callLater(0, igmp_include_to_block_src_list_functionality) |
| 705 | return df |
| 706 | |
| 707 | |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 708 | def igmp_change_to_include_src_list_functionality(self, df = None): |
| 709 | groups1 = (self.MGROUP1,) |
| 710 | groups2 = (self.MGROUP2,) |
| 711 | self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4'], |
| 712 | iface = self.V_INF1, delay = 2) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 713 | |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 714 | dst_mac = '01:00:5e:01:02:03' |
| 715 | src_ip = '2.2.2.2' |
| 716 | if df is None: |
| 717 | df = defer.Deferred() |
| 718 | igmpState1 = IGMPTestState(groups = groups1, df = df) |
| 719 | igmpStateRecv1 = IGMPTestState(groups = groups1, df = df) |
| 720 | mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac, |
| 721 | src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1) |
| 722 | mcastTraffic1.start() |
| 723 | join_state1 = IGMPTestState(groups = groups1) |
| 724 | target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1) |
| 725 | assert target1 == 1, 'EXPECTED FAILURE' |
| 726 | log.info('Interface is not receiving from multicast groups %s' %groups1) |
| 727 | self.igmp_send_joins_different_groups_srclist(groups1 + groups2, |
| 728 | (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['6.6.6.6', '5.5.5.5']), |
| 729 | intf = self.V_INF1, delay = 2) |
| 730 | target2 = self.igmp_recv_task(self.V_INF1, groups1, join_state1) |
| 731 | log.info('Interface is receiving from multicast groups %s after send Change to include message' %groups1) |
| 732 | mcastTraffic1.stop() |
| 733 | self.onos_ctrl.deactivate() |
| 734 | |
| 735 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10) |
| 736 | def test_igmp_change_to_include_src_list_functionality(self): |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 737 | df = defer.Deferred() |
| 738 | def igmp_change_to_include_src_list_functionality(): |
| 739 | self.igmp_change_to_include_src_list_functionality(df = df) |
| 740 | df.callback(0) |
| 741 | reactor.callLater(0, igmp_change_to_include_src_list_functionality) |
| 742 | return df |
| 743 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 744 | def igmp_exclude_to_allow_src_list_functionality(self, df = None): |
| 745 | groups1 = (self.MGROUP1,) |
| 746 | groups2 = (self.MGROUP2,) |
| 747 | self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4'], |
| 748 | iface = self.V_INF1, delay = 2) |
| 749 | |
| 750 | dst_mac = '01:00:5e:01:02:03' |
| 751 | src_ip = '2.2.2.2' |
| 752 | if df is None: |
| 753 | df = defer.Deferred() |
| 754 | igmpState1 = IGMPTestState(groups = groups1, df = df) |
| 755 | igmpStateRecv1 = IGMPTestState(groups = groups1, df = df) |
| 756 | mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac, |
| 757 | src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1) |
| 758 | mcastTraffic1.start() |
| 759 | join_state1 = IGMPTestState(groups = groups1) |
| 760 | target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1) |
| 761 | assert target1 == 1, 'EXPECTED FAILURE' |
| 762 | log.info('Interface is not receiving from multicast groups %s' %groups1) |
| 763 | self.igmp_send_joins_different_groups_srclist(groups1 + groups2, |
| 764 | (['6.6.6.6', '7.7.7.7', '8.8.8.8'], ['6.6.6.6', '5.5.5.5']), |
| 765 | intf = self.V_INF1, delay = 2) |
| 766 | target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1) |
| 767 | assert target1 == 1, 'EXPECTED FAILURE' |
| 768 | log.info('Interface is not receiving from multicast groups %s' %groups1) |
| 769 | mcastTraffic1.stop() |
| 770 | self.onos_ctrl.deactivate() |
| 771 | |
| 772 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10) |
| 773 | def test_igmp_exclude_to_allow_src_list_functionality(self): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 774 | df = defer.Deferred() |
| 775 | def igmp_exclude_to_allow_src_list_functionality(): |
| 776 | self.igmp_exclude_to_allow_src_list_functionality(df = df) |
| 777 | df.callback(0) |
| 778 | reactor.callLater(0, igmp_exclude_to_allow_src_list_functionality) |
| 779 | return df |
| 780 | |
| 781 | def igmp_exclude_to_block_src_list_functionality(self, df = None): |
| 782 | groups1 = (self.MGROUP1,) |
| 783 | groups2 = (self.MGROUP2,) |
| 784 | self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4'], |
| 785 | iface = self.V_INF1, delay = 2) |
| 786 | |
| 787 | dst_mac = '01:00:5e:01:02:03' |
| 788 | src_ip = '2.2.2.2' |
| 789 | if df is None: |
| 790 | df = defer.Deferred() |
| 791 | igmpState1 = IGMPTestState(groups = groups1, df = df) |
| 792 | igmpStateRecv1 = IGMPTestState(groups = groups1, df = df) |
| 793 | mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac, |
| 794 | src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1) |
| 795 | mcastTraffic1.start() |
| 796 | join_state1 = IGMPTestState(groups = groups1) |
| 797 | target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1) |
| 798 | assert target1 == 1, 'EXPECTED FAILURE' |
| 799 | log.info('Interface is not receiving from multicast groups %s' %groups1) |
| 800 | 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'], |
| 801 | iface = self.V_INF1, delay = 2) |
| 802 | target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1) |
| 803 | assert target1 == 1, 'EXPECTED FAILURE' |
| 804 | log.info('Interface is not receiving from multicast groups %s' %groups1) |
| 805 | mcastTraffic1.stop() |
| 806 | self.onos_ctrl.deactivate() |
| 807 | |
| 808 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10) |
| 809 | def test_igmp_exclude_to_block_src_list_functionality(self): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 810 | df = defer.Deferred() |
| 811 | def igmp_exclude_to_block_src_list_functionality(): |
| 812 | self.igmp_exclude_to_block_src_list_functionality(df = df) |
| 813 | df.callback(0) |
| 814 | reactor.callLater(0, igmp_exclude_to_block_src_list_functionality) |
| 815 | return df |
| 816 | |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 817 | def igmp_new_src_list_functionality(self, df = None): |
| 818 | groups1 = (self.MGROUP1,) |
| 819 | groups2 = (self.MGROUP2,) |
| 820 | self.igmp_send_joins_different_groups_srclist(groups1+groups2, |
| 821 | (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']), |
| 822 | intf = self.V_INF1, delay = 2) |
| 823 | dst_mac = '01:00:5e:01:02:03' |
| 824 | src_ip = '6.6.6.6' |
| 825 | if df is None: |
| 826 | df = defer.Deferred() |
| 827 | igmpState1 = IGMPTestState(groups = groups1, df = df) |
| 828 | igmpStateRecv1 = IGMPTestState(groups = groups1, df = df) |
| 829 | mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac, |
| 830 | src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1) |
| 831 | mcastTraffic1.start() |
| 832 | join_state1 = IGMPTestState(groups = groups1) |
| 833 | target1 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1) |
| 834 | assert target1 == 1, 'EXPECTED FAILURE' |
| 835 | log.info('Interface is not receiving from multicast groups %s' %groups1) |
| 836 | self.igmp_send_joins_different_groups_srclist(groups1 + groups2, |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 837 | (['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] | 838 | intf = self.V_INF1, delay = 2) |
| 839 | target2 = self.igmp_recv_task(self.V_INF1, groups1, join_state1) |
| 840 | log.info('Interface is receiving from multicast groups %s after sending join with new source list' %groups1) |
| 841 | mcastTraffic1.stop() |
| 842 | self.onos_ctrl.deactivate() |
| 843 | |
| 844 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10) |
| 845 | def test_igmp_new_src_list_functionality(self): |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 846 | df = defer.Deferred() |
| 847 | def igmp_new_src_list_functionality(): |
| 848 | self.igmp_new_src_list_functionality(df = df) |
| 849 | df.callback(0) |
| 850 | reactor.callLater(0, igmp_new_src_list_functionality) |
| 851 | return df |
| 852 | |
| 853 | def igmp_block_old_src_list_functionality(self, df = None): |
| 854 | groups1 = (self.MGROUP1,) |
| 855 | groups2 = (self.MGROUP2,) |
| 856 | groups = groups1 + groups2 |
| 857 | self.igmp_send_joins_different_groups_srclist(groups, |
| 858 | (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']), |
| 859 | intf = self.V_INF1, delay = 2) |
| 860 | dst_mac = '01:00:5e:02:02:03' |
| 861 | src_ip = '5.5.5.5' |
| 862 | if df is None: |
| 863 | df = defer.Deferred() |
| 864 | igmpState1 = IGMPTestState(groups = groups2, df = df) |
| 865 | igmpStateRecv1 = IGMPTestState(groups = groups2, df = df) |
| 866 | mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac, |
| 867 | src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1) |
| 868 | mcastTraffic1.start() |
| 869 | join_state1 = IGMPTestState(groups = groups2) |
| 870 | target1 = self.igmp_recv_task(self.V_INF1, groups2, join_state1) |
| 871 | log.info('Interface is receiving from multicast groups %s' %groups2) |
| 872 | self.igmp_send_joins_different_groups_srclist(groups, |
| 873 | (['6.6.6.6', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '7.7.7.7']), |
| 874 | intf = self.V_INF1, delay = 2) |
| 875 | target2 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1) |
Chetan Gaonker | 7791bda | 2016-05-12 17:36:52 -0700 | [diff] [blame] | 876 | assert target2 == 2, 'EXPECTED FAILURE' |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 877 | log.info('Interface is not receiving from multicast groups %s after sending join with block old source list' %groups2) |
| 878 | mcastTraffic1.stop() |
| 879 | self.onos_ctrl.deactivate() |
| 880 | |
| 881 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20) |
| 882 | def test_igmp_block_old_src_list_functionality(self): |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 883 | df = defer.Deferred() |
| 884 | def igmp_block_old_src_list_functionality(): |
| 885 | self.igmp_block_old_src_list_functionality(df = df) |
| 886 | df.callback(0) |
| 887 | reactor.callLater(0, igmp_block_old_src_list_functionality) |
| 888 | return df |
| 889 | |
| 890 | def igmp_include_empty_src_list_functionality(self, df = None): |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 891 | groups1 = (self.MGROUP1,) |
| 892 | groups2 = (self.MGROUP2,) |
| 893 | groups = groups1 + groups2 |
| 894 | self.igmp_send_joins_different_groups_srclist(groups, |
| 895 | (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['']), |
| 896 | intf = self.V_INF1, delay = 2) |
| 897 | dst_mac = '01:00:5e:02:02:03' |
| 898 | src_ip = '5.5.5.5' |
| 899 | if df is None: |
| 900 | df = defer.Deferred() |
| 901 | igmpState1 = IGMPTestState(groups = groups2, df = df) |
| 902 | igmpStateRecv1 = IGMPTestState(groups = groups2, df = df) |
| 903 | mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac, |
| 904 | src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1) |
| 905 | mcastTraffic1.start() |
| 906 | join_state1 = IGMPTestState(groups = groups2) |
| 907 | target1 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1) |
| 908 | assert target1==1, 'EXPECTED FAILURE' |
| 909 | log.info('Interface is not receiving from multicast groups %s when we sent join with source list is empty' %groups2) |
| 910 | mcastTraffic1.stop() |
| 911 | self.onos_ctrl.deactivate() |
| 912 | |
| 913 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20) |
| 914 | def ztest_igmp_include_empty_src_list_functionality(self): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 915 | ## '''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] | 916 | df = defer.Deferred() |
| 917 | def igmp_include_empty_src_list_functionality(): |
| 918 | self.igmp_include_empty_src_list_functionality(df = df) |
| 919 | df.callback(0) |
| 920 | reactor.callLater(0, igmp_include_empty_src_list_functionality) |
| 921 | return df |
| 922 | |
| 923 | def igmp_exclude_empty_src_list_functionality(self, df = None): |
| 924 | groups1 = (self.MGROUP1,) |
| 925 | groups2 = (self.MGROUP2,) |
| 926 | groups = groups1 + groups2 |
| 927 | self.send_igmp_leave(groups = groups2, src_list = [''], iface = self.V_INF1, delay = 2) |
| 928 | dst_mac = '01:00:5e:02:02:03' |
| 929 | src_ip = '5.5.5.5' |
| 930 | if df is None: |
| 931 | df = defer.Deferred() |
| 932 | igmpState1 = IGMPTestState(groups = groups2, df = df) |
| 933 | igmpStateRecv1 = IGMPTestState(groups = groups2, df = df) |
| 934 | mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac, |
| 935 | src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1) |
| 936 | mcastTraffic1.start() |
| 937 | join_state1 = IGMPTestState(groups = groups2) |
| 938 | target1 = self.igmp_recv_task(self.V_INF1, groups2, join_state1) |
| 939 | log.info('Interface is receiving multicast groups %s' %groups2) |
| 940 | mcastTraffic1.stop() |
| 941 | self.onos_ctrl.deactivate() |
| 942 | |
| 943 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20) |
| 944 | def ztest_igmp_exclude_empty_src_list_functionality(self): |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 945 | df = defer.Deferred() |
| 946 | def igmp_exclude_empty_src_list_functionality(): |
| 947 | self.igmp_exclude_empty_src_list_functionality() |
| 948 | df.callback(0) |
| 949 | reactor.callLater(0, igmp_exclude_empty_src_list_functionality) |
| 950 | return df |
| 951 | |
| 952 | def igmp_join_sourceip_0_0_0_0_functionality(self, df = None): |
| 953 | groups1 = (self.MGROUP1,) |
| 954 | groups2 = (self.MGROUP2,) |
| 955 | groups = groups1 + groups2 |
| 956 | ip_src = '0.0.0.0' |
| 957 | self.igmp_send_joins_different_groups_srclist(groups, |
| 958 | (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['5.5.5.5']), |
| 959 | intf = self.V_INF1, delay = 2, ip_src = ip_src) |
| 960 | ip_src = self.IP_SRC |
| 961 | dst_mac = '01:00:5e:02:02:03' |
| 962 | src_ip = '5.5.5.5' |
| 963 | if df is None: |
| 964 | df = defer.Deferred() |
| 965 | igmpState1 = IGMPTestState(groups = groups2, df = df) |
| 966 | igmpStateRecv1 = IGMPTestState(groups = groups2, df = df) |
| 967 | mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac, |
| 968 | src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1) |
| 969 | mcastTraffic1.start() |
| 970 | join_state1 = IGMPTestState(groups = groups2) |
| 971 | target1 = self.igmp_recv_task(self.V_INF1, groups2, join_state1) |
| 972 | log.info('Interface is receiving from multicast groups %s when we sent join with source IP is 0.0.0.0' %groups2) |
| 973 | mcastTraffic1.stop() |
| 974 | self.onos_ctrl.deactivate() |
| 975 | |
| 976 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20) |
| 977 | def test_igmp_join_sourceip_0_0_0_0_functionality(self): |
Chetan Gaonker | 8bbc4d5 | 2016-03-29 16:59:45 -0700 | [diff] [blame] | 978 | df = defer.Deferred() |
| 979 | def igmp_join_sourceip_0_0_0_0_functionality(): |
| 980 | self.igmp_join_sourceip_0_0_0_0_functionality(df = df) |
| 981 | df.callback(0) |
| 982 | reactor.callLater(0, igmp_join_sourceip_0_0_0_0_functionality) |
| 983 | return df |
| 984 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 985 | |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 986 | def igmp_invalid_join_packet_functionality(self, df = None): |
| 987 | groups1 = (self.MGROUP1,) |
| 988 | groups2 = (self.MINVALIDGROUP1,) |
| 989 | groups = groups1 + groups2 |
| 990 | ip_src = '1.1.1.1' |
| 991 | self.igmp_send_joins_different_groups_srclist(groups, |
| 992 | (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['5.5.5.5']), |
| 993 | intf = self.V_INF1, delay = 2, ip_src = ip_src) |
| 994 | ip_src = self.IP_SRC |
| 995 | dst_mac = '01:00:5e:02:02:03' |
| 996 | src_ip = '5.5.5.5' |
| 997 | if df is None: |
| 998 | df = defer.Deferred() |
| 999 | igmpState1 = IGMPTestState(groups = groups2, df = df) |
| 1000 | igmpStateRecv1 = IGMPTestState(groups = groups2, df = df) |
| 1001 | mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac, |
| 1002 | src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1) |
| 1003 | mcastTraffic1.start() |
| 1004 | join_state1 = IGMPTestState(groups = groups2) |
| 1005 | target1 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1) |
| 1006 | assert target1==1, 'EXPECTED FAILURE' |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1007 | 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] | 1008 | mcastTraffic1.stop() |
| 1009 | self.onos_ctrl.deactivate() |
| 1010 | |
| 1011 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20) |
| 1012 | def test_igmp_invalid_join_packet_functionality(self): |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1013 | df = defer.Deferred() |
| 1014 | def igmp_invalid_join_packet_functionality(): |
| 1015 | self.igmp_invalid_join_packet_functionality(df = df) |
| 1016 | df.callback(0) |
| 1017 | reactor.callLater(0, igmp_invalid_join_packet_functionality) |
| 1018 | return df |
| 1019 | |
| 1020 | def igmp_join_data_receiving_during_subscriber_link_down_up_functionality(self, df = None): |
| 1021 | groups1 = (self.MGROUP1,) |
| 1022 | groups2 = (self.MGROUP2,) |
| 1023 | groups = groups1 + groups2 |
| 1024 | ip_src = '1.1.1.1' |
| 1025 | self.igmp_send_joins_different_groups_srclist(groups, |
| 1026 | (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['5.5.5.5']), |
| 1027 | intf = self.V_INF1, delay = 2, ip_src = ip_src) |
| 1028 | ip_src = self.IP_SRC |
| 1029 | dst_mac = '01:00:5e:02:02:03' |
| 1030 | src_ip = '5.5.5.5' |
| 1031 | if df is None: |
| 1032 | df = defer.Deferred() |
| 1033 | igmpState1 = IGMPTestState(groups = groups2, df = df) |
| 1034 | igmpStateRecv1 = IGMPTestState(groups = groups2, df = df) |
| 1035 | mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac, |
| 1036 | src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1) |
| 1037 | mcastTraffic1.start() |
| 1038 | join_state1 = IGMPTestState(groups = groups2) |
| 1039 | target1 = self.igmp_recv_task(self.V_INF1, groups2, join_state1) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1040 | 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] | 1041 | os.system('ifconfig '+self.V_INF1+' down') |
| 1042 | log.info(' the self.V_INF1 %s is down now ' %self.V_INF1) |
| 1043 | os.system('ifconfig '+self.V_INF1) |
| 1044 | time.sleep(10) |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1045 | os.system('ifconfig '+self.V_INF1+' up') |
| 1046 | os.system('ifconfig '+self.V_INF1) |
| 1047 | 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] | 1048 | target1 = self.igmp_recv_task(self.V_INF1, groups2, join_state1) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1049 | 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] | 1050 | mcastTraffic1.stop() |
| 1051 | self.onos_ctrl.deactivate() |
| 1052 | |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1053 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1054 | def test_igmp_join_data_receiving_during_subscriber_link_up_down_functionality(self): |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1055 | df = defer.Deferred() |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1056 | def igmp_join_data_receiving_during_subscriber_link_up_down_functionality(): |
| 1057 | self.igmp_join_data_receiving_during_subscriber_link_down_up_functionality(df = df) |
| 1058 | df.callback(0) |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1059 | reactor.callLater(0, igmp_join_data_receiving_during_subscriber_link_down_up_functionality) |
| 1060 | return df |
| 1061 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1062 | def igmp_join_data_receiving_during_channel_distributor_link_up_down_functionality(self, df = None): |
| 1063 | groups1 = (self.MGROUP1,) |
| 1064 | groups2 = (self.MGROUP2,) |
| 1065 | groups = groups1 + groups2 |
| 1066 | ip_src = '1.1.1.1' |
| 1067 | self.igmp_send_joins_different_groups_srclist(groups, |
| 1068 | (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['5.5.5.5', '6.6.6.6']), |
| 1069 | intf = self.V_INF1, delay = 2, ip_src = ip_src) |
| 1070 | ip_src = self.IP_SRC |
| 1071 | dst_mac1 = '01:00:5e:01:02:03' |
| 1072 | dst_mac2 = '01:00:5e:02:02:03' |
| 1073 | src_ip2 = '5.5.5.5' |
| 1074 | src_ip1 = '2.2.2.2' |
| 1075 | if df is None: |
| 1076 | df = defer.Deferred() |
| 1077 | igmpState1 = IGMPTestState(groups = groups1, df = df) |
| 1078 | igmpState2 = IGMPTestState(groups = groups2, df = df) |
| 1079 | igmpStateRecv1 = IGMPTestState(groups = groups1, df = df) |
| 1080 | igmpStateRecv2 = IGMPTestState(groups = groups2, df = df) |
| 1081 | mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac1, |
| 1082 | src_ip = src_ip1, cb = self.send_mcast_cb, arg = igmpState1) |
| 1083 | mcastTraffic2 = McastTraffic(groups2, iface= 'veth3', dst_mac = dst_mac2, |
| 1084 | src_ip = src_ip2, cb = self.send_mcast_cb, arg = igmpState2) |
| 1085 | mcastTraffic1.start() |
| 1086 | mcastTraffic2.start() |
| 1087 | join_state1 = IGMPTestState(groups = groups1) |
| 1088 | join_state2 = IGMPTestState(groups = groups2) |
| 1089 | target1 = self.igmp_recv_task(self.V_INF1, groups1, join_state1) |
| 1090 | target2 = self.igmp_recv_task(self.V_INF1, groups2, join_state2) |
| 1091 | 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) |
| 1092 | mcastTraffic1.stop() |
| 1093 | os.system('ifconfig '+'veth2'+' down') |
| 1094 | log.info(' the channel distributor interface veth2 is down now ' ) |
| 1095 | os.system('ifconfig '+'veth2') |
| 1096 | time.sleep(10) |
| 1097 | log.info('Verifying interface is still receiving a multicast groups2 %s traffic even though other group traffic sending interface goes down' %groups2) |
| 1098 | target2 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1) |
| 1099 | log.info('Verified that interface is still receiving a multicast groups2 %s traffic even though other group traffic sending interface goes down' %groups2) |
| 1100 | target1 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1) |
| 1101 | assert target1==1, 'EXPECTED FAILURE' |
| 1102 | log.info('Interface is not receiving from multicast groups1 %s when we shutdown the subscriber interface ' %groups1) |
| 1103 | os.system('ifconfig '+'veth2'+' up') |
| 1104 | os.system('ifconfig '+'veth2') |
| 1105 | log.info(' the channel distributor interface veth2 is up now ') |
| 1106 | time.sleep(10) |
| 1107 | mcastTraffic1.start() |
| 1108 | log.info('Verifying interface is receiving from both multicast groups data %s when we bringup interface up after down ' %groups2) |
| 1109 | target1 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1) |
| 1110 | target2 = self.igmp_recv_task(self.V_INF1, groups2, join_state2) |
| 1111 | target2 = self.igmp_recv_task(self.V_INF1, groups2, join_state2) |
| 1112 | log.info('Interface is receiving from multicast groups %s when we bringup interface up after down ' %groups2) |
| 1113 | mcastTraffic2.stop() |
| 1114 | self.onos_ctrl.deactivate() |
| 1115 | ## This test case is failing to receive traffic from multicast data from defferent channel interfaces TO-DO |
| 1116 | ###### TO DO scenario ####### |
| 1117 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+60) |
Chetan Gaonker | 7791bda | 2016-05-12 17:36:52 -0700 | [diff] [blame] | 1118 | def test_igmp_join_data_receiving_during_channel_distributor_link_down_up_functionality(self): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1119 | df = defer.Deferred() |
| 1120 | def igmp_join_data_receiving_during_channel_distributor_link_down_up_functionality(): |
| 1121 | self.igmp_join_data_receiving_during_channel_distributor_link_down_up_functionality(df = df) |
| 1122 | df.callback(0) |
| 1123 | reactor.callLater(0, igmp_join_data_receiving_during_channel_distributor_link_down_up_functionality) |
| 1124 | return df |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1125 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1126 | def igmp_invalidClassD_IP_join_packet_functionality(self, df = None): |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1127 | groups1 = (self.MGROUP1,) |
| 1128 | groups2 = (self.MINVALIDGROUP2,) |
| 1129 | groups = groups1 + groups2 |
| 1130 | ip_src = '1.1.1.1' |
| 1131 | self.igmp_send_joins_different_groups_srclist(groups, |
| 1132 | (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['5.5.5.5']), |
| 1133 | intf = self.V_INF1, delay = 2, ip_src = ip_src) |
| 1134 | ip_src = self.IP_SRC |
| 1135 | dst_mac = '01:00:5e:02:02:03' |
| 1136 | src_ip = '5.5.5.5' |
| 1137 | if df is None: |
| 1138 | df = defer.Deferred() |
| 1139 | igmpState1 = IGMPTestState(groups = groups2, df = df) |
| 1140 | igmpStateRecv1 = IGMPTestState(groups = groups2, df = df) |
| 1141 | mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac, |
| 1142 | src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1) |
| 1143 | mcastTraffic1.start() |
| 1144 | join_state1 = IGMPTestState(groups = groups2) |
| 1145 | target1 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1) |
| 1146 | assert target1==1, 'EXPECTED FAILURE' |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1147 | 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] | 1148 | mcastTraffic1.stop() |
| 1149 | self.onos_ctrl.deactivate() |
| 1150 | |
| 1151 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1152 | def test_igmp_invalidClassD_IP_join_packet_functionality(self): |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1153 | df = defer.Deferred() |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1154 | def igmp_invalidClass_D_IP_join_packet_functionality(): |
| 1155 | self.igmp_invalidClass_D_IP_join_packet_functionality(df = df) |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1156 | df.callback(0) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1157 | reactor.callLater(0, igmp_invalidClassD_IP_join_packet_functionality) |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1158 | return df |
| 1159 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1160 | def igmp_invalidClassD_IP_as_srclistIP_join_packet_functionality(self, df = None): |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1161 | groups1 = (self.MGROUP1,) |
| 1162 | groups2 = (self.MGROUP2,) |
| 1163 | groups = groups1 + groups2 |
| 1164 | ip_src = '1.1.1.1' |
| 1165 | self.igmp_send_joins_different_groups_srclist(groups, |
| 1166 | (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['239.5.5.5']), |
| 1167 | intf = self.V_INF1, delay = 2, ip_src = ip_src) |
| 1168 | ip_src = self.IP_SRC |
| 1169 | dst_mac = '01:00:5e:02:02:03' |
| 1170 | src_ip = '5.5.5.5' |
| 1171 | if df is None: |
| 1172 | df = defer.Deferred() |
| 1173 | igmpState1 = IGMPTestState(groups = groups2, df = df) |
| 1174 | igmpStateRecv1 = IGMPTestState(groups = groups2, df = df) |
| 1175 | mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac, |
| 1176 | src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1) |
| 1177 | mcastTraffic1.start() |
| 1178 | join_state1 = IGMPTestState(groups = groups2) |
| 1179 | target1 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1) |
| 1180 | assert target1==1, 'EXPECTED FAILURE' |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1181 | 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] | 1182 | mcastTraffic1.stop() |
| 1183 | self.onos_ctrl.deactivate() |
| 1184 | |
| 1185 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20) |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1186 | def test_igmp_invalidClassD_IP_as_srclistIP_join_packet_functionality(self): |
Chetan Gaonker | 586fec3 | 2016-04-29 17:33:54 -0700 | [diff] [blame] | 1187 | df = defer.Deferred() |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1188 | def igmp_invalidClassD_IP_as_srclistIP_join_packet_functionality(): |
| 1189 | self.igmp_invalidClassD_IP_as_srclistIP_join_packet_functionality(df = df) |
| 1190 | df.callback(0) |
| 1191 | reactor.callLater(0, igmp_invalidClassD_IP_as_srclistIP_join_packet_functionality) |
| 1192 | return df |
Chetan Gaonker | f72ca40 | 2016-05-02 16:29:32 -0700 | [diff] [blame] | 1193 | |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1194 | |
| 1195 | def igmp_general_query_recv_packet_functionality(self, df = None): |
| 1196 | groups1 = (self.MGROUP1,) |
| 1197 | groups2 = (self.MGROUP2,) |
| 1198 | groups = groups1 + groups2 |
| 1199 | ip_src = '1.1.1.1' |
| 1200 | self.igmp_send_joins_different_groups_srclist(groups, |
| 1201 | (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['5.5.5.5']), |
| 1202 | intf = self.V_INF1, delay = 2, ip_src = ip_src) |
| 1203 | ip_src = self.IP_SRC |
| 1204 | dst_mac = '01:00:5e:02:02:03' |
| 1205 | src_ip = '5.5.5.5' |
| 1206 | if df is None: |
| 1207 | df = defer.Deferred() |
| 1208 | igmpState1 = IGMPTestState(groups = groups2, df = df) |
| 1209 | igmpStateRecv1 = IGMPTestState(groups = groups2, df = df) |
| 1210 | mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac, |
| 1211 | src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1) |
| 1212 | mcastTraffic1.start() |
| 1213 | join_state1 = IGMPTestState(groups = groups2) |
| 1214 | log.info('Started delay to verify multicast data taraffic for group %s is received or not for 180 sec ' %groups2) |
| 1215 | time.sleep(100) |
| 1216 | target2 = self.igmp_recv_task(self.V_INF1, groups2, join_state1) |
| 1217 | log.info('Verified that multicast data for group %s is received after 100 sec ' %groups2) |
| 1218 | time.sleep(50) |
| 1219 | target2 = self.igmp_recv_task(self.V_INF1, groups2, join_state1) |
| 1220 | log.info('Verified that multicast data for group %s is received after 150 sec ' %groups2) |
| 1221 | time.sleep(30) |
| 1222 | target2 = self.igmp_recv_task(self.V_INF1, groups2, join_state1) |
| 1223 | log.info('Verified that multicast data for group %s is received after 180 sec ' %groups2) |
| 1224 | time.sleep(10) |
| 1225 | target2 = self.igmp_recv_task(self.V_INF1, groups2, join_state1) |
| 1226 | log.info('Verified that multicast data for group %s is received after 190 sec ' %groups2) |
| 1227 | target3 = mcastTraffic1.isRecvStopped() |
| 1228 | assert target3==False, 'EXPECTED FAILURE' |
| 1229 | log.info('Verified that multicast data for a group %s is still transmitting from a data interface' %groups2) |
| 1230 | log.info('Now checking joining interface is receiving a multicast data for group %s after 190 sec' %groups2) |
| 1231 | target1 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1) |
| 1232 | assert target1==1, 'EXPECTED FAILURE' |
| 1233 | log.info('Interface is not receiving multicast data for group %s' %groups2) |
| 1234 | mcastTraffic1.stop() |
| 1235 | self.onos_ctrl.deactivate() |
| 1236 | |
| 1237 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+250) |
| 1238 | def test_igmp_general_query_recv_packet_traffic_functionality(self): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1239 | df = defer.Deferred() |
| 1240 | def igmp_general_query_recv_packet_functionality(): |
| 1241 | self.igmp_general_query_recv_packet_functionality(df = df) |
| 1242 | df.callback(0) |
| 1243 | reactor.callLater(0, igmp_general_query_recv_packet_functionality) |
| 1244 | return df |
| 1245 | |
| 1246 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+80) |
| 1247 | def test_igmp_query_packet_received_on_joining_interface(self): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1248 | groups = ['224.0.1.10', '225.0.0.10'] |
| 1249 | leave_groups = ['224.0.1.10'] |
| 1250 | df = defer.Deferred() |
| 1251 | igmpState = IGMPTestState(groups = groups, df = df) |
| 1252 | igmpStateRecv = IGMPTestState(groups = groups, df = df) |
| 1253 | igmpStateList = (igmpState, igmpStateRecv) |
| 1254 | mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb, |
| 1255 | arg = igmpState) |
| 1256 | self.df = df |
| 1257 | self.mcastTraffic = mcastTraffic |
| 1258 | self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP) |
| 1259 | |
| 1260 | def igmp_srp_task(stateList): |
| 1261 | igmpSendState, igmpRecvState = stateList |
| 1262 | if not mcastTraffic.isRecvStopped(): |
| 1263 | result = self.igmp_recv(igmpRecvState) |
| 1264 | reactor.callLater(0, igmp_srp_task, stateList) |
| 1265 | else: |
| 1266 | self.mcastTraffic.stop() |
| 1267 | self.recv_socket.close() |
| 1268 | self.igmp_verify_leave(stateList, leave_groups) |
| 1269 | self.df.callback(0) |
| 1270 | |
| 1271 | log.info('Sending join packet and expected to receive on egeneral query packet after 60 sec for multicast %s ' %groups) |
| 1272 | self.send_igmp_join_recvQuery(groups) |
| 1273 | log.info('Received a egeneral query packet for multicast %s group on joing interface and sending traffic' %groups) |
| 1274 | mcastTraffic.start() |
| 1275 | self.test_timer = reactor.callLater(self.MCAST_TRAFFIC_TIMEOUT, self.mcast_traffic_timer) |
| 1276 | reactor.callLater(0, igmp_srp_task, igmpStateList) |
| 1277 | return df |
| 1278 | |
| 1279 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+190) |
| 1280 | def test_igmp_periodic_query_packet_received_on_joining_interface(self): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1281 | groups = ['224.0.1.10', '225.0.0.10'] |
| 1282 | leave_groups = ['224.0.1.10'] |
| 1283 | df = defer.Deferred() |
| 1284 | igmpState = IGMPTestState(groups = groups, df = df) |
| 1285 | igmpStateRecv = IGMPTestState(groups = groups, df = df) |
| 1286 | igmpStateList = (igmpState, igmpStateRecv) |
| 1287 | mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb, |
| 1288 | arg = igmpState) |
| 1289 | self.df = df |
| 1290 | self.mcastTraffic = mcastTraffic |
| 1291 | self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP) |
| 1292 | |
| 1293 | def igmp_srp_task(stateList): |
| 1294 | igmpSendState, igmpRecvState = stateList |
| 1295 | if not mcastTraffic.isRecvStopped(): |
| 1296 | result = self.igmp_recv(igmpRecvState) |
| 1297 | reactor.callLater(0, igmp_srp_task, stateList) |
| 1298 | else: |
| 1299 | self.mcastTraffic.stop() |
| 1300 | self.recv_socket.close() |
| 1301 | self.igmp_verify_leave(stateList, leave_groups) |
| 1302 | self.df.callback(0) |
| 1303 | |
| 1304 | self.send_igmp_join_recvQuery(groups,3) |
| 1305 | return df |
| 1306 | |
| 1307 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+190) |
| 1308 | def test_igmp_periodic_query_packet_received_and_checking_entry_deleted(self): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1309 | groups = ['224.0.1.10', '225.0.0.10'] |
| 1310 | leave_groups = ['224.0.1.10'] |
| 1311 | df = defer.Deferred() |
| 1312 | igmpState = IGMPTestState(groups = groups, df = df) |
| 1313 | igmpStateRecv = IGMPTestState(groups = groups, df = df) |
| 1314 | igmpStateList = (igmpState, igmpStateRecv) |
| 1315 | mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb, |
| 1316 | arg = igmpState) |
| 1317 | self.df = df |
| 1318 | self.mcastTraffic = mcastTraffic |
| 1319 | self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP) |
| 1320 | |
| 1321 | def igmp_srp_task(stateList): |
| 1322 | igmpSendState, igmpRecvState = stateList |
| 1323 | if not mcastTraffic.isRecvStopped(): |
| 1324 | result = self.igmp_recv(igmpRecvState) |
| 1325 | reactor.callLater(0, igmp_srp_task, stateList) |
| 1326 | else: |
| 1327 | self.mcastTraffic.stop() |
| 1328 | self.recv_socket.close() |
| 1329 | self.igmp_verify_leave(stateList, leave_groups) |
| 1330 | self.df.callback(0) |
| 1331 | |
| 1332 | self.send_igmp_join_recvQuery(groups,3) |
| 1333 | log.info('Received periodic egeneral query packets for multicast %s, now checking entry is deleted from tabel by sending traffic for that group' %groups) |
| 1334 | mcastTraffic.start() |
| 1335 | self.test_timer = reactor.callLater(self.MCAST_TRAFFIC_TIMEOUT, self.mcast_traffic_timer) |
| 1336 | reactor.callLater(0, igmp_srp_task, igmpStateList) |
| 1337 | return df |
| 1338 | |
| 1339 | |
| 1340 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+190) |
| 1341 | def test_igmp_member_query_interval_expire_re_joining_interface(self): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1342 | groups = ['224.0.1.10', '225.0.0.10'] |
| 1343 | leave_groups = ['224.0.1.10'] |
| 1344 | df = defer.Deferred() |
| 1345 | igmpState = IGMPTestState(groups = groups, df = df) |
| 1346 | igmpStateRecv = IGMPTestState(groups = groups, df = df) |
| 1347 | igmpStateList = (igmpState, igmpStateRecv) |
| 1348 | mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb, |
| 1349 | arg = igmpState) |
| 1350 | self.df = df |
| 1351 | self.mcastTraffic = mcastTraffic |
| 1352 | self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP) |
| 1353 | |
| 1354 | def igmp_srp_task(stateList): |
| 1355 | igmpSendState, igmpRecvState = stateList |
| 1356 | if not mcastTraffic.isRecvStopped(): |
| 1357 | result = self.igmp_recv(igmpRecvState) |
| 1358 | reactor.callLater(0, igmp_srp_task, stateList) |
| 1359 | else: |
| 1360 | self.mcastTraffic.stop() |
| 1361 | self.recv_socket.close() |
| 1362 | self.igmp_verify_leave(stateList, leave_groups) |
| 1363 | self.df.callback(0) |
| 1364 | |
| 1365 | self.send_igmp_join_recvQuery(groups,3) |
| 1366 | 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) |
| 1367 | self.send_igmp_join(groups) |
| 1368 | mcastTraffic.start() |
| 1369 | self.test_timer = reactor.callLater(self.MCAST_TRAFFIC_TIMEOUT, self.mcast_traffic_timer) |
| 1370 | reactor.callLater(0, igmp_srp_task, igmpStateList) |
| 1371 | return df |
| 1372 | |
| 1373 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+50) |
| 1374 | def test_igmp_leave_verify_received_group_source_specific_query(self): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1375 | groups = ['224.0.1.10', '225.0.0.10'] |
| 1376 | leave_groups = ['224.0.1.10'] |
| 1377 | df = defer.Deferred() |
| 1378 | igmpState = IGMPTestState(groups = groups, df = df) |
| 1379 | igmpStateRecv = IGMPTestState(groups = groups, df = df) |
| 1380 | igmpStateList = (igmpState, igmpStateRecv) |
| 1381 | mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb, |
| 1382 | arg = igmpState) |
| 1383 | self.df = df |
| 1384 | self.mcastTraffic = mcastTraffic |
| 1385 | self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP) |
| 1386 | |
| 1387 | def igmp_srp_task(stateList): |
| 1388 | igmpSendState, igmpRecvState = stateList |
| 1389 | if not mcastTraffic.isRecvStopped(): |
| 1390 | result = self.igmp_recv(igmpRecvState) |
| 1391 | reactor.callLater(0, igmp_srp_task, stateList) |
| 1392 | else: |
| 1393 | self.mcastTraffic.stop() |
| 1394 | self.recv_socket.close() |
| 1395 | self.igmp_verify_leave(stateList, leave_groups) |
| 1396 | self.df.callback(0) |
| 1397 | |
| 1398 | self.send_igmp_join(groups) |
| 1399 | self.send_igmp_leave_listening_group_specific_query(leave_groups, delay = 3) |
| 1400 | return df |
| 1401 | |
| 1402 | def igmp_change_to_exclude_src_list_check_for_group_source_specific_query(self, df = None): |
| 1403 | groups1 = (self.MGROUP1,) |
| 1404 | groups2 = (self.MGROUP2,) |
| 1405 | self.igmp_send_joins_different_groups_srclist(groups1 + groups2, |
| 1406 | (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']), |
| 1407 | intf = self.V_INF1, delay = 2) |
| 1408 | dst_mac = '01:00:5e:01:02:03' |
| 1409 | src_ip = '2.2.2.2' |
| 1410 | if df is None: |
| 1411 | df = defer.Deferred() |
| 1412 | igmpState1 = IGMPTestState(groups = groups1, df = df) |
| 1413 | igmpStateRecv1 = IGMPTestState(groups = groups1, df = df) |
| 1414 | mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac, |
| 1415 | src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1) |
| 1416 | mcastTraffic1.start() |
| 1417 | join_state1 = IGMPTestState(groups = groups1) |
| 1418 | target1 = self.igmp_recv_task(self.V_INF1, groups1, join_state1) |
| 1419 | self.send_igmp_leave_listening_group_specific_query(groups = groups1, src_list = ['2.2.2.2'], iface = self.V_INF1, delay =2) |
| 1420 | time.sleep(10) |
| 1421 | target2 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1) |
| 1422 | assert target2 == 1, 'EXPECTED FAILURE' |
| 1423 | log.info('Interface is not receiving from multicast groups %s after sending CHANGE_TO_EXCLUDE' %groups2) |
| 1424 | mcastTraffic1.stop() |
| 1425 | self.onos_ctrl.deactivate() |
| 1426 | |
| 1427 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+60) |
| 1428 | def test_igmp_change_to_exclude_src_list_check_for_group_source_specific_query(self): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1429 | df = defer.Deferred() |
| 1430 | def igmp_change_to_exclude_src_list_check_for_group_source_specific_query(): |
| 1431 | self.igmp_change_to_exclude_src_list_check_for_group_source_specific_query(df = df) |
| 1432 | df.callback(0) |
| 1433 | reactor.callLater(0, igmp_change_to_exclude_src_list_check_for_group_source_specific_query) |
| 1434 | return df |
| 1435 | |
| 1436 | def igmp_change_to_include_src_list_check_for_general_query(self, df = None): |
| 1437 | groups1 = (self.MGROUP1,) |
| 1438 | groups2 = (self.MGROUP2,) |
| 1439 | self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4'], |
| 1440 | iface = self.V_INF1, delay = 2) |
| 1441 | dst_mac = '01:00:5e:01:02:03' |
| 1442 | src_ip = '2.2.2.2' |
| 1443 | if df is None: |
| 1444 | df = defer.Deferred() |
| 1445 | igmpState1 = IGMPTestState(groups = groups1, df = df) |
| 1446 | igmpStateRecv1 = IGMPTestState(groups = groups1, df = df) |
| 1447 | mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac, |
| 1448 | src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1) |
| 1449 | mcastTraffic1.start() |
| 1450 | join_state1 = IGMPTestState(groups = groups1) |
| 1451 | target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1) |
| 1452 | assert target1 == 1, 'EXPECTED FAILURE' |
| 1453 | log.info('Interface is not receiving from multicast groups %s' %groups1) |
| 1454 | self.igmp_send_joins_different_groups_srclist_wait_query_packets(groups1 + groups2, |
| 1455 | (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['6.6.6.6', '5.5.5.5']), |
| 1456 | intf = self.V_INF1, delay = 2,query_group1 = 'group1', query_group2 = None) |
| 1457 | time.sleep(10) |
| 1458 | target2 = self.igmp_recv_task(self.V_INF1, groups1, join_state1) |
| 1459 | log.info('Interface is receiving from multicast groups %s after send Change to include message' %groups1) |
| 1460 | mcastTraffic1.stop() |
| 1461 | self.onos_ctrl.deactivate() |
| 1462 | |
| 1463 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+80) |
| 1464 | def test_igmp_change_to_include_src_list_check_for_general_query(self): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1465 | df = defer.Deferred() |
| 1466 | def igmp_change_to_include_src_list_check_for_general_query(): |
| 1467 | self.igmp_change_to_include_src_list_check_for_general_query(df = df) |
| 1468 | df.callback(0) |
| 1469 | reactor.callLater(0, igmp_change_to_include_src_list_check_for_general_query) |
| 1470 | return df |
| 1471 | |
| 1472 | def igmp_allow_new_src_list_check_for_general_query(self, df = None): |
| 1473 | groups1 = (self.MGROUP1,) |
| 1474 | groups2 = (self.MGROUP2,) |
| 1475 | self.igmp_send_joins_different_groups_srclist(groups1+groups2, |
| 1476 | (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']), |
| 1477 | intf = self.V_INF1, delay = 2) |
| 1478 | dst_mac = '01:00:5e:01:02:03' |
| 1479 | src_ip = '6.6.6.6' |
| 1480 | if df is None: |
| 1481 | df = defer.Deferred() |
| 1482 | igmpState1 = IGMPTestState(groups = groups1, df = df) |
| 1483 | igmpStateRecv1 = IGMPTestState(groups = groups1, df = df) |
| 1484 | mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac, |
| 1485 | src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1) |
| 1486 | mcastTraffic1.start() |
| 1487 | join_state1 = IGMPTestState(groups = groups1) |
| 1488 | target1 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1) |
| 1489 | #assert target1 == 1, 'EXPECTED FAILURE' |
| 1490 | log.info('Interface is not receiving from multicast groups %s' %groups1) |
| 1491 | 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']), |
| 1492 | intf = self.V_INF1, delay = 2, query_group1 = 'group1', query_group2 = None) |
| 1493 | target2 = self.igmp_recv_task(self.V_INF1, groups1, join_state1) |
| 1494 | log.info('Interface is receiving from multicast groups %s after sending join with new source list' %groups1) |
| 1495 | mcastTraffic1.stop() |
| 1496 | self.onos_ctrl.deactivate() |
| 1497 | |
| 1498 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+80) |
| 1499 | def test_igmp_allow_new_src_list_check_for_general_query(self): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1500 | df = defer.Deferred() |
| 1501 | def igmp_allow_new_src_list_check_for_general_query(): |
| 1502 | self.igmp_allow_new_src_list_check_for_general_query(df = df) |
| 1503 | df.callback(0) |
| 1504 | reactor.callLater(0, igmp_allow_new_src_list_check_for_general_query) |
| 1505 | return df |
| 1506 | |
| 1507 | def igmp_block_old_src_list_check_for_group_source_specific_query(self, df = None): |
| 1508 | groups1 = (self.MGROUP1,) |
| 1509 | groups2 = (self.MGROUP2,) |
| 1510 | groups = groups1 + groups2 |
| 1511 | self.igmp_send_joins_different_groups_srclist(groups, |
| 1512 | (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']), |
| 1513 | intf = self.V_INF1, delay = 2) |
| 1514 | dst_mac = '01:00:5e:02:02:03' |
| 1515 | src_ip = '5.5.5.5' |
| 1516 | if df is None: |
| 1517 | df = defer.Deferred() |
| 1518 | igmpState1 = IGMPTestState(groups = groups2, df = df) |
| 1519 | igmpStateRecv1 = IGMPTestState(groups = groups2, df = df) |
| 1520 | mcastTraffic1 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac, |
| 1521 | src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1) |
| 1522 | mcastTraffic1.start() |
| 1523 | join_state1 = IGMPTestState(groups = groups2) |
| 1524 | target1 = self.igmp_recv_task(self.V_INF1, groups2, join_state1) |
| 1525 | log.info('Interface is receiving from multicast groups %s' %groups2) |
| 1526 | self.igmp_send_joins_different_groups_srclist_wait_query_packets(groups, |
| 1527 | (['6.6.6.6', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '7.7.7.7']), |
| 1528 | intf = self.V_INF1, delay = 2, query_group1 = 'group1', query_group2 = None) |
| 1529 | target2 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1) |
| 1530 | assert target2 == 1, 'EXPECTED FAILURE' |
| 1531 | log.info('Interface is not receiving from multicast groups %s after sending join with block old source list' %groups2) |
| 1532 | mcastTraffic1.stop() |
| 1533 | self.onos_ctrl.deactivate() |
| 1534 | |
| 1535 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+90) |
| 1536 | def test_igmp_block_old_src_list_check_for_group_source_specific_query(self): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1537 | df = defer.Deferred() |
| 1538 | def igmp_block_old_src_list_check_for_group_source_specific_query(): |
| 1539 | self.igmp_block_old_src_list_check_for_group_source_specific_query(df = df) |
| 1540 | df.callback(0) |
| 1541 | reactor.callLater(0, igmp_block_old_src_list_check_for_group_source_specific_query) |
| 1542 | return df |
| 1543 | |
| 1544 | def igmp_include_to_allow_src_list_check_for_general_query(self, df = None): |
| 1545 | groups1 = (self.MGROUP1,) |
| 1546 | groups2 = (self.MGROUP2,) |
| 1547 | self.igmp_send_joins_different_groups_srclist(groups1 + groups2, |
| 1548 | (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']), |
| 1549 | intf = self.V_INF1, delay = 2) |
| 1550 | dst_mac = '01:00:5e:01:02:03' |
| 1551 | src_ip = '2.2.2.2' |
| 1552 | if df is None: |
| 1553 | df = defer.Deferred() |
| 1554 | igmpState1 = IGMPTestState(groups = groups1, df = df) |
| 1555 | igmpStateRecv1 = IGMPTestState(groups = groups1, df = df) |
| 1556 | mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac, |
| 1557 | src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1) |
| 1558 | mcastTraffic1.start() |
| 1559 | join_state1 = IGMPTestState(groups = groups1) |
| 1560 | target1 = self.igmp_recv_task(self.V_INF1, groups1, join_state1) |
| 1561 | self.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) |
| 1562 | target1 = self.igmp_recv_task(self.V_INF1, groups1, join_state1) |
| 1563 | mcastTraffic1.stop() |
| 1564 | self.onos_ctrl.deactivate() |
| 1565 | |
| 1566 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+40) |
| 1567 | def test_igmp_include_to_allow_src_list_check_for_general_query(self): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1568 | df = defer.Deferred() |
| 1569 | def igmp_include_to_allow_src_list_check_for_general_query(): |
| 1570 | self.igmp_include_to_allow_src_list_check_for_general_query(df = df) |
| 1571 | df.callback(0) |
| 1572 | reactor.callLater(0, igmp_include_to_allow_src_list_check_for_general_query) |
| 1573 | return df |
| 1574 | |
| 1575 | def igmp_include_to_block_src_list_check_for_group_source_specific_query(self, df = None): |
| 1576 | groups1 = (self.MGROUP1,) |
| 1577 | groups2 = (self.MGROUP2,) |
| 1578 | self.igmp_send_joins_different_groups_srclist(groups1 + groups2, |
| 1579 | (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']), |
| 1580 | intf = self.V_INF1, delay = 2) |
| 1581 | dst_mac = '01:00:5e:01:02:03' |
| 1582 | src_ip = '2.2.2.2' |
| 1583 | if df is None: |
| 1584 | df = defer.Deferred() |
| 1585 | igmpState1 = IGMPTestState(groups = groups1, df = df) |
| 1586 | igmpStateRecv1 = IGMPTestState(groups = groups1, df = df) |
| 1587 | mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac, |
| 1588 | src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1) |
| 1589 | mcastTraffic1.start() |
| 1590 | join_state1 = IGMPTestState(groups = groups1) |
| 1591 | target1 = self.igmp_recv_task(self.V_INF1, groups1, join_state1) |
| 1592 | self.send_igmp_leave_listening_group_specific_query(groups = groups1, src_list = ['6.6.6.6','7.7.7.7'], |
| 1593 | iface = self.V_INF1, delay = 2) |
| 1594 | target1 = self.igmp_recv_task(self.V_INF1, groups1, join_state1) |
| 1595 | mcastTraffic1.stop() |
| 1596 | self.onos_ctrl.deactivate() |
| 1597 | |
| 1598 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+40) |
| 1599 | def test_igmp_include_to_block_src_list_check_for_group_source_specific_query(self): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1600 | df = defer.Deferred() |
| 1601 | def igmp_include_to_block_src_list_check_for_group_source_specific_query(): |
| 1602 | self.igmp_include_to_block_src_list_check_for_group_source_specific_query(df = df) |
| 1603 | df.callback(0) |
| 1604 | reactor.callLater(0, igmp_include_to_block_src_list_check_for_group_source_specific_query) |
| 1605 | return df |
| 1606 | |
| 1607 | def igmp_exclude_to_allow_src_list_check_for_general_query(self, df = None): |
| 1608 | groups1 = (self.MGROUP1,) |
| 1609 | groups2 = (self.MGROUP2,) |
| 1610 | self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4'], |
| 1611 | iface = self.V_INF1, delay = 2) |
| 1612 | |
| 1613 | dst_mac = '01:00:5e:01:02:03' |
| 1614 | src_ip = '2.2.2.2' |
| 1615 | if df is None: |
| 1616 | df = defer.Deferred() |
| 1617 | igmpState1 = IGMPTestState(groups = groups1, df = df) |
| 1618 | igmpStateRecv1 = IGMPTestState(groups = groups1, df = df) |
| 1619 | mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac, |
| 1620 | src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1) |
| 1621 | mcastTraffic1.start() |
| 1622 | join_state1 = IGMPTestState(groups = groups1) |
| 1623 | target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1) |
| 1624 | assert target1 == 1, 'EXPECTED FAILURE' |
| 1625 | log.info('Interface is not receiving from multicast groups %s' %groups1) |
| 1626 | self.igmp_send_joins_different_groups_srclist_wait_query_packets(groups1 + groups2, |
| 1627 | (['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) |
| 1628 | target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1) |
| 1629 | assert target1 == 1, 'EXPECTED FAILURE' |
| 1630 | log.info('Interface is not receiving from multicast groups %s' %groups1) |
| 1631 | mcastTraffic1.stop() |
| 1632 | self.onos_ctrl.deactivate() |
| 1633 | |
| 1634 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+90) |
| 1635 | def test_igmp_exclude_to_allow_src_list_check_for_general_query(self): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1636 | df = defer.Deferred() |
| 1637 | def igmp_exclude_to_allow_src_list_check_for_general_query(): |
| 1638 | self.igmp_exclude_to_allow_src_list_check_for_general_query(df = df) |
| 1639 | df.callback(0) |
| 1640 | reactor.callLater(0, igmp_exclude_to_allow_src_list_check_for_general_query) |
| 1641 | return df |
| 1642 | |
| 1643 | def igmp_exclude_to_block_src_list_check_for_group_source_specific_query(self, df = None): |
| 1644 | groups1 = (self.MGROUP1,) |
| 1645 | groups2 = (self.MGROUP2,) |
| 1646 | self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4'], |
| 1647 | iface = self.V_INF1, delay = 2) |
| 1648 | |
| 1649 | dst_mac = '01:00:5e:01:02:03' |
| 1650 | src_ip = '2.2.2.2' |
| 1651 | if df is None: |
| 1652 | df = defer.Deferred() |
| 1653 | igmpState1 = IGMPTestState(groups = groups1, df = df) |
| 1654 | igmpStateRecv1 = IGMPTestState(groups = groups1, df = df) |
| 1655 | mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac, |
| 1656 | src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1) |
| 1657 | mcastTraffic1.start() |
| 1658 | join_state1 = IGMPTestState(groups = groups1) |
| 1659 | target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1) |
| 1660 | assert target1 == 1, 'EXPECTED FAILURE' |
| 1661 | log.info('Interface is not receiving from multicast groups %s' %groups1) |
| 1662 | self.send_igmp_leave_listening_group_specific_query(groups = groups1, |
| 1663 | src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4', '5.5.5.5', '7.7.7.7'], |
| 1664 | iface = self.V_INF1, delay = 2) |
| 1665 | target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1) |
| 1666 | assert target1 == 1, 'EXPECTED FAILURE' |
| 1667 | log.info('Interface is not receiving from multicast groups %s' %groups1) |
| 1668 | mcastTraffic1.stop() |
| 1669 | self.onos_ctrl.deactivate() |
| 1670 | |
| 1671 | @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+40) |
| 1672 | def test_igmp_exclude_to_block_src_list_check_for_group_source_specific_query(self): |
Chetan Gaonker | 441c9ac | 2016-05-06 10:30:13 -0700 | [diff] [blame] | 1673 | df = defer.Deferred() |
| 1674 | def igmp_exclude_to_block_src_list_check_for_group_source_specific_query(): |
| 1675 | self.igmp_exclude_to_block_src_list_check_for_group_source_specific_query(df = df) |
| 1676 | df.callback(0) |
| 1677 | reactor.callLater(0, igmp_exclude_to_block_src_list_check_for_group_source_specific_query) |
| 1678 | return df |
| 1679 | |
| 1680 | |