diff options
| author | lijia <[email protected]> | 2024-11-19 19:17:00 +0800 |
|---|---|---|
| committer | lijia <[email protected]> | 2024-11-25 16:18:34 +0800 |
| commit | c7b97c072b52676b6c17bf6713f399ce0273b308 (patch) | |
| tree | 1a3e73dfbb0eee578eea8262a2d4314a75b3ee54 /include | |
| parent | 8d24a9cc945c2a6d0b0bfa447c7b4d1caec9397c (diff) | |
Diffstat (limited to 'include')
| -rw-r--r-- | include/private/stream_internal.h | 20 | ||||
| -rw-r--r-- | include/public/stream_inc/stream_control.h | 126 |
2 files changed, 82 insertions, 64 deletions
diff --git a/include/private/stream_internal.h b/include/private/stream_internal.h index 044bc32..731c81f 100644 --- a/include/private/stream_internal.h +++ b/include/private/stream_internal.h @@ -6,6 +6,7 @@ #include "mesa_pkt_dump.h" #include "sapp_limits.h" #include "stream.h" +#include <float.h> //#define STREAM_BASE_MD5_CHECK "dd09b3b11993cc835200db477dad7d4b" //#define STREAM_CONTROL_MD5_CHECK "75aab0821e489b84355fa22ad02a2e78" @@ -57,6 +58,8 @@ #ifndef uuid_t typedef unsigned char uuid_t[16]; #endif +#define TCP_SAMPLING_SRTT_INTERVAL_MS (5000) /* millisecond */ +#define TCP_SRTT_EWMA_ALPHA (0.125) #ifdef __cplusplus extern "C" { @@ -264,6 +267,18 @@ struct streaminfo_private uuid_t stream_uuid; }; +#define DOUBLE_EPSILON 1e-15 +#define DOUBLE_IS_ZERO(v) (fabs(v) < DOUBLE_EPSILON) +struct tcp_srtt_metric +{ + long long last_rtt_sampling_time; + unsigned short half_pkt_interval_c2s; + unsigned short half_pkt_interval_s2c; + unsigned short rtt_dpi_server_dpi; /* millisecond, duration of 'dpi-->server-->dpi', every Nsec throughout the life of stream */ + unsigned short rtt_dpi_client_dpi; /* millisecond, duration of 'dpi-->client-->dpi', every Nsec throughout the life of stream */ + double srtt; /* Smoothed Round-Trip Time, update every Nsec throughout the life of stream */ +}; + struct tcpdetail_private { /* ����ṹ�����ڽṹ�����?, ָ���ַ���Ի���ǿ�? */ @@ -304,10 +319,11 @@ struct tcpdetail_private void *pAllpktpme; //��״̬��tcp���������� struct tcp_flow_stat *flow_stat; /* 2016-07-14 lijia add, ���ڼ�¼TCP��data���ļ���, ʵ���ڴ������ͷ���projectģ�����?, ����ΪNULL, */ struct tcp_flow_stat *deduce_flow_stat; /* 2018-10-30 lijia add, ���ڼ�¼������ƶϳ������ϴ��������, ���������ij���; �Լ������������?, �Զ�Ӧ���յ������� */ - unsigned short rtt_csc; - unsigned short rtt_scs; + double internet_latency; /* millisecond, from the hashshake phase */ + double access_latency; /* millisecond, from the hashshake phase */ long long last_c2s_pkt_rcv_time; long long last_s2c_pkt_rcv_time; + struct tcp_srtt_metric srtt_metric; }; struct udpdetail_private diff --git a/include/public/stream_inc/stream_control.h b/include/public/stream_inc/stream_control.h index 4353f70..eb3e0bd 100644 --- a/include/public/stream_inc/stream_control.h +++ b/include/public/stream_inc/stream_control.h @@ -14,68 +14,70 @@ extern "C" /*
option of stream,
- MSO_IGNORE_RST_FIN: will not be terminated by RST, FIN packet, only if timeout or in LRU tail, it will be eliminated.
- */
- enum MESA_stream_opt
- {
- __MSO_PAD = 0, /* placeholder */
- MSO_MAX_UNORDER = 1, /* opt_val type must be struct max_unorder_opt */
- MSO_NEED_ACK, /* opt_val type must be unsigned char, value only be [0,1] */
- MSO_TAKEOVER, /* opt_val type must be int, value only be [0,1] */
- MSO_TIMEOUT, /* opt_val type must be unsigned short */
- MSO_IGNORE_RST_FIN, /* opt_val type must be unsigned char, value only be [0,1] */
- MSO_TCP_CREATE_LINK_MODE, /* opt_val must be unsigned char, refer to TCP_CTEAT_LINK_xxx */
- MSO_TCP_ISN_C2S, /* Host-order, opt_val type must be unsigned int */
- MSO_TCP_ISN_S2C, /* Host-order, opt_val type must be unsigned int */
- MSO_TCP_SYN_OPT, /* opt_val must be struct tcp_option **, opt_val_len [OUT} is struct tcp_option number, valid only if SYN packet is captured */
- MSO_TCP_SYNACK_OPT, /* opt_val must be struct tcp_option **, opt_val_len [OUT} is struct tcp_option number, valid only if SYN/ACK packet is captured */
- MSO_STREAM_TUNNEL_TYPE, /* opt_val must be unsigned short, refer to enum stream_carry_tunnel_t */
- MSO_STREAM_CLOSE_REASON, /* opt_val type must be unsigned char, refer to stream_close_reason_t */
- MSO_STREAM_VXLAN_INFO, /* opt_val type must be struct vxlan_info, only support for MAC-in-MAC encapsulation in mirror mode */
- MSO_TCPALL_VALID_AFTER_KILL, /* opt_val type must be unsigned char, value only be [0,1]; Warning, this option is obsolete, use MESA_rst_tcp() instead */
- MSO_GLOBAL_STREAM_ID, /* opt_val type must be unsigned long long, is value-result argument, IN: device_id, value range[0, 4095]; OUT:global stream id */
- MSO_DROP_STREAM, /* opt_val type must be int, value only be [0,1]; similar to DROPPKT, but effective scope is all subsequent packets of this stream. */
- MSO_TCP_RST_REMEDY, /* opt_val type must be int, value only be [0,1]; if not set this, default is disable. */
- MSO_TOTAL_INBOUND_PKT, /* inbound packet number of this stream, opt_val type must be unsigned long long */
- MSO_TOTAL_INBOUND_BYTE, /* inbound packet byte of this stream, opt_val type must be unsigned long long */
- MSO_TOTAL_OUTBOUND_PKT, /* outbound packet pkt of this stream, opt_val type must be unsigned long long */
- MSO_TOTAL_OUTBOUND_BYTE, /* outbound packet byte of this stream, opt_val type must be unsigned long long */
- MSO_STREAM_CREATE_TIMESTAMP_MS, /* first pkt arrive timestamp of this stream, opt_val type must be unsigned long long */
- MSO_TOTAL_INBOUND_BYTE_RAW, /* inbound packet byte of this stream, raw packet len, include ip hdr, ethernet hdr... opt_val type must be unsigned long long */
- MSO_TOTAL_OUTBOUND_BYTE_RAW, /* outbound packet byte of this stream, raw packet len, include ip hdr, ethernet hdr... opt_val type must be unsigned long long */
- MSO_STREAM_UP_LAYER_TUNNEL_TYPE, /* opt_val must be unsigned short, refer to enum stream_carry_tunnel_t */
- MSO_STREAM_PLUG_PME, /* opt_val type must be struct mso_plug_pme, this is a value-result argument, the caller should set plug_name and plug_entry_type, only support: TCP, TCP_ALL, UDP */
- MSO_DROP_CURRENT_PKT, /* opt_val type must be int, value only be [0,1], notice the difference between MSO_DROP_CURRENT_PKT and MSO_DROP_STREAM, MSO_DROP_CURRENT_PKT only discard current packet, but MSO_DROP_STREAM discard all subsequent packets of stream */
- MSO_HAVE_DUP_PKT, /* opt_val type must be int, value only be [0, 1, -2], if the current stream found duplicate packets ? 0:no; 1:yes; -2: not sure */
- MSO_STREAM_LASTUPDATE_TIMESTAMP_MS, /* latest pkt arrive timestamp of this stream, opt_val type must be unsigned long long */
- MSO_STREAM_TIMED,
- MSO_STREAM_APPLEND_SEGMENT_ID_LIST,
- MSO_STREAM_PREPLEND_SEGMENT_ID_LIST,
- MSO_STREAM_SET_DATAMETA_TRACE_ID,
- MSO_STREAM_C2S_RAWPKT_HDR,
- MSO_STREAM_S2C_RAWPKT_HDR,
- MSO_STREAM_C2S_SYN_NUM,
- MSO_STREAM_S2C_SYN_NUM,
- MSO_STREAM_INBOND_LINK_ID,
- MSO_STREAM_OUTBOND_LINK_ID,
- MSO_STREAM_C2S_ROUTE_DIRECTION,
- MSO_STREAM_INBOND_ROUTE_CTX,
- MSO_STREAM_OUTBOND_ROUTE_CTX,
- MSO_STREAM_C2S_LINK_ID,
- MSO_STREAM_S2C_LINK_ID,
- MSO_STREAM_C2S_ROUTE_CTX,
- MSO_STREAM_S2C_ROUTE_CTX,
- MSO_IP_TTL_C2S, /* opt_val type must be unsigned char, IPv4 is TTL, IPv6 is Hop Limit */
- MSO_IP_TTL_S2C, /* opt_val type must be unsigned char, IPv4 is TTL, IPv6 is Hop Limit */
- MSO_TCP_RTT_CSC, /* opt_val type must be unsigned short, the full RTT is client->tsg->server->tsg->client, this is |tsg->server->tsg| */
- MSO_TCP_RTT_SCS, /* opt_val type must be unsigned short, the full RTT is server->tsg->client->tsg->server, this is |tsg->client->tsg| */
- MSO_STREAM_C2S_SEGMENT_ID_LIST,
- MSO_STREAM_S2C_SEGMENT_ID_LIST,
- MSO_STREAM_INBOND_SEGMENT_ID_LIST,
- MSO_STREAM_OUTBOND_SEGMENT_ID_LIST,
- MSO_STREAM_UUID, /* opt_val is uuid_t (unsigned char [16]) */
- __MSO_MAX,
- };
+ MSO_IGNORE_RST_FIN: will not be terminated by RST, FIN packet, only if timeout or in LRU tail, it will be eliminated.
+*/
+enum MESA_stream_opt{
+ __MSO_PAD = 0, /* placeholder */
+ MSO_MAX_UNORDER = 1, /* opt_val type must be struct max_unorder_opt */
+ MSO_NEED_ACK, /* opt_val type must be unsigned char, value only be [0,1] */
+ MSO_TAKEOVER, /* opt_val type must be int, value only be [0,1] */
+ MSO_TIMEOUT, /* opt_val type must be unsigned short */
+ MSO_IGNORE_RST_FIN, /* opt_val type must be unsigned char, value only be [0,1] */
+ MSO_TCP_CREATE_LINK_MODE, /* opt_val must be unsigned char, refer to TCP_CTEAT_LINK_xxx */
+ MSO_TCP_ISN_C2S, /* Host-order, opt_val type must be unsigned int */
+ MSO_TCP_ISN_S2C, /* Host-order, opt_val type must be unsigned int */
+ MSO_TCP_SYN_OPT, /* opt_val must be struct tcp_option **, opt_val_len [OUT} is struct tcp_option number, valid only if SYN packet is captured */
+ MSO_TCP_SYNACK_OPT, /* opt_val must be struct tcp_option **, opt_val_len [OUT} is struct tcp_option number, valid only if SYN/ACK packet is captured */
+ MSO_STREAM_TUNNEL_TYPE, /* opt_val must be unsigned short, refer to enum stream_carry_tunnel_t */
+ MSO_STREAM_CLOSE_REASON, /* opt_val type must be unsigned char, refer to stream_close_reason_t */
+ MSO_STREAM_VXLAN_INFO, /* opt_val type must be struct vxlan_info, only support for MAC-in-MAC encapsulation in mirror mode */
+ MSO_TCPALL_VALID_AFTER_KILL, /* opt_val type must be unsigned char, value only be [0,1]; Warning, this option is obsolete, use MESA_rst_tcp() instead */
+ MSO_GLOBAL_STREAM_ID, /* opt_val type must be unsigned long long, is value-result argument, IN: device_id, value range[0, 4095]; OUT:global stream id */
+ MSO_DROP_STREAM, /* opt_val type must be int, value only be [0,1]; similar to DROPPKT, but effective scope is all subsequent packets of this stream. */
+ MSO_TCP_RST_REMEDY, /* opt_val type must be int, value only be [0,1]; if not set this, default is disable. */
+ MSO_TOTAL_INBOUND_PKT, /* inbound packet number of this stream, opt_val type must be unsigned long long */
+ MSO_TOTAL_INBOUND_BYTE, /* inbound packet byte of this stream, opt_val type must be unsigned long long */
+ MSO_TOTAL_OUTBOUND_PKT, /* outbound packet pkt of this stream, opt_val type must be unsigned long long */
+ MSO_TOTAL_OUTBOUND_BYTE,/* outbound packet byte of this stream, opt_val type must be unsigned long long */
+ MSO_STREAM_CREATE_TIMESTAMP_MS,/* first pkt arrive timestamp of this stream, opt_val type must be unsigned long long */
+ MSO_TOTAL_INBOUND_BYTE_RAW, /* inbound packet byte of this stream, raw packet len, include ip hdr, ethernet hdr... opt_val type must be unsigned long long */
+ MSO_TOTAL_OUTBOUND_BYTE_RAW,/* outbound packet byte of this stream, raw packet len, include ip hdr, ethernet hdr... opt_val type must be unsigned long long */
+ MSO_STREAM_UP_LAYER_TUNNEL_TYPE, /* opt_val must be unsigned short, refer to enum stream_carry_tunnel_t */
+ MSO_STREAM_PLUG_PME, /* opt_val type must be struct mso_plug_pme, this is a value-result argument, the caller should set plug_name and plug_entry_type, only support: TCP, TCP_ALL, UDP */
+ MSO_DROP_CURRENT_PKT, /* opt_val type must be int, value only be [0,1], notice the difference between MSO_DROP_CURRENT_PKT and MSO_DROP_STREAM, MSO_DROP_CURRENT_PKT only discard current packet, but MSO_DROP_STREAM discard all subsequent packets of stream */
+ MSO_HAVE_DUP_PKT, /* opt_val type must be int, value only be [0, 1, -2], if the current stream found duplicate packets ? 0:no; 1:yes; -2: not sure */
+ MSO_STREAM_LASTUPDATE_TIMESTAMP_MS,/* latest pkt arrive timestamp of this stream, opt_val type must be unsigned long long */
+ MSO_STREAM_TIMED,
+ MSO_STREAM_APPLEND_SEGMENT_ID_LIST,
+ MSO_STREAM_PREPLEND_SEGMENT_ID_LIST,
+ MSO_STREAM_SET_DATAMETA_TRACE_ID,
+ MSO_STREAM_C2S_RAWPKT_HDR,
+ MSO_STREAM_S2C_RAWPKT_HDR,
+ MSO_STREAM_C2S_SYN_NUM,
+ MSO_STREAM_S2C_SYN_NUM,
+ MSO_STREAM_INBOND_LINK_ID,
+ MSO_STREAM_OUTBOND_LINK_ID,
+ MSO_STREAM_C2S_ROUTE_DIRECTION,
+ MSO_STREAM_INBOND_ROUTE_CTX,
+ MSO_STREAM_OUTBOND_ROUTE_CTX,
+ MSO_STREAM_C2S_LINK_ID,
+ MSO_STREAM_S2C_LINK_ID,
+ MSO_STREAM_C2S_ROUTE_CTX,
+ MSO_STREAM_S2C_ROUTE_CTX,
+ MSO_IP_TTL_C2S, /* opt_val type must be unsigned char, IPv4 is TTL, IPv6 is Hop Limit */
+ MSO_IP_TTL_S2C, /* opt_val type must be unsigned char, IPv4 is TTL, IPv6 is Hop Limit */
+ MSO_TCP_RTT_CSC, /* deprecated in v24.12 */
+ MSO_TCP_RTT_SCS, /* deprecated in v24.12 */
+ MSO_STREAM_C2S_SEGMENT_ID_LIST,
+ MSO_STREAM_S2C_SEGMENT_ID_LIST,
+ MSO_STREAM_INBOND_SEGMENT_ID_LIST,
+ MSO_STREAM_OUTBOND_SEGMENT_ID_LIST,
+ MSO_STREAM_UUID, /* opt_val is uuid_t (unsigned char [16]) */
+ MSO_ACCESS_LATENCY, /* millisecond, opt_val type must be double, the access latency from client to DPI system */
+ MSO_INTERNET_LATENCY, /* millisecond, opt_val type must be double, the internet latency from DPI system to server */
+ MSO_TCP_STREAM_SRTT, /* millisecond, opt_val type must be double, the SRTT of current TCP stream */
+ __MSO_MAX,
+};
/* for MSO_STREAM_CLOSE_REASON,
don't confuse, these values is not consecutive indeed, because some value(1,2) is obsoleted!
|
