4 ms·
With IPv6 it's plausible that you can avoid collisions as long as you use an expensive hash function, but for v4 how do you avoid IP collisions? With only 22 b
by Retr0id 4mo ago
With IPv6 it's plausible that you can avoid collisions as long as you use an expensive hash function, but for v4 how do you avoid IP collisions?
With only 22 bits of entropy in your v4 addresses, you'll get accidental collisions with only ~2000 users.
- dfish 4mo agoIndeed. So what we do is build your ipv4 using private key bits + collision_index. It is not perfect but it has worked in our tests. We'll keep improving it. The collision_index is incremented when a collision happens on a network. Let's say you join network A, B, C. But when you join C, another peer has the same IP. The coordinator (which is a role anybody can have in the network) will not accept you in the network unless you change your IP. Which means you need to increase your collision index. Now that process is repeated N times until you don't collide with any other peer.
- Retr0id 4mo agoSo I'd have a different IP on each network? (I really hope "private key" was a typo of "public key"?)
- dfish 4mo agoIndeed, it is a typo of `public key`. What I mean is that your identity is your private key. And no, you won't have a new IP per network. Your IP is `fnv1a(ip || index) when index > 0`. Which changes your IP in all of the networks. That's why we also implemented MagicDNS. You can just use your `user.ray` name. The daemon handles IP changes.
- Retr0id 4mo agoSo every time you join a new network, your IP in the others can change?
- dfish 4mo agoNo, only once if there is a collision, which is 1/4M
- Retr0id 3mo agoThat's a "yes"
- dfish 3mo ago> So I'd have a different IP on each network? NO. You will ONLY have to rotate your IP if you join a network in which there is a collision. 1 in 4 million chance. If that happens, it's ok. Ideally you are using magicDNS and don't have to worry about IPs or just use the IPv6.