Commit Graph

824 Commits

Author SHA1 Message Date
Jason Zhang 67717618b7 [test] support multiple backbone interfaces in otbr docker test (#10550)
In previous otbr docker tests, when creating docker containers, all the
containers(otbr nodes) are connected to the same docker network bridge `backbone0`
(when the env PORT_OFFSET is not set or set to 0), this means all the
otbr nodes are connected to the same infrastructures.

This commit adds support to enable user to config otbr instance
infrastructures seperately in `TOPOLOGY` when defining test cases, this
provides flexibility to run multi-ail related test cases.

The format to define backbone interface per node is:

```
class NewTestCase(thread_cert.TestCase):
    ...
    BR = 1
    ...
    TOPOLOGY = {
        BR: {
            ...
	    'is_otbr': True,
	    'backbone': <backbone-name>,
	    ...
	}
	...
    }
    ...
```

`'backbone': <backbone-name>` is optional, when it's not given when
defining a otbr node, the backbone is default as
`BACKBONE_DOCKER_NETWORK_NAME`. The `<backbone-name>` is suggested to be
defined as `backbone[0-9]` to make it more easy to read and understand.

This commit also adds test_multi_ail.py as an example test case to use
this new method, this test case checks the two otbr nodes are connected
to the different infra and are in the same Thread mesh network.
2024-08-08 07:44:26 -07:00
Jason Zhang 6635201aa1 [thread-cert] fix bug that docker network is not removed (#10590)
In some cases that `_do_packet_verification` is False (e.g. verify() is
not defined), the docker network is not correctly removed.

docker network interface should always be removed at the end of the test
if it was created at the begin of the test
2024-08-08 08:37:57 -06:00
Mia Yang 634745dd72 [test] verify state bitmap when runtime enable/disable EphemeralKey mode (#10503)
Meshcop ePSKc mode supported bitmap check.
2024-08-06 08:54:02 -06:00
Jason Zhang 1d35e30e0e [thread-cert] output docker stdout/stderr only when VERBOSE is non-zero (#10574)
This commit supresses the docker output unless verbose mode is enabled,
which helps preventing unnecessary output from cluttering the console.

docker output is enabled when:
 * env VERBOSE is set to a non-zero value

docker output is suppressed (redirecting to /dev/null) when:
 * VERBOSE is not explicitly set in env, or
 * env VERBOSE is set to 0
2024-08-06 08:49:27 -06:00
Zhanglong Xia c5ad131028 [cli] add the sync option to the linkmetrics cli commands (#10518)
The cli command `linkmetrics` only provides an asynchronous output
method. It is difficult for scripts to call the `ot-ctl` to capture
the results of asynchronous output.

This commit replaces the command `linkmetrics mgmt` and `linkmetrics
query` with commands `linkmetrics config` and `linkmetrics
request`. Both the commands `linkmetrics config` and `linkmetrics
request` are set to the `sync` mode by default, and an option `async`
is added to these commands to support `async` mode.
2024-08-02 13:37:18 -07:00
Yakun Xu af18582b4e [test] set default paths of expect scripts (#10530)
This commit adds default paths for expect scripts to make it easier for
running expect scripts. With this change, we can run expect tests as
follows:

```bash
./script/cmake-build simulation
./script/cmake-build posix
./tests/scripts/expect/cli-ping.exp
OT_NODE_TYPE=rcp ./tests/scripts/expect/cli-ping.exp
```

This commit also updates an existing test to cover the change.
2024-07-24 06:50:17 -07:00
Abtin Keshavarzian 171f94c307 [srp-client] defer SRP update on SLAAC address deprecation (#10505)
This commit updates SRP client's `AutoHostAddress` behavior to
defer SRP updates on SLAAC address deprecation events.

Under `AutoHostAddressMode`, all preferred addresses on Thread Netif,
excluding link-local and mesh-local addresses, are registered. If no
eligible address is available, then the ML-EID will be registered.

This commit adds a new mechanism where if a previously registered
address starts being deprecated (e.g., due to an OMR prefix removal
from Network Data), the SRP update is deferred. The client will
re-register after the deprecation time has elapsed and the address is
removed. In the meantime, if any other event triggers the client to
send an SRP update, the updated address list will be included in that
update.

This commit also updates `test_srp_auto_host_address` to validate the
newly added behavior.
2024-07-17 11:14:09 -07:00
Przemysław Bida bf5ddb908e [tcat] implementation of tcat Ping command (#10484)
Commit implements Tcat ping command `kTlvPing`.

Signed-off-by: Przemyslaw Bida <przemyslaw.bida@nordicsemi.no>
2024-07-09 10:11:39 -07:00
Rongli Sun fbdb4b6c8f [test] supplement state bitmap test (#10318) 2024-07-05 09:51:33 -07:00
Abtin Keshavarzian e72ef4354a [test] harden test_advertising_proxy (#10474)
This commit makes two changes in `test_advertising_proxy`:

- In the test step where the server is restarted, a longer wait time
  is used to account for the longer jitter interval used by SRP
  client in such a case.
- Due to the use of short lease time (10 seconds) in this test, the
  client will refresh the registered services quickly. Therefore, in
  `check_host_and_service()`, any of `Registered`, `ToRefresh`, or
  `Refreshing` states are accepted as indicating successful
  registration.
2024-07-05 09:49:03 -07:00
Abtin Keshavarzian d87be657c6 [srp-client] enhance selection of TX jitter based on trigger reason (#10357)
This commit improves the `Srp::Client` mechanism for applying random
jitter delays before sending update messages to the server. It now
supports different jitter ranges based on specific triggers. Since
trigger events are often network-wide, potentially causing
simultaneous SRP re-registration from many nodes, longer jitter
intervals are used to distribute the resulting SRP update
transmissions and avoid congestion.

The following triggers are covered:

- Server switch: Client switching to a new server while already
  connected to a discovered server. This occurs when a new server
  entry appears in Network Data which is preferred over the current
  selection.

- Server restart: Client was previously connected to a server that
  disappeared from Network Data. Later, the same or a new server is
  discovered in Network Data.

- SLAAC address add or remove: This is generally triggered by updates
  to SLAAC prefixes in Network Data (e.g., OMR prefix changes).

- First registration after attach:

  - If the device is attaching to an established Thread mesh
    (e.g., after a reboot or initial pairing), the Network Data it
    receives should already include a server entry, leading to a
    quick server selection after attach. If server selection occurs
    within a short window, a shorter TX jitter is used, allowing the
    device to register quickly and become discoverable.

  - If server discovery takes longer, a longer TX jitter is used. This
    situation can indicate a server/BR starting up or a network-wide
    restart of many nodes (e.g., due to a power outage).

This commit introduces `TxJitter` class to manage the requested TX
jitter based on a trigger reason. It tracks the time of the event
that triggered a longer jitter request. If the update message is sent
immediately after the trigger event, the requested maximum jitter is
applied. However, if the update message is sent later, the maximum
jitter is adjusted proportionally to the time elapsed since the
trigger event. If the elapsed time exceeds the requested maximum
jitter interval, the default short jitter is applied to avoid
unnecessary registration delay.
2024-07-02 08:52:28 -07:00
Przemysław Bida 6aa6f45606 [tcat] implement decommissioning in tcat_agent (#10415)
Commits adds handling of TCAT TLV 0x60 `kTlvDecommission`.
2024-07-01 19:14:53 -07:00
Konrad Derda 8a8a4d8e31 [netif] remove multicast promiscuous mode configuration (#10338)
Since 74c833b623 was introduced all IPv6
multicast packets are passed to the host. Previously used promiscuous
mode configuration is now unused. This commit removes the dead code and
corresponding elements as there is no use case for them at the moment
(and they can confuse a user).

Signed-off-by: Konrad Derda <konrad.derda@nordicsemi.no>
2024-06-14 10:08:44 -07:00
Yakun Xu fa71a8afa3 [diag] specify sending frame (#10359)
This commit adds an extra command `diag frame` to specify the frame
used for `diag send` and `diag repeat`, so that we can use this
command to send arbitrary 802.15.4 frames.
2024-06-13 07:53:48 -07:00
Abtin Keshavarzian 4a0d6b7b64 [test] update key-increment test scripts to align with cert test (#10347)
This commit removes the option to set `key_switch_guardtime` when
constructing nodes and network topology in test scripts. The
following tests are updated to reflect this change:

- `Cert_5_8_02_KeyIncrement.py`
- `Cert_5_8_03_KeyIncrementRollOver.py`
- `Cert_6_6_01_KeyIncrement.py`
- `Cert_6_6_02_KeyIncrementRollOver.py`
2024-06-12 10:56:00 -07:00
Przemysław Bida 398df8c408 [tcat] implement tcat advertisement (#9858)
Commit introduces implementation of TCAT advertisement over BLE
compliant with Thread 1.3.1 specification.
2024-06-06 11:26:59 -07:00
Yakun Xu 39ce8117a5 [simulation] support simulating radio over IPv6 (#10194)
This commit adds support to simulate Thread radio over IPv6.

With this commit, a simulation will be simulated over either IPv6 or IPv4.
If it's simulated on IPv6, it communicates with other simulation nodes
in IPv6 group `ff02::116`. And if it's simulated on IPv4, it communicates
with other simulation nodes in IPv4 group `224.0.0.116`.

Note that simulating virtual time is not included in this commit.
2024-05-13 09:27:54 -07:00
Abtin Keshavarzian efb80c0b83 [routing-manager] exclude on-link prefixes with short preferred lifetime (#10062)
This commit updates `FindFavoredOnLinkPrefix()` to exclude discovered
on-link prefixes with preferred lifetimes under 30 minutes.
2024-04-29 09:11:27 -07:00
Li Cao 93f3113764 [link-metrics] add cli command to show link metrics manager state (#10046) 2024-04-25 08:31:18 -07:00
Li Cao b6a1dc8fe8 [tests] enhance expect test for link metrics manager feature (#10035)
This commit enhances the expect test against link metrics manager
feature to ensure that the feature can be continuously turned on or
off and work well. Because the feature will be controlled by the
feature flag in ot-br-posix.
2024-04-17 12:56:44 -07:00
Abtin Keshavarzian e3f97e2362 [netdata-publisher] distinguish SRP/DNS unicast entries (#9937)
This commit refines the `NetworkData::Publisher` to differentiate
between DNS/SRP unicast entries based on whether the address
information resides in service data (part of service TLV) or server
data (part of server sub-TLV).

Additionally, if another BR adds a service data unicast entry,
`Publisher` will zero out the desired count for server data unicast
entries, effectively removing any previously published server data
unicast entries.

The `test_netdata_publisher` has been updated to validate all the
newly added behaviors.
2024-04-05 09:30:26 -07:00
Handa Wang 843db1e82d [srp-server] retry other ports when failing to prepareSocket (#9981)
Unicast SRP dataset uses a ephemeral UDP port which could be taken by
another process. Currently SRP server creates the socket at the port
after the server is added into netdata. However, at that moment the
port may not be available on the platform so it may fail to create the
socket and start the server.

This commit adds the logic to restart the enabling process with
another port candidate if SRP server fails to create the socket.
2024-04-03 10:51:50 -07:00
Martin Zimmermann 4db6520d17 [channel-manager] add local csl channel selection on SSED (#9641)
This commit enables channel manager on SSED, together with channel monitor,
auto-selecting a better CSL channel for the link between child and its parent.

It also fixes tracking of CcaSuccessRate on CslChannel and adds toranj tests
for auto-channel selection and thread_cert test for autocsl-channel selection.
2024-03-25 14:06:29 -07:00
Przemysław Bida 3ae275f1ac [simulation] add simulation tests framework for tcat (#9724)
This commit adds simulation framework for tcat based on posix udp
sockets.
2024-03-22 10:30:59 -07:00
Jonathan Hui 148fa47bde [thread-cert] use unittest assert methods (#9936) 2024-03-15 11:11:51 -07:00
Abtin Keshavarzian 4c34a0e4a4 [test] enhance test_netdata_publisher robustness (#9932)
Updates validation logic after published route entry replacement to
prevent occasional failures due to a race condition. This increases
test stability.
2024-03-14 13:43:19 -07:00
Jonathan Hui 542be0f798 [thread-cert] use ROUTER_STARTUP_DELAY in test_detach (#9933) 2024-03-14 13:02:04 -07:00
Yakun Xu 3ebc3d3a06 [simulation] allow specify local host (#9925)
This commit adds a argument `-L`/`--local-host` to simulation platform
to specify the source IP address for packets simulating 15.4
frames. This allows the simulation packets being transmitted over
different network interfaces, so that the simulation can run on
different hosts.

This can be used to enable multiple emulation devices(e.g. Android
Virtual Device) communicating to each other over emulated Thread
radio.

The argument accepts either an IPv4 address or a network interface
name. In the latter case, the first found IPv4 address on that
interface will be used will be used.
2024-03-13 11:42:53 -07:00
Handa Wang 8769898255 [tests] fix test_manual_maddress.py (#9923) 2024-03-12 18:50:41 -07:00
Jonathan Hui ec7781a57e [thread-cert] set device mode in test_mle_msg_key_seq_jump (#9921) 2024-03-12 15:37:09 -07:00
Abtin Keshavarzian 518a849495 [test] add test_key_rotation_and_key_guard_time (#9906)
- Validates that key guard time is updated to 93% of key rotation
  time when it changes.
- Checks for proper key sequence updates after key rotation
  expiration.
- Confirms key guard mechanism blocks key sequence increments
  while mesh nodes staying connected.
2024-03-08 12:58:28 -08:00
Abtin Keshavarzian c66d91bdd7 [key-manager] update how key guard time is determined and applied (#9871)
This commit makes changes/fixes to `KeyManager` regarding key switch
guard time.

Key Rotation Time updates:
- When the Key Rotation Time changes (due to security policy updates),
  the key switch guard time (`mKeySwitchGuardTime`) is also adjusted.
  It's set to 93% of the Rotation Time (rounded down).
- Immediately checks if the new rotation time indicates a rotation is
  due and keys are rotated.

New variable `mKeySwitchGuardTimer`:
- This is reset to the current guard time whenever the key sequence is
  updated.
- It decrements hourly until reaching zero.
- Key switch guard comparison is made with this value, aligning the
  implementation with the Thread specification.

`SetCurrentKeySequence()` modification:
- Now accepts a new input parameter that determines whether to apply
  or ignore the key switch guard when updating the key sequence.
- During a key rotation check (when the rotation time has passed), the
  key switch guard is ignored and we always move to the next key
  sequence number.

Other changes:
- Variables handling guard and rotation time now use `uint16_t`
  instead of `uint32_t` to align with security policy definitions.
- API and CLI command documentation for setting the "key switch guard
  time" emphasize that they are intended for testing purposes.
2024-03-07 21:39:52 -08:00
Abtin Keshavarzian e0294176c1 [slaac] implement address deprecation mechanism (#9585)
This commit implements address deprecation mechanism in `Slaac` class.
When a prefix is removed from Network Data, its corresponding SLAAC
address is not removed immediately. Instead, it is marked as
deprecated and its "preferred" flag is set to false. After a
deprecation interval (300 seconds), the deprecated address is
removed. If the prefix is re-added to Network Data before the
deprecation time elapses, the SLAAC address is also reinstated.

Since the number of SLAAC address entries is limited, non-deprecated
addresses are prioritized. This means that if a new entry is required
for a new prefix, the earliest deprecating entry can be evicted to
accommodate the new entry.

The `Slaac` module keeps track of the associated Domain IDs for
deprecating SLAAC prefixes, even if the related Prefix TLV has
already been removed from the Network Data. This information is used
during external route lookup in `NetworkData::Leader::RouteLookup()`
if a deprecating SLAAC address is used as the source address in
an outbound message, ensuring that the message is not dropped and
can be delivered.

This commit also adds a detailed test `test-027-slaac-address.py`
validating various behaviors of SLAAC module.
2024-02-13 14:40:55 -08:00
Abtin Keshavarzian fffb489b26 [netdata-publisher] remove SRP unicast on anycast entry added by a BR (#9807)
This commit updates how the `NetworkData::Publisher` handles "DNS/SRP
Service Unicast Address" entries. Specifically, when a "DNS/SRP
Service Anycast" entry is added by another BR, the publisher will set
the desired count of unicast entries to zero. This effectively
removes any previously added unicast entry. This new behavior is
only applied when the address and port are included in the Server TLV
data in a "DNS/SRP Service Unicast Address" entry.

The `test_netdata_publisher` has been updated to verify this new
behavior.
2024-02-01 11:28:00 -08:00
Abtin Keshavarzian b28bb1d1e0 [srp] update config for auto-start mode to be enabled by default (#9738)
Config `OPENTHREAD_CONFIG_SRP_CLIENT_AUTO_START_DEFAULT_MODE` is
changed to use `1` by default (unless explicitly overridden in
project configs).

It also updates related test scripts to utilize auto-start mode or
explicitly disable it for manual SRP client control, reflecting this
default change.
2024-01-10 10:37:03 -08:00
Yang Liu d81c6fab98 [telemetry] add API for TREL telemetry (#9710)
Create OT API to support trel telemetry which is supported through
platform API and also add cli support to get/reset trel counters.

Metrics we are adding are:
- trel_frames_tx
- trel_bytes_tx
- trel_frames_rx
- trel_bytes_rx
- trel_frames_tx_failed
- num_trel_peers

Metrics already supported through API:
- trel_enabled
2024-01-05 22:10:27 -08:00
dependabot[bot] 09d07a7c6a Bump pycryptodome from 3.17 to 3.19.1 in /tests/scripts/thread-cert (#9755)
Bumps [pycryptodome](https://github.com/Legrandin/pycryptodome) from 3.17 to 3.19.1.
- [Release notes](https://github.com/Legrandin/pycryptodome/releases)
- [Changelog](https://github.com/Legrandin/pycryptodome/blob/master/Changelog.rst)
- [Commits](https://github.com/Legrandin/pycryptodome/compare/v3.17.0...v3.19.1)

---
updated-dependencies:
- dependency-name: pycryptodome
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-05 17:23:20 -08:00
Abtin Keshavarzian acd16029a7 [cli] add debug command (#9587)
This commit adds cli `debug` command. This command is specifically
designed for testing and debugging purposes. It executes a series of
CLI commands to gather information about the device and thread
network.
2023-12-08 15:56:13 -08:00
whd 97af664036 [tests] reduce flakiness of test_publish_meshcop_service.py (#9690) 2023-12-06 20:57:00 -08:00
whd 4ed44bc7d5 [tests] rename get_netdata_nat64_prefix() to get_netdata_nat64_routes() (#9678) 2023-12-04 22:59:13 -08:00
Abtin Keshavarzian 85660ce756 [srp-client] exclude non-preferred addresses in AutoAddress mode (#9642)
This commit updates the `AutoAddress` mode in `Srp::Client` to
exclude any deprecated (non-preferred) address when registering
host addresses.

It also updates `test_srp_auto_host_address` to validate the new
behavior.
2023-11-29 15:52:12 -08:00
whd 4b593f9d39 [tests] fix the check of external routes in test_multi_thread_networks.py (#9648)
There was a check `self.assertNotEqual(br1_external_routes,
br2_external_routes)` that verifies the external route entries of BR1
and BR2 are different, based on the fact that their external route
prefixes (in /64) were different. However, today we're using generic
external routes like `fc00::/7` so the external route entries will be
the same when BR1 and BR2 have the same RLOC16.

I updated the test case to verify that the devices have expected
external route entries respectively.
2023-11-27 18:29:02 -08:00
Mason Tran 0b0db37a13 [api] add API to reset to bootloader mode (#9523) 2023-10-27 15:54:15 -07:00
Abtin Keshavarzian 91b7c3ff3f [log] add otLogGenerateNextHexDumpLine() to generate hex dump (#9555)
This commit adds a public OT API to generate hex dump output line by
line. This function is then used for both `LogDump{}()` and frame
capture output by CLI `promiscuous` command (removing repeated
similar code) and harmonize the hex dump outputs.
2023-10-25 14:54:33 -07:00
Zhanglong Xia 4275c5826f [mac] update the cached supported channel mask when the region code changes (#9418)
The current code of the `mac.cpp` caches the supported channel mask to
a local variable. But the supported channel mask may be changed after
the country code is changed. This will cause the supported channel
mask used in `mac.cpp` to be inconsistent with the actual supported
channel mask.

This commit adds an API `otLinkSetRegion()` to set the region code and
then update the cached supported channel mask to avoid the channel
mask inconsistencies. The current Thread channel may be not included
in the new supported channel mask. When the Thread stack detects this
case, it detaches the current Thread network gracefully.
2023-10-24 14:36:57 -07:00
Abtin Keshavarzian 28f30b3ce8 [nedata] add API to retrieve Commissioning Dataset (#9551)
This commit adds `otNetDataGetCommissioningDataset()` as a public
API to retrieve the Commissioning Dataset from the Network Data.

It also updates CLI `netdata show` command to output the Commissioning
Dataset information. The documentation in `README_NETDATA.md` and
in `cli_network_data` are also updated. The test scripts that parse
`netdata show` output are also updated.
2023-10-23 05:17:51 -07:00
Abtin Keshavarzian a69c2db333 [meshcop] simplify processing of Commissioner ID TLV (#9543)
This commit updates CommissionerIdTlv to be defined as `StringTlvInfo`
(a TLV with a UTF-8 string value with a specified maximum length). This
allows us to use `Tlv` helper methods to `Find` and `Append` this
TLV, simplifying the code.

This commit also adds a helper `StringCopy()` method that copies a
C string into a given target string buffer array if it fits in the array.
This method can also optionally perform an encoding check on the string,
such as a UTF-8 encoding check. This helper method is used to simplify
setting different strings, such as Commissioner ID, Provisioning URL,
Vendor Name, etc.
2023-10-18 16:11:49 -07:00
Zhanglong Xia 7568e31c08 [spinel] create spinel interface based on the radio url protocol (#9393)
The posix platform is able to support the HDLC, SPI and vendor spinel
interfaces, but the spinel interface type can't be changed
dynamically. It is inconvenient to use different spinel interfaces for
Thread stack in Android. This commit enables the posix platform to
support the HDLC, SPI and vendor interface at the same time, and the
final spinel interface type is determined by the radio url protocol.

Some other changes:
1. Not use CRTP style for the radio spinel.
2. Deprecate the OT_POSIX_CONFIG_RCP_BUS and
   OPENTHREAD_POSIX_CONFIG_RCP_TIME_SYNC_INTERVAL.
2023-10-10 10:15:32 -07:00
whd e64f38a816 [ip6] drop UDP datagrams from an untrusted origin to TMF port (#9437)
This commit drops UDP datagrams from an untrusted origin to TMF port.

Examples of untrusted origin:
- A process other than OT on the host sends the packet to Thread
  network via platform API.
- A packet forwarded from infrastructure network to Thread network by
  Thread Border Router.

OT shouldn't allow UDP datagrams from untrusted origins going to TMF
port of any Thread device.

To implement this, there's an API `otIp6SendFromOrigin`
introduced. This can be used for specifying the origin of a packet you
want to send. This commit also encapsulates the 'origin' information
in `Message::Metadata`.
2023-10-05 09:50:57 -07:00
Zhanglong Xia df128246ac [posix] update the default channel masks in the configuration file (#9443)
The default supported channel mask is set to 0x7fff000 in the default
configuration file. The dbus client test case sets the channel to 11
which is not valid in the supported channel mask. It causes the CI test
failures in https://github.com/openthread/ot-br-posix/pull/2027.

This commit updates the default supported and preferred channel masks
in the configuration file to avoid the CI test failures.
2023-09-20 10:53:57 -07:00