Module capsules_extra::net::sixlowpan::sixlowpan_state
source · Expand description
6loWPAN (IPv6 over Low-Power Wireless Networks) is standard for compressing and fragmenting IPv6 packets over low power wireless networks, particularly ones with MTUs (Minimum Transmission Units) smaller than 1280 octets, like IEEE 802.15.4. 6loWPAN compression and fragmentation are defined in RFC 4944 and RFC 6282.
This module implements 6LoWPAN compression and reception, including compression, fragmentation, and reassembly. It allows a client to convert between a complete IPv6 packets and a series of Mac-layer frames, and vice versa. On the transmission end, IPv6 headers are compressed and packets fragmented if they are larger than the Mac layer MTU size. For reception, IPv6 packets are decompressed and reassembled from fragments and clients recieve callbacks for each full IPv6 packet.
§Usage
The Sixlowpan library exposes two different interfaces for the transmit path and the receive path. Below, both interfaces are described in detail.
§Transmit
For a layer interested in sending a packet, this library exposes a
TxState struct that statefully compresses an
IP6Packet struct. First, the TxState
object
is initialized for compressing a new packet by calling the TxState.init
method. The caller then repeatedly calls TxState.next_fragment
, which
returns the next frame to be send (or indicates that the transmission
is complete). Note that the upper layer is responsible for sending each
frame, and this library is only responsible for producing compressed frames.
§Receive
The Sixlowpan library is responsible for receiving and reassembling individual 6LoWPAN-compressed frames. Upper layers interested in receiving the fully reassembled and decompressed IPv6 packet implement the SixlowpanRxClient trait, which is called after a packet is fully received.
At a high level, clients interact with this module as shown in the diagrams below:
Transmit:
+-----------+
|Upper Layer|
+-----------+
| ^
| |
next_fragment(..packet..)
| |
v |
+---------+
|Sixlowpan|
+---------+
...
+---------------+
|SixlowpanClient|
+---------------+
^
|
send_done(..)
|
+---------+
|Sixlowpan|
+---------+
Receive:
+---------------+
|SixlowpanClient|
+---------------+
^
|
receive(..buf..)
|
+---------+
|Sixlowpan|
+---------+
Initialization:
+-----------+
|Upper Layer|
+-----------+
|
set_client(client)
|
v
+---------+
|Sixlowpan|
+---------+
§Examples
Examples of how to interface and use this layer are included in the file
boards/imix/src/lowpan_frag_dummy.rs
. Some set up is required in
the boards/imix/src/main.rs
file, but for the testing suite, a helper
initialization function is included in the lowpan_frag_dummy.rs
file.
Modules§
Structs§
- Tracks the decompression and defragmentation of an IPv6 packet
- Sends a receives IPv6 packets via 6loWPAN compression and fragmentation.
- Tracks the compression state for a single IPv6 packet.
Traits§
- Objects that implement this trait can set themselves to be the client for the Sixlowpan struct, and will then receive a callback once an IPv6 packet has been fully reassembled.