pamoja-mesh
Addressed, hop-limited, CRC-checked frames and duplicate suppression that floods a packet exactly once. One capability of pamoja, one memory-safe Rust core with bindings for TypeScript, Python, and C#.
Install
pip install pamoja-mesh
from pamoja import mesh
This pulls in pamoja-native, the compiled engine. pip install pamoja is the whole framework in one package.
Example
The script the test suite runs, spliced here as it ran.
From bindings/python/guides/mesh.py:
from pamoja.core import PamojaError
from pamoja.mesh import BROADCAST, HEADER_LEN, SeenPackets, broadcast, parse, relayed
# A river gauge floods a level reading to every node in range. The header is fixed and
# big-endian: version, source, destination, sequence id, hop limit, then the payload and a
# checksum over everything but the hop limit.
RIVER_GAUGE = 305419896
reading = broadcast(RIVER_GAUGE, 1, b"level=high")
print(f"sent {len(reading.bytes)} bytes to every node in range")
print(f"addressed to broadcast: {reading.dst == BROADCAST}")
# A neighbor hears it. Every node in range rebroadcasts, so the same packet arrives
# several times over; the source and sequence id decide which copy is the first.
received = parse(reading.bytes)
print(f"payload {received.payload.decode()}")
seen = SeenPackets(64)
first = seen.record(received.src, received.id)
again = seen.record(received.src, received.id)
print(f"first copy relayed: {first}, second copy relayed: {again}")
# Relaying spends one hop. The checksum skips the hop-limit byte, so a relay forwards the
# frame without recomputing it and the check stays end to end.
forwarded = relayed(received.bytes)
print(f"relayed hop limit {forwarded.hop_limit}")
onward = parse(forwarded.bytes)
print(f"onward {onward.payload.decode()}")
# A frame that has run out of hops is not relayed again, which is what ends the flood.
spent = relayed(broadcast(RIVER_GAUGE, 1, b"level=high", 0).bytes)
if spent is None:
print("spent hop limit reached, the flood stops here")
else:
print("a spent frame was relayed, which should never happen")
# A payload byte the air mangled fails the checksum rather than reaching the application
# as a plausible reading. The header is a fixed width, so the first byte past it is the
# first byte of the reading itself.
mangled = bytearray(reading.bytes)
mangled[HEADER_LEN] ^= 0xFF
try:
parse(bytes(mangled))
print("a mangled frame was accepted, which should never happen")
except PamojaError as error:
print(f"mangled rejected: {error}")
The same capability in every language
| Language | Package | Reference |
|---|---|---|
| Rust | pamoja-mesh |
reference, docs.rs, install |
| TypeScript | @pamoja/mesh |
reference, install |
| Python | pamoja-mesh |
reference, install |
| C# | Pamoja.Mesh |
reference, install |
Documentation
pamoja.meshreference, every class and function in this module.- The Mesh frames guide, with the same example in Rust, TypeScript, and C#.
- Every capability, and the install page.
License
MIT
Release files for pamoja-mesh 0.1.18
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pamoja_mesh-0.1.18.tar.gz | 4.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pamoja_mesh-0.1.18-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.7 kB
Release files / pamoja_mesh-0.1.18.tar.gz
| Download URL | pamoja_mesh-0.1.18.tar.gz |
|---|---|
| Size | 4.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
33a9c6ee7c9010ee54f476e0cbd93da422ddc17ca5dd1a167810417731f939b5
|
|
BLAKE2b-256 checksum How to use checksums |
1a953e48320ec555db94eb723dc0eca61b7ab4f6ee3bc172f276ff9f54cfce8c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.15
|
Release files / pamoja_mesh-0.1.18-py3-none-any.whl
| Download URL | pamoja_mesh-0.1.18-py3-none-any.whl |
|---|---|
| Size | 5.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b391aaab5536d264d201ca6bac48612d9d055d02589c21087ab14d5cdc4d0ce1
|
|
BLAKE2b-256 checksum How to use checksums |
d42bd3ef457f8621699cc1fbbb2072f1e9da9811333d12c8dead3d67f567501d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.15
|