Skip to main content

Transport Layer: Data Transfer Methods

The Transport Layer handles how data is transmitted between devices. It supports two main protocols:

  1. UDP (User Datagram Protocol)

    • Fastest transmission
    • No guarantee of delivery
    • No error checking or correction
    • Suitable for speed-critical applications (e.g., video streaming, online games)
  2. TCP (Transmission Control Protocol)

    • Reliable and secure transmission
    • Ensures data delivery with error checking and re-transmission
    • Used for applications where accuracy matters (e.g., file transfers, emails)

πŸ“‘ Protocol Requirement​

  • Protocols define the rules for communication between devices(Ensures end-to-end data delivery).
  • Communication always needs a protocol to standardize the interaction (like TCP or UDP).

Protocols:

  • TCP: Reliable, ensures ordered and error-checked data transmission.
  • UDP: Fast but less reliable, suitable for applications needing quick data transfer.

πŸš€ TCP – Transmission Control Protocol​

πŸ”— 1. Connection Establishment​

  • TCP uses a Three-Way Handshake to establish a reliable connection.
    • Client β†’ SYN β†’ Server
    • Server β†’ SYN-ACK β†’ Client
    • Client β†’ ACK β†’ Server

πŸ“Œ This process ensures both sides are ready to send and receive data.

(Three-Way Handshake):

2. Reliable Data Transfer​

  • TCP ensures reliable and ordered delivery of data:
    • Data is guaranteed to be delivered.
    • Order of delivery is preserved.
    • No data is lost.
    • Secure, reliable, and maintains data integrity.

🧩 Segmentation​

  • Large data is split into smaller chunks called packets or segments.
  • This process is known as segmentation.

Segmentation

πŸ”„ Retransmission​

  • If a packet fails to reach the destination or gets corrupted, TCP will retransmit it.
  • This ensures reliability.

Retransmission

πŸ“₯ Acknowledgment and Flow Control​

  • Instead of acknowledging every packet, TCP uses algorithms to manage ACKs more efficiently (e.g., delayed ACK, cumulative ACK).
  • Helps with performance and congestion control.

βœ… Checksum – Error Detection​

  • A checksum is used to detect errors in the data during transmission.
  • Process:
    1. Sender generates a checksum and sends it along with the data.
    2. Receiver recalculates the checksum.
    3. If both checksums match β†’ data is valid.
    4. If they differ β†’ retransmission occurs.

βœ” Checksum is essential for error handling in TCP.

3. Graceful Connection Termination​

  • TCP connection is closed using a Four-Way Handshake.
  • Either the client or server can initiate termination.

βœ… Summary – TCP Has 3 Main Steps​

  • Connection Establishment – 3-way handshake
  • Data Transfer – Sequencing, segmentation, flow control, checksums
  • Connection Termination – 4-way handshake (graceful close)

UDP – User Datagram Protocol​

  • Focuses on speed and low latency
  • "Fire and forget" mechanism – no connection is established
  • No guarantee of delivery or order
  • No retransmission or error correction
  • Stateless protocol – no session is maintained between sender and receiver

Comparison table between TCP and UDP​

FeatureTCP (Transmission Control Protocol)UDP (User Datagram Protocol)
ReliabilityReliable – Guarantees delivery of dataUnreliable – No guarantee of delivery
Connection TypeConnection-orientedConnectionless
SpeedSlower (due to connection and reliability overhead)Faster
OverheadHigh – Establish, maintain, and terminate the connectionLow – No connection setup needed
Error HandlingAdvanced error handling (e.g., checksums, retransmission)Basic error handling
Data OrderingMaintains sequencing and correct order of dataNo sequencing or ordering
RetransmissionRetransmits lost or corrupted packetsNo retransmission
Security & ReliabilitySafe, secure, and reliableLightweight and fast, but less reliable
Use CasesEmails, web browsing (HTTP/HTTPS), file transfers (FTP)Online gaming, video/audio streaming (Zoom, VoIP)
Broadcasting SupportNot supportedSupported (one-to-many communication)
info

High-Level System Design is all about trade-offs. What does a trade-off mean? β†’ If I want something, I have to give up something else.

What is a Trade-off in System Design?​

  • A trade-off means giving up one thing to gain another.
  • In system design, you often can't optimize everything at once β€” improving one aspect may come at the cost of another.

πŸ“Œ Example:

  • If you want high availability, you might have to sacrifice consistency (as in the CAP theorem).

  • If you want faster performance, you might need to use more memory or computing power, increasing cost.

Why Trade-offs Matter in High-Level Design:​

When designing a system, you’ll need to balance between:

  • Performance vs Scalability
  • Consistency vs Availability
  • Latency vs Throughput
  • Cost vs Reliability
  • Simplicity vs Flexibility
info

🧠 Golden Rule:​

  • There’s no perfect system β€” only systems that are optimized for specific goals based on the use case.
  • Every choice in system design comes with a cost, and that’s the trade-off you decide to accept.