Skip to content

Space Packet Protocol CCSDS

r0r0x-xx edited this page Jul 4, 2026 · 3 revisions

04. Space Packet Protocol (CCSDS)

This section details the implementation of the core communication protocol used by FlatSat, which follows the standardized CCSDS Space Packet Protocol (SPP). This protocol allows the spacecraft to route data efficiently using Application Process Identifiers (APIDs), enabling modular subsystem addressing.


Technical Concept: CCSDS Space Packet Standard

The Space Packet Protocol is the structural standard utilized for communication between the ground station and the satellite, as well as between different onboard subsystems. Every packet transmitted or received over the RF link (Radio 0 and Radio 1) or the USB link (usbCDC) wraps the data into a standard frame structure.


Packet Encapsulation Structure

Every space packet processed by the system consists of a Primary Header (6 bytes) followed by a variable-length Data Field.

The structure of the packet is divided into the following fields based on the firmware's parsing logic:

1. Packet Identification (2 bytes)

  • Version: Identifies the version of the Space Packet Protocol.
  • Type (1 bit): Defines the direction or purpose of the traffic.
    • 0 represents Telemetry (TM) (data leaving the satellite to the ground).
    • 1 represents Telecommands (TC) (commands sent to the satellite).
  • APID (11 bits): The Application Process Identifier used to route the traffic to the correct subsystem handler.

2. Packet Sequence Control (2 bytes)

  • Segmentation Flags: Defines whether the packet is unsegmented, part of a sequence (START/CONTINUE), or the end of a block.
  • Sequence Count (14 bits): A sequential counter used to track and order incoming or outgoing packets.

3. Packet Length (2 bytes)

  • Data Length: Specifies the total length of the Data Field minus one.

APID Registry (Mission Control)

The firmware filters and categorizes all incoming and outgoing traffic into specific Application Process Identifiers. The internal commandApidHandler matches the extracted APID to route execution to the appropriate subsystem:

APID Function Traffic Type Subsystem / Payload Description
0x01 PING TC / TM Connectivity heartbeat / Acknowledgement (ACK).
0x02 RESET TC Triggers a hardware watchdog reboot via softwareReset().
0x04 THRUSTER TC / TM Set or Get power levels for thrusters T0/T1.
0x06 BROADCAST TC Broadcast messages handling (SPP_APID_TC_BROADCAST_MSG).
0x07 FLASH TC / TM Trigger fragmented image/firmware data transfer.
0x08 SEND_TM TM Standard periodic sensor telemetry frame transmission.

Processing and Parsing Flow

When a packet arrives or is generated, the firmware operates as a non-blocking state machine governed by the telemetryRadioWorker.

Packet Ingress & Unpacking

  1. Data enters the system via Radio 0 or the USB CDC line.
  2. The spp_unpack_packet routine is invoked to validate the incoming CCSDS header.
  3. The routine verifies version consistency, alignment, and checks the packet length against the received buffer size.
  4. If an error occurs during this phase, the system triggers a visual alert (8 yellow blinks on the NeoPixel LED) and aborts processing.
  5. If valid, the packet is sent to commandApidHandler to execute the subsystem action.

Core Infrastructure Protocols: The Flash Worker

A practical implementation of the Space Packet Protocol's segmentation capability is found within the telemetrySPPTransmitFlash routine. This routine demonstrates how large blocks of data or firmware images are moved over a constrained link by utilizing packet sequencing:

  • Fragmentation: The data block is split into sequential chunks of 16 bytes each.
  • Header Flags: Each chunk is packed into an individual SPP packet, where the primary header is updated with the respective segmentation tracking flags:
    • START for the first packet of the block.
    • CONTINUE for intermediate data segments.
    • END for the final terminating chunk.
  • Integrity Validation: A custom crc8_compute routine is applied to each individual 16-byte chunk during transit to ensure that data does not suffer corruption over the RF link.