The Internet is a global network of networks, and understanding its structure is essential for computer science.
The TCP/IP Stack
Data transmission uses a layered model where each layer has specific responsibilities.
| Layer (top→bottom) | Name | Main function | Example protocols |
|---|---|---|---|
| 4 | Application | User-facing services and data formatting | HTTP, FTP, SMTP, DNS |
| 3 | Transport | End-to-end delivery and reliability | TCP, UDP |
| 2 | Network/Internet | Addressing and routing between networks | IP, ICMP |
| 1 | Link/Network Interface | Local delivery and physical transmission | Ethernet, Wi-Fi |
Scenario: You request a webpage (www.example.com)
Sending (going DOWN the stack):
Layer 4 - Application:
• Browser creates HTTP request for the webpage
• Data: "GET /index.html HTTP/1.1"
Layer 3 - Transport:
• TCP breaks data into segments
• Adds port numbers (source: 52481, destination: 80)
• Adds sequence numbers for reassembly
Layer 2 - Network:
• IP adds addresses (your IP → server's IP)
• Creates packets with routing information
Layer 1 - Link:
• Adds MAC addresses for local delivery
• Converts to electrical signals/radio waves
• Data transmitted across physical network
Receiving (going UP the stack):
The process reverses - each layer removes its header and passes data up until the browser displays the webpage.
Protocol Layering
• The protocols are applied in order, one after the other
• Each layer is self-contained, so one layer can be changed or replaced without affecting the others
• Each layer hides its details from the layers around it, which is a form of abstraction
• A large task is broken down into smaller, manageable units
• Faults are easier to find, because a problem can be traced to a single layer
• Standards can be developed for each layer separately, so products from different manufacturers work together
A web browser works in the same way whether the device is connected by Wi-Fi or by a cable. How the data physically travels is the job of the link layer, so the application layer above it does not have to change.
DNS (Domain Name System)
You type: www.example.com
Step 1: Browser checks local cache
• Have we looked this up recently? If yes, use cached IP.
Step 2: Query local DNS resolver (usually your ISP)
• Resolver checks its cache
Step 3: Query root DNS server
• "Where can I find .com domains?"
• Returns address of .com TLD server
Step 4: Query TLD (Top-Level Domain) server
• "Where can I find example.com?"
• Returns address of example.com's authoritative server
Step 5: Query authoritative DNS server
• "What's the IP for www.example.com?"
• Returns: 93.184.216.34
Step 6: IP address returned to browser
• Browser connects to 93.184.216.34
• Webpage loads
• Humans remember names, not numbers
• Websites can change IP addresses without users knowing
• Load balancing - one domain can point to multiple IPs
• Hierarchical structure provides scalability
• Distributed system - no single point of failure
Packet Switching vs Circuit Switching
| Feature | Packet switching | Circuit switching |
|---|---|---|
| Connection | No dedicated path | Dedicated path reserved |
| Routing | Packets may take different routes | Same route for whole session |
| Efficiency | High (shared network) | Lower (reserved capacity) |
| Reliability | Can route around failures | Connection fails if path breaks |
| Delay | Variable with congestion | More consistent once circuit set |
| Typical use | Internet/data networks | Traditional phone networks |