Nerf protocol window sizes

Probably due to a unit misunderstanding a long time ago the window sizes
were quite insane (especially the default).
In practice this was sometimes hidden by other bugs, games trying their
best to be lightweight or didn't matter on high-quality internet connections.
This commit is contained in:
sfan5 2024-08-30 15:58:02 +02:00
parent 9c2b2c002c
commit 42af7cc1c5
3 changed files with 15 additions and 4 deletions

@ -751,6 +751,7 @@ void Channel::UpdateTimers(float dtime)
packet_too_late = current_packet_too_late;
packets_successful = current_packet_successful;
// has half the window even been used?
if (current_bytes_transfered > (unsigned int) (m_window_size*512/2)) {
reasonable_amount_of_data_transmitted = true;
}

@ -354,15 +354,24 @@ private:
static ConnectionCommandPtr create(ConnectionCommandType type);
};
/* maximum window size to use, 0xFFFF is theoretical maximum. don't think about
/*
* Window sizes to use, in packets (not bytes!).
* 0xFFFF is theoretical maximum. don't think about
* touching it, the less you're away from it the more likely data corruption
* will occur
*
* Note: window sizes directly translate to maximum possible throughput, e.g.
* (2048 * 512 bytes) / 33ms = 15 MiB/s
*/
// Due to backwards compatibility we have different window sizes for what we'll
// accept from peers vs. what we use for sending.
#define MAX_RELIABLE_WINDOW_SIZE 0x8000
#define MAX_RELIABLE_WINDOW_SIZE_SEND 2048
/* starting value for window size */
#define START_RELIABLE_WINDOW_SIZE 0x400
#define START_RELIABLE_WINDOW_SIZE 64
/* minimum value for window size */
#define MIN_RELIABLE_WINDOW_SIZE 0x40
#define MIN_RELIABLE_WINDOW_SIZE 32
class Channel
{
@ -430,7 +439,7 @@ public:
void setWindowSize(long size)
{
m_window_size = (u16)rangelim(size, MIN_RELIABLE_WINDOW_SIZE, MAX_RELIABLE_WINDOW_SIZE);
m_window_size = (u16)rangelim(size, MIN_RELIABLE_WINDOW_SIZE, MAX_RELIABLE_WINDOW_SIZE_SEND);
}
private:

@ -327,6 +327,7 @@ void ConnectionSendThread::sendAsPacketReliable(BufferedPacketPtr &p, Channel *c
channel->outgoing_reliables_sent.insert(p,
(channel->readOutgoingSequenceNumber() - MAX_RELIABLE_WINDOW_SIZE)
% (MAX_RELIABLE_WINDOW_SIZE + 1));
// wtf is this calculation?? ^
}
catch (AlreadyExistsException &e) {
LOG(derr_con << m_connection->getDesc()