Class UDPConnectionSet


  • public class UDPConnectionSet
    extends java.lang.Object
    • Field Detail

      • LOGID

        private static final LogIDs LOGID
      • 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
      • 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
      • header_cipher_out

        private RC4Engine header_cipher_out
      • header_cipher_in

        private RC4Engine header_cipher_in
      • 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_TICKS

        private static final int STATS_LOG_TICKS
      • stats_log_ticks

        private int stats_log_ticks
      • IDLE_TICKS

        private static final int IDLE_TICKS
      • idle_ticks

        private int idle_ticks
      • 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_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_TICKS

        private static final int MIN_RETRANSMIT_TICKS
      • 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_TICKS

        private static final int MIN_KEEPALIVE_TICKS
      • 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_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

      • 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)