How to monitor Linux UDP buffer available space?

本文探讨了为什么许多程序员难以晋升为架构师的原因,并提出了解决方案,包括避免使用不可靠的UDP协议,优先考虑TCP或其他更高级的协议,以及优化应用程序读取速度以避免缓冲区溢出。

How to monitor Linux UDP buffer available space?

You are trying to solve the wrong problem. UDP is unreliable communication, period. If packet loss is a problem for you, you should either implement your own retransmission/error control algorithm or not using UDP in the first place. Drop it entirely in favor of TCP, or perhaps something more advanced like SCTP or even DCCP.

UDP is datagram-based, socket buffers should be bigger than the maximum length of an UDP datagram that your application may receive, up to 64kiB. If your application may transmit datagrams larger than this, then it is another reason you should not be using UDP. And it really doesn't matter how big is the buffer, you still may lose packets if your application can't read the socket faster than packets arrive.

You say that you want to know how full the UDP buffer is. This is the sort of thing that doesn't really matter. Just read everything that is waiting on the buffer and you can be sure that when it blocks the buffer will be empty.

If you still want to know how full the buffer is, read the file /proc/net/udp, 

             1. column rx_queue. But if you see any value different than zero in that column, it just means that your application is not reading the socket fast enough.

             2. column tx_queue is the same to rx_queue


   /proc/net/tcp  is  tcp info

转载于:https://my.oschina.net/miffa/blog/357282

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值