当前位置:网站首页>为什么TCP三次握手的时候ACK=Seq+1
为什么TCP三次握手的时候ACK=Seq+1
2022-07-27 10:57:00 【anlian523】
从Telnet协议讲起

这个例子来自《计算机网络自顶向下方法》第6版 3.5.2小节。
上图中,因为主机A发送了一个字符C给主机B,所以作为接收方B的反馈的ACK为42+1。
上图中,因为主机B发送了一个字符C给主机A,所以作为接收方A的反馈的ACK为79+1。
而在最后一次发送中,由于没有携带任何数据,实际上Seq = 43是没有意义。但由于这个固定字段总得放个值进去,所以放个Next Sequence Number到这里是最合适的。也就是说这次发送没有消耗掉序号。
有意义的只有ACK = 80,这样就告诉了主机B:我这边已经成功接受到了 起码序号为79且长度为1 的数据。
下一次的可能发送情况

如果下一次是主机A再发送数据,数据包的Seq还会是43,因为上一次主机A的发送并没有消耗掉序号(即Len = 0),所以主机A发送的数据包序号还是应该从43开始。
如果下一次是主机B再发送数据,数据包的ACK还会是43,因为上一次主机A的发送并没有消耗掉序号(即Len = 0),所以主机B还是期待对方从43开始的序号。
三次握手时的ACK
这是本机与百度之间的三次握手。
首先看前两个数据包,第一个数据包的Len = 0,但第二个数据包的ACK还是在Seq = 0的基础上加1了。这就很奇怪,因为按照上一章的逻辑,没有携带数据,那么ACK应该等于Seq的。
再看后两个数据包,同样的,第一个数据包的Len = 0,但第二个数据包的ACK还是在Seq = 0的基础上加1了。
解释
The server responds to the client with a sequence number of zero, as this is its first packet in this TCP session, and a relative acknowledgement number of 1. The acknowledgement number is set to 1 to indicate the receipt of the client’s SYN flag in packet #1.
Notice that the acknowledgement number has been increased by 1 although no payload data has yet been sent by the client. This is because the presence of the SYN or FIN flag in a received packet triggers an increase of 1 in the sequence. (This does not interfere with the accounting of payload data, because packets with the SYN or FIN flag set do not carry a payload.)
简而言之,接收方反馈的ACK之所以加1,是因为发送方包含了SYN标志位或FIN标志位。
也就是说,只要发送方包含了 SYN标志位或FIN标志位,即使没有包含数据,接收方也得认为 发送方消耗掉了一个序号。
另外,带有 SYN标志位或FIN标志位的报文段(在三次握手和四次挥手中),也是不允许携带数据的。
边栏推荐
- [shader realizes shake random shaking effect _shader effect Chapter 10]
- 局域网SDN硬核技术内幕 25 展望未来——RDMA(下)
- Maker harmony OS application development training notes 01
- 背包模型 AcWing 1024. 装箱问题
- Redis simple to use
- Remember not to copy your group work, students. Fortunately, you only passed two questions. Don't have an accident
- Solve importerror: cannot import name'abs'import tensorflow error
- Markdown editor syntax - setting of text color, size, font and background color (Reprint)
- C programming language (2nd Edition) -- Reading Notes -- 1.3
- 求组合数 AcWing 889. 满足条件的01序列
猜你喜欢

Basic use of cmake

The C programming language (2nd) -- Notes -- 1.6

Find the combinatorial number acwing 889. 01 sequence satisfying the condition

Moveit2 -- 2. Quick start of moveit in rviz

Longest ascending subsequence model acwing 272. longest common ascending subsequence

博弈论 AcWing 892. 台阶-Nim游戏

最长上升子序列模型 AcWing 1010. 拦截导弹

Force buckle - 10. Regular expression matching

【着色器实现Shake随机摇动效果_Shader效果第十篇】

求组合数 AcWing 889. 满足条件的01序列
随机推荐
CTF crypto RSA getting started
Markdown editor syntax - setting of text color, size, font and background color (Reprint)
349两个数组的交集和01两数之和
Gaussian elimination acwing 883. solving linear equations with Gaussian elimination
Game theory acwing 894. Split Nim game
Luogu p1896 non aggression
【Unity入门计划】CreatorKitFPS:第一人称射击3D小游戏
49字母异位分组和242有效的字母异位词
Luogu p3052 [usaco12mar]cows in a skyscraper G
Maker Hongmeng application development training notes 02
Caused by:org.gradle.api.internal. plugins . PluginApplicationException: Failed to apply plugin
(10) File contains
最长上升子序列模型 AcWing 1010. 拦截导弹
The difference between extern and static
Properties file
Digital triangle model acwing 1018. Minimum toll
Find the combination number acwing 886. find the combination number II
C programming language (2nd Edition) -- Reading Notes -- 1.5.1
Remember an experience of using canvas to make the banner streamer effect of Tencent cloud homepage
Moveit2 - 5. Scenario Planning