TCP/IP研究-TCB

Posted e-shannon

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了TCP/IP研究-TCB相关的知识,希望对你有一定的参考价值。

TCB结构中各变量统计

 

Date

Author

Description

2006-11-20

Kevin

First Draft

 

 

 

 

 

 

 

 

 

 

 

TCB结构取自kernel 2.6.16.27,

RX                  : 变量只被”接收”模块访问

TX                      : 变量只被”发送”模块访问

Timer                : 变量只被”超时处理”模块访问

RX, TX               : 变量只被”接收/发送”模块访问

RX, Timer             : 变量只被”接收/超时处理”模块访问

TX, Timer             : 变量只被”发送/超时处理”模块访问

RX, TX, Timer         : 变量只被”接收/发送/超时处理”模块访问

 

 

struct tcp_sock {

       /* inet_connection_sock has to be the first member of tcp_sock */

       struct inet_connection_sock   inet_conn;

       int   tcp_header_len;      /* Bytes of tcp header to send              */                  // RX, TX

 

/*

 *    Header prediction flags

 *    0x5?10 << 16 + snd_wnd in net byte order

 */

       __u32     pred_flags;                                                                           // RX, TX

 

/*

 *    RFC793 variables by their proper names. This means you can

 *    read the code and the spec side by side (and laugh ...)

 *    See RFC793 and RFC1122. The RFC writes these in capitals.

 */

      __u32     rcv_nxt;  /* What we want to receive next   */                                            // RX, TX

      __u32     snd_nxt;  /* Next sequence we send             */                                                     // RX, TX

 

      __u32     snd_una;  /* First byte we want an ack for    */                                                     // RX, TX

      __u32     snd_sml;  /* Last byte of the most recently transmitted small packet */                         // TX

       __u32     rcv_tstamp;     /* timestamp of last received ACK (for keepalives) */                      // Timer

       __u32     lsndtime; /* timestamp of last sent data packet (for restart window) */             // RX, TX, Timer

 

       /* Data for direct copy to user */

       struct {

              struct sk_buff_head       prequeue;

              struct task_struct    *task;

              struct iovec            *iov;

              int                 memory;

              int                 len;

       } ucopy;                                                                                                                         // RX, Timer

 

       __u32     snd_wl1; /* Sequence for window update           */                                              // RX

       __u32     snd_wnd; /* The window we expect to receive     */                                              // RX, TX, Timer

       __u32     max_window; /* Maximal window ever seen from peer      */                                // RX, TX

       __u32     mss_cache;     /* Cached effective mss, not including SACKS */                           // RX, TX

       __u16     xmit_size_goal;      /* Goal for segmenting output packets  */                           // TX

       /* XXX Two bytes hole, try to pack */

 

       __u32     window_clamp;      /* Maximal window to advertise          */                   // RX, TX

       __u32     rcv_ssthresh;   /* Current window clamp                    */                       // RX, TX

 

       __u32     frto_highmark;       /* snd_nxt when RTO occurred */                         // RX

       __u8       reordering;     /* Packet reordering metric.         */                                              // RX

       __u8       frto_counter;   /* Number of new acks after RTO */                                              // RX

       __u8       nonagle;  /* Disable Nagle algorithm?             */                                     // TX

       __u8       keepalive_probes; /* num of allowed keep alive probes      */                  // Timer

 

/* RTT measurement */

       __u32     srtt;         /* smoothed round trip time << 3  */                                                            // RX, TX

       __u32     mdev;            /* medium deviation                    */                                                     // RX

       __u32     mdev_max;     /* maximal mdev for the last rtt period */                                        // RX

       __u32     rttvar;            /* smoothed mdev_max               */                                                     // RX

       __u32     rtt_seq;    /* sequence number to update rttvar     */                                                  // RX

 

       __u32     packets_out;    /* Packets which are "in flight"     */                                               // RX, TX, Timer

       __u32     left_out;  /* Packets which leaved network   */                                                            // RX, TX

       __u32     retrans_out;    /* Retransmitted packets out         */                                                  // RX, TX

/*

 *      Options received (usually on last packet, some only on SYN packets).

 */

       struct tcp_options_received rx_opt;                                                                                          // RX, TX

 

/*

 *    Slow start and congestion control (see also Nagle, and Karn & Partridge)

 */

      __u32     snd_ssthresh;   /* Slow start size threshold           */                              // RX, TX

      __u32     snd_cwnd;      /* Sending congestion window             */                                              // RX, TX

