The Internet Protocol (IP)
The Internet Protocol (IP) is the core protocol of the Internet's network layer, responsible for addressing hosts and forwarding packets (datagrams) from a source to a destination.
There are two versions in use:
IPv4: The legacy and still most widely used version.
IPv6: The modern successor, designed to overcome the address space limitations of IPv4.
Key Components of the Network Layer
The Internet's network layer is comprised of three main components working together:
The IP Protocol: Defines the datagram format, addressing conventions, and the basic rules for forwarding packets.
Routing Protocols: These protocols (e.g., OSPF, BGP) determine the paths that packets take across the network. They are responsible for creating the forwarding tables used by routers.
Internet Control Message Protocol (ICMP): A supporting protocol used for error reporting and network diagnostics. For example, ICMP is used to report that a destination is unreachable or to facilitate the
ping
command.
A key distinction to understand is between forwarding and routing:
Forwarding is the local action a router takes to move a packet from an input link to the correct output link using the forwarding table and destination IP address.
Routing is the global, network-wide dynamic process of determining the paths that packets will follow to create the forwarding tables based on network topology.
The IPv4 Datagram Format
An IP packet, or datagram, is the fundamental unit of data at the Internet's network layer.
It consists of two parts: the header, which contains control information, and the payload, which carries the actual data.
The IPv4 header is typically 20 bytes long (without options). The entire datagram, including the payload, can be up to 65,535 bytes.
Key IPv4 Header Fields
The header fields can be grouped by their function:
Basic Information
Version (4 bits): Always set to 4 for IPv4.
Header Length (4 bits): Indicates length of the IP header in 32-bit words (e.g., a value of 5 means a 20-byte header).
Datagram Length (16 bits): The total size of the datagram (header + payload).
Packet Handling & Lifetime
Type of Service (ToS) (8 bits): Specifies priority or quality of service (QoS) requirements.
Time To Live (TTL) (8 bits): Limits the datagram's lifetime. Each router decrements this value by one; if it reaches zero, the packet is discarded to prevent infinite loops.
Fragmentation Fields
These fields are used to split a datagram into smaller pieces to traverse links with a smaller Maximum Transmission Unit (MTU).
Identification (16 bits): Uniquely identifies all fragments belonging to a single original datagram.
Flags (3 bits): Control bits that indicate if a datagram can be fragmented and if a fragment is the last one.
Fragment Offset (13 bits): Specifies where a particular fragment belongs in the original datagram.
Addressing and Payload Information
Protocol (8 bits): Indicates the transport-layer protocol of the payload (e.g., 6 for TCP, 17 for UDP).
Source IP Address (32 bits): The address of the sending host.
Destination IP Address (32 bits): The address of the receiving host.
Integrity Check
- Header Checksum (16 bits): Used to detect errors in the IP header. It must be recomputed at every router because the TTL field changes. This checksum does not cover the payload data.
- Data (Payload): Contains transport-layer segment (e.g., TCP/UDP segment, ICMP messages etc).
Router
A router is a network device that operates at the network layer (Layer 3) to connect different computer networks and forward data packets between them.
It performs two primary functions:
Routing (Control Plane): The router runs routing protocols (e.g., OSPF, BGP) to discover network paths and build a forwarding table. This is the "brain" function where it determines the best routes for any network.
Forwarding (Data Plane): This is the local, per-packet action of taking an incoming packet, looking up its destination IP address in the forwarding table, and sending it to the correct output port.
Architecture of a Router
A router is composed of four main components that work together to perform the routing and forwarding functions.
1. Input Ports
An input port handles the reception of incoming packets. Its key jobs are:
Performing physical and link-layer operations to receive the bitstream.
Looking up the packet's destination address in the forwarding table to determine the correct output port.
Directing control packets (like routing updates) to the Routing Processor.
2. Switching Fabric
This is the internal network that connects the router's input ports to its output ports. Common types include:
Switching via Memory: A central CPU copies packets from input to output buffers.
Switching via Bus: A shared bus is used to transfer packets from input to output.
Switching via Interconnection Network: A sophisticated switch matrix (like a crossbar) that allows for parallel packet forwarding.
3. Output Ports
An output port handles the transmission of outgoing packets. It:
Receives packets from the switching fabric and stores them in a buffer.
Performs queuing and scheduling if the link is congested.
Handles the link-layer and physical-layer operations to send the packet out onto the link.
4. Routing Processor
This is the router's central processing unit (CPU). It:
Executes the routing protocols to build and maintain the routing table.
Populates the forwarding tables used by the input ports.
Handles network management and administrative functions.