Protocol stacks are layered because each layer has a single responsibility and doesn't need to know about the layers above or below it. Understanding this at a deep level comes from building a protocol stack end-to-end, not just using one.

SpaceCAN's layers:

  • Application layer: Ground operator commands / telemetry display
  • PUS service layer: Service routing (ST[01], ST[03], ST[17]) and TC/TM semantics
  • Transport layer: Multi-frame fragmentation / reassembly, sequence numbering, timeout handling
  • CAN data link layer: Frame encoding/decoding, arbitration ID management, error frame handling
  • Physical layer: CAN-H / CAN-L differential signalling (STM32F4 bxCAN peripheral handles this)

Each layer communicates only with the layer immediately above and below. The PUS router doesn't know about CAN arbitration IDs. The fragmentation layer doesn't know about PUS service types. This isolation means:

  • You can test each layer independently
  • You can replace one layer (e.g., swap CAN for Ethernet) without changing the layers above
  • Bugs are localised — a fragmentation bug doesn't manifest as a PUS routing error

The hardest part of SpaceCAN was designing the boundary between the transport layer and the data link layer — specifically, which layer owns the reassembly buffer, and what happens on a reassembly timeout.