xref: /aosp_15_r20/external/openthread/tests/toranj/cli/test-008-multicast-traffic.py (revision cfb92d1480a9e65faed56933e9c12405f45898b4)
1*cfb92d14SAndroid Build Coastguard Worker#!/usr/bin/env python3
2*cfb92d14SAndroid Build Coastguard Worker#
3*cfb92d14SAndroid Build Coastguard Worker#  Copyright (c) 2022, The OpenThread Authors.
4*cfb92d14SAndroid Build Coastguard Worker#  All rights reserved.
5*cfb92d14SAndroid Build Coastguard Worker#
6*cfb92d14SAndroid Build Coastguard Worker#  Redistribution and use in source and binary forms, with or without
7*cfb92d14SAndroid Build Coastguard Worker#  modification, are permitted provided that the following conditions are met:
8*cfb92d14SAndroid Build Coastguard Worker#  1. Redistributions of source code must retain the above copyright
9*cfb92d14SAndroid Build Coastguard Worker#     notice, this list of conditions and the following disclaimer.
10*cfb92d14SAndroid Build Coastguard Worker#  2. Redistributions in binary form must reproduce the above copyright
11*cfb92d14SAndroid Build Coastguard Worker#     notice, this list of conditions and the following disclaimer in the
12*cfb92d14SAndroid Build Coastguard Worker#     documentation and/or other materials provided with the distribution.
13*cfb92d14SAndroid Build Coastguard Worker#  3. Neither the name of the copyright holder nor the
14*cfb92d14SAndroid Build Coastguard Worker#     names of its contributors may be used to endorse or promote products
15*cfb92d14SAndroid Build Coastguard Worker#     derived from this software without specific prior written permission.
16*cfb92d14SAndroid Build Coastguard Worker#
17*cfb92d14SAndroid Build Coastguard Worker#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18*cfb92d14SAndroid Build Coastguard Worker#  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19*cfb92d14SAndroid Build Coastguard Worker#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20*cfb92d14SAndroid Build Coastguard Worker#  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
21*cfb92d14SAndroid Build Coastguard Worker#  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22*cfb92d14SAndroid Build Coastguard Worker#  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23*cfb92d14SAndroid Build Coastguard Worker#  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24*cfb92d14SAndroid Build Coastguard Worker#  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25*cfb92d14SAndroid Build Coastguard Worker#  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26*cfb92d14SAndroid Build Coastguard Worker#  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27*cfb92d14SAndroid Build Coastguard Worker#  POSSIBILITY OF SUCH DAMAGE.
28*cfb92d14SAndroid Build Coastguard Worker
29*cfb92d14SAndroid Build Coastguard Workerfrom cli import verify
30*cfb92d14SAndroid Build Coastguard Workerfrom cli import verify_within
31*cfb92d14SAndroid Build Coastguard Workerimport cli
32*cfb92d14SAndroid Build Coastguard Workerimport time
33*cfb92d14SAndroid Build Coastguard Worker
34*cfb92d14SAndroid Build Coastguard Worker# -----------------------------------------------------------------------------------------------------------------------
35*cfb92d14SAndroid Build Coastguard Worker# Test description: Multicast traffic
36*cfb92d14SAndroid Build Coastguard Worker#
37*cfb92d14SAndroid Build Coastguard Worker# Network topology
38*cfb92d14SAndroid Build Coastguard Worker#
39*cfb92d14SAndroid Build Coastguard Worker#     r1 ---- r2 ---- r3 ---- r4
40*cfb92d14SAndroid Build Coastguard Worker#             |               |
41*cfb92d14SAndroid Build Coastguard Worker#             |               |
42*cfb92d14SAndroid Build Coastguard Worker#            fed             sed
43*cfb92d14SAndroid Build Coastguard Worker#
44*cfb92d14SAndroid Build Coastguard Worker# Test covers the following multicast traffic:
45*cfb92d14SAndroid Build Coastguard Worker#
46*cfb92d14SAndroid Build Coastguard Worker# - r2  =>> link-local all-nodes.   Expected response from [r1, r3, fed].
47*cfb92d14SAndroid Build Coastguard Worker# - r3  =>> mesh-local all-nodes.   Expected response from [r1, r2, r4, fed].
48*cfb92d14SAndroid Build Coastguard Worker# - r3  =>> link-local all-routers. Expected response from [r2, r4].
49*cfb92d14SAndroid Build Coastguard Worker# - r3  =>> mesh-local all-routers. Expected response from all routers.
50*cfb92d14SAndroid Build Coastguard Worker# - r1  =>> link-local all-thread.  Expected response from [r1, r2].
51*cfb92d14SAndroid Build Coastguard Worker# - fed =>> mesh-local all-thread.  Expected response from all nodes.
52*cfb92d14SAndroid Build Coastguard Worker# - r1  =>> mesh-local all-thread (one hop). Expected response from [r2].
53*cfb92d14SAndroid Build Coastguard Worker# - r1  =>> mesh-local all-thread (two hops). Expected response from [r2, r3, fed].
54*cfb92d14SAndroid Build Coastguard Worker# - r1  =>> mesh-local all-thread (three hops). Expected response from [r2, r3, r4, fed].
55*cfb92d14SAndroid Build Coastguard Worker# - r1  =>> mesh-local all-thread (four hops). Expected response from [r2, r3, r4, fed, sed].
56*cfb92d14SAndroid Build Coastguard Worker#
57*cfb92d14SAndroid Build Coastguard Worker# - r1  =>> realm-local scope mcast addr (on r2 and sed). Expected to receive on [r2, sed].
58*cfb92d14SAndroid Build Coastguard Worker# - r2  =>> realm-local scope mcast addr (on r2 and sed) without `multicast-loop`. Expected to receive from [sed].
59*cfb92d14SAndroid Build Coastguard Worker# - r2  =>> realm-local scope mcast addr (on r2 and sed) with `multicast-loop`. Expected to receive from [r2, sed].
60*cfb92d14SAndroid Build Coastguard Worker# - sed =>> realm-local scope mcast addr (on r2 and sed) without `multicast-loop`. Expected to receive from [r2].
61*cfb92d14SAndroid Build Coastguard Worker# - sed =>> realm-local scope mcast addr (on r2 and sed) with `multicast-loop`. Expected to receive from [r2, sed].
62*cfb92d14SAndroid Build Coastguard Worker#
63*cfb92d14SAndroid Build Coastguard Worker# - r3  =>> site-local mcast addr (on r1, r2, sed). Expected to receive from [r1, r2, sed].
64*cfb92d14SAndroid Build Coastguard Worker# - r1  =>> site-local mcast addr (on r1, r2, sed) with `multicast-loop`. Expected to receive from [r1, r2, sed].
65*cfb92d14SAndroid Build Coastguard Worker# - r1  =>> site-local mcast addr (on r1, r2, sed) without `multicast-loop`. Expected to receive from [r2, sed].
66*cfb92d14SAndroid Build Coastguard Worker# - sed =>> site-local mcast addr (on r1, r2, sed). Expected to receive from [r1, r2].
67*cfb92d14SAndroid Build Coastguard Worker
68*cfb92d14SAndroid Build Coastguard Workertest_name = __file__[:-3] if __file__.endswith('.py') else __file__
69*cfb92d14SAndroid Build Coastguard Workerprint('-' * 120)
70*cfb92d14SAndroid Build Coastguard Workerprint('Starting \'{}\''.format(test_name))
71*cfb92d14SAndroid Build Coastguard Worker
72*cfb92d14SAndroid Build Coastguard Worker# -----------------------------------------------------------------------------------------------------------------------
73*cfb92d14SAndroid Build Coastguard Worker# Creating `cli.Nodes` instances
74*cfb92d14SAndroid Build Coastguard Worker
75*cfb92d14SAndroid Build Coastguard Workerspeedup = 10
76*cfb92d14SAndroid Build Coastguard Workercli.Node.set_time_speedup_factor(speedup)
77*cfb92d14SAndroid Build Coastguard Worker
78*cfb92d14SAndroid Build Coastguard Workerr1 = cli.Node()
79*cfb92d14SAndroid Build Coastguard Workerr2 = cli.Node()
80*cfb92d14SAndroid Build Coastguard Workerr3 = cli.Node()
81*cfb92d14SAndroid Build Coastguard Workerr4 = cli.Node()
82*cfb92d14SAndroid Build Coastguard Workerfed = cli.Node()
83*cfb92d14SAndroid Build Coastguard Workersed = cli.Node()
84*cfb92d14SAndroid Build Coastguard Worker
85*cfb92d14SAndroid Build Coastguard Worker# -----------------------------------------------------------------------------------------------------------------------
86*cfb92d14SAndroid Build Coastguard Worker# Form topology
87*cfb92d14SAndroid Build Coastguard Worker
88*cfb92d14SAndroid Build Coastguard Workerr1.allowlist_node(r2)
89*cfb92d14SAndroid Build Coastguard Worker
90*cfb92d14SAndroid Build Coastguard Workerr2.allowlist_node(r1)
91*cfb92d14SAndroid Build Coastguard Workerr2.allowlist_node(fed)
92*cfb92d14SAndroid Build Coastguard Workerr2.allowlist_node(r3)
93*cfb92d14SAndroid Build Coastguard Worker
94*cfb92d14SAndroid Build Coastguard Workerfed.allowlist_node(r2)
95*cfb92d14SAndroid Build Coastguard Worker
96*cfb92d14SAndroid Build Coastguard Workerr3.allowlist_node(r2)
97*cfb92d14SAndroid Build Coastguard Workerr3.allowlist_node(r4)
98*cfb92d14SAndroid Build Coastguard Worker
99*cfb92d14SAndroid Build Coastguard Workerr4.allowlist_node(r3)
100*cfb92d14SAndroid Build Coastguard Workerr4.allowlist_node(sed)
101*cfb92d14SAndroid Build Coastguard Worker
102*cfb92d14SAndroid Build Coastguard Workersed.allowlist_node(r4)
103*cfb92d14SAndroid Build Coastguard Worker
104*cfb92d14SAndroid Build Coastguard Workerr1.form("multicast")
105*cfb92d14SAndroid Build Coastguard Workerr2.join(r1)
106*cfb92d14SAndroid Build Coastguard Workerr3.join(r2)
107*cfb92d14SAndroid Build Coastguard Workerr4.join(r3)
108*cfb92d14SAndroid Build Coastguard Workerfed.join(r1, cli.JOIN_TYPE_REED)
109*cfb92d14SAndroid Build Coastguard Worker
110*cfb92d14SAndroid Build Coastguard Workersed.join(r3, cli.JOIN_TYPE_SLEEPY_END_DEVICE)
111*cfb92d14SAndroid Build Coastguard Worker
112*cfb92d14SAndroid Build Coastguard Workersed.set_pollperiod(600)
113*cfb92d14SAndroid Build Coastguard Worker
114*cfb92d14SAndroid Build Coastguard Workerverify(r1.get_state() == 'leader')
115*cfb92d14SAndroid Build Coastguard Workerverify(r2.get_state() == 'router')
116*cfb92d14SAndroid Build Coastguard Workerverify(r3.get_state() == 'router')
117*cfb92d14SAndroid Build Coastguard Workerverify(r4.get_state() == 'router')
118*cfb92d14SAndroid Build Coastguard Workerverify(fed.get_state() == 'child')
119*cfb92d14SAndroid Build Coastguard Workerverify(sed.get_state() == 'child')
120*cfb92d14SAndroid Build Coastguard Worker
121*cfb92d14SAndroid Build Coastguard Worker# -----------------------------------------------------------------------------------------------------------------------
122*cfb92d14SAndroid Build Coastguard Worker# Test Implementation
123*cfb92d14SAndroid Build Coastguard Worker
124*cfb92d14SAndroid Build Coastguard Worker# Wait till first router has either established a link or
125*cfb92d14SAndroid Build Coastguard Worker# has a valid "next hop" towards all other routers.
126*cfb92d14SAndroid Build Coastguard Worker
127*cfb92d14SAndroid Build Coastguard Workerr1_rloc16 = int(r1.get_rloc16(), 16)
128*cfb92d14SAndroid Build Coastguard Worker
129*cfb92d14SAndroid Build Coastguard Worker
130*cfb92d14SAndroid Build Coastguard Workerdef check_r1_router_table():
131*cfb92d14SAndroid Build Coastguard Worker    table = r1.get_router_table()
132*cfb92d14SAndroid Build Coastguard Worker    verify(len(table) == 4)
133*cfb92d14SAndroid Build Coastguard Worker    for entry in table:
134*cfb92d14SAndroid Build Coastguard Worker        verify(int(entry['RLOC16'], 0) == r1_rloc16 or int(entry['Link']) == 1 or int(entry['Next Hop']) != 63)
135*cfb92d14SAndroid Build Coastguard Worker
136*cfb92d14SAndroid Build Coastguard Worker
137*cfb92d14SAndroid Build Coastguard Workerverify_within(check_r1_router_table, 160)
138*cfb92d14SAndroid Build Coastguard Worker
139*cfb92d14SAndroid Build Coastguard Worker# r2  =>> link-local all-nodes. Expected response from [r1, r3, fed].
140*cfb92d14SAndroid Build Coastguard Worker
141*cfb92d14SAndroid Build Coastguard Workeroutputs = r2.cli('ping ff02::1')
142*cfb92d14SAndroid Build Coastguard Workerverify(len(outputs) == 4)
143*cfb92d14SAndroid Build Coastguard Workerfor node in [r1, r3, fed]:
144*cfb92d14SAndroid Build Coastguard Worker    ll_addr = node.get_linklocal_ip_addr()
145*cfb92d14SAndroid Build Coastguard Worker    verify(any(ll_addr in line for line in outputs))
146*cfb92d14SAndroid Build Coastguard Worker
147*cfb92d14SAndroid Build Coastguard Worker# r3  =>> mesh-local all-nodes. Expected response from [r1, r2, r4, fed].
148*cfb92d14SAndroid Build Coastguard Worker
149*cfb92d14SAndroid Build Coastguard Workeroutputs = r3.cli('ping ff03::1')
150*cfb92d14SAndroid Build Coastguard Workerverify(len(outputs) == 5)
151*cfb92d14SAndroid Build Coastguard Workerfor node in [r1, r2, r4, fed]:
152*cfb92d14SAndroid Build Coastguard Worker    ml_addr = node.get_mleid_ip_addr()
153*cfb92d14SAndroid Build Coastguard Worker    verify(any(ml_addr in line for line in outputs))
154*cfb92d14SAndroid Build Coastguard Worker
155*cfb92d14SAndroid Build Coastguard Worker# r3  =>> link-local all-routers. Expected response from [r2, r4].
156*cfb92d14SAndroid Build Coastguard Worker
157*cfb92d14SAndroid Build Coastguard Workeroutputs = r3.cli('ping ff02::2')
158*cfb92d14SAndroid Build Coastguard Workerverify(len(outputs) == 3)
159*cfb92d14SAndroid Build Coastguard Workerfor node in [r2, r4]:
160*cfb92d14SAndroid Build Coastguard Worker    ll_addr = node.get_linklocal_ip_addr()
161*cfb92d14SAndroid Build Coastguard Worker    verify(any(ll_addr in line for line in outputs))
162*cfb92d14SAndroid Build Coastguard Worker
163*cfb92d14SAndroid Build Coastguard Worker# r3  =>> mesh-local all-routers. Expected response from all routers.
164*cfb92d14SAndroid Build Coastguard Worker
165*cfb92d14SAndroid Build Coastguard Workeroutputs = r3.cli('ping ff03::2')
166*cfb92d14SAndroid Build Coastguard Workerverify(len(outputs) == 5)
167*cfb92d14SAndroid Build Coastguard Workerfor node in [r1, r2, r4, fed]:
168*cfb92d14SAndroid Build Coastguard Worker    ml_addr = node.get_mleid_ip_addr()
169*cfb92d14SAndroid Build Coastguard Worker    verify(any(ml_addr in line for line in outputs))
170*cfb92d14SAndroid Build Coastguard Worker
171*cfb92d14SAndroid Build Coastguard Worker# r1  =>> link-local all-thread.  Expected response from [r2].
172*cfb92d14SAndroid Build Coastguard Worker
173*cfb92d14SAndroid Build Coastguard Workerml_prefix = r1.get_mesh_local_prefix().strip().split('/')[0]
174*cfb92d14SAndroid Build Coastguard Workerll_all_thread_nodes_addr = 'ff32:40:' + ml_prefix + '1'
175*cfb92d14SAndroid Build Coastguard Workeroutputs = r1.cli('ping', ll_all_thread_nodes_addr)
176*cfb92d14SAndroid Build Coastguard Workerverify(len(outputs) == 2)
177*cfb92d14SAndroid Build Coastguard Workerfor node in [r2]:
178*cfb92d14SAndroid Build Coastguard Worker    ll_addr = node.get_linklocal_ip_addr()
179*cfb92d14SAndroid Build Coastguard Worker    verify(any(ll_addr in line for line in outputs))
180*cfb92d14SAndroid Build Coastguard Worker
181*cfb92d14SAndroid Build Coastguard Worker# fed =>> mesh-local all-thread.  Expected response from all nodes.
182*cfb92d14SAndroid Build Coastguard Worker
183*cfb92d14SAndroid Build Coastguard Workerml_all_thread_nodes_addr = 'ff33:40:' + ml_prefix + '1'
184*cfb92d14SAndroid Build Coastguard Workeroutputs = fed.cli('ping', ml_all_thread_nodes_addr)
185*cfb92d14SAndroid Build Coastguard Workerverify(len(outputs) == 6)
186*cfb92d14SAndroid Build Coastguard Workerfor node in [r1, r2, r3, r4, sed]:
187*cfb92d14SAndroid Build Coastguard Worker    ml_addr = node.get_mleid_ip_addr()
188*cfb92d14SAndroid Build Coastguard Worker    verify(any(ml_addr in line for line in outputs))
189*cfb92d14SAndroid Build Coastguard Worker
190*cfb92d14SAndroid Build Coastguard Worker# Repeat the same with larger ping msg requiring fragmentation
191*cfb92d14SAndroid Build Coastguard Worker
192*cfb92d14SAndroid Build Coastguard Workeroutputs = fed.cli('ping', ml_all_thread_nodes_addr, 200)
193*cfb92d14SAndroid Build Coastguard Workerverify(len(outputs) == 6)
194*cfb92d14SAndroid Build Coastguard Workerfor node in [r1, r2, r3, r4, sed]:
195*cfb92d14SAndroid Build Coastguard Worker    ml_addr = node.get_mleid_ip_addr()
196*cfb92d14SAndroid Build Coastguard Worker    verify(any(ml_addr in line for line in outputs))
197*cfb92d14SAndroid Build Coastguard Worker
198*cfb92d14SAndroid Build Coastguard Worker# r1  =>> mesh-local all-thread (one hop). Expected response from [r2].
199*cfb92d14SAndroid Build Coastguard Worker
200*cfb92d14SAndroid Build Coastguard Workerhop_limit = 1
201*cfb92d14SAndroid Build Coastguard Workeroutputs = r1.cli('ping', ml_all_thread_nodes_addr, 10, 1, 0, hop_limit)
202*cfb92d14SAndroid Build Coastguard Workerverify(len(outputs) == 2)
203*cfb92d14SAndroid Build Coastguard Workerfor node in [r2]:
204*cfb92d14SAndroid Build Coastguard Worker    ml_addr = node.get_mleid_ip_addr()
205*cfb92d14SAndroid Build Coastguard Worker    verify(any(ml_addr in line for line in outputs))
206*cfb92d14SAndroid Build Coastguard Worker
207*cfb92d14SAndroid Build Coastguard Worker# r1  =>> mesh-local all-thread (two hops). Expected response from [r2, r3, fed].
208*cfb92d14SAndroid Build Coastguard Worker
209*cfb92d14SAndroid Build Coastguard Workerhop_limit = 2
210*cfb92d14SAndroid Build Coastguard Workeroutputs = r1.cli('ping', ml_all_thread_nodes_addr, 10, 1, 0, hop_limit)
211*cfb92d14SAndroid Build Coastguard Workerverify(len(outputs) == 4)
212*cfb92d14SAndroid Build Coastguard Workerfor node in [r2, r3, fed]:
213*cfb92d14SAndroid Build Coastguard Worker    ml_addr = node.get_mleid_ip_addr()
214*cfb92d14SAndroid Build Coastguard Worker    verify(any(ml_addr in line for line in outputs))
215*cfb92d14SAndroid Build Coastguard Worker
216*cfb92d14SAndroid Build Coastguard Worker# r1  =>> mesh-local all-thread (three hops). Expected response from [r2, r3, r4, fed].
217*cfb92d14SAndroid Build Coastguard Worker
218*cfb92d14SAndroid Build Coastguard Workerhop_limit = 3
219*cfb92d14SAndroid Build Coastguard Workeroutputs = r1.cli('ping', ml_all_thread_nodes_addr, 10, 1, 0, hop_limit)
220*cfb92d14SAndroid Build Coastguard Workerverify(len(outputs) == 5)
221*cfb92d14SAndroid Build Coastguard Workerfor node in [r2, r3, r4, fed]:
222*cfb92d14SAndroid Build Coastguard Worker    ml_addr = node.get_mleid_ip_addr()
223*cfb92d14SAndroid Build Coastguard Worker    verify(any(ml_addr in line for line in outputs))
224*cfb92d14SAndroid Build Coastguard Worker
225*cfb92d14SAndroid Build Coastguard Worker# r1  =>> mesh-local all-thread (four hops). Expected response from [r2, r3, r4, fed, sed].
226*cfb92d14SAndroid Build Coastguard Worker
227*cfb92d14SAndroid Build Coastguard Workerhop_limit = 4
228*cfb92d14SAndroid Build Coastguard Workeroutputs = r1.cli('ping', ml_all_thread_nodes_addr, 10, 1, 0, hop_limit)
229*cfb92d14SAndroid Build Coastguard Workerverify(len(outputs) == 6)
230*cfb92d14SAndroid Build Coastguard Workerfor node in [r2, r3, r4, fed, sed]:
231*cfb92d14SAndroid Build Coastguard Worker    ml_addr = node.get_mleid_ip_addr()
232*cfb92d14SAndroid Build Coastguard Worker    verify(any(ml_addr in line for line in outputs))
233*cfb92d14SAndroid Build Coastguard Worker
234*cfb92d14SAndroid Build Coastguard Worker# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
235*cfb92d14SAndroid Build Coastguard Worker# Subscribe to a realm-local scope multicast address on r2 and sed
236*cfb92d14SAndroid Build Coastguard Worker
237*cfb92d14SAndroid Build Coastguard Workermcast_addr = 'ff03:0:0:0:0:0:0:114'
238*cfb92d14SAndroid Build Coastguard Workerr2.add_ip_maddr(mcast_addr)
239*cfb92d14SAndroid Build Coastguard Workersed.add_ip_maddr(mcast_addr)
240*cfb92d14SAndroid Build Coastguard Workertime.sleep(1)
241*cfb92d14SAndroid Build Coastguard Workermaddrs = r2.get_ip_maddrs()
242*cfb92d14SAndroid Build Coastguard Workerverify(any(mcast_addr in maddr for maddr in maddrs))
243*cfb92d14SAndroid Build Coastguard Workermaddrs = sed.get_ip_maddrs()
244*cfb92d14SAndroid Build Coastguard Workerverify(any(mcast_addr in maddr for maddr in maddrs))
245*cfb92d14SAndroid Build Coastguard Worker
246*cfb92d14SAndroid Build Coastguard Worker# r1  =>> realm-local scope mcast addr (on r2 and sed). Expected to receive on [r2, sed].
247*cfb92d14SAndroid Build Coastguard Worker
248*cfb92d14SAndroid Build Coastguard Workeroutputs = r1.cli('ping', mcast_addr)
249*cfb92d14SAndroid Build Coastguard Workerverify(len(outputs) == 3)
250*cfb92d14SAndroid Build Coastguard Workerfor node in [r2, sed]:
251*cfb92d14SAndroid Build Coastguard Worker    ml_addr = node.get_mleid_ip_addr()
252*cfb92d14SAndroid Build Coastguard Worker    verify(any(ml_addr in line for line in outputs))
253*cfb92d14SAndroid Build Coastguard Worker
254*cfb92d14SAndroid Build Coastguard Worker# r2  =>> realm-local scope mcast addr (on r2 and sed) without `multicast-loop`. Expected to receive from [sed].
255*cfb92d14SAndroid Build Coastguard Worker
256*cfb92d14SAndroid Build Coastguard Workeroutputs = r2.cli('ping', mcast_addr)
257*cfb92d14SAndroid Build Coastguard Workerverify(len(outputs) == 2)
258*cfb92d14SAndroid Build Coastguard Workerfor node in [sed]:
259*cfb92d14SAndroid Build Coastguard Worker    ml_addr = node.get_mleid_ip_addr()
260*cfb92d14SAndroid Build Coastguard Worker    verify(any(ml_addr in line for line in outputs))
261*cfb92d14SAndroid Build Coastguard Worker
262*cfb92d14SAndroid Build Coastguard Worker# r2  =>> realm-local scope mcast addr (on r2 and sed) with `multicast-loop`. Expected to receive from [r2, sed].
263*cfb92d14SAndroid Build Coastguard Worker
264*cfb92d14SAndroid Build Coastguard Workeroutputs = r2.cli('ping', '-m', mcast_addr)
265*cfb92d14SAndroid Build Coastguard Workerverify(len(outputs) == 3)
266*cfb92d14SAndroid Build Coastguard Workerfor node in [r2, sed]:
267*cfb92d14SAndroid Build Coastguard Worker    ml_addr = node.get_mleid_ip_addr()
268*cfb92d14SAndroid Build Coastguard Worker    verify(any(ml_addr in line for line in outputs))
269*cfb92d14SAndroid Build Coastguard Worker
270*cfb92d14SAndroid Build Coastguard Worker# sed  =>> realm-local scope mcast addr (on r2 and sed) without `multicast-loop`. Expected to receive from [r2].
271*cfb92d14SAndroid Build Coastguard Worker
272*cfb92d14SAndroid Build Coastguard Workeroutputs = sed.cli('ping', mcast_addr)
273*cfb92d14SAndroid Build Coastguard Workerverify(len(outputs) == 2)
274*cfb92d14SAndroid Build Coastguard Workerfor node in [r2]:
275*cfb92d14SAndroid Build Coastguard Worker    ml_addr = node.get_mleid_ip_addr()
276*cfb92d14SAndroid Build Coastguard Worker    verify(any(ml_addr in line for line in outputs))
277*cfb92d14SAndroid Build Coastguard Worker
278*cfb92d14SAndroid Build Coastguard Worker# sed  =>> realm-local scope mcast addr (on r2 and sed) with `multicast-loop`. Expected to receive from [r2, sed].
279*cfb92d14SAndroid Build Coastguard Worker
280*cfb92d14SAndroid Build Coastguard Workeroutputs = sed.cli('ping', '-m', mcast_addr)
281*cfb92d14SAndroid Build Coastguard Workerverify(len(outputs) == 3)
282*cfb92d14SAndroid Build Coastguard Workerfor node in [r2, sed]:
283*cfb92d14SAndroid Build Coastguard Worker    ml_addr = node.get_mleid_ip_addr()
284*cfb92d14SAndroid Build Coastguard Worker    verify(any(ml_addr in line for line in outputs))
285*cfb92d14SAndroid Build Coastguard Worker
286*cfb92d14SAndroid Build Coastguard Worker# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
287*cfb92d14SAndroid Build Coastguard Worker# Subscribe to a larger than realm-local scope (site-local) multicast address on r1, r2, and sed
288*cfb92d14SAndroid Build Coastguard Worker
289*cfb92d14SAndroid Build Coastguard Workermcast_addr = 'ff05:0:0:0:0:0:0:abcd'
290*cfb92d14SAndroid Build Coastguard Workerr1.add_ip_maddr(mcast_addr)
291*cfb92d14SAndroid Build Coastguard Workerr2.add_ip_maddr(mcast_addr)
292*cfb92d14SAndroid Build Coastguard Workersed.add_ip_maddr(mcast_addr)
293*cfb92d14SAndroid Build Coastguard Workertime.sleep(1)
294*cfb92d14SAndroid Build Coastguard Workermaddrs = r1.get_ip_maddrs()
295*cfb92d14SAndroid Build Coastguard Workerverify(any(mcast_addr in maddr for maddr in maddrs))
296*cfb92d14SAndroid Build Coastguard Workermaddrs = r2.get_ip_maddrs()
297*cfb92d14SAndroid Build Coastguard Workerverify(any(mcast_addr in maddr for maddr in maddrs))
298*cfb92d14SAndroid Build Coastguard Workermaddrs = sed.get_ip_maddrs()
299*cfb92d14SAndroid Build Coastguard Workerverify(any(mcast_addr in maddr for maddr in maddrs))
300*cfb92d14SAndroid Build Coastguard Worker
301*cfb92d14SAndroid Build Coastguard Worker# r3  =>> site-local mcast addr (on r1, r2, sed) with `multicast-loop`. Expected to receive from [r1, r2, sed].
302*cfb92d14SAndroid Build Coastguard Worker
303*cfb92d14SAndroid Build Coastguard Workeroutputs = r3.cli('ping', '-m', mcast_addr)
304*cfb92d14SAndroid Build Coastguard Workerverify(len(outputs) == 4)
305*cfb92d14SAndroid Build Coastguard Workerfor node in [r1, r2, sed]:
306*cfb92d14SAndroid Build Coastguard Worker    ml_addr = node.get_mleid_ip_addr()
307*cfb92d14SAndroid Build Coastguard Worker    verify(any(ml_addr in line for line in outputs))
308*cfb92d14SAndroid Build Coastguard Worker
309*cfb92d14SAndroid Build Coastguard Worker# r1  =>> site-local mcast addr (on r1, r2, sed) with `multicast-loop`. Expected to receive from [r1, r2, sed].
310*cfb92d14SAndroid Build Coastguard Worker
311*cfb92d14SAndroid Build Coastguard Workeroutputs = r1.cli('ping', '-m', mcast_addr)
312*cfb92d14SAndroid Build Coastguard Workerverify(len(outputs) == 4)
313*cfb92d14SAndroid Build Coastguard Workerfor node in [r1, r2, sed]:
314*cfb92d14SAndroid Build Coastguard Worker    ml_addr = node.get_mleid_ip_addr()
315*cfb92d14SAndroid Build Coastguard Worker    verify(any(ml_addr in line for line in outputs))
316*cfb92d14SAndroid Build Coastguard Worker
317*cfb92d14SAndroid Build Coastguard Worker# r1  =>> site-local mcast addr (on r1, r2, sed) without `multicast-loop`. Expected to receive from [r2, sed].
318*cfb92d14SAndroid Build Coastguard Worker
319*cfb92d14SAndroid Build Coastguard Workeroutputs = r1.cli('ping', mcast_addr)
320*cfb92d14SAndroid Build Coastguard Workerverify(len(outputs) == 3)
321*cfb92d14SAndroid Build Coastguard Workerfor node in [r2, sed]:
322*cfb92d14SAndroid Build Coastguard Worker    ml_addr = node.get_mleid_ip_addr()
323*cfb92d14SAndroid Build Coastguard Worker    verify(any(ml_addr in line for line in outputs))
324*cfb92d14SAndroid Build Coastguard Worker
325*cfb92d14SAndroid Build Coastguard Worker# sed  =>> site-local mcast addr (on r1, r2, sed) without `multicast-loop`. Expected to receive from [r1, r2].
326*cfb92d14SAndroid Build Coastguard Worker
327*cfb92d14SAndroid Build Coastguard Workeroutputs = sed.cli('ping', mcast_addr)
328*cfb92d14SAndroid Build Coastguard Workerverify(len(outputs) >= 3)
329*cfb92d14SAndroid Build Coastguard Workerfor node in [r1, r2]:
330*cfb92d14SAndroid Build Coastguard Worker    ml_addr = node.get_mleid_ip_addr()
331*cfb92d14SAndroid Build Coastguard Worker    verify(any(ml_addr in line for line in outputs))
332*cfb92d14SAndroid Build Coastguard Worker
333*cfb92d14SAndroid Build Coastguard Worker# -----------------------------------------------------------------------------------------------------------------------
334*cfb92d14SAndroid Build Coastguard Worker# Test finished
335*cfb92d14SAndroid Build Coastguard Worker
336*cfb92d14SAndroid Build Coastguard Workercli.Node.finalize_all_nodes()
337*cfb92d14SAndroid Build Coastguard Worker
338*cfb92d14SAndroid Build Coastguard Workerprint('\'{}\' passed.'.format(test_name))
339