The P2P peer can be woken up using the wake-up identifier. The wake-up identifier
is included in the Connection IE. This commit implements methods to the Connection IE
and Frame to process wake-up identifier.
This commit updates `TxFrame::Info` to include `mCommandId`, used when
the frame type is `kTypeMacCmd`. This allows callers to specify the
Command ID when preparing a MAC Command `TxFrame`. With this change
`Frame::SetCommandId()` is no longer used or needed so it is
removed.
Recent changes updated `Mac::Frame` to use `FrameBuilder` for
preparing frame headers. With the adoption of this model, the
previously defined `Set` methods for setting source/destination
address or PAN ID are no longer used or needed. This commit removes
them.
This commit updates `TxFrame::GenerateWakeupFrame()` to utilize the
`FrameBuilder` class for constructing frame header fields.
It also updates the `TestMacWakeupFrameGeneration()` unit test in
`test_mac_frame.cpp`:
- Uses source and destination address constants that are not reversible
to validate that extended addresses are appended in the correct byte
order.
- Includes minor style changes (renames constants and uses lowercase
hexadecimal digits for consistency).
This commit simplifies the preparation of MAC and security frames. It
introduces a `TxFrame::Info` structure that provides information
about the frame, such as its type, version, source and destination
addresses, PAN IDs, security level, and key ID mode. A new method
`PrepareHeadersIn()` is added, which uses the `Info` structure to
construct the MAC address and security headers in a given `TxFrame`.
This approach replaces the earlier `Mac::Frame::InitMacHeader()` where
all the information was passed as a list of input arguments. The
`TxFrame::Info` approach simplifies the code and allows for future
extension to accommodate other parameters (e.g., Header IE entries).
1. Add OT_WAKEUP_COORDINATOR and OT_WAKEUP_END_DEVICE build
options.
2. Add support for parsing and constructing 802.15.4
Multipurpose frames.
3. Add support for parsing and constructing wake-up
frames.
This commit updates unit test modules to be defined under the `ot`
namespace. This aligns all the unit tests to follow the same
model, eliminating the need to use `ot::` prefix in unit test
code.
This commit updates the `GenerateEnhAck()` method to add checks to
validate the received frame before preparing the ACK. These checks
are added as a safeguard in case the caller (radio platform
implementation) does not validate the received frame before calling
this method to generate the ACK.
Specifically, the checks verify that the received frame is using the
2015 version, has the "Ack Request" flag, has a valid source address
(which is used as the destination in the generated ACK), and has a
valid destination address that is not broadcast. The checks also
verify that if the received frame is secured, it uses security level
`kSecurityEncMic32`.
The commit also simplifies the code by using `InitMacHeader()` to
prepare the header and addresses. Enhanced ACK frames always have a
destination address and no source address (to keep the frame
shorter). If the received frame has a source PAN ID, it is used in
the ACK frame. If it does not, the code checks if the received frame
has a destination PAN ID and uses that in the ACK frame.
This commit updates the `InitMacFrame()` method to allow the caller to
specify whether the source or destination PAN IDs are present or not.
It also handles all cases related to PAN ID compression as defined by
IEEE 802.15.4-2015. While these cases are not used by the Thread
stack itself, adding them to `InitMacFrame()` makes it more capable
allowing future use-cases of this method such as generating enhanced
ACKs based on a received frame.
The `test_mac_frame` unit test has been updated to cover the newly
added cases.
This commit updates how we prepare the MAC headers:
- New `enum`s are defined in `Mac::Frame` to specify the frame
`Type`, `Version`, `SecurityLevel`, etc.
- `InitMacHeader()` will itself determine the Frame Control Field
from the given address info.
- It now uses `FrameBuilder` to prepare the headers.
- New helper `MeshForwarder::PrepareMacHeaders()` is added which
takes care of adding MAC (address, security header) along with
any IE headers.
- These changes ensure that PAN ID Compression bit is properly
set on MAC frames when using 2015 version (ensure that PAN
IDs are not omitted when both addresses use Extended format).
This commit fixes the `NetworkName` check (for its length to be larger
than zero) which was recently added in commit e2f0afab5d. This commit
moves the name length check to method `Set(const NameData &aNameData)`
and after the `newLen` is calculated.
This commit also updates `TestMacNetworkName()` in unit test to verify
that setting the network name to an empty string correctly fails with
`kErrorInvalidArgs`.
This commit updates `VerifyOrQuit()` and `SuccessOrQuit()` macros to
include the failed condition in the error message that is printed on
a failure (in addition to function name and line number where the
error happened). This commit also changes the second parameter
(`aMessage`) to in these macros to be optional.
This commit also updates unit tests to remove the second `aMessage`
string in cases where the failure can be inferred from the condition
itself.
This commit contains a small fix in `Mac::ChannelMask::ToString()`
string output (e.g, return `{ 11-26 }` instead of `{ 11-26}`). This
commit also updates the unit test to follow naming style and verify
the `ToString()` behavior.
This commit adds a new core header files `common/error.hpp` which
defines `ot::Error` (mirroring `otError`) and `kError{Name}` constants
(mirroring the public `OT_ERROR_{NAME}` definitions). The new (C++
style) definitions are used by core modules. This commit also moves
`otThreadErrorToString()` (from `logging.hpp` to `error.hpp`) and
renames it to `ErrorToString()` which is used as the internal (to
core) function to covert an `Error` to a string.
This commit refactors the code to set frame version, IE present field
in frame control field and to append Header IE.
- Split UpdateFrameControlField into two methods: CalcIePresent and
CalcFrameVersion. Currently UpdateFrameControlField` is not
easy-to-read and hard to extend the method to handle more cases.
- Move this code from Mac to MeshForwarder. I think it should be
MeshForwarder's responsibility (PrepareDataFrame) to prepare the
frame (though Mac sometimes prepare data frames itself). Since when
preparing the frame, most information comes from the Message which
is only in MeshForwarder, we can put this code for preparing frame
in MeshForwarder.
- Enhance the way to append Header IEs to the frame. Currently in
Mac::AppendHeaderIe, it generates a list of HeaderIe first and then
call Frame::AppendHeaderIe. There are two problems here: 1. it uses
another copy (copy HeaderIe to the frame's buffer). 2. it has to
initialize Vendor IE (e.g. TimeSync IE) after Vendor IE header has
been copied to the buffer. Currently it directly finds the first
Vendor IE in the buffer and initialize it as TimeSync IE, which is
not extensible. This commit shifts the responsibility of 'how to
append the IE' to Frame, by providing AppendHeaderIeAt method. And
MeshForwarder can decide which IEs to append and directly call the
method to append IEs to the frame.
This commit adds support for multi radio links in OpenThread core.
A set of `OPENTHREAD_CONFIG_RADIO_LINK_*` definitions (in header
`config/radio_link.h`) determines the supported radio link types.
This commit adds a new class `RadioSelector` which selects the radio
link for each message transmission. Per neighbor it tracks the
supported radio types and a preference value for each type.
`RadioSelector` updates the preference value based on the history of
rx/tx events with the neighbor, e.g., a successful tx on a radio link
increases the preference, whereas a failed tx attempt decreases it.
A new class `Mac::Links` is added defining a layer between `Mac` and
different radio links (e.g., `SubMac` for 802.15.4 radio type).
Broadcast frames are sent in parallel over all radio links. A unicast
transmission is sent over a single radio link at a time but on a tx
failure it may be retransmitted over other radio links.
This commit also adds the concept of deferred ack, allowing radio
links report status of ack at a later time through a different
callback.
In current Mac::Frame implementation, when the frame is a Mac command,
the CommandId is always not included as its private payload, which
means we won't encrypt the CommandId.
In most cases the Private Payload(things we need to encrypt) shall be
set to the MAC Payload field(For Mac cmd, this field includes
CommandId, shown in Figure 7-17) and the Open Payload shall be
empty. The only 2 exception cases are listed in Table 9-1.
So for Mac command with version >= 2, its CommandId should be included
in Private Payload and should be encrypted when necessary. For Mac
command with version < 2, CommandId should be in included in Open
Payload and shouldn't be encrypted.
This commit fixes this problem and adds unit tests for this.
- Existing code assumes security is always enabled in enhanced ack,
however that's not always the case. So add security part only when
it's required.
- FindHeaderIeIndex would return kInvalidIndex when IE is not
present. It's possible that no IE is in an enh ack, so use
SkipSecurityHeaderIndex instead.
This commit adds mac frame util functions to generate acks (both Imm
and Enh acks) from a received frame. These funtions are utils APIs for
platforms which don't provide ack generation.
This commit also introduces compile options for CSL to control the CSL
IE related part.
This commit enhances some utility functions in mac frame for frame
parsing and adds some basic testing.
- Currently the mac frame parsing only doesn't include the rule for
version 2015. This commit adds the parsing of dstPanId for 2015
frames.
- This commit adds some helper function dealing with Security Header
so that later commit of CSL and setting security header in enhanced
ACK would be easier.
This commit removes the extra `\n` at the end of error message strings
used in `VerifyOrQuit()` or `SuccessOrQuit()` macros in different unit
test modules. This help make the style (usage of macros) consistent
across all unit tests.
This commit adds `Mac::NetworkName` class as C++ wrapper over the
`otNetworkName`. It also adds `NetworkName::Data` to represent the
network name as a pointer to a char array buffer (not necessarily null
terminated) with a given length. This representation is used by
`Mac::BeaconPlayload` and `MeshCop::NetworkNameTlv`. This commit also
adds a unit test for `Mac::NetworkName` class.
This commit updates `Mac::ExtAddress` and `Mac::Address` to add
helper methods to copy address from/to a byte array in normal or
reverse bye order. This commit also adds a unit test for the two
Address classes.
This commit renames existing `phy` folder into `radio`. It also
renames some of the related files in this folder. It also moves
all default/weak `otPlatRadio` implementations to a common
`radio_platform_defaults.cpp` file.
This commit defines RxFrame for receiving frames and TxFrame for
transmitting frames. The motivation is to prevent invalid uses of
Mac::Frame methods, because some of them are only available for rx
frames and some only for tx frames.
OpenThread network-wide time synchronization service is an experimental feature, not part of the standard Thread protocol.
Feature Overview:
* All the nodes in the same Thread partition sync to the same Thread network-wide time;
* Microsecond level time synchronization precision;
* Flexible time accuracy and time sync period configuration;
* APIs for application layer use case, support both CLI and NCP version.
The feature is wrapped by OPENTHREAD_CONFIG_ENABLE_TIME_SYNC, there's no change to current Thread 1.1
implementation if OPENTHREAD_CONFIG_ENABLE_TIME_SYNC is not enabled.
If OPENTHREAD_CONFIG_ENABLE_TIME_SYNC is enabled, the node could:
* Attach to a time sync enabled network, otherwise
* Attach to a standard Thread 1.1 network, otherwise
* Form a new time sync enabled network
In addition, if OPENTHREAD_CONFIG_TIME_SYNC_REQUIRED is also enable, the node could only:
* Attach to a time sync enabled network, otherwise
* Form a new time sync enabled network
Note:
Currently, the feature is only supported on nRF52840 and posix platforms. And the network time
is only synced among Routers and REEDs, the SEDs will be supported later as an optional feature.
This commit adds a new template class `ot::String<size>` which
implements a fixed-length character string. This class is then used as
return value of `ToString()` methods from different classes. This
simplifies the `ToString()` implementation and its use. This commit
also adds a unit test for `String`.
This commit adds a new feature/class namely `AnnounceSender` which
enables periodic transmission of MLE Announce messages on all
channels. The feature can be enabled using the config option
`OPENTHREAD_CONFIG_ENABLE_ANNOUNCE_SENDER` (disabled by default).
This commit also adds some new helper methods in `Mac::ChannelMask`
to get number of channels in a given mask, and operator overloads
to compare two masks.
This commit adds a `Mac::ChannelMask` class to define a channel (a
`uint32_t` bit-vector specifying a set of channels). The `ChannelMask`
class provides methods to add/remove channel to the mask, intersect
two masks, and iterate through the channels in the mask. A unit test
for the new class is also added.
This commit new configuration option `enable-multiple-instances` and
its corresponding option `OPENTHREAD_ENABLE_MULTIPLE_INSTANCES`. When
enabled OpenThread supports handling of multiple instances. By default
this is disabled.
This commit also adds two optimizations for single instance case to
simplify the code and also help reduce memory/RAM usage:
(1) OpenThread objects/classes typically keep a reference to a higher
level object (e.g., many classes keep track of owning `ThreadNetif`)
to be able to access other objects/methods within OpenThread class
hierarchy. In single instance mode, the reference member variables are
removed and instead global functions are used to access the singleton
objects from one class to the other. To implement this, a group of
`<Object>Locator` classes are defined (e.g., `ThreadNetifLocator`,
etc.) which are then used as base class of other OpenThread classes.
(2) OpenThread objects which provide a callback/handler (e.g.,
`Timer`, `Tasklet`, etc.) have `void *mContext` member variable which
is used to keep track of the owner of the object. In single instance
mode the `mConext` member variables are removed since the owner is
expected to be a singleton and can be uniquely determined from the
callback function.
To implement this, two changes are made: First the handler methods are
modified to provide a reference to the object (e.g., `Timer` handler
will provide a `Timer &aTimer` as a parameter of its handler
callback). Second, a new base class `Context` is introduced which
hides the implementation providing an arbitrary context information. A
new static method `GetOwner(aContext)` is added to classes which own a
callback providing objects. This method help convert a `Context` to
the reference of the owner class object.