You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This repo is basically a wrapper for sending and receiving UDP multicast messages via python. Y.M.M.V.
6
-
This library is not intended to fully implement the complexities of multicast traffic, rather to allow a user
7
-
friendly API for python components to send and receive across a multicast transmission.
8
-
The obvious advantage of this wrapper over unicast solutions is the ability to have multiple nodes communicate
9
-
concurrently without individual connections for each node pair.
5
+
The `multicast` package is a Python library that simplifies sending and receiving multicast network messages. It provides classes and tools for implementing multicast communication in Python applications, making it straightforward to work with multicast sockets.
10
6
11
-
## CI:
7
+
## Features
12
8
13
-
Continuous integration testing is handled by github actions and the generous Circle-CI Service.
9
+
-**Easy Multicast Communication**: Send and receive messages over multicast networks with simple interfaces.
10
+
-**Command-Line Tools**: Includes command-line utilities for quick multicast operations.
11
+
-**Cross-Python Compatibility**: Designed to work with multiple Python versions.
12
+
-**Support for UDP**: Works with UDP via IPv4 multicast addresses.
14
13
15
14
## Status
16
15
@@ -36,245 +35,99 @@ Continuous integration testing is handled by github actions and the generous Cir
The CLI is actually not the best way to use this kind of library so it should not be considered the full implementation. For testing/prototyping though it is quite convenient, thus I begin with it.
python3 -m multicast SAY --mcast-group 224.1.1.2 --port 59595 --message"Hello World!"
70
+
# Receive a message
71
+
message = receiver()
72
+
print('Received:', message)
117
73
```
118
74
119
-
120
-
### What is the basic API via python (instead of bash like above):
121
-
122
-
#### Caveat: this module is still a BETA
123
-
[Here is how it is tested right now](https://github.com/reactive-firewall/multicast/blob/cdd577549c0bf7c2bcf85d1b857c86135778a9ed/tests/test_usage.py#L251-L554)
75
+
### Listening for Multicast Messages
124
76
125
77
```python3
126
-
import mulicast as mulicast
127
-
from multiprocessing import Process as Process
128
-
129
-
# setup some stuff
130
-
_fixture_PORT_arg =int(59595)
131
-
_fixture_mcast_GRP_arg ="""224.0.0.1"""# only use dotted notation for multicast group addresses
#### Caveat: the above examples assume the reader is knowledgeable about general `IPC` theory and the standard python `multiprocessing` module and its use.
181
-
182
-
183
-
### What are the defaults?
184
-
185
-
##### The default multicast group address is 224.0.0.1
186
-
187
-
From the [documentation](https://github.com/reactive-firewall/multicast/blob/v1.4/multicast/__init__.py#L185-L187):
188
-
> The Value of "224.0.0.1" is chosen as a default multicast group as per RFC-5771
189
-
> on the rational that this group address will be treated as a local-net multicast
190
-
> (caveat: one should use link-local for ipv6)
191
-
192
-
##### The default multicast Time-to-Live (TTL) is 1
193
-
194
-
From [RFC-1112 §6.1](https://www.rfc-editor.org/rfc/rfc1112#section-6.1)
195
-
> ... If the
196
-
> upper-layer protocol chooses not to specify a time-to-live, it should
197
-
> default to 1 for all multicast IP datagrams, so that an explicit
198
-
> choice is required to multicast beyond a single network.
199
-
200
-
From the [documentation](https://github.com/reactive-firewall/multicast/blob/v1.4/multicast/__init__.py#L214-L217):
201
-
> A Value of 1 (one TTL) is chosen as per RFC1112 Sec 6.1 on the rational that an
202
-
> explicit value that could traverse byond the local connected network should be
203
-
> chosen by the caller rather than the default vaule. This is inline with the principle
204
-
> of none, one or many.
205
-
206
-
##### The default multicast destination port is 59559
207
-
208
-
From the [documentation](https://github.com/reactive-firewall/multicast/blob/v1.4/multicast/__init__.py#L155):
209
-
> Arbitrary port to use by default, though any dynamic and free port would work.
210
86
211
-
> :exclamation: Caution: it is best to specify the port in use at this time as the default has yet to be properly assigned ( see related #62 )
87
+
## Command-Line Usage
212
88
89
+
The `multicast` package provides command-line tools for multicast communication prototyping.
90
+
* Read the [Usage](docs/USAGE.md) for details.
213
91
214
-
### What does exit code _x_ mean?
215
-
216
-
#### Python function return code meanings
217
-
218
-
`0` is the default and implies *success*, and means the process has essentially (or actually) returned nothing (or `None`)
219
-
220
-
`1` is used when a *single* result is returned (caveat: functions may return a single `tuple` instead of `None` to indicate exit code `1` by returning a `boolean` success value, and result (which may also be encapsulated as an iteratable if needed) )
221
-
222
-
`2` is used to indicate a *value and reason* are returned (caveat: functions may return a single `tuple` with a single value and reason and the value can be a `tuple`)
223
-
224
-
`-1` is used to mean *many* of unspecified length and otherwise functions as `1`
225
-
226
-
#### CLI exit code meanings
92
+
## FAQ
227
93
228
-
`0`*success*
94
+
* Read the [FAQ](docs/FAQ.md) for common answers.
229
95
230
-
`1`*none-sucsess* - and is often accompanied by warnings or errors
96
+
## Default Settings
231
97
232
-
`2 >`*failure* of specific reason
98
+
-**Multicast Group Address**: `224.0.0.1` (link-local multicast as per [RFC 5771](https://tools.ietf.org/html/rfc5771))
99
+
-**Default Port**: `59259` (within the dynamic/private port range defined by [RFC 6335](https://tools.ietf.org/html/rfc6335))
100
+
-**Time-to-Live (TTL)**: `1` (as recommended by [RFC 1112 Section 6.1](https://tools.ietf.org/html/rfc1112#section-6.1); messages do not leave the local network)
233
101
102
+
## Security Considerations
234
103
235
-
#### Everything Else
236
-
_(extra exit code meanings)_
104
+
In the realm of network communication, security is paramount. When using multicast communication, be vigilant about potential vulnerabilities:
237
105
238
-
Other codes (such as `126`) may or may not have meanings (such as skip) but are not handled within the scope of the Multicast Project at this time.
106
+
-**Data Sanitization**: Always sanitize incoming data to prevent injection attacks ([CWE-20](https://cwe.mitre.org/data/definitions/20.html), [CWE-74](https://cwe.mitre.org/data/definitions/74.html)).
239
107
240
-
---
241
-
## Considerations for usage:
108
+
-**Network Scope**: Be mindful of the TTL settings to limit message propagation to the intended network segment. Inappropriate TTL values might expose your multicast traffic beyond the local network, potentially leading to information disclosure ([CWE-200](https://cwe.mitre.org/data/definitions/200.html)).
242
109
243
-
#### [CWE-183]
110
+
-**Validation and Error Handling**: Implement robust validation and error handling to prevent misuse or disruption of multicast services. ([CWE-351](https://cwe.mitre.org/data/definitions/351.html)).
244
111
245
-
:warning: ALL MULTICAST is a surface of attack if the data is not sanitized. Common criteria applies here too, don't assume this library won't forward raw network data that reaches it. Notably the default group is all connected nodes (224.0.0.1).
112
+
As Bruce Schneier aptly puts it, "Security is a process, not a product." Always be proactive in assessing and mitigating risks in your implementations and use of `multicast`.
246
113
247
-
Other common weakness left to the user to handle (NOT an exhaustive list):
248
-
- CWE-417 - in general all risks of a communication channel :thinking:
249
-
- CWE-346 - multicast is by its very nature NOT one-to-one and can probably always be spoofed to some degree (hint: shared secrets (group keys) are probably a start :shrug:)
250
-
- CWE-351 - don't assume only strings can be sent/received
114
+
[](https://www.bestpractices.dev/projects/9458)
251
115
252
-
---
253
-
## Dev dependancy Testing:
116
+
## Documentation
254
117
255
-
#### In a rush to get this module working? Then try using this with your own test:
118
+
For more detailed documentation and advanced usage, please refer to the [official documentation](docs/toc.md).
256
119
257
-
```bash
258
-
#cd /MY-AWSOME-DEV-PATH/multicast
259
-
make clean ;# cleans up from any previous tests hopefully
260
-
make test;# runs the tests
261
-
make clean ;# cleans up for next test
262
-
```
120
+
## Contributing
263
121
264
-
#### Use PEP8 to check python code style? Great! Try this:
122
+
Contributions are welcome! Please read the [contributing guidelines](.github/CONTRIBUTING.md) for more information.
265
123
266
-
```bash
267
-
make clean ;# cleans up from any previous tests hopefully
268
-
make test-style ;# runs the tests
269
-
make clean ;# cleans up for next test
270
-
```
271
-
---
272
-
## Next steps:
124
+
### Next steps
273
125
274
126
Next-steps and bug-fixes are tracked [Here](https://github.com/users/reactive-firewall/projects/1).
275
127
276
-
---
277
-
#### Copyright (c) 2021-2024, Mr. Walls
128
+
## License
129
+
130
+
This project is licensed under the MIT License. See the [LICENSE.md](LICENSE.md) file for details.
0 commit comments