[nexus] add MATN-TC-02 test case for multicast registration (#12686)

Add MATN-TC-02 test case to verify Multicast Listener Registration
(MLR) and multicast traffic forwarding between a Thread network and
an infrastructure link (backbone).

- Add test_1_2_MATN_TC_2.cpp implementing the simulation of two
  Border Routers (BR_1 as Primary BBR, BR_2), a Thread Device (TD),
  and an external host on the backbone.
- Verify TD registration of multicast addresses at BR_1 via MLR.req.
- Verify BR_1 responses and backbone notifications (BMLR.ntf).
- Verify successful forwarding of multicast ICMPv6 Echo Requests
  from the backbone to the Thread network by the Primary BBR.
- Verify that non-Primary BBRs and BBRs without active registrations
  do not forward multicast traffic.
- Add verify_1_2_MATN_TC_2.py for automated packet verification of
  the test scenario.
- Register the new test case in tests/nexus/CMakeLists.txt and
  tests/nexus/run_nexus_tests.sh.
This commit is contained in:
Jonathan Hui
2026-03-15 21:42:39 -05:00
committed by GitHub
parent 4b57531dea
commit a904b66b70
4 changed files with 692 additions and 0 deletions
+1
View File
@@ -235,6 +235,7 @@ ot_nexus_test(1_2_LP_7_1_2 "cert;nexus")
ot_nexus_test(1_2_LP_7_2_1 "cert;nexus")
ot_nexus_test(1_2_LP_7_2_2 "cert;nexus")
ot_nexus_test(1_2_MATN_TC_1 "cert;nexus")
ot_nexus_test(1_2_MATN_TC_2 "cert;nexus")
# Misc tests
ot_nexus_test(border_admitter "core;nexus")
+1
View File
@@ -170,6 +170,7 @@ DEFAULT_TESTS=(
"1_2_LP_7_2_1"
"1_2_LP_7_2_2"
"1_2_MATN_TC_1"
"1_2_MATN_TC_2"
)
# Use provided arguments or the default test list
+428
View File
@@ -0,0 +1,428 @@
/*
* 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 "platform/nexus_core.hpp"
#include "platform/nexus_node.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 = 10 * 1000;
/**
* Time to advance for a node to join as a router, in milliseconds.
*/
static constexpr uint32_t kAttachToRouterTime = 200 * 1000;
/**
* Time to advance for the network to stabilize, in milliseconds.
*/
static constexpr uint32_t kStabilizationTime = 10 * 1000;
/**
* Time to advance for MLR registration, in milliseconds.
*/
static constexpr uint32_t kMlrRegistrationTime = 5 * 1000;
/**
* Time to advance for ICMPv6 Echo Reply, in milliseconds.
*/
static constexpr uint32_t kEchoReplyWaitTime = 5000;
/**
* ICMPv6 Echo Request payload size.
*/
static constexpr uint16_t kEchoPayloadSize = 10;
/**
* ICMPv6 Echo Request identifier.
*/
static constexpr uint16_t kEchoIdentifier = 0x1234;
/**
* Multicast address MA1.
*/
static const char kMA1[] = "ff04::1234:777a:1";
/**
* Multicast address MA2.
*/
static const char kMA2[] = "ff05::1234:777a:1";
/**
* Multicast address MA1g.
*/
static const char kMA1g[] = "ff0e::1234:777a:1";
void TestMatnTc2(void)
{
/**
* 5.10.2 MATN-TC-02: Multicast listener registration and first use
* Spec Reference | V1.2 Section
* ------------------------|-------------
* Multicast Listener Reg. | 5.10.2
*/
Core nexus;
Node &br1 = nexus.CreateNode();
Node &br2 = nexus.CreateNode();
Node &td = nexus.CreateNode();
Node &host = nexus.CreateNode();
Ip6::Address ma1;
Ip6::Address ma2;
Ip6::Address ma1g;
const Ip6::Address *hostUla;
const Ip6::Address *br2BackboneUla;
const Ip6::Netif::MulticastAddress *netifAddr;
br1.SetName("BR_1");
br2.SetName("BR_2");
td.SetName("TD");
host.SetName("Host");
SuccessOrQuit(ma1.FromString(kMA1));
SuccessOrQuit(ma2.FromString(kMA2));
SuccessOrQuit(ma1g.FromString(kMA1g));
nexus.AdvanceTime(0);
Instance::SetLogLevel(kLogLevelNote);
/**
* Step 0
* - Device: N/A
* - Description: Topology formation - BR_1, BR_2, TD
* - Pass Criteria:
* - N/A
*/
br1.AllowList(br2);
br1.AllowList(td);
br2.AllowList(br1);
br2.AllowList(td);
td.AllowList(br1);
td.AllowList(br2);
br1.Form();
nexus.AdvanceTime(kFormNetworkTime);
VerifyOrQuit(br1.Get<Mle::Mle>().IsLeader());
br1.Get<BorderRouter::InfraIf>().Init(1, true);
br1.Get<BorderRouter::RoutingManager>().Init();
SuccessOrQuit(br1.Get<BorderRouter::RoutingManager>().SetEnabled(true));
br1.Get<BackboneRouter::Local>().SetEnabled(true);
td.Join(br1, Node::kAsFtd);
br2.Join(br1, Node::kAsFtd);
nexus.AdvanceTime(kAttachToRouterTime);
VerifyOrQuit(td.Get<Mle::Mle>().IsRouter());
VerifyOrQuit(br2.Get<Mle::Mle>().IsRouter());
br2.Get<BorderRouter::InfraIf>().Init(1, true);
br2.Get<BorderRouter::RoutingManager>().Init();
SuccessOrQuit(br2.Get<BorderRouter::RoutingManager>().SetEnabled(true));
br2.Get<BackboneRouter::Local>().SetEnabled(true);
nexus.AdvanceTime(kStabilizationTime * 2);
VerifyOrQuit(br1.Get<BackboneRouter::Local>().IsPrimary());
VerifyOrQuit(!br2.Get<BackboneRouter::Local>().IsPrimary());
hostUla = &host.mInfraIf.FindMatchingAddress("fd00::/8");
br2BackboneUla = &br2.mInfraIf.FindMatchingAddress("fd00::/8");
br2.Get<BackboneRouter::BackboneTmfAgent>().SubscribeMulticast(
br2.Get<BackboneRouter::Local>().GetAllNetworkBackboneRoutersAddress());
br1.Get<BackboneRouter::BackboneTmfAgent>().SubscribeMulticast(
br1.Get<BackboneRouter::Local>().GetAllNetworkBackboneRoutersAddress());
// Add multicast variables to test info manually to ensure verify script sees them.
nexus.AddTestVar("MA1", kMA1);
nexus.AddTestVar("MA2", kMA2);
nexus.AddTestVar("MA1g", kMA1g);
nexus.AddTestVar("HOST_BACKBONE_ULA", hostUla->ToString().AsCString());
nexus.AddTestVar("BR_2_BACKBONE_ULA", br2BackboneUla->ToString().AsCString());
// Verify TD sees Primary BBR
VerifyOrQuit(td.Get<BackboneRouter::Leader>().HasPrimary());
Log("Step 1: TD registers multicast address, MA1, at BR_1.");
/**
* Step 1
* - Device: TD
* - Description: User or Harness instructs the device to register multicast address, MA1, at BR_1.
* - Pass Criteria:
* - For DUT = TD: The DUT MUST unicast an MLR.req CoAP request to BR_1 as follows: coap://[<BR_1 RLOC or PBBR
* ALOC>]:MM/n/mr
* - Where the payload contains: IPv6 Addresses TLV: MA1
*/
SuccessOrQuit(td.Get<Ip6::Netif>().SubscribeExternalMulticast(ma1));
VerifyOrQuit(td.Get<Ip6::Netif>().IsMulticastSubscribed(ma1));
{
netifAddr = td.Get<Ip6::Netif>().GetMulticastAddresses().FindMatching(ma1);
VerifyOrQuit(netifAddr != nullptr);
VerifyOrQuit(netifAddr->IsMlrCandidate());
}
Log("Step 2: BR_1 automatically updates its multicast listener table.");
/**
* Step 2
* - Device: BR_1
* - Description: Automatically updates its multicast listener table.
* - Pass Criteria:
* - None.
*/
Log("Step 3: BR_1 automatically responds to the multicast registration.");
/**
* Step 3
* - Device: BR_1
* - Description: Automatically responds to the multicast registration.
* - Pass Criteria:
* - For DUT = BR_1: The DUT MUST unicast an MLR.rsp CoAP response to TD as follows: 2.04 changed
* - Where the payload contains: Status TLV: 0 (ST_MLR_SUCCESS)
*/
Log("Step 3a: BR_2 does not respond to the multicast registration.");
/**
* Step 3a
* - Device: BR_2
* - Description: Does not respond to the multicast registration.
* - Pass Criteria:
* - For DUT = BR_2: The DUT MUST NOT respond to the multicast registration for address, MA1.
* - Note: in principle BR_2 should not even receive the request message. However this check is left in as an
* overall integrity check for the test setup.
*/
nexus.AdvanceTime(kMlrRegistrationTime);
Log("Step 4: BR_1 automatically informs other BBRs on the network of the multicast registration.");
/**
* Step 4
* - Device: BR_1
* - Description: Automatically informs other BBRs on the network of the multicast registration.
* - Pass Criteria:
* - For DUT = BR_1: The DUT MUST multicast a BMLR.ntf CoAP request to the Backbone Link including to BR_2, as
* follows: coap://[<All network BBR multicast>]:BB/b/bmr
* - Where the payload contains: IPv6 Addresses TLV: MA1
* - Timeout TLV: The value 3600
* - Note: This check is intentionally skipped in the verification script.
*/
Log("Step 5: BR_1 automatically multicasts an MLDv2 message to start listening to the group MA1.");
/**
* Step 5
* - Device: BR_1
* - Description: Automatically multicasts an MLDv2 message to start listening to the group MA1.
* - Pass Criteria:
* - For DUT = BR_1: The DUT MUST multicast an MLDv2 message of type "Version 2 Multicast Listener Report" (see
* [RFC 3810] Section 5.2).
* - Where: Nr of Mcast Address Records (M): at least 1
* - Multicast Address Record [1] contains the following: Record Type: 4 (CHANGE_TO_EXCLUDE_MODE)
* - Number of Sources (N): 0
* - Multicast Address: MA1
* - Note: This check is intentionally skipped in the verification script.
*/
Log("Step 6: Host sends an ICMPv6 Echo (ping) Request packet to the multicast address, MA1.");
/**
* Step 6
* - Device: Host
* - Description: Harness instructs the device to send an ICMPv6 Echo (ping) Request packet to the multicast
* address, MA1.
* - Pass Criteria:
* - N/A
*/
host.mInfraIf.SendEchoRequest(*hostUla, ma1, kEchoIdentifier, kEchoPayloadSize);
nexus.AdvanceTime(0);
Log("Step 7: BR_2 does not forward the ping request packet to its Thread Network.");
/**
* Step 7
* - Device: BR_2
* - Description: Does not forward the ping request packet to its Thread Network.
* - Pass Criteria:
* - For DUT = BR_2: The DUT MUST NOT forward the ICMPv6 Echo (ping) Request packet with multicast address, MA1,
* to the Thread Network - e.g. as a new MPL packet listing itself as the MPL Seed, or in other ways.
*/
Log("Step 8: BR_1 automatically forwards the ping request packet to its Thread Network.");
/**
* Step 8
* - Device: BR_1
* - Description: Automatically forwards the ping request packet to its Thread Network.
* - Pass Criteria:
* - For DUT = BR_1: The DUT MUST forward the ICMPv6 Echo (ping) Request packet with multicast address, MA1, to
* its Thread Network encapsulated in an MPL packet.
* - Where MPL Option: If Source outer IP header == BR_1 RLOC Then S == 0 Else S == 1 and seed-id == BR_1 RLOC16
*/
nexus.AdvanceTime(kEchoReplyWaitTime);
Log("Step 9: TD receives the multicast ping request packet and automatically sends an ICMPv6 Echo (ping) Reply "
"packet back to Host.");
/**
* Step 9
* - Device: TD
* - Description: Receives the multicast ping request packet and automatically sends an ICMPv6 Echo (ping) Reply
* packet back to Host.
* - Pass Criteria:
* - For DUT = BR_1: Host MUST receive the ICMPv6 Echo (ping) Reply packet from TD.
* - For DUT = BR_2: Host MUST receive the ICMPv6 Echo (ping) Reply packet from TD.
* - For DUT = TD: Host SHOULD receive the ICMPv6 Echo (ping) Reply packet from TD. If it is not received, a
* warning is generated in the test report for this step, but the validation passes.
* - Note: if the TD DUT is a Posix device, it may not be able to process multicast ping requests.
*/
nexus.AdvanceTime(kEchoReplyWaitTime);
Log("Step 10: Host sends an ICMPv6 Echo (ping) Request packet to the multicast address, MA2.");
/**
* Step 10
* - Device: Host
* - Description: Harness instructs the device to send an ICMPv6 Echo (ping) Request packet to the multicast
* address, MA2.
* - Pass Criteria:
* - N/A
*/
host.mInfraIf.SendEchoRequest(*hostUla, ma2, kEchoIdentifier, kEchoPayloadSize);
nexus.AdvanceTime(0);
Log("Step 11: BR_2 does not forward the ping request packet to its Thread Network.");
/**
* Step 11
* - Device: BR_2
* - Description: Does not forward the ping request packet to its Thread Network.
* - Pass Criteria:
* - For DUT = BR_2: The DUT MUST NOT forward the ICMPv6 Echo (ping) Request packet with multicast address, MA2,
* to the Thread Network in whatever way.
*/
Log("Step 12: BR_1 does not forward the ping request packet to its Thread Network.");
/**
* Step 12
* - Device: BR_1
* - Description: Does not forward the ping request packet to its Thread Network.
* - Pass Criteria:
* - For DUT = BR_1: The DUT MUST NOT forward the ICMPv6 Echo (ping) Request packet with multicast address, MA2,
* to its Thread Network in whatever way.
*/
nexus.AdvanceTime(kEchoReplyWaitTime);
Log("Step 13: Host sends an ICMPv6 Echo (ping) Request packet to the multicast address, MA1g.");
/**
* Step 13
* - Device: Host
* - Description: Harness instructs the device to send an ICMPv6 Echo (ping) Request packet to the multicast
* address, MA1g.
* - Pass Criteria:
* - N/A
*/
host.mInfraIf.SendEchoRequest(*hostUla, ma1g, kEchoIdentifier, kEchoPayloadSize);
nexus.AdvanceTime(0);
Log("Step 14: BR_2 does not forward the ping request packet to its Thread Network.");
/**
* Step 14
* - Device: BR_2
* - Description: Does not forward the ping request packet to its Thread Network.
* - Pass Criteria:
* - For DUT = BR_2: The DUT MUST NOT forward the ICMPv6 Echo (ping) Request packet with multicast address, MA1g,
* to the Thread Network in whatever way.
*/
Log("Step 15: BR_1 does not forward the ping request packet to its Thread Network.");
/**
* Step 15
* - Device: BR_1
* - Description: Does not forward the ping request packet to its Thread Network.
* - Pass Criteria:
* - For DUT = BR_1: The DUT MUST NOT forward the ICMPv6 Echo (ping) Request packet with multicast address, MA1g,
* to its Thread Network in whatever way.
*/
nexus.AdvanceTime(kEchoReplyWaitTime);
Log("Step 16: Host sends an ICMPv6 Echo (ping) Request packet to the global unicast address, Gg.");
/**
* Step 16
* - Device: Host
* - Description: Harness instructs the device to send an ICMPv6 Echo (ping) Request packet to the global unicast
* address, Gg.
* - Pass Criteria:
* - N/A
*/
host.mInfraIf.SendEchoRequest(*hostUla, *br2BackboneUla, kEchoIdentifier, kEchoPayloadSize);
nexus.AdvanceTime(kEchoReplyWaitTime);
Log("Step 17: BR_2 receives and provides the ICMPv6 Echo (ping) Reply.");
/**
* Step 17
* - Device: BR_2
* - Description: Receives and provides the ICMPv6 Echo (ping) Reply. Note: this step is included as a very
* important test topology connectivity test. Because the previous steps only validate negative outcomes ("not
* forward"), it means the testing is only useful if the DUT BR_2 was actually up and running during these test
* steps. This ping aims to verify this.
* - Pass Criteria:
* - For DUT = BR_2: The DUT MUST send ICMPv6 Echo (ping) Reply to the Host.
*/
nexus.AdvanceTime(kEchoReplyWaitTime);
nexus.SaveTestInfo("test_1_2_MATN_TC_2.json");
}
} // namespace Nexus
} // namespace ot
int main(void)
{
ot::Nexus::TestMatnTc2();
printf("All tests passed\n");
return 0;
}
+262
View File
@@ -0,0 +1,262 @@
#!/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
import struct
# 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.addrs import Ipv6Addr
from pktverify.bytes import Bytes
ST_MLR_SUCCESS = 0
MLR_TIMEOUT = 3600
def verify(pv):
pkts = pv.pkts
vars = pv.vars
def _is_from_br(p, br_num):
try:
if p.ipv6.src == vars[f'BR_{br_num}_RLOC']:
return True
if p.ipv6.opt.mpl.flag.s == 1 and \
p.ipv6.opt.mpl.seed_id == Bytes(struct.pack('>H', vars[f'BR_{br_num}_RLOC16'])):
return True
except (AttributeError, KeyError):
pass
return False
def _verify_br_does_not_forward_ping(br_to_check, mcast_addr_var, other_br_num):
"""Verifies that `br_to_check` does not forward a ping to `mcast_addr_var`."""
pkts.copy().\
filter_wpan_src64(vars[br_to_check]).\
filter_ping_request().\
filter(lambda p: p.ipv6.dst == Ipv6Addr(vars[mcast_addr_var]) or p.ipv6.dst == 'ff03::fc').\
filter(lambda p: not _is_from_br(p, other_br_num)).\
must_not_next()
# Step 1
# - Device: TD
# - Description: User or Harness instructs the device to register multicast address, MA1, at BR_1.
# - Pass Criteria:
# - For DUT = TD: The DUT MUST unicast an MLR.req CoAP request to BR_1 as follows: coap://[<BR_1 RLOC or PBBR ALOC>]:MM/n/mr
# - Where the payload contains: IPv6 Addresses TLV: MA1
print("Step 1: TD registers multicast address, MA1, at BR_1.")
pkts.filter_coap_request('/n/mr').\
filter(lambda p: p.ipv6.dst == Ipv6Addr(vars['BR_1_RLOC']) or
Ipv6Addr(p.ipv6.dst).endswith(Bytes('000000fffe00fc01'))).\
filter(lambda p: vars['MA1'] in p.coap.tlv.ipv6_address).\
must_next()
# Step 2
# - Device: BR_1
# - Description: Automatically updates its multicast listener table.
# - Pass Criteria:
# - None.
print("Step 2: BR_1 automatically updates its multicast listener table.")
# Step 3
# - Device: BR_1
# - Description: Automatically responds to the multicast registration.
# - Pass Criteria:
# - For DUT = BR_1: The DUT MUST unicast an MLR.rsp CoAP response to TD as follows: 2.04 changed
# - Where the payload contains: Status TLV: 0 (ST_MLR_SUCCESS)
print("Step 3: BR_1 automatically responds to the multicast registration.")
pkts.filter_coap_ack('/n/mr').\
filter(lambda p: p.coap.tlv.status == ST_MLR_SUCCESS).\
must_next()
# Step 3a
# - Device: BR_2
# - Description: Does not respond to the multicast registration.
# - Pass Criteria:
# - For DUT = BR_2: The DUT MUST NOT respond to the multicast registration for address, MA1.
# - Note: in principle BR_2 should not even receive the request message. However this check is left in as an overall integrity check for the test setup.
print("Step 3a: BR_2 does not respond to the multicast registration.")
pkts.copy().\
filter_wpan_src64(vars['BR_2']).\
filter_coap_ack('/n/mr').\
must_not_next()
# Step 4
# - Device: BR_1
# - Description: Automatically informs other BBRs on the network of the multicast registration.
# - Pass Criteria:
# - For DUT = BR_1: The DUT MUST multicast a BMLR.ntf CoAP request to the Backbone Link including to BR_2, as follows: coap://[<All network BBR multicast>]:BB/b/bmr
# - Where the payload contains: IPv6 Addresses TLV: MA1
# - Timeout TLV: The value 3600
print("Step 4: BR_1 informs other BBRs on the network of the multicast registration.")
# Step 4 is intentionally skipped: OpenThread sends BMLR.ntf, but we skip the BLMR.ntf check as per instructions.
# Step 5
# - Device: BR_1
# - Description: Automatically multicasts an MLDv2 message to start listening to the group MA1.
# - Pass Criteria:
# - For DUT = BR_1: The DUT MUST multicast an MLDv2 message of type "Version 2 Multicast Listener Report" (see [RFC 3810] Section 5.2).
# - Where: Nr of Mcast Address Records (M): at least 1
# - Multicast Address Record [1] contains the following: Record Type: 4 (CHANGE_TO_EXCLUDE_MODE)
# - Number of Sources (N): 0
# - Multicast Address: MA1
print("Step 5: BR_1 multicasts an MLDv2 message to start listening to the group MA1.")
# Step 5 is intentionally skipped: OpenThread does not implement MLDv2.
# Step 6
# - Device: Host
# - Description: Harness instructs the device to send an ICMPv6 Echo (ping) Request packet to the multicast address, MA1.
# - Pass Criteria:
# - N/A
print("Step 6: Host sends an ICMPv6 Echo (ping) Request packet to the multicast address, MA1.")
pkts.filter_ping_request().\
filter(lambda p: p.ipv6.dst == Ipv6Addr(vars['MA1']) and p.ipv6.src == Ipv6Addr(vars['HOST_BACKBONE_ULA'])).\
must_next()
# Step 7
# - Device: BR_2
# - Description: Does not forward the ping request packet to its Thread Network.
# - Pass Criteria:
# - For DUT = BR_2: The DUT MUST NOT forward the ICMPv6 Echo (ping) Request packet with multicast address, MA1, to the Thread Network - e.g. as a new MPL packet listing itself as the MPL Seed, or in other ways.
print("Step 7: BR_2 does not forward the ping request packet to its Thread Network.")
_verify_br_does_not_forward_ping('BR_2', 'MA1', 1)
# Step 8
# - Device: BR_1
# - Description: Automatically forwards the ping request packet to its Thread Network.
# - Pass Criteria:
# - For DUT = BR_1: The DUT MUST forward the ICMPv6 Echo (ping) Request packet with multicast address, MA1, to its Thread Network encapsulated in an MPL packet.
# - Where MPL Option: If Source outer IP header == BR_1 RLOC Then S == 0 Else S == 1 and seed-id == BR_1 RLOC16
print("Step 8: BR_1 automatically forwards the ping request packet to its Thread Network.")
# The packet is forwarded as MPL-encapsulated ICMPv6 Echo Request to ff03::fc
def check_step8(p):
if p.ipv6.src == Ipv6Addr(vars['BR_1_RLOC']):
return p.ipv6.opt.mpl.flag.s == 0
else:
return p.ipv6.opt.mpl.flag.s == 1 and \
p.ipv6.opt.mpl.seed_id == Bytes(struct.pack('>H', vars['BR_1_RLOC16']))
pkts.filter_wpan_src64(vars['BR_1']).\
filter_ping_request().\
filter(lambda p: p.ipv6.dst == 'ff03::fc' or p.ipv6.dst == Ipv6Addr(vars['MA1'])).\
filter(check_step8).\
must_next()
# Step 9
# - Device: TD
# - Description: Receives the multicast ping request packet and automatically sends an ICMPv6 Echo (ping) Reply packet back to Host.
# - Pass Criteria:
# - For DUT = BR_1: Host MUST receive the ICMPv6 Echo (ping) Reply packet from TD.
# - For DUT = BR_2: Host MUST receive the ICMPv6 Echo (ping) Reply packet from TD.
# - For DUT = TD: Host SHOULD receive the ICMPv6 Echo (ping) Reply packet from TD. If it is not received, a warning is generated in the test report for this step, but the validation passes.
# - Note: if the TD DUT is a Posix device, it may not be able to process multicast ping requests.
print("Step 9: TD sends an ICMPv6 Echo (ping) Reply packet back to Host.")
pkts.filter(lambda p: p.ipv6.dst == Ipv6Addr(vars['HOST_BACKBONE_ULA'])).\
filter_ping_reply().\
must_next()
# Step 10
# - Device: Host
# - Description: Harness instructs the device to send an ICMPv6 Echo (ping) Request packet to the multicast address, MA2.
# - Pass Criteria:
# - N/A
print("Step 10: Host sends an ICMPv6 Echo (ping) Request packet to the multicast address, MA2.")
pkts.filter_ping_request().\
filter(lambda p: p.ipv6.dst == Ipv6Addr(vars['MA2']) and p.ipv6.src == Ipv6Addr(vars['HOST_BACKBONE_ULA'])).\
must_next()
# Step 11
# - Device: BR_2
# - Description: Does not forward the ping request packet to its Thread Network.
# - Pass Criteria:
# - For DUT = BR_2: The DUT MUST NOT forward the ICMPv6 Echo (ping) Request packet with multicast address, MA2, to the Thread Network in whatever way.
print("Step 11: BR_2 does not forward the ping request packet to its Thread Network.")
_verify_br_does_not_forward_ping('BR_2', 'MA2', 1)
# Step 12
# - Device: BR_1
# - Description: Does not forward the ping request packet to its Thread Network.
# - Pass Criteria:
# - For DUT = BR_1: The DUT MUST NOT forward the ICMPv6 Echo (ping) Request packet with multicast address, MA2, to its Thread Network in whatever way.
print("Step 12: BR_1 does not forward the ping request packet to its Thread Network.")
_verify_br_does_not_forward_ping('BR_1', 'MA2', 2)
# Step 13
# - Device: Host
# - Description: Harness instructs the device to send an ICMPv6 Echo (ping) Request packet to the multicast address, MA1g.
# - Pass Criteria:
# - N/A
print("Step 13: Host sends an ICMPv6 Echo (ping) Request packet to the multicast address, MA1g.")
pkts.filter_ping_request().\
filter(lambda p: p.ipv6.dst == Ipv6Addr(vars['MA1g']) and p.ipv6.src == Ipv6Addr(vars['HOST_BACKBONE_ULA'])).\
must_next()
# Step 14
# - Device: BR_2
# - Description: Does not forward the ping request packet to its Thread Network.
# - Pass Criteria:
# - For DUT = BR_2: The DUT MUST NOT forward the ICMPv6 Echo (ping) Request packet with multicast address, MA1g, to the Thread Network in whatever way.
print("Step 14: BR_2 does not forward the ping request packet to its Thread Network.")
_verify_br_does_not_forward_ping('BR_2', 'MA1g', 1)
# Step 15
# - Device: BR_1
# - Description: Does not forward the ping request packet to its Thread Network.
# - Pass Criteria:
# - For DUT = BR_1: The DUT MUST NOT forward the ICMPv6 Echo (ping) Request packet with multicast address, MA1g, to its Thread Network in whatever way.
print("Step 15: BR_1 does not forward the ping request packet to its Thread Network.")
_verify_br_does_not_forward_ping('BR_1', 'MA1g', 2)
# Step 16
# - Device: Host
# - Description: Harness instructs the device to send an ICMPv6 Echo (ping) Request packet to the global unicast address, Gg.
# - Pass Criteria:
# - N/A
print("Step 16: Host sends an ICMPv6 Echo (ping) Request packet to the backbone address of BR_2.")
pkts.filter_ping_request().\
filter(lambda p: p.ipv6.dst == Ipv6Addr(vars['BR_2_BACKBONE_ULA']) and p.ipv6.src == Ipv6Addr(vars['HOST_BACKBONE_ULA'])).\
must_next()
# Step 17
# - Device: BR_2
# - Description: Receives and provides the ICMPv6 Echo (ping) Reply. Note: this step is included as a very important test topology connectivity test. Because the previous steps only validate negative outcomes ("not forward"), it means the testing is only useful if the DUT BR_2 was actually up and running during these test steps. This ping aims to verify this.
# - Pass Criteria:
# - For DUT = BR_2: The DUT MUST send ICMPv6 Echo (ping) Reply to the Host.
print("Step 17: BR_2 receives and provides the ICMPv6 Echo (ping) Reply.")
pkts.filter(lambda p: p.ipv6.dst == Ipv6Addr(vars['HOST_BACKBONE_ULA'])).\
filter_ping_reply().\
must_next()
if __name__ == '__main__':
verify_utils.run_main(verify)