Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ikcp_send 在流模式下为何也要限制127个MSS呢? #431

Open
colinsusie opened this issue Oct 28, 2024 · 2 comments
Open

ikcp_send 在流模式下为何也要限制127个MSS呢? #431

colinsusie opened this issue Oct 28, 2024 · 2 comments

Comments

@colinsusie
Copy link

阅读源码发现在stream=1的时候,ikcp_send 做数据分段发现如下代码:

	if (len <= (int)kcp->mss) count = 1;
	else count = (len + kcp->mss - 1) / kcp->mss;

	if (count >= (int)IKCP_WND_RCV) return -2;

即使流模式也会限制分段的数量,感觉似乎没必要;这样上层大于127就要自己分成多次调用ikcp_send。
有其他的原因吗?

@skywind3000
Copy link
Owner

因为 kcp 不是流式的,窗口需要容纳下一个完整的消息才行。

@colinsusie
Copy link
Author

@skywind3000 非流模式我能理解,一个完整消息需要在窗口之内。
但流模式的frg似乎一直都是0,每次从KCP接收只返回一个segment。

现在上层发送过大的包也要分成多次调用ikcp_send;而流模式接收的时候并不是按发送多少次就接收多少次,是一个个segment接收。这样在流模式下限制包大小好好像不是很必要?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants