internal void CountAcknowledgesReceived(int numberOfAcks)
        {
            m_acksReceived += numberOfAcks;
            NetConnectionStatistics window = GetCurrentWindow(NetTime.Now);

            if (window != null)
            {
                window.CountAcknowledgesReceived(numberOfAcks);
            }
        }
        internal void CountDroppedSequencedMessage()
        {
            m_userSequencedMessagesRejected++;

            NetConnectionStatistics window = GetCurrentWindow(NetTime.Now);

            if (window != null)
            {
                window.CountDroppedSequencedMessage();
            }
        }
        internal void CountPacketSent(int numBytes)
        {
            m_packetsSent++;
            m_bytesSent += numBytes;

            NetConnectionStatistics window = GetCurrentWindow(NetTime.Now);

            if (window != null)
            {
                window.CountPacketSent(numBytes);
            }
        }
        internal void CountPacketReceived(int numBytes, double now)
        {
            m_packetsReceived++;
            m_bytesReceived += numBytes;

            NetConnectionStatistics window = GetCurrentWindow(now);

            if (window != null)
            {
                window.CountPacketReceived(numBytes, now);
            }
        }
Пример #5
0
 internal NetConnection(NetPeer peer, IPEndPoint remoteEndpoint)
 {
     m_peer = peer;
     m_peerConfiguration = m_peer.Configuration;
     m_status = NetConnectionStatus.None;
     m_visibleStatus = NetConnectionStatus.None;
     m_remoteEndpoint = remoteEndpoint;
     m_sendChannels = new NetSenderChannelBase[NetConstants.NumTotalChannels];
     m_receiveChannels = new NetReceiverChannelBase[NetConstants.NumTotalChannels];
     m_queuedAcks = new NetQueue<NetTuple<NetMessageType, int>>(4);
     m_statistics = new NetConnectionStatistics(this);
     m_averageRoundtripTime = -1.0f;
 }
Пример #6
0
 internal NetConnection(NetPeer peer, IPEndPoint remoteEndpoint)
 {
     m_peer = peer;
     m_peerConfiguration    = m_peer.Configuration;
     m_status               = NetConnectionStatus.None;
     m_visibleStatus        = NetConnectionStatus.None;
     m_remoteEndpoint       = remoteEndpoint;
     m_sendChannels         = new NetSenderChannelBase[NetConstants.NumTotalChannels];
     m_receiveChannels      = new NetReceiverChannelBase[NetConstants.NumTotalChannels];
     m_queuedAcks           = new NetQueue <NetTuple <NetMessageType, int> >(4);
     m_statistics           = new NetConnectionStatistics(this);
     m_averageRoundtripTime = -1.0f;
 }
        internal void CountDuplicateMessage(NetMessage msg)
        {
            m_duplicateMessagesRejected++;
            if (msg.m_type == NetMessageLibraryType.User)
            {
                m_userDuplicateMessagesRejected++;
            }
            NetConnectionStatistics window = GetCurrentWindow(NetTime.Now);

            if (window != null)
            {
                window.CountDuplicateMessage(msg);
            }
        }
 public NetConnectionStatistics(NetConnection connection, float windowSize)
 {
     if (connection == null)
     {
         throw new ArgumentNullException("connection");
     }
     m_connection = connection;
     m_windowSize = windowSize;
     if (windowSize > 0.0f)
     {
         m_currentWindow  = new NetConnectionStatistics(connection, 0.0f);
         m_previousWindow = new NetConnectionStatistics(connection, 0.0f);
     }
     Reset();
 }
Пример #9
0
 internal NetConnection(NetPeer peer, NetEndPoint remoteEndPoint)
 {
     m_peer = peer;
     m_peerConfiguration    = m_peer.Configuration;
     m_status               = NetConnectionStatus.None;
     m_visibleStatus        = NetConnectionStatus.None;
     m_remoteEndPoint       = remoteEndPoint;
     m_sendChannels         = new NetSenderChannelBase[NetConstants.NumTotalChannels];
     m_receiveChannels      = new NetReceiverChannelBase[NetConstants.NumTotalChannels];
     m_queuedOutgoingAcks   = new NetQueue <NetTuple <NetMessageType, int> >(4);
     m_queuedIncomingAcks   = new NetQueue <NetTuple <NetMessageType, int> >(4);
     m_statistics           = new NetConnectionStatistics(this);
     m_averageRoundtripTime = -1.0f;
     m_currentMTU           = m_peerConfiguration.MaximumTransmissionUnit;
 }
        internal void CountMessageResent(NetMessageLibraryType tp)
        {
            m_messagesResent++;
            if (tp == NetMessageLibraryType.User)
            {
                m_userMessagesResent++;
            }

            NetConnectionStatistics window = GetCurrentWindow(NetTime.Now);

            if (window != null)
            {
                window.CountMessageResent(tp);
            }
        }
Пример #11
0
 internal NetConnection(NetPeer peer, NetEndPoint remoteEndPoint)
 {
     m_peer = peer;
     m_peerConfiguration = m_peer.Configuration;
     m_status = NetConnectionStatus.None;
     m_outputtedStatus = NetConnectionStatus.None;
     m_visibleStatus = NetConnectionStatus.None;
     m_remoteEndPoint = remoteEndPoint;
     m_sendChannels = new NetSenderChannelBase[NetConstants.NumTotalChannels];
     m_receiveChannels = new NetReceiverChannelBase[NetConstants.NumTotalChannels];
     m_queuedOutgoingAcks = new NetQueue<NetTuple<NetMessageType, int>>(4);
     m_queuedIncomingAcks = new NetQueue<NetTuple<NetMessageType, int>>(4);
     m_statistics = new NetConnectionStatistics(this);
     m_averageRoundtripTime = -1.0f;
     m_currentMTU = m_peerConfiguration.MaximumTransmissionUnit;
 }
        internal void CountMessageReceived(NetMessageLibraryType tp, NetChannel channel, int numBytes, double now)
        {
            m_messagesReceived++;
            if (tp == NetMessageLibraryType.User)
            {
                m_userMessagesReceived++;
                m_userBytesReceived += (4 + numBytes);
                m_userTypeMessagesReceived[(int)channel]++;
            }

            NetConnectionStatistics window = GetCurrentWindow(now);

            if (window != null)
            {
                window.CountMessageReceived(tp, channel, numBytes, now);
            }
        }
        internal void CountMessageSent(NetMessage msg, int numBytes)
        {
            m_messagesSent++;
            if (msg.m_type == NetMessageLibraryType.User)
            {
                m_userMessagesSent++;
                m_userBytesSent += numBytes;
                m_userTypeMessagesSent[(int)msg.m_sequenceChannel]++;
            }

            NetConnectionStatistics window = GetCurrentWindow(NetTime.Now);

            if (window != null)
            {
                window.CountMessageSent(msg, numBytes);
            }
        }
        internal void Reset()
        {
            m_remoteRndSignature = null;
            m_remoteRndSeqNr     = 0;
            m_localRndSeqNr      = NetRandom.Instance.Next(0, NetConstants.NumSequenceNumbers - 1);
            m_futureClose        = double.MaxValue;

            m_throttleDebt = m_owner.m_config.m_throttleBytesPerSecond;             // slower start

            m_statistics = new NetConnectionStatistics(this);
            m_unsentMessages.Clear();
            m_status = NetConnectionStatus.Connecting;             // to prevent immediate removal on heartbeat thread

            ResetReliability();
            InitializeReliability();
            InitializeFragmentation();
            InitializeStringTable();
        }
        private NetConnectionStatistics GetCurrentWindow(double now)
        {
            if (m_currentWindow == null)
            {
                return(null);
            }

            if (now - m_currentWindow.m_startTimestamp >= m_windowSize)
            {
                // close this window and open new (actually, flip and reset)
                NetConnectionStatistics tmp = m_previousWindow;
                m_previousWindow = m_currentWindow;
                m_previousWindow.m_totalTimeSpan = (float)(now - m_previousWindow.m_startTimestamp);
                m_currentWindow = tmp;
                m_currentWindow.Reset(now);
            }
            return(m_currentWindow);
        }
