示例#1
0
        public void TestClientThrottlePerClientAndRegionLimited()
        {
            TestHelpers.InMethod();
            //TestHelpers.EnableLogging();

            int resendBytes  = 4000;
            int landBytes    = 6000;
            int windBytes    = 8000;
            int cloudBytes   = 10000;
            int taskBytes    = 12000;
            int textureBytes = 14000;
            int assetBytes   = 16000;

            // current total 70000
            int totalBytes = resendBytes + landBytes + windBytes + cloudBytes + taskBytes + textureBytes + assetBytes;

            Scene           scene     = new SceneHelpers().SetupScene();
            TestLLUDPServer udpServer = ClientStackHelpers.AddUdpServer(scene);

            udpServer.ThrottleRates.Total        = (int)(totalBytes * 1.1);
            udpServer.Throttle.RequestedDripRate = (int)(totalBytes * 1.5);

            ScenePresence sp1
                = ClientStackHelpers.AddChildClient(
                      scene, udpServer, TestHelpers.ParseTail(0x1), TestHelpers.ParseTail(0x2), 123456);

            LLUDPClient udpClient1 = ((LLClientView)sp1.ControllingClient).UDPClient;

            udpClient1.ThrottleDebugLevel = 1;

            SetThrottles(
                udpClient1, resendBytes, landBytes, windBytes, cloudBytes, taskBytes, textureBytes, assetBytes);

            AssertThrottles(
                udpClient1,
                resendBytes, landBytes, windBytes, cloudBytes, taskBytes,
                textureBytes, assetBytes, totalBytes, 0, totalBytes * 1.1);

            // Now add another client
            ScenePresence sp2
                = ClientStackHelpers.AddChildClient(
                      scene, udpServer, TestHelpers.ParseTail(0x10), TestHelpers.ParseTail(0x20), 123457);

            LLUDPClient udpClient2 = ((LLClientView)sp2.ControllingClient).UDPClient;

            udpClient2.ThrottleDebugLevel = 1;

            SetThrottles(
                udpClient2, resendBytes, landBytes, windBytes, cloudBytes, taskBytes, textureBytes, assetBytes);

            AssertThrottles(
                udpClient1,
                resendBytes * 0.75, landBytes * 0.75, windBytes * 0.75, cloudBytes * 0.75, taskBytes * 0.75,
                textureBytes * 0.75, assetBytes * 0.75, totalBytes * 0.75, 0, totalBytes * 1.1);

            AssertThrottles(
                udpClient2,
                resendBytes * 0.75, landBytes * 0.75, windBytes * 0.75, cloudBytes * 0.75, taskBytes * 0.75,
                textureBytes * 0.75, assetBytes * 0.75, totalBytes * 0.75, 0, totalBytes * 1.1);
        }
        /// <summary>
        /// Set up a client for tests which aren't concerned with this process itself and where only one client is being
        /// tested
        /// </summary>
        /// <param name="circuitCode"></param>
        /// <param name="epSender"></param>
        /// <param name="testLLUDPServer"></param>
        /// <param name="acm"></param>
        protected void AddClient(
            uint circuitCode, EndPoint epSender, TestLLUDPServer testLLUDPServer, AgentCircuitManager acm)
        {
            UUID myAgentUuid   = UUID.Parse("00000000-0000-0000-0000-000000000001");
            UUID mySessionUuid = UUID.Parse("00000000-0000-0000-0000-000000000002");

            AddClient(circuitCode, epSender, myAgentUuid, mySessionUuid, testLLUDPServer, acm);
        }
        private void AddUdpServer(IniConfigSource configSource)
        {
            uint port = 0;
            AgentCircuitManager acm = m_scene.AuthenticateHandler;

            m_udpServer = new TestLLUDPServer(IPAddress.Any, ref port, 0, false, configSource, acm);
            m_udpServer.AddScene(m_scene);
        }
        public void TestAddClient()
        {
            TestHelpers.InMethod();
//            TestHelpers.EnableLogging();

            TestLLUDPServer udpServer = ClientStackHelpers.AddUdpServer(m_scene);

            UUID       myAgentUuid   = TestHelpers.ParseTail(0x1);
            UUID       mySessionUuid = TestHelpers.ParseTail(0x2);
            uint       myCircuitCode = 123456;
            IPEndPoint testEp        = new IPEndPoint(IPAddress.Loopback, 999);

            UseCircuitCodePacket uccp = new UseCircuitCodePacket();

            UseCircuitCodePacket.CircuitCodeBlock uccpCcBlock
                = new UseCircuitCodePacket.CircuitCodeBlock();
            uccpCcBlock.Code      = myCircuitCode;
            uccpCcBlock.ID        = myAgentUuid;
            uccpCcBlock.SessionID = mySessionUuid;
            uccp.CircuitCode      = uccpCcBlock;

            byte[]          uccpBytes = uccp.ToBytes();
            UDPPacketBuffer upb       = new UDPPacketBuffer(testEp, uccpBytes.Length);

            upb.DataLength = uccpBytes.Length;  // God knows why this isn't set by the constructor.
            Buffer.BlockCopy(uccpBytes, 0, upb.Data, 0, uccpBytes.Length);

            udpServer.PacketReceived(upb);

            // Presence shouldn't exist since the circuit manager doesn't know about this circuit for authentication yet
            Assert.That(m_scene.GetScenePresence(myAgentUuid), Is.Null);

            AgentCircuitData acd = new AgentCircuitData();

            acd.AgentID   = myAgentUuid;
            acd.SessionID = mySessionUuid;

            m_scene.AuthenticateHandler.AddNewCircuit(myCircuitCode, acd);

            udpServer.PacketReceived(upb);

            // Should succeed now
            ScenePresence sp = m_scene.GetScenePresence(myAgentUuid);

            Assert.That(sp.UUID, Is.EqualTo(myAgentUuid));

            Assert.That(udpServer.PacketsSent.Count, Is.EqualTo(1));

            Packet packet = udpServer.PacketsSent[0];

            Assert.That(packet, Is.InstanceOf(typeof(PacketAckPacket)));

            PacketAckPacket ackPacket = packet as PacketAckPacket;

            Assert.That(ackPacket.Packets.Length, Is.EqualTo(1));
            Assert.That(ackPacket.Packets[0].ID, Is.EqualTo(0));
        }
