Exemple #1
0
        /// <summary>
        ///     Default constructor
        /// </summary>
        /// <param name="server">Reference to the UDP server this client is connected to</param>
        /// <param name="rates">Default throttling rates and maximum throttle limits</param>
        /// <param name="parentThrottle">
        ///     Parent HTB (hierarchical token bucket)
        ///     that the child throttles will be governed by
        /// </param>
        /// <param name="circuitCode">Circuit code for this connection</param>
        /// <param name="agentID">AgentID for the connected agent</param>
        /// <param name="remoteEndPoint">Remote endpoint for this connection</param>
        /// <param name="defaultRTO"></param>
        /// <param name="maxRTO"></param>
        public LLUDPClient(LLUDPServer server, ThrottleRates rates, TokenBucket parentThrottle, uint circuitCode,
                           UUID agentID, IPEndPoint remoteEndPoint, int defaultRTO, int maxRTO)
        {
            AgentID        = agentID;
            RemoteEndPoint = remoteEndPoint;
            CircuitCode    = circuitCode;
            m_udpServer    = server;
            if (defaultRTO != 0)
            {
                m_defaultRTO = defaultRTO;
            }
            if (maxRTO != 0)
            {
                m_maxRTO = maxRTO;
            }

            // Create a token bucket throttle for this client that has the scene token bucket as a parent
            m_throttle = new TokenBucket(parentThrottle, rates.TotalLimit, 0);

            // remember the rates the client requested
            Rates = new int[(int)ThrottleOutPacketType.Count];

            for (int i = 0; i < (int)ThrottleOutPacketType.Count; i++)
            {
                PacketsCounts[i] = 0;
            }

            //Set the priorities for the different packet types
            //Higher is more important
            MapCatsToPriority[(int)ThrottleOutPacketType.Resend]     = 7;
            MapCatsToPriority[(int)ThrottleOutPacketType.Land]       = 1;
            MapCatsToPriority[(int)ThrottleOutPacketType.Wind]       = 0;
            MapCatsToPriority[(int)ThrottleOutPacketType.Cloud]      = 0;
            MapCatsToPriority[(int)ThrottleOutPacketType.Task]       = 4;
            MapCatsToPriority[(int)ThrottleOutPacketType.Texture]    = 2;
            MapCatsToPriority[(int)ThrottleOutPacketType.Asset]      = 3;
            MapCatsToPriority[(int)ThrottleOutPacketType.Transfer]   = 5;
            MapCatsToPriority[(int)ThrottleOutPacketType.State]      = 5;
            MapCatsToPriority[(int)ThrottleOutPacketType.AvatarInfo] = 6;
            MapCatsToPriority[(int)ThrottleOutPacketType.OutBand]    = 7;

            // Default the retransmission timeout to one second
            RTO = m_defaultRTO;

            // Initialize this to a sane value to prevent early disconnects
            TickLastPacketReceived = Environment.TickCount & Int32.MaxValue;
        }
