kcp Window size

czfnxgou  于 2022-10-25  发布在  其他
关注(0)|答案(1)|浏览(172)

ikcp.h line 387 says ->

// set maximum window size: sndwnd=32, rcvwnd=32 by default
int ikcp_wndsize(ikcpcb *kcp, int sndwnd, int rcvwnd);

However the default setting for the receive window size ikcp.cpp line 248 says ->
kcp->rcv_wnd = IKCP_WND_RCV;

And

const IUINT32 IKCP_WND_RCV = 128; // must >= max fragment size

Meaning there is a discrepancy between the text in the header file and what is actually set in the cpp file.

Then I also got a question regarding the window size.

What it should be set to? meaning what parameters should I look for to set the optimal value, What is the best practise regarding the window size settings?

And can I set it in runtime meaning changing the window size during transmission?

Thank you for any help.

/Anders

lp0sw83n

lp0sw83n1#

Send and receive windows are how large the buffers are for outgoing and incoming packets.

sndwnd limits how many packets will be send out until things pause for the next ACK to come in. So if you set this higher, you'll use more memory but possibly get a higher throughput on high-latency connections. Similarly, if you expect a higher packet loss, you need more buffers to keep old packets around for resending them.

rcvwnd is how many buffers you allocate for receiving stuff. Once they are full, the receiver will notify the sender to pause/delay sending more. So if you expect large bursts of data or if you expect your receiving program to be a bit slow at handling the massages, you need a large receive window.

There's also an internal cwnd which is the control window for flow control after packets are lost due to congestion. That one kind of limits the sender as if the receivers rcvwnd was full, to throttle sending speed.

And yes, the new defaults appear to be sndwnd=32, rcvwnd=128. Those defaults seem reasonable for a game network protocol. 1024 for both is probably a good value for streaming videos or file downloads.

相关问题