Print this page
11547 Want connstat(1M) command to display per-connection TCP statistics
Portions contributed by: Cody Peter Mello <cody.mello@joyent.com>
Portions contributed by: Ahmed G <ahmedg@delphix.com>
Reviewed by: Jason King <jason.king@joyent.com>
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Dan McDonald <danmcd@joyent.com>


 160         clock_t tcp_rto;                /* Round trip timeout */
 161         int64_t tcp_last_rcv_lbolt;
 162                                 /* lbolt on last packet, used for PAWS */
 163         uint32_t tcp_rto_initial;       /* Initial RTO */
 164         uint32_t tcp_rto_min;           /* Minimum RTO */
 165         uint32_t tcp_rto_max;           /* Maximum RTO */
 166 
 167         uint32_t tcp_snxt;              /* Senders next seq num */
 168         uint32_t tcp_swnd;              /* Senders window (relative to suna) */
 169         uint32_t tcp_mss;               /* Max segment size */
 170         uint32_t tcp_iss;               /* Initial send seq num */
 171         uint32_t tcp_rnxt;              /* Seq we expect to recv next */
 172         uint32_t tcp_rwnd;
 173 
 174         /* Fields arranged in approximate access order along main paths */
 175         mblk_t  *tcp_xmit_head;         /* Head of xmit/rexmit list */
 176         mblk_t  *tcp_xmit_last;         /* Last valid data seen by tcp_wput */
 177         mblk_t  *tcp_xmit_tail;         /* Last data sent */
 178         uint32_t tcp_unsent;            /* # of bytes in hand that are unsent */
 179         uint32_t tcp_xmit_tail_unsent;  /* # of unsent bytes in xmit_tail */
 180 
 181         uint32_t tcp_suna;              /* Sender unacknowledged */
 182         uint32_t tcp_rexmit_nxt;        /* Next rexmit seq num */
 183         uint32_t tcp_rexmit_max;        /* Max retran seq num */
 184         uint32_t tcp_cwnd;              /* Congestion window */
 185         int32_t tcp_cwnd_cnt;           /* cwnd cnt in congestion avoidance */
 186 
 187         uint32_t tcp_ibsegs;            /* Inbound segments on this stream */
 188         uint32_t tcp_obsegs;            /* Outbound segments on this stream */
 189 
 190         uint32_t tcp_naglim;            /* Tunable nagle limit */
 191         uint32_t        tcp_valid_bits;
 192 #define TCP_ISS_VALID   0x1     /* Is the tcp_iss seq num active? */
 193 #define TCP_FSS_VALID   0x2     /* Is the tcp_fss seq num active? */
 194 #define TCP_URG_VALID   0x4     /* Is the tcp_urg seq num active? */
 195 #define TCP_OFO_FIN_VALID 0x8   /* Has TCP received an out of order FIN? */
 196 
 197 
 198 
 199         timeout_id_t    tcp_timer_tid;  /* Control block for timer service */
 200         uchar_t tcp_timer_backoff;      /* Backoff shift count. */
 201         int64_t tcp_last_recv_time;     /* Last time we receive a segment. */
 202         uint32_t tcp_init_cwnd;         /* Initial cwnd (start/restart) */
 203 
 204         /* Following manipulated by TCP under squeue protection */
 205         uint32_t
 206                 tcp_urp_last_valid : 1, /* Is tcp_urp_last valid? */
 207                 tcp_hard_binding : 1,   /* TCP_DETACHED_NONEAGER */
 208                 tcp_fin_acked : 1,      /* Has our FIN been acked? */
 209                 tcp_fin_rcvd : 1,       /* Have we seen a FIN? */
 210 
 211                 tcp_fin_sent : 1,       /* Have we sent our FIN yet? */
 212                 tcp_ordrel_done : 1,    /* Have we sent the ord_rel upstream? */
 213                 tcp_detached : 1,       /* If we're detached from a stream */
 214                 tcp_zero_win_probe: 1,  /* Zero win probing is in progress */
 215 
 216                 tcp_loopback: 1,        /* src and dst are the same machine */
 217                 tcp_localnet: 1,        /* src and dst are on the same subnet */
 218                 tcp_syn_defense: 1,     /* For defense against SYN attack */


 265 
 266 #define tcp_pipe                tcp_sack_info.tcp_pipe
 267 #define tcp_fack                tcp_sack_info.tcp_fack
 268 #define tcp_sack_snxt           tcp_sack_info.tcp_sack_snxt
 269 #define tcp_max_sack_blk        tcp_sack_info.tcp_max_sack_blk
 270 #define tcp_num_sack_blk        tcp_sack_info.tcp_num_sack_blk
 271 #define tcp_sack_list           tcp_sack_info.tcp_sack_list
 272 #define tcp_num_notsack_blk     tcp_sack_info.tcp_num_notsack_blk
 273 #define tcp_cnt_notsack_list    tcp_sack_info.tcp_cnt_notsack_list
 274 #define tcp_notsack_list        tcp_sack_info.tcp_notsack_list
 275 
 276         mblk_t  *tcp_rcv_list;          /* Queued until push, urgent data, */
 277         mblk_t  *tcp_rcv_last_head;     /* optdata, or the count exceeds */
 278         mblk_t  *tcp_rcv_last_tail;     /* tcp_rcv_push_wait. */
 279         uint32_t tcp_rcv_cnt;           /* tcp_rcv_list is b_next chain. */
 280 
 281         uint32_t tcp_cwnd_ssthresh;     /* Congestion window */
 282         uint32_t tcp_cwnd_max;
 283         uint32_t tcp_csuna;             /* Clear (no rexmits in window) suna */
 284 


 285         hrtime_t tcp_rtt_sa;            /* Round trip smoothed average */
 286         hrtime_t tcp_rtt_sd;            /* Round trip smoothed deviation */
 287         uint32_t tcp_rtt_update;        /* Round trip update(s) */
 288         clock_t tcp_ms_we_have_waited;  /* Total retrans time */
 289 
 290         uint32_t tcp_swl1;              /* These help us avoid using stale */
 291         uint32_t tcp_swl2;              /*  packets to update state */
 292 
 293         uint32_t tcp_rack;              /* Seq # we have acked */
 294         uint32_t tcp_rack_cnt;          /* # of segs we have deferred ack */
 295         uint32_t tcp_rack_cur_max;      /* # of segs we may defer ack for now */
 296         uint32_t tcp_rack_abs_max;      /* # of segs we may defer ack ever */
 297         timeout_id_t    tcp_ack_tid;    /* Delayed ACK timer ID */
 298         timeout_id_t    tcp_push_tid;   /* Push timer ID */
 299 
 300         uint32_t tcp_max_swnd;          /* Maximum swnd we have seen */
 301 
 302         struct tcp_s *tcp_listener;     /* Our listener */
 303 
 304         uint32_t tcp_irs;               /* Initial recv seq num */


 476          * Socket generation number which is bumped when a connection attempt
 477          * is initiated. Its main purpose is to ensure that the socket does not
 478          * miss the asynchronous connected/disconnected notification.
 479          */
 480         sock_connid_t   tcp_connid;
 481 
 482         /* mblk_t used to enter TCP's squeue from the service routine. */
 483         mblk_t          *tcp_rsrv_mp;
 484         /* Mutex for accessing tcp_rsrv_mp */
 485         kmutex_t        tcp_rsrv_mp_lock;
 486 
 487         /* For connection counting. */
 488         struct tcp_listen_cnt_s *tcp_listen_cnt;
 489 
 490         /* Segment reassembly timer. */
 491         timeout_id_t            tcp_reass_tid;
 492 
 493         /* FIN-WAIT-2 flush timeout */
 494         uint32_t                tcp_fin_wait_2_flush_interval;
 495 


 496 #ifdef DEBUG
 497         pc_t                    tcmp_stk[15];
 498 #endif
 499 } tcp_t;
 500 
 501 #ifdef DEBUG
 502 #define TCP_DEBUG_GETPCSTACK(buffer, depth)     ((void) getpcstack(buffer, \
 503                                                     depth))
 504 #else
 505 #define TCP_DEBUG_GETPCSTACK(buffer, depth)
 506 #endif
 507 
 508 extern void     tcp_conn_reclaim(void *);
 509 extern void     tcp_free(tcp_t *tcp);
 510 extern void     tcp_ddi_g_init(void);
 511 extern void     tcp_ddi_g_destroy(void);
 512 extern void     *tcp_get_conn(void *arg, tcp_stack_t *);
 513 extern mblk_t   *tcp_snmp_get(queue_t *, mblk_t *, boolean_t);
 514 extern int      tcp_snmp_set(queue_t *, int, int, uchar_t *, int len);
 515 




 160         clock_t tcp_rto;                /* Round trip timeout */
 161         int64_t tcp_last_rcv_lbolt;
 162                                 /* lbolt on last packet, used for PAWS */
 163         uint32_t tcp_rto_initial;       /* Initial RTO */
 164         uint32_t tcp_rto_min;           /* Minimum RTO */
 165         uint32_t tcp_rto_max;           /* Maximum RTO */
 166 
 167         uint32_t tcp_snxt;              /* Senders next seq num */
 168         uint32_t tcp_swnd;              /* Senders window (relative to suna) */
 169         uint32_t tcp_mss;               /* Max segment size */
 170         uint32_t tcp_iss;               /* Initial send seq num */
 171         uint32_t tcp_rnxt;              /* Seq we expect to recv next */
 172         uint32_t tcp_rwnd;
 173 
 174         /* Fields arranged in approximate access order along main paths */
 175         mblk_t  *tcp_xmit_head;         /* Head of xmit/rexmit list */
 176         mblk_t  *tcp_xmit_last;         /* Last valid data seen by tcp_wput */
 177         mblk_t  *tcp_xmit_tail;         /* Last data sent */
 178         uint32_t tcp_unsent;            /* # of bytes in hand that are unsent */
 179         uint32_t tcp_xmit_tail_unsent;  /* # of unsent bytes in xmit_tail */

 180         uint32_t tcp_suna;              /* Sender unacknowledged */
 181         uint32_t tcp_rexmit_nxt;        /* Next rexmit seq num */
 182         uint32_t tcp_rexmit_max;        /* Max retran seq num */
 183         uint32_t tcp_cwnd;              /* Congestion window */
 184         int32_t tcp_cwnd_cnt;           /* cwnd cnt in congestion avoidance */




 185         uint32_t tcp_naglim;            /* Tunable nagle limit */
 186         uint32_t        tcp_valid_bits;
 187 #define TCP_ISS_VALID   0x1     /* Is the tcp_iss seq num active? */
 188 #define TCP_FSS_VALID   0x2     /* Is the tcp_fss seq num active? */
 189 #define TCP_URG_VALID   0x4     /* Is the tcp_urg seq num active? */
 190 #define TCP_OFO_FIN_VALID 0x8   /* Has TCP received an out of order FIN? */
 191 


 192         timeout_id_t    tcp_timer_tid;  /* Control block for timer service */
 193         uchar_t tcp_timer_backoff;      /* Backoff shift count. */
 194         int64_t tcp_last_recv_time;     /* Last time we receive a segment. */
 195         uint32_t tcp_init_cwnd;         /* Initial cwnd (start/restart) */
 196 
 197         /* Following manipulated by TCP under squeue protection */
 198         uint32_t
 199                 tcp_urp_last_valid : 1, /* Is tcp_urp_last valid? */
 200                 tcp_hard_binding : 1,   /* TCP_DETACHED_NONEAGER */
 201                 tcp_fin_acked : 1,      /* Has our FIN been acked? */
 202                 tcp_fin_rcvd : 1,       /* Have we seen a FIN? */
 203 
 204                 tcp_fin_sent : 1,       /* Have we sent our FIN yet? */
 205                 tcp_ordrel_done : 1,    /* Have we sent the ord_rel upstream? */
 206                 tcp_detached : 1,       /* If we're detached from a stream */
 207                 tcp_zero_win_probe: 1,  /* Zero win probing is in progress */
 208 
 209                 tcp_loopback: 1,        /* src and dst are the same machine */
 210                 tcp_localnet: 1,        /* src and dst are on the same subnet */
 211                 tcp_syn_defense: 1,     /* For defense against SYN attack */


 258 
 259 #define tcp_pipe                tcp_sack_info.tcp_pipe
 260 #define tcp_fack                tcp_sack_info.tcp_fack
 261 #define tcp_sack_snxt           tcp_sack_info.tcp_sack_snxt
 262 #define tcp_max_sack_blk        tcp_sack_info.tcp_max_sack_blk
 263 #define tcp_num_sack_blk        tcp_sack_info.tcp_num_sack_blk
 264 #define tcp_sack_list           tcp_sack_info.tcp_sack_list
 265 #define tcp_num_notsack_blk     tcp_sack_info.tcp_num_notsack_blk
 266 #define tcp_cnt_notsack_list    tcp_sack_info.tcp_cnt_notsack_list
 267 #define tcp_notsack_list        tcp_sack_info.tcp_notsack_list
 268 
 269         mblk_t  *tcp_rcv_list;          /* Queued until push, urgent data, */
 270         mblk_t  *tcp_rcv_last_head;     /* optdata, or the count exceeds */
 271         mblk_t  *tcp_rcv_last_tail;     /* tcp_rcv_push_wait. */
 272         uint32_t tcp_rcv_cnt;           /* tcp_rcv_list is b_next chain. */
 273 
 274         uint32_t tcp_cwnd_ssthresh;     /* Congestion window */
 275         uint32_t tcp_cwnd_max;
 276         uint32_t tcp_csuna;             /* Clear (no rexmits in window) suna */
 277 
 278         hrtime_t tcp_rtt_sum;           /* Round trip sum */
 279         uint32_t tcp_rtt_cnt;           /* Round trip count (non_dup ACKs) */
 280         hrtime_t tcp_rtt_sa;            /* Round trip smoothed average */
 281         hrtime_t tcp_rtt_sd;            /* Round trip smoothed deviation */
 282         uint32_t tcp_rtt_update;        /* Round trip update(s) */
 283         clock_t tcp_ms_we_have_waited;  /* Total retrans time */
 284 
 285         uint32_t tcp_swl1;              /* These help us avoid using stale */
 286         uint32_t tcp_swl2;              /*  packets to update state */
 287 
 288         uint32_t tcp_rack;              /* Seq # we have acked */
 289         uint32_t tcp_rack_cnt;          /* # of segs we have deferred ack */
 290         uint32_t tcp_rack_cur_max;      /* # of segs we may defer ack for now */
 291         uint32_t tcp_rack_abs_max;      /* # of segs we may defer ack ever */
 292         timeout_id_t    tcp_ack_tid;    /* Delayed ACK timer ID */
 293         timeout_id_t    tcp_push_tid;   /* Push timer ID */
 294 
 295         uint32_t tcp_max_swnd;          /* Maximum swnd we have seen */
 296 
 297         struct tcp_s *tcp_listener;     /* Our listener */
 298 
 299         uint32_t tcp_irs;               /* Initial recv seq num */


 471          * Socket generation number which is bumped when a connection attempt
 472          * is initiated. Its main purpose is to ensure that the socket does not
 473          * miss the asynchronous connected/disconnected notification.
 474          */
 475         sock_connid_t   tcp_connid;
 476 
 477         /* mblk_t used to enter TCP's squeue from the service routine. */
 478         mblk_t          *tcp_rsrv_mp;
 479         /* Mutex for accessing tcp_rsrv_mp */
 480         kmutex_t        tcp_rsrv_mp_lock;
 481 
 482         /* For connection counting. */
 483         struct tcp_listen_cnt_s *tcp_listen_cnt;
 484 
 485         /* Segment reassembly timer. */
 486         timeout_id_t            tcp_reass_tid;
 487 
 488         /* FIN-WAIT-2 flush timeout */
 489         uint32_t                tcp_fin_wait_2_flush_interval;
 490 
 491         tcp_conn_stats_t        tcp_cs;
 492 
 493 #ifdef DEBUG
 494         pc_t                    tcmp_stk[15];
 495 #endif
 496 } tcp_t;
 497 
 498 #ifdef DEBUG
 499 #define TCP_DEBUG_GETPCSTACK(buffer, depth)     ((void) getpcstack(buffer, \
 500                                                     depth))
 501 #else
 502 #define TCP_DEBUG_GETPCSTACK(buffer, depth)
 503 #endif
 504 
 505 extern void     tcp_conn_reclaim(void *);
 506 extern void     tcp_free(tcp_t *tcp);
 507 extern void     tcp_ddi_g_init(void);
 508 extern void     tcp_ddi_g_destroy(void);
 509 extern void     *tcp_get_conn(void *arg, tcp_stack_t *);
 510 extern mblk_t   *tcp_snmp_get(queue_t *, mblk_t *, boolean_t);
 511 extern int      tcp_snmp_set(queue_t *, int, int, uchar_t *, int len);
 512