Skip to content

A very small IP stack written in C2x which is intended for use on resource constrained microcontrollers. It provides at least enough to support UDP multicast required by Cyphal.

License

Notifications You must be signed in to change notification settings

OpenCyphal-Garage/libhypha

Repository files navigation

Hypha IP Stack

Hypha IP

Hypha IP is a tiny IP stack coded in C17/C23 which seeks to implement the bare minimum of features to enable libudpard to operate in a resource constrained environment.

Supported Features

  • Single Network Interface
  • Ethernet Multicast (01:00:5E:xx:xx:xx)
  • IPv4, no optional headers
  • IPv4 Checksum
  • IPv4 Multicast
  • UDP
  • IGMPv2 (Join/Leave)

Optional Features

  • Software MAC Filter (incomplete)
  • Software IP Filter (incomplete)
  • Preloading ARP cache (incomplete)
  • ARP Request/Response (incomplete)
  • UDP Checksum (incomplete)
  • ICMP Echo/Response (incomplete)
  • VLAN Tagging (incomplete)

Future Features

  • IPv6

User Requirements

Users will simply need to provide a set of functions with the following features:

  • an Ethernet PHY driver capable of receiving raw frames and sending the frames which Hypha IP fills in. Hypha IP assumes that the CRC32 is handled by the Ethernet PHY Driver or Peripheral Hardware.
  • A frame acquire and release mechanism. Users are free to use static or dynamic memory or DMA memory to implement this.
  • A printing function to enable debugging. The lack of a printing function indicates that the debugging is disabled.
  • A Monotonic Time source (in whatever granularity you wish).
  • A reporting function which can receive asynchronous error reports.

User Configurability

Users can statically configure Hypha IP in several regards

  • IP TTL using HYPHA_IP_TTL set to a number > 0
  • MTU Size using HYPHA_IP_MTU set to a number >= 64.
  • ARP Cache (define HYPHA_IP_USE_ARP_CACHE as 1 or 0) and ARP Cache Size (HYPHA_IP_ARP_TABLE_SIZE set to a number > 0)
  • IPv4 Checksum Enablement (HYPHA_IP_USE_IP_CHECKSUM set to true or false)
  • UDP Checksum Enablement (HYPHA_IP_USE_UDP_CHECKSUM set to true or false)
  • Ethernet MAC Filter (define HYPHA_IP_USE_MAC_FILTER to 1 or 0) and number of Filter Elements (HYPHA_IP_MAC_FILTER_TABLE_SIZE set to a number > 0)
  • Allow any IP Localhost into the stack (define HYPHA_IP_ALLOW_ANY_LOCALHOST to 1 or 0)
  • Allow any IP Broadcast into the stack (define HYPHA_IP_ALLOW_ANY_BROADCAST to 1 or 0)
  • Allow any IP Multicast into the stack (define HYPHA_IP_ALLOW_ANY_MULTICAST to 1 or 0)
  • Multicast IP Filter (define HYPHA_IP_USE_IP_FILTER to 1 or 0) and Number of Filter Elements (HYPHA_IP_IPv4_FILTER_TABLE_SIZE set to a number > 0)
  • Use VLAN (define HYPHA_IP_USE_VLAN as 1 or 0) and assign VLAN ID using HYPHA_IP_VLAN_ID set to a number between 0 and 2^12-1 inclusive.
  • Default expiration time for items to stay in the various Cache and Filters. Use HYPHA_IP_EXPIRATION_TIME which must be in the units of HyphaIpTimestamp_t.

Building

You can optionally add a CMAKE_INSTALL_PREFIX to indicate where you'd like to install the headers, libs, cmake, etc.

cmake -B build -S . -DCMAKE_INSTALL_PREFIX=../install
cmake --build build --target all

Installing

cmake --build build --target install

Testing

Using a host compiler, build

cmake -B build -S .
cmake --build build --target all
cmake --build build --target test

Coverage

Creates a coverage report on the Unity Test.

cmake -B build -S .
cmake --build build --target all
cmake --build build --target test
cmake --build build --target coverage
open build/coverage/coverage-hypha_ip_test/index.html

Documentation

doxygen documentation/Doxyfile
open build/documentation/html/index.html

References

Parent Forum post

About

A very small IP stack written in C2x which is intended for use on resource constrained microcontrollers. It provides at least enough to support UDP multicast required by Cyphal.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published