1
votes

I'm looking for a way to generate a random IPv6 multicast address in Java for a distributed pub/sub application.

This means there may be many (distributed) nodes and each node should be able to generate (potentially many) random and unique IPv6 multicast addresses.

I'm unsure how to efficiently and safely do this. Assuming a fixed multicast prefix leaves us 2^112 unique multicast addresses but that does require a good random number generator, one that can be used in a distributed setting. Perhaps I should seed it with the time or something like that? Even if I do so, I'm unsure what is a good way to construct an IPv6 address, Java does not immediately provide functionality for this.

Any suggestions?

1
You only get 31 bits for SSM; see RFC 4607.Michael Hampton
Thanks, I was unaware. However, the thing I want to do remains unchanged. This won't enter a commercial/real-life application.user4346741
For use on the public Internet? Otherwise just use one of the scoped prefixes like ffx8::/16 and replace the lower 112 bits with the hosts unicast address.Steve-o

1 Answers

0
votes

There's an IPv4 and IPv6 arbitrary data generator included in MockNeat.

Check up the methods: ipv4s() and ipv6s().

Example from the wiki:

String ipv6 = mock.iPv6s().val();
// Possible Output: 35f1:b02f:8843:9abb:82bf:967a:34f5:ed8b

Disclaimer: I am the author of the library, so I might be biased when I am recommending it.