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
Metadata
Release files for pamoja-mesh 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pamoja_mesh-0.2.1.tar.gz | 4.6 kB | Without provenance | Details for pamoja_mesh-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pamoja_mesh-0.2.1-py3-none-any.whl | Python 3 | none | any | Details for pamoja_mesh-0.2.1-py3-none-any.whl |
Total release size: 9.8 kB
Release files / pamoja_mesh-0.2.1.tar.gz
| Download URL | pamoja_mesh-0.2.1.tar.gz |
|---|---|
| Size | 4.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e996fb88f5a596cd8f47bfc91402ef06ca0af3d9d55c041a92b63e613aa4ae6b
|
|
BLAKE2b-256 checksum How to use checksums |
8976de4c2f71d1d011df43b833fa304005497d2b0e54bea623c446f0e5ba748d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.18
|
Release files / pamoja_mesh-0.2.1-py3-none-any.whl
| Download URL | pamoja_mesh-0.2.1-py3-none-any.whl |
|---|---|
| Size | 5.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d02385b51e45c646066d9df8bca253ac4d6834e45af570c15c5508f3dd0f5a26
|
|
BLAKE2b-256 checksum How to use checksums |
783653756499b89676c9136195d9a5d32c662919320527d043cc5c9518eef4d4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.18
|
Security for pamoja-mesh 0.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.