@@ -62,22 +62,35 @@ const COUNTER_FLOW_ID_MASK: u64 = 0x00FFFFFF;
6262#[ repr( u8 ) ]
6363pub enum CloseType {
6464 Unknown = 0 ,
65- TcpFin = 1 , // 1: 正常结束
66- TcpServerRst = 2 , // 2: 传输-服务端重置
67- Timeout = 3 , // 3: 连接超时
68- ForcedReport = 5 , // 5: 周期性上报
69- ClientSynRepeat = 7 , // 7: 建连-客户端SYN结束
70- ServerHalfClose = 8 , // 8: 断连-服务端半关
71- TcpClientRst = 9 , // 9: 传输-客户端重置
72- ServerSynAckRepeat = 10 , // 10: 建连-服务端SYN结束
73- ClientHalfClose = 11 , // 11: 断连-客户端半关
74- ClientSourcePortReuse = 13 , // 13: 建连-客户端端口复用
75- ServerReset = 15 , // 15: 建连-服务端直接重置
76- ServerQueueLack = 17 , // 17: 传输-服务端队列溢出
77- ClientEstablishReset = 18 , // 18: 建连-客户端其他重置
78- ServerEstablishReset = 19 , // 19: 建连-服务端其他重置
79- TcpFinClientRst = 20 , // 20: 正常结束-客户端重置
80- Max = 21 ,
65+ TcpFin = 1 , // 1: 正常结束
66+ TcpServerRst = 2 , // 2: 传输-服务端重置
67+ Timeout = 3 , // 3: 连接超时
68+ ForcedReport = 5 , // 5: 周期性上报
69+ ClientSynRepeat = 7 , // 7: 建连-客户端SYN结束
70+ ServerHalfClose = 8 , // 8: 断连-服务端半关
71+ TcpClientRst = 9 , // 9: 传输-客户端重置
72+ ServerSynAckRepeat = 10 , // 10: 建连-服务端SYN结束
73+ ClientHalfClose = 11 , // 11: 断连-客户端半关
74+ ClientSourcePortReuse = 13 , // 13: 建连-客户端端口复用
75+ ServerReset = 15 , // 15: 建连-服务端直接重置
76+ ServerQueueLack = 17 , // 17: 传输-服务端队列溢出
77+ ClientEstablishReset = 18 , // 18: 建连-客户端其他重置
78+ ServerEstablishReset = 19 , // 19: 建连-服务端其他重置
79+ TcpFinClientRst = 20 , // 20: 正常结束-客户端重置
80+ IcmpNormal = 21 , // 21: ICMP-正常结束
81+ IcmpAddressMaskTimeout = 22 , // 22: ICMP-地址掩码超时
82+ IcmpDestinationUnreachable = 23 , // 23: ICMP-目标不可达
83+ IcmpEchoTimeout = 24 , // 24: ICMP-PING超时
84+ IcmpInformationTimeout = 25 , // 25: ICMP-信息超时
85+ IcmpParameterProblem = 26 , // 26: ICMP-参数问题
86+ IcmpRouterTimeout = 27 , // 27: ICMP-路由器超时
87+ IcmpSourceQuench = 28 , // 28: ICMP-源站抑制
88+ IcmpTimeExceeded = 29 , // 29: ICMP-TTL溢出
89+ IcmpTimestampTimeout = 30 , // 30: ICMP-时间戳超时
90+ IcmpNeighborTimeout = 31 , // 31: ICMP-邻居发现超时
91+ IcmpPacketTooBig = 32 , // 32: ICMP-Packet过大
92+ IcmpOtherTimeout = 33 , // 33: ICMP-未知超时
93+ Max = 34 ,
8194}
8295
8396impl CloseType {
@@ -97,6 +110,18 @@ impl CloseType {
97110 || self == CloseType :: ServerReset
98111 || self == CloseType :: ServerQueueLack
99112 || self == CloseType :: ServerEstablishReset
113+ || self == CloseType :: IcmpAddressMaskTimeout
114+ || self == CloseType :: IcmpEchoTimeout
115+ || self == CloseType :: IcmpInformationTimeout
116+ || self == CloseType :: IcmpRouterTimeout
117+ || self == CloseType :: IcmpTimestampTimeout
118+ || self == CloseType :: IcmpNeighborTimeout
119+ || self == CloseType :: IcmpPacketTooBig
120+ || self == CloseType :: IcmpTimeExceeded
121+ || self == CloseType :: IcmpSourceQuench
122+ || self == CloseType :: IcmpDestinationUnreachable
123+ || self == CloseType :: IcmpParameterProblem
124+ || self == CloseType :: IcmpOtherTimeout
100125 }
101126}
102127
@@ -1070,7 +1095,40 @@ impl Flow {
10701095 FlowState :: Exception => CloseType :: Unknown ,
10711096 FlowState :: Opening1 => CloseType :: ClientSynRepeat ,
10721097 FlowState :: Opening2 => CloseType :: ServerSynAckRepeat ,
1073- FlowState :: Established => CloseType :: Timeout ,
1098+ FlowState :: IcmpAddressMaskReply => CloseType :: IcmpNormal ,
1099+ FlowState :: IcmpAddressMaskRequest => CloseType :: IcmpAddressMaskTimeout ,
1100+ FlowState :: IcmpEchoReply => CloseType :: IcmpNormal ,
1101+ FlowState :: IcmpEchoRequest => CloseType :: IcmpEchoTimeout ,
1102+ FlowState :: IcmpDestinationUnreachable => CloseType :: IcmpDestinationUnreachable ,
1103+ FlowState :: IcmpInformationReply => CloseType :: IcmpNormal ,
1104+ FlowState :: IcmpInformationRequest => CloseType :: IcmpInformationTimeout ,
1105+ FlowState :: IcmpNeighborAdvert => CloseType :: IcmpNormal ,
1106+ FlowState :: IcmpNeighborSolicit => CloseType :: IcmpNeighborTimeout ,
1107+ FlowState :: IcmpPacketTooBig => CloseType :: IcmpPacketTooBig ,
1108+ FlowState :: IcmpParameterProblem => CloseType :: IcmpParameterProblem ,
1109+ FlowState :: IcmpRedirectMessage => CloseType :: IcmpNormal ,
1110+ FlowState :: IcmpRouterAdvertisement => CloseType :: IcmpNormal ,
1111+ FlowState :: IcmpRouterSolicitation => CloseType :: IcmpRouterTimeout ,
1112+ FlowState :: IcmpSourceQuench => CloseType :: IcmpSourceQuench ,
1113+ FlowState :: IcmpTimeExceeded => CloseType :: IcmpTimeExceeded ,
1114+ FlowState :: IcmpTimestamp => CloseType :: IcmpTimestampTimeout ,
1115+ FlowState :: IcmpTimestampReply => CloseType :: IcmpNormal ,
1116+ FlowState :: IcmpTraceroute => CloseType :: IcmpNormal ,
1117+ FlowState :: Established => {
1118+ if self . flow_key . proto == IpProtocol :: ICMPV4
1119+ || self . flow_key . proto == IpProtocol :: ICMPV6
1120+ {
1121+ if self . flow_metrics_peers [ 0 ] . total_packet_count
1122+ != self . flow_metrics_peers [ 1 ] . total_packet_count
1123+ {
1124+ CloseType :: IcmpOtherTimeout
1125+ } else {
1126+ CloseType :: IcmpNormal
1127+ }
1128+ } else {
1129+ CloseType :: Timeout
1130+ }
1131+ }
10741132 FlowState :: ClosingTx1 => CloseType :: ServerHalfClose ,
10751133 FlowState :: ClosingRx1 => CloseType :: ClientHalfClose ,
10761134 FlowState :: ClosingTx2 | FlowState :: ClosingRx2 | FlowState :: Closed => CloseType :: TcpFin ,
0 commit comments