TCP

Transmission Control Protocol (TCP/IP)

TCP header

Screenshot 2025-01-13 at 11.55.14 PM.png
- The sequence numbers change over the lifetime of the connection
- They changed based on how much data is sent.

Three-way Handshake

Pasted image 20250114000317.png

RST and FIN flags

In TCP (Transmission Control Protocol), the FIN and RST flags are used for managing the state of a connection:

  1. FIN (Finish):
    • Indicates that the sender has finished sending data and wants to gracefully close the connection.
    • When a device sends a FIN flag, it is signaling the end of data transmission, and the other device should acknowledge it by sending an ACK (Acknowledgment) back.
    • This is part of the four-way handshake for closing a TCP connection.
  2. RST (Reset):
    • Indicates that the connection should be immediately reset or aborted.
    • Typically used when there is an error, such as a non-existent port, or when a device wants to abruptly terminate the connection for some reason.
    • Unlike FIN, which is part of the graceful termination process, RST abruptly ends the connection without the normal handshakes.