Skip to content

A compact implementation of the Cyphal/UDP protocol in C for high-integrity real-time embedded systems

License

Notifications You must be signed in to change notification settings

OpenCyphal/libudpard

Repository files navigation

Compact Cyphal/UDP in C

Main Workflow Reliability Rating Coverage Forum

LibUDPard is a compact implementation of the Cyphal/UDP protocol in C99/C11 for high-integrity real-time embedded systems.

Cyphal is an open lightweight data bus standard designed for reliable intravehicular communication in aerospace and robotic applications via CAN bus, UDP, and other robust transports.

We pronounce LibUDPard as lib-you-dee-pee-ard.

Features

Some of the features listed here are intrinsic properties of Cyphal.

  • Full branch coverage and extensive static analysis.

  • Compliance with automatically enforceable MISRA C rules (reach out to https://forum.opencyphal.org for details).

  • Detailed time complexity and memory requirement models for the benefit of real-time high-integrity applications.

  • Purely reactive time-deterministic API without the need for background servicing.

  • Zero-copy data pipeline on reception -- payload is moved from the underlying NIC driver all the way to the application without copying.

  • Support for redundant network interfaces with seamless interface aggregation and no fail-over delay.

  • Out-of-order multi-frame transfer reassembly, including cross-transfer interleaved frames.

  • Support for repetition-coding forward error correction (FEC) for lossy links (e.g., wireless) transparent to the application.

  • No dependency on heap memory; the library can be used with fixed-size block pool allocators.

  • Compatibility with all conventional 8/16/32/64-bit platforms.

  • Compatibility with extremely resource-constrained baremetal environments starting from 64K ROM and 64K RAM.

  • Implemented in ≈2000 lines of code.

Usage

The library implements the Cyphal/UDP protocol, which is a transport-layer entity. An application using this library will need to implement the presentation layer above the library, perhaps with the help of the Nunavut transpiler, and the network layer below the library using a third-party UDP/IP stack implementation with multicast/IGMP support (TCP and ARP are not needed). In the most straightforward case, the network layer can be based on the standard Berkeley socket API or a lightweight embedded stack such as LwIP.

%%{init: {"fontFamily": "Ubuntu Mono, monospace", "flowchart": {"curve": "basis"}}}%%
flowchart TD
    classDef OpenCyphal color:#00DAC6,fill:#1700b3,stroke:#00DAC6,stroke-width:2px,font-weight:600
    Application <-->|messages,\nrequests,\nresponses| LibUDPard[fa:fa-code LibUDPard]
    class LibUDPard OpenCyphal
    LibUDPard <-->|multicast datagrams| UDP
    subgraph domain_udpip["3rd-party UDP/IP+IGMP stack"]
        UDP <--> IP["IPv4, IGMPv1+"] <--> MAC
    end
    MAC <--> PHY
Loading

To integrate the library into your application, simply copy the files under libudpard/ into your project tree, or add this entire repository as a submodule. The library contains only one translation unit named udpard.c; no special compiler options are needed to build it. The library should be compatible with all conventional computer architectures where a standards-compliant C99 compiler is available.

Read the API docs in libudpard/udpard.h. For complete usage examples, please refer to https://github.com/OpenCyphal-Garage/demos.

Revisions

v1.0

Initial release.

About

A compact implementation of the Cyphal/UDP protocol in C for high-integrity real-time embedded systems

Resources

License

Stars

Watchers

Forks

Languages