tiny.reticulum.wire
Defined in tiny.reticulum.
The byte layouts of one datagram on a mesh network, with a reader and a writer for each: the header and its flag bits, the byte that says what the payload is for, the digest that names the packet, the two shapes of the signed reply that says a packet arrived, and the payloads that open an encrypted session.
API (24)
Actions
Public operations.
decode: Reads a packet out ofbytes, for a caller splitting the bytes a network interface delivered into fields it can read, following Reticulum@1.5.0 RNS/Packet.py:243-271.encode: Writes the header and the payload intooutand returns the bytes written, for a caller writing a built packet into the buffer handed to a network interface, following Reticulum@1.5.0 RNS/Packet.py:178-239.encodedLengthheaderLength
Types and contracts
Public types and contracts.
Context: The header's last byte names what the payload is for: nothing in particular, one of the seven resource-transfer kinds, a cache request, a request or its response, a path response, a command or its status, a channel message, a keepalive, or one of the five link control values, following Reticulum@1.5.0 RNS/Packet.py:…DecodeErrorDestinationTypeEncodeErrorFlagsHeaderTypePacketPacketTypeTransportType
Namespaces
Public namespaces.
Values and defaults
Public values and defaults.
header_one_bytes: Nineteen bytes, the header shape that carries no transport id (the 16 bytes naming a node the packet passes through): the flags byte, the hop count, a 16-byte destination hash, and the context byte, for a caller working out where a payload starts behind the shorter of the two headers, following Reticulum@1.5.0 RNS/R…header_two_bytes: Thirty-five bytes, the header shape that carries a 16-byte transport id ahead of the destination hash, for a caller working out where a payload starts behind the longer of the two headers, following Reticulum@1.5.0 RNS/Reticulum.py:151.mtu: Five hundred bytes, the largest Reticulum datagram (packet) every Reticulum implementation accepts, for a caller sizing the buffer it reads a frame into and checking its own payload against this before building a packet, following Reticulum@1.5.0 RNS/Reticulum.py:93.pathfinder_hops: One hundred twenty-eight, the hop count at and above which a packet is refused, for a caller checking how far a packet has traveled before forwarding the packet again, following Reticulum@1.5.0 RNS/Transport.py:115.truncated_hash_bytes: Sixteen bytes, the width of a destination hash and of a transport id inside a header, for a caller sizing those fields in a header, following Reticulum@1.5.0 RNS/Reticulum.py:148.
Source
Source: lib/reticulum/src/root.zig:60
zig
pub const wire = @import("wire/root.zig");Source: lib/reticulum/src/wire/root.zig
zig
//! The byte layouts of one datagram on a mesh network, with a reader and a//! writer for each: the header and its flag bits, the byte that says what the//! payload is for, the digest that names the packet, the two shapes of the//! signed reply that says a packet arrived, and the payloads that open an//! encrypted session. That network is Reticulum, in which nodes find each other//! by broadcasting signed announcements and reach each other over any medium//! that moves bytes.//!//! Two programs that have never met have to agree on every byte of a 500-byte//! datagram, down to the order of the bits inside its first byte. The code that//! reads those bytes runs where memory is fixed before the program starts, so//! it works in buffers its caller owns and hands back slices of them. One//! packet needs one name that both ends and every node between them compute the//! same way, because a signed reply travels back naming the packet it answers.//!//! The bytes a device hands over are whatever the wire delivered, so a reader//! settles every length question before it indexes into them. A packet changes//! as it travels, because the hop count rises at every node and a node carrying//! it for someone else inserts sixteen bytes of its own ahead of the address. A//! field can arrive holding a value this release has no name for, and//! discarding it would break a peer running a newer build.//!//! The subtree follows Reticulum 1.5.0, the reference implementation, pinned to//! one upstream commit by the package README and the generated conformance//! corpus. What it takes from the reference is the field order, the bit//! positions, and the length rule of each layout, and each declaration names//! the reference file and line range it follows. The package generates byte//! vectors from that release and replays them in tests, so each of those claims//! is checkable from this tree.//!//! Reading and writing both work in a slice the caller supplies and return a//! slice of it, so this code calls no allocator. The 32-byte SHA-256 digest//! that names a packet (*packet hash*) covers the low four bits of the first//! byte and everything from the address onward, which leaves out the hop count//! and the sixteen bytes a carrying node inserts, so the name holds still as//! the packet crosses the mesh. Each enum here names every bit pattern its//! field can hold, and the header's last byte, which says what the payload is//! for (*context byte*), carries an unnamed value through a decode and an//! encode unchanged. The subtree names its pieces: the flag bits, the context//! byte, the packet hash, the header, the proof payloads, and the link//! payloads.//!//! - *proof*: a packet carrying a signature over an earlier packet's hash, sent//! back so the sender learns the packet arrived.//! - *link*: an encrypted session between two endpoints, named by a 16-byte//! link id that both ends derive from the request packet.pub const context = @import("context.zig");pub const flags = @import("flags.zig");pub const hash = @import("hash.zig");pub const header = @import("header.zig");pub const link = @import("link.zig");pub const proof = @import("proof.zig");pub const Context = context.Context;pub const Flags = flags.Flags;pub const HeaderType = flags.HeaderType;pub const TransportType = flags.TransportType;pub const DestinationType = flags.DestinationType;pub const PacketType = flags.PacketType;pub const Packet = header.Packet;pub const DecodeError = header.DecodeError;pub const EncodeError = header.EncodeError;pub const decode = header.decode;pub const encode = header.encode;pub const encodedLength = header.encodedLength;pub const headerLength = header.headerLength;pub const header_one_bytes = header.header_one_bytes;pub const header_two_bytes = header.header_two_bytes;pub const mtu = header.mtu;pub const pathfinder_hops = header.pathfinder_hops;pub const truncated_hash_bytes = header.truncated_hash_bytes;Audit
| Definitions | 1 |
|---|---|
| Public names | 1 |
| Members | 0 |
| Version | 26.7.0 |
| Revision | daab053ee433 |