From: <sv...@ww...> - 2005-01-01 11:56:25
|
Author: mkrose Date: 2005-01-01 03:56:14 -0800 (Sat, 01 Jan 2005) New Revision: 1432 Modified: trunk/CSP/SimNet/PeerInfo.cpp trunk/CSP/SimNet/PeerInfo.h Log: More timing changes. Wait to accumulate more time skew samples before increasing the filter time constant. Together with faster pings after the initial connection, this should yield better convergence on the true time offset. Browse at: https://www.zerobar.net/viewcvs/viewcvs.cgi?view=rev&rev=1432 Modified: trunk/CSP/SimNet/PeerInfo.cpp =================================================================== --- trunk/CSP/SimNet/PeerInfo.cpp 2005-01-01 10:52:11 UTC (rev 1431) +++ trunk/CSP/SimNet/PeerInfo.cpp 2005-01-01 11:56:14 UTC (rev 1432) @@ -308,12 +308,16 @@ correction = m_time_skew_history.add(correction); m_time_skew = m_time_skew * m_time_filter + correction * (1.0 - m_time_filter); m_last_ping_latency = ping_latency; - if (m_time_filter < 0.9999) { - m_time_filter += (1.0 - m_time_filter) * 0.1; + + // wait for a few values to arrive before increasing the filter time constant + if (m_time_skew_history.count() >= 7) { + if (m_time_filter < 0.9999) { + m_time_filter += (1.0 - m_time_filter) * 0.1; + } + if (m_time_filter > 0.9999) { + m_time_filter = 0.9999; + } } - if (m_time_filter > 0.9999) { - m_time_filter = 0.9999; - } //std::cout << "clock skew = " << m_time_skew << "\n"; //std::cout << "round trip = " << m_roundtrip_latency << "\n"; } Modified: trunk/CSP/SimNet/PeerInfo.h =================================================================== --- trunk/CSP/SimNet/PeerInfo.h 2005-01-01 10:52:11 UTC (rev 1431) +++ trunk/CSP/SimNet/PeerInfo.h 2005-01-01 11:56:14 UTC (rev 1432) @@ -192,7 +192,7 @@ inline bool needsPing() { // ping quickly at first to help establish a stable time offset; and at // least occasionally after that. - const double ping_limit = (m_connect_time < 20.0 ? 1.0 : 10.0); + const double ping_limit = (m_connect_time < 20.0 ? 0.5 : 10.0); const double quiet_limit = (hasPendingConfirmations() ? 0.0 : 0.5); bool ping = (m_quiet_time > quiet_limit || m_ping_time > ping_limit); if (ping) m_ping_time = 0.0; |