tcp: add more connection stats
[vpp.git] / src / vnet / tcp / tcp.h
index 698173e..fe02640 100644 (file)
@@ -300,6 +300,17 @@ typedef enum tcp_cc_event_
   TCP_CC_EVT_START_TX,
 } tcp_cc_event_t;
 
+/*
+ * As per RFC4898 tcpEStatsStackSoftErrors
+ */
+typedef struct tcp_errors_
+{
+  u32 below_data_wnd;  /**< All data in seg is below snd_una */
+  u32 above_data_wnd;  /**< Some data in segment is above snd_wnd */
+  u32 below_ack_wnd;   /**< Acks for data below snd_una */
+  u32 above_ack_wnd;   /**< Acks for data not sent */
+} tcp_errors_t;
+
 typedef struct _tcp_connection
 {
   CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
@@ -309,7 +320,10 @@ typedef struct _tcp_connection
   u16 flags;                   /**< Connection flags (see tcp_conn_flags_e) */
   u32 timers[TCP_N_TIMERS];    /**< Timer handles into timer wheel */
 
-  /* TODO RFC4898 */
+  u64 segs_in;         /** RFC4022/4898 tcpHCInSegs/tcpEStatsPerfSegsIn */
+  u64 bytes_in;                /** RFC4898 tcpEStatsPerfHCDataOctetsIn */
+  u64 segs_out;                /** RFC4898 tcpEStatsPerfSegsOut */
+  u64 bytes_out;       /** RFC4898 tcpEStatsPerfHCDataOctetsOut */
 
   /** Send sequence variables RFC793 */
   u32 snd_una;         /**< oldest unacknowledged sequence number */
@@ -320,6 +334,9 @@ typedef struct _tcp_connection
   u32 snd_nxt;         /**< next seq number to be sent */
   u16 snd_mss;         /**< Effective send max seg (data) size */
 
+  u64 data_segs_in;    /** RFC4898 tcpEStatsPerfDataSegsIn */
+  u64 data_segs_out;   /** RFC4898 tcpEStatsPerfDataSegsOut */
+
   /** Receive sequence variables RFC793 */
   u32 rcv_nxt;         /**< next sequence number expected */
   u32 rcv_wnd;         /**< receive window we expect */
@@ -342,8 +359,10 @@ typedef struct _tcp_connection
   sack_block_t *snd_sacks_fl;  /**< Vector for building new list */
   sack_scoreboard_t sack_sb;   /**< SACK "scoreboard" that tracks holes */
 
-  u16 rcv_dupacks;     /**< Number of DUPACKs received */
+  u16 rcv_dupacks;     /**< Number of recent DUPACKs received */
+  u32 dupacks_in;      /**< RFC4898 tcpEStatsStackDupAcksIn*/
   u8 pending_dupacks;  /**< Number of DUPACKs to be sent */
+  u32 dupacks_out;     /**< RFC4898 tcpEStatsPathDupAcksOut */
 
   /* Congestion control */
   u32 cwnd;            /**< Congestion window */
@@ -361,6 +380,12 @@ typedef struct _tcp_connection
   tcp_cc_algorithm_t *cc_algo; /**< Congestion control algorithm */
   u8 cc_data[TCP_CC_DATA_SZ];  /**< Congestion control algo private data */
 
+  u32 fr_occurences;   /**< fast-retransmit occurrences RFC4898
+                            tcpEStatsStackFastRetran */
+  u32 tr_occurences;   /**< timer-retransmit occurrences */
+  u64 bytes_retrans;   /**< RFC4898 tcpEStatsPerfOctetsRetrans */
+  u64 segs_retrans;    /**< RFC4898 tcpEStatsPerfSegsRetrans*/
+
   /* RTT and RTO */
   u32 rto;             /**< Retransmission timeout */
   u32 rto_boff;                /**< Index for RTO backoff */
@@ -382,9 +407,12 @@ typedef struct _tcp_connection
   f64 delivered_time;          /**< Time last bytes were acked */
   tcp_byte_tracker_t *bt;      /**< Tx byte tracker */
 
+  tcp_errors_t errors; /**< Soft connection errors */
+
+  f64 start_ts;                /**< Timestamp when connection initialized */
   u32 last_fib_check;  /**< Last time we checked fib route for peer */
   u16 mss;             /**< Our max seg size that includes options */
-  u32 timestamp_delta;
+  u32 timestamp_delta; /**< Offset for timestamp */
 } tcp_connection_t;
 
 /* *INDENT-OFF* */