tcp sock struct 注释分析

struct tcp_sock {
/* inet_connection_sock has to be the first member of tcp_sock */
struct inet_connection_sock inet_conn;
//tcp头部长度   
u16 tcp_header_len; /* Bytes of tcp header to send */ 

// 分段数据包的数量  
u16 xmit_size_goal_segs; /* Goal for segmenting output packets */


/*
 * Header prediction flags
 * 0x5?10 << 16 + snd_wnd in net byte order
 */
  // 头部预置位(用于检测头部标识位处理ACK和PUSH之外还有没有其他位,从而判断是不是可以使用快速路径处理数据
__be32 pred_flags;


/*
 * 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.
 */
  /*接收下个包的序列号seq, 当一个数据包来就能计算出下个数据报的SEQ*/
  u32 rcv_nxt; /* What we want to receive next */


// 没还有读出的数据的头
u32 copied_seq; /* Head of yet unread data */


/*当接收到一个数据包就能计算出下个过来的数据的SEQ, 当这个数据包回复ack 后就更新rcv_wup =rcv_nxt*/
u32 rcv_wup; /* rcv_nxt on last window update sent */


/*下次准备发送的数据的序列号值, 对于发送端发送数据以后, 就知道下次需要发送数据的序号*/
  u32 snd_nxt; /* Next sequence we send */


/*接受到数据包,就知道本地要发送的数据包SEQ , 等于snd_nxt=acked_req, 当回复该数据包以后,就 snd_una=snd_nxt*/
// 对于发出的数据,都需要对方的ACK,这里标示当前需要被确认的第一个字节  
u32 snd_una; /* First byte we want an ack for */


// 最近发送的小数据包的最后一个字节
  u32 snd_sml; /* Last byte of the most recently transmitted small packet */


// 最后一次接收到ACK的时间戳
u32 rcv_tstamp; /* timestamp of last received ACK (for keepalives) */

// 最后一次发送数据包时间戳 
u32 lsndtime; /* timestamp of last sent data packet (for restart window) */


/* Data for direct copy to user */



// 注意下面这个ucopy:就是将用户数据从skb中拿出来放进去,然后传给应用进程!!!   
struct {
struct sk_buff_head prequeue; // 预处理队列  
struct task_struct *task; // 预处理进程 
struct iovec *iov; // 用户程序(应用程序)接收数据的缓冲区
int memory; // 用于预处理计数
int len;  // 预处理长度
#ifdef CONFIG_NET_DMA
/* members for async copy */
struct dma_chan *dma_chan;
int wakeup;
struct dma_pinned_list *pinned_list;
dma_cookie_t dma_cookie;
#endif
} ucopy;


/*TCP window 发送窗口有变化请求的 tcp tcphdr seq 的值*/
u32 snd_wl1; /* Sequence for window update */

// TCP window 发送窗口值根据对方tcp hdr window 值决定, ,WINDOW 值 乘以 SYN options 中的 window scale shift count 2n 次方
u32 snd_wnd; /* The window we expect to receive */

//记录对方最大的发送 window 窗口值 
u32 max_window; /* Maximal window ever seen from peer */


// 最长报文大小默认536, 与对方协商一般为1460 = 1500-20-20
u32 mss_cache; /* Cached effective mss, not including SACKS */


// 对外公布的最大的窗口
u32 window_clamp; /* Maximal window to advertise */
// 当前窗口值  
u32 rcv_ssthresh; /* Current window clamp */


u32 frto_highmark; /* snd_nxt when RTO occurred */


// 对外公布的MSS  
u16 advmss; /* Advertised MSS */
u8 frto_counter; /* Number of new acks after RTO */
u8 nonagle; /* Disable Nagle algorithm?             */


/* RTT measurement */
u32 srtt; /* smoothed round trip time << 3 */
u32 mdev; /* medium deviation 中偏差*/ 
u32 mdev_max; /* maximal mdev for the last rtt period */
u32 rttvar; /* smoothed mdev_max */



/*指明那个数据和请求更新rtt 时间*/
u32 rtt_seq; /* sequence number to update rttvar */

/* 已发送且还没被ACK的数据包个数 */


u32 packets_out; /* Packets which are "in flight" */


/* 重传且未未被ACK的数据包个数 */
u32 retrans_out; /* Retransmitted packets out */


u16 urg_data; /* Saved octet of OOB data and control flags */
u8 ecn_flags; /* ECN status bits. */
u8 reordering; /* Packet reordering metric. */
u32 snd_up; /* Urgent pointer */


u8 keepalive_probes; /* num of allowed keep alive probes */
/*
 *      Options received (usually on last packet, some only on SYN packets).
 */
struct tcp_options_received rx_opt;


/*
 * Slow start and congestion control (see also Nagle, and Karn & Partridge)
 */
/*// 慢启动的开始大小 /// 初始化值2147483647(0x7fffffff) ,网络很好的情况下,一般不会变*/
  u32 snd_ssthresh; /* Slow start size threshold */
// 发送阻塞窗口 
  u32 snd_cwnd; /* Sending congestion window */
// 线性增长计数器(为了窗口的扩大) 
u32 snd_cwnd_cnt; /* Linear increase counter */

/*snd_cwnd_clamp:4294967295(0xffffffff) 拥塞窗口最大值, snd cwnd 不能超过该值*/
// snd_cwnd值不可以超过这个门限  
u32 snd_cwnd_clamp; /* Do not allow snd_cwnd to grow above this */

u32 snd_cwnd_used; /*已经被发送数据占用的窗口数目*/
u32 snd_cwnd_stamp; /*拥塞窗口变化的时间*/

// 当前接收窗口  
  u32 rcv_wnd; /* Current receiver window */


// tcp发送buf中数据的尾部
u32 write_seq; /* Tail(+1) of data held in tcp send buffer */
u32 pushed_seq; /* Last pushed seq, required to talk to windows */


/* 丢失的数据包个数,这是个猜测值 */
u32 lost_out; /* Lost packets */


/* 被SACKED的数据包个数 */
u32 sacked_out; /* SACK'd packets */
u32 fackets_out; /* FACK'd packets */
u32 tso_deferred;
u32 bytes_acked; /* Appropriate Byte Counting - RFC3465 */


/* 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_head out_of_order_queue; /* Out of order segments go here */


/* SACKs data, these 2 need to be together (see tcp_build_and_update_options) */
struct tcp_sack_block duplicate_sack[1]; /* D-SACK block */
struct tcp_sack_block selective_acks[4]; /* The SACKS themselves*/


struct tcp_sack_block recv_sack_cache[4];


struct sk_buff *highest_sack;   /* highest skb with SACK received
* (validity guaranteed only if
* sacked_out > 0)
*/


int     lost_cnt_hint;
u32     retransmit_high; /* L-bits may be on up to this seqno */


u32 lost_retrans_low; /* Sent seq after any rxmit (lowest) */


u32 prior_ssthresh; /* ssthresh saved at recovery start */
u32 high_seq; /* snd_nxt at onset of congestion */


u32 retrans_stamp; /* Timestamp of the last retransmit,
* also used in SYN-SENT to remember stamp of
* the first SYN. */
u32 undo_marker; /* tracking retrans started here. */
int undo_retrans; /* number of undoable retransmissions. */
u32 total_retrans; /* Total retransmits for entire connection */


u32 urg_seq; /* Seq of received urgent pointer */
unsigned int keepalive_time;  /* time before keep alive takes place */
unsigned int keepalive_intvl;  /* time interval between keep alive probes */


int linger2;


/* Receiver side RTT estimation */
struct {
u32 rtt;
u32 seq;
u32 time;
} rcv_rtt_est;  /* 用于接收端的RTT测量*/  


/* Receiver queue space */
struct {
int space;  /* 表示当前接收缓存的大小(只包括应用层数据,单位为字节)。?/
u32 seq;
u32 time;
} rcvq_space; /* 用于调整接收缓冲区和接收窗口*/


//sk->sk_rcvbuf表示当前接收缓存的大小(包括应用层数据、
//TCP协议头、sk_buff和skb_shared_info结构,tcp_adv_win_scale微调,单位为字节)。


/* TCP-specific MTU probe information. */
struct {
u32  probe_seq_start;
u32  probe_seq_end;
} mtu_probe;


#ifdef CONFIG_TCP_MD5SIG
/* TCP AF-Specific parts; only used by MD5 Signature support so far */
const struct tcp_sock_af_ops *af_specific;


/* TCP MD5 Signature Option information */
struct tcp_md5sig_info *md5sig_info;
#endif


#ifndef __GENKSYMS__
u8  thin_lto    : 1,/* Use linear timeouts for thin streams */
thin_dupack : 1,/* Fast retransmit on first dupack      */
unused      : 6;


u32 prior_cwnd; /* Congestion window at start of Recovery. */
u32 prr_delivered;  /* Number of newly delivered packets to
* receiver in Recovery. */
u32 prr_out;    /* Total number of pkts sent during Recovery. */
#endif


};
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值