Mic_chen

It is not the strongest of the species that survive, nor the most intelligent, but the one most responsive to change

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

 

http://blog.chinaunix.net/uid-20665441-id-305478.html

详细解释为:
先把TCP协议的序列号搞清楚:
1、开始C端随机生成初始sequence(C),发到S,flag为syn (eg.Seq(C)=0)
2、S端回应C端,也随机生成初始sequence(S) eg. Seq(S)=0,ack=sequence(C)+1,表示收到C端的连接请求,flag为syn+ack(eg. Seq(s)=0, ack=1)
3 、C端回应S端,ack=sequence(S)+1,表示收到S端的连接回应,flag为ack (eg. ack=1)

至此三次握手建立,此后双方的序列号变化为:
刚开始任一方(不分C或S)的sequence=sequence(握手时)+1
至于next sequence是wireshark自己加上去的,其值为 n_sequence=此次发送包的sequence+TCP层以上负载的数据长度.也就是下次发包时该方将会使用的sequence值
5、同理任一方的ack=收到的对方的sequence+其TCP层以上负载的数据长度,也就是期待对方下一次发包所使用的sequence值

 

注意:因为一个SYN将占用一个序号,所以要加1。

2021.10.6

 

posted on 2023-04-06 14:45  Mic_chen  阅读(49)  评论(0编辑  收藏  举报