How should I choose an IPv4 multicast address for my application's use? I may need more than one (a whole range perhaps ultimately) but just want to avoid conflicts with other applications.
Ideas please :)
Currently I've just allocated an arbitrary one from the "local use" space, 239.255.42.99
So, the full range of multicast addresses is from 224.0. 0.0 to 239.255. 255.255. Since multicast addresses represent a group of IP devices (sometimes called a host group) they can only be used as the destination of a datagram; never the source.
The address range is divided into blocks each assigned a specific purpose or behavior. Addresses in the range of 224.0. 0.0 to 224.0. 0.255 are individually assigned by IANA and designated for multicasting on the local subnetwork only.
The multicast addresses are in the range 224.0. 0.0 through 239.255. 255.255.
It seems you've already found http://www.iana.org/assignments/multicast-addresses
, so you've done the right thing by picking an address from the 239.255/16
range.
As those ranges are entirely for site-local use it's no ones else's business which particular address you pick, but you may need to coordinate with the network manager (assuming that's not you) to pick an alternate address pool.
As others have suggested, just make sure there's an easy way to change the address just in case it does conflict with another address on the local LAN.
If the multiple applications issue becomes a problem, provide a (locally) well-known multicast address which the applications can talk to which will issue unique local-scope IP addresses for clients' use.
As already suggested, allow the range to be configured. But taking that further, don't require configuration. You pick the range and allow configuration to override if necessary.
You should have some logic in your application to handle foreign packets, to alert the user, through logs, or some other mechanism, that your application has detected multicast packets from another app, with instructions on how to change the configuration.
If it turns out that there is a conflict, play those numbers in the lottery!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With