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 neighbour 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.17
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.17.tar.gz | 4.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pamoja_mesh-0.1.17-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.7 kB
Release files / pamoja_mesh-0.1.17.tar.gz
| Download URL | pamoja_mesh-0.1.17.tar.gz |
|---|---|
| Size | 4.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9a57ea4ceade8cb0dd310e6fdc2d7b45941e52cb3e0ccd76550198ea5bd7a9b6
|
|
BLAKE2b-256 checksum How to use checksums |
f1fdb229c0e66b3f9f96b164a873477e3235cb03d5a3cb3f6036b2671b7b7a8f
|
| 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.17-py3-none-any.whl
| Download URL | pamoja_mesh-0.1.17-py3-none-any.whl |
|---|---|
| Size | 5.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ed72ec9b4dbbfc5c96736135e7223b239010e5bf09d6d684a9cd80be55f9efc6
|
|
BLAKE2b-256 checksum How to use checksums |
17e7474ec9c0506be4ad95ab1a36293f1e288308c7a41835fa864fbe2132fb88
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.15
|