SwarmNet
A robust communications library for robot swarms. This is based on gossip protocols where the message will propagate around the swarm. When an agent receives a message it has not seen before, it will broadcast it to all other members of the swarm.
Usage
A SwarmNet object must be created that handles all of the communication. Only one instance should be created. To start the communication framework, the start() method must be run.
All devices must use the same port number
This start() command will broadcast a JOIN command to register with the rest of the swarm.
Message Parsers
Parsers are defined to handle incoming messages of specific types, for example, you may want to send COUNT 1 to increase a distributed counter by 1 when the COUNT command is received. This would be defined as follows.
counter = 0
def count_recv(msg: Optional[str]) -> None:
counter += int(msg)
sn = SwarmNet({"COUNT": count_recv})
sn.start()
while(True):
pass
sn.kill()
It is important to remember that the parser functions are called from a different thread. Special care should be taken to ensure data integrity and consistency across threads.
The type of each parser is Optional[str] -> None where the string is a string of any fields in the message. For example, if the message is CMD field1 field2, the string will be "field1 field2.
If a message is received with a command token for which there is no parser, an error message is produced with a list of recognised command tokens. To prevent error spam in more complex systems, you can set certain commands to be ignored by defining the parser as None. For example, if the above code was deployed in a swarm that also had DEBUG messages that were only important to one specific node, you could ignore them using None.
counter = 0
def count_recv(msg: Optional[str]) -> None:
counter += int(msg)
sn = SwarmNet({"COUNT": count_recv, "DEBUG": None})
sn.start()
while(True):
pass
sn.kill()
Message Format
All messages follow the format: <CMD> <DATA1> <DATA2> ...
A dictionary that maps command tokens to functions is passed to the SwarmNet constructor. The signature of this map is Dict[str, Optional[Callable[[Optional[str]], None]]] where the str passed to the parser function is the rest of the message string (if any)
Internally, every message is prefixed with an identifier that is not overwritten when the message is forwarded by receivers. This means agents will not parse their own message or parse the same message more than once.
Metadata
Release files for swarmnet 0.0.8
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 |
|---|---|---|---|---|
| swarmnet-0.0.8.tar.gz | 20.0 kB | Without provenance | Details for swarmnet-0.0.8.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| swarmnet-0.0.8-py3-none-any.whl | Python 3 | none | any | Details for swarmnet-0.0.8-py3-none-any.whl |
Total release size: 40.9 kB
Release files / swarmnet-0.0.8.tar.gz
| Download URL | swarmnet-0.0.8.tar.gz |
|---|---|
| Size | 20.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
83729c838aa13b4dd0baa5655f6f8a64d5752e1afcfdf224e5c143ac8b70b235
|
|
BLAKE2b-256 checksum How to use checksums |
0291e73c27760276ad77f56e5c71dcaa46639b4adf7f2b2b9a3f1d32db88d689
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.18
|
Release files / swarmnet-0.0.8-py3-none-any.whl
| Download URL | swarmnet-0.0.8-py3-none-any.whl |
|---|---|
| Size | 20.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0e4acf7ccaa72bf2920ea296469aa83da1700d82e51efb4415e60d756489a1a5
|
|
BLAKE2b-256 checksum How to use checksums |
b302a02143a95b3ca1fe3465d239a545d4a9920ede3560353b9fde50cdf82b3d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.18
|
Security for swarmnet 0.0.8
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.