From 7d10faea6f564b06b0f435aecc524c747f747e74 Mon Sep 17 00:00:00 2001 From: Jonathan Hui Date: Sat, 21 Feb 2026 22:06:28 -0600 Subject: [PATCH] [nexus] add test 7.1.8 Network data propagation - BR as FED (#12520) This commit adds a new Nexus test case 7.1.8 which verifies that when global prefix information is set on a Full End Device (FED), the DUT (Router) properly disseminates the associated network data. It also verifies that the DUT sends revised server data information to the Leader when the FED is removed. The test setup uses: - Leader: Forms the network. - Router 1 (DUT): Attached to the Leader. - FED 1: Attached to the DUT. The test verifies that: - FED 1 sends a CoAP Server Data Notification to the Leader after prefixes (2001::/64 stable and 2002::/64 non-stable) are added. - The Leader and DUT multicast MLE Data Responses containing the new network data. - When FED 1 is removed, the DUT unicasts a CoAP Server Data Notification to the Leader containing only the removed server's RLOC16. Summary of changes: - Created tests/nexus/test_7_1_8.cpp: - Implements test logic using direct core method calls. - Sets log level to note. - Configures AllowList for specified links (Leader-Router1, Router1-FED1). - Includes 1-line log outputs for each test step. - Adheres to requested block comment formatting and line length. - Created tests/nexus/verify_7_1_8.py: - Implements pcap-based verification of PASS criteria. - Validates CoAP and MLE message exchanges. - Follows requested Python filter and line length formatting. - Updated tests/nexus/CMakeLists.txt to build the new test. - Updated tests/nexus/run_nexus_tests.sh to add 7_1_8 to the default test list. --- tests/nexus/CMakeLists.txt | 1 + tests/nexus/run_nexus_tests.sh | 1 + tests/nexus/test_7_1_8.cpp | 253 +++++++++++++++++++++++++++++++++ tests/nexus/verify_7_1_8.py | 151 ++++++++++++++++++++ 4 files changed, 406 insertions(+) create mode 100644 tests/nexus/test_7_1_8.cpp create mode 100644 tests/nexus/verify_7_1_8.py diff --git a/tests/nexus/CMakeLists.txt b/tests/nexus/CMakeLists.txt index bae359694..4ddbad83e 100644 --- a/tests/nexus/CMakeLists.txt +++ b/tests/nexus/CMakeLists.txt @@ -192,6 +192,7 @@ ot_nexus_test(7_1_3 "cert;nexus") ot_nexus_test(7_1_4 "cert;nexus") ot_nexus_test(7_1_5 "cert;nexus") ot_nexus_test(7_1_6 "cert;nexus") +ot_nexus_test(7_1_8 "cert;nexus") ot_nexus_test(9_2_1 "cert;nexus") ot_nexus_test(9_2_2 "cert;nexus") diff --git a/tests/nexus/run_nexus_tests.sh b/tests/nexus/run_nexus_tests.sh index 7eb3f7b87..f5d94f09d 100755 --- a/tests/nexus/run_nexus_tests.sh +++ b/tests/nexus/run_nexus_tests.sh @@ -128,6 +128,7 @@ DEFAULT_TESTS=( "7_1_4" "7_1_5" "7_1_6" + "7_1_8" "9_2_1" "9_2_2" ) diff --git a/tests/nexus/test_7_1_8.cpp b/tests/nexus/test_7_1_8.cpp new file mode 100644 index 000000000..54f1eb10b --- /dev/null +++ b/tests/nexus/test_7_1_8.cpp @@ -0,0 +1,253 @@ +/* + * Copyright (c) 2026, The OpenThread Authors. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holder nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include + +#include "mac/mac.hpp" +#include "platform/nexus_core.hpp" +#include "platform/nexus_node.hpp" +#include "thread/child_table.hpp" +#include "thread/neighbor.hpp" +#include "thread/neighbor_table.hpp" +#include "thread/network_data_local.hpp" +#include "thread/network_data_notifier.hpp" + +namespace ot { +namespace Nexus { + +/** + * Time to advance for a node to form a network and become leader, in milliseconds. + */ +static constexpr uint32_t kFormNetworkTime = 13 * 1000; + +/** + * Time to advance for a node to join as a child and upgrade to a router, in milliseconds. + */ +static constexpr uint32_t kAttachToRouterTime = 200 * 1000; + +/** + * Time to advance for a node to join as a child, in milliseconds. + */ +static constexpr uint32_t kAttachAsChildTime = 5 * 1000; + +/** + * Child timeout value in seconds. + */ +static constexpr uint32_t kChildTimeout = 10; + +/** + * Time to advance for the network to stabilize, in milliseconds. + */ +static constexpr uint32_t kStabilizationTime = 10 * 1000; + +/** + * IPv6 Prefix 1. + */ +static const char kPrefix1[] = "2001::/64"; + +/** + * IPv6 Prefix 2. + */ +static const char kPrefix2[] = "2002::/64"; + +void Test7_1_8(const char *aJsonFile) +{ + /** + * 7.1.8 Network data propagation – Border Router as End Device in Thread network; registers new server data + * information after network is formed + * + * 7.1.8.1 Topology + * - FED_1 is configured to require complete network data. (Mode TLV) + * + * 7.1.8.2 Purpose & Description + * The purpose of this test case is to verify that when global prefix information is set on the FED, the DUT + * properly disseminates the associated network data. It also verifies that the DUT sends revised server data + * information to the Leader when the FED is removed. + * + * Spec Reference | V1.1 Section | V1.3.0 Section + * -------------------------------------------|--------------------|-------------------- + * Thread Network Data / Stable Thread | 5.13 / 5.14 / 5.15 | 5.13 / 5.14 / 5.15 + * Network Data / Network Data Propagation | | + */ + + Core nexus; + + Node &leader = nexus.CreateNode(); + Node &router1 = nexus.CreateNode(); // DUT + Node &fed1 = nexus.CreateNode(); + + leader.SetName("LEADER"); + router1.SetName("ROUTER_1"); + fed1.SetName("FED_1"); + + nexus.AdvanceTime(0); + + Instance::SetLogLevel(kLogLevelNote); + + Log("---------------------------------------------------------------------------------------"); + Log("Step 1: All"); + + /** + * Step 1: All + * - Description: Topology Ensure topology is formed correctly. + * - Pass Criteria: N/A. + */ + + /** Use AllowList feature to specify links between nodes. */ + leader.AllowList(router1); + router1.AllowList(leader); + + router1.AllowList(fed1); + fed1.AllowList(router1); + + leader.Form(); + nexus.AdvanceTime(kFormNetworkTime); + VerifyOrQuit(leader.Get().IsLeader()); + + router1.Join(leader); + nexus.AdvanceTime(kAttachToRouterTime); + VerifyOrQuit(router1.Get().IsRouter()); + + fed1.Get().SetTimeout(kChildTimeout); + fed1.Join(router1, Node::kAsFed); + nexus.AdvanceTime(kAttachAsChildTime); + VerifyOrQuit(fed1.Get().IsChild()); + + nexus.AdvanceTime(kStabilizationTime); + + Log("---------------------------------------------------------------------------------------"); + Log("Step 2: FED_1"); + + /** + * Step 2: FED_1 + * - Description: Harness configures device with the following On-Mesh Prefix Set: + * - Prefix 1: P_Prefix=2001::/64 P_stable=1 P_default=1 P_slaac=1 P_on_mesh=1 P_preferred=1 + * - Prefix 2: P_Prefix=2002::/64 P_stable=0 P_default=1 P_slaac=1 P_on_mesh=1 P_preferred=1 + * - Automatically sends a CoAP Server Data Notification message with the server’s information (Prefix, Border + * Router) to the Leader. + * - Pass Criteria: N/A. + */ + + { + NetworkData::OnMeshPrefixConfig config; + + config.Clear(); + IgnoreError(config.GetPrefix().FromString(kPrefix1)); + config.mStable = true; + config.mDefaultRoute = true; + config.mSlaac = true; + config.mOnMesh = true; + config.mPreferred = true; + IgnoreError(fed1.Get().AddOnMeshPrefix(config)); + + config.Clear(); + IgnoreError(config.GetPrefix().FromString(kPrefix2)); + config.mStable = false; + config.mDefaultRoute = true; + config.mSlaac = true; + config.mOnMesh = true; + config.mPreferred = true; + IgnoreError(fed1.Get().AddOnMeshPrefix(config)); + + fed1.Get().HandleServerDataUpdated(); + } + + nexus.AdvanceTime(kStabilizationTime); + + Log("---------------------------------------------------------------------------------------"); + Log("Step 3: Leader"); + + /** + * Step 3: Leader + * - Description: Automatically transmits a 2.04 Changed CoAP response to the DUT. Automatically transmits + * multicast MLE Data Response with the new information collected, adding also 6LoWPAN ID TLV for the prefix set + * on FED_1. + * - Pass Criteria: N/A. + */ + + nexus.AdvanceTime(kStabilizationTime); + + Log("---------------------------------------------------------------------------------------"); + Log("Step 4: Router_1 (DUT)"); + + /** + * Step 4: Router_1 (DUT) + * - Description: Automatically transmits multicast MLE Data Response with the new information collected, adding + * also 6LoWPAN ID TLV for the prefix set on FED_1. + * - Pass Criteria: The DUT MUST send a multicast MLE Data Response. + */ + + nexus.AdvanceTime(kStabilizationTime); + + Log("---------------------------------------------------------------------------------------"); + Log("Step 5: FED_1"); + + /** + * Step 5: FED_1 + * - Description: Harness silently powers-down FED_1 and waits for Router_1 to remove FED_1 from its neighbor + * table. + * - Pass Criteria: N/A. + */ + + fed1.Get().Stop(); + + // Wait for the child to be timed out by the parent router. + nexus.AdvanceTime((kChildTimeout + 2) * 1000); + + // Verify that the child is removed from the neighbor table. + VerifyOrQuit(router1.Get().FindNeighbor(fed1.Get().GetExtAddress()) == nullptr, + "FED_1 should be removed after timeout"); + + nexus.AdvanceTime(kStabilizationTime); + + Log("---------------------------------------------------------------------------------------"); + Log("Step 6: Router_1 (DUT)"); + + /** + * Step 6: Router_1 (DUT) + * - Description: Automatically notifies Leader of removed server’s (FED_1’s) RLOC16. + * - Pass Criteria: The DUT MUST send a CoAP Server Data Notification message to the Leader containing only the + * removed server’s RLOC16: + * - CoAP Request URI: coap://[]:MM/a/sd + * - CoAP Payload: RLOC16 TLV. + */ + + nexus.AdvanceTime(kStabilizationTime); + + nexus.SaveTestInfo(aJsonFile); +} + +} // namespace Nexus +} // namespace ot + +int main(int argc, char *argv[]) +{ + ot::Nexus::Test7_1_8((argc > 2) ? argv[2] : "test_7_1_8.json"); + printf("All tests passed\n"); + return 0; +} diff --git a/tests/nexus/verify_7_1_8.py b/tests/nexus/verify_7_1_8.py new file mode 100644 index 000000000..12cdc0863 --- /dev/null +++ b/tests/nexus/verify_7_1_8.py @@ -0,0 +1,151 @@ +#!/usr/bin/env python3 +# +# Copyright (c) 2026, The OpenThread Authors. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. Neither the name of the copyright holder nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# + +import sys +import os + +# Add the current directory to sys.path to find verify_utils +CUR_DIR = os.path.dirname(os.path.abspath(__file__)) +sys.path.append(CUR_DIR) + +import verify_utils +from pktverify import consts +from pktverify.addrs import Ipv6Addr + + +def verify(pv): + # 7.1.8 Network data propagation - Border Router as End Device in Thread network; registers new server data + # information after network is formed + # + # 7.1.8.1 Topology + # - FED_1 is configured to require complete network data. (Mode TLV) + # + # 7.1.8.2 Purpose and Description + # The purpose of this test case is to verify that when global prefix information is set on the FED, the DUT + # properly disseminates the associated network data. It also verifies that the DUT sends revised server data + # information to the Leader when the FED is removed. + # + # Spec Reference | V1.1 Section | V1.3.0 Section + # -------------------------------------------|--------------------|-------------------- + # Thread Network Data / Stable Thread | 5.13 / 5.14 / 5.15 | 5.13 / 5.14 / 5.15 + # Network Data / Network Data Propagation | | + + pkts = pv.pkts + pv.summary.show() + + LEADER = pv.vars['LEADER'] + ROUTER_1 = pv.vars['ROUTER_1'] + FED_1 = pv.vars['FED_1'] + LEADER_RLOC16 = pv.vars['LEADER_RLOC16'] + FED_1_RLOC16 = pv.vars['FED_1_RLOC16'] + + PREFIX_1 = Ipv6Addr("2001::") + PREFIX_2 = Ipv6Addr("2002::") + + # Step 1: All + # - Description: Topology Ensure topology is formed correctly. + # - Pass Criteria: N/A. + print("Step 1: Topology Ensure topology is formed correctly.") + pkts.filter_wpan_src64(LEADER).\ + filter_mle_cmd(consts.MLE_ADVERTISEMENT).\ + must_next() + pkts.filter_wpan_src64(ROUTER_1).\ + filter_mle_cmd(consts.MLE_ADVERTISEMENT).\ + must_next() + pkts.filter_wpan_src64(FED_1).\ + filter_mle_cmd(consts.MLE_CHILD_ID_REQUEST).\ + must_next() + + # Step 2: FED_1 + # - Description: Harness configures device with the following On-Mesh Prefix Set: + # - Prefix 1: P_Prefix=2001::/64 P_stable=1 P_default=1 P_slaac=1 P_on_mesh=1 P_preferred=1 + # - Prefix 2: P_Prefix=2002::/64 P_stable=0 P_default=1 P_slaac=1 P_on_mesh=1 P_preferred=1 + # - Automatically sends a CoAP Server Data Notification message with the server’s information (Prefix, Border + # Router) to the Leader. + # - Pass Criteria: N/A. + print("Step 2: FED_1 sends a CoAP Server Data Notification message.") + pkts.filter_wpan_src64(FED_1).\ + filter_coap_request(consts.SVR_DATA_URI).\ + filter(lambda p: consts.NL_THREAD_NETWORK_DATA_TLV in p.coap.tlv.type).\ + must_next() + + # Step 3: Leader + # - Description: Automatically transmits a 2.04 Changed CoAP response to the DUT. Automatically transmits + # multicast MLE Data Response with the new information collected, adding also 6LoWPAN ID TLV for the prefix set + # on FED_1. + # - Pass Criteria: N/A. + print("Step 3: Leader transmits a 2.04 Changed CoAP response and multicast MLE Data Response.") + pkts.filter_wpan_src64(LEADER).\ + filter_LLANMA().\ + filter_mle_cmd(consts.MLE_DATA_RESPONSE).\ + filter(lambda p: { + PREFIX_1, + PREFIX_2 + } <= set(p.thread_nwd.tlv.prefix)).\ + must_next() + pkts.filter_wpan_src64(LEADER).\ + filter_coap_ack(consts.SVR_DATA_URI).\ + must_next() + + # Step 4: Router_1 (DUT) + # - Description: Automatically transmits multicast MLE Data Response with the new information collected, adding + # also 6LoWPAN ID TLV for the prefix set on FED_1. + # - Pass Criteria: The DUT MUST send a multicast MLE Data Response. + print("Step 4: Router_1 (DUT) transmits multicast MLE Data Response.") + pkts.filter_wpan_src64(ROUTER_1).\ + filter_LLANMA().\ + filter_mle_cmd(consts.MLE_DATA_RESPONSE).\ + filter(lambda p: { + PREFIX_1, + PREFIX_2 + } <= set(p.thread_nwd.tlv.prefix)).\ + must_next() + + # Step 5: FED_1 + # - Description: Harness silently powers-down FED_1 and waits for Router_1 to remove FED_1 from its neighbor + # table. + # - Pass Criteria: N/A. + print("Step 5: FED_1 is powered down.") + + # Step 6: Router_1 (DUT) + # - Description: Automatically notifies Leader of removed server’s (FED_1’s) RLOC16. + # - Pass Criteria: The DUT MUST send a CoAP Server Data Notification message to the Leader containing only the + # removed server’s RLOC16: + # - CoAP Request URI: coap://[]:MM/a/sd + # - CoAP Payload: RLOC16 TLV. + print("Step 6: Router_1 (DUT) notifies Leader of removed server's RLOC16.") + pkts.filter_wpan_src64(ROUTER_1).\ + filter_coap_request(consts.SVR_DATA_URI).\ + filter(lambda p: p.coap.tlv.type == [consts.NL_RLOC16_TLV]).\ + filter(lambda p: p.coap.tlv.rloc16 == FED_1_RLOC16).\ + must_next() + + +if __name__ == '__main__': + verify_utils.run_main(verify)