Reputation:
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?
Upvotes: 1
Views: 1939
Reputation: 12838
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.
Upvotes: 1