[nexus] add test 7.1.6 Network data propagation - BR leaves/rejoins (#12515)

This commit adds a new Nexus test case 7.1.6 which verifies network
data propagation when a Border Router leaves the network, rejoins,
and updates its server data.

The test verifies that when the DUT (Border Router) leaves, its
registered prefixes are removed from the network data after a timeout.
Upon rejoining and updating its server data, the test ensures that
the new prefixes are correctly propagated to other routers and
their children (MED and SED).

Summary of changes:
- Created tests/nexus/test_7_1_6.cpp:
    - Implements the 17-step test specification.
    - Handles DUT reset and rejoin as a Router (FED).
    - Uses direct OpenThread core method calls.
    - Configures AllowList for controlled topology.
    - Addressed review comments by using more idiomatic `FromString()`
      and removing redundant constants.
- Created tests/nexus/verify_7_1_6.py:
    - Implements PCAP-based verification of the test steps.
    - Validates prefix removal and subsequent propagation of updated
      data.
    - Uses non-sequential packet search for robust verification.
- Updated tests/nexus/CMakeLists.txt to build the new test.
- Updated tests/nexus/run_nexus_tests.sh to include 7_1_6 in the
  default test list.
This commit is contained in:
Jonathan Hui
2026-02-21 19:07:44 -06:00
committed by GitHub
parent d5996e2a57
commit a6c4acce13
4 changed files with 819 additions and 0 deletions
+1
View File
@@ -190,6 +190,7 @@ ot_nexus_test(7_1_2 "cert;nexus")
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(9_2_1 "cert;nexus")
# Misc tests
+1
View File
@@ -126,6 +126,7 @@ DEFAULT_TESTS=(
"7_1_3"
"7_1_4"
"7_1_5"
"7_1_6"
"9_2_1"
)
+471
View File
@@ -0,0 +1,471 @@
/*
* 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 <stdio.h>
#include "common/code_utils.hpp"
#include "common/encoding.hpp"
#include "platform/nexus_core.hpp"
#include "platform/nexus_node.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 the network to stabilize after routers have attached.
*/
static constexpr uint32_t kStabilizationTime = 30 * 1000;
/**
* Time to allow Leader to detect Router removal, in milliseconds.
*/
static constexpr uint32_t kRouterRemovalDetectionTime = 720 * 1000;
/**
* Timeout for ping response, in milliseconds.
*/
static constexpr uint32_t kPingTimeout = 30 * 1000;
/**
* Test prefix.
*/
static constexpr char kPrefix[] = "2001:db8:1::/64";
/**
* Delay for SED echo response, in milliseconds.
*/
static constexpr uint32_t kSedEchoResponseDelay = 180 * 1000;
void Test7_1_6(void)
{
/**
* 7.1.6 Network data propagation when BR Leaves the network, rejoins and updates server data
*
* 7.1.6.1 Topology
* - Router_1 is configured as Border Router for prefix 2001:db8:1::/64.
* - Router_2 is configured as Border Router for prefix 2001:db8:1::/64.
* - MED_1 is configured to require complete network data.
* - SED_1 is configured to request only stable network data.
*
* 7.1.6.2 Purpose & Description
* The purpose of this test case is to verify that network data is properly updated when a server from the network
* leaves and rejoins.
*
* Spec Reference | V1.1 Section | V1.3.0 Section
* -----------------|--------------|---------------
* Server Behavior | 5.15.6 | 5.15.6
*/
Core nexus;
Node &dut = nexus.CreateNode();
Node &router1 = nexus.CreateNode();
Node &router2 = nexus.CreateNode();
Node &med1 = nexus.CreateNode();
Node &sed1 = nexus.CreateNode();
dut.SetName("DUT");
router1.SetName("ROUTER_1");
router2.SetName("ROUTER_2");
med1.SetName("MED_1");
sed1.SetName("SED_1");
nexus.AdvanceTime(0);
Instance::SetLogLevel(kLogLevelNote);
Log("---------------------------------------------------------------------------------------");
Log("Step 1: All");
/**
* Step 1: All
* - Description: Ensure topology is formed correctly.
* - Pass Criteria: N/A.
*/
dut.AllowList(router1);
dut.AllowList(router2);
dut.AllowList(med1);
dut.AllowList(sed1);
router1.AllowList(dut);
router2.AllowList(dut);
med1.AllowList(dut);
sed1.AllowList(dut);
dut.Form();
nexus.AdvanceTime(kFormNetworkTime);
VerifyOrQuit(dut.Get<Mle::Mle>().IsLeader());
router1.Join(dut);
nexus.AdvanceTime(kAttachToRouterTime);
VerifyOrQuit(router1.Get<Mle::Mle>().IsRouter());
router2.Join(dut);
nexus.AdvanceTime(kAttachToRouterTime);
VerifyOrQuit(router2.Get<Mle::Mle>().IsRouter());
med1.Join(dut, Node::kAsMed);
nexus.AdvanceTime(kAttachToRouterTime);
VerifyOrQuit(med1.Get<Mle::Mle>().IsChild());
sed1.Join(dut, Node::kAsSed);
nexus.AdvanceTime(kAttachToRouterTime);
VerifyOrQuit(sed1.Get<Mle::Mle>().IsChild());
nexus.AdvanceTime(kStabilizationTime);
Log("---------------------------------------------------------------------------------------");
Log("Step 2: Router_1");
/**
* Step 2: Router_1
* - Description: Harness configures the device with the following On-Mesh Prefix Set:
* - Prefix 1: P_prefix = 2001:db8:1::/64 P_stable = 1 P_on_mesh = 1 P_slaac = 1 P_default = 1
* - Automatically sends a CoAP Server Data Notification message with the servers information (Prefix, Border
* Router) to the Leader:
* - CoAP Request URI: coap://[<leader address>]:MM/a/sd
* - CoAP Payload: Thread Network Data TLV
* - Pass Criteria: N/A.
*/
{
NetworkData::OnMeshPrefixConfig config;
config.Clear();
SuccessOrQuit(config.GetPrefix().FromString(kPrefix));
config.mStable = true;
config.mOnMesh = true;
config.mSlaac = true;
config.mDefaultRoute = true;
SuccessOrQuit(router1.Get<NetworkData::Local>().AddOnMeshPrefix(config));
}
router1.Get<NetworkData::Notifier>().HandleServerDataUpdated();
nexus.AdvanceTime(kStabilizationTime);
Log("---------------------------------------------------------------------------------------");
Log("Step 3: Router_2");
/**
* Step 3: Router_2
* - Description: Harness configures the device with the following On-Mesh Prefix Set:
* - Prefix 1: P_Prefix = 2001:db8:1::/64 P_stable = 0 P_on_mesh = 1 P_slaac = 1 P_default = 1
* - Automatically sends a CoAP Server Data Notification message with the servers information (Prefix, Border
* Router) to the Leader:
* - CoAP Request URI: coap://[<leader address>]:MM/a/sd
* - CoAP Payload: Thread Network Data TLV
* - Pass Criteria: N/A.
*/
{
NetworkData::OnMeshPrefixConfig config;
config.Clear();
SuccessOrQuit(config.GetPrefix().FromString(kPrefix));
config.mStable = false;
config.mOnMesh = true;
config.mSlaac = true;
config.mDefaultRoute = true;
SuccessOrQuit(router2.Get<NetworkData::Local>().AddOnMeshPrefix(config));
}
router2.Get<NetworkData::Notifier>().HandleServerDataUpdated();
nexus.AdvanceTime(kStabilizationTime);
Log("---------------------------------------------------------------------------------------");
Log("Step 4: Leader (DUT)");
/**
* Step 4: Leader (DUT)
* - Description: Automatically sends a CoAP ACK frame to each of Router_1 and Router_2.
* - Pass Criteria:
* - The DUT MUST send a CoAP ACK frame (2.04 Changed) to Router_1.
* - The DUT MUST send a CoAP ACK frame (2.04 Changed) to Router_2.
*/
Log("---------------------------------------------------------------------------------------");
Log("Step 5: Leader (DUT)");
/**
* Step 5: Leader (DUT)
* - Description: Automatically sends new network data to neighbors and rx-on-when idle Children (MED_1) via a
* multicast MLE Data Response to address FF02::1.
* - Pass Criteria: The DUT MUST multicast MLE Data Response with the new information collected from Router_1 and
* Router_2, including the following TLVs:
* - Source Address TLV
* - Leader Data TLV
* - Data Version field <incremented>
* - Stable Data Version field <incremented>
* - Network Data TLV
* - At least one Prefix TLV (Prefix 1)
* - Two Border Router sub-TLVs
* - 6LoWPAN ID sub-TLV
*/
Log("---------------------------------------------------------------------------------------");
Log("Step 6: Leader (DUT)");
/**
* Step 6: Leader (DUT)
* - Description: Automatically sends notification of new network data to SED_1 via a unicast MLE Child Update
* Request or MLE Data Response.
* - Pass Criteria: The DUT MUST send MLE Child Update Request or Data Response to SED_1, which contains the stable
* Network Data and includes the following TLVs:
* - Source Address TLV
* - Leader Data TLV
* - Data version numbers must be the same as the ones sent in the multicast data response in step 5
* - Network Data TLV
* - At least one TLV (Prefix 1) TLV, including:
* - Border Router sub-TLV (corresponding to Router_1)
* - 6LoWPAN ID sub-TLV
* - P_border_router_16 <0xFFFE>
* - Active Timestamp TLV
*/
nexus.AdvanceTime(kStabilizationTime);
Log("---------------------------------------------------------------------------------------");
Log("Step 7: Router_1");
/**
* Step 7: Router_1
* - Description: Harness silently powers-off Router_1 and waits 720 seconds to allow Leader (DUT) to detect the
* change.
* - Pass Criteria: N/A.
*/
router1.Reset();
nexus.AdvanceTime(kRouterRemovalDetectionTime);
Log("---------------------------------------------------------------------------------------");
Log("Step 8: Leader (DUT)");
/**
* Step 8: Leader (DUT)
* - Description: Automatically detects removal of Router_1 and updates the Router ID Set accordingly.
* - Pass Criteria:
* - The DUT MUST detect that Router_1 is removed from the network and update the Router ID Set.
* - The DUT MUST remove the Network Data section corresponding to Router_1 and increment the Data Version and
* Stable Data Version.
*/
Log("---------------------------------------------------------------------------------------");
Log("Step 9: Leader (DUT)");
/**
* Step 9: Leader (DUT)
* - Description: Automatically sends new updated network data to neighbors and rx-on-when idle Children (MED_1).
* - Pass Criteria: The DUT MUST send MLE Data Response to the Link-Local All Nodes multicast address (FF02::1),
* including the following TLVs:
* - Source Address TLV
* - Leader Data TLV
* - Data version field <incremented>
* - Stable Version field <incremented>
* - Network Data TLV
* - Router_1s Network Data section MUST be removed
*/
Log("---------------------------------------------------------------------------------------");
Log("Step 10: Leader (DUT)");
/**
* Step 10: Leader (DUT)
* - Description: Automatically sends notification of new network data to SED_1 via a unicast MLE Child Update
* Request or MLE Data Response.
* - Pass Criteria: The DUT MUST unicast MLE Child Update Request or Data Response to SED_1, containing the updated
* Network Data:
* - Source Address TLV
* - Network Data TLV
* - Active Timestamp TLV
*/
nexus.AdvanceTime(kStabilizationTime);
Log("---------------------------------------------------------------------------------------");
Log("Step 11: Router_1");
/**
* Step 11: Router_1
* - Description: Harness silently powers-up Router_1; it automatically begins the attach procedure.
* - Pass Criteria: N/A.
*/
dut.AllowList(router1);
router1.AllowList(dut);
router1.Join(dut, Node::kAsFed);
nexus.AdvanceTime(kAttachToRouterTime);
Log("---------------------------------------------------------------------------------------");
Log("Step 12: Leader (DUT)");
/**
* Step 12: Leader (DUT)
* - Description: Automatically attaches Router_1 as a Child.
* - Pass Criteria: The DUT MUST send MLE Child ID Response to Router_1, which includes the following TLVs:
* - Source Address TLV
* - Leader Data TLV
* - Address16 TLV
* - Route64 TLV
* - Network Data TLV
* - At least one Prefix TLV (Prefix 1) including:
* - Border Router sub-TLV corresponding to Router_2
* - 6LoWPAN ID sub-TLV
*/
nexus.AdvanceTime(kStabilizationTime);
Log("---------------------------------------------------------------------------------------");
Log("Step 13: Router_1");
/**
* Step 13: Router_1
* - Description: Harness (re)configures the device with the following On-Mesh Prefix Set:
* - Prefix 1: P_prefix = 2001:db8:1::/64 P_stable = 1 P_on_mesh = 1 P_slaac = 1 P_default = 1
* - Automatically sends a CoAP Server Data Notification message with the servers information (Prefix, Border
* Router) to the Leader:
* - CoAP Request URI: coap://[<leader address>]:MM/a/sd
* - CoAP Payload: Thread Network Data TLV
* - Pass Criteria: N/A.
*/
SuccessOrQuit(router1.Get<Mle::Mle>().SetRouterEligible(true));
SuccessOrQuit(router1.Get<Mle::Mle>().BecomeRouter(Mle::kReasonTooFewRouters));
nexus.AdvanceTime(kStabilizationTime);
{
NetworkData::OnMeshPrefixConfig config;
config.Clear();
SuccessOrQuit(config.GetPrefix().FromString(kPrefix));
config.mStable = true;
config.mOnMesh = true;
config.mSlaac = true;
config.mDefaultRoute = true;
SuccessOrQuit(router1.Get<NetworkData::Local>().AddOnMeshPrefix(config));
}
router1.Get<NetworkData::Notifier>().HandleServerDataUpdated();
nexus.AdvanceTime(kStabilizationTime);
Log("---------------------------------------------------------------------------------------");
Log("Step 14: Leader (DUT)");
/**
* Step 14: Leader (DUT)
* - Description: Automatically sends a CoAP ACK frame to Router_1.
* - Pass Criteria: The DUT MUST send a CoAP ACK frame (2.04 Changed) to Router_1.
*/
Log("---------------------------------------------------------------------------------------");
Log("Step 15: Leader (DUT)");
/**
* Step 15: Leader (DUT)
* - Description: Automatically sends new updated network data to neighbors and rx-on-when idle Children (MED_1).
* - Pass Criteria: The DUT MUST multicast a MLE Data Response with the new information collected from Router_1,
* including the following fields:
* - Source Address TLV
* - Leader Data TLV
* - Data version field <incremented>
* - Stable Version field <incremented>
* - Network Data TLV
* - At least one Prefix TLV (Prefix 1) including:
* - Two Border Router sub-TLVs corresponding to Router_1 and Router_2
* - 6LoWPAN ID sub-TLV
*/
Log("---------------------------------------------------------------------------------------");
Log("Step 16: Leader (DUT)");
/**
* Step 16: Leader (DUT)
* - Description: Automatically sends notification of new network data to SED_1 via a unicast MLE Child Update
* Request or MLE Data Response.
* - Pass Criteria: The DUT MUST send a unicast MLE Child Update Request or Data Response to SED_1, containing the
* stable Network Data and including the following TLVs:
* - Source Address TLV
* - Leader Data TLV
* - Data version numbers must be the same as those sent in the multicast data response in step 15
* - Network Data TLV
* - At least one Prefix TLV (Prefix 1), including:
* - Border Router sub-TLV (corresponding to Router_1)
* - 6LoWPAN ID sub-TLV
* - P_border_router_16 <0xFFFE>
* - Active Timestamp TLV
*/
nexus.AdvanceTime(kStabilizationTime);
Log("---------------------------------------------------------------------------------------");
Log("Step 17: Router_1, SED_1");
/**
* Step 17: Router_1, SED_1
* - Description: Harness verifies connectivity by sending ICMPv6 Echo Requests from Router_1 and SED_1 to the DUT
* Prefix_1 based address.
* - Pass Criteria: The DUT MUST respond with ICMPv6 Echo Replies.
*/
{
const Ip6::Address &dutAddress = dut.FindMatchingAddress(kPrefix);
router1.SendEchoRequest(dutAddress, 1);
nexus.AdvanceTime(kPingTimeout);
sed1.SendEchoRequest(dutAddress, 2);
nexus.AdvanceTime(kSedEchoResponseDelay);
}
nexus.SaveTestInfo("test_7_1_6.json");
}
} /* namespace Nexus */
} /* namespace ot */
int main(void)
{
ot::Nexus::Test7_1_6();
printf("All tests passed\n");
return 0;
}
+346
View File
@@ -0,0 +1,346 @@
#!/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
PREFIX = Ipv6Addr('2001:db8:1::')
def verify(pv):
# 7.1.6 Network data propagation when BR Leaves the network, rejoins and updates server data
#
# 7.1.6.1 Topology
# - Router_1 is configured as Border Router for prefix 2001:db8:1::/64.
# - Router_2 is configured as Border Router for prefix 2001:db8:1::/64.
# - MED_1 is configured to require complete network data.
# - SED_1 is configured to request only stable network data.
#
# 7.1.6.2 Purpose & Description
# The purpose of this test case is to verify that network data is properly updated when a server from the network
# leaves and rejoins.
#
# Spec Reference | V1.1 Section | V1.3.0 Section
# -----------------|--------------|---------------
# Server Behavior | 5.15.6 | 5.15.6
pkts = pv.pkts
pv.summary.show()
DUT = pv.vars['DUT']
ROUTER_1 = pv.vars['ROUTER_1']
ROUTER_2 = pv.vars['ROUTER_2']
MED_1 = pv.vars['MED_1']
SED_1 = pv.vars['SED_1']
# Step 1: All
# - Description: Ensure topology is formed correctly.
# - Pass Criteria: N/A.
print("Step 1: Ensure topology is formed correctly.")
pv.verify_attached('ROUTER_1', 'DUT')
pv.verify_attached('ROUTER_2', 'DUT')
pv.verify_attached('MED_1', 'DUT', 'MTD')
pv.verify_attached('SED_1', 'DUT', 'MTD')
# Step 2: Router_1
# - Description: Harness configures the device with the following On-Mesh Prefix Set:
# - Prefix 1: P_prefix = 2001:db8:1::/64 P_stable = 1 P_on_mesh = 1 P_slaac = 1 P_default = 1
# - Automatically sends a CoAP Server Data Notification message with the servers information (Prefix, Border Router) to the Leader:
# - CoAP Request URI: coap://[<leader address>]:MM/a/sd
# - CoAP Payload: Thread Network Data TLV
# - Pass Criteria: N/A.
print("Step 2: Router_1 sends a CoAP Server Data Notification.")
req1 = pkts.filter_wpan_src64(ROUTER_1).\
filter_coap_request(consts.SVR_DATA_URI).\
must_next()
index_after_req1 = pkts.index
# Step 3: Router_2
# - Description: Harness configures the device with the following On-Mesh Prefix Set:
# - Prefix 1: P_Prefix = 2001:db8:1::/64 P_stable = 0 P_on_mesh = 1 P_slaac = 1 P_default = 1
# - Automatically sends a CoAP Server Data Notification message with the servers information (Prefix, Border Router) to the Leader:
# - CoAP Request URI: coap://[<leader address>]:MM/a/sd
# - CoAP Payload: Thread Network Data TLV
# - Pass Criteria: N/A.
print("Step 3: Router_2 sends a CoAP Server Data Notification.")
req2 = pkts.filter_wpan_src64(ROUTER_2).\
filter_coap_request(consts.SVR_DATA_URI).\
must_next()
index_after_req2 = pkts.index
# Step 4: Leader (DUT)
# - Description: Automatically sends a CoAP ACK frame to each of Router_1 and Router_2.
# - Pass Criteria:
# - The DUT MUST send a CoAP ACK frame (2.04 Changed) to Router_1.
# - The DUT MUST send a CoAP ACK frame (2.04 Changed) to Router_2.
print("Step 4: DUT MUST send a CoAP ACK frame (2.04 Changed) to Router_1 and Router_2.")
# We find the ACKs which might be out of order with respect to Step 3's request.
pkts.index = index_after_req1
pkts.filter_ipv6_src(str(req1.ipv6.dst)).\
filter_ipv6_dst(str(req1.ipv6.src)).\
filter(lambda p: p.coap.code == consts.COAP_CODE_ACK).\
must_next()
pkts.index = index_after_req2
pkts.filter_ipv6_src(str(req2.ipv6.dst)).\
filter_ipv6_dst(str(req2.ipv6.src)).\
filter(lambda p: p.coap.code == consts.COAP_CODE_ACK).\
must_next()
# Step 5: Leader (DUT)
# - Description: Automatically sends new network data to neighbors and rx-on-when idle Children (MED_1) via a multicast MLE Data Response to address FF02::1.
# - Pass Criteria: The DUT MUST multicast MLE Data Response with the new information collected from Router_1 and Router_2, including the following TLVs:
# - Source Address TLV
# - Leader Data TLV
# - Data Version field <incremented>
# - Stable Data Version field <incremented>
# - Network Data TLV
# - At least one Prefix TLV (Prefix 1)
# - Two Border Router sub-TLVs
# - 6LoWPAN ID sub-TLV
print("Step 5: DUT MUST multicast MLE Data Response with new information.")
pkts.filter_LLANMA().\
filter_mle_cmd(consts.MLE_DATA_RESPONSE).\
filter(lambda p: {
consts.SOURCE_ADDRESS_TLV,
consts.LEADER_DATA_TLV,
consts.NETWORK_DATA_TLV
} <= set(p.mle.tlv.type) and\
PREFIX in p.thread_nwd.tlv.prefix and\
len(p.thread_nwd.tlv.border_router_16) == 2).\
must_next()
# Step 6: Leader (DUT)
# - Description: Automatically sends notification of new network data to SED_1 via a unicast MLE Child Update Request or MLE Data Response.
# - Pass Criteria: The DUT MUST send MLE Child Update Request or Data Response to SED_1, which contains the stable Network Data and includes the following TLVs:
# - Source Address TLV
# - Leader Data TLV
# - Data version numbers must be the same as the ones sent in the multicast data response in step 5
# - Network Data TLV
# - At least one TLV (Prefix 1) TLV, including:
# - Border Router sub-TLV (corresponding to Router_1)
# - 6LoWPAN ID sub-TLV
# - P_border_router_16 <0xFFFE>
# - Active Timestamp TLV
print("Step 6: DUT MUST send MLE Child Update Request, Response or Data Response to SED_1.")
pkts.filter_wpan_dst64(SED_1).\
filter(lambda p: p.mle.cmd in (consts.MLE_CHILD_UPDATE_REQUEST,
consts.MLE_CHILD_UPDATE_RESPONSE,
consts.MLE_DATA_RESPONSE)).\
filter(lambda p: {
consts.SOURCE_ADDRESS_TLV,
consts.LEADER_DATA_TLV,
consts.NETWORK_DATA_TLV,
consts.ACTIVE_TIMESTAMP_TLV
} <= set(p.mle.tlv.type)).\
must_next()
# Step 7: Router_1
# - Description: Harness silently powers-off Router_1 and waits 720 seconds to allow Leader (DUT) to detect the change.
# - Pass Criteria: N/A.
print("Step 7: Router_1 is powered off.")
# Step 8: Leader (DUT)
# - Description: Automatically detects removal of Router_1 and updates the Router ID Set accordingly.
# - Pass Criteria:
# - The DUT MUST detect that Router_1 is removed from the network and update the Router ID Set.
# - The DUT MUST remove the Network Data section corresponding to Router_1 and increment the Data Version and Stable Data Version.
print("Step 8: DUT MUST detect removal of Router_1 and update network data.")
# Step 9: Leader (DUT)
# - Description: Automatically sends new updated network data to neighbors and rx-on-when idle Children (MED_1).
# - Pass Criteria: The DUT MUST send MLE Data Response to the Link-Local All Nodes multicast address (FF02::1), including the following TLVs:
# - Source Address TLV
# - Leader Data TLV
# - Data version field <incremented>
# - Stable Version field <incremented>
# - Network Data TLV
# - Router_1s Network Data section MUST be removed
print("Step 9: DUT MUST multicast MLE Data Response with Router_1 data removed.")
pkts.filter_LLANMA().\
filter_mle_cmd(consts.MLE_DATA_RESPONSE).\
filter(lambda p: {
consts.SOURCE_ADDRESS_TLV,
consts.LEADER_DATA_TLV,
consts.NETWORK_DATA_TLV
} <= set(p.mle.tlv.type) and\
PREFIX in p.thread_nwd.tlv.prefix and\
len(p.thread_nwd.tlv.border_router_16) == 1).\
must_next()
# Step 10: Leader (DUT)
# - Description: Automatically sends notification of new network data to SED_1 via a unicast MLE Child Update Request or MLE Data Response.
# - Pass Criteria: The DUT MUST unicast MLE Child Update Request or Data Response to SED_1, containing the updated Network Data:
# - Source Address TLV
# - Network Data TLV
# - Active Timestamp TLV
print("Step 10: DUT MUST unicast MLE Child Update Request, Response or Data Response to SED_1.")
pkts.filter_wpan_dst64(SED_1).\
filter(lambda p: p.mle.cmd in (consts.MLE_CHILD_UPDATE_REQUEST,
consts.MLE_CHILD_UPDATE_RESPONSE,
consts.MLE_DATA_RESPONSE)).\
filter(lambda p: {
consts.SOURCE_ADDRESS_TLV,
consts.LEADER_DATA_TLV,
consts.NETWORK_DATA_TLV,
consts.ACTIVE_TIMESTAMP_TLV
} <= set(p.mle.tlv.type)).\
must_next()
# Step 11: Router_1
# - Description: Harness silently powers-up Router_1; it automatically begins the attach procedure.
# - Pass Criteria: N/A.
print("Step 11: Router_1 is powered up and begins attach procedure.")
# Step 12: Leader (DUT)
# - Description: Automatically attaches Router_1 as a Child.
# - Pass Criteria: The DUT MUST send MLE Child ID Response to Router_1, which includes the following TLVs:
# - Source Address TLV
# - Leader Data TLV
# - Address16 TLV
# - Route64 TLV
# - Network Data TLV
# - At least one Prefix TLV (Prefix 1) including:
# - Border Router sub-TLV corresponding to Router_2
# - 6LoWPAN ID sub-TLV
print("Step 12: DUT MUST send MLE Child ID Response to Router_1.")
pkts.filter_wpan_dst64(ROUTER_1).\
filter_mle_cmd(consts.MLE_CHILD_ID_RESPONSE).\
filter(lambda p: {
consts.SOURCE_ADDRESS_TLV,
consts.LEADER_DATA_TLV,
consts.ADDRESS16_TLV,
consts.ROUTE64_TLV,
consts.NETWORK_DATA_TLV
} <= set(p.mle.tlv.type)).\
must_next()
# Step 13: Router_1
# - Description: Harness (re)configures the device with the following On-Mesh Prefix Set:
# - Prefix 1: P_prefix = 2001:db8:1::/64 P_stable = 1 P_on_mesh = 1 P_slaac = 1 P_default = 1
# - Automatically sends a CoAP Server Data Notification message with the servers information (Prefix, Border Router) to the Leader:
# - CoAP Request URI: coap://[<leader address>]:MM/a/sd
# - CoAP Payload: Thread Network Data TLV
# - Pass Criteria: N/A.
print("Step 13: Router_1 sends a CoAP Server Data Notification.")
req3 = pkts.filter_wpan_src64(ROUTER_1).\
filter_coap_request(consts.SVR_DATA_URI).\
must_next()
index_after_req3 = pkts.index
# Step 14: Leader (DUT)
# - Description: Automatically sends a CoAP ACK frame to Router_1.
# - Pass Criteria: The DUT MUST send a CoAP ACK frame (2.04 Changed) to Router_1.
print("Step 14: DUT MUST send a CoAP ACK frame (2.04 Changed) to Router_1.")
pkts.index = index_after_req3
pkts.filter_ipv6_src(str(req3.ipv6.dst)).\
filter_ipv6_dst(str(req3.ipv6.src)).\
filter(lambda p: p.coap.code == consts.COAP_CODE_ACK).\
must_next()
# Step 15: Leader (DUT)
# - Description: Automatically sends new updated network data to neighbors and rx-on-when idle Children (MED_1).
# - Pass Criteria: The DUT MUST multicast a MLE Data Response with the new information collected from Router_1, including the following fields:
# - Source Address TLV
# - Leader Data TLV
# - Data version field <incremented>
# - Stable Version field <incremented>
# - Network Data TLV
# - At least one Prefix TLV (Prefix 1) including:
# - Two Border Router sub-TLVs corresponding to Router_1 and Router_2
# - 6LoWPAN ID sub-TLV
print("Step 15: DUT MUST multicast MLE Data Response with updated information.")
pkts.filter_LLANMA().\
filter_mle_cmd(consts.MLE_DATA_RESPONSE).\
filter(lambda p: {
consts.SOURCE_ADDRESS_TLV,
consts.LEADER_DATA_TLV,
consts.NETWORK_DATA_TLV
} <= set(p.mle.tlv.type) and\
PREFIX in p.thread_nwd.tlv.prefix and\
len(p.thread_nwd.tlv.border_router_16) == 2).\
must_next()
# Step 16: Leader (DUT)
# - Description: Automatically sends notification of new network data to SED_1 via a unicast MLE Child Update Request or MLE Data Response.
# - Pass Criteria: The DUT MUST send a unicast MLE Child Update Request or Data Response to SED_1, containing the stable Network Data and including the following TLVs:
# - Source Address TLV
# - Leader Data TLV
# - Data version numbers must be the same as those sent in the multicast data response in step 15
# - Network Data TLV
# - At least one Prefix TLV (Prefix 1), including:
# - Border Router sub-TLV (corresponding to Router_1)
# - 6LoWPAN ID sub-TLV
# - P_border_router_16 <0xFFFE>
# - Active Timestamp TLV
print("Step 16: DUT MUST send a unicast MLE Child Update Request, Response or Data Response to SED_1.")
pkts.filter_wpan_dst64(SED_1).\
filter(lambda p: p.mle.cmd in (consts.MLE_CHILD_UPDATE_REQUEST,
consts.MLE_CHILD_UPDATE_RESPONSE,
consts.MLE_DATA_RESPONSE)).\
filter(lambda p: {
consts.SOURCE_ADDRESS_TLV,
consts.LEADER_DATA_TLV,
consts.NETWORK_DATA_TLV,
consts.ACTIVE_TIMESTAMP_TLV
} <= set(p.mle.tlv.type)).\
must_next()
# Step 17: Router_1, SED_1
# - Description: Harness verifies connectivity by sending ICMPv6 Echo Requests from Router_1 and SED_1 to the DUT Prefix_1 based address.
# - Pass Criteria: The DUT MUST respond with ICMPv6 Echo Replies.
print("Step 17: ICMPv6 Echo Request/Reply.")
# Verify pings from Router_1 and SED_1 to DUT
pkts.filter_wpan_src64(ROUTER_1).\
filter_ping_request(identifier=1).\
must_next()
pkts.filter_wpan_src64(DUT).\
filter_ping_reply(identifier=1).\
must_next()
pkts.filter_wpan_src64(SED_1).\
filter_ping_request(identifier=2).\
must_next()
pkts.filter_wpan_src64(DUT).\
filter_ping_reply(identifier=2).\
must_next()
if __name__ == '__main__':
verify_utils.run_main(verify)