|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.i2p.router.transport.ntcp.NTCPConnection
public class NTCPConnection
Coordinate the connection to a single peer. The NTCP transport sends individual I2NP messages AES/256/CBC encrypted with a simple checksum. The unencrypted message is encoded as follows: +-------+-------+--//--+---//----+-------+-------+-------+-------+ | sizeof(data) | data | padding | adler checksum of sz+data+pad | +-------+-------+--//--+---//----+-------+-------+-------+-------+ That message is then encrypted with the DH/2048 negotiated session key (station to station authenticated per the EstablishState class) using the last 16 bytes of the previous encrypted message as the IV. One special case is a metadata message where the sizeof(data) is 0. In that case, the unencrypted message is encoded as: +-------+-------+-------+-------+-------+-------+-------+-------+ | 0 | timestamp in seconds | uninterpreted +-------+-------+-------+-------+-------+-------+-------+-------+ uninterpreted | adler checksum of sz+data+pad | +-------+-------+-------+-------+-------+-------+-------+-------+
Constructor Summary | |
---|---|
NTCPConnection(RouterContext ctx,
NTCPTransport transport,
RouterIdentity remotePeer,
NTCPAddress remAddr)
Create an outbound unconnected NTCP connection |
|
NTCPConnection(RouterContext ctx,
NTCPTransport transport,
java.nio.channels.SocketChannel chan,
java.nio.channels.SelectionKey key)
Create an inbound connected (though not established) NTCP connection |
Method Summary | |
---|---|
void |
close()
|
void |
close(boolean allowRequeue)
|
void |
complete(FIFOBandwidthLimiter.Request req)
|
void |
enqueueInfoMessage()
|
boolean |
equals(java.lang.Object obj)
|
void |
finishInboundEstablishment(SessionKey key,
long clockSkew,
byte[] prevWriteEnd,
byte[] prevReadEnd)
|
void |
finishOutboundEstablishment(SessionKey key,
long clockSkew,
byte[] prevWriteEnd,
byte[] prevReadEnd)
|
java.nio.channels.SocketChannel |
getChannel()
|
long |
getClockSkew()
|
int |
getConsecutiveBacklog()
|
EstablishState |
getEstablishState()
|
boolean |
getIsInbound()
|
java.nio.channels.SelectionKey |
getKey()
|
long |
getMessagesReceived()
|
long |
getMessagesSent()
|
java.nio.ByteBuffer |
getNextReadBuf()
|
java.nio.ByteBuffer |
getNextWriteBuf()
|
long |
getOutboundQueueSize()
|
long |
getReadTime()
|
float |
getRecvRate()
|
NTCPAddress |
getRemoteAddress()
|
RouterIdentity |
getRemotePeer()
|
float |
getSendRate()
|
long |
getTimeSinceCreated()
|
long |
getTimeSinceReceive()
|
long |
getTimeSinceSend()
|
long |
getUptime()
|
int |
getWriteBufCount()
|
int |
hashCode()
|
boolean |
isClosed()
|
boolean |
isEstablished()
|
boolean |
isInbound()
|
void |
outboundConnected()
async callback after the outbound connection was completed (this should NOT block, as it occurs in the selector thread) |
int |
outboundQueueSize()
|
(package private) void |
prepareNextWrite()
prepare the next i2np message for transmission. |
(package private) void |
prepareNextWriteFast()
prepare the next i2np message for transmission. |
void |
queuedRecv(java.nio.ByteBuffer buf,
FIFOBandwidthLimiter.Request req)
We have read the data in the buffer, but we can't process it locally yet, because we're choked by the bandwidth limiter. |
void |
queuedWrite(java.nio.ByteBuffer buf,
FIFOBandwidthLimiter.Request req)
|
void |
recv(java.nio.ByteBuffer buf)
The contents of the buffer have been read and can be processed asap. |
(package private) void |
recvEncryptedI2NP(java.nio.ByteBuffer buf)
the contents of the buffer include some fraction of one or more encrypted and encoded I2NP messages. |
void |
removeReadBuf(java.nio.ByteBuffer buf)
|
void |
removeWriteBuf(java.nio.ByteBuffer buf)
|
void |
send(OutNetMessage msg)
toss the message onto the connection's send queue |
void |
setChannel(java.nio.channels.SocketChannel chan)
|
void |
setKey(java.nio.channels.SelectionKey key)
|
void |
setRemotePeer(RouterIdentity ident)
|
boolean |
tooBacklogged()
|
void |
write(java.nio.ByteBuffer buf)
The contents of the buffer have been encrypted / padded / etc and have been fully allocated for the bandwidth limiter. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public NTCPConnection(RouterContext ctx, NTCPTransport transport, java.nio.channels.SocketChannel chan, java.nio.channels.SelectionKey key)
public NTCPConnection(RouterContext ctx, NTCPTransport transport, RouterIdentity remotePeer, NTCPAddress remAddr)
Method Detail |
---|
public java.nio.channels.SocketChannel getChannel()
public java.nio.channels.SelectionKey getKey()
public void setChannel(java.nio.channels.SocketChannel chan)
public void setKey(java.nio.channels.SelectionKey key)
public boolean isInbound()
public boolean isEstablished()
public EstablishState getEstablishState()
public NTCPAddress getRemoteAddress()
public RouterIdentity getRemotePeer()
public void setRemotePeer(RouterIdentity ident)
public void finishInboundEstablishment(SessionKey key, long clockSkew, byte[] prevWriteEnd, byte[] prevReadEnd)
clockSkew
- alice's clock minus bob's clock in seconds (may be negative, obviously, but |val| should
be under 1 minute)public long getClockSkew()
public long getUptime()
public long getMessagesSent()
public long getMessagesReceived()
public long getOutboundQueueSize()
public long getTimeSinceSend()
public long getTimeSinceReceive()
public long getTimeSinceCreated()
public int getConsecutiveBacklog()
public boolean isClosed()
public void close()
public void close(boolean allowRequeue)
public void send(OutNetMessage msg)
public boolean tooBacklogged()
public void enqueueInfoMessage()
public void finishOutboundEstablishment(SessionKey key, long clockSkew, byte[] prevWriteEnd, byte[] prevReadEnd)
clockSkew
- alice's clock minus bob's clock in seconds (may be negative, obviously, but |val| should
be under 1 minute)public boolean getIsInbound()
void prepareNextWrite()
void prepareNextWriteFast()
public void outboundConnected()
public void complete(FIFOBandwidthLimiter.Request req)
complete
in interface FIFOBandwidthLimiter.CompleteListener
public int outboundQueueSize()
public void queuedRecv(java.nio.ByteBuffer buf, FIFOBandwidthLimiter.Request req)
public void queuedWrite(java.nio.ByteBuffer buf, FIFOBandwidthLimiter.Request req)
public void recv(java.nio.ByteBuffer buf)
public void write(java.nio.ByteBuffer buf)
public java.nio.ByteBuffer getNextReadBuf()
public void removeReadBuf(java.nio.ByteBuffer buf)
public int getWriteBufCount()
public java.nio.ByteBuffer getNextWriteBuf()
public void removeWriteBuf(java.nio.ByteBuffer buf)
public float getSendRate()
public float getRecvRate()
void recvEncryptedI2NP(java.nio.ByteBuffer buf)
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public long getReadTime()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |