最近在做的实验,需要同时保持大量的TCP连接,大概在3K的连接数,但是会在一些时刻突然有大量连接断开,等发现的时候也很难排查原因。
主要考虑有三方面的原因,1是网络,2是内存CPU,3是实验本身的代码。首先是排查网络的影响,google了一下,发现ubuntu自带的netstat工具就记录了丰富的网络相关的字段。
netstat -s输出如下:
Ip:
225089275794 total packets received
0 forwarded
87 with unknown protocol
0 incoming packets discarded
225089139658 incoming packets delivered
117924163195 requests sent out
4952 outgoing packets dropped
120 dropped because of missing route
67 fragments dropped after timeout
12431 reassemblies required
6181 packets reassembled ok
67 packet reassembles failed
Icmp:
7278063 ICMP messages received
5811819 input ICMP message failed.
InCsumErrors: 118
ICMP input histogram:
destination unreachable: 546500
timeout in tran