TCP Sequence Number

后端 未结 3 1080
囚心锁ツ
囚心锁ツ 2021-02-03 21:23

I\'m trying to understand how the sequence numbers of the TCP header are generated.

In some places I read that it is the \"index of the first byte in the packet\" (link

3条回答
  •  没有蜡笔的小新
    2021-02-03 22:17

    Each endpoint of a TCP connection establishes a starting sequence number for packets it sends, and sends this number in the SYN packet that it sends as part of establishing a connection.

    There is no requirement for either end to follow a particular procedure in choosing the starting sequence number. The operating system is free to use any mechanism it likes, but generally it's best if it chooses a random number, as this is more secure.

    From that starting point, each packet sent by either end contains two sequence numbers - one to specify where in the stream the packet is, and an ACK sequence number which signifies the number of bytes received. Both numbers are offset by the starting sequence number.

    Read all about it in Wikipedia of course - look for "sequence number" in that page to get all the gory details.

提交回复
热议问题