📡

Understanding TCP, UDP, and Data Encapsulation

Apr 3, 2025

Networking and Internet Protocols Lecture Notes

Moving Data Analogy

  • Truck Analogy: Moving data is like moving boxes with a truck.
    • Network as Roads: Different types of networks (wireless, DSL, cable, Ethernet) act as roads.
    • Internet Protocol (IP) as Trucks: IP is the truck transporting data.
    • Data as Boxes: Data is encapsulated in boxes within the truck, which can be specific to applications or functions.

Data Encapsulation Process

  • Visual Representation: Device on one side, server on the other (web, mail server, etc.).
  • Ethernet Frame: Contains the Ethernet payload, which includes IP header and payload.
  • IP Payload: Can contain TCP or UDP data.
  • Data Encapsulation: Layers within the data – Ethernet, IP, TCP/UDP, HTTP.

TCP and UDP Protocols

  • Encapsulation in IP: Both are encapsulated within IP.
  • Transport Layer (OSI Layer 4): TCP and UDP operate at this layer.

TCP (Transmission Control Protocol)

  • Connection-Oriented: Formal setup and teardown process.
  • Reliable Delivery: Ensures data is received and can reorder or retransmit packets if needed.
  • Flow Control: Mechanism to adjust sending rate based on receiving capabilities.

UDP (User Datagram Protocol)

  • Connectionless: No formal setup or teardown.
  • Unreliable: No receipt confirmation, no flow control.
  • Use Cases: Real-time communication (e.g., VoIP).

Port Numbers

  • Multiplexing: Use of port numbers to direct data to correct application.
  • Non-Ephemeral Ports: Permanent ports for consistent access (e.g., HTTP on port 80).
  • Ephemeral Ports: Temporary ports used by clients in communication.
  • Common Port Numbers: TCP 80 (HTTP), TCP 443 (HTTPS), TCP 25 (Mail), UDP 123 (Time).

IP Addressing

  • Unique Addresses: Each device on a network has a unique IP address, similar to mailing addresses.

Communication Example

  • Client to Server Communication:
    • Client IP: 10.0.0.1, Server IP: 10.0.0.2.
    • HTTP via TCP port 80, VoIP via UDP port 5004, Email via TCP port 143.
    • Source and Destination Ports: Random source ports; destination ports are well-known.

Security and Port Scanning

  • Port Scanning: Port numbers are not security mechanisms; they can be scanned and identified.

Summary

  • Port numbers and IP addresses help manage multiple simultaneous connections.
  • TCP and UDP serve different roles based on the need for reliable delivery or speed.