Exemplo n.º 1
0
        private TcpStats AnalyzeConnections(ConnectionData[] connections, TimeSpan measurePeriod)
        {
            _receivedSinceLastRun     = 0;
            _sentSinceLastRun         = 0;
            _pendingSendOnLastRun     = 0;
            _inSendOnLastRun          = 0;
            _pendingReceivedOnLastRun = 0;
            _anySendBlockedOnLastRun  = false;

            foreach (var connection in connections)
            {
                AnalyzeConnection(connection);
            }

            var stats = new TcpStats(connections.Length,
                                     _sentTotal,
                                     _receivedTotal,
                                     _sentSinceLastRun,
                                     _receivedSinceLastRun,
                                     _pendingSendOnLastRun,
                                     _inSendOnLastRun,
                                     _pendingReceivedOnLastRun,
                                     measurePeriod);


            if (Application.IsDefined(Application.DumpStatistics))
            {
                _logger.DebugFormat("\n# Total connections: {0,3}. Out: {1:0.00}b/s  In: {2:0.00}b/s  Pending Send: {3}  " +
                                    "In Send: {4}  Pending Received: {5} Measure Time: {6}",
                                    stats.Connections,
                                    stats.SendingSpeed,
                                    stats.ReceivingSpeed,
                                    stats.PendingSend,
                                    stats.InSend,
                                    stats.PendingSend,
                                    stats.MeasureTime);
            }
            return(stats);
        }
        private TcpStats AnalyzeConnections(ConnectionData[] connections, TimeSpan measurePeriod)
        {
            _receivedSinceLastRun = 0;
            _sentSinceLastRun = 0;
            _pendingSendOnLastRun = 0;
            _inSendOnLastRun = 0;
            _pendingReceivedOnLastRun = 0;
            _anySendBlockedOnLastRun = false;

            foreach (var connection in connections)
            {
                AnalyzeConnection(connection);
            }

            var stats = new TcpStats(connections.Length,
                                     _sentTotal,
                                     _receivedTotal,
                                     _sentSinceLastRun,
                                     _receivedSinceLastRun,
                                     _pendingSendOnLastRun,
                                     _inSendOnLastRun,
                                     _pendingReceivedOnLastRun,
                                     measurePeriod);

            if (Application.IsDefined(Application.DumpStatistics))
            {
                Log.Trace("\n# Total connections: {0,3}. Out: {1:0.00}b/s  In: {2:0.00}b/s  Pending Send: {3}  " +
                          "In Send: {4}  Pending Received: {5} Measure Time: {6}",
                          stats.Connections,
                          stats.SendingSpeed,
                          stats.ReceivingSpeed,
                          stats.PendingSend,
                          stats.InSend,
                          stats.PendingSend,
                          stats.MeasureTime);
            }
            return stats;
        }