Пример #16
0
        internal NetConnection(NetBase owner, IPEndPoint remoteEndPoint, byte[] localHailData, byte[] remoteHailData)
        {
            m_owner          = owner;
            m_remoteEndPoint = remoteEndPoint;
            m_localHailData  = localHailData;
            m_remoteHailData = remoteHailData;
            m_futureClose    = double.MaxValue;

            m_throttleDebt = owner.m_config.m_throttleBytesPerSecond;             // slower start

            m_statistics           = new NetConnectionStatistics(this, 1.0f);
            m_unsentMessages       = new NetQueue <OutgoingNetMessage>(6);
            m_lockedUnsentMessages = new NetQueue <OutgoingNetMessage>(3);
            m_status = NetConnectionStatus.Connecting;             // to prevent immediate removal on heartbeat thread

            InitializeReliability();
            InitializeFragmentation();
            InitializeStringTable();
            //InitializeCongestionControl(32);
        }
Пример #17
0
        internal NetConnection(NetBase owner, IPEndPoint remoteEndPoint, byte[] localHailData, byte[] remoteHailData)
        {
            m_owner = owner;
            m_remoteEndPoint = remoteEndPoint;
            m_localHailData = localHailData;
            m_remoteHailData = remoteHailData;
            m_futureClose = double.MaxValue;

            m_throttleDebt = owner.m_config.m_throttleBytesPerSecond; // slower start

            m_statistics = new NetConnectionStatistics(this, 1.0f);
            m_unsentMessages = new NetQueue<OutgoingNetMessage>(6);
            m_lockedUnsentMessages = new NetQueue<OutgoingNetMessage>(3);
            m_status = NetConnectionStatus.Connecting; // to prevent immediate removal on heartbeat thread

            InitializeReliability();
            InitializeFragmentation();
            InitializeStringTable();
            //InitializeCongestionControl(32);
        }
        internal NetConnection(NetBase owner, NetworkEndPoint remoteEndPoint, byte[] localHailData, byte[] remoteHailData, byte[] remoteRndSignature, int remoteRndSeqNr)
        {
            m_owner              = owner;
            m_remoteEndPoint     = remoteEndPoint;
            m_localHailData      = localHailData;
            m_remoteHailData     = remoteHailData;
            m_remoteRndSignature = remoteRndSignature;
            m_remoteRndSeqNr     = remoteRndSeqNr;
            m_localRndSeqNr      = NetRandom.Instance.Next(0, NetConstants.NumSequenceNumbers - 1);
            m_futureClose        = double.MaxValue;

            m_throttleDebt = owner.m_config.m_throttleBytesPerSecond;             // slower start

            m_statistics = new NetConnectionStatistics(this);
            m_status     = NetConnectionStatus.Connecting;         // to prevent immediate removal on heartbeat thread

            ResetReliability();
            InitializeReliability();
            InitializeFragmentation();
            InitializeStringTable();
            //InitializeCongestionControl(32);
        }
