Zero-copy read and write structures for handling IEEE 802.15.4 MAC frames.
Each reader contains the following functions:
new: Create a new reader.check_len: Check if the buffer is long enough to contain a valid frame.new_unchecked: Create a new reader without checking the buffer length.
The most important reader is the [Frame] reader, which is used to read a
full IEEE 802.15.4 frame. The reader provides the following functions:
frame_control: returns a [FrameControl] reader.sequence_number: returns the sequence number if not suppressed.addressing: returns an [AddressingFields] reader.auxiliary_security_header: returns an [AuxiliarySecurityHeader] reader.information_elements: returns an [InformationElements] reader.payload: returns the payload of the frame.
Reading a frame
For an incoming frame, use the [Frame] structure to read its content.
# use ;
# let frame: = ;
let frame = new.unwrap;
let fc = frame.frame_control;
let src_addr = frame.addressing.unwrap.src_address;
let dst_addr = frame.addressing.unwrap.dst_address;
assert_eq!;
let Some = frame.information_elements else ;
for payload in ie.payload_information_elements
Writing a frame
Work in progress!
Information Elements
The IEEE 802.15.4 standard defines a set of Information Elements (IEs) that
can be included in the frame. These IEs are used to provide additional
information about the frame, such as timestamping, channel hopping, and
more. The IEs are divided into two groups: Header IEs and Payload IEs.
Calling information_elements on a [Frame] reader returns an
[InformationElements] reader. The reader provides access to the Header and
Payload IEs, via the header_information_elements and
payload_information_elements functions.
Header Information Elements
The Header IEs are located in the frame header, and are used to provide information about the frame itself. The following IEs are defined in the standard:
- [
VendorSpecific] - [
Csl] - [
Rit] -
DsmePanDescriptor - [
RendezvousTime] - [
TimeCorrection] -
ExtededDsmePanDescriptor -
FragmentSequencecontextDescription - [
SimplifiedSuperframeSpecification] -
SimplifiedGtsSpecification -
LecimCapabilities -
TrleDescriptor -
RccCapabilities -
RccnDescriptor -
GlobalTime -
Da -
HeaderTermination1 -
HeaderTermination2
Payload Information Elements
The Payload IEs are located in the frame payload, and are used to provide information about the payload itself. The following IEs are defined in the standard:
-
Esdu -
Mlme: The MLME group contains a set of nested IEs. Callnested_information_elementsto get an iterator over the nested IEs. -
VendorSpecific -
PayloadTermination
Nested Information Elements
Some IEs contain nested IEs. The [NestedInformationElementsIterator]
provides an iterator over the nested IEs. The iterator is used to parse the
nested IEs.
The Nested IEs are split into two groups: Short and Long. The following short IEs are defined in the standard:
- [
TschSynchronization] - [
TschSlotframeAndLink] - [
TschTimeslot] -
HoppingTiming -
EnhancedBeaconFilter -
MacMetrics -
AllMacMetrics -
CoexistenceSpecification -
SunDeviceCapabilities -
SunFskGenericPhy -
ModeSwitchParameter -
PhyParameterChange -
OQpskPhyMode -
PcaAllocation -
LecimDsssOperatingMode -
LecimFskOperatingMode -
TvwsPhyOperatingMode -
TvwsDeviceCapabilities -
TvwsDeviceCategory -
TvwsDeviceIdentification -
TvwsDeviceLocation -
TvwsChannelInformationQuery -
TvwsChannelInformationSource -
Ctm -
Timestamp -
TimestampDifference -
TmctpSpecification -
RccPhyOperatingMode -
LinkMargin -
RsGfskDeviceCapabilities -
MultiPhy -
VendorSpecific -
Srm
The following long IEs are defined in the standard:
-
VendorSpecificNested - [
ChannelHopping]