How to monitor Linux UDP buffer available space?
you is 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 us ing 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 a UDP datagram that your application m Ay receive, up to 64kiB. If your application may transmit datagrams larger than this and then it's another reason you should isn't be using UDP. And it really doesn ' t matter how big was the buffer, you still may lose packets if your application can ' t read the socket F Aster than packets arrive.
You say this want to know "how full" the UDP buffer is. This is the sort of thing that doesn ' t really matter. Just read everything that's waiting on the buffer and you can being sure that when it blocks the buffer would be empty.
If you still want to know how full the buffer is, the read the file /proc/net/udp
,
1. column rx_queue
2. Column Tx_queue is the same to Rx_queue
/PROC/NET/TCP is TCP info
How to monitor Linux UDP buffer available space?