示例#5
0
        public void TestSingleClientThrottleRegionLimited()
        {
            TestHelpers.InMethod();
            //            TestHelpers.EnableLogging();

            int resendBytes  = 6000;
            int landBytes    = 8000;
            int windBytes    = 10000;
            int cloudBytes   = 12000;
            int taskBytes    = 14000;
            int textureBytes = 16000;
            int assetBytes   = 18000;
            int totalBytes
                = (int)((resendBytes + landBytes + windBytes + cloudBytes + taskBytes + textureBytes + assetBytes) / 2);

            Scene           scene     = new SceneHelpers().SetupScene();
            TestLLUDPServer udpServer = ClientStackHelpers.AddUdpServer(scene);

            udpServer.Throttle.RequestedDripRate = totalBytes;

            ScenePresence sp1
                = ClientStackHelpers.AddChildClient(
                      scene, udpServer, TestHelpers.ParseTail(0x1), TestHelpers.ParseTail(0x2), 123456);

            LLUDPClient udpClient1 = ((LLClientView)sp1.ControllingClient).UDPClient;

            SetThrottles(
                udpClient1, resendBytes, landBytes, windBytes, cloudBytes, taskBytes, textureBytes, assetBytes);

            AssertThrottles(
                udpClient1,
                resendBytes / 2, landBytes / 2, windBytes / 2, cloudBytes / 2, taskBytes / 2,
                textureBytes / 2, assetBytes / 2, totalBytes, 0, 0);

            // Test: Now add another client
            ScenePresence sp2
                = ClientStackHelpers.AddChildClient(
                      scene, udpServer, TestHelpers.ParseTail(0x10), TestHelpers.ParseTail(0x20), 123457);

            LLUDPClient udpClient2 = ((LLClientView)sp2.ControllingClient).UDPClient;

            //            udpClient.ThrottleDebugLevel = 1;

            SetThrottles(
                udpClient2, resendBytes, landBytes, windBytes, cloudBytes, taskBytes, textureBytes, assetBytes);

            AssertThrottles(
                udpClient1,
                resendBytes / 4, landBytes / 4, windBytes / 4, cloudBytes / 4, taskBytes / 4,
                textureBytes / 4, assetBytes / 4, totalBytes / 2, 0, 0);

            AssertThrottles(
                udpClient2,
                resendBytes / 4, landBytes / 4, windBytes / 4, cloudBytes / 4, taskBytes / 4,
                textureBytes / 4, assetBytes / 4, totalBytes / 2, 0, 0);
        }
        /// <summary>
        /// Add a client for testing
        /// </summary>
        /// <param name="scene"></param>
        /// <param name="testLLUDPServer"></param>
        /// <param name="testPacketServer"></param>
        /// <param name="acm">Agent circuit manager used in setting up the stack</param>
        protected void SetupStack(
            IScene scene, out TestLLUDPServer testLLUDPServer, out TestLLPacketServer testPacketServer,
            out AgentCircuitManager acm)
        {
            IConfigSource           configSource = new IniConfigSource();
            ClientStackUserSettings userSettings = new ClientStackUserSettings();

            testLLUDPServer = new TestLLUDPServer();
            acm             = new AgentCircuitManager();

            uint port = 666;

            testLLUDPServer.Initialise(null, ref port, 0, false, configSource, acm);
            testPacketServer           = new TestLLPacketServer(testLLUDPServer, userSettings);
            testLLUDPServer.LocalScene = scene;
        }
        public void TestLogoutClientDueToAck()
        {
            TestHelpers.InMethod();
//            TestHelpers.EnableLogging();

            IniConfigSource ics    = new IniConfigSource();
            IConfig         config = ics.AddConfig("ClientStack.LindenUDP");

            config.Set("AckTimeout", -1);
            TestLLUDPServer udpServer = ClientStackHelpers.AddUdpServer(m_scene, ics);

            ScenePresence sp
                = ClientStackHelpers.AddChildClient(
                      m_scene, udpServer, TestHelpers.ParseTail(0x1), TestHelpers.ParseTail(0x2), 123456);

            udpServer.ClientOutgoingPacketHandler(sp.ControllingClient, true, false, false);

            ScenePresence spAfterAckTimeout = m_scene.GetScenePresence(sp.UUID);

            Assert.That(spAfterAckTimeout, Is.Null);
        }
        /// <summary>
        /// Set up a client for tests which aren't concerned with this process itself
        /// </summary>
        /// <param name="circuitCode"></param>
        /// <param name="epSender"></param>
        /// <param name="agentId"></param>
        /// <param name="sessionId"></param>
        /// <param name="testLLUDPServer"></param>
        /// <param name="acm"></param>
        protected void AddClient(
            uint circuitCode, EndPoint epSender, UUID agentId, UUID sessionId,
            TestLLUDPServer testLLUDPServer, AgentCircuitManager acm)
        {
            AgentCircuitData acd = new AgentCircuitData();

            acd.AgentID   = agentId;
            acd.SessionID = sessionId;

            UseCircuitCodePacket uccp = new UseCircuitCodePacket();

            UseCircuitCodePacket.CircuitCodeBlock uccpCcBlock
                = new UseCircuitCodePacket.CircuitCodeBlock();
            uccpCcBlock.Code      = circuitCode;
            uccpCcBlock.ID        = agentId;
            uccpCcBlock.SessionID = sessionId;
            uccp.CircuitCode      = uccpCcBlock;

            acm.AddNewCircuit(circuitCode, acd);

            testLLUDPServer.LoadReceive(uccp, epSender);
            testLLUDPServer.ReceiveData(null);
        }
