Loading learning content...
Every packet traversing the Internet carries within itself all the information needed to reach its destination. No prior arrangement between source and destination, no reserved path through the network, no state maintained at intermediate routers about ongoing communications—just a destination address and the network's collective wisdom to get it there.
This is the datagram approach to packet switching: a connectionless, best-effort, per-packet routing paradigm that has proven extraordinarily resilient and scalable. It stands in stark contrast to the telephone network's circuit-switched model and to the virtual circuit approach we'll examine later.
In this page, we conduct an exhaustive exploration of datagram switching—its principles, routing mechanics, advantages, limitations, and the engineering decisions that make it the foundation of the world's largest engineered system: the Internet.
By completing this page, you will: (1) Understand the fundamental principles of connectionless datagram switching, (2) Trace the journey of a datagram through multiple routers, (3) Analyze datagram routing table structures and lookup mechanisms, (4) Evaluate the advantages and limitations of the datagram approach, and (5) Compare datagram switching with connection-oriented alternatives.
The datagram approach is characterized by several defining principles that distinguish it from connection-oriented alternatives.
1. Connectionless Operation
There is no connection establishment phase before data transfer. The sender can transmit a datagram to any destination at any time without prior negotiation. There is no call setup, no handshake with the network, and no reservation of resources along the path.
Implications:
2. Self-Contained Packets
Each datagram carries complete addressing information—specifically, the full destination address (and source address for replies). A router examining a datagram has all the information needed to make a forwarding decision without consulting external state about the packet's context.
3. Independent Routing
Each datagram is routed independently, based solely on its destination address and the router's current forwarding table. Consecutive packets between the same source-destination pair may take different paths if routing tables change (due to link failures, congestion, or routing protocol updates).
4. Stateless Switches/Routers
Routers maintain no per-flow or per-connection state. The only state is the forwarding table—a mapping from destination addresses (or prefixes) to outgoing interfaces. This state reflects the network topology, not individual communications.
The datagram approach embodies the 'end-to-end principle'—a design philosophy stating that application-specific features (reliable delivery, in-order delivery, error correction) should be implemented at the endpoints, not in the network core. The network's job is simply to deliver packets on a best-effort basis. This principle, articulated by Saltzer, Reed, and Clark in 1984, has been central to Internet architecture and its remarkable ability to support unforeseen applications.
A datagram must carry sufficient information for any router to make a forwarding decision and for the destination to reassemble and interpret the data. Let us examine the structure of the Internet Protocol (IP) datagram—the canonical example.
The IPv4 header is 20-60 bytes in length (20 bytes minimum, with up to 40 bytes of options). The essential fields are:
| Field | Size | Purpose |
|---|---|---|
| Version | 4 bits | IP version (4 for IPv4) |
| IHL | 4 bits | Header length in 32-bit words |
| Type of Service | 8 bits | Quality of service parameters |
| Total Length | 16 bits | Entire datagram length in bytes |
| Identification | 16 bits | Unique ID for fragment reassembly |
| Flags | 3 bits | Fragmentation control |
| Fragment Offset | 13 bits | Fragment position in original datagram |
| TTL | 8 bits | Hop limit—decremented at each router |
| Protocol | 8 bits | Upper layer protocol (TCP=6, UDP=17) |
| Header Checksum | 16 bits | Error detection for header only |
| Source Address | 32 bits | Originating host's IP address |
| Destination Address | 32 bits | Target host's IP address |
| Options | Variable | Security, routing, timestamps, etc. |
Destination Address: The 32-bit (IPv4) or 128-bit (IPv6) destination address is the primary routing key. Routers perform longest prefix matching against this field to determine the outgoing interface.
Time-to-Live (TTL): This field prevents packets from circulating indefinitely if a routing loop occurs. Each router decrements TTL by 1; if it reaches 0, the packet is discarded and an ICMP Time Exceeded message is sent to the source. Typical initial TTL values are 64, 128, or 255.
Protocol Field: Identifies the encapsulated protocol (TCP, UDP, ICMP, etc.). This doesn't affect routing but is essential for endpoint demultiplexing.
IPv6 dramatically simplified the datagram header:
| Field | Size | Purpose |
|---|---|---|
| Version | 4 bits | IP version (6 for IPv6) |
| Traffic Class | 8 bits | QoS/DSCP equivalent |
| Flow Label | 20 bits | Optional flow identification |
| Payload Length | 16 bits | Payload length (excludes header) |
| Next Header | 8 bits | Upper layer or extension header type |
| Hop Limit | 8 bits | IPv6 equivalent of TTL |
| Source Address | 128 bits | Originating host's IPv6 address |
| Destination Address | 128 bits | Target host's IPv6 address |
Notable Simplifications:
IP (both v4 and v6) does not checksum the payload—only the header in IPv4, and nothing in IPv6. This is deliberate: endpoint protocols (TCP, UDP) provide their own checksums, and duplicating this work at every hop would waste CPU cycles. This design reflects the end-to-end principle: error detection is an endpoint responsibility, not a network function.
As a datagram traverses the network, it is encapsulated within link-layer frames at each hop:
┌─────────────────────────────────────────────────────────────────────┐
│ Link Layer Frame (e.g., Ethernet) │
│ ┌─────────────────────────────────────────────────────────────────┐ │
│ │ Ethernet Header │ IP Datagram │ Ethernet Trailer │ │
│ │ (14 bytes) │ │ (4 bytes FCS) │ │
│ │ │ ┌─────────────────────────────────────────┐ │ │
│ │ │ │ IP Header │ Transport Header │ Data │ │ │
│ │ │ │ │ (TCP/UDP) │ │ │ │
│ │ │ └─────────────────────────────────────────┘ │ │
│ └─────────────────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────────────┘
At each hop:
The IP datagram remains unchanged except for TTL (and header checksum in IPv4)—addressing information is preserved end-to-end.
The heart of datagram switching is the forwarding table (also called routing table or Forwarding Information Base—FIB). This table maps destination addresses to outgoing interfaces and next-hop addresses.
A typical routing table entry contains:
| Field | Description | Example |
|---|---|---|
| Destination Prefix | Network address and mask | 192.168.1.0/24 |
| Next Hop | IP address of next router | 10.0.0.1 |
| Interface | Outgoing interface | eth0 |
| Metric | Route preference (lower = better) | 10 |
| Origin | How route was learned | OSPF, BGP, Static |
When a datagram arrives, the router must find the most specific matching route. This is accomplished through longest prefix matching:
Example:
Routing table:
0.0.0.0/0 → Interface eth0 (default route)
192.168.0.0/16 → Interface eth1
192.168.1.0/24 → Interface eth2
192.168.1.128/25 → Interface eth3
Destination: 192.168.1.200
Winner: 192.168.1.128/25 → Forward via eth3
The /25 prefix is most specific (longest match), so it wins despite other valid matches.
Internet backbone routers have routing tables with 900,000+ prefixes (as of 2024). Performing longest prefix match on every packet at 100 Gbps (150+ million packets/second) requires highly optimized hardware. Solutions include TCAMs (Ternary Content-Addressable Memory), multi-bit tries, and hash-based schemes. LPM lookup is one of the most performance-critical operations in networking.
Let us trace a datagram through a router:
Step 1: Ingress Processing
Step 2: Route Lookup
Step 3: TTL and Checksum Update
Step 4: Queuing
Step 5: Egress Processing
How does the routing table get populated? Through two mechanisms:
1. Static Routes: Manually configured by network administrators. Used for:
2. Dynamic Routing Protocols: Automatically discover and advertise network reachability:
| Protocol | Type | Scope | Algorithm |
|---|---|---|---|
| RIP | IGP | Intra-domain | Distance Vector |
| OSPF | IGP | Intra-domain | Link State |
| IS-IS | IGP | Intra-domain | Link State |
| EIGRP | IGP | Intra-domain | Hybrid |
| BGP | EGP | Inter-domain | Path Vector |
IGP (Interior Gateway Protocol): Routes within an autonomous system EGP (Exterior Gateway Protocol): Routes between autonomous systems
These protocols continuously exchange routing information, enabling the network to adapt to topology changes, link failures, and policy modifications—all without affecting the datagram's self-contained, independently-routed nature.
Let us trace a complete datagram journey from source to destination, examining the decisions made at each hop.
Host A Host B
10.1.1.10 10.3.1.20
│ │
│ eth0 eth0 │
┌───┴───┐ ┌─────────┐ ┌─────────┐ ┌───┴───┐
│Router1│──eth1─────│ Router2 │───eth1────│ Router3 │─────│Network│
│ │ │ │ │ │ │10.3.1 │
└───────┘ └─────────┘ └─────────┘ └───────┘
10.1.1.1 10.2.1.1/10.2.2.1 10.2.2.2/10.3.1.1
(eth0) (eth1) (eth0) (eth1)
Router 1 (10.1.1.1):
10.1.1.0/24 → eth0 (directly connected)
10.2.1.0/24 → eth1 (directly connected)
10.2.2.0/24 → 10.2.1.2 via eth1
10.3.1.0/24 → 10.2.1.2 via eth1
Router 2 (10.2.1.2 / 10.2.2.1):
10.1.1.0/24 → 10.2.1.1 via eth0
10.2.1.0/24 → eth0 (directly connected)
10.2.2.0/24 → eth1 (directly connected)
10.3.1.0/24 → 10.2.2.2 via eth1
Router 3 (10.2.2.2 / 10.3.1.1):
10.1.1.0/24 → 10.2.2.1 via eth0
10.2.1.0/24 → 10.2.2.1 via eth0
10.2.2.0/24 → eth0 (directly connected)
10.3.1.0/24 → eth1 (directly connected)
Step 1: Host A Creates Datagram
Host A (10.1.1.10) wants to send data to Host B (10.3.1.20).
IP Datagram Created:
Host A checks: Is 10.3.1.20 on my local network (10.1.1.0/24)? No. → Forward to default gateway: Router 1 (10.1.1.1) → ARP resolves 10.1.1.1 to MAC_R1_eth0 → Ethernet frame created with destination MAC_R1_eth0
Step 2: Router 1 Receives and Forwards
Router 1 receives frame on eth0:
Step 3: Router 2 Receives and Forwards
Router 2 receives frame on eth0:
Step 4: Router 3 Receives and Delivers
Router 3 receives frame on eth0:
Step 5: Host B Receives Datagram
Host B receives frame:
Datagram journey complete. Each router made an independent forwarding decision based solely on the destination address.
Notice three critical points: (1) The IP addresses in the datagram header NEVER changed—only the link-layer addresses were modified at each hop. (2) TTL decreased at each router—if it reaches 0, the packet dies. (3) Each router made its decision independently—Router 2 had no idea the packet came from Router 1 or was destined for Host B. It only knew: 'destination 10.3.1.20 should go to 10.2.2.2.'
The datagram approach has proven extraordinarily successful, powering the Internet's growth from a research network to a global infrastructure. Its advantages are both technical and architectural.
| Application | Key Advantage | Why It Matters |
|---|---|---|
| Web Browsing | Zero setup latency | Faster page loads; HTTP/3's 0-RTT relies on connectionless IP |
| DNS Queries | Simple request-response | Single packet each direction; connection overhead would dominate |
| Video Streaming | Fault tolerance | Lost packets skipped; stream continues despite link failures |
| IoT Sensors | Stateless operation | Millions of devices, infrequent traffic; connection state impractical |
| CDN Distribution | Multicast capability | Content can be replicated efficiently toward multiple receivers |
Layered Independence: The datagram model enables clean separation between layers. The network layer (IP) provides best-effort delivery; the transport layer (TCP/UDP) builds reliability or real-time semantics on top. This allows innovation at each layer independently.
Application Agnosticism: The network treats all traffic equally—it has no concept of applications. New applications can be deployed without network changes. This has been critical to Internet innovation: video streaming, VoIP, P2P, and countless applications emerged without requiring router upgrades.
Economic Efficiency: Stateless routers can be mass-produced with standard designs. There's no need for application-specific logic or complex state machines. This drove down networking costs and accelerated deployment.
Operational Simplicity: Debugging datagram networks is straightforward. Tools like traceroute and ping work because each packet can be analyzed independently. There's no hidden connection state to confuse troubleshooting.
The Internet has grown from 4 hosts in 1969 to over 30 billion connected devices today. This growth would have been impossible with connection-oriented network layer. The datagram approach—with its stateless routers and best-effort forwarding—is the fundamental enabler of Internet-scale networking.
The datagram approach, for all its strengths, has significant limitations that have shaped network architecture decisions for decades.
The networking community has developed numerous mechanisms to address datagram limitations while preserving the core architecture:
QoS Challenges: Addressed through:
Reliability Challenges: Addressed through:
Latency Variance: Addressed through:
The decision to use datagrams was a conscious trade-off: give up guaranteed delivery and predictable latency in exchange for simplicity, scalability, and fault tolerance. This trade-off, made in the 1970s, has been validated by five decades of Internet growth. Applications that need reliability build it at the transport layer (TCP). Those that need real-time delivery accept some loss in exchange for low latency (UDP). The network itself remains simple—and that simplicity is its greatest strength.
The datagram approach is one of two fundamental packet switching paradigms. The other—virtual circuits—takes a fundamentally different approach. Understanding both is essential for comprehensive networking knowledge.
| Characteristic | Datagram | Virtual Circuit |
|---|---|---|
| Setup Required | No | Yes (connection establishment) |
| Packet Routing | Independent per-packet | Follows established path |
| State in Network | None (per-flow) | Per-connection state at each switch |
| Addressing | Full address in every packet | Short label after setup |
| Route Decision | Made at each hop | Made once at setup |
| Failure Handling | Automatic reroute | May require re-establishment |
| QoS Capability | Best-effort only | Resource reservation possible |
| Scalability | Very high (stateless) | Limited by state capacity |
| Examples | Internet (IP) | ATM, MPLS, Frame Relay |
Datagram Preferred When:
Virtual Circuit Preferred When:
| Overhead Type | Datagram (IP) | Virtual Circuit (MPLS) |
|---|---|---|
| Connection Setup | 0 bytes, 0 RTT | Signaling messages, ~1 RTT minimum |
| Per-Packet Header | 20-40 bytes (IPv4/IPv6) | 4 bytes (MPLS label) |
| Router State | O(prefixes) ≈ 1M entries | O(connections) - potentially billions |
| Lookup Complexity | LPM (complex) | Exact match (simple) |
Modern networks often combine both approaches. The Internet uses IP datagrams end-to-end but employs MPLS label switching for traffic engineering within carrier networks. SD-WAN overlays create virtual circuits over datagram infrastructure. The wisdom is not in choosing one paradigm exclusively but in understanding when each serves best.
We have completed an exhaustive examination of the datagram approach—the connectionless paradigm that underpins the global Internet. Let us consolidate the key concepts:
What's Next:
Having examined the connectionless datagram approach, we now turn to its counterpart: virtual circuit switching. We'll explore how connection-oriented packet switching works, its advantages for certain application types, and how technologies like ATM, Frame Relay, and MPLS implement virtual circuits in practice.
You have mastered the datagram switching paradigm—the foundation of Internet routing. You can now trace a packet's journey through multiple routers, analyze routing table structure and longest-prefix matching, and articulate the advantages and limitations that have shaped Internet architecture. Next, we'll explore virtual circuits—the connection-oriented alternative.