Example #1
0
        void IInStatsCollector.PacketsDropped(DateTime now, int packetCount)
        {
            var p = new PacketStatus {
                State = PacketState.Dropped, SavedAt = now, OctetSize = 0
            };

            Add(p);
        }
Example #2
0
        void IInStatsCollector.PacketReceived(DateTime now, int octetCount)
        {
            var p = new PacketStatus {
                State = PacketState.Received, SavedAt = now, OctetSize = octetCount
            };

            Add(p);
        }
Example #3
0
        void Add(PacketStatus p)
        {
            const int MaxCount = 127;

            if (queue.Count > MaxCount)
            {
                PacketStatus packetStatus;
                queue.TryDequeue(out packetStatus);
            }
            p.StatsPacketId = statsPacketId++;

            queue.Enqueue(p);
        }
Example #4
0
        public InStats GetInfo(int maxCount)
        {
            var wholeArray = queue.ToArray();
            var clamp      = maxCount;

            if (clamp > wholeArray.Length)
            {
                clamp = wholeArray.Length;
            }
            var index         = wholeArray.Length - clamp;
            var copiedPackets = new PacketStatus[clamp];

            Array.Copy(wholeArray, index, copiedPackets, 0, clamp);
            return(new InStats {
                packetInfo = copiedPackets
            });
        }