Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is a FIN+ACK message in TCP?

Tags:

networking

tcp

I'm working on implementing TCP myself for a class project, and there's one detail I can't seem to understand. What is a FIN+ACK message? In the diagram I included here, receipt of a FIN+ACK will take a host from the FIN_WAIT_1 state to the TIME_WAIT state. Yet, NO state transition in the entire diagram sends a FIN+ACK. So how could a FIN+ACK ever be received if nothing is ever sending it?

enter image description here

like image 393
Christopher Shroba Avatar asked May 05 '15 02:05

Christopher Shroba


People also ask

What is FIN ACK Wireshark?

A FIN is used to indicate the termination of a TCP session. The ACK bit is used to indicate that that the ACK number in the TCP header is acknowledging data.

Why do fins ACK instead of fins?

ACK just acknowledges the receipt of data (e.g. received everything up to given sequence number) packets will be re-send until one receives an ACK for them. FIN just says that the side sending the FIN will not send any more data. It gives no information if it will still receive data.

What is FIN SYN ACK?

SYN: a synchronization message typically used to request a connection between a client and a server. ACK: an acknowledgment message employed to declare the receipt of a particular message. FIN: a message that triggers a graceful connection termination between a client and a server.

How does TCP FIN work?

At the protocol level, a disconnect request is conveyed in the TCP FIN packet. Upon receiving a close request from the TCP user. The TCP layer stops sending new packets and waits for the pending TCP acks. Once all pending packets are transmitted successfully, the sender sends the TCP FIN to the receiver.


2 Answers

When an application calls close it moves to FIN_WAIT_1

From FIN_WAIT_1 multiple things can happen:

  1. Application receives ACK:

    This means that the peer as acknowledged the last sent data packet. Local application moves to FIN_WAIT_2

  2. Application receives FIN:

    This indicates that peer has called close. And local application should acknowledge that. Hence ACK goes out to peer. Local application moves to CLOSING

  3. Application receives FIN + ACK:

    What FIN+ACK as you put it means is that the peer has called close as well as in the same TCP segment is acknowledging the data received last. Local application will acknowledge the FIN and this takes the state to TIME_WAIT.

like image 102
Prabhu Avatar answered Sep 25 '22 17:09

Prabhu


TCP is defined by more than just that state diagram, the basic specification can be found in RFC 793. One particular statement is as follows (page 15, description of ACK field):

Once a connection is established this is always sent.

So basically this says an ACK must always be present after the initial three-way handshake, including during the four-way disconnect phase. There are subsequently only 2 messages that do not include an ACK:

  • The very first SYN as there is nothing to ACK
  • A RST as this usually means the connection state is non-existent or so messed up that an ACK does not make sense.

So to answer your question: in that diagram, whenever a FIN is sent, the ACK flag will also be set and an ACK nr will be present, even though it is not explicitly stated.

like image 44
KillianDS Avatar answered Sep 23 '22 17:09

KillianDS