net.i2p.router.transport.udp
Class PeerState

java.lang.Object
  extended bynet.i2p.router.transport.udp.PeerState

public class PeerState
extends java.lang.Object

Contain all of the state about a UDP connection to a peer


Constructor Summary
PeerState(I2PAppContext ctx)
           
 
Method Summary
 boolean allocateSendingBytes(int size)
          Decrement the remaining bytes in the current period's window, returning true if the full size can be decremented, false if it cannot.
static java.lang.String calculateRemoteHostString(byte[] ip, int port)
           
static java.lang.String calculateRemoteHostString(UDPPacket packet)
           
 void congestionOccurred()
          either they told us to back off, or we had to resend to get the data through.
 void dataReceived()
           
 void ECNReceived()
          we received a backoff request, so cut our send window
 boolean equals(java.lang.Object o)
           
 short getClockSkew()
          how far off is the remote peer from our clock, in seconds?
 int getConsecutiveSendingSecondsWithoutACKS()
          how many seconds have we sent packets without any ACKs received?
 SessionKey getCurrentCipherKey()
          The AES key used to encrypt/decrypt packets, set only after the connection is established.
 SessionKey getCurrentMACKey()
          The AES key used to verify packets, set only after the connection is established.
 long getCurrentReceiveSecond()
          what is the current receive second, for congestion control?
 boolean getCurrentSecondECNReceived()
          have we received a packet with the ECN bit set in the current second?
 long getKeyEstablishedTime()
          when were the current cipher and MAC keys established/rekeyed?
 long getLastACKSend()
          when did we last send an ACK to the peer?
 long getLastReceiveTime()
          when did we last receive a packet from them?
 long getLastSendTime()
          when did we last send them a packet?
 long getMessagesReceived()
           
 long getMessagesSent()
           
 int getMTU()
          what is the largest packet we can send to the peer?
 long getMTULastChecked()
          when did we last check the MTU?
 SessionKey getNextCipherKey()
          The pending AES key for encrypting/decrypting packets if we are rekeying the connection, or null if we are not in the process of rekeying.
 byte[] getNextKeyingMaterial()
          The keying material used for the rekeying, or null if we are not in the process of rekeying.
 SessionKey getNextMACKey()
          The pending AES key for verifying packets if we are rekeying the connection, or null if we are not in the process of rekeying.
 boolean getRekeyBeganLocally()
          true if we began the current rekeying, false otherwise
 java.lang.String getRemoteHostString()
           
 byte[] getRemoteIP()
          what IP is the peer sending and receiving packets on?
 java.net.InetAddress getRemoteIPAddress()
           
 Hash getRemotePeer()
          The peer are we talking to.
 int getRemotePort()
          what port is the peer sending and receiving packets on?
 boolean getRemoteRequiresIntroduction()
          if we need to contact them, do we need to talk to an introducer?
 boolean getRemoteWantsPreviousACKs()
          have all of the packets received in the current second requested that the previous second's ACKs be sent?
 int getSendWindowBytes()
          how many bytes should we send to the peer in a second
 int getSendWindowBytesRemaining()
          how many bytes can we send to the peer in the current second
 int getSlowStartThreshold()
           
 long getTheyRelayToUsAs()
          If they have offered to serve as an introducer to us, this is the tag we can use to publish that fact.
 long getWeRelayToThemAs()
          if we are serving as an introducer to them, this is the the tag that they can publish that, when presented to us, will cause us to send a relay introduction to the current peer
 int hashCode()
           
 void incrementConsecutiveSendingSecondsWithoutACKS()
           
 void messageACKed(int bytesACKed)
          we sent a message which was ACKed containing the given # of bytes
 void messageFullyReceived(java.lang.Long messageId)
          we received the message specified completely
 void remoteDoesNotWantPreviousACKs()
          have all of the packets received in the current second requested that the previous second's ACKs be sent?
 void resetConsecutiveSendingSecondsWithoutACKS()
           
 java.util.List retrieveACKs()
          pull off the ACKs (Long) to send to the peer
 void setClockSkew(short skew)
          how far off is the remote peer from our clock, in seconds?
 void setCurrentCipherKey(SessionKey key)
          The AES key used to encrypt/decrypt packets, set only after the connection is established.
 void setCurrentMACKey(SessionKey key)
          The AES key used to verify packets, set only after the connection is established.
 void setCurrentReceiveSecond(long sec)
          what is the current receive second, for congestion control?
 void setKeyEstablishedTime(long when)
          when were the current cipher and MAC keys established/rekeyed?
 void setLastACKSend(long when)
           
 void setLastReceiveTime(long when)
          when did we last receive a packet from them?
 void setLastSendTime(long when)
          when did we last send them a packet?
 void setMTU(int mtu)
          what is the largest packet we can send to the peer?
 void setNextCipherKey(SessionKey key)
          The pending AES key for encrypting/decrypting packets if we are rekeying the connection, or null if we are not in the process of rekeying.
 void setNextKeyingMaterial(byte[] data)
          The keying material used for the rekeying, or null if we are not in the process of rekeying.
 void setNextMACKey(SessionKey key)
          The pending AES key for verifying packets if we are rekeying the connection, or null if we are not in the process of rekeying.
 void setRekeyBeganLocally(boolean local)
          true if we began the current rekeying, false otherwise
 void setRemoteAddress(byte[] ip, int port)
          what IP+port is the peer sending and receiving packets on?
 void setRemotePeer(Hash peer)
          The peer are we talking to.
 void setRemoteRequiresIntroduction(boolean required)
          if we need to contact them, do we need to talk to an introducer?
 void setTheyRelayToUsAs(long tag)
          If they have offered to serve as an introducer to us, this is the tag we can use to publish that fact.
 void setWeRelayToThemAs(long tag)
          if we are serving as an introducer to them, this is the the tag that they can publish that, when presented to us, will cause us to send a relay introduction to the current peer
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PeerState

