netstat Recv-Q和Send-Q详解
http://blog.csdn.net/sjin_1314/article/details/9853163
通过netstat -anp可以查看机器的当前连接状态:
“Proto” is short for protocol, which is either TCP or UDP. “Recv-Q” and “Send-Q” mean receiving queue and sending queue. These should always be zero; if they\’re not you might have a problem. Packets should not be piling up in either queue, except briefly, as this example shows:
tcp 0 593 192.168.1.5:34321 venus.euao.com:smtp ESTABLISHED
That happened when I hit the “check mail” button in KMail; a brief queuing of outgoing packets is normal behavior. If the receiving queue is consistently jamming up, you might be experiencing a denial-of-service attack. If the sending queue does not clear quickly, you might have an application that is sending them out too fast, or the receiver cannot accept them quickly enough.
“Local address” is either your IP and port number, or IP and the name of a service. “Foreign address” is the hostname and service you are connected to. The asterisk is a placeholder for IP addresses, which of course cannot be known until a remote host connects. “State” is the current status of the connection. Any TCP state can be displayed here, but these three are the ones you want to see。
这两个值通常应该为0,如果不为0可能是有问题的。packets在两个队列里都不应该有堆积状态。可接受短暂的非0情况。如文中的示例,短暂的Send-Q队列发送pakets非0是正常状态。
Recv-Q:表示收到的数据已经在本地接收缓冲,但是还有多少没有被进程取走,recv()
Send-Q:对方没有收到的数据或者说没有Ack的,还是本地缓冲区.
通过netstat的这两个值就可以简单判断程序收不到包到底是包没到还是包没有被进程recv。