Packet Switching: Shared Resource Data Networks
Datagram Approach: Connectionless Packet Switching
Read aloud is unavailable in this browser.
The Internet's Routing Philosophy
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.
Fundamental Principles of Datagram Switching
The datagram approach is characterized by several defining principles that distinguish it from connection-oriented alternatives.
Core Characteristics
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:
- Zero setup latency—the first packet can be sent immediately
- No cleanup required when communication ends
- The network has no concept of "ongoing conversations"
- Each packet is treated as an independent, self-contained unit
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.
- •State Location: In datagram networks, intelligence resides in the endpoints (hosts). The network core is "dumb"—it only forwards packets. In connection-oriented networks, the core maintains per-connection state.
- •Addressing Granularity: Datagrams use destination addresses (e.g., IP addresses). Connection-oriented networks often use short connection identifiers (e.g., MPLS labels, ATM VCIs) after initial setup.
- •Route Binding: Datagram routes are determined packet-by-packet (late binding). Virtual circuits bind routes at connection setup (early binding).
- •Failure Handling: Datagram networks route around failures automatically (packets take alternate paths). Virtual circuits may require explicit rerouting or connection re-establishment.
- •Resource Allocation: Datagrams compete for resources at each hop (statistical multiplexing). Virtual circuits can reserve capacity along the path (guaranteed QoS).
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.
Datagram Structure and Headers
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.
IPv4 Header Structure
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. |
Key Fields for Datagram Routing
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 Header Simplification
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:
- Fixed 40-byte header (no options in base header; extension headers used instead)
- No header checksum (relies on link-layer and transport-layer checksums)
- No fragmentation fields in base header (handled via extension headers; routers do NOT fragment—only endpoints)
- Flow Label enables efficient hardware handling of packet streams
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.
Datagram Encapsulation
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 incoming frame's link-layer header is stripped
- The IP datagram is processed (TTL decremented, next hop determined)
- A new link-layer header is added for the outgoing link
- The frame is transmitted on the outgoing interface
The IP datagram remains unchanged except for TTL (and header checksum in IPv4)—addressing information is preserved end-to-end.
Routing Table and Forwarding Mechanics
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.
Routing Table Structure
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 |
Longest Prefix Matching (LPM)
When a datagram arrives, the router must find the most specific matching route. This is accomplished through longest prefix matching:
- Extract the destination IP address from the datagram
- Compare against all prefixes in the routing table
- Select the entry with the longest matching prefix (most specific route)
- Forward to the corresponding interface/next-hop
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
- 0.0.0.0/0 matches (0 bits specific)
- 192.168.0.0/16 matches (16 bits specific)
- 192.168.1.0/24 matches (24 bits specific)
- 192.168.1.128/25 matches (25 bits specific, covers 192.168.1.128-192.168.1.255)
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.
The Forwarding Process
Let us trace a datagram through a router:
Step 1: Ingress Processing
- Packet arrives on input interface
- Link-layer header removed (Ethernet de-encapsulation)
- IP header validation: version, header length, checksum
- If TTL = 1, discard packet and send ICMP Time Exceeded
Step 2: Route Lookup
- Extract destination IP address from header
- Perform LPM against FIB
- Determine: (a) output interface, (b) next-hop IP address
Step 3: TTL and Checksum Update
- Decrement TTL by 1
- Recompute IPv4 header checksum (IPv6 has no header checksum)
Step 4: Queuing
- Place packet in output interface queue
- Apply QoS scheduling if configured
Step 5: Egress Processing
- Resolve next-hop IP to link-layer address (ARP for IPv4, NDP for IPv6)
- Encapsulate in new link-layer frame
- Transmit on output interface
- •Input Port: Packet received, L2 header stripped, basic validation
- •Parsing: IP header parsed, key fields extracted
- •LPM Lookup: Destination address matched against FIB via TCAM or trie
- •TTL Processing: Decrement and check; discard if zero
- •Checksum Update: Recompute header checksum (IPv4 only)
- •Switch Fabric: Packet transferred to output port (crossbar, shared memory, bus)
- •Output Queue: Packet buffered in appropriate priority queue
- •Scheduling: Queue discipline selects next packet for transmission
- •L2 Encapsulation: New Ethernet/link-layer header added
- •Transmission: Packet serialized onto outgoing link
Routing Table Population
How does the routing table get populated? Through two mechanisms:
1. Static Routes: Manually configured by network administrators. Used for:
- Default routes (gateway of last resort)
- Specific known destinations
- Policy-based routing overrides
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.
Worked Example: A Datagram's Journey
Let us trace a complete datagram journey from source to destination, examining the decisions made at each hop.
Network Topology
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)
Routing Tables
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)
Datagram Transmission: Host A → Host B
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:
- Source IP: 10.1.1.10
- Destination IP: 10.3.1.20
- TTL: 64
- Payload: Application data
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:
- Strips Ethernet header
- Validates IP header, checks TTL (64 > 1, OK)
- Destination: 10.3.1.20
- LPM lookup: 10.3.1.0/24 → 10.2.1.2 via eth1
- Decrements TTL: 64 → 63
- Recalculates IPv4 checksum
- ARP resolves 10.2.1.2 to MAC_R2_eth0
- New Ethernet frame: dst=MAC_R2_eth0, src=MAC_R1_eth1
- Transmits on eth1
Step 3: Router 2 Receives and Forwards
Router 2 receives frame on eth0:
- Strips Ethernet header
- Validates IP header, checks TTL (63 > 1, OK)
- Destination: 10.3.1.20
- LPM lookup: 10.3.1.0/24 → 10.2.2.2 via eth1
- Decrements TTL: 63 → 62
- Recalculates IPv4 checksum
- ARP resolves 10.2.2.2 to MAC_R3_eth0
- New Ethernet frame: dst=MAC_R3_eth0, src=MAC_R2_eth1
- Transmits on eth1
Step 4: Router 3 Receives and Delivers
Router 3 receives frame on eth0:
- Strips Ethernet header
- Validates IP header, checks TTL (62 > 1, OK)
- Destination: 10.3.1.20
- LPM lookup: 10.3.1.0/24 → eth1 (directly connected)
- Decrements TTL: 62 → 61
- Recalculates IPv4 checksum
- ARP resolves 10.3.1.20 to MAC_HostB
- New Ethernet frame: dst=MAC_HostB, src=MAC_R3_eth1
- Transmits on eth1
Step 5: Host B Receives Datagram
Host B receives frame:
- Ethernet destination matches local MAC → accept
- Strips Ethernet header
- IP destination (10.3.1.20) matches local IP → process
- Passes payload to upper layer (TCP/UDP) based on Protocol field
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.'
Advantages of Datagram Switching
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.
- •Zero Setup Latency: No connection establishment required. The first packet can be sent immediately. For short transfers (DNS queries, HTTP/3 connections with 0-RTT), this eliminates significant delays.
- •Natural Fault Tolerance: If a link or router fails, subsequent packets automatically take alternate paths (once routing tables converge). No explicit failure notification or recovery procedure needed—the network self-heals.
- •Efficient for Bursty Traffic: No resources are reserved when idle. A host can burst data immediately without waiting for capacity allocation. Statistical multiplexing maximizes utilization.
- •Simplified Router Design: Routers maintain only topology-based state (routing tables), not per-connection state. A backbone router handling millions of concurrent flows stores the same routing table regardless of traffic volume.
- •Stateless Core: The lack of per-flow state enables horizontal scaling. Adding router capacity doesn't require state migration or synchronization. The network core remains 'dumb' and simple.
- •Multicast Support: Connectionless operation naturally supports multicast. A single datagram can be replicated at routers and forwarded to multiple destinations without establishing multiple connections.
| 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 |
Architectural Advantages
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.
Limitations and Challenges
The datagram approach, for all its strengths, has significant limitations that have shaped network architecture decisions for decades.
- •No Quality of Service Guarantees: Pure datagram networks offer only best-effort delivery. There's no mechanism to guarantee bandwidth, delay bounds, or jitter limits. Real-time applications (voice, video) may suffer during congestion.
- •Per-Packet Overhead: Every packet carries full addressing information (20 bytes IPv4 header, 40 bytes IPv6). For small payloads (e.g., TCP ACKs), header overhead is significant. Virtual circuits with short labels are more efficient per-packet.
- •Per-Packet Processing: Routers perform LPM on every packet. For millions of packets per second, this demands expensive hardware (TCAMs). Connection-based approaches with simple label switching can be faster.
- •Unpredictable Latency: Each packet may take a different path with different congestion levels. End-to-end delay can vary packet-to-packet, complicating real-time application design.
- •Out-of-Order Delivery: Packets may arrive at the destination in a different order than sent. The destination (or transport layer) must reorder them. This adds complexity to endpoints.
- •No Built-in Reliability: Datagrams may be lost, duplicated, or corrupted. The network provides no notification of delivery success or failure. Upper layers must implement reliability if needed.
How Limitations Are Addressed
The networking community has developed numerous mechanisms to address datagram limitations while preserving the core architecture:
QoS Challenges: Addressed through:
- Differentiated Services (DiffServ): Per-hop behavior based on DSCP field
- IntServ: Resource reservation with RSVP (less common today)
- Traffic engineering: Carefully planned capacity to ensure adequate resources
- Over-provisioning: Simply building more capacity than typically needed
Reliability Challenges: Addressed through:
- Transport layer protocols (TCP, QUIC) providing reliable, in-order delivery
- Application-layer acknowledgments and retransmissions
- Forward Error Correction (FEC) for real-time media
Latency Variance: Addressed through:
- Traffic engineering to stabilize routing
- Playout buffers at receivers for media
- Jitter buffers in VoIP systems
- ECMP (Equal Cost Multi-Path) with flow-based hashing to keep flows on consistent paths
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.
Datagram vs. Virtual Circuit: Comparative Analysis
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.
Comparative Overview
| 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 |
When Each Approach Excels
Datagram Preferred When:
- Traffic is bursty or unpredictable
- Setup overhead would dominate (short transfers)
- Fault tolerance is critical
- Scale is massive (billions of endpoints)
- Best-effort delivery is acceptable
Virtual Circuit Preferred When:
- Guaranteed QoS is essential (telecom services)
- Traffic is long-lived and steady
- Per-packet overhead must be minimized
- Predictable latency is required
- Accounting/billing per-connection is needed
| 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.
KEEP LEARNING
Keep learning for free.
Read the complete lesson, save your notes and pick up where you left off with a free account. No card needed.