Class UDPConnectionSet

java.lang.Object
com.biglybt.core.networkmanager.impl.udp.UDPConnectionSet

public class UDPConnectionSet extends Object
  • Field Details

    • LOGID

      private static final LogIDs LOGID
    • DEBUG_SEQUENCES

      private static final boolean DEBUG_SEQUENCES
      See Also:
    • 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:
    • MAX_HEADER

      private static final int MAX_HEADER
      See Also:
    • MIN_WRITE_PAYLOAD

      public static final int MIN_WRITE_PAYLOAD
      See Also:
    • MAX_BUFFERED_PAYLOAD

      public static final int MAX_BUFFERED_PAYLOAD
      See Also:
    • manager

      private final UDPConnectionManager manager
    • selector

      private final UDPSelector selector
    • local_port

      private final int local_port
    • remote_address

      private final InetSocketAddress remote_address
    • outgoing

      boolean outgoing
    • connection_key

      private final String connection_key
    • random

      private 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 Map connections
    • connection_writers

      private final LinkedList connection_writers
    • total_tick_count

      private long total_tick_count
    • STATS_LOG_TIMER

      private static final int STATS_LOG_TIMER
      See Also:
    • 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:
    • 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:
    • TIMER_BASE_MIN

      private static final int TIMER_BASE_MIN
      See Also:
    • TIMER_BASE_MAX

      private static final int TIMER_BASE_MAX
      See Also:
    • 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:
    • 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:
    • MIN_RETRANSMIT_TIMER

      private static final int MIN_RETRANSMIT_TIMER
      See Also:
    • MIN_RETRANSMIT_TICKS

      private static final int MIN_RETRANSMIT_TICKS
    • MAX_RETRANSMIT_TIMER

      private static final int MAX_RETRANSMIT_TIMER
      See Also:
    • 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:
    • MAX_TRANSMIT_UNACK_PACKETS

      private static final int MAX_TRANSMIT_UNACK_PACKETS
      See Also:
    • transmit_unack_packets

      private final List transmit_unack_packets
    • MAX_CONTIGUOUS_RETRANS_FOR_ACK

      private static final int MAX_CONTIGUOUS_RETRANS_FOR_ACK
      See Also:
    • MIN_KEEPALIVE_TIMER

      private static final int MIN_KEEPALIVE_TIMER
      See Also:
    • MIN_KEEPALIVE_TICKS

      private static final int MIN_KEEPALIVE_TICKS
    • MAX_KEEPALIVE_TIMER

      private static final int MAX_KEEPALIVE_TIMER
      See Also:
    • 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:
    • 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:
    • 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:
    • receive_done_sequences

      private final LinkedList receive_done_sequences
    • RECEIVE_OUT_OF_ORDER_PACKETS_MAX

      private static final int RECEIVE_OUT_OF_ORDER_PACKETS_MAX
      See Also:
    • receive_out_of_order_packets

      private final List receive_out_of_order_packets
    • explicitack_ticks

      private int explicitack_ticks
    • MAX_SEQ_MEMORY

      static final int MAX_SEQ_MEMORY
  • Constructor Details

  • Method Details

    • getSelector

      protected UDPSelector getSelector()
    • getRemoteAddress

      protected InetSocketAddress getRemoteAddress()
    • getKey

      protected String getKey()
    • add

      protected void add(UDPConnection connection) throws IOException
      Throws:
      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 IOException
      Throws:
      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 IOException
      Throws:
      IOException
    • remoteLastInSequence

      protected boolean remoteLastInSequence(int alt_sequence)
    • dumpState

      protected void dumpState()
    • send

      protected void send(UDPPacket packet) throws IOException
      Throws:
      IOException
    • receive

      public void receive(byte[] initial_data, int initial_data_length) throws IOException
      Throws:
      IOException
    • sendCrypto

      protected int sendCrypto(ByteBuffer[] buffers, int offset, int length) throws IOException
      Throws:
      IOException
    • receiveCrypto

      protected void receiveCrypto(ByteBuffer buffer) throws IOException
      Throws:
      IOException
    • sendDataCommand

      protected int sendDataCommand(UDPConnection connection, ByteBuffer[] buffers, int offset, int length) throws IOException
      Throws:
      IOException
    • receiveDataCommand

      protected void receiveDataCommand(int sequence, ByteBuffer buffer, int header_length) throws IOException
      Throws:
      IOException
    • sendAckCommand

      protected void sendAckCommand(boolean timer_expired) throws IOException
      Throws:
      IOException
    • receiveAckCommand

      protected void receiveAckCommand(ByteBuffer buffer) throws IOException
      Throws:
      IOException
    • sendStatsRequest

      protected void sendStatsRequest() throws IOException
      Throws:
      IOException
    • receiveStatsRequest

      protected void receiveStatsRequest(ByteBuffer buffer) throws IOException
      Throws:
      IOException
    • receiveStatsReply

      protected void receiveStatsReply(ByteBuffer buffer) throws IOException
      Throws:
      IOException
    • sendCloseCommand

      protected void sendCloseCommand(UDPConnection connection) throws IOException
      Throws:
      IOException
    • receiveCloseCommand

      protected void receiveCloseCommand(ByteBuffer buffer) throws IOException
      Throws:
      IOException
    • writeHeaderStart

      protected int[] writeHeaderStart(ByteBuffer buffer, byte command, byte flags) throws IOException
      Throws:
      IOException
    • writeHeaderEnd

      protected int writeHeaderEnd(ByteBuffer buffer, boolean randomise_size) throws IOException
      Throws:
      IOException
    • write

      protected int write(UDPConnection connection, ByteBuffer[] buffers, int offset, int length) throws IOException
      Throws:
      IOException
    • canWrite

      protected boolean canWrite(UDPConnection connection)
    • close

      public void close(UDPConnection connection, String reason)
    • failed

      public void failed(UDPConnection connection, Throwable reason)
    • failed

      protected void failed(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 String getName()
    • logStats

      protected void logStats()
    • trace

      protected void trace(String str)
    • trace

      protected void trace(UDPConnection connection, String str)