public PeerState(I2PAppContext ctx)
Method Detail

getRemotePeer

public Hash getRemotePeer()
The peer are we talking to. This should be set as soon as this state is created if we are initiating a connection, but if we are receiving the connection this will be set only after the connection is established.


getCurrentMACKey

public SessionKey getCurrentMACKey()
The AES key used to verify packets, set only after the connection is established.


getCurrentCipherKey

public SessionKey getCurrentCipherKey()
The AES key used to encrypt/decrypt packets, set only after the connection is established.


getNextMACKey

public SessionKey getNextMACKey()
The pending AES key for verifying packets if we are rekeying the connection, or null if we are not in the process of rekeying.


getNextCipherKey

public SessionKey getNextCipherKey()
The pending AES key for encrypting/decrypting packets if we are rekeying the connection, or null if we are not in the process of rekeying.


getNextKeyingMaterial

public byte[] getNextKeyingMaterial()
The keying material used for the rekeying, or null if we are not in the process of rekeying.


getRekeyBeganLocally

public boolean getRekeyBeganLocally()
true if we began the current rekeying, false otherwise


getKeyEstablishedTime

public long getKeyEstablishedTime()
when were the current cipher and MAC keys established/rekeyed?


getClockSkew

public short getClockSkew()
how far off is the remote peer from our clock, in seconds?


getCurrentReceiveSecond

public long getCurrentReceiveSecond()
what is the current receive second, for congestion control?


getLastSendTime

public long getLastSendTime()
when did we last send them a packet?


getLastReceiveTime

public long getLastReceiveTime()
when did we last receive a packet from them?


getConsecutiveSendingSecondsWithoutACKS

public int getConsecutiveSendingSecondsWithoutACKS()
how many seconds have we sent packets without any ACKs received?


getCurrentSecondECNReceived

public boolean getCurrentSecondECNReceived()
have we received a packet with the ECN bit set in the current second?


getRemoteWantsPreviousACKs

public boolean getRemoteWantsPreviousACKs()
have all of the packets received in the current second requested that the previous second's ACKs be sent?


getSendWindowBytes

public int getSendWindowBytes()
how many bytes should we send to the peer in a second


getSendWindowBytesRemaining

public int getSendWindowBytesRemaining()
how many bytes can we send to the peer in the current second


getRemoteIP

public byte[] getRemoteIP()
what IP is the peer sending and receiving packets on?


getRemoteIPAddress

public java.net.InetAddress getRemoteIPAddress()

getRemotePort

public int getRemotePort()
what port is the peer sending and receiving packets on?


getRemoteRequiresIntroduction

public boolean getRemoteRequiresIntroduction()
if we need to contact them, do we need to talk to an introducer?


getWeRelayToThemAs

public long getWeRelayToThemAs()
if we are serving as an introducer to them, this is the the tag that they can publish that, when presented to us, will cause us to send a relay introduction to the current peer


getTheyRelayToUsAs

public long getTheyRelayToUsAs()
If they have offered to serve as an introducer to us, this is the tag we can use to publish that fact.


