java.lang.Object
net.i2p.router.tunnel.HopConfig
Defines the general configuration for a hop in a tunnel.
This is used for both participating tunnels and tunnels we create. Data only stored for tunnels we create should be in TunnelCreatorConfig to save space.
Field Summary
FieldsModifier and TypeFieldDescriptionprivate intAllocated bandwidth, in KBps.private longWhen the tunnel was created.private longWhen the tunnel expires.private SessionKeyThe initialization vector key.private SessionKeyThe layer key for the decryption.private final AtomicIntegerMessages processed so far.private intOld messages processed so far.private HashThe router we receive from.private TunnelIdThe tunnel id we receive on.private HashThe router we send to.private TunnelIdThe tunnel id we send on.Constructor Summary
ConstructorsMethod Summary
Public MethodsModifier and TypeMethodDescriptionintThe bandwidth allocated for this hop.(package private) intThis returns the number of processed messages since the last time this was called, and resets the count.longWhen was this tunnel created (in ms since the epoch)?longWhen does this tunnel expire (in ms since the epoch)?getIVKey()What key encrypts the preIV before passing it on?What key encrypts the layer before passing it on?intThe messages processed so far.What is the previous peer in the tunnel (null if gateway)?What tunnel ID are we receiving on? (null if uninitialized).longWhat tunnel ID are we receiving on? (0 if uninitialized).intThis returns the number of processed messages since the last time getAndResetRecentMessagesCount() was called.What is the next peer in the tunnel (null if endpoint)?What is the next tunnel ID we are sending to? (null if endpoint).longWhat is the next tunnel ID we are sending to? (0 if endpoint).voidTake note of a message being pumped through this tunnel.voidsetAllocatedBW(int bw) The bandwidth allocated for this hop.voidsetCreation(long when) The tunnel creation time, in ms since the epoch.voidsetExpiration(long when) The tunnel expiration time, in ms since the epoch.voidsetIVKey(SessionKey key) The key to encrypt the IV with before passing it on.voidsetLayerKey(SessionKey key) The key to encrypt the layer with before passing it on.voidsetReceiveFrom(Hash from) Do not set for gateway.voidsetReceiveTunnelId(long id) The receive tunnel ID, from 1 to 0xffffffff.voidThe tunnel ID to receive messages on.voidDo not set for endpoint.voidsetSendTunnelId(long id) The send tunnel ID, from 1 to 0xffffffff.voidThe tunnel ID to send messages through.Compact one-line hop identifier for log output: the next peer to send to.toString()
Field Details
_receiveTunnel
The tunnel id we receive on._receiveFrom
The router we receive from._sendTunnel
The tunnel id we send on._sendTo
The router we send to._layerKey
The layer key for the decryption._ivKey
The initialization vector key._creation
private long _creationWhen the tunnel was created._expiration
private long _expirationWhen the tunnel expires._messagesProcessed
Messages processed so far. An int rather than a long to save space, two billion messages of 1KB per 10 minutes is 3 GBps in one tunnel, and the lock-free access keeps the pumped-message counters off the monitor contended by every participating tunnel._oldMessagesProcessed
private volatile int _oldMessagesProcessedOld messages processed so far._allocatedBW
private volatile int _allocatedBWAllocated bandwidth, in KBps.
Constructor Details
HopConfig
public HopConfig()Creates a new HopConfig with default values.
Method Details
getReceiveTunnelId
public long getReceiveTunnelId()What tunnel ID are we receiving on? (0 if uninitialized).- Returns:
- the receive tunnel ID or 0
getReceiveTunnel
What tunnel ID are we receiving on? (null if uninitialized).- Returns:
- the receive tunnel or null
setReceiveTunnelId
The tunnel ID to receive messages on.- Parameters:
id- the tunnel ID
setReceiveTunnelId
public void setReceiveTunnelId(long id) The receive tunnel ID, from 1 to 0xffffffff.- Parameters:
id- 1 to 0xffffffff- Throws:
IllegalArgumentException- if less than or equal to zero or greater than max value
getReceiveFrom
What is the previous peer in the tunnel (null if gateway)?- Returns:
- the hash of the peer we receive from, or null at the gateway
setReceiveFrom
Do not set for gateway.- Parameters:
from- the previous peer hash
getSendTunnelId
public long getSendTunnelId()What is the next tunnel ID we are sending to? (0 if endpoint).- Returns:
- the send tunnel ID or 0
getSendTunnel
What is the next tunnel ID we are sending to? (null if endpoint).- Returns:
- the send tunnel or null
setSendTunnelId
The tunnel ID to send messages through. Do not set for endpoint.- Parameters:
id- the tunnel ID
setSendTunnelId
public void setSendTunnelId(long id) The send tunnel ID, from 1 to 0xffffffff. Do not set for endpoint.- Parameters:
id- 1 to 0xffffffff- Throws:
IllegalArgumentException- if less than or equal to zero or greater than max value
getSendTo
What is the next peer in the tunnel (null if endpoint)?- Returns:
- the hash of the peer we send to, or null at the endpoint
setSendTo
getLayerKey
What key encrypts the layer before passing it on?- Returns:
- the layer session key, or null if this hop does not relay layers
setLayerKey
The key to encrypt the layer with before passing it on.- Parameters:
key- the layer session key applied to relayed layer messages
getIVKey
What key encrypts the preIV before passing it on?- Returns:
- the IV session key, or null if this hop does not relay IVs
setIVKey
The key to encrypt the IV with before passing it on.- Parameters:
key- the IV session key applied to relayed pre-IV messages
getExpiration
public long getExpiration()When does this tunnel expire (in ms since the epoch)?- Returns:
- the expiration time in milliseconds since the epoch
setExpiration
public void setExpiration(long when) The tunnel expiration time, in ms since the epoch.- Parameters:
when- the expiration time in milliseconds since the epoch
getCreation
public long getCreation()When was this tunnel created (in ms since the epoch)?- Returns:
- the creation time in milliseconds since the epoch
setCreation
public void setCreation(long when) The tunnel creation time, in ms since the epoch.- Parameters:
when- the creation time in milliseconds since the epoch
getAllocatedBW
public int getAllocatedBW()The bandwidth allocated for this hop.- Returns:
- the bandwidth in Bps
setAllocatedBW
public void setAllocatedBW(int bw) The bandwidth allocated for this hop.- Parameters:
bw- the bandwidth in Bps
incrementProcessedMessages
public void incrementProcessedMessages()Take note of a message being pumped through this tunnel. "processed" is for incoming and "sent" is for outgoing (could be dropped in between).getProcessedMessagesCount
public int getProcessedMessagesCount()The messages processed so far.- Returns:
- the count of processed messages
getRecentMessagesCount
public int getRecentMessagesCount()This returns the number of processed messages since the last time getAndResetRecentMessagesCount() was called. As of 0.9.23, does NOT reset the count, see getAndResetRecentMessagesCount().- Returns:
- the recent messages count
getAndResetRecentMessagesCount
int getAndResetRecentMessagesCount()This returns the number of processed messages since the last time this was called, and resets the count. It should only be called by code that updates the router stats. SeeTunnelDispatcher.updateParticipatingStats(int).The counter is sampled once so the returned delta and the stored baseline refer to the same read; a concurrent increment lands in the next window.
- Returns:
- the number of messages processed since the previous call
toShortString
Compact one-line hop identifier for log output: the next peer to send to. No message counts or expiration, no newlines.- Returns:
- the next-hop identifier, or "local hop" for the final hop
toString