示例#9
0
        public void TestClientThrottlePerClientLimited()
        {
            TestHelpers.InMethod();
            //            TestHelpers.EnableLogging();

            int resendBytes  = 4000;
            int landBytes    = 6000;
            int windBytes    = 8000;
            int cloudBytes   = 10000;
            int taskBytes    = 12000;
            int textureBytes = 14000;
            int assetBytes   = 16000;
            int totalBytes
                = (int)((resendBytes + landBytes + windBytes + cloudBytes + taskBytes + textureBytes + assetBytes) / 2);

            Scene           scene     = new SceneHelpers().SetupScene();
            TestLLUDPServer udpServer = ClientStackHelpers.AddUdpServer(scene);

            udpServer.ThrottleRates.Total = totalBytes;

            ScenePresence sp
                = ClientStackHelpers.AddChildClient(
                      scene, udpServer, TestHelpers.ParseTail(0x1), TestHelpers.ParseTail(0x2), 123456);

            LLUDPClient udpClient = ((LLClientView)sp.ControllingClient).UDPClient;

            //            udpClient.ThrottleDebugLevel = 1;

            SetThrottles(
                udpClient, resendBytes, landBytes, windBytes, cloudBytes, taskBytes, textureBytes, assetBytes);

            AssertThrottles(
                udpClient,
                resendBytes / 2, landBytes / 2, windBytes / 2, cloudBytes / 2, taskBytes / 2,
                textureBytes / 2, assetBytes / 2, totalBytes, 0, totalBytes);
        }
