class Connection extends Object
| Modifier and Type | Class and Description |
|---|---|
(package private) class |
Connection.ConEvent
fired to reschedule event notification
|
(package private) class |
Connection.ResendPacketEvent
This is not normally scheduled.
|
(package private) class |
Connection.RetransmitEvent
A single retransmit timer for all packets.
|
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_CONNECT_TIMEOUT |
static int |
DISCONNECT_TIMEOUT
Wait up to 5 minutes after disconnection so we can ack/close packets.
|
(package private) static int |
FAST_RETRANSMIT_THRESHOLD
If we have been explicitly NACKed three times, retransmit the packet even if
there are other packets in flight.
|
static int |
MAX_RESEND_DELAY |
static int |
MAX_WINDOW_SIZE
This is the default maximum.
|
static int |
MIN_RESEND_DELAY |
| Constructor and Description |
|---|
Connection(I2PAppContext ctx,
ConnectionManager manager,
I2PSession session,
SchedulerChooser chooser,
SimpleTimer2 timer,
PacketQueue queue,
ConnectionPacketHandler handler,
ConnectionOptions opts,
boolean isInbound) |
| Modifier and Type | Method and Description |
|---|---|
(package private) void |
ackImmediately() |
List<PacketLocal> |
ackPackets(long ackThrough,
long[] nacks)
Process the acks and nacks received in a packet
|
void |
closeReceived()
Notify that a close was received.
|
void |
disconnect(boolean cleanDisconnect)
Must be called when we are done with this connection.
|
void |
disconnect(boolean cleanDisconnect,
boolean removeFromConMgr)
Must be called when we are done with this connection.
|
void |
disconnectComplete()
Must be called when we are done with this connection.
|
(package private) void |
eventOccurred() |
long |
getAckedPackets()
how many packets have we sent and the other side has ACKed?
|
long |
getCloseReceivedOn() |
long |
getCloseSentOn() |
long |
getCongestionWindowEnd() |
String |
getConnectionError() |
ConnectionManager |
getConnectionManager() |
long |
getCreatedOn() |
long |
getDisconnectScheduledOn() |
boolean |
getHardDisconnected() |
long |
getHighestAckedThrough() |
MessageInputStream |
getInputStream()
stream that the local peer receives data on
|
boolean |
getIsConnected()
Always true at the start, even if we haven't gotten a reply on an
outbound connection.
|
long |
getLastActivityOn() |
long |
getLastSendId()
What was the last packet Id sent to the peer?
|
long |
getLastSendTime()
When did we last send anything to the peer?
|
long |
getLifetime() |
long |
getLifetimeBytesReceived() |
long |
getLifetimeBytesSent() |
long |
getLifetimeDupMessagesReceived() |
long |
getLifetimeDupMessagesSent() |
int |
getLocalPort() |
long |
getNextOutboundPacketNum() |
long |
getNextSendTime()
Time when the scheduler next want to send a packet, or -1 if
never.
|
ConnectionOptions |
getOptions()
Retrieve the current ConnectionOptions.
|
MessageOutputStream |
getOutputStream()
stream that the local peer sends data to the remote peer on
|
ConnectionPacketHandler |
getPacketHandler() |
int |
getPort()
The remote port.
|
long |
getReceiveStreamId()
The stream ID of a peer connection that sends data to us, or zero if unknown.
|
Destination |
getRemotePeer()
who are we talking with
|
SigningPublicKey |
getRemoteSPK()
The key to verify signatures with.
|
boolean |
getResetReceived() |
boolean |
getResetSent() |
long |
getResetSentOn() |
long |
getSendStreamId()
What stream do we send data to the peer on?
|
I2PSession |
getSession() |
I2PSocketFull |
getSocket() |
(package private) int |
getSSThresh() |
int |
getUnackedPacketsReceived() |
int |
getUnackedPacketsSent()
how many packets have we sent but not yet received an ACK for?
|
void |
incrementBytesReceived(int bytes) |
void |
incrementBytesSent(int bytes) |
void |
incrementDupMessagesReceived(int msgs) |
void |
incrementDupMessagesSent(int msgs) |
void |
incrementUnackedPacketsReceived() |
boolean |
isChoked()
Is the other side choking us?
|
boolean |
isInbound() |
(package private) Connection.ResendPacketEvent |
newResendPacketEvent(PacketLocal packet)
A new ResendPacketEvent.
|
void |
notifyCloseSent()
Notify that a close was sent.
|
void |
notifyLastPacketAcked()
Notify that a close that we sent, and all previous packets, were acked.
|
(package private) void |
packetReceived() |
boolean |
packetSendChoke(long timeoutMs)
This doesn't "send a choke".
|
void |
resetReceived()
Notify that a reset was received.
|
void |
schedule(SimpleTimer.TimedEvent event,
long msToWait)
Schedule something on our timer.
|
void |
scheduleConnectionEvent(long msToWait)
Called from SchedulerImpl
|
(package private) void |
sendAvailable()
Flush any data that we can.
|
(package private) void |
sendPacket(PacketLocal packet)
This sends all 'normal' packets (acks and data) for the first time.
|
void |
setChoked(boolean on)
Set or clear if we are being choked by the other side.
|
void |
setChoking(boolean on)
Set or clear if we are choking the other side.
|
void |
setCongestionWindowEnd(long endMsg) |
void |
setConnectionError(String err) |
void |
setLastSendId(long id)
Set the packet Id that was sent to a peer.
|
void |
setNextSendTime(long when)
If the next send time is currently >= 0 (i.e.
|
void |
setOptions(ConnectionOptions opts)
Set the ConnectionOptions.
|
void |
setReceiveStreamId(long id) |
void |
setRemotePeer(Destination peer) |
void |
setRemoteTransientSPK(SigningPublicKey transientSPK) |
void |
setSendStreamId(long id) |
void |
setSocket(I2PSocketFull socket) |
String |
toString() |
void |
updateShareOpts() |
(package private) void |
waitForConnect()
wait until a connection is made or the connection fails within the
timeout period, setting the error accordingly.
|
(package private) void |
windowAdjusted()
Notify all threads waiting in packetSendChoke()
|
public static final int DEFAULT_CONNECT_TIMEOUT
public static final int DISCONNECT_TIMEOUT
static final int FAST_RETRANSMIT_THRESHOLD
public static final int MAX_RESEND_DELAY
public static final int MAX_WINDOW_SIZE
public static final int MIN_RESEND_DELAY
public Connection(I2PAppContext ctx, ConnectionManager manager, I2PSession session, SchedulerChooser chooser, SimpleTimer2 timer, PacketQueue queue, ConnectionPacketHandler handler, ConnectionOptions opts, boolean isInbound)
opts - may be nullvoid ackImmediately()
public List<PacketLocal> ackPackets(long ackThrough, long[] nacks)
public void closeReceived()
public void disconnect(boolean cleanDisconnect)
cleanDisconnect - if true, normal close; if false, send a RESETpublic void disconnect(boolean cleanDisconnect,
boolean removeFromConMgr)
cleanDisconnect - if true, normal close; if false, send a RESETremoveFromConMgr - if true, enters TIME-WAIT if necessary.
if false, MUST call disconnectComplete() later.
Should always be true unless called from ConnectionManager.public void disconnectComplete()
void eventOccurred()
public long getAckedPackets()
public long getCloseReceivedOn()
public long getCloseSentOn()
public long getCongestionWindowEnd()
public String getConnectionError()
public ConnectionManager getConnectionManager()
public long getCreatedOn()
public long getDisconnectScheduledOn()
public boolean getHardDisconnected()
public long getHighestAckedThrough()
public MessageInputStream getInputStream()
public boolean getIsConnected()
public long getLastActivityOn()
public long getLastSendId()
public long getLastSendTime()
public long getLifetime()
public long getLifetimeBytesReceived()
public long getLifetimeBytesSent()
public long getLifetimeDupMessagesReceived()
public long getLifetimeDupMessagesSent()
public int getLocalPort()
public long getNextOutboundPacketNum()
public long getNextSendTime()
public ConnectionOptions getOptions()
public MessageOutputStream getOutputStream()
public ConnectionPacketHandler getPacketHandler()
public int getPort()
public long getReceiveStreamId()
public Destination getRemotePeer()
public SigningPublicKey getRemoteSPK()
public boolean getResetReceived()
public boolean getResetSent()
public long getResetSentOn()
public long getSendStreamId()
public I2PSession getSession()
public I2PSocketFull getSocket()
int getSSThresh()
public int getUnackedPacketsReceived()
public int getUnackedPacketsSent()
public void incrementBytesReceived(int bytes)
public void incrementBytesSent(int bytes)
public void incrementDupMessagesReceived(int msgs)
public void incrementDupMessagesSent(int msgs)
public void incrementUnackedPacketsReceived()
public boolean isChoked()
public boolean isInbound()
Connection.ResendPacketEvent newResendPacketEvent(PacketLocal packet)
public void notifyCloseSent()
public void notifyLastPacketAcked()
void packetReceived()
public boolean packetSendChoke(long timeoutMs)
throws IOException,
InterruptedException
timeoutMs - 0 or negative means wait forever, 5 minutes maxIOExceptionInterruptedExceptionpublic void resetReceived()
public void schedule(SimpleTimer.TimedEvent event, long msToWait)
public void scheduleConnectionEvent(long msToWait)
void sendAvailable()
void sendPacket(PacketLocal packet)
public void setChoked(boolean on)
on - true for chokedpublic void setChoking(boolean on)
on - true for chokingpublic void setCongestionWindowEnd(long endMsg)
public void setConnectionError(String err)
public void setLastSendId(long id)
id - The packet IDpublic void setNextSendTime(long when)
public void setOptions(ConnectionOptions opts)
opts - ConnectionOptions non-nullpublic void setReceiveStreamId(long id)
id - 0 to 0xffffffffIllegalStateException - if already set to nonzeropublic void setRemotePeer(Destination peer)
peer - non-nullpublic void setRemoteTransientSPK(SigningPublicKey transientSPK)
transientSPK - null okpublic void setSendStreamId(long id)
id - 0 to 0xffffffffIllegalStateException - if already set to nonzeropublic void setSocket(I2PSocketFull socket)
public void updateShareOpts()
void waitForConnect()
void windowAdjusted()