Skip to main content

L2 - Network layer

The Layer 2 (Network Layer) acts as the great equalizer for the NSLP stack, responsible for taking potentially large Transport Layer (L3) payloads and segmenting them into strict, predictable Network MTUs (Maximum Transmission Units). Because the overall NSLP packet size is strictly capped at 255 bytes to accommodate highly constrained mediums (e.g., LoRa, CAN), L2 ensures that no single data payload exceeds the 250-byte limit. When an L3 payload surpasses this boundary, L2 automatically slices the data into sequential chunks, isolating the upper transport protocols from these rigid, network-level size constraints.

Overview

To manage this fragmentation seamlessly, L2 encapsulates each chunk with the standardized 5-byte NSLP routing header. By utilizing the Sequence Number alongside the Source address and Destination addresses, the transmitting L2 carefully tracks the fragmented data stream. On the receiving end, the Network Layer intercepts these distinct packets, uses the sequence numbers to validate their order, and reassembles the complete, contiguous L3 payload (e.g., SL-TCP or SL-UDP) before passing it up the stack. This guarantees that whether a payload requires one packet or one hundred, the Transport Layer only ever sees a single, intact data transmission.

NSLP Packet

While the exact bit-level arrangements are dictated by the specific hardware medium, every Layer 1 implementation fundamentally acts as a protective envelope around your data. It wraps the standard Layer 2 packet with medium-agnostic transmission data such as size and sequence number (which can be helpful for packet reassembly).

General structure

01
0123456789101112131415
VersionProtocolSource Address
Destination AddressSequence number
SizeData (Byte 0)
Data (Bytes 1 - 249)

Fields

  • Version (4 bits): The version of the NSLP protocol stack in use. Underlying implementations may parse packets differently based on this field.

    note

    The current latest version is 0x01.

  • Protocol (4 bits): The identifier of the encapsulated Layer 2 protocol payload.

  • Source Address (8 bits): The unique network identifier of the device transmitting the packet.

  • Destination Address (8 bits): The unique network identifier of the intended recipient device.

  • Sequence Number (8 bits): Tracks the order of packets. If the underlying medium has a limited payload size requiring fragmentation, this field ensures the NSLP packet is reassembled in the correct order on the receiving side.

  • Size (8 bits): The exact size of the data payload.

    info

    Many underlying mediums have strict size constraints (e.g., LoRa, CAN). To accommodate this, we designed the packet to max out at 255 bytes total. With a 5-byte header, this allows for a maximum payload size of 250 bytes.

  • Data (up to 250 bytes): The actual L2 payload being securely delivered across the network.