大网数据广告活动
服务器运维问答

Why the Sequence number in an ACK packet is incremented?

· 52CE 我爱测

I was wondering if there is any particular reason to increment the ACK sequence number instead of acknowledging the received sequence number. Why the RFC designed it this way? Actual: [SYN] SEQ=100 [SYN, ACK] Seq=300 Ack=101 [ACK…

问题原文

原帖链接 · L.S. · CC BY-SA 3.0

I was wondering if there is any particular reason to increment the ACK sequence number instead of acknowledging the received sequence number. Why the RFC designed it this way?

Actual:
[SYN] SEQ=100
[SYN, ACK] Seq=300 Ack=101
[ACK] Seq=101 Ack=301

Why not:
[SYN] Seq=100
[SYN/ACK] Seq=300 Ack=100
[ACK] Seq=101 Ack=300

Naturally it would make sense to acknowledge the sequence number you just received instead of the sequence number you received + 1?

已采纳解答

原帖链接 · Luca Gibelli · CC BY-SA 3.0

In TCP, the protocol keeps track of what has been sent by using a Sequence number. Effectively it's a counter of everything that was sent+1.

More details on https://www.rfc-editor.org/rfc/rfc793#section-3.3

ACK is incremented by 1 because the packet is carrying a SYN, it's not empty. SYNs contribute to incrementing the SEG.LEN, as explained in the rfc:

SEG.LEN = the number of octets occupied by the data in the segment (counting SYN and FIN)

Had the packet been empty and without SYN/FIN, the counter would have not been incremented.

This is also contemplated in the rfc where it states that the next sequence number to be sent must be greater or equal than the one indicated in the ACK:

A new acknowledgment (called an "acceptable ack"), is one for which the inequality below holds:

SND.UNA < SEG.ACK =< SND.NXT

where SND.UNA is the oldest unacknowledged sequence number and SND.NXT is the next sequence number to be sent.

By incrementing the seq. number the packet is basically asking the other party "I expect you to send me the first byte of data now"

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2018-03-27)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。