Transport Layer (Layer 4) and Session Layer (Layer 5) - Part 1

Transport Layer (Layer 4) and Session Layer (Layer 5)

Overview

  • The transport layer (layer 4) and session layer (layer 5) of the OSI model are closely related, with overlapping functionalities, and are often discussed together.
  • Layer 4 operates above the network layer (layer 3) and provides essential functionality for networking.
  • The OSI model is conceptual, and functionalities often span multiple layers.

Layer 3 Limitations

  • Layer 3 enables communication between devices using IP addresses.
  • Each IP packet is routed independently across networks.
  • Packets are not guaranteed to arrive in the same order, timing, or quality due to varying network conditions.

Issues with Layer 3:

  • Out-of-Order Arrival: Packets may arrive in a different order than they were sent, requiring complex application logic to resequence them.
  • Missing Packets: Network issues can cause packets to be lost.
  • Delivery Delay: Latency can affect real-time applications.
  • No Application Separation: IP alone cannot distinguish between different applications.
  • No Flow Control: A sender might overwhelm a receiver, leading to data loss.

Layer 4: TCP and UDP

TCP (Transmission Control Protocol)

  • Provides reliability, error correction, and ordered data delivery.
  • Used by protocols like HTTP, HTTPS, and SSH.
  • Connection-oriented: requires establishing a connection before data transfer.
  • Creates a bidirectional communication channel.

UDP (User Datagram Protocol)

  • Offers faster performance but is less reliable than TCP.
  • Lacks the overhead of TCP.

TCP/IP

  • The term "TCP/IP" refers to TCP running on top of IP.

TCP Segments

  • TCP uses segments to encapsulate data, which are then placed inside IP packets.
  • Segments do not have source or destination IP addresses, relying on the IP packet for routing.

TCP Segment Structure:

  • Source and Destination Ports: Allow multiple communication streams between devices.
  • A unique combination of source and destination IP and source and destination ports identifies a single communication channel.
  • Sequence Number: A unique number incremented with each segment for error correction and ordering.
  • Acknowledgement Field: Indicates the receiver has received segments up to a certain sequence number. Essential for TCP's reliable protocol.
  • Flags: Control the TCP connection. Includes flags, data offset, and reserved space.
  • TCP Window: Defines the number of bytes a receiver is willing to accept before acknowledging. Used for flow control.
  • Smaller windows provide more control but less efficiency.
  • Larger windows are more efficient but offer less control.
  • Checksum: Used for error detection and retransmission of data.
  • Urgent Pointer: Allows priority processing of control traffic in data transfer applications like FTP and Telnet.

TCP Header

  • All the fields combined form the TCP header.
  • The remaining capacity of a TCP segment is used for data.