public NetConnectionConfiguration(NetConnection forConnection)
        {
            if (forConnection == null)
            {
                throw new ArgumentNullException("forConnection");
            }

            m_forConnection             = forConnection;
            forConnection.Configuration = this;

            ConnectionTimeOut      = NetConnectionConfiguration.DefaultConnectionTimeOut;
            AveragePingSamples     = 5;
            PingFrequency          = NetConnectionConfiguration.DefaultPingFrequency;
            m_currentOptimization  = NetConnectionConfiguration.DefaultOptimization;
            ThrottleBytesPerSecond = NetConnectionConfiguration.DefaultThrottleBytesPerSecond;

            // default lag/loss/dupe settings
            SimulateLagLoss        = false;
            LossChance             = 0.05f;
            LagDelayChance         = 1.0f;
            LagDelayMinimum        = 0.1f;
            LagDelayVariance       = 0.05f;
            DuplicatedPacketChance = 0.01f;

            // reliability
            OptimizeSettings(m_currentOptimization, 0.1f, true);             // assume 100ms roundtrip for starters
        }
        internal void OptimizeSettings(NetOptimization optimize, float roundtrip, bool silent)
        {
            m_currentOptimization = optimize;

            if (!silent)
            {
                m_forConnection.Parent.Log.Verbose("Optimizing network settings for " + NetUtil.SecToMil(roundtrip) + " ms roundtrip time (" + optimize.ToString() + ")");
            }
            switch (optimize)
            {
            //
            // std = example of 100 ms roundtrip time
            //
            case NetOptimization.EmphasizeResponse:
                ResendFirstUnacknowledgedDelay      = 0.1f + roundtrip * 1.5f;                                          // std:
                ResendSubsequentUnacknowledgedDelay = 0.1f + (roundtrip * 3.0f);                                        // std:
                NumResendsBeforeFailing             = (int)(15.0f / ResendSubsequentUnacknowledgedDelay);               // std:
                ForceExplicitAckDelay = roundtrip * 0.5f;                                                               // std:
                PingFrequency         = 4.0f;
                break;

            case NetOptimization.EmphasizeBandwidth:
                ResendFirstUnacknowledgedDelay      = 0.2f + roundtrip * 5.0f;                                          // std:
                ResendSubsequentUnacknowledgedDelay = 0.25f + (roundtrip * 12.0f);                                      // std:
                NumResendsBeforeFailing             = (int)(30.0f / ResendSubsequentUnacknowledgedDelay);               // std:
                ForceExplicitAckDelay = roundtrip * 2.0f;                                                               // std:
                PingFrequency         = 12.0f;
                break;

            case NetOptimization.Neutral:
            default:
                ResendFirstUnacknowledgedDelay      = 0.1f + roundtrip * 2.0f;                                          // std:
                ResendSubsequentUnacknowledgedDelay = 0.25f + (roundtrip * 5.0f);                                       // std:
                NumResendsBeforeFailing             = (int)(20.0f / ResendSubsequentUnacknowledgedDelay);               // std:
                ForceExplicitAckDelay = roundtrip * 1.0f;                                                               // std:
                PingFrequency         = 6.0f;
                break;
            }

            m_forConnection.NotifyOptimized();
        }
		public NetConnectionConfiguration(NetConnection forConnection)
		{
			if (forConnection == null)
				throw new ArgumentNullException("forConnection");

			m_forConnection = forConnection;
			forConnection.Configuration = this;

			ConnectionTimeOut = NetConnectionConfiguration.DefaultConnectionTimeOut;
			AveragePingSamples = 5;
			PingFrequency = NetConnectionConfiguration.DefaultPingFrequency;
            m_currentOptimization = NetOptimization.EmphasizeBandwidth;
			ThrottleBytesPerSecond = NetConnectionConfiguration.DefaultThrottleBytesPerSecond;

			// default lag/loss/dupe settings
			SimulateLagLoss = false;
			LossChance = 0.05f;
			LagDelayChance = 1.0f;
			LagDelayMinimum = 0.1f;
			LagDelayVariance = 0.05f;
			DuplicatedPacketChance = 0.01f;

			// reliability
			OptimizeSettings(m_currentOptimization, 0.1f, true); // assume 100ms roundtrip for starters
		}
		internal void OptimizeSettings(NetOptimization optimize, float roundtrip, bool silent)
		{
			m_currentOptimization = optimize;

			if (!silent)
				m_forConnection.Parent.Log.Verbose("Optimizing network settings for " + NetUtil.SecToMil(roundtrip) + " ms roundtrip time (" + optimize.ToString() + ")");
			switch(optimize)
			{
				//
				// std = example of 100 ms roundtrip time
				//
				case NetOptimization.EmphasizeResponse:
					ResendFirstUnacknowledgedDelay = 0.1f + roundtrip * 1.5f;						// std: 
					ResendSubsequentUnacknowledgedDelay = 0.1f + (roundtrip * 3.0f);				// std: 
					NumResendsBeforeFailing = (int)(15.0f / ResendSubsequentUnacknowledgedDelay);	// std: 
					ForceExplicitAckDelay = roundtrip * 0.5f;										// std: 
					PingFrequency = 4.0f;
					break;
				case NetOptimization.EmphasizeBandwidth:
					ResendFirstUnacknowledgedDelay = 0.2f + roundtrip * 5.0f;						// std: 
					ResendSubsequentUnacknowledgedDelay = 0.25f + (roundtrip * 12.0f);				// std: 
					NumResendsBeforeFailing = (int)(30.0f / ResendSubsequentUnacknowledgedDelay);	// std: 
					ForceExplicitAckDelay = roundtrip * 2.0f;										// std: 
					PingFrequency = 20.0f;
					break;
				case NetOptimization.Neutral:
				default:
					ResendFirstUnacknowledgedDelay = 0.1f + roundtrip * 2.0f;						// std: 
					ResendSubsequentUnacknowledgedDelay = 0.25f + (roundtrip * 5.0f);				// std: 
					NumResendsBeforeFailing = (int)(20.0f / ResendSubsequentUnacknowledgedDelay);	// std: 
					ForceExplicitAckDelay = roundtrip * 1.0f;										// std: 
					PingFrequency = 6.0f;
					break;
			}

			m_forConnection.NotifyOptimized();
		}
		internal void OptimizeSettings(NetOptimization optimize, float roundtrip)
		{
			OptimizeSettings(optimize, roundtrip, false);
		}
 internal void OptimizeSettings(NetOptimization optimize, float roundtrip)
 {
     OptimizeSettings(optimize, roundtrip, false);
 }