IPv4 packet header codec

Files
README.md

nox-ip #

Warning. This is a work-in-progress experimental fork of mirage-tcpip. Do not use it in production; use mirage-tcpip instead.

IPv4 and IPv6 packet headers in pure OCaml, and an Eio IP layer over Ethernet.

Ip.V4 encodes and decodes the IPv4 header of RFC 791 with its options and its RFC 1071 checksum; Ip.V6 does the same for the fixed IPv6 header of RFC 8200 and steps over its extension-header chain. Both compute the pseudo-header that UDP and TCP checksums cover, and both encode to a zero-copy rope, so a payload reaches the device without being copied. Field handles on the wire-level header let a NAT rewrite an address or a TTL in place and patch the checksums incrementally (RFC 1624).

Ip.Reassembly puts fragments back together with the hole descriptors of RFC 815, for IPv4 (RFC 791, RFC 1122 section 3.3.2) and IPv6 (RFC 8200 section 4.5, with the RFC 5722 overlap rule), in a table bounded per source and in total, with a 60 s timeout.

The nox-ip-eio library runs these codecs over an Ethernet layer: IPv4 with ARP, IPv6 with Neighbor Discovery, or both on one device, and IPv4 over a point-to-point carrier of whole datagrams. Both layers reassemble fragments before any transport sees them, and IPv4 sends atomic datagrams, with Don't Fragment set (RFC 6864).

Installation #

Install with opam:

$ opam install nox-ip

If opam cannot find the package, it may not yet be released in the public opam-repository. Add the overlay repository, then install it:

$ opam repo add samoht https://tangled.org/gazagnaire.org/opam-overlay.git
$ opam update
$ opam install nox-ip

Credits #

Forked from mirage/mirage-tcpip, originally by Anil Madhavapeddy, Mindy Preston, and the MirageOS team, released under the ISC license. The cstruct codec is replaced by the wire library and the C checksum by nox-crc's Crc.internet_checksum. The original copyright notices are preserved in LICENSE.md.

License #

ISC