🔗

TCP Control Flags and Handshakes

Jul 14, 2025

Overview

This lecture explains the role of TCP in network communication, focusing on TCP control flags and the processes of establishing and closing TCP connections.

TCP vs. Lower Layer Protocols

  • TCP establishes connections and sends data in segments, unlike IP and Ethernet, which send individual packets.
  • Understanding TCP operations is essential for troubleshooting network traffic issues.

TCP Control Flags

  • TCP uses six control flags, each serving a specific purpose in connection management.
  • URG (Urgent): Indicates the segment is urgent and uses the urgent pointer field (rarely used).
  • ACK (Acknowledged): Signals that the acknowledgement number field should be checked.
  • PSH (Push): Tells the receiver to deliver buffered data to the application immediately.
  • RST (Reset): Indicates a failed connection recovery; requests to reset the connection.
  • SYN (Synchronize): Used to initiate a connection and synchronize sequence numbers.
  • FIN (Finish): Indicates no more data will be sent and the connection should be closed.

Establishing a TCP Connection (Three-Way Handshake)

  • Computer A sends a segment with the SYN flag to initiate a connection.
  • Computer B replies with a segment with both SYN and ACK flags set, acknowledging the request.
  • Computer A responds with a segment with the ACK flag set, confirming the acknowledgement.
  • This process is called the three-way handshake and establishes a full-duplex TCP connection.

Data Transfer and Acknowledgement

  • After the handshake, either device can send data, and each segment should be acknowledged with ACK.
  • Full duplex means both sides can send and receive data simultaneously.

Closing a TCP Connection (Four-Way Handshake)

  • The device wanting to close sends a segment with the FIN flag.
  • The other device responds with ACK, then sends its own FIN when ready to close.
  • The connection is fully closed after a final ACK from the first device.
  • TCP connections can theoretically stay open in simplex mode (one side closed), but this is rare.

Key Terms & Definitions

  • Segment — A single unit of data sent over a TCP connection.
  • TCP Control Flags — Bits in the TCP header used for managing connections (URG, ACK, PSH, RST, SYN, FIN).
  • Buffer — Temporary storage for data awaiting transfer or processing.
  • Full Duplex — Communication where both devices can send and receive data simultaneously.
  • Three-Way Handshake — The SYN, SYN-ACK, and ACK exchange used to establish a TCP connection.
  • Four-Way Handshake — The FIN and ACK exchange used to properly close a TCP connection.

Action Items / Next Steps

  • Review the definitions and functions of the six TCP control flags.
  • Practice diagramming the TCP three-way and four-way handshake processes.