Comments (4)
我的疑问:
- socket的缓存和TCP/UDP(网上说内核对UDP没有缓存)和窗口个数之间是什么关系?
UDP没有缓存的说法是错误的,man 7 udp有明确的说明:
udp_mem (since Linux 2.6.25)
This is a vector of three integers governing the number of pages allowed for queueing by all UDP sockets.
通过sysctl -a |grep udp, 可以观察到系统的udp缓存分配
窗口是TCP的概念,接收方用于告诉发送方可以一次性发送多少数据,而不等ACK,用于消除RTT带来的等待耗时。
KCP的默认MTU是1400,即单个UDP包最大为1400+8,不是你说的s.kcp.mss乘以窗口数,这里的分隔值只是确保单个数据包大小不超过整个发送缓冲区。
576这个值是个经验值,此文的时间可能比较久远,旧式设备可能有这个限制,但新设备基本都支持1400,你可以观察一下你的家用路由器的MTU默认值。 如果1400这个值真的导致了IP fragment,其实是很容易观察到降速问题的,按需调整也就行了。
from kcp-go.
谢谢 @xtaci
[ec2-user@ip-172-31-10-243 ~]$ sudo sysctl -a |grep udp
net.ipv4.udp_mem = 174852 233137 349704 (单位page个数)
net.ipv4.udp_rmem_min = 4096 (单位字节)
net.ipv4.udp_wmem_min = 4096 (单位字节)
麻烦帮看下我的理解的对吗?
- 设置窗口数主要参考上行和下行带宽,配合平均发送的数据大小,算出窗口值;
- 保证窗口值和kcp.mss的乘积接近但不大于udp_mem*PAGE_SIZE的最大值;
关于rmem_min 和 wmen_min设置有个疑问:
设置成udp_mem max / 使用udp的进程数是否是最好的?(但udp_mem max 的设置要注意不能占用全部剩余可用内存)
from kcp-go.
麻烦帮看下我的理解的对吗?
- 设置窗口数主要参考上行和下行带宽,配合平均发送的数据大小,算出窗口值;
静态窗口控制来说,这个是正确的。
- 保证窗口值和kcp.mss的乘积接近但不大于udp_mem*PAGE_SIZE的最大值;
两者没有关系,MTU已经控制了。建议你复习下TCP。
关于rmem_min 和 wmen_min设置有个疑问:
设置成udp_mem max / 使用udp的进程数是否是最好的?(但udp_mem max 的设置要注意不能占用全部剩余可用内存)udp_mem : 全局控制
udp_rmem_min : per socket控制 ( Each UDP socket is able to use the size for receiving data, even if total pages of UDP sockets exceed udp_mem pressure. )
udp_wmem_min : per socket控制
如果处理的够快,基本不需要调整这些参数,默认系统给的buffer就很大了,你可以计算下。
from kcp-go.
谢谢 @xtaci, 我买本tcp协议学习下。
from kcp-go.
Related Issues (20)
- 是不是可以修改session的fec配置? HOT 2
- is there a way to support non-block read?
- Write方法返回时不能保证数据写到了对方缓冲区 HOT 7
- Add exam in examples
- UDPSession.WriteBuffers里面的timeout 有内存泄漏风险 HOT 2
- why IKCP_OVERHEAD is 24bytes HOT 2
- Just need some help and explanation
- write to non-existent host does not cause an error
- packetInput 允许用户自行处理解码失败的UDP包
- is it possible to disable ack, for use in unidirectional network.
- 希望Listener上能提供一个NewUdpSession的方法
- 如何提升kcp的速度? HOT 4
- kcp.(*UDPSession).update 存在内存泄漏? HOT 19
- 为什么一重启服务器端,就收不到客户端传来的信息呢
- 服务器链接超过某个数后内存暴涨 HOT 1
- 如何抵御重放攻击(How to defend against replay attacks)? HOT 1
- 用户数据过大时,会出现数据错乱问题 HOT 3
- 只能通过UDPSession.Close才能跳出readloop循环,如果通过调用SetXXXDeadline的方式,会造成协程泄露。 HOT 1
- 在穿越了NAT的P2P隧道里,使用kcp.NewConn2建立的一对连接无法成功通信
- 请教一个dynamic fec的参数问题 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kcp-go.