mirror of
https://github.com/espressif/openthread.git
synced 2026-08-03 09:27:47 +00:00
[nexus] implement test 1.2.LP.7.2.1 for Forward Tracking Series (#12624)
This commit implements Nexus test 1.2.LP.7.2.1 to validate the Forward Tracking Series Link Metrics functionality. Specifically, the test verifies that: - The DUT (Leader) correctly handles Forward Series Link Metrics Management Requests from SED and SSED children. - The DUT properly aggregates metrics for Forward Series (MAC Data Requests for SED, all data frames for SSED). - Aggregated results are accurately reported in MLE Data Responses when queried. - Forward Series can be successfully cleared, and unknown Series IDs result in appropriate error statuses. Summary of changes: - Created test_1_2_LP_7_2_1.cpp to implement the test logic. - Created verify_1_2_LP_7_2_1.py for automated packet verification. - Updated verify_utils.py to include MLE TLV field definitions for Link Metrics (e.g., forward series, flags, query ID). - Registered the new test in tests/nexus/CMakeLists.txt and tests/nexus/run_nexus_tests.sh.
This commit is contained in:
@@ -226,6 +226,7 @@ ot_nexus_test(1_2_LP_5_3_7 "cert;nexus")
|
||||
ot_nexus_test(1_2_LP_5_3_8 "cert;nexus")
|
||||
ot_nexus_test(1_2_LP_7_1_1 "cert;nexus")
|
||||
ot_nexus_test(1_2_LP_7_1_2 "cert;nexus")
|
||||
ot_nexus_test(1_2_LP_7_2_1 "cert;nexus")
|
||||
|
||||
# Misc tests
|
||||
ot_nexus_test(border_admitter "core;nexus")
|
||||
|
||||
@@ -161,6 +161,7 @@ DEFAULT_TESTS=(
|
||||
"1_2_LP_5_3_8"
|
||||
"1_2_LP_7_1_1"
|
||||
"1_2_LP_7_1_2"
|
||||
"1_2_LP_7_2_1"
|
||||
)
|
||||
|
||||
# Use provided arguments or the default test list
|
||||
|
||||
@@ -0,0 +1,628 @@
|
||||
/*
|
||||
* 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 "mac/data_poll_sender.hpp"
|
||||
#include "platform/nexus_core.hpp"
|
||||
#include "platform/nexus_node.hpp"
|
||||
#include "thread/link_metrics.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, in milliseconds.
|
||||
*/
|
||||
static constexpr uint32_t kAttachTime = 5 * 1000;
|
||||
|
||||
/**
|
||||
* Time to advance for the network to stabilize, in milliseconds.
|
||||
*/
|
||||
static constexpr uint32_t kStabilizationTime = 10 * 1000;
|
||||
|
||||
/**
|
||||
* Time to advance for CSL synchronization to complete, in milliseconds.
|
||||
*/
|
||||
static constexpr uint32_t kCslSyncTime = 5 * 1000;
|
||||
|
||||
/**
|
||||
* Time to wait for metrics collection, in milliseconds.
|
||||
*/
|
||||
static constexpr uint32_t kWaitTime = 30 * 1000;
|
||||
|
||||
/**
|
||||
* SED poll period, in milliseconds.
|
||||
*/
|
||||
static constexpr uint32_t kSedPollPeriod = 2000;
|
||||
|
||||
/**
|
||||
* SSED data packet interval, in milliseconds.
|
||||
*/
|
||||
static constexpr uint32_t kSsedDataInterval = 1000;
|
||||
|
||||
/**
|
||||
* Echo response timeout, in milliseconds.
|
||||
*/
|
||||
static constexpr uint32_t kEchoTimeout = 5000;
|
||||
|
||||
/**
|
||||
* CSL Period in milliseconds.
|
||||
*/
|
||||
static constexpr uint32_t kCslPeriodMs = 100;
|
||||
|
||||
/**
|
||||
* CSL Period in units of 10 symbols (160 microseconds).
|
||||
*/
|
||||
static constexpr uint32_t kCslPeriod = kCslPeriodMs * 1000 / OT_US_PER_TEN_SYMBOLS;
|
||||
|
||||
/**
|
||||
* Forward Series IDs.
|
||||
*/
|
||||
static constexpr uint8_t kSeriesId4 = 4;
|
||||
static constexpr uint8_t kSeriesId11 = 11;
|
||||
static constexpr uint8_t kSeriesId16 = 16;
|
||||
|
||||
/**
|
||||
* Forward Series Flags.
|
||||
*/
|
||||
static constexpr uint8_t kSeriesFlagsMacDataRequest = 0x04;
|
||||
static constexpr uint8_t kSeriesFlagsAllDataFrames = 0x02;
|
||||
static constexpr uint8_t kSeriesFlagsClear = 0x00;
|
||||
|
||||
static otLinkMetricsStatus sMgmtStatus;
|
||||
static bool sMgmtResponseReceived;
|
||||
static otLinkMetricsStatus sReportStatus;
|
||||
static bool sReportReceived;
|
||||
|
||||
static void HandleMgmtResponse(const otIp6Address *aAddress, otLinkMetricsStatus aStatus, void *aContext)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aAddress);
|
||||
OT_UNUSED_VARIABLE(aContext);
|
||||
|
||||
sMgmtStatus = aStatus;
|
||||
sMgmtResponseReceived = true;
|
||||
}
|
||||
|
||||
static void HandleReport(const otIp6Address *aSource,
|
||||
const otLinkMetricsValues *aMetricsValues,
|
||||
otLinkMetricsStatus aStatus,
|
||||
void *aContext)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aSource);
|
||||
OT_UNUSED_VARIABLE(aMetricsValues);
|
||||
OT_UNUSED_VARIABLE(aContext);
|
||||
|
||||
sReportStatus = aStatus;
|
||||
sReportReceived = true;
|
||||
}
|
||||
|
||||
void Test1_2_LP_7_2_1(void)
|
||||
{
|
||||
/**
|
||||
* 7.2.1 Forward Tracking Series
|
||||
*
|
||||
* 7.2.1.1 Topology
|
||||
* - Leader (DUT)
|
||||
* - SED_1
|
||||
* - SSED_1
|
||||
*
|
||||
* 7.2.1.2 Purpose & Definition
|
||||
* The purpose of this test case is to ensure that the DUT can successfully respond to a Forward Series Link Metrics
|
||||
* Request from both a SED & SSED.
|
||||
*
|
||||
* Spec Reference | V1.2 Section
|
||||
* -------------------------|-------------
|
||||
* Forward Tracking Series | 4.11.3.2
|
||||
*/
|
||||
|
||||
Core nexus;
|
||||
|
||||
Node &leader = nexus.CreateNode();
|
||||
Node &sed1 = nexus.CreateNode();
|
||||
Node &ssed1 = nexus.CreateNode();
|
||||
|
||||
leader.SetName("LEADER");
|
||||
sed1.SetName("SED_1");
|
||||
ssed1.SetName("SSED_1");
|
||||
|
||||
{
|
||||
Mac::ExtAddress addr;
|
||||
static const uint8_t kLeaderAddr[] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88};
|
||||
static const uint8_t kSedAddr[] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x89};
|
||||
static const uint8_t kSsedAddr[] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x8a};
|
||||
|
||||
addr.Set(kLeaderAddr);
|
||||
leader.Get<Mac::Mac>().SetExtAddress(addr);
|
||||
addr.Set(kSedAddr);
|
||||
sed1.Get<Mac::Mac>().SetExtAddress(addr);
|
||||
addr.Set(kSsedAddr);
|
||||
ssed1.Get<Mac::Mac>().SetExtAddress(addr);
|
||||
}
|
||||
|
||||
nexus.AdvanceTime(0);
|
||||
|
||||
Instance::SetLogLevel(kLogLevelNote);
|
||||
|
||||
/**
|
||||
* Step 0: SED_1
|
||||
* - Description: Preconditions: SED_1 data poll rate set to 2 seconds.
|
||||
* - Pass Criteria: N/A
|
||||
*/
|
||||
Log("Step 0: SED_1 data poll rate set to 2 seconds.");
|
||||
SuccessOrQuit(sed1.Get<DataPollSender>().SetExternalPollPeriod(kSedPollPeriod));
|
||||
SuccessOrQuit(ssed1.Get<DataPollSender>().SetExternalPollPeriod(kSedPollPeriod));
|
||||
|
||||
/**
|
||||
* Step 1: All
|
||||
* - Description: Topology formation: DUT, SED_1, SSED_1.
|
||||
* - Pass Criteria: N/A
|
||||
*/
|
||||
Log("Step 1: Topology formation: DUT, SED_1, SSED_1.");
|
||||
leader.AllowList(sed1);
|
||||
leader.AllowList(ssed1);
|
||||
sed1.AllowList(leader);
|
||||
ssed1.AllowList(leader);
|
||||
|
||||
leader.Form();
|
||||
nexus.AdvanceTime(kFormNetworkTime);
|
||||
VerifyOrQuit(leader.Get<Mle::Mle>().IsLeader());
|
||||
|
||||
/**
|
||||
* Step 2: SED_1, SSED_1
|
||||
* - Description: Each device automatically attaches to the DUT.
|
||||
* - Pass Criteria: N/A
|
||||
*/
|
||||
Log("Step 2: Each device automatically attaches to the DUT.");
|
||||
sed1.Join(leader, Node::kAsSed);
|
||||
ssed1.Join(leader, Node::kAsSed);
|
||||
nexus.AdvanceTime(kAttachTime);
|
||||
VerifyOrQuit(sed1.Get<Mle::Mle>().IsAttached());
|
||||
VerifyOrQuit(ssed1.Get<Mle::Mle>().IsAttached());
|
||||
|
||||
ssed1.Get<Mac::Mac>().SetCslPeriod(kCslPeriod);
|
||||
nexus.AdvanceTime(kCslSyncTime);
|
||||
|
||||
nexus.AdvanceTime(kStabilizationTime);
|
||||
|
||||
/**
|
||||
* Step 3: SED_1, SSED_1
|
||||
* - Description: Harness verifies connectivity by instructing each device to send an ICMPv6 Echo Request to the
|
||||
* DUT.
|
||||
* - Pass Criteria:
|
||||
* - 3.1: The DUT MUST send an ICMPv6 Echo Reply to SED_1.
|
||||
* - 3.2: The DUT MUST send an ICMPv6 Echo Reply to SSED_1.
|
||||
*/
|
||||
Log("Step 3: Harness verifies connectivity.");
|
||||
nexus.SendAndVerifyEchoRequest(sed1, leader.Get<Mle::Mle>().GetLinkLocalAddress(), 0, 64, kEchoTimeout);
|
||||
nexus.SendAndVerifyEchoRequest(ssed1, leader.Get<Mle::Mle>().GetLinkLocalAddress(), 0, 64, kEchoTimeout);
|
||||
nexus.AdvanceTime(kStabilizationTime);
|
||||
|
||||
/**
|
||||
* Step 4: SED_1
|
||||
* - Description: Harness instructs the device to request a Forward Series Link Metric by sending a Link Metrics
|
||||
* Management Request to the DUT with the following payload:
|
||||
* - MLE Link Metrics Management TLV
|
||||
* - Forward Probing Registration Sub-TLV
|
||||
* - Type = 3
|
||||
* - Forward Series ID = 4
|
||||
* - Forward Series Flags = 0x04
|
||||
* - Bits 0-1 = 0
|
||||
* - Bit 2 = 1 (MAC Data Request command frames)
|
||||
* - Bits 3-7 = 0
|
||||
* - Concatenation of Link Metric Type ID Flags=0x40
|
||||
* - E = 0x00; L = 0x01
|
||||
* - Type/Average Enum = 0x00 (count)
|
||||
* - Metric Enum = 0x00 (count)
|
||||
* - Pass Criteria: N/A
|
||||
*/
|
||||
Log("Step 4: SED_1 requests Forward Series Link Metric ID 4.");
|
||||
{
|
||||
LinkMetrics::SeriesFlags flags;
|
||||
LinkMetrics::Metrics metrics;
|
||||
|
||||
flags.SetFrom(kSeriesFlagsMacDataRequest);
|
||||
metrics.Clear();
|
||||
metrics.mPduCount = true;
|
||||
|
||||
sed1.Get<LinkMetrics::Initiator>().SetMgmtResponseCallback(HandleMgmtResponse, nullptr);
|
||||
sMgmtResponseReceived = false;
|
||||
|
||||
SuccessOrQuit(sed1.Get<LinkMetrics::Initiator>().SendMgmtRequestForwardTrackingSeries(
|
||||
leader.Get<Mle::Mle>().GetLinkLocalAddress(), kSeriesId4, flags, &metrics));
|
||||
}
|
||||
nexus.AdvanceTime(kSedPollPeriod);
|
||||
|
||||
/**
|
||||
* Step 5: Leader (DUT)
|
||||
* - Description: Automatically responds to SED_1 with a Link Metrics Management Response.
|
||||
* - Pass Criteria: The DUT MUST unicast Link Metrics Management Response to SED_1, including the following TLVs:
|
||||
* - MLE Link Metrics Management TLV
|
||||
* - Link Metrics Status Sub-TLV = 0 (Success)
|
||||
*/
|
||||
Log("Step 5: Leader responds to SED_1 with a Link Metrics Management Response.");
|
||||
nexus.AdvanceTime(kStabilizationTime);
|
||||
VerifyOrQuit(sMgmtResponseReceived);
|
||||
VerifyOrQuit(sMgmtStatus == OT_LINK_METRICS_STATUS_SUCCESS);
|
||||
|
||||
/**
|
||||
* Step 6: SED_1
|
||||
* - Description: Harness waits for 30 seconds (MAC Data Requests sent every 2 seconds).
|
||||
* - Pass Criteria: N/A
|
||||
*/
|
||||
Log("Step 6: Wait for 30 seconds.");
|
||||
nexus.AdvanceTime(kWaitTime);
|
||||
|
||||
/**
|
||||
* Step 7: SED_1
|
||||
* - Description: Harness instructs the device to retrieve aggregated Forward Series results by sending a MLE Data
|
||||
* Request message to the DUT with the following payload:
|
||||
* - TLV Request TLV (Link Metrics Report TLV specified)
|
||||
* - Link Metrics Query TLV
|
||||
* - Link Metrics Query ID Sub-TLV
|
||||
* - Query ID = 4 [series configured in step 4]
|
||||
* - Pass Criteria: N/A
|
||||
*/
|
||||
Log("Step 7: SED_1 retrieves aggregated Forward Series ID 4 results.");
|
||||
{
|
||||
sed1.Get<LinkMetrics::Initiator>().SetReportCallback(HandleReport, nullptr);
|
||||
sReportReceived = false;
|
||||
|
||||
SuccessOrQuit(sed1.Get<LinkMetrics::Initiator>().Query(leader.Get<Mle::Mle>().GetLinkLocalAddress(), kSeriesId4,
|
||||
nullptr));
|
||||
}
|
||||
nexus.AdvanceTime(kSedPollPeriod);
|
||||
|
||||
/**
|
||||
* Step 8: Leader (DUT)
|
||||
* - Description: Automatically responds to SED_1 with a MLE Data Response.
|
||||
* - Pass Criteria: The DUT MUST unicast MLE Data Response to SED_1, including the following TLVs:
|
||||
* - Link Metrics Report TLV
|
||||
* - Link Metrics Report Sub-TLV
|
||||
* - Metric Type ID Flags
|
||||
* - E = 0x00
|
||||
* - L = 0x01
|
||||
* - Type / Average Enum = 0x00 (count/sum)
|
||||
* - Metric Enum = 0x00 (number of PDUs received)
|
||||
* - Count Value (4 bytes)
|
||||
*/
|
||||
Log("Step 8: Leader responds to SED_1 with a MLE Data Response.");
|
||||
nexus.AdvanceTime(kStabilizationTime);
|
||||
VerifyOrQuit(sReportReceived);
|
||||
VerifyOrQuit(sReportStatus == OT_LINK_METRICS_STATUS_SUCCESS);
|
||||
|
||||
/**
|
||||
* Step 9: SED_1
|
||||
* - Description: Harness instructs the device to clear the Forward Series Link Metric by sending a Link Metrics
|
||||
* Management Request with the following payload:
|
||||
* - Link Metrics Management Request:
|
||||
* - Link Metrics Management TLV
|
||||
* - Forward Probing Registration Sub-TLV
|
||||
* - Type = 3
|
||||
* - Forward Series ID = 4 [series configured in step 4]
|
||||
* - Forward Series Flags = 0x00
|
||||
* - Bits 0 -7 = 0
|
||||
* - Pass Criteria: N/A
|
||||
*/
|
||||
Log("Step 9: SED_1 clears Forward Series Link Metric ID 4.");
|
||||
{
|
||||
LinkMetrics::SeriesFlags flags;
|
||||
flags.SetFrom(kSeriesFlagsClear);
|
||||
|
||||
sMgmtResponseReceived = false;
|
||||
|
||||
SuccessOrQuit(sed1.Get<LinkMetrics::Initiator>().SendMgmtRequestForwardTrackingSeries(
|
||||
leader.Get<Mle::Mle>().GetLinkLocalAddress(), kSeriesId4, flags, nullptr));
|
||||
}
|
||||
nexus.AdvanceTime(kSedPollPeriod);
|
||||
|
||||
/**
|
||||
* Step 10: Leader (DUT)
|
||||
* - Description: Automatically responds to SED_1 with a Link Metrics Management Response.
|
||||
* - Pass Criteria: The DUT MUST unicast Link Metrics Management Response to SED_1, including the following TLVs:
|
||||
* - MLE Link Metrics Management TLV
|
||||
* - Link Metrics Status Sub-TLV = 0 (Success)
|
||||
*/
|
||||
Log("Step 10: Leader responds to SED_1 with a Link Metrics Management Response.");
|
||||
nexus.AdvanceTime(kStabilizationTime);
|
||||
VerifyOrQuit(sMgmtResponseReceived);
|
||||
VerifyOrQuit(sMgmtStatus == OT_LINK_METRICS_STATUS_SUCCESS);
|
||||
|
||||
/**
|
||||
* Step 11: SED_1
|
||||
* - Description: Harness instructs the device to request a Forward Series Link Metric by sending a Link Metrics
|
||||
* Management Request with the following payload:
|
||||
* - Link Metrics Management TLV
|
||||
* - Forward Probing Registration Sub-TLV
|
||||
* - Type = 3
|
||||
* - Forward Series ID: 11
|
||||
* - Forward Series Flags = 0x04
|
||||
* - Bits 0,1 = 0
|
||||
* - Bit 2 = 1 (MAC Data Request command frames)
|
||||
* - Bits 3-7 = 0
|
||||
* - Concatenation of Link Metric Type ID Flags=0x40
|
||||
* - E= 0x00; L = 0x01
|
||||
* - Metric Enum = 0x00 (count)
|
||||
* - Type/Average Enum = 0x00 (count)
|
||||
* - Pass Criteria: N/A
|
||||
*/
|
||||
Log("Step 11: SED_1 requests Forward Series Link Metric ID 11.");
|
||||
{
|
||||
LinkMetrics::SeriesFlags flags;
|
||||
LinkMetrics::Metrics metrics;
|
||||
|
||||
flags.SetFrom(kSeriesFlagsMacDataRequest);
|
||||
metrics.Clear();
|
||||
metrics.mPduCount = true;
|
||||
|
||||
sMgmtResponseReceived = false;
|
||||
|
||||
SuccessOrQuit(sed1.Get<LinkMetrics::Initiator>().SendMgmtRequestForwardTrackingSeries(
|
||||
leader.Get<Mle::Mle>().GetLinkLocalAddress(), kSeriesId11, flags, &metrics));
|
||||
}
|
||||
nexus.AdvanceTime(kSedPollPeriod);
|
||||
|
||||
/**
|
||||
* Step 12: Leader (DUT)
|
||||
* - Description: Automatically responds to SED_1 with a Link Metrics Management Response.
|
||||
* - Pass Criteria: The DUT MUST unicast Link Metrics Management Response to SED_1, including the following TLVs:
|
||||
* - MLE Link Metrics Management TLV
|
||||
* - Link Metrics Status Sub-TLV = 0 (Success)
|
||||
*/
|
||||
Log("Step 12: Leader responds to SED_1 with a Link Metrics Management Response.");
|
||||
nexus.AdvanceTime(kStabilizationTime);
|
||||
VerifyOrQuit(sMgmtResponseReceived);
|
||||
VerifyOrQuit(sMgmtStatus == OT_LINK_METRICS_STATUS_SUCCESS);
|
||||
|
||||
/**
|
||||
* Step 13: SED_1
|
||||
* - Description: Harness waits for 30 seconds (MAC Data Requests sent every two seconds).
|
||||
* - Pass Criteria: N/A
|
||||
*/
|
||||
Log("Step 13: Wait for 30 seconds.");
|
||||
nexus.AdvanceTime(kWaitTime);
|
||||
|
||||
/**
|
||||
* Step 14: SED_1
|
||||
* - Description: Harness instructs the device to retrieve aggregated Forward Series results by sending a MLE Data
|
||||
* Request message to the DUT with the following payload:
|
||||
* - TLV Request TLV (Link Metrics Report TLV specified)
|
||||
* - Link Metrics Query TLV
|
||||
* - Link Metrics Query ID Sub-TLV
|
||||
* - Query ID = 11 [series configured in step 11]
|
||||
* - Pass Criteria: N/A
|
||||
*/
|
||||
Log("Step 14: SED_1 retrieves aggregated Forward Series ID 11 results.");
|
||||
{
|
||||
sReportReceived = false;
|
||||
|
||||
SuccessOrQuit(sed1.Get<LinkMetrics::Initiator>().Query(leader.Get<Mle::Mle>().GetLinkLocalAddress(),
|
||||
kSeriesId11, nullptr));
|
||||
}
|
||||
nexus.AdvanceTime(kSedPollPeriod);
|
||||
|
||||
/**
|
||||
* Step 15: Leader (DUT)
|
||||
* - Description: Automatically responds to SED_1 with a MLE Data Response.
|
||||
* - Pass Criteria: The DUT MUST unicast MLE Data Response to SED_1, including the following TLVs:
|
||||
* - Link Metrics Report TLV
|
||||
* - Link Metrics Report Sub-TLV
|
||||
* - Metric Type ID Flags
|
||||
* - E = 0x00
|
||||
* - L = 0x01
|
||||
* - Type / Average Enum = 0x00 (count / sum)
|
||||
* - Metric Enum = 0x00 (number of PDUs received)
|
||||
* - Count Value (4 bytes)
|
||||
*/
|
||||
Log("Step 15: Leader responds to SED_1 with a MLE Data Response.");
|
||||
nexus.AdvanceTime(kStabilizationTime);
|
||||
VerifyOrQuit(sReportReceived);
|
||||
VerifyOrQuit(sReportStatus == OT_LINK_METRICS_STATUS_SUCCESS);
|
||||
|
||||
/**
|
||||
* Step 16: SSED_1
|
||||
* - Description: Harness instructs the device to request a Forward Series Link Metric by sending a Link Metrics
|
||||
* Management Request with the following payload:
|
||||
* - MLE Link Metrics Management TLV
|
||||
* - Forward Probing Registration Sub-TLV
|
||||
* - Type = 3
|
||||
* - Forward Series ID: 16
|
||||
* - Forward Series Flags = 0x02
|
||||
* - Bit 0 =0
|
||||
* - Bit 1 = 1 (all Link Layer Data Frames)
|
||||
* - Bits 2-7 = 0
|
||||
* - Concatenation of Link Metric Type ID Flags = 0x0a
|
||||
* - E = 0x00; L = 0x00
|
||||
* - Type/Average Enum = 0x01 - Exponential Moving Avg
|
||||
* - Metric Enum = 0x02 (Link Margin)
|
||||
* - Pass Criteria: N/A
|
||||
*/
|
||||
Log("Step 16: SSED_1 requests Forward Series Link Metric ID 16.");
|
||||
{
|
||||
LinkMetrics::SeriesFlags flags;
|
||||
LinkMetrics::Metrics metrics;
|
||||
|
||||
flags.SetFrom(kSeriesFlagsAllDataFrames);
|
||||
metrics.Clear();
|
||||
metrics.mLinkMargin = true;
|
||||
|
||||
ssed1.Get<LinkMetrics::Initiator>().SetMgmtResponseCallback(HandleMgmtResponse, nullptr);
|
||||
sMgmtResponseReceived = false;
|
||||
|
||||
SuccessOrQuit(ssed1.Get<LinkMetrics::Initiator>().SendMgmtRequestForwardTrackingSeries(
|
||||
leader.Get<Mle::Mle>().GetLinkLocalAddress(), kSeriesId16, flags, &metrics));
|
||||
}
|
||||
nexus.AdvanceTime(kSedPollPeriod);
|
||||
|
||||
/**
|
||||
* Step 17: Leader (DUT)
|
||||
* - Description: Automatically responds with a Link Metrics Management Response.
|
||||
* - Pass Criteria: The DUT MUST unicast Link Metrics Management Response to SSED_1, including the following TLVs:
|
||||
* - MLE Link Metrics Management TLV
|
||||
* - Link Metrics Status Sub-TLV = 0 (Success)
|
||||
*/
|
||||
Log("Step 17: Leader responds to SSED_1 with a Link Metrics Management Response.");
|
||||
nexus.AdvanceTime(kStabilizationTime);
|
||||
VerifyOrQuit(sMgmtResponseReceived);
|
||||
VerifyOrQuit(sMgmtStatus == OT_LINK_METRICS_STATUS_SUCCESS);
|
||||
|
||||
/**
|
||||
* Step 18: SSED_1
|
||||
* - Description: Harness instructs the device to send MAC Data packets every 1 second for 30 seconds.
|
||||
* - Pass Criteria: N/A
|
||||
*/
|
||||
Log("Step 18: SSED_1 sends MAC Data packets every 1 second for 30 seconds.");
|
||||
for (uint32_t i = 0; i < kWaitTime / kSsedDataInterval; i++)
|
||||
{
|
||||
ssed1.SendEchoRequest(leader.Get<Mle::Mle>().GetLinkLocalAddress(), 0);
|
||||
nexus.AdvanceTime(kSsedDataInterval);
|
||||
}
|
||||
|
||||
/**
|
||||
* Step 19: SSED_1
|
||||
* - Description: Harness instructs the device to retrieve aggregated Forward Series results by sending a MLE Data
|
||||
* Request message to the DUT with the following payload:
|
||||
* - TLV Request TLV (Link Metrics Report TLV specified)
|
||||
* - Link Metrics Query TLV
|
||||
* - Link Metrics Query ID Sub-TLV
|
||||
* - Query ID = 16 [same value as set in step 16]
|
||||
* - Pass Criteria: N/A
|
||||
*/
|
||||
Log("Step 19: SSED_1 retrieves aggregated Forward Series ID 16 results.");
|
||||
{
|
||||
ssed1.Get<LinkMetrics::Initiator>().SetReportCallback(HandleReport, nullptr);
|
||||
sReportReceived = false;
|
||||
|
||||
SuccessOrQuit(ssed1.Get<LinkMetrics::Initiator>().Query(leader.Get<Mle::Mle>().GetLinkLocalAddress(),
|
||||
kSeriesId16, nullptr));
|
||||
}
|
||||
nexus.AdvanceTime(kSedPollPeriod);
|
||||
|
||||
/**
|
||||
* Step 20: Leader (DUT)
|
||||
* - Description: Automatically responds with a MLE Data Response.
|
||||
* - Pass Criteria: The DUT MUST reply to SSED_1 with a MLE Data Response with the following:
|
||||
* - Link Metrics Report TLV
|
||||
* - Link Metrics Report Sub-TLV
|
||||
* - Metric Type ID Flags
|
||||
* - E = 0x00
|
||||
* - L = 0x00
|
||||
* - Type / Average Enum = 0x01 (Exponential Moving Avg)
|
||||
* - Metric Enum = 0x02 (Link Margin)
|
||||
* - Value (1 byte)
|
||||
*/
|
||||
Log("Step 20: Leader responds to SSED_1 with a MLE Data Response.");
|
||||
nexus.AdvanceTime(kStabilizationTime);
|
||||
VerifyOrQuit(sReportReceived);
|
||||
VerifyOrQuit(sReportStatus == OT_LINK_METRICS_STATUS_SUCCESS);
|
||||
|
||||
/**
|
||||
* Step 21: SSED_1
|
||||
* - Description: Harness instructs device to clear an ongoing Forward Series by sending a Link Metrics Management
|
||||
* Request with the following payload:
|
||||
* - MLE Link Metrics Management TLV
|
||||
* - Forward Probing Registration Sub-TLV
|
||||
* - Type = 3
|
||||
* - Forward Series ID: = 16 [same value as set in step 16]
|
||||
* - Forward Series Flags = 0x00
|
||||
* - Pass Criteria: N/A
|
||||
*/
|
||||
Log("Step 21: SSED_1 clears Forward Series ID 16.");
|
||||
{
|
||||
LinkMetrics::SeriesFlags flags;
|
||||
|
||||
sMgmtResponseReceived = false;
|
||||
|
||||
flags.SetFrom(kSeriesFlagsClear);
|
||||
SuccessOrQuit(ssed1.Get<LinkMetrics::Initiator>().SendMgmtRequestForwardTrackingSeries(
|
||||
leader.Get<Mle::Mle>().GetLinkLocalAddress(), kSeriesId16, flags, nullptr));
|
||||
}
|
||||
nexus.AdvanceTime(kSedPollPeriod);
|
||||
|
||||
/**
|
||||
* Step 22: Leader (DUT)
|
||||
* - Description: Automatically responds with a Link Metrics Management Response.
|
||||
* - Pass Criteria: The DUT MUST reply to SSED_1 with a Link Metrics Management Response containing the following:
|
||||
* - MLE Link Metrics Management TLV
|
||||
* - Link Metrics Status Sub-TLV = 0 (Success)
|
||||
*/
|
||||
Log("Step 22: Leader responds to SSED_1 with a Link Metrics Management Response.");
|
||||
nexus.AdvanceTime(kStabilizationTime);
|
||||
VerifyOrQuit(sMgmtResponseReceived);
|
||||
VerifyOrQuit(sMgmtStatus == OT_LINK_METRICS_STATUS_SUCCESS);
|
||||
|
||||
/**
|
||||
* Step 23: SSED_1
|
||||
* - Description: Harness instructs the device to retrieve aggregated Forward Series results by sending a MLE Data
|
||||
* Request message to the DUT with the following payload:
|
||||
* - TLV Request TLV (Link Metrics Report TLV specified)
|
||||
* - Link Metrics Query TLV
|
||||
* - Link Metrics Query ID Sub-TLV
|
||||
* - Query ID = 16 [same value as set in step 16]
|
||||
* - This is a negative step
|
||||
* - Pass Criteria: N/A
|
||||
*/
|
||||
Log("Step 23: SSED_1 retrieves aggregated Forward Series ID 16 results (negative step).");
|
||||
{
|
||||
sReportReceived = false;
|
||||
|
||||
SuccessOrQuit(ssed1.Get<LinkMetrics::Initiator>().Query(leader.Get<Mle::Mle>().GetLinkLocalAddress(),
|
||||
kSeriesId16, nullptr));
|
||||
}
|
||||
nexus.AdvanceTime(kSedPollPeriod);
|
||||
|
||||
/**
|
||||
* Step 24: Leader (DUT)
|
||||
* - Description: Automatically responds with a MLE Data Response.
|
||||
* - Pass Criteria: The DUT MUST reply to SSED_1 with a MLE Data Response with the following:
|
||||
* - Link Metrics Report TLV
|
||||
* - Link Metrics Status Sub-TLV
|
||||
* - Status = 3 (Failure - Series ID not recognized)
|
||||
*/
|
||||
Log("Step 24: Leader responds to SSED_1 with a MLE Data Response (Failure).");
|
||||
nexus.AdvanceTime(kStabilizationTime);
|
||||
VerifyOrQuit(sReportReceived);
|
||||
VerifyOrQuit(sReportStatus == OT_LINK_METRICS_STATUS_SERIESID_NOT_RECOGNIZED);
|
||||
|
||||
nexus.SaveTestInfo("test_1_2_LP_7_2_1.json");
|
||||
}
|
||||
|
||||
} // namespace Nexus
|
||||
} // namespace ot
|
||||
|
||||
int main(void)
|
||||
{
|
||||
ot::Nexus::Test1_2_LP_7_2_1();
|
||||
printf("All tests passed\n");
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,475 @@
|
||||
#!/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
|
||||
|
||||
|
||||
def verify(pv):
|
||||
# 7.2.1 Forward Tracking Series
|
||||
#
|
||||
# 7.2.1.1 Topology
|
||||
# - Leader (DUT)
|
||||
# - SED_1
|
||||
# - SSED_1
|
||||
#
|
||||
# 7.2.1.2 Purpose & Definition
|
||||
# The purpose of this test case is to ensure that the DUT can successfully respond to a Forward Series Link Metrics
|
||||
# Request from both a SED & SSED.
|
||||
#
|
||||
# Spec Reference | V1.2 Section
|
||||
# -------------------------|-------------
|
||||
# Forward Tracking Series | 4.11.3.2
|
||||
|
||||
pkts = pv.pkts
|
||||
pv.summary.show()
|
||||
|
||||
LEADER = pv.vars['LEADER']
|
||||
LEADER_RLOC16 = pv.vars['LEADER_RLOC16']
|
||||
SED_1 = pv.vars['SED_1']
|
||||
SED_1_RLOC16 = pv.vars['SED_1_RLOC16']
|
||||
SSED_1 = pv.vars['SSED_1']
|
||||
SSED_1_RLOC16 = pv.vars['SSED_1_RLOC16']
|
||||
|
||||
SERIES_ID_4 = 4
|
||||
SERIES_ID_11 = 11
|
||||
SERIES_ID_16 = 16
|
||||
|
||||
FORWARD_SERIES_FLAGS_MAC_DATA_REQUEST = 0x04
|
||||
FORWARD_SERIES_FLAGS_ALL_DATA_FRAMES = 0x02
|
||||
FORWARD_SERIES_FLAGS_CLEAR = 0x00
|
||||
|
||||
# Step 0: SED_1
|
||||
# - Description: Preconditions: SED_1 data poll rate set to 2 seconds.
|
||||
# - Pass Criteria: N/A
|
||||
print("Step 0: SED_1 data poll rate set to 2 seconds.")
|
||||
|
||||
# Step 1: All
|
||||
# - Description: Topology formation: DUT, SED_1, SSED_1.
|
||||
# - Pass Criteria: N/A
|
||||
print("Step 1: Topology formation: DUT, SED_1, SSED_1.")
|
||||
|
||||
# Step 2: SED_1, SSED_1
|
||||
# - Description: Each device automatically attaches to the DUT.
|
||||
# - Pass Criteria: N/A
|
||||
print("Step 2: Each device automatically attaches to the DUT.")
|
||||
|
||||
# Step 3: SED_1, SSED_1
|
||||
# - Description: Harness verifies connectivity by instructing each device to send an ICMPv6 Echo Request to the DUT.
|
||||
# - Pass Criteria:
|
||||
# - 3.1: The DUT MUST send an ICMPv6 Echo Reply to SED_1.
|
||||
# - 3.2: The DUT MUST send an ICMPv6 Echo Reply to SSED_1.
|
||||
print("Step 3: Harness verifies connectivity.")
|
||||
_pkt = pkts.filter_ping_request().\
|
||||
filter_wpan_src64(SED_1).\
|
||||
filter_wpan_dst64(LEADER).\
|
||||
must_next()
|
||||
pkts.filter_ping_reply(identifier=_pkt.icmpv6.echo.identifier).\
|
||||
filter_wpan_src64(LEADER).\
|
||||
filter_wpan_dst64(SED_1).\
|
||||
must_next()
|
||||
|
||||
_pkt = pkts.filter_ping_request().\
|
||||
filter_wpan_src64(SSED_1).\
|
||||
filter_wpan_dst64(LEADER).\
|
||||
must_next()
|
||||
pkts.filter_ping_reply(identifier=_pkt.icmpv6.echo.identifier).\
|
||||
filter_wpan_src64(LEADER).\
|
||||
filter_wpan_dst64(SSED_1).\
|
||||
must_next()
|
||||
|
||||
# Step 4: SED_1
|
||||
# - Description: Harness instructs the device to request a Forward Series Link Metric by sending a Link Metrics
|
||||
# Management Request to the DUT with the following payload:
|
||||
# - MLE Link Metrics Management TLV
|
||||
# - Forward Probing Registration Sub-TLV
|
||||
# - Type = 3
|
||||
# - Forward Series ID = 4
|
||||
# - Forward Series Flags = 0x04
|
||||
# - Bits 0-1 = 0
|
||||
# - Bit 2 = 1 (MAC Data Request command frames)
|
||||
# - Bits 3-7 = 0
|
||||
# - Concatenation of Link Metric Type ID Flags=0x40
|
||||
# - E = 0x00; L = 0x01
|
||||
# - Type/Average Enum = 0x00 (count)
|
||||
# - Metric Enum = 0x00 (count)
|
||||
# - Pass Criteria: N/A
|
||||
print("Step 4: SED_1 requests Forward Series Link Metric ID 4.")
|
||||
pkts.filter_wpan_src64(SED_1).\
|
||||
filter_wpan_dst64(LEADER).\
|
||||
filter_mle_cmd(consts.MLE_LINK_METRICS_MANAGEMENT_REQUEST).\
|
||||
filter(lambda p: consts.LINK_METRICS_MANAGEMENT_TLV in p.mle.tlv.type).\
|
||||
filter(lambda p: consts.LM_FORWARD_PROBING_REGISTRATION_SUB_TLV in p.mle.tlv.link_sub_tlv).\
|
||||
filter(lambda p: SERIES_ID_4 in p.mle.tlv.link_forward_series).\
|
||||
filter(lambda p: p.mle.tlv.link_forward_series_flags == FORWARD_SERIES_FLAGS_MAC_DATA_REQUEST).\
|
||||
filter(lambda p: consts.LINK_METRICS_TYPE_AVERAGE_ENUM_COUNT in p.mle.tlv.metric_type_id_flags.type).\
|
||||
filter(lambda p: consts.LINK_METRICS_METRIC_TYPE_ENUM_PDU_COUNT in p.mle.tlv.metric_type_id_flags.metric).\
|
||||
filter(lambda p: 1 in p.mle.tlv.metric_type_id_flags.l).\
|
||||
must_next()
|
||||
|
||||
# Step 5: Leader (DUT)
|
||||
# - Description: Automatically responds to SED_1 with a Link Metrics Management Response.
|
||||
# - Pass Criteria: The DUT MUST unicast Link Metrics Management Response to SED_1, including the following TLVs:
|
||||
# - MLE Link Metrics Management TLV
|
||||
# - Link Metrics Status Sub-TLV = 0 (Success)
|
||||
print("Step 5: Leader responds to SED_1 with a Link Metrics Management Response.")
|
||||
pkts.filter_wpan_src64(LEADER).\
|
||||
filter_wpan_dst64(SED_1).\
|
||||
filter_mle_cmd(consts.MLE_LINK_METRICS_MANAGEMENT_RESPONSE).\
|
||||
filter(lambda p: p.mle.tlv.link_status_sub_tlv == consts.LINK_METRICS_STATUS_SUCCESS).\
|
||||
must_next()
|
||||
|
||||
# Step 6: SED_1
|
||||
# - Description: Harness waits for 30 seconds (MAC Data Requests sent every 2 seconds).
|
||||
# - Pass Criteria: N/A
|
||||
print("Step 6: Wait for 30 seconds.")
|
||||
# Verify that SED_1 is actually polling
|
||||
pkts.copy().\
|
||||
filter(lambda p: p.wpan.src64 == SED_1 or p.wpan.src16 == SED_1_RLOC16).\
|
||||
filter(lambda p: p.wpan.dst64 == LEADER or p.wpan.dst16 == LEADER_RLOC16).\
|
||||
filter(lambda p: p.wpan.frame_type == consts.WPAN_CMD).\
|
||||
must_next()
|
||||
|
||||
# Step 7: SED_1
|
||||
# - Description: Harness instructs the device to retrieve aggregated Forward Series results by sending a MLE Data
|
||||
# Request message to the DUT with the following payload:
|
||||
# - TLV Request TLV (Link Metrics Report TLV specified)
|
||||
# - Link Metrics Query TLV
|
||||
# - Link Metrics Query ID Sub-TLV
|
||||
# - Query ID = 4 [series configured in step 4]
|
||||
# - Pass Criteria: N/A
|
||||
print("Step 7: SED_1 retrieves aggregated Forward Series ID 4 results.")
|
||||
pkts.filter_wpan_src64(SED_1).\
|
||||
filter_wpan_dst64(LEADER).\
|
||||
filter_mle_cmd(consts.MLE_DATA_REQUEST).\
|
||||
filter(lambda p: consts.TLV_REQUEST_TLV in p.mle.tlv.type).\
|
||||
filter(lambda p: p.mle.tlv.query_id == SERIES_ID_4).\
|
||||
must_next()
|
||||
|
||||
# Step 8: Leader (DUT)
|
||||
# - Description: Automatically responds to SED_1 with a MLE Data Response.
|
||||
# - Pass Criteria: The DUT MUST unicast MLE Data Response to SED_1, including the following TLVs:
|
||||
# - Link Metrics Report TLV
|
||||
# - Link Metrics Report Sub-TLV
|
||||
# - Metric Type ID Flags
|
||||
# - E = 0x00
|
||||
# - L = 0x01
|
||||
# - Type / Average Enum = 0x00 (count/sum)
|
||||
# - Metric Enum = 0x00 (number of PDUs received)
|
||||
# - Count Value (4 bytes)
|
||||
print("Step 8: Leader responds to SED_1 with a MLE Data Response.")
|
||||
pkts.filter_wpan_src64(LEADER).\
|
||||
filter_wpan_dst64(SED_1).\
|
||||
filter_mle_cmd(consts.MLE_DATA_RESPONSE).\
|
||||
filter(lambda p: consts.LINK_METRICS_REPORT_TLV in p.mle.tlv.type).\
|
||||
filter(lambda p: consts.LINK_METRICS_TYPE_AVERAGE_ENUM_COUNT in p.mle.tlv.metric_type_id_flags.type).\
|
||||
filter(lambda p: consts.LINK_METRICS_METRIC_TYPE_ENUM_PDU_COUNT in p.mle.tlv.metric_type_id_flags.metric).\
|
||||
filter(lambda p: 1 in p.mle.tlv.metric_type_id_flags.l).\
|
||||
must_next()
|
||||
|
||||
# Step 9: SED_1
|
||||
# - Description: Harness instructs the device to clear the Forward Series Link Metric by sending a Link Metrics
|
||||
# Management Request with the following payload:
|
||||
# - Link Metrics Management Request:
|
||||
# - Link Metrics Management TLV
|
||||
# - Forward Probing Registration Sub-TLV
|
||||
# - Type = 3
|
||||
# - Forward Series ID = 4 [series configured in step 4]
|
||||
# - Forward Series Flags = 0x00
|
||||
# - Bits 0 -7 = 0
|
||||
# - Pass Criteria: N/A
|
||||
print("Step 9: SED_1 clears Forward Series Link Metric ID 4.")
|
||||
pkts.filter_wpan_src64(SED_1).\
|
||||
filter_wpan_dst64(LEADER).\
|
||||
filter_mle_cmd(consts.MLE_LINK_METRICS_MANAGEMENT_REQUEST).\
|
||||
filter(lambda p: consts.LINK_METRICS_MANAGEMENT_TLV in p.mle.tlv.type).\
|
||||
filter(lambda p: consts.LM_FORWARD_PROBING_REGISTRATION_SUB_TLV in p.mle.tlv.link_sub_tlv).\
|
||||
filter(lambda p: SERIES_ID_4 in p.mle.tlv.link_forward_series).\
|
||||
filter(lambda p: p.mle.tlv.link_forward_series_flags == FORWARD_SERIES_FLAGS_CLEAR).\
|
||||
must_next()
|
||||
|
||||
# Step 10: Leader (DUT)
|
||||
# - Description: Automatically responds to SED_1 with a Link Metrics Management Response.
|
||||
# - Pass Criteria: The DUT MUST unicast Link Metrics Management Response to SED_1, including the following TLVs:
|
||||
# - MLE Link Metrics Management TLV
|
||||
# - Link Metrics Status Sub-TLV = 0 (Success)
|
||||
print("Step 10: Leader responds to SED_1 with a Link Metrics Management Response.")
|
||||
pkts.filter_wpan_src64(LEADER).\
|
||||
filter_wpan_dst64(SED_1).\
|
||||
filter_mle_cmd(consts.MLE_LINK_METRICS_MANAGEMENT_RESPONSE).\
|
||||
filter(lambda p: p.mle.tlv.link_status_sub_tlv == consts.LINK_METRICS_STATUS_SUCCESS).\
|
||||
must_next()
|
||||
|
||||
# Step 11: SED_1
|
||||
# - Description: Harness instructs the device to request a Forward Series Link Metric by sending a Link Metrics
|
||||
# Management Request with the following payload:
|
||||
# - MLE Link Metrics Management TLV
|
||||
# - Forward Probing Registration Sub-TLV
|
||||
# - Type = 3
|
||||
# - Forward Series ID: 11
|
||||
# - Forward Series Flags = 0x04
|
||||
# - Bits 0,1 = 0
|
||||
# - Bit 2 = 1 (MAC Data Request command frames)
|
||||
# - Bits 3-7 = 0
|
||||
# - Concatenation of Link Metric Type ID Flags=0x40
|
||||
# - E= 0x00; L = 0x01
|
||||
# - Metric Enum = 0x00 (count)
|
||||
# - Type/Average Enum = 0x00 (count)
|
||||
# - Pass Criteria: N/A
|
||||
print("Step 11: SED_1 requests Forward Series Link Metric ID 11.")
|
||||
pkts.filter_wpan_src64(SED_1).\
|
||||
filter_wpan_dst64(LEADER).\
|
||||
filter_mle_cmd(consts.MLE_LINK_METRICS_MANAGEMENT_REQUEST).\
|
||||
filter(lambda p: consts.LINK_METRICS_MANAGEMENT_TLV in p.mle.tlv.type).\
|
||||
filter(lambda p: consts.LM_FORWARD_PROBING_REGISTRATION_SUB_TLV in p.mle.tlv.link_sub_tlv).\
|
||||
filter(lambda p: SERIES_ID_11 in p.mle.tlv.link_forward_series).\
|
||||
filter(lambda p: p.mle.tlv.link_forward_series_flags == FORWARD_SERIES_FLAGS_MAC_DATA_REQUEST).\
|
||||
filter(lambda p: consts.LINK_METRICS_TYPE_AVERAGE_ENUM_COUNT in p.mle.tlv.metric_type_id_flags.type).\
|
||||
filter(lambda p: consts.LINK_METRICS_METRIC_TYPE_ENUM_PDU_COUNT in p.mle.tlv.metric_type_id_flags.metric).\
|
||||
filter(lambda p: 1 in p.mle.tlv.metric_type_id_flags.l).\
|
||||
must_next()
|
||||
|
||||
# Step 12: Leader (DUT)
|
||||
# - Description: Automatically responds to SED_1 with a Link Metrics Management Response.
|
||||
# - Pass Criteria: The DUT MUST unicast Link Metrics Management Response to SED_1, including the following TLVs:
|
||||
# - MLE Link Metrics Management TLV
|
||||
# - Link Metrics Status Sub-TLV = 0 (Success)
|
||||
print("Step 12: Leader responds to SED_1 with a Link Metrics Management Response.")
|
||||
pkts.filter_wpan_src64(LEADER).\
|
||||
filter_wpan_dst64(SED_1).\
|
||||
filter_mle_cmd(consts.MLE_LINK_METRICS_MANAGEMENT_RESPONSE).\
|
||||
filter(lambda p: p.mle.tlv.link_status_sub_tlv == consts.LINK_METRICS_STATUS_SUCCESS).\
|
||||
must_next()
|
||||
|
||||
# Step 13: SED_1
|
||||
# - Description: Harness waits for 30 seconds (MAC Data Requests sent every two seconds).
|
||||
# - Pass Criteria: N/A
|
||||
print("Step 13: Wait for 30 seconds.")
|
||||
pkts.copy().\
|
||||
filter(lambda p: p.wpan.src64 == SED_1 or p.wpan.src16 == SED_1_RLOC16).\
|
||||
filter(lambda p: p.wpan.dst64 == LEADER or p.wpan.dst16 == LEADER_RLOC16).\
|
||||
filter(lambda p: p.wpan.frame_type == consts.WPAN_CMD).\
|
||||
must_next()
|
||||
|
||||
# Step 14: SED_1
|
||||
# - Description: Harness instructs the device to retrieve aggregated Forward Series results by sending a MLE Data
|
||||
# Request message to the DUT with the following payload:
|
||||
# - TLV Request TLV (Link Metrics Report TLV specified)
|
||||
# - Link Metrics Query TLV
|
||||
# - Link Metrics Query ID Sub-TLV
|
||||
# - Query ID = 11 [series configured in step 11]
|
||||
# - Pass Criteria: N/A
|
||||
print("Step 14: SED_1 retrieves aggregated Forward Series ID 11 results.")
|
||||
pkts.filter_wpan_src64(SED_1).\
|
||||
filter_wpan_dst64(LEADER).\
|
||||
filter_mle_cmd(consts.MLE_DATA_REQUEST).\
|
||||
filter(lambda p: consts.TLV_REQUEST_TLV in p.mle.tlv.type).\
|
||||
filter(lambda p: p.mle.tlv.query_id == SERIES_ID_11).\
|
||||
must_next()
|
||||
|
||||
# Step 15: Leader (DUT)
|
||||
# - Description: Automatically responds to SED_1 with a MLE Data Response.
|
||||
# - Pass Criteria: The DUT MUST unicast MLE Data Response to SED_1, including the following TLVs:
|
||||
# - Link Metrics Report TLV
|
||||
# - Link Metrics Report Sub-TLV
|
||||
# - Metric Type ID Flags
|
||||
# - E = 0x00
|
||||
# - L = 0x01
|
||||
# - Type / Average Enum = 0x00 (count / sum)
|
||||
# - Metric Enum = 0x00 (number of PDUs received)
|
||||
# - Count Value (4 bytes)
|
||||
print("Step 15: Leader responds to SED_1 with a MLE Data Response.")
|
||||
pkts.filter_wpan_src64(LEADER).\
|
||||
filter_wpan_dst64(SED_1).\
|
||||
filter_mle_cmd(consts.MLE_DATA_RESPONSE).\
|
||||
filter(lambda p: consts.LINK_METRICS_REPORT_TLV in p.mle.tlv.type).\
|
||||
filter(lambda p: consts.LINK_METRICS_TYPE_AVERAGE_ENUM_COUNT in p.mle.tlv.metric_type_id_flags.type).\
|
||||
filter(lambda p: consts.LINK_METRICS_METRIC_TYPE_ENUM_PDU_COUNT in p.mle.tlv.metric_type_id_flags.metric).\
|
||||
filter(lambda p: 1 in p.mle.tlv.metric_type_id_flags.l).\
|
||||
must_next()
|
||||
|
||||
# Step 16: SSED_1
|
||||
# - Description: Harness instructs the device to request a Forward Series Link Metric by sending a Link Metrics
|
||||
# Management Request with the following payload:
|
||||
# - MLE Link Metrics Management TLV
|
||||
# - Forward Probing Registration Sub-TLV
|
||||
# - Type = 3
|
||||
# - Forward Series ID: 16
|
||||
# - Forward Series Flags = 0x02
|
||||
# - Bit 0 =0
|
||||
# - Bit 1 = 1 (all Link Layer Data Frames)
|
||||
# - Bits 2-7 = 0
|
||||
# - Concatenation of Link Metric Type ID Flags = 0x0a
|
||||
# - E = 0x00; L = 0x00
|
||||
# - Type/Average Enum = 0x01 - Exponential Moving Avg
|
||||
# - Metric Enum = 0x02 (Link Margin)
|
||||
# - Pass Criteria: N/A
|
||||
print("Step 16: SSED_1 requests Forward Series Link Metric ID 16.")
|
||||
pkts.filter_wpan_src64(SSED_1).\
|
||||
filter_wpan_dst64(LEADER).\
|
||||
filter_mle_cmd(consts.MLE_LINK_METRICS_MANAGEMENT_REQUEST).\
|
||||
filter(lambda p: consts.LINK_METRICS_MANAGEMENT_TLV in p.mle.tlv.type).\
|
||||
filter(lambda p: consts.LM_FORWARD_PROBING_REGISTRATION_SUB_TLV in p.mle.tlv.link_sub_tlv).\
|
||||
filter(lambda p: SERIES_ID_16 in p.mle.tlv.link_forward_series).\
|
||||
filter(lambda p: p.mle.tlv.link_forward_series_flags == FORWARD_SERIES_FLAGS_ALL_DATA_FRAMES).\
|
||||
filter(lambda p: consts.LINK_METRICS_TYPE_AVERAGE_ENUM_EXPONENTIAL in p.mle.tlv.metric_type_id_flags.type).\
|
||||
filter(lambda p: consts.LINK_METRICS_METRIC_TYPE_ENUM_LINK_MARGIN in p.mle.tlv.metric_type_id_flags.metric).\
|
||||
filter(lambda p: 0 in p.mle.tlv.metric_type_id_flags.l).\
|
||||
must_next()
|
||||
|
||||
# Step 17: Leader (DUT)
|
||||
# - Description: Automatically responds with a Link Metrics Management Response.
|
||||
# - Pass Criteria: The DUT MUST unicast Link Metrics Management Response to SSED_1, including the following TLVs:
|
||||
# - MLE Link Metrics Management TLV
|
||||
# - Link Metrics Status Sub-TLV = 0 (Success)
|
||||
print("Step 17: Leader responds to SSED_1 with a Link Metrics Management Response.")
|
||||
pkts.filter_wpan_src64(LEADER).\
|
||||
filter_wpan_dst64(SSED_1).\
|
||||
filter_mle_cmd(consts.MLE_LINK_METRICS_MANAGEMENT_RESPONSE).\
|
||||
filter(lambda p: p.mle.tlv.link_status_sub_tlv == consts.LINK_METRICS_STATUS_SUCCESS).\
|
||||
must_next()
|
||||
|
||||
# Step 18: SSED_1
|
||||
# - Description: Harness instructs the device to send MAC Data packets every 1 second for 30 seconds.
|
||||
# - Pass Criteria: N/A
|
||||
print("Step 18: SSED_1 sends MAC Data packets every 1 second for 30 seconds.")
|
||||
pkts.copy().\
|
||||
filter(lambda p: p.wpan.src64 == SSED_1 or p.wpan.src16 == SSED_1_RLOC16).\
|
||||
filter(lambda p: p.wpan.dst64 == LEADER or p.wpan.dst16 == LEADER_RLOC16).\
|
||||
filter_ping_request().\
|
||||
must_next()
|
||||
|
||||
# Step 19: SSED_1
|
||||
# - Description: Harness instructs the device to retrieve aggregated Forward Series results by sending a MLE Data
|
||||
# Request message to the DUT with the following payload:
|
||||
# - TLV Request TLV (Link Metrics Report TLV specified)
|
||||
# - Link Metrics Query TLV
|
||||
# - Link Metrics Query ID Sub-TLV
|
||||
# - Query ID = 16 [same value as set in step 16]
|
||||
# - Pass Criteria: N/A
|
||||
print("Step 19: SSED_1 retrieves aggregated Forward Series ID 16 results.")
|
||||
pkts.filter_wpan_src64(SSED_1).\
|
||||
filter_wpan_dst64(LEADER).\
|
||||
filter_mle_cmd(consts.MLE_DATA_REQUEST).\
|
||||
filter(lambda p: consts.TLV_REQUEST_TLV in p.mle.tlv.type).\
|
||||
filter(lambda p: p.mle.tlv.query_id == SERIES_ID_16).\
|
||||
must_next()
|
||||
|
||||
# Step 20: Leader (DUT)
|
||||
# - Description: Automatically responds with a MLE Data Response.
|
||||
# - Pass Criteria: The DUT MUST reply to SSED_1 with a MLE Data Response with the following:
|
||||
# - Link Metrics Report TLV
|
||||
# - Link Metrics Report Sub-TLV
|
||||
# - Metric Type ID Flags
|
||||
# - E = 0x00
|
||||
# - L = 0x00
|
||||
# - Type / Average Enum = 0x01 (Exponential Moving Avg)
|
||||
# - Metric Enum = 0x02 (Link Margin)
|
||||
# - Value (1 byte)
|
||||
print("Step 20: Leader responds to SSED_1 with a MLE Data Response.")
|
||||
pkts.filter_wpan_src64(LEADER).\
|
||||
filter_wpan_dst64(SSED_1).\
|
||||
filter_mle_cmd(consts.MLE_DATA_RESPONSE).\
|
||||
filter(lambda p: consts.LINK_METRICS_REPORT_TLV in p.mle.tlv.type).\
|
||||
filter(lambda p: consts.LINK_METRICS_TYPE_AVERAGE_ENUM_EXPONENTIAL in p.mle.tlv.metric_type_id_flags.type).\
|
||||
filter(lambda p: consts.LINK_METRICS_METRIC_TYPE_ENUM_LINK_MARGIN in p.mle.tlv.metric_type_id_flags.metric).\
|
||||
filter(lambda p: 0 in p.mle.tlv.metric_type_id_flags.l).\
|
||||
must_next()
|
||||
|
||||
# Step 21: SSED_1
|
||||
# - Description: Harness instructs device to clear an ongoing Forward Series by sending a Link Metrics Management
|
||||
# Request with the following payload:
|
||||
# - MLE Link Metrics Management TLV
|
||||
# - Forward Probing Registration Sub-TLV
|
||||
# - Type = 3
|
||||
# - Forward Series ID: = 16 [same value as set in step 16]
|
||||
# - Forward Series Flags = 0x00
|
||||
# - Pass Criteria: N/A
|
||||
print("Step 21: SSED_1 clears Forward Series ID 16.")
|
||||
pkts.filter_wpan_src64(SSED_1).\
|
||||
filter_wpan_dst64(LEADER).\
|
||||
filter_mle_cmd(consts.MLE_LINK_METRICS_MANAGEMENT_REQUEST).\
|
||||
filter(lambda p: consts.LINK_METRICS_MANAGEMENT_TLV in p.mle.tlv.type).\
|
||||
filter(lambda p: consts.LM_FORWARD_PROBING_REGISTRATION_SUB_TLV in p.mle.tlv.link_sub_tlv).\
|
||||
filter(lambda p: SERIES_ID_16 in p.mle.tlv.link_forward_series).\
|
||||
filter(lambda p: p.mle.tlv.link_forward_series_flags == FORWARD_SERIES_FLAGS_CLEAR).\
|
||||
must_next()
|
||||
|
||||
# Step 22: Leader (DUT)
|
||||
# - Description: Automatically responds with a Link Metrics Management Response.
|
||||
# - Pass Criteria: The DUT MUST reply to SSED_1 with a Link Metrics Management Response containing the following:
|
||||
# - MLE Link Metrics Management TLV
|
||||
# - Link Metrics Status Sub-TLV = 0 (Success)
|
||||
print("Step 22: Leader responds to SSED_1 with a Link Metrics Management Response.")
|
||||
pkts.filter_wpan_src64(LEADER).\
|
||||
filter_wpan_dst64(SSED_1).\
|
||||
filter_mle_cmd(consts.MLE_LINK_METRICS_MANAGEMENT_RESPONSE).\
|
||||
filter(lambda p: p.mle.tlv.link_status_sub_tlv == consts.LINK_METRICS_STATUS_SUCCESS).\
|
||||
must_next()
|
||||
|
||||
# Step 23: SSED_1
|
||||
# - Description: Harness instructs the device to retrieve aggregated Forward Series results by sending a MLE Data
|
||||
# Request message to the DUT with the following payload:
|
||||
# - TLV Request TLV (Link Metrics Report TLV specified)
|
||||
# - Link Metrics Query TLV
|
||||
# - Link Metrics Query ID Sub-TLV
|
||||
# - Query ID = 16 [same value as set in step 16]
|
||||
# - This is a negative step
|
||||
# - Pass Criteria: N/A
|
||||
print("Step 23: SSED_1 retrieves aggregated Forward Series ID 16 results (negative step).")
|
||||
pkts.filter_wpan_src64(SSED_1).\
|
||||
filter_wpan_dst64(LEADER).\
|
||||
filter_mle_cmd(consts.MLE_DATA_REQUEST).\
|
||||
filter(lambda p: consts.TLV_REQUEST_TLV in p.mle.tlv.type).\
|
||||
filter(lambda p: p.mle.tlv.query_id == SERIES_ID_16).\
|
||||
must_next()
|
||||
|
||||
# Step 24: Leader (DUT)
|
||||
# - Description: Automatically responds with a MLE Data Response.
|
||||
# - Pass Criteria: The DUT MUST reply to SSED_1 with a MLE Data Response with the following:
|
||||
# - Link Metrics Report TLV
|
||||
# - Link Metrics Status Sub-TLV
|
||||
# - Status = 3 (Failure - Series ID not recognized)
|
||||
print("Step 24: Leader responds to SSED_1 with a MLE Data Response (Failure).")
|
||||
pkts.filter_wpan_src64(LEADER).\
|
||||
filter_wpan_dst64(SSED_1).\
|
||||
filter_mle_cmd(consts.MLE_DATA_RESPONSE).\
|
||||
filter(lambda p: p.mle.tlv.link_status_sub_tlv == consts.LINK_METRICS_STATUS_SERIES_ID_NOT_RECOGNIZED).\
|
||||
must_next()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
verify_utils.run_main(verify)
|
||||
@@ -248,6 +248,13 @@ def apply_patches():
|
||||
|
||||
Layer.get_field = patched_get_field
|
||||
|
||||
layer_fields._LAYER_FIELDS['mle.tlv.link_forward_series'] = layer_fields._list(layer_fields._auto)
|
||||
layer_fields._LAYER_FIELDS['mle.tlv.link_forward_series_flags'] = layer_fields._auto
|
||||
layer_fields._LAYER_FIELDS['mle.tlv.link_status_sub_tlv'] = layer_fields._auto
|
||||
layer_fields._LAYER_FIELDS['mle.tlv.query_id'] = layer_fields._auto
|
||||
layer_fields._LAYER_FIELDS['mle.tlv.metric_type_id_flags.type'] = layer_fields._list(layer_fields._hex)
|
||||
layer_fields._LAYER_FIELDS['mle.tlv.metric_type_id_flags.metric'] = layer_fields._list(layer_fields._hex)
|
||||
layer_fields._LAYER_FIELDS['mle.tlv.metric_type_id_flags.l'] = layer_fields._list(layer_fields._hex)
|
||||
layer_fields._LAYER_FIELDS['coap.tlv.tlv_request'] = layer_fields._bytes
|
||||
layer_fields._LAYER_FIELDS['mle.tlv.active_operational_dataset'] = layer_fields._bytes
|
||||
layer_fields._LAYER_FIELDS['mle.tlv.pending_operational_dataset'] = layer_fields._bytes
|
||||
|
||||
Reference in New Issue
Block a user