Commit Graph

6474 Commits

Author SHA1 Message Date
Abtin Keshavarzian 2ce3d3bf02 [mesh-forwarder] add delay-aware queue management (#7568)
This commit implements delay-aware queue management. When enabled the
device will monitor time-in-queue of messages in the direct tx queue
and if it is lager than specified thresholds it updates ECN flag
(if message indicates it is ECN-capable) and/or drop the message. This
mechanism is applied to IPv6 messages on the first device that sends
the message into Thread mesh and also on intermediate routers that are
forwarding the message (e.g., as a "mesh lowpan fragment" frame). On an
intermediate router when forwarding the fragments of a message, if any
fragment is dropped by the queue management policy, all subsequent
fragments will also be dropped.

In particular, this commit contains the following:

- Adds `DecompressEcn()` and `MarkCompressedEcn()` in `Lowpan` class
  to decompress or update the ECN field in a compressed IPHC header
  (unit test `test_lowpan` is also updated to test the new methods).
- Adds `UpdateEcnOrDrop()` which implements the main queue management
 logic. This method is used when preparing next direct tx message. It
 decides whether to keep the message as is, update ECN on it or drop
 it.
- Updates `EvictMessage()` to first apply the queue management rule
  to see if any message can be dropped before using the eviction
  logic based on message priority.
- Updates and reuses the `FragmentPriorityList` to track whether
  queue management dropped any of the fragments of same message so
  to also drop any subsequent ones.
- Updates `LogMessage()` to log when a message is dropped by
  queue-management or when ECN is marked on a message.
thread-reference-20221027
2022-07-08 13:02:53 -07:00
Abtin Keshavarzian 8aca0655e7 [srp-client] exclude sub-type PTR when service is being removed (#7883)
This commit updates the SRP client to not include sub-types PTR
records when the base service is being removed.
2022-07-08 12:13:04 -07:00
Bob MacDonald 742b4e8cc3 [gcov] use __gcov_dump() instead for clang 12/13 (#7880)
Use gcov_dump when using clang on MacOS and the version is 13 or above
or when using clang on a non MacOS system and the version is 12 or
above.
2022-07-07 21:28:29 -07:00
Abtin Keshavarzian 5d09e9ca4f [mle] update number parent requests in an attach cycle (#7538)
This commit updates the MLE attach process so that in the first attach
cycle device tries a total of six MLE Parent Requests, the first two
to routers only followed by four to routers and REEDs. For example,
the six Parent Request message will be used before device can decide
to act the leader. An MTD in the next attach attempt (if cannot find a
parent in first attempt cycle), will go to the model of two Parent
Requests (first to routers, then to routers/REEDs).

This change impacts the time it takes for a device to start as leader
(due to increased number of Parent Request and wait time). This commit
updates different test scripts to address the change in the wait
time. It adds a new `config.LEADER_STARTUP_DELAY` constants which is
used for wait time for leader to start.
2022-07-07 16:50:21 -07:00
Abtin Keshavarzian b71c1590c1 [routing-manager] adding LocalOmrPrefix class (#7871)
This commit contain smaller enhancements related to managing the
local OMR prefix:

- It adds a new class to encapsulate all the related data and
  methods.
- We directly track whether or not the prefix is added to the local
  Network Data (using a boolean)
- The methods are renamed to use the terms "add/remove" instead of
  "publish/unpublish" since the Network data publisher is not used
  for OMR prefix and it is directly added or removed.
2022-07-07 10:11:10 -07:00
Abtin Keshavarzian 31f1992dbd [ip6] Headers class to parse IPv6 and UDP/TCP/ICMPv6 headers from message (#7851)
This commit adds `Ip6::Headers` class which represents IPv6 header
along with related transport layer header (UDP, TCP or ICMP6). It
provides helper methods to parse all headers from an IPv6 message or
decompress and read them from a lowpan frame.

This helps simplify the code and allows us to remove multiple similar
methods in `MeshForwarder` performing decompression/parsing.
2022-07-07 10:08:23 -07:00
Abtin Keshavarzian 12dfedb28f [csl] update CSL on role change to router or leader (#7874)
This commit adds a call to `Get<Mac::Mac>().UpdateCsl()` when there
is role change from `SetStateLeader()` or `SetStateRouter()`. This
ensures to disable CSL at `SubMac` and radio platform.
2022-07-07 08:54:14 -07:00
Zhanglong Xia eb3ca48042 [platform] add RCP interface metrics (#7860) 2022-07-07 08:47:58 -07:00
Zhanglong Xia 7e7da0e211 [spinel] add an API to get the radio spinel metrics (#7859)
When the RCP is not stable, it causes the Thread stack to crash.  To
better know the stability of the RCP, this commit adds an API to
return the radio spinel metrics.
2022-07-06 20:30:23 -07:00
canisLupus1313 dd631b2a19 [spinel] fix dua log region (#7865)
This commit sets dua log region to correct value 20.
2022-07-06 11:33:03 -07:00
Eduardo Montoya 289bbebb9c [csl] simplify states and scheduling (#7783)
After enabling the scheduling of delayed reception slots in #7677
they would be configured even when the device switched to MED mode.

This commit introduces some simplifications around the CSL states
and scheduling:
- Maintain the CSL timer stopped if not in CSL Receiver mode.
- Keep the CSL Period and Channel values in the MAC in order to use
  them as an indication of CSL Receiver mode in the Sub-Mac.
- Simplify CSL states with `mIsCslSampling` variable.
- Use a simplified interaction between MAC and SubMac:
  - `SubMac::UpdateCsl` for CSL config or stopping CSL sampling.
  - `SubMac::CslSample` for start/maintain CSL sampling.
2022-07-06 10:58:01 -07:00
Abtin Keshavarzian 2057ca8846 [cli] add helper method ParsePreference() (#7858)
This commit adds a helper method `ParsePreference()` to parse a given
CLI argument string as a route preference comparing it against "high",
"med", or "low". This commit also moves the `PreferenceToString()`
method from `Cli::NetworkData` to `Cli::Interpreter` class.
2022-06-30 15:05:56 -07:00
Abtin Keshavarzian a8924f65f7 [routing-manager] get/set preference for RIOs in emitted RA messages (#7849)
This commit adds new mechanism in `RoutingManager` to allow user to
get or set the preference level to use when advertising Rout Info
Options (e.g., for discovered OMR prefixes) in RA messages sent on
infra netif. By default 'medium' preference is used. As an example,
user can choose to set the preference to 'low' when the device is
acting as a temporary BR (a mobile or battery-powered BR) to indicate
that other BRs should be preferred over this BR on the infra link.

This commit also adds CLI sub-commands for newly added APIs and
updates the documentation.
2022-06-30 12:49:49 -07:00
Abtin Keshavarzian ec8ff8f3b4 [instance] move definition of all OT core objects in Instance (#7842)
This commit moves all the OT core member variable definitions into
`Instance` class (from `ThreadNetif`).
2022-06-30 12:35:28 -07:00
Abtin Keshavarzian f2f98c565f [routing-manager] skip self-prepared RA when learning host RA header (#7846)
This commit updates how `RoutingManager` learns the RA header from
host daemons. It adds a new method to determine whether a received RA
message is prepared by the `RoutingManager` itself by checking the
options (PIO and RIO) from the RA message. When learning/updating the
host RA header, we check and skip over such self-prepared RA
messages.
2022-06-30 12:18:31 -07:00
Abtin Keshavarzian 0132362815 [netdata] wait for sync before accepting new data on leader restart (#7838)
This commit adds a new mechanism related to Network Data recovery on
leader after restart. We determine whether device is starting normally
as leader or restoring its role as leader after restart. In the
latter case, we do not allow the device to accept any new Network Data
registrations until it has successfully recovered the Network Data
(received MLE Data Response).

This change help address situation where Network Data entries
registered with leader before it syncs and restores the Network Data
can be removed and then take a while to be re-registered.
2022-06-30 09:49:27 -07:00
Yakun Xu 3b0a876b24 [cli] use snprintf instead (#7848)
To address a warning on some platforms.
2022-06-29 22:33:27 -07:00
Simon Lin 86e642379c [thci] configure backbone netif (#7804)
The backbone netif is always set to `eth0` in the original THCI. This
commit allows to configure backbone netif via THC parameter `Param8`.
2022-06-29 13:32:00 -07:00
Eduardo Montoya b058ea4e17 [dua] allow MTD to handle ADDR_ERR.ntf messages (#7844)
An MTD interface should be able to handle Address Error Notifications
as per Thread Specification section 5.6.4.
2022-06-29 11:11:46 -07:00
Mason Tran 902f295b31 [cmake] add option for RCP specfific mbedtls library (#7847) 2022-06-29 11:09:51 -07:00
Sarah 4747a9c776 [docs] add Doxygen support for CLI comments (#7749) 2022-06-28 16:44:39 -07:00
Abtin Keshavarzian f561b44586 [routing-manager] discover and publish default route (#7839)
This commit updates `RoutingManager` to discover and publish default
route entries. It updates `DiscoveredPrefixTable` to track which
routers provide default route when processing the received RA
messages. A router can indicate that it provides default route in the
RA message header and it can also include an RIO for "::/0". When
processing the RA message, the preference and lifetime values in a
"::/0" RIO override the preference and lifetime values in the RA
header.

While `DiscoveredPrefixTable` will always track default routes, only
if we see an OMR prefix with default route flag in the Network Data,
we allow it to publish the discovered default route (as "::/0"
external route) in the Network Data. Finding such an OMR prefix
indicates that this prefix is routable beyond the infra link and
therefore default routes can be published and used within Thread
mesh.
2022-06-28 11:36:35 -07:00
JaneFromSilabs 7576306553 [thci] support 1.3 border router configurations (#7826)
Adding support for 1.3 style border router configurations which are
different from the 1.2 style border router configurations.  The
'device capabilities' is used to differentiate between these 2 device
types to assign them their needed configuration parameters.

Also moving restartAgentService to the proper class.
2022-06-28 09:32:39 -07:00
Abtin Keshavarzian ba7d5f1b94 [ip6] use Array in Ip6::Filter (#7843)
This commit updates `Ip6::Filter` to use `Array` to track the
unsecure ports.
2022-06-28 08:42:49 -07:00
Abtin Keshavarzian 827006b2e2 [routing-manager] track discovered entries per router in prefix table (#7830)
This commit updates the data model used by `DiscoveredPrefixTable` in
`RoutingManager` to track the router which added each prefix entry.
This change ensures correct behavior when multiple routers on the
infra link advertise the same set of prefixes. The routers can
potentially advertise the same prefixes (in RIOs) with different
preference levels and/or stop/start advertising the prefixes
independently of each other. We publish the prefixes in Network Data
with highest seen preference. The published entries in Network Data
are also updated as the table entries changes.
2022-06-28 08:37:19 -07:00
Eduardo Montoya dbcebd2ed4 [mle] reuse ScheduleChildUpdateRequest where possible (#7841) 2022-06-27 20:14:53 -07:00
Abtin Keshavarzian 733750b3de [mle] handle rx key seq update based on MLE message class (#7672)
This commit implements new mechanism in `Mle` related to key sequence
update when an MLE message is received with a larger key sequence
compared to the one being used by `KeyManager`. The MLE messages are
categorized into classes of Authoritative, or Peer depending on the
MLE command type and included TLVs. The class determines different
actions: Authoritative indicates sender is confident that its key seq
is in sync, so receiver will adopt the larger key seq. Peer class is
used when both sender and receiver think they are in sync. In this
case, if the MLE message is from a known neighbor, receiver will
adopt the larger key seq if the difference is one, otherwise it will
try to re-establish link with the neighbor using Authoritative
message exchanges (e.g. sending Link Request or Child Update
Request).
2022-06-24 12:21:04 -07:00
Abtin Keshavarzian f4c2233527 [thread-tlvs] define min/max num of addrs under Ip6AddressesTlv (#7834)
This commit moves the definitions of constants related to min/max
number of IPv6 addresses that can be included in an IP6 Addresses TLV
to `Ip6AddressesTlv` class. It also adds a public OT constant in
`ip6.h` related to this for MLR feature which is then used in `cli`
and `ncp` modules so to avoid the use of OT core internal constant
from CLI/NCP.
2022-06-24 08:37:58 -07:00
Abtin Keshavarzian 747e20cc54 [script] fix multiple LOG_OUTPUT definitions (#7833)
This commit updates `check-simulation-build-autotools` to use the
`LOG_OUTPUT` switch directly. This addresses an issue where
we could end up with multiple `OPENTHREAD_CONFIG_LOG_OUTPUT`
definitions in the `CPPFLAGS`.
2022-06-23 21:22:41 -07:00
Abtin Keshavarzian 0bf370c22a [owning-list] fix typos (#7831) 2022-06-23 17:52:25 -07:00
Abtin Keshavarzian dff9111d0c [array] add RemoveAllMatching() (#7829)
This commit adds a new method in `Array` to remove all elements
in the array matching a given indicator.

This commit also updates `test_array.cpp` unit test to validate
the behavior of the newly added method.
2022-06-23 07:35:28 -07:00
Abtin Keshavarzian 5cfbcfcbf4 [netdata] update Publisher to allow change to previous entries (#7827)
This commit updates `NetworkData::Publisher` so that a call to
`PublishOnMeshPrefix()` or `PublishExternalRoute()` replaces a
previous request for the same prefix. In particular, if the new call
only changes the flags (e.g., preference level) and the prefix is
already added in the Network Data, the change to flags is immediately
reflected in the Network Data. This ensures that existing entries in
the Network Data are not abruptly removed. Note that a change in the
preference level can potentially later cause the entry to be removed
from the Network Data after determining there are other nodes that
are publishing the same prefix with the same or higher preference.

This commit also updates `test_netdata_publisher.py` to test the newly
added behavior.
2022-06-22 14:17:28 -07:00
Abtin Keshavarzian 64e837861f [netdata] add feature for BR to request router role upgrade (#7597)
This commit adds a new mechanism to allow border routers to request
router role upgrade.

A border router which provides IP connectivity (either adding an
external route prefix or an on-mesh prefix with default route flag)
and is acting as a REED is eligible to request a router role upgrade
by sending an "Address Solicit" request to leader with status reason
`BorderRouterRequest`. This reason is used when the number of active
routers in the Thread mesh is above the threshold, and only if the
number of existing eligible BRs (determined from the network data)
that are acting as router is less than two. This mechanism  allows up
to two eligible border routers to request router role upgrade when
the number of routers is already above the threshold.

This commit also adds a new test-case `test_br_upgrade_router_role`
which validates the behavior of the new mechanism.
2022-06-22 11:45:30 -07:00
Dong Jiachen 4164a5029d [posix] remove used variables (#7828) 2022-06-22 11:27:26 -07:00
Abtin Keshavarzian 7e4d4d5cc1 [routing-manager] add DiscoveredPrefixTable (#7821)
This commit introduces `DiscoveredPrefixTable` class as a nested type
in `RoutingManager`. This class maintains the on-link and route
prefixes which are discovered by processing the received Router
Advertisement messages. It manages the lifetime of the discovered
prefixes (running a timer and removing entries when they expire). It
also handles publishing and unpublishing the prefixes in the Thread
Network Data as they are added and removed.

When there is any change in the table (an entry is added, removed,
or modified), it signals this through a callback to `RoutingManager`
which can then take action and decide whether or not to re-evaluate
the routing policy. A `Tasklet` is used for signalling which ensures
that if there are multiple changes within the same flow of execution,
the callback is invoked after all the changes are processed.

The change in this commit simplifies the overall `RoutingManager`
code by abstracting away the prefix table management into its own
class and allows us to hide the internal data model used for storing
the discovered prefixes.
2022-06-21 15:53:28 -07:00
Abtin Keshavarzian 2bc87ce157 [netdata] simplify Publisher to use HandleServerDataUpdated() (#7823)
This commit simplifies `NetworkData::Publisher` to rely and use the
new `HandleServerDataUpdated()` behavior which uses a `Tasklet` to
start the registration with leader. With this, we can directly call
`HandleServerDataUpdated()` whenever there is a change and even
multiple times during processing from `Publisher` while ensuring that
all changes are still registered together.
2022-06-21 09:55:20 -07:00
Abtin Keshavarzian ea611dc1f1 [netdata] perform SynchronizeServerData() from a Tasklet (#7823)
This commit adds a `Taskelt` in `NetworkData::Notifier` to perform
`SynchronizeServerData()` and post this tasklet when there is a
change and `HandleServerDataUpdated()` is called. This ensures that
if there are multiple changes triggered within the same flow of
execution, they are all synchronized together and included in the
same message to register with leader.
2022-06-21 09:55:20 -07:00
Abtin Keshavarzian 481a064f03 [ip6] update Ip6::Prefix comparison (#7813)
This commit updates `Ip6::Prefix` comparison (overload of `<`
operator). If the two prefixes have same length N, then the bytes are
compared directly (as two big-endian N-bit numbers). If the two
prefix have different lengths, the shorter prefix is padded by `0`
bit up to the longer prefix length N before the bytes are compared
(as big-endian N-bit numbers). If all bytes are equal, the prefix
with shorter length is considered smaller.

This commit also updates `test_ip_address` unit test to validate
the new comparison behavior.
2022-06-16 21:28:08 -07:00
Abtin Keshavarzian 16ddb157d0 [dns-dso] use Array::RemoveMatching() (#7817) 2022-06-16 21:26:03 -07:00
Abtin Keshavarzian aad14e9f2f [array] add Remove() and RemoveMatching() (#7817)
This commit adds `Remove/RemoveMatching()` in `Array` class which
remove a given or a matched element from the array. To remove the
element, it is replaced by the last element from array, so the order
of items in the array can change after call to these method.

This commit also updated unit test `test_array` to verify the behavior
of newly added methods.
2022-06-16 21:26:03 -07:00
Abtin Keshavarzian a5d39c3ec3 [routing-manager] fix calculation if an entry's stale time is in past (#7818)
This commit updates the calculation of the next stale time in
`ResetDiscoveredPrefixStaleTimer()` in (unlikely) cases where the
stale time of a discovered prefix or RA header happens to be in past
(compared to `GetNow()`). In such a case, we use `now` as the stale
time of the entry. This then ensures that the we can correctly
compare the stale time with `now.GetDistantFuture()`.
2022-06-16 21:22:02 -07:00
Simon Lin c055c10a9a [routing-manager] self-generated OMR prefix to use P_preference=Low (#7802) 2022-06-16 19:42:10 -07:00
Abtin Keshavarzian d5926a2445 [mle] refactor Tx/RxMessage method definitions (#7812)
This commit is a cosmetic change and contains no change in the code
logic. It is a follow-up from #7689 which added `Mle::Tx/RxMessage`
types. This commit moves all `TxMessage` and `RxMessage` method
definitions close to one another (at the end of `mle.cpp`).
2022-06-15 13:35:40 -07:00
Abtin Keshavarzian 49b9846632 [routing-manager] simplify RA message parsing and preparation (#7789)
This commit adds a new class `RouterAdvertMessage` representing an RA
message. It provides methods to append options (PIO or RIO) to the RA
message or parse and iterate over the options in the RA message
(using newly added `Option::Iterator` which allows use of range-based
`for` loop). These method are used by `RoutingManager` and help
simplify the code.
2022-06-14 21:58:35 -07:00
Simon Lin b7c2c52d5c [thci] wait for netdata to stabilize if BORDER_ROUTING is enabled (#7798)
A BR with `BORDER_ROUTING` feature may add OMR prefix and external
routes to the network data when Thread is started.  The network data
changes may incur additional Thread communications that may interfere
with certification traffic.

This commit enhances THCI to wait for the network data to stabilize
after the BR is started.
2022-06-14 20:11:27 -07:00
Abtin Keshavarzian ac62f7819c [border-router] use Ip6::Nd namespace for IPv6 Neighbor Discovery (#7780)
This commit uses `Ip6::Nd` namespace for IPv6 Neighbor Discovery
definitions (used for border router). It also renames and moves
the source files to `net/nd6.*`.
2022-06-14 12:26:18 -07:00
Abtin Keshavarzian 19f8033b78 [srp-server] validate sub-types and treat as atomic (#7795)
This commit updates `Srp::Server` to treat the update instructions in
a received SRP message for a service and all its sub-types as atomic.
It adds a new method `ValidateServiceSubTypes()` which performs two
checks. First, it verifies that there is a matching base service for
all sub-type services in a received SRP Update message. Second, it
treats the sub-types in the message as atomic, i.e., whatever
information appears in the message is considered the entirety of
information about the service and its sub-types. In particular, any
previously registered service sub-type that does not appear in a new
SRP Update is removed (marked as deleted).

This commit updates `test_srp_sub_type.py` test-case to validate the
behavior of newly added mechanism (i.e. removal of older sub-types
when not present in the new SRP update message).
2022-06-13 10:56:42 -07:00
JaneFromSilabs d0a7147165 [thci] add support for Thread Version 4 (1.3) (#7806) 2022-06-13 10:36:54 -07:00
Jonathan Hui abad2f2cc1 [docs] remove linkquality from src/cli/README.md (#7810) 2022-06-13 10:35:18 -07:00
Simon Lin edbb07d95f [tests] verify a Router can establish links quickly via multicast Link Request (#7807)
This commit adds a test to make sure delay sending multicast Link
Request (#7745) works as intended.
2022-06-13 09:54:57 -07:00