Exemple #2
0
        public void Initialise(uint port, IConfigSource configSource, AgentCircuitManager circuitManager)
        {
            IConfig networkConfig = configSource.Configs["Network"];
            IPAddress internalIP = IPAddress.Any;
            if (networkConfig != null)
                IPAddress.TryParse(networkConfig.GetString("internal_ip", "0.0.0.0"), out internalIP);

            InitThreadPool(15);

            base.Initialise(internalIP, (int)port);

            #region Environment.TickCount Measurement

            // Measure the resolution of Environment.TickCount
            TickCountResolution = 0f;
            for (int i = 0; i < 5; i++)
            {
                int start = Environment.TickCount;
                int now = start;
                while (now == start)
                    now = Environment.TickCount;
                TickCountResolution += (now - start)*0.2f;
            }
            //MainConsole.Instance.Info("[LLUDPSERVER]: Average Environment.TickCount resolution: " + TickCountResolution + "ms");
            TickCountResolution = (float) Math.Ceiling(TickCountResolution);

            #endregion Environment.TickCount Measurement

            m_circuitManager = circuitManager;
            int sceneThrottleBps = 0;

            IConfig config = configSource.Configs["ClientStack.LindenUDP"];
            if (config != null)
            {
                m_asyncPacketHandling = config.GetBoolean("async_packet_handling", false);
                m_recvBufferSize = config.GetInt("client_socket_rcvbuf_size", 0);
                sceneThrottleBps = config.GetInt("scene_throttle_max_bps", 0);

                PrimUpdatesPerCallback = config.GetInt("PrimUpdatesPerCallback", 60);
                AvatarUpdatesPerCallBack = config.GetInt("AvatarUpdatesPerCallback", 80);
                TextureSendLimit = config.GetInt("TextureSendLimit", 25);

                m_defaultRTO = config.GetInt("DefaultRTO", 1000);
                m_maxRTO = config.GetInt("MaxRTO", 20000);
                ClientTimeOut = config.GetInt("ClientTimeOut", 500);
            }
            else
            {
                PrimUpdatesPerCallback = 60;
                AvatarUpdatesPerCallBack = 80;
                TextureSendLimit = 25;
                ClientTimeOut = 500;
            }

            #region BinaryStats

            config = configSource.Configs["Statistics.Binary"];
            m_shouldCollectStats = false;
            if (config != null)
            {
                if (config.Contains("enabled") && config.GetBoolean("enabled"))
                {
                    if (config.Contains("collect_packet_headers"))
                        m_shouldCollectStats = config.GetBoolean("collect_packet_headers");
                    if (config.Contains("packet_headers_period_seconds"))
                    {
                        binStatsMaxFilesize = TimeSpan.FromSeconds(config.GetInt("region_stats_period_seconds"));
                    }
                    if (config.Contains("stats_dir"))
                    {
                        binStatsDir = config.GetString("stats_dir");
                    }
                }
                else
                {
                    m_shouldCollectStats = false;
                }
            }

            #endregion BinaryStats

            if (sceneThrottleBps != 0)
                m_throttle = new TokenBucket(null, sceneThrottleBps, 0);
            m_throttleRates = new ThrottleRates(configSource);
        }
        /// <summary>
        ///     Default constructor
        /// </summary>
        /// <param name="server">Reference to the UDP server this client is connected to</param>
        /// <param name="rates">Default throttling rates and maximum throttle limits</param>
        /// <param name="parentThrottle">
        ///     Parent HTB (hierarchical token bucket)
        ///     that the child throttles will be governed by
        /// </param>
        /// <param name="circuitCode">Circuit code for this connection</param>
        /// <param name="agentID">AgentID for the connected agent</param>
        /// <param name="remoteEndPoint">Remote endpoint for this connection</param>
        /// <param name="defaultRTO"></param>
        /// <param name="maxRTO"></param>
        public LLUDPClient(LLUDPServer server, ThrottleRates rates, TokenBucket parentThrottle, uint circuitCode,
                           UUID agentID, IPEndPoint remoteEndPoint, int defaultRTO, int maxRTO)
        {
            AgentID = agentID;
            RemoteEndPoint = remoteEndPoint;
            CircuitCode = circuitCode;
            m_udpServer = server;
            if (defaultRTO != 0)
                m_defaultRTO = defaultRTO;
            if (maxRTO != 0)
                m_maxRTO = maxRTO;

            // Create a token bucket throttle for this client that has the scene token bucket as a parent
            m_throttle = new TokenBucket(parentThrottle, rates.TotalLimit, 0);

            // remember the rates the client requested
            Rates = new int[(int) ThrottleOutPacketType.Count];

            for (int i = 0; i < (int) ThrottleOutPacketType.Count; i++)
            {
                PacketsCounts[i] = 0;
            }

            //Set the priorities for the different packet types
            //Higher is more important
            MapCatsToPriority[(int) ThrottleOutPacketType.Resend] = 7;
            MapCatsToPriority[(int) ThrottleOutPacketType.Land] = 1;
            MapCatsToPriority[(int) ThrottleOutPacketType.Wind] = 0;
            MapCatsToPriority[(int) ThrottleOutPacketType.Cloud] = 0;
            MapCatsToPriority[(int) ThrottleOutPacketType.Task] = 4;
            MapCatsToPriority[(int) ThrottleOutPacketType.Texture] = 2;
            MapCatsToPriority[(int) ThrottleOutPacketType.Asset] = 3;
            MapCatsToPriority[(int) ThrottleOutPacketType.Transfer] = 5;
            MapCatsToPriority[(int) ThrottleOutPacketType.State] = 5;
            MapCatsToPriority[(int) ThrottleOutPacketType.AvatarInfo] = 6;
            MapCatsToPriority[(int) ThrottleOutPacketType.OutBand] = 7;

            // Default the retransmission timeout to one second
            RTO = m_defaultRTO;

            // Initialize this to a sane value to prevent early disconnects
            TickLastPacketReceived = Environment.TickCount & Int32.MaxValue;
        }