forked from Mirrorlandia_minetest/minetest
master #7
@ -42,11 +42,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
|
|
||||||
#define CONNECTION_TIMEOUT 30
|
#define CONNECTION_TIMEOUT 30
|
||||||
|
|
||||||
#define RESEND_TIMEOUT_MIN 0.1
|
|
||||||
#define RESEND_TIMEOUT_MAX 3.0
|
|
||||||
// resend_timeout = avg_rtt * this
|
|
||||||
#define RESEND_TIMEOUT_FACTOR 4
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Server
|
Server
|
||||||
*/
|
*/
|
||||||
|
@ -51,6 +51,15 @@ namespace con
|
|||||||
|
|
||||||
#define PING_TIMEOUT 5.0f
|
#define PING_TIMEOUT 5.0f
|
||||||
|
|
||||||
|
// exponent base
|
||||||
|
#define RESEND_SCALE_BASE 1.5f
|
||||||
|
|
||||||
|
// since spacing is exponential the numbers here shouldn't be too high
|
||||||
|
// (it's okay to start out quick)
|
||||||
|
#define RESEND_TIMEOUT_MIN 0.1f
|
||||||
|
#define RESEND_TIMEOUT_MAX 2.0f
|
||||||
|
#define RESEND_TIMEOUT_FACTOR 2
|
||||||
|
|
||||||
u16 BufferedPacket::getSeqnum() const
|
u16 BufferedPacket::getSeqnum() const
|
||||||
{
|
{
|
||||||
if (size() < BASE_HEADER_SIZE + 3)
|
if (size() < BASE_HEADER_SIZE + 3)
|
||||||
@ -354,7 +363,10 @@ std::list<ConstSharedPtr<BufferedPacket>>
|
|||||||
MutexAutoLock listlock(m_list_mutex);
|
MutexAutoLock listlock(m_list_mutex);
|
||||||
std::list<ConstSharedPtr<BufferedPacket>> timed_outs;
|
std::list<ConstSharedPtr<BufferedPacket>> timed_outs;
|
||||||
for (auto &packet : m_list) {
|
for (auto &packet : m_list) {
|
||||||
if (packet->time < timeout)
|
// resend time scales exponentially with each cycle
|
||||||
|
const float pkt_timeout = timeout * powf(RESEND_SCALE_BASE, packet->resend_count);
|
||||||
|
|
||||||
|
if (packet->time < pkt_timeout)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// caller will resend packet so reset time and increase counter
|
// caller will resend packet so reset time and increase counter
|
||||||
@ -980,14 +992,14 @@ void UDPPeer::reportRTT(float rtt)
|
|||||||
}
|
}
|
||||||
RTTStatistics(rtt,"rudp",MAX_RELIABLE_WINDOW_SIZE*10);
|
RTTStatistics(rtt,"rudp",MAX_RELIABLE_WINDOW_SIZE*10);
|
||||||
|
|
||||||
|
// use this value to decide the resend timeout
|
||||||
float timeout = getStat(AVG_RTT) * RESEND_TIMEOUT_FACTOR;
|
float timeout = getStat(AVG_RTT) * RESEND_TIMEOUT_FACTOR;
|
||||||
if (timeout < RESEND_TIMEOUT_MIN)
|
if (timeout < RESEND_TIMEOUT_MIN)
|
||||||
timeout = RESEND_TIMEOUT_MIN;
|
timeout = RESEND_TIMEOUT_MIN;
|
||||||
if (timeout > RESEND_TIMEOUT_MAX)
|
if (timeout > RESEND_TIMEOUT_MAX)
|
||||||
timeout = RESEND_TIMEOUT_MAX;
|
timeout = RESEND_TIMEOUT_MAX;
|
||||||
|
|
||||||
MutexAutoLock usage_lock(m_exclusive_access_mutex);
|
setResendTimeout(timeout);
|
||||||
resend_timeout = timeout;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UDPPeer::Ping(float dtime,SharedBuffer<u8>& data)
|
bool UDPPeer::Ping(float dtime,SharedBuffer<u8>& data)
|
||||||
|
Loading…
Reference in New Issue
Block a user