class IntroductionManager extends Object
Indirect session establishment by means of a third party introduction is necessary for efficient NAT traversal. Charlie, a router behind a NAT or firewall which does not allow unsolicited inbound UDP packets, first contacts a few peers, choosing some to serve as introducers. Each of these peers (Bob, Bill, Betty, etc) provide Charlie with an introduction tag - a 4 byte random number - which he then makes available to the public as methods of contacting him. Alice, a router who has Charlie's published contact methods, first sends a RelayRequest packet to one or more of the introducers, asking each to introduce her to Charlie (offering the introduction tag to identify Charlie). Bob then forwards a RelayIntro packet to Charlie including Alice's public IP and port number, then sends Alice back a RelayResponse packet containing Charlie's public IP and port number. When Charlie receives the RelayIntro packet, he sends off a small random packet to Alice's IP and port (poking a hole in his NAT/firewall), and when Alice receives Bob's RelayResponse packet, she begins a new full direction session establishment with the specified IP and port.
Alice first connects to introducer Bob, who relays the request to Charlie.
Alice Bob Charlie RelayRequest ----------------------> <-------------- RelayResponse RelayIntro -----------> <-------------------------------------------- HolePunch (data ignored) SessionRequest --------------------------------------------> <-------------------------------------------- SessionCreated SessionConfirmed ------------------------------------------> <-------------------------------------------- DeliveryStatusMessage <-------------------------------------------- DatabaseStoreMessage DatabaseStoreMessage --------------------------------------> Data <--------------------------------------------------> Data
After the hole punch, the session is established between Alice and Charlie as in a direct establishment.
Modifier and Type | Field and Description |
---|---|
static int |
MAX_OUTBOUND
This is enforced in EstablishmentManager
|
Constructor and Description |
---|
IntroductionManager(RouterContext ctx,
UDPTransport transport) |
Modifier and Type | Method and Description |
---|---|
void |
add(PeerState peer) |
(package private) int |
introducedCount() |
(package private) int |
introducerCount()
Not as elaborate as pickInbound() above.
|
int |
pickInbound(Properties ssuOptions,
int howMany)
Grab a bunch of peers who are willing to be introducers for us that
are locally known (duh) and have published their own SSU address (duh^2).
|
void |
pingIntroducers()
Was part of pickInbound(), moved out so we can call it more often
|
(package private) void |
receiveRelayIntro(RemoteHostId bob,
UDPPacketReader reader)
We are Charlie and we got this from Bob.
|
(package private) void |
receiveRelayRequest(RemoteHostId alice,
UDPPacketReader reader)
We are Bob and we got this from Alice.
|
void |
remove(PeerState peer) |
void |
reset() |
public static final int MAX_OUTBOUND
public IntroductionManager(RouterContext ctx, UDPTransport transport)
public void reset()
public void add(PeerState peer)
public void remove(PeerState peer)
public int pickInbound(Properties ssuOptions, int howMany)
ssuOptions
- out parameter, options are addedpublic void pingIntroducers()
int introducerCount()
int introducedCount()
void receiveRelayIntro(RemoteHostId bob, UDPPacketReader reader)
void receiveRelayRequest(RemoteHostId alice, UDPPacketReader reader)