      __u16     snd_cwnd_cnt;       /* Linear increase counter             */                          // RX

       __u16     snd_cwnd_clamp; /* Do not allow snd_cwnd to grow above this */                  // RX

       __u32     snd_cwnd_used;                                                                                                    // RX, TX

       __u32     snd_cwnd_stamp;                                                          // RX, TX

 

       struct sk_buff_head       out_of_order_queue; /* Out of order segments go here */

 

      __u32     rcv_wnd; /* Current receiver window          */                                  // RX, TX

       __u32     rcv_wup; /* rcv_nxt on last window update sent  */                              // RX, TX

       __u32     write_seq;       /* Tail(+1) of data held in tcp send buffer */                         // RX, TX

       __u32     pushed_seq;    /* Last pushed seq, required to talk to windows */                    // TX

       __u32     copied_seq;     /* Head of yet unread data            */                              // RX, TX

 

/*    SACKs data    */

       struct tcp_sack_block duplicate_sack[1]; /* D-SACK block */                              // RX, TX

       struct tcp_sack_block selective_acks[4]; /* The SACKS themselves*/                        // RX, TX

 

       struct tcp_sack_block recv_sack_cache[4];                                              // RX

 

       /* from STCP, retrans queue hinting */

       struct sk_buff* lost_skb_hint;

 

       struct sk_buff *scoreboard_skb_hint;

       struct sk_buff *retransmit_skb_hint;

       struct sk_buff *forward_skb_hint;

       struct sk_buff *fastpath_skb_hint;

 

       int     fastpath_cnt_hint;                                                          // RX

       int     lost_cnt_hint;                                                              // RX

       int     retransmit_cnt_hint;                                                         // TX

       int     forward_cnt_hint;                                                           // TX

 

       __u16     advmss;          /* Advertised MSS               */                                   // RX, TX

       __u16     prior_ssthresh; /* ssthresh saved at recovery start */                                // RX, TX

       __u32     lost_out;  /* Lost packets                     */                                        // RX, TX

       __u32     sacked_out;     /* SACK‘d packets                */                                    // RX, TX

       __u32     fackets_out;    /* FACK‘d packets                */                                    // RX, TX

       __u32     high_seq; /* snd_nxt at onset of congestion   */                                    // RX, TX

 

       __u32     retrans_stamp; /* Timestamp of the last retransmit,                     // RX, TX

                             * also used in SYN-SENT to remember stamp of

                             * the first SYN. */

       __u32     undo_marker; /* tracking retrans started here. */                       // RX, TX

       int   undo_retrans;  /* number of undoable retransmissions. */                    // RX, TX

       __u32     urg_seq;  /* Seq of received urgent pointer */                          // RX

       __u16     urg_data; /* Saved octet of OOB data and control flags */                // RX

       __u8       urg_mode;      /* In urgent mode          */                                                // RX, TX

       __u8       ecn_flags;       /* ECN status bits.                */                         // RX

       __u32     snd_up;          /* Urgent pointer           */                                        // RX, TX

 

       __u32     total_retrans;   /* Total retransmits for entire connection */

       __u32     bytes_acked;   /* Appropriate Byte Counting - RFC3465 */

 

       unsigned int           keepalive_time;        /* time before keep alive takes place */     // RX, Timer

       unsigned int           keepalive_intvl;  /* time interval between keep alive probes */    // Timer

       int                 linger2;                                                     // RX, Timer

 

       unsigned long last_synq_overflow;

 

/* Receiver side RTT estimation */

       struct {

              __u32     rtt;

              __u32     seq;

              __u32     time;

       } rcv_rtt_est;                                                                         // RX

 

/* Receiver queue space */

       struct {

              int   space;

              __u32     seq;

              __u32     time;

       } rcvq_space;                                                                                  // RX

      

}

 

 

可见,TCB结构中大多数变量都会被”发送”,”接收”模块同时修改, 不可能以下理想情况: ”发送”模块访问一部分标量,”接收”模块

访问一部分变量,互不冲突.

 

所以, 在设计中必须解决多TCB结构的竞争访问问题.

以上是关于TCP/IP研究-TCB的主要内容,如果未能解决你的问题,请参考以下文章

搞明白 WebSocket 与 TCP/IP

OSI参考模型与 TCP/IP参考模型

TCP/IP体系结构

TCP/IP详解阅读笔记:TCP协议

TCP/IP协议参考模型

TCP/IP中你不得不知的十大秘密