当前位置: 技术问答>linux和unix
关于TCP数据结构
来源: 互联网 发布时间:2015-10-15
本文导语: 中,对tcp报文头格式指出顺序如下: 源端口 目的端口 序号 确认号 首部长度 保留未用 码元比特 窗口 校验和 紧急指针 选项(若有) 填充 数据 但是在linux中的 中,结构定义...
中,对tcp报文头格式指出顺序如下:
源端口 目的端口 序号 确认号
首部长度 保留未用 码元比特 窗口
校验和 紧急指针 选项(若有) 填充
数据
但是在linux中的 中,结构定义为:
struct tcphdr
{
u_int16_t source; //源端口
u_int16_t dest; //目的端口
u_int32_t seq; //序号
u_int32_t ack_seq; //确认号
# if __BYTE_ORDER == __LITTLE_ENDIAN
u_int16_t res1:4;
u_int16_t doff:4;
u_int16_t fin:1;
u_int16_t syn:1;
u_int16_t rst:1;
u_int16_t psh:1;
u_int16_t ack:1;
u_int16_t urg:1;
u_int16_t res2:2;
# elif __BYTE_ORDER == __BIG_ENDIAN
u_int16_t doff:4;
u_int16_t res1:4;
u_int16_t res2:2;
u_int16_t urg:1;
u_int16_t ack:1;
u_int16_t psh:1;
u_int16_t rst:1;
u_int16_t syn:1;
u_int16_t fin:1;
# else
# error "Adjust your defines"
# endif
u_int16_t window;
u_int16_t check;
u_int16_t urg_ptr;
};
字段共有16个(前面4个加上中间9个,还有最后3个)!
有没有高手告诉我doff,res1,res2,window,check,urg_ptr是什么意思啊?
源端口 目的端口 序号 确认号
首部长度 保留未用 码元比特 窗口
校验和 紧急指针 选项(若有) 填充
数据
但是在linux中的 中,结构定义为:
struct tcphdr
{
u_int16_t source; //源端口
u_int16_t dest; //目的端口
u_int32_t seq; //序号
u_int32_t ack_seq; //确认号
# if __BYTE_ORDER == __LITTLE_ENDIAN
u_int16_t res1:4;
u_int16_t doff:4;
u_int16_t fin:1;
u_int16_t syn:1;
u_int16_t rst:1;
u_int16_t psh:1;
u_int16_t ack:1;
u_int16_t urg:1;
u_int16_t res2:2;
# elif __BYTE_ORDER == __BIG_ENDIAN
u_int16_t doff:4;
u_int16_t res1:4;
u_int16_t res2:2;
u_int16_t urg:1;
u_int16_t ack:1;
u_int16_t psh:1;
u_int16_t rst:1;
u_int16_t syn:1;
u_int16_t fin:1;
# else
# error "Adjust your defines"
# endif
u_int16_t window;
u_int16_t check;
u_int16_t urg_ptr;
};
字段共有16个(前面4个加上中间9个,还有最后3个)!
有没有高手告诉我doff,res1,res2,window,check,urg_ptr是什么意思啊?
|
doff=首部长度
window=窗口
check=校验和
urg_ptr=紧急指针
window=窗口
check=校验和
urg_ptr=紧急指针