java.lang.Object
net.i2p.router.transport.udp.PeerTestState
Track the state of a peer test. Used only by
PeerTestManager.Nested Class Summary
Nested ClassesField Summary
FieldsModifier and TypeFieldDescriptionprivate PeerState2Alice's peer state, when we are Bob.private SessionKeyAlice's cipher key for the test.private HashAlice's router hash, for SSU2 tests.private SessionKeyAlice's introduction key.private InetAddressAlice's IP as seen by Bob or Charlie.private InetAddressAlice's IP as Charlie reported it.private SessionKeyAlice's MAC key for the test.private intAlice's port as seen by Bob or Charlie.private intAlice's port as Charlie reported it.private final longWhen the test began.private final PeerStateBob's peer state, when we are Alice or Charlie.private HashCharlie's router hash, for SSU2 tests.private SessionKeyCharlie's introduction key.private InetAddressCharlie's IP as seen by us.private intCharlie's port as seen by us.private final booleanTrue for an IPv6 test.private longWhen we last sent a test packet.private final PeerTestState.RoleOur role in the test.private final AtomicIntegerTest packets relayed so far.Previous Charlies to avoid reusing, for SSU2 Bob.private longWhen we last received from Alice.private longWhen we last received from Bob.private longWhen we last received from Charlie.private longWhen we last sent to Alice.private longWhen we last sent to Charlie.private intCurrent status of the test.private byte[]Test data for an SSU2 Bob.private final longNonce identifying this peer test.Constructor Summary
ConstructorsConstructorDescriptionPeerTestState(PeerTestState.Role role, PeerState bob, boolean isIPv6, long nonce, long now) Create a new peer test state for the given role.Method Summary
All MethodsModifier and TypeMethodDescriptiongetAlice()Return Alice's PeerState2 (SSU2 only).Return Alice's cipher key.Return Alice's intro key.If we are Alice, return the IP that Bob says we can be reached at.Return Alice's IP as reported by Charlie.Return Alice's MAC key.intIf we are Alice, return the port that Bob says we can be reached at.intReturn Alice's port as reported by Charlie.longReturn the time when this test began.getBob()Return Bob's PeerState.getBobIP()Return Bob's IP address.intReturn Bob's port.Return Charlie's Hash (SSU2 only).Return Charlie's intro key.Return Charlie's IP address.intReturn Charlie's port.longReturn the time we last sent a packet.longgetNonce()Return the test nonce identifier.Return our role in the peer test.Return previous Charlie hashes (SSU2 only, Bob only).longReturn the time we last received from Alice.longReturn the time we last received from Bob.longReturn the time we last received from Charlie.longReturn when we last sent to Alice (SSU2 Bob only).longReturn when we last sent to Charlie (SSU2 Alice only).intReturn the status code sent to Alice (SSU2 Bob only).byte[]Test data for retransmission.intIncrement and return the packets relayed count.booleanisIPv6()Whether this is an IPv6 test.voidsetAlice(InetAddress ip, int port, Hash hash) Alice's IP, port, and hash.voidsetAlice(PeerState2 alice) Alice's PeerState2 (SSU2 only).voidAlice's intro key.voidAlice's IP as reported by Charlie.voidsetAliceKeys(SessionKey ck, SessionKey mk) Alice's cipher and MAC keys.voidsetAlicePortFromCharlie(int alicePortFromCharlie) Alice's port as reported by Charlie.voidsetCharlie(InetAddress ip, int port, Hash hash) Charlie's IP, port, and hash.voidCharlie's intro key.voidsetCharliePort(int charliePort) Charlie's port.voidsetLastSendTime(long when) Time we last sent a packet.voidsetReceiveAliceTime(long when) Time we last received from Alice.voidsetReceiveBobTime(long when) Time we last received from Bob.voidsetReceiveCharlieTime(long when) Time we last received from Charlie.voidsetSendAliceTime(long when) When we last sent to Alice (SSU2 Bob only).voidsetSendCharlieTime(long when) When we last sent to Charlie (SSU2 Alice only).voidsetStatus(int status) Status code sent to Alice (SSU2 Bob only).voidsetTestData(byte[] data) Save the test data for retransmission.toString()String representation of this test state.
Field Details
_testNonce
private final long _testNonceNonce identifying this peer test._ourRole
Our role in the test._isIPv6
private final boolean _isIPv6True for an IPv6 test._alice
Alice's peer state, when we are Bob._aliceIP
Alice's IP as seen by Bob or Charlie._alicePort
private int _alicePortAlice's port as seen by Bob or Charlie._bob
Bob's peer state, when we are Alice or Charlie._charlieIP
Charlie's IP as seen by us._charliePort
private int _charliePortCharlie's port as seen by us._aliceIPFromCharlie
Alice's IP as Charlie reported it._alicePortFromCharlie
private int _alicePortFromCharlieAlice's port as Charlie reported it._aliceIntroKey
Alice's introduction key._aliceCipherKey
Alice's cipher key for the test._aliceMACKey
Alice's MAC key for the test._charlieIntroKey
Charlie's introduction key._aliceHash
Alice's router hash, for SSU2 tests._charlieHash
Charlie's router hash, for SSU2 tests._testData
private byte[] _testDataTest data for an SSU2 Bob._previousCharlies
_beginTime
private final long _beginTimeWhen the test began._lastSendTime
private long _lastSendTimeWhen we last sent a test packet._receiveAliceTime
private long _receiveAliceTimeWhen we last received from Alice._receiveBobTime
private long _receiveBobTimeWhen we last received from Bob._receiveCharlieTime
private long _receiveCharlieTimeWhen we last received from Charlie._sendAliceTime
private long _sendAliceTimeWhen we last sent to Alice._sendCharlieTime
private long _sendCharlieTimeWhen we last sent to Charlie._status
private int _statusCurrent status of the test._packetsRelayed
Test packets relayed so far.
Constructor Details
PeerTestState
Create a new peer test state for the given role.- Parameters:
role- our role in the peer testbob- Bob's PeerState, or null if we are BobisIPv6- whether this is an IPv6 testnonce- the test nonce identifiernow- the time when the test begins
Method Details
getNonce
public long getNonce()Return the test nonce identifier.- Returns:
- the nonce identifying this test, as supplied to the constructor
getOurRole
Return our role in the peer test.- Returns:
- Alice, Bob, or Charlie
getBob
isIPv6
public boolean isIPv6()Whether this is an IPv6 test.- Returns:
- true for IPv6, false for IPv4
getAliceIP
If we are Alice, return the IP that Bob says we can be reached at. The IP that Charlie reports is available viagetAliceIPFromCharlie().- Returns:
- Alice's IP as reported by Bob
getAlice
Return Alice's PeerState2 (SSU2 only).- Returns:
- Alice's SSU2 state, or null for SSU1
setAlice
Alice's PeerState2 (SSU2 only).- Parameters:
alice- Alice's SSU2 state
setAlice
Alice's IP, port, and hash.- Parameters:
ip- Alice's IP addressport- Alice's port, as seen by the reporterhash- Alice's Hash (SSU2 only), null for SSU1
getBobIP
getCharlieIP
Return Charlie's IP address.- Returns:
- Charlie's IP, or null if not set
getCharlieHash
Return Charlie's Hash (SSU2 only).- Returns:
- Charlie's Hash, or null for SSU1
setCharlie
Charlie's IP, port, and hash. Saves the previous Charlie hash for tracking rotations.- Parameters:
ip- Charlie's IP addressport- Charlie's port, as seen by ushash- Charlie's Hash (SSU2 only), null for SSU1
getPreviousCharlies
getAliceIPFromCharlie
Return Alice's IP as reported by Charlie.- Returns:
- Alice's IP from Charlie's perspective
setAliceIPFromCharlie
Alice's IP as reported by Charlie.- Parameters:
ip- Alice's IP from Charlie's perspective
getAlicePort
public int getAlicePort()If we are Alice, return the port that Bob says we can be reached at. The port Charlie reports is available viagetAlicePortFromCharlie().- Returns:
- Alice's port as reported by Bob
getBobPort
public int getBobPort()Return Bob's port.- Returns:
- Bob's remote port
getCharliePort
public int getCharliePort()Return Charlie's port.- Returns:
- Charlie's port, or 0 if not set
setCharliePort
public void setCharliePort(int charliePort) Charlie's port.- Parameters:
charliePort- Charlie's port number
getAlicePortFromCharlie
public int getAlicePortFromCharlie()Return Alice's port as reported by Charlie.- Returns:
- Alice's port from Charlie's perspective
setAlicePortFromCharlie
public void setAlicePortFromCharlie(int alicePortFromCharlie) Alice's port as reported by Charlie.- Parameters:
alicePortFromCharlie- Alice's port from Charlie's perspective
getAliceIntroKey
Return Alice's intro key.- Returns:
- Alice's intro key, or null if not set
setAliceIntroKey
getAliceCipherKey
Return Alice's cipher key.- Returns:
- the cipher key, or null if not set
getAliceMACKey
setAliceKeys
Alice's cipher and MAC keys.- Parameters:
ck- cipher keymk- MAC key
getCharlieIntroKey
Return Charlie's intro key.- Returns:
- Charlie's intro key, or null if not set
setCharlieIntroKey
Charlie's intro key.- Parameters:
key- Charlie's intro key
getBeginTime
public long getBeginTime()Return the time when this test began.- Returns:
- the begin timestamp
getLastSendTime
public long getLastSendTime()Return the time we last sent a packet.- Returns:
- the last send timestamp
setLastSendTime
public void setLastSendTime(long when) Time we last sent a packet.- Parameters:
when- the last send timestamp
getReceiveAliceTime
public long getReceiveAliceTime()Return the time we last received from Alice.- Returns:
- the receive timestamp
setReceiveAliceTime
public void setReceiveAliceTime(long when) Time we last received from Alice.- Parameters:
when- the receive timestamp
getReceiveBobTime
public long getReceiveBobTime()Return the time we last received from Bob.- Returns:
- the receive timestamp
setReceiveBobTime
public void setReceiveBobTime(long when) Time we last received from Bob.- Parameters:
when- the receive timestamp
getReceiveCharlieTime
public long getReceiveCharlieTime()Return the time we last received from Charlie.- Returns:
- the receive timestamp
setReceiveCharlieTime
public void setReceiveCharlieTime(long when) Time we last received from Charlie.- Parameters:
when- the receive timestamp
getSendAliceTime
public long getSendAliceTime()Return when we last sent to Alice (SSU2 Bob only).- Returns:
- the send timestamp
setSendAliceTime
public void setSendAliceTime(long when) When we last sent to Alice (SSU2 Bob only).- Parameters:
when- the send timestamp
getSendCharlieTime
public long getSendCharlieTime()Return when we last sent to Charlie (SSU2 Alice only).- Returns:
- the send timestamp
setSendCharlieTime
public void setSendCharlieTime(long when) When we last sent to Charlie (SSU2 Alice only).- Parameters:
when- the send timestamp
getStatus
public int getStatus()Return the status code sent to Alice (SSU2 Bob only).- Returns:
- the status code
setStatus
public void setStatus(int status) Status code sent to Alice (SSU2 Bob only).- Parameters:
status- the SSU2 status code to report to Alice
getTestData
public byte[] getTestData()Test data for retransmission. SSU2 only, used when we are Alice, Bob, or Charlie.- Returns:
- the test data, or null if not set
setTestData
public void setTestData(byte[] data) Save the test data for retransmission. SSU2 only, used when we are Alice, Bob, or Charlie.- Parameters:
data- the test data
incrementPacketsRelayed
public int incrementPacketsRelayed()Increment and return the packets relayed count.- Returns:
- the incremented count
toString