mirror of
https://github.com/minetest/minetest.git
synced 2024-11-05 07:13:46 +01:00
Improve timeout calculation
gf
This commit is contained in:
parent
944ffe9e53
commit
247a1ebf23
@ -1410,6 +1410,7 @@ void ConnectionSendThread::runTimeouts(float dtime)
|
|||||||
(m_max_data_packets_per_iteration/numpeers));
|
(m_max_data_packets_per_iteration/numpeers));
|
||||||
|
|
||||||
channel->UpdatePacketLossCounter(timed_outs.size());
|
channel->UpdatePacketLossCounter(timed_outs.size());
|
||||||
|
g_profiler->graphAdd("packets_lost", timed_outs.size());
|
||||||
|
|
||||||
m_iteration_packets_avaialble -= timed_outs.size();
|
m_iteration_packets_avaialble -= timed_outs.size();
|
||||||
|
|
||||||
@ -1421,6 +1422,7 @@ void ConnectionSendThread::runTimeouts(float dtime)
|
|||||||
u16 seqnum = readU16(&(k->data[BASE_HEADER_SIZE+1]));
|
u16 seqnum = readU16(&(k->data[BASE_HEADER_SIZE+1]));
|
||||||
|
|
||||||
channel->UpdateBytesLost(k->data.getSize());
|
channel->UpdateBytesLost(k->data.getSize());
|
||||||
|
k->resend_count++;
|
||||||
|
|
||||||
LOG(derr_con<<m_connection->getDesc()
|
LOG(derr_con<<m_connection->getDesc()
|
||||||
<<"RE-SENDING timed-out RELIABLE to "
|
<<"RE-SENDING timed-out RELIABLE to "
|
||||||
@ -2349,9 +2351,14 @@ SharedBuffer<u8> ConnectionReceiveThread::processPacket(Channel *channel,
|
|||||||
try{
|
try{
|
||||||
BufferedPacket p =
|
BufferedPacket p =
|
||||||
channel->outgoing_reliables_sent.popSeqnum(seqnum);
|
channel->outgoing_reliables_sent.popSeqnum(seqnum);
|
||||||
|
|
||||||
|
// only calculate rtt from straight sent packets
|
||||||
|
if (p.resend_count == 0) {
|
||||||
// Get round trip time
|
// Get round trip time
|
||||||
unsigned int current_time = porting::getTimeMs();
|
unsigned int current_time = porting::getTimeMs();
|
||||||
|
|
||||||
|
// a overflow is quite unlikely but as it'd result in major
|
||||||
|
// rtt miscalculation we handle it here
|
||||||
if (current_time > p.absolute_send_time)
|
if (current_time > p.absolute_send_time)
|
||||||
{
|
{
|
||||||
float rtt = (current_time - p.absolute_send_time) / 1000.0;
|
float rtt = (current_time - p.absolute_send_time) / 1000.0;
|
||||||
@ -2368,6 +2375,7 @@ SharedBuffer<u8> ConnectionReceiveThread::processPacket(Channel *channel,
|
|||||||
// (avg_rtt and resend_timeout)
|
// (avg_rtt and resend_timeout)
|
||||||
dynamic_cast<UDPPeer*>(&peer)->reportRTT(rtt);
|
dynamic_cast<UDPPeer*>(&peer)->reportRTT(rtt);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
//put bytes for max bandwidth calculation
|
//put bytes for max bandwidth calculation
|
||||||
channel->UpdateBytesSent(p.data.getSize(),1);
|
channel->UpdateBytesSent(p.data.getSize(),1);
|
||||||
if (channel->outgoing_reliables_sent.size() == 0)
|
if (channel->outgoing_reliables_sent.size() == 0)
|
||||||
@ -2542,7 +2550,8 @@ SharedBuffer<u8> ConnectionReceiveThread::processPacket(Channel *channel,
|
|||||||
|
|
||||||
// we already have this packet so this one was on wire at least
|
// we already have this packet so this one was on wire at least
|
||||||
// the current timeout
|
// the current timeout
|
||||||
dynamic_cast<UDPPeer*>(&peer)->reportRTT(dynamic_cast<UDPPeer*>(&peer)->getResendTimeout());
|
// we don't know how long this packet was on wire don't do silly guessing
|
||||||
|
// dynamic_cast<UDPPeer*>(&peer)->reportRTT(dynamic_cast<UDPPeer*>(&peer)->getResendTimeout());
|
||||||
|
|
||||||
throw ProcessedSilentlyException("Retransmitting ack for old packet");
|
throw ProcessedSilentlyException("Retransmitting ack for old packet");
|
||||||
}
|
}
|
||||||
|
@ -162,16 +162,19 @@ inline bool seqnum_in_window(u16 seqnum, u16 next,u16 window_size)
|
|||||||
struct BufferedPacket
|
struct BufferedPacket
|
||||||
{
|
{
|
||||||
BufferedPacket(u8 *a_data, u32 a_size):
|
BufferedPacket(u8 *a_data, u32 a_size):
|
||||||
data(a_data, a_size), time(0.0), totaltime(0.0), absolute_send_time(-1)
|
data(a_data, a_size), time(0.0), totaltime(0.0), absolute_send_time(-1),
|
||||||
|
resend_count(0)
|
||||||
{}
|
{}
|
||||||
BufferedPacket(u32 a_size):
|
BufferedPacket(u32 a_size):
|
||||||
data(a_size), time(0.0), totaltime(0.0), absolute_send_time(-1)
|
data(a_size), time(0.0), totaltime(0.0), absolute_send_time(-1),
|
||||||
|
resend_count(0)
|
||||||
{}
|
{}
|
||||||
SharedBuffer<u8> data; // Data of the packet, including headers
|
SharedBuffer<u8> data; // Data of the packet, including headers
|
||||||
float time; // Seconds from buffering the packet or re-sending
|
float time; // Seconds from buffering the packet or re-sending
|
||||||
float totaltime; // Seconds from buffering the packet
|
float totaltime; // Seconds from buffering the packet
|
||||||
unsigned int absolute_send_time;
|
unsigned int absolute_send_time;
|
||||||
Address address; // Sender or destination
|
Address address; // Sender or destination
|
||||||
|
unsigned int resend_count;
|
||||||
};
|
};
|
||||||
|
|
||||||
// This adds the base headers to the data and makes a packet out of it
|
// This adds the base headers to the data and makes a packet out of it
|
||||||
|
@ -43,7 +43,7 @@ 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.333
|
#define RESEND_TIMEOUT_MIN 0.1
|
||||||
#define RESEND_TIMEOUT_MAX 3.0
|
#define RESEND_TIMEOUT_MAX 3.0
|
||||||
// resend_timeout = avg_rtt * this
|
// resend_timeout = avg_rtt * this
|
||||||
#define RESEND_TIMEOUT_FACTOR 4
|
#define RESEND_TIMEOUT_FACTOR 4
|
||||||
|
Loading…
Reference in New Issue
Block a user