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")
to = "every node in range" if reading.dst == BROADCAST else "one node"
print(f"sent {len(reading.bytes)} bytes to {to}, hop limit {reading.hop_limit}")
# 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)
if first and not again:
print("dedup the first copy is relayed, and the second is dropped")
# 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)
onward = parse(forwarded.bytes)
print(
f"relayed hop limit {forwarded.hop_limit}, and the checksum still holds: "
f"{onward.payload.decode()}"
)
# A frame that has run out of hops is not relayed again, which is what ends the flood.
if relayed(broadcast(RIVER_GAUGE, 1, b"level=high", hop_limit=0).bytes) is None:
print("spent at hop limit 0 the frame goes no further")
# 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.2.0
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.2.0.tar.gz | 4.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pamoja_mesh-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.8 kB
Release files / pamoja_mesh-0.2.0.tar.gz
| Download URL | pamoja_mesh-0.2.0.tar.gz |
|---|---|
| Size | 4.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b7a9ee65d2547548390629f094b34fae8bff5ee615bdb77d79b20912a1e3b339
|
|
BLAKE2b-256 checksum How to use checksums |
1a70fb10ef6e360848613f794ba2ed10c9b20486937dfbd6d1fa612d157dba73
|
| 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.2.0-py3-none-any.whl
| Download URL | pamoja_mesh-0.2.0-py3-none-any.whl |
|---|---|
| Size | 5.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
afac851f544a3b2d929dbe48bbecfded59b7aa6122f4761b391e3c0dc308b564
|
|
BLAKE2b-256 checksum How to use checksums |
06129edb297b26712ab7f50d18e49179ea9f95d6df44d46f63c796d3cbf6cae6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.15
|