Пример #19
0
        public string GetStatisticsString(NetConnection connection)
        {
            double now    = NetTime.Now;
            string retval =
                "--- Application wide statistics ---" + Environment.NewLine +
                "Heartbeats: " + this.HeartbeatAverageFrequency + "/sec" + Environment.NewLine +
                "Packets sent: " + m_statistics.PacketsSent + " (" + m_statistics.GetPacketsSentPerSecond(now).ToString("N1") + "/sec)" + Environment.NewLine +
                "Bytes sent: " + m_statistics.BytesSent + " (" + m_statistics.GetBytesSentPerSecond(now).ToString("N1") + "/sec)" + Environment.NewLine +
                "Packets received: " + m_statistics.PacketsReceived + " (" + m_statistics.GetPacketsReceivedPerSecond(now).ToString("N1") + "/sec)" + Environment.NewLine +
                "Bytes received: " + m_statistics.BytesReceived + " (" + m_statistics.GetBytesReceivedPerSecond(now).ToString("N1") + "/sec)" + Environment.NewLine;

            if (m_simulatedLoss > 0.0f)
            {
                retval = retval +
                         "Simulated dropped packets: " + m_statistics.SimulatedDroppedPackets + Environment.NewLine +
                         "Simulated delayed packets: " + m_delayedPackets.Count + Environment.NewLine
                ;
            }

            if (connection != null)
            {
                NetConnectionStatistics connStats = connection.Statistics;
                retval += Environment.NewLine +
                          "--- Connection wide statistics ---" + Environment.NewLine +
                          "Status: " + connection.Status + Environment.NewLine +

                          "Received -----" + Environment.NewLine +
                          "Messages: " + connStats.GetMessagesReceived(true) + " (" + connStats.GetMessagesReceivedPerSecond(now).ToString("N1") + "/sec)" + Environment.NewLine +
                          "  User/type: " +
                          connStats.GetUserUnreliableReceived() + "/" +
                          connStats.GetUserSequencedReceived() + "/" +
                          connStats.GetUserReliableUnorderedReceived() + "/" +
                          connStats.GetUserOrderedReceived() + Environment.NewLine +
                          "Packets: " + connStats.PacketsReceived + Environment.NewLine +
                          "Bytes: " + connStats.GetBytesReceived(true) + " (" + connStats.GetBytesReceivedPerSecond(now).ToString("N1") + "/sec)" + Environment.NewLine +
                          "Acks: " + connStats.AcknowledgesReceived + Environment.NewLine +
                          Environment.NewLine +

                          "Sent ------" + Environment.NewLine +
                          "Messages: " + connStats.GetMessagesSent(true) +
                          " (excl. resends " + (connStats.GetMessagesSent(true) - connStats.MessagesResent) + ")" + Environment.NewLine +
                          "  User/type: " +
                          connStats.GetUserUnreliableSent() + "/" +
                          connStats.GetUserSequencedSent() + "/" +
                          connStats.GetUserReliableUnorderedSent() + "/" +
                          connStats.GetUserOrderedSent() + Environment.NewLine +

                          "Packets: " + connStats.PacketsSent + Environment.NewLine +
                          "Bytes: " + connStats.GetBytesSent(true) + " (" + connStats.GetBytesSentPerSecond(now).ToString("N1") + "/sec)" + Environment.NewLine +
                          "Acks: " + connStats.AcknowledgesSent + Environment.NewLine +
                          Environment.NewLine +
                          "Resent: " + connStats.MessagesResent + Environment.NewLine +
                          "Duplicates: " + connStats.DuplicateMessagesRejected + Environment.NewLine +
                          "Dropped sequenced: " + connStats.SequencedMessagesRejected + Environment.NewLine +
                          Environment.NewLine +
                          "Unsent messages: " + connection.m_unsentMessages.Count + Environment.NewLine +
                          "Stored messages: " + connStats.CurrentlyStoredMessagesCount + Environment.NewLine +
                          "Withheld messages: " + connStats.CurrentlyWithheldMessagesCount + Environment.NewLine +
                          "Average roundtrip: " + (int)(connection.AverageRoundtripTime * 1000) + " ms" + Environment.NewLine
                          //"Window: " + connection.GetEstimatedPacketsOnWire() + " of " + connection.m_congestionWindowSize
                ;
            }
            return(retval);
        }
		private NetConnectionStatistics GetCurrentWindow(double now)
		{
			if (m_currentWindow == null)
				return null;

			if (now - m_currentWindow.m_startTimestamp >= m_windowSize)
			{
				// close this window and open new (actually, flip and reset)
				NetConnectionStatistics tmp = m_previousWindow;
				m_previousWindow = m_currentWindow;
				m_previousWindow.m_totalTimeSpan = (float)(now - m_previousWindow.m_startTimestamp);
				m_currentWindow = tmp;
				m_currentWindow.Reset(now);
			}
			return m_currentWindow;
		}
		public NetConnectionStatistics(NetConnection connection, float windowSize)
		{
			if (connection == null)
				throw new ArgumentNullException("connection");
			m_connection = connection;
			m_windowSize = windowSize;
			if (windowSize > 0.0f)
			{
				m_currentWindow = new NetConnectionStatistics(connection, 0.0f);
				m_previousWindow = new NetConnectionStatistics(connection, 0.0f);
			}
			Reset();
		}