java.lang.Object
net.i2p.router.transport.udp.PeerTestState

class PeerTestStateextends Object
Track the state of a peer test. Used only by PeerTestManager.
  • Field Details

    • _testNonce

      private final long _testNonce
      Nonce identifying this peer test.
    • _ourRole

      private final PeerTestState.Role _ourRole
      Our role in the test.
    • _isIPv6

      private final boolean _isIPv6
      True for an IPv6 test.
    • _alice

      private PeerState2 _alice
      Alice's peer state, when we are Bob.
    • _aliceIP

      private InetAddress _aliceIP
      Alice's IP as seen by Bob or Charlie.
    • _alicePort

      private int _alicePort
      Alice's port as seen by Bob or Charlie.
    • _bob

      private final PeerState _bob
      Bob's peer state, when we are Alice or Charlie.
    • _charlieIP

      private InetAddress _charlieIP
      Charlie's IP as seen by us.
    • _charliePort

      private int _charliePort
      Charlie's port as seen by us.
    • _aliceIPFromCharlie

      private InetAddress _aliceIPFromCharlie
      Alice's IP as Charlie reported it.
    • _alicePortFromCharlie

      private int _alicePortFromCharlie
      Alice's port as Charlie reported it.
    • _aliceIntroKey

      private SessionKey _aliceIntroKey
      Alice's introduction key.
    • _aliceCipherKey

      private SessionKey _aliceCipherKey
      Alice's cipher key for the test.
    • _aliceMACKey

      private SessionKey _aliceMACKey
      Alice's MAC key for the test.
    • _charlieIntroKey

      private SessionKey _charlieIntroKey
      Charlie's introduction key.
    • _aliceHash

      private Hash _aliceHash
      Alice's router hash, for SSU2 tests.
    • _charlieHash

      private Hash _charlieHash
      Charlie's router hash, for SSU2 tests.
    • _testData

      private byte[] _testData
      Test data for an SSU2 Bob.
    • _previousCharlies

      private final List<Hash> _previousCharlies
      Previous Charlies to avoid reusing, for SSU2 Bob.
    • _beginTime

      private final long _beginTime
      When the test began.
    • _lastSendTime

      private long _lastSendTime
      When we last sent a test packet.
    • _receiveAliceTime

      private long _receiveAliceTime
      When we last received from Alice.
    • _receiveBobTime

      private long _receiveBobTime
      When we last received from Bob.
    • _receiveCharlieTime

      private long _receiveCharlieTime
      When we last received from Charlie.
    • _sendAliceTime

      private long _sendAliceTime
      When we last sent to Alice.
    • _sendCharlieTime

      private long _sendCharlieTime
      When we last sent to Charlie.
    • _status

      private int _status
      Current status of the test.
    • _packetsRelayed

      private final AtomicInteger _packetsRelayed
      Test packets relayed so far.
  • Constructor Details

    • PeerTestState

      public PeerTestState(PeerTestState.Role role, PeerState bob, boolean isIPv6, long nonce, long now)
      Create a new peer test state for the given role.
      Parameters:
      role - our role in the peer test
      bob - Bob's PeerState, or null if we are Bob
      isIPv6 - whether this is an IPv6 test
      nonce - the test nonce identifier
      now - 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

      public PeerTestState.Role getOurRole()
      Return our role in the peer test.
      Returns:
      Alice, Bob, or Charlie
    • getBob

      public PeerState getBob()
      Return Bob's PeerState.
      Returns:
      Bob's PeerState, or null if we are Bob
    • isIPv6

      public boolean isIPv6()
      Whether this is an IPv6 test.
      Returns:
      true for IPv6, false for IPv4
    • getAliceIP

      public InetAddress getAliceIP()
      If we are Alice, return the IP that Bob says we can be reached at. The IP that Charlie reports is available via getAliceIPFromCharlie().
      Returns:
      Alice's IP as reported by Bob
    • getAlice

      public PeerState2 getAlice()
      Return Alice's PeerState2 (SSU2 only).
      Returns:
      Alice's SSU2 state, or null for SSU1
    • setAlice

      public void setAlice(PeerState2 alice)
      Alice's PeerState2 (SSU2 only).
      Parameters:
      alice - Alice's SSU2 state
    • setAlice

      public void setAlice(InetAddress ip, int port, Hash hash)
      Alice's IP, port, and hash.
      Parameters:
      ip - Alice's IP address
      port - Alice's port, as seen by the reporter
      hash - Alice's Hash (SSU2 only), null for SSU1
    • getBobIP

      public InetAddress getBobIP()
      Return Bob's IP address.
      Returns:
      Bob's remote IP
    • getCharlieIP

      public InetAddress getCharlieIP()
      Return Charlie's IP address.
      Returns:
      Charlie's IP, or null if not set
    • getCharlieHash

      public Hash getCharlieHash()
      Return Charlie's Hash (SSU2 only).
      Returns:
      Charlie's Hash, or null for SSU1
    • setCharlie

      public void setCharlie(InetAddress ip, int port, Hash hash)
      Charlie's IP, port, and hash. Saves the previous Charlie hash for tracking rotations.
      Parameters:
      ip - Charlie's IP address
      port - Charlie's port, as seen by us
      hash - Charlie's Hash (SSU2 only), null for SSU1
    • getPreviousCharlies

      public List<Hash> getPreviousCharlies()
      Return previous Charlie hashes (SSU2 only, Bob only). Does not include the current Charlie.
      Returns:
      list of previous Charlie hashes, or null if not Bob
    • getAliceIPFromCharlie

      public InetAddress getAliceIPFromCharlie()
      Return Alice's IP as reported by Charlie.
      Returns:
      Alice's IP from Charlie's perspective
    • setAliceIPFromCharlie

      public void setAliceIPFromCharlie(InetAddress ip)
      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 via getAlicePortFromCharlie().
      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

      public SessionKey getAliceIntroKey()
      Return Alice's intro key.
      Returns:
      Alice's intro key, or null if not set
    • setAliceIntroKey

      public void setAliceIntroKey(SessionKey key)
      Alice's intro key.
      Parameters:
      key - Alice's intro key
    • getAliceCipherKey

      public SessionKey getAliceCipherKey()
      Return Alice's cipher key.
      Returns:
      the cipher key, or null if not set
    • getAliceMACKey

      public SessionKey getAliceMACKey()
      Return Alice's MAC key.
      Returns:
      the MAC key, or null if not set
    • setAliceKeys

      public void setAliceKeys(SessionKey ck, SessionKey mk)
      Alice's cipher and MAC keys.
      Parameters:
      ck - cipher key
      mk - MAC key
    • getCharlieIntroKey

      public SessionKey getCharlieIntroKey()
      Return Charlie's intro key.
      Returns:
      Charlie's intro key, or null if not set
    • setCharlieIntroKey

      public void setCharlieIntroKey(SessionKey key)
      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

      public String toString()
      String representation of this test state.
      Overrides:
      toString in class Object