java.lang.Object
net.i2p.router.transport.udp.InboundEstablishState
- Direct Known Subclasses:
InboundEstablishState2
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.
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumStates for inbound SSU session establishment.Field Summary
FieldsModifier and TypeFieldDescriptionprotected final byte[]Alice's IP address from the SessionCreated message.protected final intAlice's port number.protected byte[]Our IP address as seen by Alice.protected final intOur port number as seen by Alice.protected final RouterContextRouter context.protected intCount of SessionCreated packets sent (for exponential backoff).protected InboundEstablishState.InboundStateCurrent state in the inbound establishment protocol.protected final longTimestamp when establishment began.protected booleanWhether Alice requested introduction (default true for SSU 1, false for SSU 2).protected longLast packet send time.protected final LogLogger.protected longNext scheduled send time.private final Queue<OutNetMessage> Messages queued while session was being established.protected RouterIdentityIdentity after successful signature verification.private byte[][]SessionConfirmed message fragments from Alice (fragmentation theoretical only).protected RouterIdentityIdentity before signature verification.private byte[]SessionRequest message data from Alice.protected final RemoteHostIdRemote host identifier for uniqueness.protected intEstimated round-trip time.protected longRelay tag we sent to Alice.private longSigned-on time we sent to Alice.protected static final longBasic delay before backoff Transmissions at 0, 1, 3, 7 sec.Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedInboundEstablishState(RouterContext ctx, InetSocketAddress addr) For SSU2.Method Summary
Modifier and TypeMethodDescriptionvoidaddMessage(OutNetMessage msg) Queue a message to be sent after the session is established.voidcomplete()Notify successful completion of the inbound session establishment.protected booleanHave we fully received the SessionConfirmed messages from Alice? Caller must synchronize on this.voidRecord that a SessionCreated packet was just sent, update backoff state.voidfail()Mark this establishment attempt as failed.The confirmed identity of Alice (null if forged/unknown).longThe wall clock time when this establishment attempt began.longHow long have we been trying to establish this session?longgetLifetime(long now) How long have we been trying to establish this session, using the given time.protected static longMax delay including backoff.Pull from the message queue.longThe next time at which we should send a packet for this establishment.byte[]Our IP address as reported by Alice in the SessionRequest.byte[]The received X value from Alice's SessionRequest message.(package private) RemoteHostIdThe RemoteHostId that uniquely identifies this establishment attempt.(package private) intgetRTT()The estimated round-trip time for this establishment.byte[]Alice's apparent IP address.intAlice's apparent port number.longThe relay tag we sent to Alice in the SessionCreated message.longThe signed-on time we sent to Alice.getState()Current state of the inbound session establishment.intReturn the SSU protocol version for this state (always 1 for SSU1).booleanCheck if the inbound establish state is complete.booleanWhether Alice requested an introduction.protected voidUpdate the next send time to now, as we just received a packet.booleanWhether the SessionRequest message has been received from Alice.voidsetSentRelayTag(long tag) Set the relay tag to include in the SessionCreated message.toString()Return a human-readable description of this establish state.
Field Details
_context
Router context._log
Logger._receivedX
private byte[] _receivedXSessionRequest message data from Alice._bobIP
protected byte[] _bobIPOur IP address as seen by Alice._bobPort
protected final int _bobPortOur port number as seen by Alice._aliceIP
protected final byte[] _aliceIPAlice's IP address from the SessionCreated message._alicePort
protected final int _alicePortAlice's port number._sentRelayTag
protected long _sentRelayTagRelay tag we sent to Alice._sentSignedOnTime
private long _sentSignedOnTimeSigned-on time we sent to Alice._receivedIdentity
private byte[][] _receivedIdentitySessionConfirmed message fragments from Alice (fragmentation theoretical only)._receivedUnconfirmedIdentity
Identity before signature verification._receivedConfirmedIdentity
Identity after successful signature verification._establishBegin
protected final long _establishBeginTimestamp when establishment began._lastSend
protected long _lastSendLast packet send time._nextSend
protected long _nextSendNext scheduled send time._remoteHostId
Remote host identifier for uniqueness._currentState
Current state in the inbound establishment protocol._queuedMessages
Messages queued while session was being established._createdSentCount
protected int _createdSentCountCount of SessionCreated packets sent (for exponential backoff)._introductionRequested
protected boolean _introductionRequestedWhether Alice requested introduction (default true for SSU 1, false for SSU 2)._rtt
protected int _rttEstimated round-trip time.RETRANSMIT_DELAY
protected static final long RETRANSMIT_DELAYBasic delay before backoff Transmissions at 0, 1, 3, 7 sec. This should be a little shorter than for outbound.
Constructor Details
InboundEstablishState
For SSU2.- Parameters:
ctx- router context, used for the clock and the logaddr- 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
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
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
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