tcp头部如下图
依次是
源端口号:16位
目标端口号:16位
seq号:32位, seq, 这个报文对应的序列号。
ack号:32位, ack_seq, 告诉对端自己下一个接收的新包的开始序列号。
首部长度(doff):4位,最大值为15。单位为4字节,即首部最大长度为60字节.
保留字段(res1):4位
标志位:
CWR: Congestion Window Reduced (the sender reduced its sending rate)
ECE: ECN Echo (the sender received an earlier congestion notification)
URG: Urgent (the Urgent Pointer field is valid—rarely used)
ACK: Acknowledgment (the Acknowledgment Number field is valid—always on after a
connection is established)
PSH: Push (the receiver should pass this data to the application as soon as possible—not
reliably implemented or used)
RST: Reset the connection (connection abort, usually because of an error)
SYN: Synchronize sequence numbers to initiate a connection;
FIN: The sender of the segment is finished sending data to its peer;
窗口大小(windown):16位,最大值为65535。单位为字节,即最大窗口为65535字节
检验和(check):16位。检验和覆盖了整个tcp报文,是一个强制性字段,一定是由发送端计算和存储,并由接收端进行验证。
紧急指针(urg_ptr):16位。当标志位URG为1时,紧急指针表示一个正的偏移量,加上seq表示紧急数据的最后一个字节。
linux内核代码定义如下