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