getMTU

public int getMTU()
what is the largest packet we can send to the peer?


getMTULastChecked

public long getMTULastChecked()
when did we last check the MTU?


setRemotePeer

public void setRemotePeer(Hash peer)
The peer are we talking to. This should be set as soon as this state is created if we are initiating a connection, but if we are receiving the connection this will be set only after the connection is established.


setCurrentMACKey

public void setCurrentMACKey(SessionKey key)
The AES key used to verify packets, set only after the connection is established.


setCurrentCipherKey

public void setCurrentCipherKey(SessionKey key)
The AES key used to encrypt/decrypt packets, set only after the connection is established.


setNextMACKey

public void setNextMACKey(SessionKey key)
The pending AES key for verifying packets if we are rekeying the connection, or null if we are not in the process of rekeying.


setNextCipherKey

public void setNextCipherKey(SessionKey key)
The pending AES key for encrypting/decrypting packets if we are rekeying the connection, or null if we are not in the process of rekeying.


setNextKeyingMaterial

public void setNextKeyingMaterial(byte[] data)
The keying material used for the rekeying, or null if we are not in the process of rekeying.


setRekeyBeganLocally

public void setRekeyBeganLocally(boolean local)
true if we began the current rekeying, false otherwise


setKeyEstablishedTime

public void setKeyEstablishedTime(long when)
when were the current cipher and MAC keys established/rekeyed?


setClockSkew

public void setClockSkew(short skew)
how far off is the remote peer from our clock, in seconds?


setCurrentReceiveSecond

public void setCurrentReceiveSecond(long sec)
what is the current receive second, for congestion control?


setLastSendTime

public void setLastSendTime(long when)
when did we last send them a packet?


setLastReceiveTime

public void setLastReceiveTime(long when)
when did we last receive a packet from them?


incrementConsecutiveSendingSecondsWithoutACKS

public void incrementConsecutiveSendingSecondsWithoutACKS()

resetConsecutiveSendingSecondsWithoutACKS

public void resetConsecutiveSendingSecondsWithoutACKS()

remoteDoesNotWantPreviousACKs

public void remoteDoesNotWantPreviousACKs()
have all of the packets received in the current second requested that the previous second's ACKs be sent?


allocateSendingBytes

public boolean allocateSendingBytes(int size)
Decrement the remaining bytes in the current period's window, returning true if the full size can be decremented, false if it cannot. If it is not decremented, the window size remaining is not adjusted at all.


setRemoteAddress

public void setRemoteAddress(byte[] ip,
                             int port)
what IP+port is the peer sending and receiving packets on?


setRemoteRequiresIntroduction

public void setRemoteRequiresIntroduction(boolean required)
if we need to contact them, do we need to talk to an introducer?


setWeRelayToThemAs

public void setWeRelayToThemAs(long tag)
if we are serving as an introducer to them, this is the the tag that they can publish that, when presented to us, will cause us to send a relay introduction to the current peer


setTheyRelayToUsAs

public void setTheyRelayToUsAs(long tag)
If they have offered to serve as an introducer to us, this is the tag we can use to publish that fact.


setMTU

public void setMTU(int mtu)
what is the largest packet we can send to the peer?


getSlowStartThreshold

public int getSlowStartThreshold()

messageFullyReceived

public void messageFullyReceived(java.lang.Long messageId)
we received the message specified completely


congestionOccurred

public void congestionOccurred()
either they told us to back off, or we had to resend to get the data through.


retrieveACKs

public java.util.List retrieveACKs()
pull off the ACKs (Long) to send to the peer


messageACKed

public void messageACKed(int bytesACKed)
we sent a message which was ACKed containing the given # of bytes


getMessagesSent

public long getMessagesSent()

getMessagesReceived

public long getMessagesReceived()

ECNReceived

public void ECNReceived()
we received a backoff request, so cut our send window


dataReceived

public void dataReceived()

getLastACKSend

public long getLastACKSend()
when did we last send an ACK to the peer?


setLastACKSend

public void setLastACKSend(long when)

getRemoteHostString

public java.lang.String getRemoteHostString()

calculateRemoteHostString

public static java.lang.String calculateRemoteHostString(byte[] ip,
                                                         int port)

calculateRemoteHostString

public static java.lang.String calculateRemoteHostString(UDPPacket packet)

hashCode

public int hashCode()

equals

public boolean equals(java.lang.Object o)

toString

public java.lang.String toString()