2412 Commits

Author SHA1 Message Date
Abtin Keshavarzian 2a120a9ddf [nexus] remove redundant mInfraIf initializations (#12851)
This commit removes redundant calls to `mInfraIf.Init()` and
`mInfraIf.AddAddress()` from various Nexus test cases.

The infrastructure interface (`mInfraIf`) is automatically initialized
and assigned a link-local address by the core framework when a new
`Node` is added. The `InfraIf::Init()` method derives the link-local
address from the MAC address and adds it to the interface. Therefore,
these explicit manual calls in individual test scripts are unnecessary
and can be removed to simplify the test setup.
2026-04-08 16:09:17 -05:00
Jonathan Hui 87d39dbf5e [nexus] increase kAttachToRouterTime in 1_4_TREL_TC_4 (#12852)
Nexus test 1_4_TREL_TC_4 occasionally fails during topology formation
because the router promotion timeout (kAttachToRouterTime) was set to
120 seconds.

The MLE router selection jitter (OPENTHREAD_CONFIG_MLE_ROUTER_SELECTION
_JITTER) defaults to 120 seconds. Since the jitter timer starts after
successful attachment as a child, 120 seconds is insufficient when the
maximum jitter is selected, leading to a race condition.

This commit increases kAttachToRouterTime to 200 seconds, matching the
value used in most other Nexus tests and providing sufficient time for
router promotion to complete reliably.
2026-04-07 16:20:18 -05:00
Abtin Keshavarzian d2aba43057 [nexus] remove mSrpHostAddresses from Node class (#12850)
This commit removes the `mSrpHostAddresses` array from the `Node`
class in the Nexus platform. The array was specific to SRP client
testing and was occupying unnecessary memory for every simulated
node instance.

Instead of keeping this state inside the `Node` abstraction, a local
`hostAddrs` array is now declared within the `Test_1_3_SRP_TC_1()` test
function. This local array safely persists for the duration of the
test, allowing `Srp::Client::SetHostAddresses()` to use the
provided pointer without relying on a global or node-level member.
2026-04-07 14:21:32 -05:00
Abtin Keshavarzian a44970bdb4 [nexus] simplify node lookup using LinkedList matching methods (#12849)
This commit updates the address-based node lookup methods in `Core`
to use the `FindMatching()` and `ContainsMatching()` methods provided
by the `LinkedList` class. This replaces manual `for` loops with
cleaner, built-in list operations.

To facilitate this, a new `AddressNetif` enum and a `Matches()` method
are added to the `Node` class. The `Matches()` method accepts an
`Ip6::Address` and an `AddressNetif` indicator, allowing it to check
if the node has the specified address on its Thread interface, its
Infrastructure interface, or any.

Additionally, a `const` overload for the `Get()` template method is
added to the `Node` class to ensure proper const-correctness.
2026-04-07 13:23:25 -05:00
Abtin Keshavarzian a24e841ad2 [nexus] optimize HandleIp6Receive and SendIp6 to use OwnedPtr (#12846)
This commit updates the IPv6 receive path in the Nexus platform to
utilize `OwnedPtr<Message>` for message lifecycle management. It
also removes the need for a large local buffer and redundant
message allocations.

Previously, `Node::HandleReceive()` copied the entire `otMessage`
payload into a local array, and `InfraIf::SendIp6()` allocated a new
`Message` to enqueue for transmission.

With this change:
- `Node::HandleIp6Receive()` wraps the received `otMessage` in an
  `OwnedPtr<Message>`, ensuring proper cleanup upon exit without
  explicitly calling `otMessageFree()`.
- The `Ip6::Header::ParseFrom` is used which reads and validates
  the IPv6 header and the message.
- The hop limit is updated in-place within the `Message` using
  `Write()` to overwrite previous header.
- `InfraIf::SendIp6()` accepts the `OwnedPtr<Message>` directly,
  taking ownership and enqueuing it without requiring reallocation
  or memory copying.
- Condition checks in `Node::HandleIp6Receive()` are reordered
  to match the comment.
2026-04-07 13:22:55 -05:00
Abtin Keshavarzian 641e84aed4 [meshcop] consolidate Open() and Bind() in SecureTransport (#12826)
This commit simplifies the `SecureTransport` API by consolidating the
previous `Open()` and `Bind()` methods into two specialized `Open()`
flavors.

The first flavor, `Open(uint16_t aPort, ...)`, creates and binds a UDP
socket to a specific port and network interface. If the port is zero,
an ephemeral port is automatically selected.

The second flavor, `Open(TransportCallback aCallback, ...)`, enables
callback-based transmission, where outgoing messages are sent via the
provided callback and received messages are passed in through
`HandleReceive()`.

This consolidation ensures that the transport is fully initialized and
ready for traffic in a single method call. It also prevents the
creation of unused UDP sockets when a `TransportCallback` is
employed, avoiding unnecessary overhead in the `Udp` class.

All core components (`BorderAgent`, `Commissioner`, `Joiner`, and
`BleSecure`) and related tests are updated to utilize the new
patterns.
2026-04-07 01:30:39 -05:00
Abtin Keshavarzian 1e79496c57 [border-agent] handle mDNS service name conflict by renaming (#12790)
This commit adds support for handling mDNS service name conflicts by
automatically renaming the service when a collision is detected during
registration.

The new naming scheme appends a suffix based on the last two bytes of
the device's Extended Address (e.g., " #AB1E"). If this name also
conflicts, an additional index is appended (e.g., " #AB1E (1)").

Changes:
- Added `mServiceRenameIndex` to `Manager` and `EphemeralKeyManager`
  to track re-naming attempts.
- Updated `otBorderAgentSetMeshCoPServiceBaseName()` and CLI documentation
  to reflect the new naming and conflict resolution logic.
- Updated `OT_BORDER_AGENT_MESHCOP_SERVICE_BASE_NAME_MAX_LENGTH` to
  ensure the full name fits within the 63-character DNS label limit.
- Added Nexus tests to verify the renaming logic under conflict.
2026-04-06 23:47:39 -05:00
Abtin Keshavarzian 754eefabb6 [nexus] fix IPv6 receive callback setup in node reset (#12845)
This commit updates `Node::Reset()` in the Nexus platform to correctly
set the IPv6 receive callback after the OpenThread `Instance` has been
re-initialized via placement `new`.

Previously, `otIp6SetReceiveCallback()` was called before the new
`Instance` was constructed, meaning the callback registration would
be lost when the instance memory was overwritten. Additionally, the
callback registration now passes the associated `Node` object as the
context.
2026-04-06 23:46:21 -05:00
Abtin Keshavarzian 5735726616 [nexus-test] reuse foundService bool in tests (#12844)
This commit replaces local `found` boolean variable with the shared
`foundService` variable.
2026-04-06 23:45:59 -05:00
Abtin Keshavarzian 8985f29e8e [udp] change Ip6::Udp::GetUdpSockets() to return LinkedList (#12843)
This change updates `Ip6::Udp::GetUdpSockets()` to return a reference
to the `LinkedList<SocketHandle>` instead of a pointer to the head of
the list. This allows for cleaner iteration using range-based for
loops and provides a more idiomatic C++ interface.

Call sites are updated accordingly. Specifically, the Nexus UDP
platform  code now uses a range-based for loop to iterate through the
sockets.
2026-04-06 23:45:32 -05:00
Jonathan Hui ac01d4b132 [tests] initialize DNS browser and resolver in nexus tests (#12847)
In nexus tests, DNS browser and resolver objects must be initialized
using ClearAllBytes before use to ensure predictable behavior.

This commit adds missing ClearAllBytes calls for:
- Dns::Multicast::Core::Browser
- Dns::Multicast::Core::TxtResolver
- Dns::Multicast::Core::SrvResolver
- Dns::Multicast::Core::AddressResolver

In test_1_3_SRP_TC_4.cpp, ClearAllBytes is now called before browser
reuse in Step 19.

Redundant includes of common/clearable.hpp were removed as it is
available transitively.

A blank line was added after Browser declarations for consistency.
2026-04-06 23:44:20 -05:00
Abtin Keshavarzian f8af79817b [uptime] enhance UptimeToString() and add flags (#12841)
This commit enhances the `UptimeToString()` function by introducing
`UptimeStringFlags` to allow customization of the output string.
Specifically, it adds the following flags:

- `kUptimeStringIncludeMsec`: Includes milliseconds in the string.
- `kUptimeStringSkipHoursIfZero`: Omits the `<hh>:` part when hours
  and days are zero.

The commit also adds a new `UptimeToString()` overload that returns
an `UptimeString` (a `String` object), simplifying usage in logging
and other areas. All existing call sites are updated to use the new
flags and the new overload where appropriate.
2026-04-06 19:13:32 -05:00
Jonathan Hui f0cc2809cc [nexus] implement 1.4 Thread Administration Sharing test (1_4_CS_TC_3) (#12832)
This commit implements the Thread 1.4 Credential Sharing (CS) TC-3
Nexus test, focusing on Thread Administration Sharing using ePSKc.
The test case covers mDNS discovery, ePSKc generation/validation,
and DTLS secure transport for TMF message exchange.

Detailed changes:
- Implement full 26-step Nexus test in tests/nexus/test_1_4_CS_TC_3.cpp
  covering the following procedures:
  - mDNS discovery of meshcop and meshcop-e service instances.
  - Validation of State Bitmap (sb) and other TXT record fields.
  - Generation and Verhoeff-based validation of One-Time Passcodes.
  - DTLS handshakes using correct and incorrect ePSKc values.
  - MGMT_ACTIVE_GET and MGMT_PENDING_GET request/response exchanges
    over the secure DTLS session.
  - Testing of ephemeral key expiration and max connection attempts.
- Add Python-based packet verification script in
  tests/nexus/verify_1_4_CS_TC_3.py using pktverify to ensure
  protocol compliance.
- Register the 1_4_CS_TC_3 test in tests/nexus/CMakeLists.txt.
- Add 1_4_CS_TC_3 to the default test list in run_nexus_tests.sh.
2026-04-06 17:39:31 -05:00
Jonathan Hui 5439f80c7b [nexus] implement platform UDP support (#12822)
This commit implements the otPlatUdp API for the Nexus simulation
environment and updates core UDP logic to facilitate it.

Changes in src/core:
- Initialize mHandle in Udp::Open with the current Instance pointer
  when Nexus platform UDP is enabled. This allows the platform UDP
  implementation to retrieve the instance context directly from the
  otUdpSocket handle.

Changes in Nexus platform:
- Implement otPlatUdp API in nexus_udp.cpp/hpp. The implementation
  routes UDP traffic through the simulated infrastructure interface
  (InfraIf).
- Integrate Udp class into Nexus::Node and Nexus::Platform.
- Update InfraIf::Receive to dispatch incoming UDP packets to the
  new platform UDP implementation.
- Enable OPENTHREAD_CONFIG_PLATFORM_UDP_ENABLE and related configs
  in Nexus.

Changes in Nexus tests:
- Update test_border_admitter, test_border_agent, test_dtls, and
  test_1_4_DNS_TC_1 to align with the new platform UDP and address/
  netif usage.
- Add nexus_udp.cpp to CMakeLists.txt.
2026-04-06 15:11:58 -05:00
Abtin Keshavarzian bf6da19fbe [border-admitter] include admitter state in all enroller responses (#12830)
This commit updates `Manager::CoapDtlsSession::SendEnrollerResponse()`
to always include the Admitter info TLVs in responses sent to
enrollers. Previously, these TLVs were only included in responses to
registration and keep-alive requests.

This change ensures that enrollers receive consistent state updates
from the `Admitter` during all interactions, such as joiner
acceptance or release.

The test case `TestBorderAdmitterJoinerEnrollerInteraction` is
updated to validate the new behavior.
2026-04-04 01:18:52 -05:00
Abtin Keshavarzian 5889e428ce [border-admitter] enhance forwarding of joiner relay to enrollers (#12829)
This commit enhances the `Admitter` logic for forwarding `RelayRx`
messages to connected enrollers.

If an enroller has explicitly accepted a specific joiner IID, the
`Admitter` will now always forward that joiner's relay traffic to the
owning enroller, regardless of its current `kForwardJoinerRelayRx`
flag in its registered enroller mode. The flag now strictly controls
whether the enroller receives general "multicast" forwarding for
joiners that have not yet been accepted by any enroller.

This enhancement adds a new capability to the interactions between the
`Admitter` and enrollers. Previously, if an enroller accepted a joiner
but also cleared its `kForwardJoinerRelayRx` flag, it could be
considered a misbehavior by the enroller, as it would effectively
block that joiner's traffic from reaching any other enrollers without
receiving the traffic itself. This scenario is no longer possible, and
this configuration now supports a new behavior: allowing an enroller
to accept certain joiners and receive relay traffic only from those it
has explicitly accepted.

The `test_border_admitter` is updated to validate this behavior in
detail.
2026-04-04 01:18:34 -05:00
Abtin Keshavarzian aec6b5d795 [border-router] introduce LinkLayerAddress in InfraIf (#12819)
This commit introduces the `LinkLayerAddress` class as a nested type
within `InfraIf`. The new class inherits from the
`otPlatInfraIfLinkLayerAddress`  and provides utility methods to
simplify address manipulation and logging.

Specifically, the following capabilities are added:
- `ConvertToIid()` converts the link-layer address into an IPv6
  `InterfaceIdentifier`.
- `ToString()` formats the address into a human-readable string.
- Getters like `GetLength()` and `GetBytes()` for accessing the
  underlying address data.

The `nexus` platform tests are updated to leverage the newly added
`LinkLayerAddress` methods, simplifying the handling of MAC addresses
and the derivation of IPv6 interface identifiers.
2026-04-04 01:16:37 -05:00
Abtin Keshavarzian 42635a12b2 [test] enhance test-008-multicast-traffic.py (#12816)
This commit updates `test-008-multicast-traffic.py` to use a strict
equality check for the number of multicast `ping` responses when the
ping originates from an SED.

The test now also verifies the `RxSuccess` IP counter on the SED to
ensure it increases by exactly the number of expected replies. This
confirms that the parent correctly avoids forwarding the original
multicast echo request back to the originating SED, even if the SED
is subscribed to the multicast address. This validates the behavior
introduced in PR #12329.
2026-04-02 00:07:15 -05:00
Jonathan Hui 057937c31f [nexus] add 1_3_GEN_TC_2 for mDNS TXT record validation (#12811)
This commit adds Nexus test case 1_3_GEN_TC_2, which verifies mDNS TXT
record regeneration across factory resets in the Nexus simulation
environment.

The test ensures that key fields such as 'id' (Border Agent ID) and
'omr' (OMR prefix) are correctly updated in mDNS advertisements after
a settings wipe and network reset.

Key features of this implementation include:
- tests/nexus/test_1_3_GEN_TC_2.cpp: Sets up a Border Router, forms a
  network, and validates initial mDNS state. It then performs an
  otPlatSettingsWipe followed by a reset to trigger new configuration.
- tests/nexus/verify_1_3_GEN_TC_2.py: Implements robust packet
  verification using hex-based marker matching for OMR prefixes to
  accurately identify iteration-specific TXT records despite any
  interleaved or stale mDNS packets in the capture.
- Integrated the new test into tests/nexus/CMakeLists.txt and
  tests/nexus/run_nexus_tests.sh for automated build and execution.

This test validates that the Thread stack correctly manages persistent
state and re-generates unique identifiers upon a factory reset.
2026-04-01 23:38:04 -05:00
Jonathan Hui 26a882dabc [nat64] handle IPv4 options and discard source route options (#12818)
OpenThread's NAT64 translator assumed a fixed IPv4 header length of 20
bytes, which caused incorrect parsing and translation of IPv4 packets
containing options (IHL > 5).

Specifically, if an IPv4 packet with options was received:
1. The transport header was read from a fixed 20-byte offset, leading
   to corruption of transport layer fields (e.g., UDP ports).
2. Only 20 bytes were removed from the message, leaving the IPv4
   options at the beginning of the translated IPv6 payload.
3. Mandatory security checks for source route options were bypassed.

This commit fixes these issues by:
- Updating Ip4::Header to validate IHL and provide the actual header
  length.
- Using the actual header length for transport header parsing and
  IPv4 header removal in the NAT64 translator.
- Implementing a check to discard packets with LSRR or SSRR options
  as required by RFC 7915.

A new Nexus regression test is added to verify the fix.
2026-04-01 20:24:42 -05:00
Jonathan Hui 42b653a18c [nexus] add 1_4_DNS_TC_1 for multi-question DNS queries (#12817)
This commit adds Nexus test case 1_4_DNS_TC_1, which verifies that the
Thread Border Router DUT can successfully handle DNS queries with
multiple questions (QDCOUNT > 1), per the Thread 1.4 specification.

The implementation includes:
- tests/nexus/test_1_4_dns_tc_1.cpp: C++ test logic that sets up a
  topology with Eth_1, BR_1 (DUT), Router_1, and ED_1. It registers
  services via mDNS on Eth_1 and SRP on Router_1, and then performs
  various DNS queries from ED_1, including multi-question queries.
- tests/nexus/verify_1_4_dns_tc_1.py: Python script that verifies
  the DNS packet exchange in the pcap, ensuring that multi-question
  queries are correctly received by the DUT and that valid responses
  are returned.
- Integration into tests/nexus/CMakeLists.txt and
  tests/nexus/run_nexus_tests.sh for automated building and execution.
2026-04-01 20:24:12 -05:00
Jonathan Hui 7bfb4226f0 [nexus] add 1_4_TREL_TC_6 for mDNS discovery of TREL service (#12809)
This commit adds Nexus test case 1_4_TREL_TC_6, which verifies mDNS
discovery of the TREL service on a Border Router (DUT), per the Thread
1.4 specification.

The implementation includes:
- tests/nexus/test_1_4_TREL_TC_6.cpp: C++ test logic that sets up a
  Border Router and a reference Ethernet device. It performs mDNS
  browsing to capture the TREL service instance name and then
  resolves that service.
- tests/nexus/verify_1_4_TREL_TC_6.py: Python script that verifies
  the mDNS packet exchange in the pcap, including PTR, SRV, TXT, and
  AAAA records, ensuring all DNS-SD parameters and fields are
  correctly advertised.
- Integration into tests/nexus/CMakeLists.txt and
  tests/nexus/run_nexus_tests.sh for automated building and execution.
2026-04-01 12:11:01 -05:00
Jonathan Hui 57539b0725 [nexus] add 1_4_TREL_TC_5 for multi-radio discovery scan (#12808)
This commit adds Nexus test case 1_4_TREL_TC_5, which verifies
MLE discovery scan behavior when nodes support different radio
links, per the Thread 1.4 specification.

The implementation includes:
- tests/nexus/test_1_4_TREL_TC_5.cpp: Sets up a topology with
  three nodes: Node_1 (DUT) and Node_2 support both 15.4 and
  TREL, while Node_3 supports 15.4 only. Each node forms its
  own network. The test performs Discovery Scans from Node_2
  and Node_3 and verifies that all expected peers are seen.
- tests/nexus/verify_1_4_TREL_TC_5.py: Verifies the exchange
  of MLE Discovery Request and Response packets in the pcap
  output, ensuring that nodes with different radio capabilities
  can discover each other correctly.
- Updated tests/nexus/CMakeLists.txt and
  tests/nexus/run_nexus_tests.sh to include the new test in the
  build and default test list.
2026-04-01 10:17:01 -05:00
Abtin Keshavarzian ad0d0fcb5e [nexus] use indexed SetName() in test cases (#12814)
This commit simplifies node naming in various Nexus test cases by
using the indexed `SetName(prefix, index)` flavor.

This replaces manual string formatting using `snprintf` or
`ot::String` buffers with the built-in indexed naming support.
2026-04-01 09:38:03 -05:00
Abtin Keshavarzian d9fc6c15dc [nexus] add AddTestVar flavor for uint values (#12813)
This commit adds a new `AddTestVar` overload that accepts a
`uint32_t` value, simplifying the addition of numeric test
variables in Nexus tests.

Previously, adding a numeric test variable required manual string
formatting using a local `String` object. The new flavor handles
the uint to string conversion internally.

The change also introduces a `NewTestVar` private helper method in
the `Core` class to consolidate the logic for creating and
initializing a new `TestVar` entry.

Various Nexus test cases are updated to use the new `AddTestVar`
flavor, removing redundant string formatting code.
2026-04-01 09:37:42 -05:00
Abtin Keshavarzian e3fa1ac524 [nexus] use Dataset::Info method to simplify test_1_2_BBR_TC_3 (#12812)
This commit updates `test_1_2_BBR_TC_3.cpp` to use the `Get<>()` method
when accessing the network name and extended PAN ID from the
`MeshCoP::Dataset::Info` instance.
2026-04-01 09:36:53 -05:00
Jonathan Hui 0f4fbabc13 [nexus] add 1_4_TREL_TC_4 for radio link (re)discovery (#12807)
This commit implements Thread 1.4 Test Case 8.4 (TREL-8.4), "Radio Link
(Re)discovery through Receive", using the Nexus simulation framework.

The test validates the multi-radio behavior of a Border Router (DUT)
and a Router neighbor, specifically focusing on TREL link state
transitions and rediscovery mechanisms.

Key test scenarios include:
- Initial topology formation with a multi-radio BR (DUT), a multi-radio
  Router, and a 15.4-only End Device (ED).
- Preference detection for TREL vs. 802.15.4 radio links.
- Detection of TREL link failure and fallback to 802.15.4.
- TREL radio link rediscovery triggered by receiving messages from a
  neighbor over the TREL interface.
- Continued reachability via TREL when the 802.15.4 radio link is
  explicitly disabled.

The implementation consists of:
- tests/nexus/test_1_4_TREL_TC_4.cpp: C++ test logic for node
  configuration, state transitions, and message exchange.
- tests/nexus/verify_1_4_TREL_TC_4.py: Python script for automated
  packet-level verification of radio link selection.
- Integration into the Nexus build system and test runner.
2026-03-31 23:14:46 -05:00
Jonathan Hui 1d1ea0890e [nexus] add 1_3_GEN_TC_1 to verify Thread Version TLV (#12810)
This commit adds Nexus test case 1_3_GEN_TC_1, which verifies that the
Thread Version TLV uses the value '4' or higher, as required by the
Thread 1.3.x and 1.4.x specifications.

The implementation includes:
- tests/nexus/test_1_3_GEN_TC_1.cpp: C++ test logic that sets up a
  topology with a Border Router, a Router, and an End Device. It
  triggers MLE attachment procedures and discovery scans to generate
  MLE packets containing the Version TLV. For 1.4 devices, it also
  sends TMF Get Diagnostic Requests to verify the Version TLV in
  DIAG_GET.rsp.
- tests/nexus/verify_1_3_GEN_TC_1.py: Python script that verifies
  the MLE Version TLV in Parent Request/Response, Child ID Request,
  and Discovery Response packets. It also verifies the Version TLV
  in Network Diagnostic responses for 1.4 devices.
- Integration into tests/nexus/CMakeLists.txt and
  tests/nexus/run_nexus_tests.sh for automated building and execution.
2026-03-31 20:20:10 -05:00
Jonathan Hui 181227afa7 [nexus] add 1_4_TREL_TC_3 for TREL radio link rediscovery (#12806)
This commit adds Nexus test case 1_4_TREL_TC_3, which verifies the
multi-radio probe mechanism and TREL radio link rediscovery after a
temporary disconnect, according to the Thread 1.4 specification.

The implementation includes:
- tests/nexus/test_1_4_TREL_TC_3.cpp: Sets up a topology with a
  multi-radio Border Router (DUT), a multi-radio Router, and a
  15.4-only End Device. It simulates a TREL disconnect by disabling
  the TREL interface on the Router, verifies that the DUT falls back
  to 15.4, and then re-enables TREL to trigger and verify the probe
  mechanism for link rediscovery.
- tests/nexus/verify_1_4_TREL_TC_3.py: Verifies the packet flow from
  the pcap output, ensuring that TREL is used when available, 15.4
  is used during the TREL disconnect, and TREL usage resumes after
  rediscovery.
- Updated tests/nexus/CMakeLists.txt and tests/nexus/run_nexus_tests.sh
  to include the new test in the build and default test list.

The test ensures that the Thread stack correctly manages link
preferences and successfully rediscovers more efficient radio links
using the multi-radio probe mechanism.
2026-03-31 20:15:31 -05:00
Jonathan Hui d0949e1e92 [nexus] add 1_4_TREL_TC_2 for TREL multi-hop routing (#12804)
This commit adds Nexus test case 1_4_TREL_TC_2, which verifies 6LoWPAN
mesh header forwarding and fragmentation over multi-hop paths involving
both 15.4 and TREL radio links, according to the Thread 1.4 spec.

The implementation includes:
- tests/nexus/test_1_4_TREL_TC_2.cpp: Sets up a complex topology with
  a multi-radio Border Router (DUT), a multi-radio Leader, and several
  Routers and End Devices with varying radio capabilities (15.4-only
  or multi-radio). It triggers pings with large payloads (500B) to
  verify fragmentation and multi-hop routing through the DUT.
- tests/nexus/verify_1_4_TREL_TC_2.py: Verifies that packets follow the
  expected multi-hop path, checking that TREL is used for infrastructure
  segments (UDP) and 15.4 is used for Thread-only segments. It also
  ensures that 6LoWPAN fragmentation and mesh headers are correctly
  handled by the DUT when forwarding between different radio types.
- Updated tests/nexus/CMakeLists.txt and tests/nexus/run_nexus_tests.sh
  to include the new test.

This test ensures that the Thread stack correctly handles multi-hop
routing and MTU differences across heterogeneous radio links.
2026-03-31 12:30:43 -05:00
Jonathan Hui 63ec21ea77 [nexus] add 1_4_TREL_TC_1 for Thread over Infrastructure (#12803)
This commit adds the Nexus test case 1_4_TREL_TC_1 which verifies
connectivity between multi-radio (15.4 and TREL) and single-radio
(15.4 only) devices, as per the Thread 1.4 test specification.

The implementation includes:
- tests/nexus/test_1_4_TREL_TC_1.cpp: Implements the test sequence.
  It sets up a topology with a Border Router (DUT) and two Routers.
  BR and Router_1 support both 15.4 and TREL, while Router_2 supports
  only 15.4. The test verifies that nodes can correctly detect
  neighbor radio capabilities and establishes connectivity using
  both radio types.
- tests/nexus/verify_1_4_TREL_TC_1.py: Performs automated packet
  verification. It ensures that traffic between multi-radio nodes
  preferentially uses TREL (simulated over the infrastructure link
  via UDP), while traffic involving the single-radio node uses 15.4.
  It also validates successful ping exchange across the mixed-radio
  topology.
- Integrated the new test into tests/nexus/CMakeLists.txt and
  tests/nexus/run_nexus_tests.sh.

The test validates that the Thread stack correctly manages multiple
radio links and ensures seamless connectivity across different
physical layers.
2026-03-31 09:39:13 -05:00
Jonathan Hui c3813d6253 [nexus] always enable TREL for Nexus tests (#12802)
This commit enables TREL by default for all Nexus tests to avoid
requiring multiple builds.

Key changes:
- Modified tests/nexus/build.sh to enable TREL (OT_TREL=ON) by default.
- Updated tests/nexus/test_border_admitter.cpp and
  tests/nexus/test_border_agent.cpp to handle multiple mDNS services
  in the platform layer, as TREL adds its own mDNS service.
- Refined tests/nexus/verify_1_2_BBR_TC_3.py to specifically filter
  for MeshCoP mDNS services and made OMR prefix verification more
  lenient to handle transitions in multi-radio environments.
- Updated .github/workflows/nexus.yml to use the default build for all
  Nexus jobs and merged TREL tests into the cert tests job.

All 133 cert tests, core tests, and TREL tests passed successfully with
these changes.
2026-03-30 22:46:53 -05:00
Jonathan Hui 7af59a1fef [nexus] route TREL traffic through simulated infrastructure link (#12801)
This commit updates the TREL traffic simulation in the Nexus platform
to flow through the simulated infrastructure link. This ensures that
TREL packets are captured in the pcap file generated by the
infrastructure link, matching the behavior of mDNS traffic.

Key changes:
- Updated Trel::Send to use InfraIf::SendUdp instead of direct
  delivery.
- Modified InfraIf::Receive to recognize TREL UDP packets and pass
  them to the TREL platform layer.
- Removed the manual mPendingTxList from the Trel struct as
  packets are now managed by the infrastructure interface's queue.
- Added initialization for the TREL platform layer in Core::CreateNode.
- Removed Core::ProcessTrel as TREL packets are now processed within
  Core::ProcessInfraIf.

This change improves the realism of the TREL simulation and simplifies
packet capture for TREL-related tests.
2026-03-30 20:56:38 -05:00
Jonathan Hui 59411c85f6 [nexus] add 1_3_DPR_TC_2 for Service Discovery - Multiple BRs (#12798)
This commit adds the Nexus test case 1_3_DPR_TC_2 which verifies
Service discovery of services on Thread and Infrastructure with
multiple Border Routers and multiple Thread networks, as per the
Thread 1.3 test specification.

The implementation includes:
- tests/nexus/test_1_3_DPR_TC_2.cpp: Implements the test sequence.
  It sets up two isolated Thread networks, each with its own Border
  Router (BR_1/DUT and BR_2) and End Device (ED_1 and ED_2),
  attached via a shared infrastructure link. It simulates SRP
  registration on both networks and verifies that services can be
  discovered across networks using the Discovery Proxy function.
- tests/nexus/verify_1_3_DPR_TC_2.py: Performs automated packet
  verification. It ensures both BRs correctly add SRP Server info
  to their respective Network Data, SRP updates are successful,
  and DNS queries (PTR and SRV) from one network successfully
  discover services in the other network through the Discovery
  Proxy and mDNS on the infrastructure link.
- Integrated the new test into tests/nexus/CMakeLists.txt and
  tests/nexus/run_nexus_tests.sh.

The test validates that the Border Router's Discovery Proxy can
successfully discover and report services advertised by another
Border Router's Advertising Proxy function across an adjacent
infrastructure link.
2026-03-30 18:18:13 -05:00
Jonathan Hui 1b78d18c13 [nexus] add 1_3_DPR_TC_1 for Service Discovery of services (#12793)
This commit adds the Nexus test case 1_3_DPR_TC_1 which verifies
Discovery Proxy functionality on a Border Router, as per the
Thread 1.3 test specification.

The implementation includes:
- tests/nexus/test_1_3_DPR_TC_1.cpp: Implements the test sequence.
  It sets up a topology with a Border Router (BR_1), a Thread End
  Device (ED_1), and an infrastructure node (Eth_1). It simulates
  Eth_1 advertising services via mDNS and ED_1 querying for those
  services through the BR's Discovery Proxy.
- tests/nexus/verify_1_3_DPR_TC_1.py: Performs automated packet
  verification. It ensures the BR correctly adds SRP Server info
  to Network Data, Eth_1 advertises services, and ED_1 receives
  a valid DNS response from the BR containing the discovered
  infrastructure services.
- tests/nexus/openthread-core-nexus-config.h: Enables the
  OPENTHREAD_CONFIG_DNSSD_DISCOVERY_PROXY_ENABLE configuration to
  support Discovery Proxy testing in the Nexus environment.
- Integrated the new test into tests/nexus/CMakeLists.txt and
  tests/nexus/run_nexus_tests.sh.

The test validates that the Border Router's Discovery Proxy can
successfully discover and report services from the infrastructure
link to Thread devices.
2026-03-30 16:23:21 -05:00
Jonathan Hui 0883176d31 [nexus] add 1_3_DIAG_TC_2 for Get Diagnostics - End Device (#12791)
This commit adds the Nexus test case 1_3_DIAG_TC_2 which verifies
that an End Device correctly reports its diagnostic information and
MLE counters via Network Diagnostic queries, as per the Thread 1.4
test specification.

The implementation includes:
- tests/nexus/test_1_3_DIAG_TC_2.cpp: Sets up a topology with a Leader,
  a Router, and a TD_1 (DUT) configured as a MED. It triggers Network
  Diagnostic Get queries from the Leader to the DUT for various TLVs
  including Max Child Timeout, EUI-64, Version, Vendor info, and MLE
  Counters.
- tests/nexus/verify_1_3_DIAG_TC_2.py: Performs automated verification
  of the captured traffic. It validates the presence and values of
  requested TLVs (Type 19, 23-28) and ensures that MLE Counters (Type
  34) reflect the expected role changes and tracking time.
- Integrated the new test into tests/nexus/CMakeLists.txt and
  tests/nexus/run_nexus_tests.sh.

The test ensures the correctness of Thread 1.4 End Device Diagnostic
and MLE Counter reporting, facilitating network health monitoring
and troubleshooting in a Thread network.
2026-03-30 14:24:45 -05:00
Jonathan Hui c6cf9b27ea [nexus] add 1_3_DIAG_TC_1 for Network Diagnostic and Child Info (#12789)
This commit adds the Nexus test case 1_3_DIAG_TC_1 which verifies
that a Thread Router correctly reports its child and neighbor
information via Network Diagnostic and MeshDiag queries, as per
the Thread 1.4 test specification.

The implementation includes:
- tests/nexus/test_1_3_DIAG_TC_1.cpp: Sets up a star topology with
  a Leader, Router_1 (DUT), and various child nodes (FED, MED, SED,
  REED). It triggers Network Diagnostic Get and MeshDiag queries
  (QueryChildTable, QueryChildrenIp6Addrs, QueryRouterNeighborTable)
  from the Leader to the DUT.
- tests/nexus/verify_1_3_DIAG_TC_1.py: Performs automated verification
  of the captured traffic. It implements a custom TLV parser for
  CoAP payloads to verify Max Child Timeout (19), Vendor/Stack info
  (23-28), MLE Counters (34), Child Table (29), Child IPv6 (30),
  and Router Neighbor (31) TLVs.
- Integrated the new test into tests/nexus/CMakeLists.txt and
  tests/nexus/run_nexus_tests.sh.

The test ensures the correctness of Thread 1.4 Router Diagnostic
and Child Information reporting, facilitating remote monitoring
and management of the Thread network.
2026-03-30 11:48:59 -05:00
Jonathan Hui 9bb7e37ff9 [nexus] add SRPC-TC-7 for SRP client key persistence (#12788)
This commit adds the Nexus test case 1_3_SRPC_TC_7 which verifies
that a Thread device re-registers its service with the same KEY
record after a reboot, as per the Thread 1.3 test specification.

The implementation includes:
- tests/nexus/test_1_3_SRPC_TC_7.cpp: Executes the test sequence
  by forming a Thread network with a Border Router (BR_1), a Router,
  and a DUT (TD_1). It registers a service on the DUT, simulates a
  reboot using Node::Reset(), and re-registers the same service.
- tests/nexus/verify_1_3_SRPC_TC_7.py: Performs automated verification
  of the captured traffic. It ensures that the SRP Update sent after
  reboot contains a KEY record identical to the one sent before
  reboot. It includes a monkey-patch to access the
  dns.key.public_key field in the packet verifier.
- Integrated the new test into tests/nexus/CMakeLists.txt and
  tests/nexus/run_nexus_tests.sh.

The test validates that the SRP client correctly persists its key
material across reboots, which is essential for maintaining service
registration continuity.
2026-03-29 22:14:56 -05:00
Jonathan Hui 1b20885508 [nexus] add SRPC-TC-5 for DNS-SD service discovery (#12787)
This commit adds the Nexus test case 1_3_SRPC_TC_5 which verifies
that a DNS-SD client can correctly discover multiple services
registered via SRP, as per the Thread 1.3 test specification.

The implementation includes:
- tests/nexus/test_1_3_SRPC_TC_5.cpp: Executes the test sequence
  by configuring a Border Router (BR_1), an End Device (ED_2)
  registering 5 services with various TXT records, and a DUT
  (TD_1). It instructs the DUT to browse for services, resolve
  them, and send UDP packets to each resolved service. It verifies
  the TXT record values and successful UDP transmissions.
- tests/nexus/verify_1_3_SRPC_TC_5.py: Performs automated
  verification of the captured traffic (PCAP). It validates the
  DNS query, the DNS response containing all 5 services, and the
  subsequent UDP packets sent to the resolved addresses and ports.
- Integrated the new test into tests/nexus/CMakeLists.txt and
  tests/nexus/run_nexus_tests.sh.

The test ensures the correctness of DNS-SD client discovery logic
and its ability to handle multiple service responses in a Thread
network.
2026-03-28 22:46:09 -05:00
Jonathan Hui dd855c3b3e [nexus] add SRPC-TC-4 for service removal by SRP client (#12780)
This commit adds the Nexus test case 1_3_SRPC_TC_4 which verifies
that an SRP client can correctly remove one service while leaving
other services registered, as per the Thread 1.3 test specification.

The implementation includes:
- tests/nexus/test_1_3_SRPC_TC_4.cpp: Executes the test sequence
  by configuring a Border Router (BR_1) and an End Device (TD_1
  as DUT). It instructs the DUT to register two services and then
  remove the first service. It verifies that the SRP server handles
  the removal correctly and only provides the remaining service in
  subsequent DNS PTR queries.
- tests/nexus/verify_1_3_SRPC_TC_4.py: Performs automated
  verification of the captured traffic (PCAP). It validates the
  SRP Update messages for service registration and removal, and
  checks that the DNS response from BR_1 only contains the
  expected service.
- Integrated the new test into tests/nexus/CMakeLists.txt and
  tests/nexus/run_nexus_tests.sh.

The test ensures the correctness of SRP client service removal
logic and SRP server state management.
2026-03-27 18:56:29 -05:00
Jonathan Hui 51353a9c9e [nexus] add SRPC-TC-1 for SRP client re-registration (#12779)
This commit adds the Nexus test case 1_3_SRPC_TC_1 which verifies
that the SRP client correctly handles re-registration with active
SRP servers, especially when multiple Border Routers are present,
as per the Thread 1.3 test specification.

The implementation includes:
- tests/nexus/test_1_3_SRPC_TC_1.cpp: Executes the test sequence
  by configuring two Border Routers (BR_1 and BR_2), a Router,
  and an End Device (ED_1 as DUT). It simulates BR_1 (the initial
  SRP server) becoming unresponsive and verifies that the DUT
  correctly switches to BR_2. It also verifies that the DUT
  stays with its current server (BR_2) even when a numerically
  lower server (BR_1) is re-enabled.
- tests/nexus/verify_1_3_SRPC_TC_1.py: Performs automated
  verification of the captured traffic (PCAP). It checks for
  correct SRP Update packets to the expected SRP servers and
  validates that the DUT behavior matches the specification
  criteria.
- Integrated the new test into tests/nexus/CMakeLists.txt and
  tests/nexus/run_nexus_tests.sh.

The test ensures robust SRP client behavior in dynamic networks
with multiple SRP servers.
2026-03-27 16:54:22 -05:00
Jonathan Hui d630934857 [nexus] add SRP-TC-15 for validation of SRP subtypes (#12777)
This commit adds the Nexus test case 1_3_SRP_TC_15 which verifies
that the SRP server and Border Router correctly handle services
that include additional subtypes, as per the Thread 1.3 test
specification.

The implementation includes:
- tests/nexus/test_1_3_SRP_TC_15.cpp: Executes the test sequence
  by configuring a Border Router (BR_1 as DUT/Leader), an End
  Device (ED_1), and an Infrastructure node (Eth_1). It simulates
  adding, updating, and removing subtypes for a registered service
  and verifies that the BR responds correctly to DNS and mDNS
  queries for both basic types and subtypes.
- tests/nexus/verify_1_3_SRP_TC_15.py: Performs automated
  verification of the captured traffic (PCAP). It checks SRP
  updates, DNS resolutions, and mDNS responses to ensure that
  subtypes are properly registered and advertised.
- Integrated the new test into tests/nexus/CMakeLists.txt and
  tests/nexus/run_nexus_tests.sh.

The test ensures robust support for SRP service subtypes and
their discovery across both Thread and Infrastructure links.
2026-03-27 13:44:45 -05:00
Jonathan Hui 7f26ca3997 [nexus] add SRP-TC-13 for Thread Device address update (#12774)
This commit adds the Nexus test case 1_3_SRP_TC_13 which verifies that
the SRP server and BR correctly handle SRP updates when a Thread
Device's IPv6 addresses change, as per the Thread 1.3 test
specification.

The implementation includes:
- tests/nexus/test_1_3_SRP_TC_13.cpp: Executes the test sequence by
  configuring a Border Router (BR_1 as DUT/Leader), an End Device
  (ED_1), and an Infrastructure node (Eth_1). It simulates address
  updates on ED_1 and verifies that the BR updates its records and
  correctly responds to DNS/mDNS queries.
- tests/nexus/verify_1_3_SRP_TC_13.py: Performs automated verification
  of the captured traffic (PCAP). It checks SRP updates, DNS
  resolutions, and mDNS responses to ensure they only contain the
  updated addresses and not stale ones.
- Integrated the new test into tests/nexus/CMakeLists.txt and
  tests/nexus/run_nexus_tests.sh.

The test ensures that SRP and DNS discovery remain accurate when
device addresses are updated dynamically.
2026-03-27 11:08:50 -05:00
Jonathan Hui 96e8286b37 [nexus] use SetGlobalLogLevel in SRP-TC-11 and SRP-TC-12 (#12782)
This commit updates recently added Nexus tests to use the new
SetGlobalLogLevel() method instead of the deprecated instance-specific
SetLogLevel(). This aligns with the recent changes in the logging
API which introduced per-instance log levels and repurposed the
global log level management.

The following test files were updated:
- tests/nexus/test_1_3_SRP_TC_11.cpp
- tests/nexus/test_1_3_SRP_TC_12.cpp

The change also wraps the call in SuccessOrQuit() to ensure that any
errors during log level configuration are caught, matching the
pattern used in other Nexus tests.
2026-03-27 09:17:26 -05:00
Abtin Keshavarzian cb4b28313b [logging] add support for per-instance log levels (#12740)
This commit introduces the ability to set and manage log levels on a
per-instance basis when dynamic logging is enabled, while maintaining
backward compatibility with existing logging behaviors.

The existing `otLoggingGetLevel()` and `otLoggingSetLevel()` APIs are
repurposed to manage the "global" log level. They continue to behave
exactly as before in both single-instance and multi-instance
configurations, ensuring that existing users of these APIs do not need
to change their implementations. To provide more granular control, new
APIs `otGetLogLevel()` and `otSetLogLevel()` are added to handle
per-instance log levels.

Specifically, this commit makes the following changes:
- Adds `mLogLevel` to `Instance` to track the instance-specific log
  level.
- Renames the global log level static variable to `sGlobalLogLevel` and
  introduces `GetGlobalLogLevel()` and `SetGlobalLogLevel()` to manage
  it in a multi-instance configuration.
- Updates `otGetLogLevel()` and `otSetLogLevel()` APIs to handle
  per-instance log level retrieval and configuration. If a specific
  level is not set for an instance, it falls back to the global
  log level.
- Adds `mIsLogLevelSet` to distinguish between an explicitly set
  instance log level and the global fallback in multi-instance builds.
- Introduces `otPlatLogHandleLogLevelChanged()` platform callback to
  notify the platform when an instance-specific log level is updated.
- Updates Nexus tests to use `SetGlobalLogLevel()` instead of the
  deprecated instance `SetLogLevel()` method.
2026-03-27 00:24:49 -05:00
Jonathan Hui 497e82ad5a [nexus] fix flakiness in 1_2_MATN_TC_9 test (#12781)
This commit fixes an intermittent failure in the Nexus test
1_2_MATN_TC_9 by ensuring that the packet verification for Step 4b
does not advance the packet cursor prematurely.

In Step 4b, the test verifies that BR_2 (DUT) becomes the leader and
distributes its BBR dataset. It checks for both an MLE Advertisement
and an MLE Data Response from BR_2. However, these packets may arrive
in either order.

Previously, the check for the MLE Advertisement used must_next(),
which advanced the packet cursor. If the MLE Data Response arrived
before the Advertisement, the subsequent check for the Data Response
would fail because it started searching from after the Advertisement.

By using copy() for the MLE Advertisement check, we ensure that both
checks search from the same point in the packet log, making the test
robust against packet reordering.
2026-03-26 23:11:07 -05:00
Jonathan Hui 112458b743 [nexus] add SRP-TC-12 for multiple BRs service advertisement (#12773)
This commit adds the Nexus test case 1_3_SRP_TC_12 which verifies
DNS/SRP service advertisement by all BRs in the Thread Network and
correct integration by the Leader, as per the Thread 1.3 test
specification.

The implementation includes:
- tests/nexus/test_1_3_SRP_TC_12.cpp: Executes the test sequence with
  three Border Routers (BR_1 as DUT/Leader, BR_2, and BR_3). It
  simulates adding faked high and low numerical addresses for Unicast
  Datasets and adding an additional Anycast Dataset from BR_2. It
  verifies the integration and withdrawal logic for SRP services.
- tests/nexus/verify_1_3_SRP_TC_12.py: Performs automated verification
  of the captured traffic (PCAP). It checks the Thread Network Data
  contained in MLE Data Responses for the presence of expected
  Anycast and Unicast Datasets and the withdrawal of the DUT's
  service when appropriate.
- Integrated the new test into tests/nexus/CMakeLists.txt and
  tests/nexus/run_nexus_tests.sh.

The test ensures that the DUT correctly manages multiple SRP server
entries in the network data based on their priority and numerical
address values.
2026-03-26 22:47:19 -05:00
Jonathan Hui 12f4b83195 [nexus] add SRP-TC-11 for recovery after reboot (#12772)
This commit adds the Nexus test case 1_3_SRP_TC_11 which verifies that
SRP registration and mDNS discovery are correctly recovered after
various device reboots, as per the Thread 1.3 test specification.

The implementation includes:
- tests/nexus/test_1_3_SRP_TC_11.cpp: Executes the test sequence by
  simulating reboots of a Thread End Device (ED_1), a Border Router
  (BR_1), and an Infrastructure node (Eth_1). It ensures consistent
  network datasets across reboots and uses direct method calls for
  configuration.
- tests/nexus/verify_1_3_SRP_TC_11.py: Performs automated verification
  of the captured traffic (PCAP). It uses specific MAC address filters
  to reliably identify mDNS queries and responses across multiple
  reboot scenarios where protocol exchanges may otherwise appear
  identical.
- Integrated the new test into tests/nexus/CMakeLists.txt and
  tests/nexus/run_nexus_tests.sh.

The test ensures that SRP clients automatically re-register after
device or server reboots and that the BR correctly continues to
respond to mDNS queries on the infrastructure interface.
2026-03-26 21:10:45 -05:00
Jonathan Hui 35512636b8 [nexus] add SRP-TC-8 for removing some published services (#12771)
This commit adds the Nexus test case 1_3_SRP_TC_8 which verifies that
the SRP server correctly removes only selected service instances while
keeping others registered, as per the Thread 1.3 test specification.

The implementation includes:
- tests/nexus/test_1_3_SRP_TC_8.cpp: Executes the test sequence by
  configuring a Thread Border Router (DUT), an End Device (ED), and
  an Infrastructure node (Eth). It registers multiple services and
  then removes one while verifying the remaining service.
- tests/nexus/verify_1_3_SRP_TC_8.py: Performs automated verification
  of the captured traffic (PCAP), ensuring that SRP Updates, DNS
  queries, and mDNS responses correctly reflect the removal of the
  selected service and the persistence of the other.
- Integrated the new test into tests/nexus/CMakeLists.txt and
  tests/nexus/run_nexus_tests.sh.

The test ensures that the SRP server properly handles service
deregistration according to the SRP draft and that DNS/mDNS discovery
responses are updated correctly.
2026-03-26 19:27:39 -05:00
Jonathan Hui 6dee5af2ae [nexus] add SRP-TC-6 for DNS name compression handling (#12765)
This commit adds the Nexus test case 1_3_SRP_TC_6 which verifies that
the SRP server correctly handles SRP Updates both with and without
DNS name compression, according to the Thread 1.3 test specification.

The implementation includes:
- tests/nexus/test_1_3_SRP_TC_6.cpp: Executes the test sequence by
  configuring a Thread Border Router (DUT), an End Device (ED), and
  an Infrastructure node (Eth). It uses SetDnsNameCompressionEnabled()
  to toggle name compression for SRP Updates.
- tests/nexus/verify_1_3_SRP_TC_6.py: Performs automated verification
  of the captured traffic (PCAP), ensuring that SRP Updates, DNS
  queries, and mDNS responses are correctly formatted and contain the
  expected resource records.
- Updating tests/nexus/CMakeLists.txt and tests/nexus/run_nexus_tests.sh
  to integrate the new test into the build and default test suite.

The test ensures that the SRP server can successfully parse uncompressed
names in SRP Updates and that subsequent DNS/mDNS discovery remains
functional for both compressed and uncompressed registration formats.
2026-03-26 17:49:34 -05:00