Transport Layer (TCP and UDP)

Context: FIT1047_MOC · application-to-application communication — ports, segmentation, reliability · the layer that turns “packets may vanish” into “it always looks like a clean pipe”

Quick Revision

  • 🎯 Objective: transport identifies applications (ports), splits messages, and — in TCP — repairs the network’s unreliability via ARQ (seq/ack numbers + retransmit-on-no-ACK).
  • 📦 Core Components: TCP = connection-oriented + reliable (3-way open, 4-way close) · UDP = connectionless, compact, unreliable.
  • ⚡ Key Constraint: the two numbers per TCP packet — sequence = bytes I’ve sent so far, acknowledgement = bytes I’ve received — everything (handshakes, loss recovery) is arithmetic on these.

📝 Core

TCP (Transmission Control Protocol)

  • Connection-oriented ➔ a virtual circuit: to the application it’s a point-to-point full-duplex pipe; messages split into segments.
  • Reliable ➔ errors detected/corrected; segments reassembled in order. Used by HTTP, SMTP, IMAP, SSH.
  • ARQ (Automatic Repeat reQuest) ➔ data link discards bad frames and packets can vanish ⟹ receiver sends ACKs; sender retransmits anything unacknowledged within the timeout.
  • Open: 3-way handshake ➔ client SYN (random seq ) → server SYN,ACK (ack , random seq ) → client ACK (seq , ack ).
  • Close: 4-way handshake ➔ FIN → ACK → FIN → ACK (either side may start; FIN/ACK can combine into 3) — two FINs because full-duplex: each direction closes independently.
  • Tuning trade-offs ➔ send rate (too fast overloads receiver/path) and segment size (too big forces IP fragmentation and raises error odds).

UDP (User Datagram Protocol)

  • Connectionless ➔ each datagram independent; arrival, order, and acknowledgement all unguaranteed.
  • Compact ➔ ~8-byte header, minimal latency overhead — for short notifications, live video, VoIP, where a late retransmission is worthless anyway.

📊 Exam Execution Trace — lecture TCP session (seq | ack)

Client →← ServerPhase
SYNopen
SYN, ACKopen
ACKopen complete
“some data” · “more data” “thanks!“full-duplex data
ACK … FINclose begins
ACK · ACK · FIN exchange4-way close
Read it as: every ack = the other side’s seq + bytes received; gaps ⟹ retransmission.

⚖️ Core Decision Matrix

TCPUDP
connectionvirtual circuit (handshakes)none — independent datagrams
reliabilityARQ: ACKs, retransmit, reordernone
overheadheaders + handshakes + state~8-byte header
fitsweb, mail, SSH — completeness mattersstreaming, VoIP, notifications — timeliness matters

⚠️ Common Mistakes

  • 💡 Reliability lives HERE, not below ➔ the data link only discards bad frames; TCP is what retransmits — layer-attribution questions hinge on this.
  • 💡 Four-way close because full-duplex ➔ each direction carries its own FIN; “why not two messages?” is the standard exam probe.
  • 💡 UDP isn’t broken TCP ➔ for live media, retransmitted-late data is useless; unreliability is the correct engineering choice.

🧠 Active Recall