From 5a2d4fd47f64a656b36fd428473715d9f764729b Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 28 Aug 2014 16:49:32 +0100 Subject: [PATCH] add some functions for estimation of number of bytes that can be send in a category in specified time --- OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs | 8 ++++++++ OpenSim/Region/ClientStack/Linden/UDP/TokenBucket.cs | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs index bb68921c29..7c55b379f4 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs @@ -453,6 +453,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP return data; } + + public int GetCatBytesCanSend(ThrottleOutPacketType cat, int timeMS) + { + TokenBucket bucket = m_throttleCategories[(int)cat]; + int bytes = timeMS * (int)(bucket.RequestedDripRate / 1000); + bytes += (int)bucket.CurrentTokenCount(); + return bytes; + } /// /// Queue an outgoing packet if appropriate. diff --git a/OpenSim/Region/ClientStack/Linden/UDP/TokenBucket.cs b/OpenSim/Region/ClientStack/Linden/UDP/TokenBucket.cs index 4c33db55c2..2a60b489e7 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/TokenBucket.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/TokenBucket.cs @@ -274,6 +274,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP return false; } + public long CurrentTokenCount() + { + return m_tokenCount; + } + /// /// Deposit tokens into the bucket from a child bucket that did /// not use all of its available tokens