Certainly, let's dive into the details of how TCP connections are established and closed using TCP control flags:

TCP Control Flags and Their Purposes:

Untitled

When the value of each Control flags is set to one (1) :

  1. URG (Urgent): Indicates that the segment contains urgent data. Not widely adopted in modern networking.
  2. ACK (Acknowledgment): Acknowledges receipt of data. The acknowledgement number field should be examined if set to 1.
  3. PSH (Push): Requests the receiving end to push buffered data to the application immediately.
  4. RST (Reset): Used to reset a connection when issues with data recovery occur.
  5. SYN (Synchronize): Initiates the establishment of a TCP connection. Used to synchronize sequence numbers, to make sure the receiving end knows to examine the sequence number field.
  6. FIN (Finish): Indicates the sender has no more data to send and wishes to close the connection.

Establishing a TCP Connection (Three-Way Handshake):

Untitled

  1. Computer A (transmitter) sends a TCP segment to Computer B with the SYN flag set.
  2. Computer B (receiver) responds with a TCP segment with both the SYN and ACK flags set.
  3. Computer A responds with a TCP segment with only the ACK flag set.

Operating in Full Duplex:

Untitled

Closing a TCP Connection (Four-Way Handshake):