bundle#
Pure OCaml implementation of the IETF Bundle Protocol Version 7 (RFC 9171) for Delay-Tolerant Networking (DTN).
Overview#
Bundle Protocol is a store-and-forward messaging protocol designed for networks with intermittent connectivity, long delays, and high error rates. It's the foundational protocol for Delay-Tolerant Networking (DTN), used in:
- Deep space communications (NASA missions)
- Disaster recovery networks
- Remote sensor networks
- Challenged terrestrial networks
A "bundle" is a self-contained message that can be stored at intermediate nodes and forwarded when connectivity becomes available.
Features#
- Full RFC 9171 Bundle Protocol v7 implementation
- CBOR encoding/decoding using the
cbortlibrary - Support for all standard block types:
- Payload block
- Previous node block
- Bundle age block
- Hop count block
- Extension blocks
- CRC-16 X.25 and CRC-32C integrity checking
- Endpoint ID support (dtn: and ipn: schemes)
- Streaming I/O with bytesrw
Installation#
opam install bundle
Usage#
(* Create a bundle *)
let bundle =
Bundle.v
~source:(Bundle.Ipn (1L, 1L))
~destination:(Bundle.Ipn (2L, 1L))
~creation_timestamp:{ Bundle.time = 0L; seq = 0L }
~payload:"Hello, DTN!"
()
(* Encode to bytes *)
let encoded = Bundle.encode bundle
(* Decode from bytes *)
match Bundle.decode encoded with
| Ok decoded -> Printf.printf "Payload: %s\n" (Option.get (Bundle.payload decoded))
| Error e -> Printf.printf "Error: %a\n" Bundle.pp_error e
API#
Types#
Bundle.t- A complete bundleBundle.eid- Endpoint identifier (dtn:none, dtn:URI, ipn:node.service)Bundle.primary_block- Bundle primary blockBundle.canonical_block- Extension/payload blocksBundle.timestamp- Creation timestamp
Functions#
Bundle.v- Create a bundleBundle.encode/Bundle.decode- Serialize/deserializeBundle.payload- Extract payload dataBundle.previous_node/Bundle.bundle_age/Bundle.hop_count- Extract extension block data
Related Work#
- ION - NASA/JPL's production DTN implementation in C
- µD3TN - Lightweight C implementation for embedded systems
- DTN7 - Go/Rust implementations of BPv7
This implementation focuses on:
- Pure OCaml with minimal C dependencies
- Integration with the OCaml ecosystem (cbort, bytesrw)
- Type-safe API with comprehensive error handling
References#
- RFC 9171 - Bundle Protocol Version 7
- RFC 9172 - Bundle Protocol Security (BPSec)
- CCSDS 734.2-B-1 - CCSDS Bundle Protocol Specification
Licence#
ISC License. See LICENSE.md for details.