示例#10
0
        public void TestClientThrottleSetNoLimit()
        {
            TestHelpers.InMethod();
//            TestHelpers.EnableLogging();

            Scene           scene     = new SceneHelpers().SetupScene();
            TestLLUDPServer udpServer = ClientStackHelpers.AddUdpServer(scene);

            ScenePresence sp
                = ClientStackHelpers.AddChildClient(
                      scene, udpServer, TestHelpers.ParseTail(0x1), TestHelpers.ParseTail(0x2), 123456);

            LLUDPClient udpClient = ((LLClientView)sp.ControllingClient).UDPClient;

            udpServer.Throttle.DebugLevel = 1;
            udpClient.ThrottleDebugLevel  = 1;

            int resendBytes  = 1000;
            int landBytes    = 2000;
            int windBytes    = 3000;
            int cloudBytes   = 4000;
            int taskBytes    = 5000;
            int textureBytes = 6000;
            int assetBytes   = 7000;

            SetThrottles(
                udpClient, resendBytes, landBytes, windBytes, cloudBytes, taskBytes, textureBytes, assetBytes);

            // We expect this to be lower because of the minimum bound set by MTU
            int totalBytes = LLUDPServer.MTU + landBytes + windBytes + cloudBytes + taskBytes + textureBytes + assetBytes;

            AssertThrottles(
                udpClient,
                LLUDPServer.MTU, landBytes, windBytes, cloudBytes, taskBytes,
                textureBytes, assetBytes, totalBytes, 0, 0);
        }
示例#11
0
        public void TestClientThrottleAdaptiveNoLimit()
        {
            TestHelpers.InMethod();
//            TestHelpers.EnableLogging();

            Scene scene = new SceneHelpers().SetupScene();

            IniConfigSource ics    = new IniConfigSource();
            IConfig         config = ics.AddConfig("ClientStack.LindenUDP");

            config.Set("enable_adaptive_throttles", true);
            config.Set("adaptive_throttle_min_bps", 32000);

            TestLLUDPServer udpServer = ClientStackHelpers.AddUdpServer(scene, ics);

            ScenePresence sp
                = ClientStackHelpers.AddChildClient(
                      scene, udpServer, TestHelpers.ParseTail(0x1), TestHelpers.ParseTail(0x2), 123456);

            LLUDPClient udpClient = ((LLClientView)sp.ControllingClient).UDPClient;

            udpServer.Throttle.DebugLevel = 1;
            udpClient.ThrottleDebugLevel  = 1;

            // Total is 275000
            int resendBytes  = 5000; // this is set low to test the minimum throttle override
            int landBytes    = 20000;
            int windBytes    = 30000;
            int cloudBytes   = 40000;
            int taskBytes    = 50000;
            int textureBytes = 60000;
            int assetBytes   = 70000;
            int totalBytes   = resendBytes + landBytes + windBytes + cloudBytes + taskBytes + textureBytes + assetBytes;

            SetThrottles(
                udpClient, resendBytes, landBytes, windBytes, cloudBytes, taskBytes, textureBytes, assetBytes);

            // Ratio of current adaptive drip rate to requested bytes, minimum rate is 32000
            double commitRatio = 32000.0 / totalBytes;

            AssertThrottles(
                udpClient,
                LLUDPServer.MTU, landBytes * commitRatio, windBytes * commitRatio, cloudBytes * commitRatio, taskBytes * commitRatio,
                textureBytes * commitRatio, assetBytes * commitRatio, udpClient.FlowThrottle.AdjustedDripRate, totalBytes, 0);

            // Test an increase in target throttle, ack of 20 packets adds 20 * LLUDPServer.MTU bytes
            // to the throttle, recompute commitratio from those numbers
            udpClient.FlowThrottle.AcknowledgePackets(20);
            commitRatio = (32000.0 + 20.0 * LLUDPServer.MTU) / totalBytes;

            AssertThrottles(
                udpClient,
                LLUDPServer.MTU, landBytes * commitRatio, windBytes * commitRatio, cloudBytes * commitRatio, taskBytes * commitRatio,
                textureBytes * commitRatio, assetBytes * commitRatio, udpClient.FlowThrottle.AdjustedDripRate, totalBytes, 0);

            // Test a decrease in target throttle, adaptive throttle should cut the rate by 50% with a floor
            // set by the minimum adaptive rate
            udpClient.FlowThrottle.ExpirePackets(1);
            commitRatio = (32000.0 + (20.0 * LLUDPServer.MTU) / Math.Pow(2, 1)) / totalBytes;

            AssertThrottles(
                udpClient,
                LLUDPServer.MTU, landBytes * commitRatio, windBytes * commitRatio, cloudBytes * commitRatio, taskBytes * commitRatio,
                textureBytes * commitRatio, assetBytes * commitRatio, udpClient.FlowThrottle.AdjustedDripRate, totalBytes, 0);
        }