简体   繁体   中英

TCP sequence and acknowledgment numbers | do these numbers matter during TCP handshake

I have made a simple program in C.

Currenty I am trying to establish TCP handshake between server and client.

  1. So when I recieve [SYN] flag then I respond with [SYN+ACK] flags (along with any sequence number, so I am choosing it as zero) and any ACK number

  2. And in code when I receive in server ACK flag from client in TCP handshake's final packet I send ACK flag along with my own chosen sequence number (any number) and ACK numebr = one incremented of received SYC packet's sequence number because no data has been transmitted from server.

But I am not getting any ACK packet. my client is keep sending SYN packets and my server keep responding with Syn +ACK packet.

I like to know are sequence numbers and acknowledgement number during TCP handshake process are irreverent so I can focus on other fields which may be why my client ignoring my SYN responded SYC+ACK packet like IP and tcp checksum. Or is there anything wrong with my sequence and acknowlegement number handling first

In addition I am using TUN device in Linux that I created from server program

TCP sequence and acknowledgement numbers are absolutely NOT irrelevant during handshake (or any time in TCP connection). In fact, TCP handshake is there so that the server and the client can learn each other's sequence numbers. Your packets are ignored because ACKs do not match.

The ACK number in SYNACK packet is the sequence number in first SYN + 1. And the ACK number in last ACK packet is the seq. in SYNACK packet + 1.

In addition to the standard, linked by @Barmar, you can use this picture ( source )

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM