ELEC3506

Topics

Transport LayerLecture 7 PDF15 min

TCP connection establishment and termination

The three-way handshake that opens a TCP connection, what each segment in it carries, and the FIN-based handshake that closes one down.

By the end of this page you should be able to

  • Name the three phases of connection-oriented TCP transmission
  • Describe each step of the three-way handshake for connection establishment, including what each segment carries
  • State what rwnd is and where it is first communicated
  • Say which flag marks graceful connection termination and where it appears

The idea

The previous topic covered what a TCP segment looks like once a connection exists. Before any of that data can flow, both sides have to agree the connection is open — and once they are done, both sides have to agree it is closed. TCP handles both with the same basic idea: a three-step exchange.

How it works

Three phases

Connection-oriented transmission in TCP requires three phases:

  1. Connection establishment
  2. Data transfer
  3. Connection termination

Connection establishment is called three-way handshaking. Once a connection is established, data may flow back and forth in both directions until the connection is closed.

How it works

The three-way handshake

  1. Client sends SYN to server, with no data — signalling that it is ready for a connection.
  2. Server responds with SYN-ACK, with no data. This single segment does three things: it acknowledges the client’s sequence number, it sends the server’s own initial sequence number (ISN), and it includes the server’s received window (rwnd) for flow control.
  3. Client sends ACK, which may or may not include data, acknowledging the server’s sequence number.

Where marks get lost

Not every handshake segment is data-free

The first two steps — SYN and SYN-ACK — carry no data, but the lecture is explicit that the client’s final ACK may include data. Treating all three handshake segments as necessarily empty is a common mistake.

How it works

rwnd

rwnd is the received window of the client or server, used for flow control. It first appears in the server’s SYN-ACK during the handshake. What rwnd actually constrains, and how it is calculated, is covered in the next topic.

How it works

Data transfer

Once the connection is up, 2,000 data bytes might be sent as two segments, or as a single segment — segment sizes are not fixed. The PSH flag indicates a data transmission from the client.

Aside

The slides’ complete sequence diagram for data transfer — showing SYN, ACK and PSH flags alongside actual data payloads step by step — did not survive extraction. Only the points above are stated directly in the source.

How it works

Terminating connections

Termination uses a handshake similar to establishment, but with FIN flags in place of SYN. The FIN flag is sent together with the last data segment, signalling there is nothing further to transmit.

Aside

The slides’ complete state machine diagram for termination — the sequence of FIN and ACK segments each side sends — did not survive extraction. This page states only that FIN accompanies the last data segment, as the source gives it, without reconstructing the full close-down sequence.

In the exam

  • Name all three phases in order: establishment, data transfer, termination.
  • Know what each handshake step carries, not just “SYN, SYN-ACK, ACK” as labels — step 2 alone does three jobs at once (ack, ISN, rwnd).
  • The final ACK may carry data. Only the first two steps are stated as data-free.
  • FIN accompanies the last data segment during termination — it is not a separate, contentless close request.

Check yourself

  • Three phases: connection establishment (three-way handshake), data transfer, connection termination.
  • SYN (no data) → SYN-ACK (acknowledges client, gives server’s ISN and rwnd, no data) → ACK (acknowledges server, data optional).
  • rwnd is introduced in the SYN-ACK step, for flow control detailed next.
  • Termination mirrors establishment’s handshake shape but uses FIN, sent with the last data segment.

Check yourself

  1. What are TCP's three phases of connection-oriented transmission, in order?
  2. In the three-way handshake, what does the server's SYN-ACK segment carry?
  3. Can the client's final ACK in the three-way handshake carry application data?
  4. Where is rwnd first communicated in a TCP connection?
  5. What flag does TCP use to close a connection, and when is it sent?