class PeerTestManager extends Object
The automation of collaborative reachability testing for peers is enabled by a sequence of PeerTest messages. With its proper execution, a peer will be able to determine their own reachability and may update its behavior accordingly. The testing process is quite simple:
Alice Bob Charlie runTest() sendTestToBob() receiveFromAliceAsBob() PeerTest -------------------> sendTestToCharlie() receiveFromBobAsCharlie() PeerTest--------------------> receiveFromCharlieAsBob() <-------------------PeerTest receiveTestReply() <-------------------PeerTest receiveTestReply() <------------------------------------------PeerTest receiveFromAliceAsCharlie() PeerTest------------------------------------------> receiveTestReply() <------------------------------------------PeerTest
Each of the PeerTest messages carry a nonce identifying the test series itself, as initialized by Alice. If Alice doesn't get a particular message that she expects, she will retransmit accordingly, and based upon the data received or the messages missing, she will know her reachability. The various end states that may be reached are as follows:
Alice should choose Bob arbitrarily from known peers who seem to be capable of participating in peer tests. Bob in turn should choose Charlie arbitrarily from peers that he knows who seem to be capable of participating in peer tests and who are on a different IP from both Bob and Alice. If the first error condition occurs (Alice doesn't get PeerTest messages from Bob), Alice may decide to designate a new peer as Bob and try again with a different nonce.
Alice's introduction key is included in all of the PeerTest messages so that she doesn't need to already have an established session with Bob and so that Charlie can contact her without knowing any additional information. Alice may go on to establish a session with either Bob or Charlie, but it is not required.
Constructor and Description |
---|
PeerTestManager(RouterContext context,
UDPTransport transport)
Have seen peer tests (as Alice) get stuck (_currentTest != null)
so I've thrown some synchronizization on the methods;
don't know the root cause or whether this fixes it
|
Modifier and Type | Method and Description |
---|---|
void |
receiveTest(RemoteHostId from,
UDPPacketReader reader)
Entry point for all incoming packets.
|
void |
runTest(InetAddress bobIP,
int bobPort,
SessionKey bobCipherKey,
SessionKey bobMACKey)
The next few methods are for when we are Alice
|
public PeerTestManager(RouterContext context, UDPTransport transport)
public void runTest(InetAddress bobIP, int bobPort, SessionKey bobCipherKey, SessionKey bobMACKey)
bobIP
- IPv4 onlypublic void receiveTest(RemoteHostId from, UDPPacketReader reader)