Nerf protocol window sizes

This commit is contained in:
sfan5 2024-09-13 18:51:09 +02:00 committed by SmallJoker
parent b93cce11d8
commit 722c0044b1
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; packet_too_late = current_packet_too_late;
packets_successful = current_packet_successful; packets_successful = current_packet_successful;
// has half the window even been used?
if (current_bytes_transfered > (unsigned int) (m_window_size*512/2)) { if (current_bytes_transfered > (unsigned int) (m_window_size*512/2)) {
reasonable_amount_of_data_transmitted = true; reasonable_amount_of_data_transmitted = true;
} }

@ -329,15 +329,24 @@ private:
static ConnectionCommandPtr create(ConnectionCommandType type); 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 * touching it, the less you're away from it the more likely data corruption
* will occur * 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 0x8000
#define MAX_RELIABLE_WINDOW_SIZE_SEND 2048
/* starting value for window size */ /* starting value for window size */
#define START_RELIABLE_WINDOW_SIZE 0x400 #define START_RELIABLE_WINDOW_SIZE 64
/* minimum value for window size */ /* minimum value for window size */
#define MIN_RELIABLE_WINDOW_SIZE 0x40 #define MIN_RELIABLE_WINDOW_SIZE 32
class Channel class Channel
{ {
@ -405,7 +414,7 @@ public:
void setWindowSize(long size) 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: private:

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