tcp_sock结构分析
位置:include/linux/tcp.h
基础机构
struct tcp_sock {
/* inet_connection_sock has to be the first member of tcp_sock */
struct inet_connection_sock inet_conn;
u16 tcp_header_len; /* Bytes of tcp header to send */
u16 gso_segs; /* Max number of segs per GSO packet */
/*
* Header prediction flags
* 0x5?10 << 16 + snd_wnd in net byte order
* 预判标志,判定是否走快速处理路径
*/
__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.
*/
u32 rcv_nxt; /* What we want to receive next 下一个期望收到的序号 */
u32 copied_seq; /* Head of yet unread data,未读数据开头的序列号 */
u32 rcv_wup; /* rcv_nxt on last window update sent,窗口更新就是发送ACK,ACK序号有新的变化(snd_una会移动)。发送ACK后就更新成rcv_nxt */
u32 snd_nxt; /* Next sequence we send */
u32 snd_una; /* First byte we want an ack for */
u32 snd_sml; /* Last byte of the most recently transmitted small packet */
u32 rcv_tstamp; /* timestamp of last received ACK (for keepalives) */
u32 lsndtime; /* timestamp of last sent data packet (for restart window) */
u32 tsoffset; /* timestamp offset */
struct list_head tsq_node; /* anchor in tsq_tasklet.head list */
unsigned long tsq_flags;
/* Data for direct copy to user */
struct {
struct sk_buff_head prequeue;
struct task_struct *task;
struct msghdr *msg;
int memory;
int len;
} ucopy;
u32 snd_wl1; /* Sequence for window update窗口更新的ACK序号 */
u32 snd_wnd; /* The window we expect to receive,接到对方ACK后,tcphdr中window字段 */
u32 max_window; /* Maximal window ever seen from peer,snd_wnd的最大值 */
u32 mss_cache; /* Cached effective mss, not including SACKS */
u32 window_clamp; /* Maximal window to advertise */
u32 rcv_ssthresh; /* Current window clamp