tomp2p / TomP2P

A P2P-based high performance key-value pair storage library
http://tomp2p.net
Apache License 2.0
438 stars 122 forks source link

UDP-capable discovery and bootstrap #131

Open nmcodeeu opened 8 years ago

nmcodeeu commented 8 years ago

Hi,

As discussed on the mailing list few weeks ago, Discovery and Bootstrap builders should have a UDP/TCP switch for users to choose the bootstrap protocol.

I started to include my work based on the latest master state.

However the discovery process remains unclear to me after a few hours spent studying the existing code... Why the public-IP discovery is a two-steps process ? Currently, a first (tcp) pingDiscover is fired to a known peer. The response message should contain our public IP (through the recipient() property). The internal peerAddress is updated accordingly, then tcp and udp pingProbe messages are sent. The discovery process succeeds only once the fire and forget ping from the known peer is received. In which case the pingDiscover response is insufficient to consider the discovery process complete ?

I also encountered an issue during my tests: the UDP pingDiscover response doesn't contain a recipient address (recipient().ipv4Socket() == null). Is it normal ?

nmcodeeu commented 8 years ago

Sorry about the first question, I realised this two-step process is necessary to ensure that our visible address to a known peer is where we are reachable (as we could still be behind a Nat, VPN, or any unusual network setup).

I'm still struggling with the recipient address being null though. I'll try soon with pingDiscover tcp to verify that this behavior is not due to udp pingDiscover