1

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?

  • You only get 31 bits for SSM; see RFC 4607. – Michael Hampton Mar 03 '15 at 00:12
  • Thanks, I was unaware. However, the thing I want to do remains unchanged. This won't enter a commercial/real-life application. –  Mar 03 '15 at 07:22
  • 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 Mar 12 '15 at 14:06

1 Answers1

1

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.

Andrei Ciobanu
  • 12,500
  • 24
  • 85
  • 118
  • Thanks. And also, it looks like actually all of your recent answers are doing the same thing. You should add a disclaimer to all of them. That said, digging up old questions just for self-promotion does seem a bit like abuse to me. – Michael Sep 12 '18 at 12:36
  • @Michael exactly what I was doing, I've added disclaimers to all of the recent answers. As long as the answer responds the question is it abuse ? – Andrei Ciobanu Sep 12 '18 at 12:37
  • I'm not sure on the "official" stance on this. Maybe a disclaimer is enough, maybe it's not. I'd just be careful if I were you. I'd personally check meta to see whether this has been discussed before, just to make sure you're not breaking any rules. – Michael Sep 12 '18 at 12:40
  • @Michael found a topic on meta about this. From my understanding it's allowed, as long as I try to document the answer and add the disclaimer. I will check further. – Andrei Ciobanu Sep 12 '18 at 12:44
  • Yeah, I've been reading up as well. It seems like its generally fine, provided there's a disclaimer, and it *is* an actual answer and not just a link to the repo. So I think you're fine on both counts. The only unclear thing to me is whether hunting specifically for questions to which your library applies and only answering those is something we want to encourage. My take is that as long as you're helping people, a bit of self-promotion doesn't hurt anyone. Your library looks cool, by the way, so good work! – Michael Sep 12 '18 at 12:49