Skip to content

Commit 0d4a43a

Browse files
authored
[nexus] add MATN-TC-03 test case for multicast registration (openthread#12688)
Add MATN-TC-03 test case to verify that a Primary Backbone Router (BBR) correctly handles Multicast Listener Registration (MLR) requests and ignores a Timeout TLV when it is not sent by a Commissioner. - Add test_1_2_MATN_TC_3.cpp implementing the simulation of two Border Routers (BR_1 as Primary BBR, BR_2), a Router, and an external Host on the backbone. - Verify that a Router can successfully register a multicast address. - Verify that a Router attempting to deregister a multicast address by sending an MLR.req with a Timeout TLV of 0 (without a Commissioner Session ID) is handled correctly by the PBBR. - Verify that the PBBR responds with Success and continues to forward multicast traffic to the registered address, effectively ignoring the invalid Timeout TLV. - Add verify_1_2_MATN_TC_3.py for automated packet verification of the test scenario. - Register the new test case in tests/nexus/CMakeLists.txt and tests/nexus/run_nexus_tests.sh.
1 parent a904b66 commit 0d4a43a

4 files changed

Lines changed: 416 additions & 0 deletions

File tree

tests/nexus/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ ot_nexus_test(1_2_LP_7_2_1 "cert;nexus")
236236
ot_nexus_test(1_2_LP_7_2_2 "cert;nexus")
237237
ot_nexus_test(1_2_MATN_TC_1 "cert;nexus")
238238
ot_nexus_test(1_2_MATN_TC_2 "cert;nexus")
239+
ot_nexus_test(1_2_MATN_TC_3 "cert;nexus")
239240

240241
# Misc tests
241242
ot_nexus_test(border_admitter "core;nexus")

tests/nexus/run_nexus_tests.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ DEFAULT_TESTS=(
171171
"1_2_LP_7_2_2"
172172
"1_2_MATN_TC_1"
173173
"1_2_MATN_TC_2"
174+
"1_2_MATN_TC_3"
174175
)
175176

176177
# Use provided arguments or the default test list

tests/nexus/test_1_2_MATN_TC_3.cpp

Lines changed: 268 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,268 @@
1+
/*
2+
* Copyright (c) 2026, The OpenThread Authors.
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions are met:
7+
* 1. Redistributions of source code must retain the above copyright
8+
* notice, this list of conditions and the following disclaimer.
9+
* 2. Redistributions in binary form must reproduce the above copyright
10+
* notice, this list of conditions and the following disclaimer in the
11+
* documentation and/or other materials provided with the distribution.
12+
* 3. Neither the name of the copyright holder nor the
13+
* names of its contributors may be used to endorse or promote products
14+
* derived from this software without specific prior written permission.
15+
*
16+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26+
* POSSIBILITY OF SUCH DAMAGE.
27+
*/
28+
29+
#include <stdio.h>
30+
31+
#include "platform/nexus_core.hpp"
32+
#include "platform/nexus_node.hpp"
33+
34+
namespace ot {
35+
namespace Nexus {
36+
37+
/**
38+
* Time to advance for a node to form a network and become leader, in milliseconds.
39+
*/
40+
static constexpr uint32_t kFormNetworkTime = 10 * 1000;
41+
42+
/**
43+
* Time to advance for a node to join as a router, in milliseconds.
44+
*/
45+
static constexpr uint32_t kAttachToRouterTime = 200 * 1000;
46+
47+
/**
48+
* Time to advance for the network to stabilize, in milliseconds.
49+
*/
50+
static constexpr uint32_t kStabilizationTime = 10 * 1000;
51+
52+
/**
53+
* Time to advance for MLR registration, in milliseconds.
54+
*/
55+
static constexpr uint32_t kMlrRegistrationTime = 5 * 1000;
56+
57+
/**
58+
* Time to advance for ICMPv6 Echo Reply, in milliseconds.
59+
*/
60+
static constexpr uint32_t kEchoReplyWaitTime = 5000;
61+
62+
/**
63+
* ICMPv6 Echo Request payload size.
64+
*/
65+
static constexpr uint16_t kEchoPayloadSize = 10;
66+
67+
/**
68+
* ICMPv6 Echo Request identifier.
69+
*/
70+
static constexpr uint16_t kEchoIdentifier = 0x1234;
71+
72+
/**
73+
* Multicast address MA1.
74+
*/
75+
static const char kMA1[] = "ff04::1234:777a:1";
76+
77+
/**
78+
* Prefix used for ULA addresses.
79+
*/
80+
static const char kUlaPrefix[] = "fd00::/8";
81+
82+
/**
83+
* Timeout value 0 for MLR deregistration attempt.
84+
*/
85+
static constexpr uint32_t kTimeoutZero = 0;
86+
87+
void TestMatnTc3(void)
88+
{
89+
/**
90+
* 5.10.3 MATN-TC-03: Thread device incorrectly attempts Commissioners (de)registration functions
91+
*
92+
* 5.10.3.1 Topology
93+
* - BR_1 (DUT)
94+
* - BR_2
95+
* - Router
96+
* - Host
97+
*
98+
* 5.10.3.2 Purpose & Description
99+
* Verify that a Primary BBR ignores a Timeout TLV if included in an MLR.req that does not contain a Commissioner
100+
* Session ID TLV nor is signed by a Commissioner.
101+
*
102+
* Spec Reference | V1.2 Section
103+
* -----------------|-------------
104+
* Multicast Reg. | 5.10.3
105+
*/
106+
107+
Core nexus;
108+
Node &br1 = nexus.CreateNode();
109+
Node &br2 = nexus.CreateNode();
110+
Node &router = nexus.CreateNode();
111+
Node &host = nexus.CreateNode();
112+
Ip6::Address ma1;
113+
const Ip6::Address *hostUla;
114+
115+
br1.SetName("BR_1");
116+
br2.SetName("BR_2");
117+
router.SetName("ROUTER");
118+
host.SetName("Host");
119+
120+
SuccessOrQuit(ma1.FromString(kMA1));
121+
122+
nexus.AdvanceTime(0);
123+
124+
Instance::SetLogLevel(kLogLevelNote);
125+
126+
Log("---------------------------------------------------------------------------------------");
127+
Log("Step 0: Topology formation - DUT, BR_2, Router");
128+
129+
/**
130+
* Step 0
131+
* - Device: Topology
132+
* - Description: Topology formation - DUT, BR_2, Router
133+
* - Pass Criteria:
134+
* - N/A
135+
*/
136+
br1.AllowList(br2);
137+
br1.AllowList(router);
138+
br2.AllowList(br1);
139+
br2.AllowList(router);
140+
router.AllowList(br1);
141+
router.AllowList(br2);
142+
143+
br1.Form();
144+
nexus.AdvanceTime(kFormNetworkTime);
145+
VerifyOrQuit(br1.Get<Mle::Mle>().IsLeader());
146+
147+
br1.Get<BorderRouter::InfraIf>().Init(1, true);
148+
br1.Get<BorderRouter::RoutingManager>().Init();
149+
SuccessOrQuit(br1.Get<BorderRouter::RoutingManager>().SetEnabled(true));
150+
br1.Get<BackboneRouter::Local>().SetEnabled(true);
151+
152+
router.Join(br1, Node::kAsFtd);
153+
br2.Join(br1, Node::kAsFtd);
154+
nexus.AdvanceTime(kAttachToRouterTime);
155+
156+
VerifyOrQuit(router.Get<Mle::Mle>().IsRouter());
157+
VerifyOrQuit(br2.Get<Mle::Mle>().IsRouter());
158+
159+
br2.Get<BorderRouter::InfraIf>().Init(1, true);
160+
br2.Get<BorderRouter::RoutingManager>().Init();
161+
SuccessOrQuit(br2.Get<BorderRouter::RoutingManager>().SetEnabled(true));
162+
br2.Get<BackboneRouter::Local>().SetEnabled(true);
163+
164+
nexus.AdvanceTime(kStabilizationTime * 2);
165+
166+
VerifyOrQuit(br1.Get<BackboneRouter::Local>().IsPrimary());
167+
VerifyOrQuit(!br2.Get<BackboneRouter::Local>().IsPrimary());
168+
169+
hostUla = &host.mInfraIf.FindMatchingAddress(kUlaPrefix);
170+
171+
/** Add variables to test info manually to ensure verify script sees them. */
172+
nexus.AddTestVar("MA1", kMA1);
173+
nexus.AddTestVar("HOST_BACKBONE_ULA", hostUla->ToString().AsCString());
174+
175+
Log("---------------------------------------------------------------------------------------");
176+
Log("Step 1: Harness instructs the device to register the multicast address MA1");
177+
178+
/**
179+
* Step 1
180+
* - Device: Router
181+
* - Description: Harness instructs the device to register the multicast address MA1
182+
* - Pass Criteria:
183+
* - N/A
184+
*/
185+
SuccessOrQuit(router.Get<Ip6::Netif>().SubscribeExternalMulticast(ma1));
186+
nexus.AdvanceTime(kMlrRegistrationTime);
187+
188+
Log("---------------------------------------------------------------------------------------");
189+
Log("Step 2: Harness instructs the device to deregister the multicast address, MA1, at BR_1.");
190+
191+
/**
192+
* Step 2
193+
* - Device: Router
194+
* - Description: Harness instructs the device to deregister the multicast address, MA1, at BR_1. Router unicasts
195+
* an MLR.req CoAP request to BR_1 as follows: coap://[<BR_1 RLOC>]:MM/n/mr Where the payload contains: IPv6
196+
* Addresses TLV: MA1, Timeout TLV the value 0
197+
* - Pass Criteria:
198+
* - N/A
199+
*/
200+
SuccessOrQuit(router.Get<MlrManager>().RegisterMulticastListeners(&ma1, 1, &kTimeoutZero, nullptr, nullptr));
201+
nexus.AdvanceTime(kMlrRegistrationTime);
202+
203+
Log("---------------------------------------------------------------------------------------");
204+
Log("Step 3: BR_1 (DUT) automatically responds successfully, ignoring the timeout value.");
205+
206+
/**
207+
* Step 3
208+
* - Device: BR_1 (DUT)
209+
* - Description: Automatically responds to the multicast registration successfully, ignoring the timeout value.
210+
* - Pass Criteria:
211+
* - For DUT=BR_1:
212+
* - The DUT MUST unicast an MLR.rsp CoAP response to Router as follows: 2.04 changed
213+
* - Where the payload contains: Status TLV: 0 [ST_MLR_SUCCESS]
214+
*/
215+
/** This is verified by the python script. */
216+
217+
Log("---------------------------------------------------------------------------------------");
218+
Log("Step 4: Host sends an ICMPv6 Echo (ping) Request packet to the multicast address, MA1.");
219+
220+
/**
221+
* Step 4
222+
* - Device: Host
223+
* - Description: Harness instructs the device to send an ICMPv6 Echo (ping) Request packet to the multicast
224+
* address, MA1.
225+
* - Pass Criteria:
226+
* - N/A
227+
*/
228+
host.mInfraIf.SendEchoRequest(*hostUla, ma1, kEchoIdentifier, kEchoPayloadSize);
229+
nexus.AdvanceTime(0);
230+
231+
Log("---------------------------------------------------------------------------------------");
232+
Log("Step 5: BR_1 (DUT) automatically forwards the ping request packet to its Thread Network.");
233+
234+
/**
235+
* Step 5
236+
* - Device: BR_1 (DUT)
237+
* - Description: Automatically forwards the ping request packet to its Thread Network.
238+
* - Pass Criteria:
239+
* - The DUT MUST forward the ICMPv6 Echo (ping) Request packet with multicast address, MA1, to its Thread
240+
* Network encapsulated in an MPL packet.
241+
*/
242+
nexus.AdvanceTime(kEchoReplyWaitTime);
243+
244+
Log("---------------------------------------------------------------------------------------");
245+
Log("Step 6: Router receives the MPL packet and automatically unicasts an ICMPv6 Echo (ping) Reply packet.");
246+
247+
/**
248+
* Step 6
249+
* - Device: Router
250+
* - Description: Receives the MPL packet containing an encapsulated ping request packet to MA1, sent by Host, and
251+
* automatically unicasts an ICMPv6 Echo (ping) Reply packet back to Host.
252+
* - Pass Criteria:
253+
* - N/A
254+
*/
255+
nexus.AdvanceTime(kEchoReplyWaitTime);
256+
257+
nexus.SaveTestInfo("test_1_2_MATN_TC_3.json");
258+
}
259+
260+
} // namespace Nexus
261+
} // namespace ot
262+
263+
int main(void)
264+
{
265+
ot::Nexus::TestMatnTc3();
266+
printf("All tests passed\n");
267+
return 0;
268+
}

0 commit comments

Comments
 (0)