Tweaks to make server more lag tolerant and also send less packets.

This commit is contained in:
KimLS 2017-03-07 18:13:17 -08:00
parent da81b7a76d
commit d494048ff6
3 changed files with 19 additions and 10 deletions

View File

@ -7,7 +7,7 @@
#include <queue>
#include <memory>
#define STREAM_IDENT_WAIT_MS 10000
#define STREAM_IDENT_WAIT_MS 30000
class OpcodeManager;
class StructStrategy;

View File

@ -272,7 +272,7 @@ EQ::Net::DaybreakConnection::DaybreakConnection(DaybreakConnectionManager *owner
m_encode_passes[1] = owner->m_options.encode_passes[1];
m_hold_time = Clock::now();
m_buffered_packets_length = 0;
m_resend_delay = m_owner->m_options.resend_delay_ms + 25;
m_resend_delay = 500;
m_rolling_ping = 100;
m_combined.reset(new char[512]);
m_combined[0] = 0;
@ -295,7 +295,7 @@ EQ::Net::DaybreakConnection::DaybreakConnection(DaybreakConnectionManager *owner
m_crc_bytes = 0;
m_hold_time = Clock::now();
m_buffered_packets_length = 0;
m_resend_delay = m_owner->m_options.resend_delay_ms + 25;
m_resend_delay = 500;
m_rolling_ping = 100;
m_combined.reset(new char[512]);
m_combined[0] = 0;
@ -316,6 +316,8 @@ void EQ::Net::DaybreakConnection::Close()
disconnect.connect_code = HostToNetwork(m_connect_code);
DynamicPacket out;
out.PutSerialize(0, disconnect);
FlushBuffer();
InternalSend(out);
ChangeStatus(StatusDisconnecting);
@ -355,9 +357,9 @@ void EQ::Net::DaybreakConnection::ResetStats()
void EQ::Net::DaybreakConnection::Process()
{
try {
m_resend_delay = (size_t)(m_stats.last_stat_ping * m_owner->m_options.resend_delay_factor) + m_owner->m_options.resend_delay_ms;
if (m_resend_delay > 500) {
m_resend_delay = 500;
m_resend_delay = (size_t)(((m_stats.min_ping + m_stats.max_ping) / 2) * m_owner->m_options.resend_delay_factor) + m_owner->m_options.resend_delay_ms;
if (m_resend_delay > m_owner->m_options.resend_delay_max) {
m_resend_delay = m_owner->m_options.resend_delay_max;
}
auto now = Clock::now();
@ -699,6 +701,8 @@ void EQ::Net::DaybreakConnection::ProcessDecodedPacket(const Packet &p)
disconnect.connect_code = HostToNetwork(m_connect_code);
DynamicPacket out;
out.PutSerialize(0, disconnect);
FlushBuffer();
InternalSend(out);
}
@ -1055,7 +1059,7 @@ void EQ::Net::DaybreakConnection::SendAck(int stream_id, uint16_t seq)
DynamicPacket p;
p.PutSerialize(0, ack);
InternalSend(p);
InternalBufferedSend(p);
}
void EQ::Net::DaybreakConnection::SendOutOfOrderAck(int stream_id, uint16_t seq)
@ -1068,7 +1072,7 @@ void EQ::Net::DaybreakConnection::SendOutOfOrderAck(int stream_id, uint16_t seq)
DynamicPacket p;
p.PutSerialize(0, ack);
InternalSend(p);
InternalBufferedSend(p);
}
void EQ::Net::DaybreakConnection::SendStatSync()
@ -1088,7 +1092,10 @@ void EQ::Net::DaybreakConnection::SendStatSync()
request.packets_sent = m_stats.sent_packets + 1;
request.packets_recv = m_stats.recv_packets;
m_last_session_stats = Clock::now();
//InternalSend()
//EQ::Net::DynamicPacket p;
//p.PutSerialize(0, request);
//InternalBufferedSend(p);
}
void EQ::Net::DaybreakConnection::InternalBufferedSend(Packet &p)

View File

@ -218,8 +218,9 @@ namespace EQ
DaybreakConnectionManagerOptions() {
max_connection_count = 0;
keepalive_delay_ms = 9000;
resend_delay_ms = 50;
resend_delay_ms = 250;
resend_delay_factor = 1.5;
resend_delay_max = 2500;
stats_delay_ms = 9000;
connect_delay_ms = 250;
stale_connection_ms = 60000;
@ -241,6 +242,7 @@ namespace EQ
size_t keepalive_delay_ms;
double resend_delay_factor;
size_t resend_delay_ms;
size_t resend_delay_max;
size_t stats_delay_ms;
size_t connect_delay_ms;
size_t connect_stale_ms;