0
votes

I am trying to implement one tcp stack. Following steps I have followed:

  1. TCP open:

    a. Client sent 'SYN' with a initial sequence no "C" and Ack no as "0" to server.

    b. Server responded with SYN + ACK with seq no "S" and ack no "C+1".

    c. Client send ACK+PSH with sequence no "C+1" and ack no "S+1".

  2. TCP send and recv:

    a. Client will send the request for data with ACK flag and the data with seq no "C+1" and ack no "S+1"

    b. The sender will send gragment with seq no "S+1+data" in segment and receiver will send ACK with ack no "S+1+data" will continue till the FIN or RST is transmitted.

In my case during data transmission I am not getting few packets but I can see them on wireshark.

Is there any mechanism to check for out of order data and packet loss using sequence number and ack number and to get the packet back

1
Are you writing your own low level tcp or are you using the system functions for writing and receiving?HeadCode
its a low level tcpPawan

1 Answers

1
votes

If you receive a segment with a sequence number higher than the next sequence expected, you should resend the last ACK. This tells the sender that some of the segments were lost, and it should immediately retransmit all the segments that are waiting for acknowledgement.

A better solution would be to implement the Selective Acknowledgement option in RFC 2018. This will allow you to acknowledge the segments received out of order, and the sender will only retransmit the ones that were missed.