Class UDPConnectionSet
- java.lang.Object
-
- com.biglybt.core.networkmanager.impl.udp.UDPConnectionSet
-
public class UDPConnectionSet extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
UDPConnectionSet.SequenceGenerator
-
Field Summary
-
Constructor Summary
Constructors Modifier Constructor Description protected
UDPConnectionSet(UDPConnectionManager _manager, java.lang.String _connection_key, UDPSelector _selector, int _local_port, java.net.InetSocketAddress _remote_address)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
add(UDPConnection connection)
protected int
bytesToInt(byte[] bytes, int offset)
protected long
bytesToLong(byte[] bytes)
protected long
bytesToLong(byte[] bytes, int offset)
protected boolean
canWrite(UDPConnection connection)
protected int
cipherInt(RC4Engine cipher, int i)
void
close(UDPConnection connection, java.lang.String reason)
protected void
dumpState()
void
failed(UDPConnection connection, java.lang.Throwable reason)
protected void
failed(java.lang.Throwable e)
(package private) static void
forDocumentation()
private RC4Engine
getCipher(byte[] key)
protected int
getExplicitAckTicks()
protected java.lang.String
getKey()
protected java.lang.String
getName()
protected java.net.InetSocketAddress
getRemoteAddress()
protected UDPPacket
getRetransmitPacket()
protected int
getRetransmitTicks()
protected int
getRetransmitTicks(int resend_count)
protected UDPSelector
getSelector()
protected boolean
hasFailed()
protected boolean
idleLimitExceeded()
protected byte[]
intToBytes(int i)
protected void
logStats()
protected void
poll()
void
receive(byte[] initial_data, int initial_data_length)
protected void
receiveAckCommand(java.nio.ByteBuffer buffer)
protected void
receiveCloseCommand(java.nio.ByteBuffer buffer)
protected void
receiveCrypto(java.nio.ByteBuffer buffer)
protected void
receiveDataCommand(int sequence, java.nio.ByteBuffer buffer, int header_length)
protected void
receiveStatsReply(java.nio.ByteBuffer buffer)
protected void
receiveStatsRequest(java.nio.ByteBuffer buffer)
private void
receiveTimerBase(int theirs)
protected boolean
remoteLastInSequence(int alt_sequence)
protected boolean
remove(UDPConnection connection)
protected void
removed()
private void
resetTimerStats()
protected void
retransmitExpired()
protected void
send(UDPPacket packet)
protected void
sendAckCommand(boolean timer_expired)
protected void
sendCloseCommand(UDPConnection connection)
protected int
sendCrypto(java.nio.ByteBuffer[] buffers, int offset, int length)
protected int
sendDataCommand(UDPConnection connection, java.nio.ByteBuffer[] buffers, int offset, int length)
protected void
sendStatsRequest()
private void
sendTimerBase()
protected void
setSecret(UDPConnection connection, byte[] session_secret)
protected void
startKeepAliveTimer()
protected void
stopKeepAliveTimer()
protected void
timerTick()
protected void
trace(UDPConnection connection, java.lang.String str)
protected void
trace(java.lang.String str)
protected int
write(UDPConnection connection, java.nio.ByteBuffer[] buffers, int offset, int length)
protected int
writeHeaderEnd(java.nio.ByteBuffer buffer, boolean randomise_size)
protected int[]
writeHeaderStart(java.nio.ByteBuffer buffer, byte command, byte flags)
-
-
-
Field Detail
-
LOGID
private static final LogIDs LOGID
-
DEBUG_SEQUENCES
private static final boolean DEBUG_SEQUENCES
- See Also:
- Constant Field Values
-
KEYA_IV
private static final byte[] KEYA_IV
-
KEYB_IV
private static final byte[] KEYB_IV
-
KEYC_IV
private static final byte[] KEYC_IV
-
KEYD_IV
private static final byte[] KEYD_IV
-
MIN_MSS
private static final int MIN_MSS
- See Also:
- Constant Field Values
-
MAX_HEADER
private static final int MAX_HEADER
- See Also:
- Constant Field Values
-
MIN_WRITE_PAYLOAD
public static final int MIN_WRITE_PAYLOAD
- See Also:
- Constant Field Values
-
MAX_BUFFERED_PAYLOAD
public static final int MAX_BUFFERED_PAYLOAD
- See Also:
- Constant Field Values
-
manager
private final UDPConnectionManager manager
-
selector
private final UDPSelector selector
-
local_port
private final int local_port
-
remote_address
private final java.net.InetSocketAddress remote_address
-
outgoing
boolean outgoing
-
connection_key
private final java.lang.String connection_key
-
random
private java.util.Random random
-
lead_connection
private UDPConnection lead_connection
-
header_cipher_out
private RC4Engine header_cipher_out
-
header_cipher_in
private RC4Engine header_cipher_in
-
in_seq_generator
private UDPConnectionSet.SequenceGenerator in_seq_generator
-
out_seq_generator
private UDPConnectionSet.SequenceGenerator out_seq_generator
-
crypto_done
private volatile boolean crypto_done
-
failed
private volatile boolean failed
-
connections
private final java.util.Map connections
-
connection_writers
private final java.util.LinkedList connection_writers
-
total_tick_count
private long total_tick_count
-
STATS_LOG_TIMER
private static final int STATS_LOG_TIMER
- See Also:
- Constant Field Values
-
STATS_LOG_TICKS
private static final int STATS_LOG_TICKS
-
stats_log_ticks
private int stats_log_ticks
-
IDLE_TIMER
private static final int IDLE_TIMER
- See Also:
- Constant Field Values
-
IDLE_TICKS
private static final int IDLE_TICKS
-
idle_ticks
private int idle_ticks
-
TIMER_BASE_DEFAULT
private static final int TIMER_BASE_DEFAULT
- See Also:
- Constant Field Values
-
TIMER_BASE_MIN
private static final int TIMER_BASE_MIN
- See Also:
- Constant Field Values
-
TIMER_BASE_MAX
private static final int TIMER_BASE_MAX
- See Also:
- Constant Field Values
-
current_timer_base
private int current_timer_base
-
old_timer_base
private int old_timer_base
-
timer_is_adjusting
private boolean timer_is_adjusting
-
stats_packets_unique_sent
private int stats_packets_unique_sent
-
stats_packets_resent_via_timer
private int stats_packets_resent_via_timer
-
stats_packets_unique_received
private int stats_packets_unique_received
-
stats_packets_duplicates
private int stats_packets_duplicates
-
STATS_RESET_TIMER
private static final int STATS_RESET_TIMER
- See Also:
- Constant Field Values
-
stats_reset_time
private long stats_reset_time
-
total_packets_sent
private int total_packets_sent
-
total_data_sent
private int total_data_sent
-
total_data_resent
private int total_data_resent
-
total_protocol_sent
private int total_protocol_sent
-
total_protocol_resent
private int total_protocol_resent
-
total_packets_unique_sent
private int total_packets_unique_sent
-
total_packets_received
private int total_packets_received
-
total_packets_unique_received
private int total_packets_unique_received
-
total_packets_duplicates
private int total_packets_duplicates
-
total_packets_out_of_order
private int total_packets_out_of_order
-
total_packets_resent_via_timer
private int total_packets_resent_via_timer
-
total_packets_resent_via_ack
private int total_packets_resent_via_ack
-
retransmit_ticks
private int retransmit_ticks
-
current_retransmit_target
private UDPPacket current_retransmit_target
-
RETRANSMIT_COUNT_LIMIT
private static final int RETRANSMIT_COUNT_LIMIT
- See Also:
- Constant Field Values
-
MIN_RETRANSMIT_TIMER
private static final int MIN_RETRANSMIT_TIMER
- See Also:
- Constant Field Values
-
MIN_RETRANSMIT_TICKS
private static final int MIN_RETRANSMIT_TICKS
-
MAX_RETRANSMIT_TIMER
private static final int MAX_RETRANSMIT_TIMER
- See Also:
- Constant Field Values
-
MAX_RETRANSMIT_TICKS
private static final int MAX_RETRANSMIT_TICKS
-
MAX_TRANSMIT_UNACK_DATA_PACKETS
private static final int MAX_TRANSMIT_UNACK_DATA_PACKETS
- See Also:
- Constant Field Values
-
MAX_TRANSMIT_UNACK_PACKETS
private static final int MAX_TRANSMIT_UNACK_PACKETS
- See Also:
- Constant Field Values
-
transmit_unack_packets
private final java.util.List transmit_unack_packets
-
MAX_CONTIGUOUS_RETRANS_FOR_ACK
private static final int MAX_CONTIGUOUS_RETRANS_FOR_ACK
- See Also:
- Constant Field Values
-
MIN_KEEPALIVE_TIMER
private static final int MIN_KEEPALIVE_TIMER
- See Also:
- Constant Field Values
-
MIN_KEEPALIVE_TICKS
private static final int MIN_KEEPALIVE_TICKS
-
MAX_KEEPALIVE_TIMER
private static final int MAX_KEEPALIVE_TIMER
- See Also:
- Constant Field Values
-
MAX_KEEPALIVE_TICKS
private static final int MAX_KEEPALIVE_TICKS
-
keep_alive_ticks
private int keep_alive_ticks
-
receive_last_inorder_sequence
private int receive_last_inorder_sequence
-
receive_last_inorder_alt_sequence
private int receive_last_inorder_alt_sequence
-
receive_their_last_inorder_sequence
private int receive_their_last_inorder_sequence
-
RECEIVE_UNACK_IN_SEQUENCE_LIMIT
private static final int RECEIVE_UNACK_IN_SEQUENCE_LIMIT
- See Also:
- Constant Field Values
-
current_receive_unack_in_sequence_count
private long current_receive_unack_in_sequence_count
-
sent_receive_unack_in_sequence_count
private long sent_receive_unack_in_sequence_count
-
RECEIVE_OUT_OF_ORDER_ACK_LIMIT
private static final int RECEIVE_OUT_OF_ORDER_ACK_LIMIT
- See Also:
- Constant Field Values
-
current_receive_out_of_order_count
private long current_receive_out_of_order_count
-
sent_receive_out_of_order_count
private long sent_receive_out_of_order_count
-
RECEIVE_DONE_SEQ_MAX
private static final int RECEIVE_DONE_SEQ_MAX
- See Also:
- Constant Field Values
-
receive_done_sequences
private final java.util.LinkedList receive_done_sequences
-
RECEIVE_OUT_OF_ORDER_PACKETS_MAX
private static final int RECEIVE_OUT_OF_ORDER_PACKETS_MAX
- See Also:
- Constant Field Values
-
receive_out_of_order_packets
private final java.util.List receive_out_of_order_packets
-
explicitack_ticks
private int explicitack_ticks
-
MAX_SEQ_MEMORY
static final int MAX_SEQ_MEMORY
-
-
Constructor Detail
-
UDPConnectionSet
protected UDPConnectionSet(UDPConnectionManager _manager, java.lang.String _connection_key, UDPSelector _selector, int _local_port, java.net.InetSocketAddress _remote_address)
-
-
Method Detail
-
getSelector
protected UDPSelector getSelector()
-
getRemoteAddress
protected java.net.InetSocketAddress getRemoteAddress()
-
getKey
protected java.lang.String getKey()
-
add
protected void add(UDPConnection connection) throws java.io.IOException
- Throws:
java.io.IOException
-
remove
protected boolean remove(UDPConnection connection)
-
poll
protected void poll()
-
setSecret
protected void setSecret(UDPConnection connection, byte[] session_secret)
-
getCipher
private RC4Engine getCipher(byte[] key)
-
sendTimerBase
private void sendTimerBase()
-
resetTimerStats
private void resetTimerStats()
-
receiveTimerBase
private void receiveTimerBase(int theirs)
-
timerTick
protected void timerTick() throws java.io.IOException
- Throws:
java.io.IOException
-
getRetransmitTicks
protected int getRetransmitTicks()
-
getExplicitAckTicks
protected int getExplicitAckTicks()
-
startKeepAliveTimer
protected void startKeepAliveTimer()
-
stopKeepAliveTimer
protected void stopKeepAliveTimer()
-
idleLimitExceeded
protected boolean idleLimitExceeded()
-
getRetransmitPacket
protected UDPPacket getRetransmitPacket()
-
getRetransmitTicks
protected int getRetransmitTicks(int resend_count)
-
retransmitExpired
protected void retransmitExpired() throws java.io.IOException
- Throws:
java.io.IOException
-
remoteLastInSequence
protected boolean remoteLastInSequence(int alt_sequence)
-
dumpState
protected void dumpState()
-
send
protected void send(UDPPacket packet) throws java.io.IOException
- Throws:
java.io.IOException
-
receive
public void receive(byte[] initial_data, int initial_data_length) throws java.io.IOException
- Throws:
java.io.IOException
-
sendCrypto
protected int sendCrypto(java.nio.ByteBuffer[] buffers, int offset, int length) throws java.io.IOException
- Throws:
java.io.IOException
-
receiveCrypto
protected void receiveCrypto(java.nio.ByteBuffer buffer) throws java.io.IOException
- Throws:
java.io.IOException
-
sendDataCommand
protected int sendDataCommand(UDPConnection connection, java.nio.ByteBuffer[] buffers, int offset, int length) throws java.io.IOException
- Throws:
java.io.IOException
-
receiveDataCommand
protected void receiveDataCommand(int sequence, java.nio.ByteBuffer buffer, int header_length) throws java.io.IOException
- Throws:
java.io.IOException
-
sendAckCommand
protected void sendAckCommand(boolean timer_expired) throws java.io.IOException
- Throws:
java.io.IOException
-
receiveAckCommand
protected void receiveAckCommand(java.nio.ByteBuffer buffer) throws java.io.IOException
- Throws:
java.io.IOException
-
sendStatsRequest
protected void sendStatsRequest() throws java.io.IOException
- Throws:
java.io.IOException
-
receiveStatsRequest
protected void receiveStatsRequest(java.nio.ByteBuffer buffer) throws java.io.IOException
- Throws:
java.io.IOException
-
receiveStatsReply
protected void receiveStatsReply(java.nio.ByteBuffer buffer) throws java.io.IOException
- Throws:
java.io.IOException
-
sendCloseCommand
protected void sendCloseCommand(UDPConnection connection) throws java.io.IOException
- Throws:
java.io.IOException
-
receiveCloseCommand
protected void receiveCloseCommand(java.nio.ByteBuffer buffer) throws java.io.IOException
- Throws:
java.io.IOException
-
writeHeaderStart
protected int[] writeHeaderStart(java.nio.ByteBuffer buffer, byte command, byte flags) throws java.io.IOException
- Throws:
java.io.IOException
-
writeHeaderEnd
protected int writeHeaderEnd(java.nio.ByteBuffer buffer, boolean randomise_size) throws java.io.IOException
- Throws:
java.io.IOException
-
write
protected int write(UDPConnection connection, java.nio.ByteBuffer[] buffers, int offset, int length) throws java.io.IOException
- Throws:
java.io.IOException
-
canWrite
protected boolean canWrite(UDPConnection connection)
-
close
public void close(UDPConnection connection, java.lang.String reason)
-
failed
public void failed(UDPConnection connection, java.lang.Throwable reason)
-
failed
protected void failed(java.lang.Throwable e)
-
hasFailed
protected boolean hasFailed()
-
removed
protected void removed()
-
forDocumentation
static void forDocumentation()
-
cipherInt
protected int cipherInt(RC4Engine cipher, int i)
-
bytesToInt
protected int bytesToInt(byte[] bytes, int offset)
-
intToBytes
protected byte[] intToBytes(int i)
-
bytesToLong
protected long bytesToLong(byte[] bytes)
-
bytesToLong
protected long bytesToLong(byte[] bytes, int offset)
-
getName
protected java.lang.String getName()
-
logStats
protected void logStats()
-
trace
protected void trace(java.lang.String str)
-
trace
protected void trace(UDPConnection connection, java.lang.String str)
-
-