Network Layer - IPv4 Datagram & Encapsulations

Ethernet vs. IP Packets

  • Ethernet Packets: Known as Ethernet frames.
  • Network Layer Packets: Referred to as IP datagrams under the IP protocol.

Structure of an IP Datagram

  • An IP datagram consists of two main sections:
  • Header: Contains various fields that are structured and strictly defined.
  • Payload: The actual data being sent.

Header Fields of an IP Datagram

  1. Version Field (4 bits):
  • Indicates the version of the Internet Protocol being used.
  • Common versions include IPv4 and the increasingly adopted IPv6.
  1. Header Length Field (4 bits):
  • Specifies the length of the header.
  • Minimum length for IPv4 is 20 bytes.
  1. Service Type Field (8 bits):
  • Used for differentiating the quality of service (QoS) options for routers.
  • Helps routers prioritize which datagrams are more critical.
  1. Total Length Field (16 bits):
  • Indicates the total length of the IP datagram.
  • Maximum value is 65,535 bytes due to 16-bit limitation.
  • If data exceeds this limit, the IP layer must fragment it.
  1. Identification Field (16 bits):
  • Groups related packets, essential for reassembly of fragmented datagrams.
  1. Flag Field:
  • Indicates if a datagram can be fragmented or if it has already been fragmented.
  1. Fragmentation Offset Field:
  • Used for reassembling fragmented packets in the correct order.
  1. Time to Live (TTL) Field (8 bits):
  • Limits the lifetime of the datagram, indicating how many hops it can take before being discarded.
  • Prevents endless looping in misconfigured networks by decrementing each time a datagram passes through a router.
  1. Protocol Field (8 bits):
  • Indicates which transport layer protocol is in use (most commonly TCP or UDP).
  1. Header Checksum Field:

    • A checksum that ensures data integrity in the header; recalculated at each router.
  2. Source and Destination IP Address Fields:

    • Each is 32 bits long, indicating the addresses of the sender and receiver.
  3. IP Options Field: (optional):

    • Used for special characteristics, mostly for testing.
  4. Padding Field:

    • A series of zeros added to ensure correct header size when the options field is variable in length.

Encapsulation

  • Every IP datagram's contents are encapsulated within the payload section of the Ethernet frame.
  • The IP datagram’s payload contains either a TCP or UDP packet.

Importance of Layered Networking

  • Understanding the functionalities of the IP layer and its relationship with the Ethernet layer emphasizes the significance of layering in networking protocols. Each layer relies on the one below it for functionality.