pamoja-routing
Reverse-path routing that learns the cheapest route from overheard traffic. One capability of pamoja, one memory-safe Rust core with bindings for TypeScript, Python, and C#.
Install
pip install pamoja-routing
from pamoja import routing
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/routing.py:
from pamoja.routing import ForwardAction, Router
# The nodes on this mesh. An address is just a number; naming them is what makes the
# table below read as a map of the site rather than a list of numbers.
GATEWAY = 1
PUMP = 9
TANK = 10
NORTH_RELAY = 5
EAST_RELAY = 7
SOUTH_RELAY = 3
SILO = 32
# A node learns the way to another from traffic it already hears: a packet from the pump
# that arrived through the north relay proves that relay is a way back, at the cost the
# packet reports.
router = Router(GATEWAY, 4)
router.observe(PUMP, NORTH_RELAY, 2)
# The table keeps only the cheapest way it knows to each node, so a cost-1 report through
# the east relay takes over and the later cost-4 report changes nothing.
router.observe(PUMP, EAST_RELAY, 1)
router.observe(PUMP, SOUTH_RELAY, 4)
router.observe(TANK, NORTH_RELAY, 3)
route = router.route(PUMP)
print(f"to the pump via {route.next_hop} at cost {route.cost}")
print(f"routes held {len(router)}")
# Every packet gets one of three answers: deliver it here, relay it to the neighbor on
# the way, or flood it because no route is known yet.
for name, address in [("gateway", GATEWAY), ("pump", PUMP), ("silo", SILO)]:
decision = router.forward(address)
if decision.action == ForwardAction.DELIVER:
print(f"for the {name:<8} deliver here")
elif decision.action == ForwardAction.RELAY:
print(f"for the {name:<8} relay via {decision.next_hop}")
else:
print(f"for the {name:<8} flood, no route known")
# Forgetting a node that has gone quiet returns its traffic to flooding, so routing is an
# optimization over flooding rather than a second thing that can fail.
router.forget(PUMP)
after = router.forward(PUMP)
print(f"pump forgotten, so it floods again: {after.action == ForwardAction.FLOOD}")
The same capability in every language
| Language | Package | Reference |
|---|---|---|
| Rust | pamoja-routing |
reference, docs.rs, install |
| TypeScript | @pamoja/routing |
reference, install |
| Python | pamoja-routing |
reference, install |
| C# | Pamoja.Routing |
reference, install |
Documentation
pamoja.routingreference, every class and function in this module.- The Routing guide, with the same example in Rust, TypeScript, and C#.
- Every capability, and the install page.
License
MIT
Release files for pamoja-routing 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_routing-0.1.18.tar.gz | 3.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pamoja_routing-0.1.18-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.6 kB
Release files / pamoja_routing-0.1.18.tar.gz
| Download URL | pamoja_routing-0.1.18.tar.gz |
|---|---|
| Size | 3.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
97c06da440e66c9d2dd26fde50560fada50ec306e7dc6daf636d71f7417aa50b
|
|
BLAKE2b-256 checksum How to use checksums |
c4a88cecdfb3d31862f1957cedc8dea3ae33cd81941cb47f8f4304f434a1bc99
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.15
|
Release files / pamoja_routing-0.1.18-py3-none-any.whl
| Download URL | pamoja_routing-0.1.18-py3-none-any.whl |
|---|---|
| Size | 4.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
aea7d26db2c9f5900092a534a04e9c817e2e9b129e42069055b6ed2c41c38392
|
|
BLAKE2b-256 checksum How to use checksums |
fc15988940ccc0ed417b82734ab469bed730eac54e04fc6d3f4df04f9318392d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.15
|