java.lang.Object
net.i2p.router.transport.udp.InboundEstablishState
Direct Known Subclasses:
InboundEstablishState2

class InboundEstablishStateextends Object
Data for a new connection being established, where the remote peer has initiated the connection with us. In other words, they are Alice and we are Bob.
  • Field Details

    • _context

      protected final RouterContext _context
      Router context.
    • _log

      protected final Log _log
      Logger.
    • _receivedX

      private byte[] _receivedX
      SessionRequest message data from Alice.
    • _bobIP

      protected byte[] _bobIP
      Our IP address as seen by Alice.
    • _bobPort

      protected final int _bobPort
      Our port number as seen by Alice.
    • _aliceIP

      protected final byte[] _aliceIP
      Alice's IP address from the SessionCreated message.
    • _alicePort

      protected final int _alicePort
      Alice's port number.
    • _sentRelayTag

      protected long _sentRelayTag
      Relay tag we sent to Alice.
    • _sentSignedOnTime

      private long _sentSignedOnTime
      Signed-on time we sent to Alice.
    • _receivedIdentity

      private byte[][] _receivedIdentity
      SessionConfirmed message fragments from Alice (fragmentation theoretical only).
    • _receivedUnconfirmedIdentity

      protected RouterIdentity _receivedUnconfirmedIdentity
      Identity before signature verification.
    • _receivedConfirmedIdentity

      protected RouterIdentity _receivedConfirmedIdentity
      Identity after successful signature verification.
    • _establishBegin

      protected final long _establishBegin
      Timestamp when establishment began.
    • _lastSend

      protected long _lastSend
      Last packet send time.
    • _nextSend

      protected long _nextSend
      Next scheduled send time.
    • _remoteHostId

      protected final RemoteHostId _remoteHostId
      Remote host identifier for uniqueness.
    • _currentState

      protected InboundEstablishState.InboundState _currentState
      Current state in the inbound establishment protocol.
    • _queuedMessages

      private final Queue<OutNetMessage> _queuedMessages
      Messages queued while session was being established.
    • _createdSentCount

      protected int _createdSentCount
      Count of SessionCreated packets sent (for exponential backoff).
    • _introductionRequested

      protected boolean _introductionRequested
      Whether Alice requested introduction (default true for SSU 1, false for SSU 2).
    • _rtt

      protected int _rtt
      Estimated round-trip time.
    • RETRANSMIT_DELAY

      protected static final long RETRANSMIT_DELAY
      Basic delay before backoff Transmissions at 0, 1, 3, 7 sec. This should be a little shorter than for outbound.
  • Constructor Details

    • InboundEstablishState

      protected InboundEstablishState(RouterContext ctx, InetSocketAddress addr)
      For SSU2.
      Parameters:
      ctx - router context, used for the clock and the log
      addr - the remote address the session request arrived from, which becomes the peer's address and remote host id
  • Method Details

    • getMaxDelay

      protected static long getMaxDelay()
      Max delay including backoff. This should be a little shorter than for outbound.
      Returns:
      the max delay
    • getVersion

      public int getVersion()
      Return the SSU protocol version for this state (always 1 for SSU1).
      Returns:
      the protocol version
    • getState

      Current state of the inbound session establishment.
      Returns:
      the current InboundState
    • isComplete

      public boolean isComplete()
      Check if the inbound establish state is complete.
      Returns:
      true if complete or failed
    • complete

      public void complete()
      Notify successful completion of the inbound session establishment.
    • addMessage

      public void addMessage(OutNetMessage msg)
      Queue a message to be sent after the session is established. This will only happen if we decide to send something during establishment.
      Parameters:
      msg - the message to send once the session is established
    • getNextQueuedMessage

      public OutNetMessage getNextQueuedMessage()
      Pull from the message queue.
      Returns:
      null if none
    • sessionRequestReceived

      public boolean sessionRequestReceived()
      Whether the SessionRequest message has been received from Alice.
      Returns:
      true if the initial request has arrived
    • getReceivedX

      public byte[] getReceivedX()
      The received X value from Alice's SessionRequest message.
      Returns:
      session request data or null
    • getReceivedOurIP

      public byte[] getReceivedOurIP()
      Our IP address as reported by Alice in the SessionRequest.
      Returns:
      our IP bytes or null
    • isIntroductionRequested

      public boolean isIntroductionRequested()
      Whether Alice requested an introduction. True by default if no extended options in session request, or the value of the introduction flag bit in the extended options.
      Returns:
      true if introduction was requested
    • getSentIP

      public byte[] getSentIP()
      Alice's apparent IP address.
      Returns:
      the IP address Alice appears to be connecting from
    • getSentPort

      public int getSentPort()
      Alice's apparent port number.
      Returns:
      the port Alice appears to be connecting from
    • fail

      public void fail()
      Mark this establishment attempt as failed.
    • getSentRelayTag

      public long getSentRelayTag()
      The relay tag we sent to Alice in the SessionCreated message.
      Returns:
      the relay tag, or 0 if not yet sent
    • setSentRelayTag

      public void setSentRelayTag(long tag)
      Set the relay tag to include in the SessionCreated message.
      Parameters:
      tag - the relay tag
    • getSentSignedOnTime

      public long getSentSignedOnTime()
      The signed-on time we sent to Alice.
      Returns:
      the signed-on timestamp
    • createdPacketSent

      public void createdPacketSent()
      Record that a SessionCreated packet was just sent, update backoff state.
    • getLifetime

      public long getLifetime()
      How long have we been trying to establish this session?
      Returns:
      the elapsed time in milliseconds
    • getLifetime

      public long getLifetime(long now)
      How long have we been trying to establish this session, using the given time.
      Parameters:
      now - the reference time
      Returns:
      the elapsed time in milliseconds
    • getEstablishBeginTime

      public long getEstablishBeginTime()
      The wall clock time when this establishment attempt began.
      Returns:
      the start timestamp
    • getNextSendTime

      public long getNextSendTime()
      The next time at which we should send a packet for this establishment. Returns the receive time after receiving a packet (including after constructor), or the send time plus backoff delay after sending a packet.
      Returns:
      the next scheduled send time
    • getRTT

      int getRTT()
      The estimated round-trip time for this establishment.
      Returns:
      the RTT in milliseconds
    • getRemoteHostId

      RemoteHostId getRemoteHostId()
      The RemoteHostId that uniquely identifies this establishment attempt.
      Returns:
      the remote host identifier
    • confirmedFullyReceived

      protected boolean confirmedFullyReceived()
      Have we fully received the SessionConfirmed messages from Alice? Caller must synchronize on this.
      Returns:
      true if all fragments have been received
    • getConfirmedIdentity

      public RouterIdentity getConfirmedIdentity()
      The confirmed identity of Alice (null if forged/unknown). Note that this isn't really confirmed - see below.
      Returns:
      Alice's RouterIdentity, or null
    • packetReceived

      protected void packetReceived()
      Update the next send time to now, as we just received a packet. Must call from synchronized method only.
    • toString

      public String toString()
      Return a human-readable description of this establish state.
      Overrides:
      toString in class Object
      Returns:
      debug string with peer address, lifetime, relay tag, and state