network layers
Summary
Building the packet
| Layer | Packet format | Needs |
|---|---|---|
| application layer | message | the data itself |
| transport layer | segment -> src & dest ports | message | which port/process to send to |
| network layer | datagram -> src & dest ip | segment | which host to send to |
| link layer | frame -> src & dest MAC | datagram | error check | which device to send to |
each successive layer builds upon the packet
Tables at each layer
| Device | Layer | Table Name | Stores | Purpose |
|---|---|---|---|---|
| Host (OS / apps) | Application | Application state / session table | App-specific data (sessions, requests, cookies) | Track application-level interactions |
| Host (OS kernel) | Transport | Socket / connection table | (IP, port, protocol) <-> process | Deliver data to correct application |
| Router / Host | Network | Routing table | Network prefix -> next hop | Decide where to send packets |
| NAT Router | Network | NAT translation table | (private IP, port) <-> (public IP, port) | Map internal <-> external connections |
| Host / Router | Link | ARP table (ARP cache) | IP -> MAC address | Resolve next-hop MAC address |
| Switch | Link | MAC (forwarding) table | MAC address -> interface | Forward frames within LAN |
Concept
Protocols
- format and order of messages exchanged
- actions taken upon receiving/sending
Protocol layers
- built upon layers of abstraction, upper layers do not need to deal with the physical connection directly
- all communication still goes through the physical layer

Application layer
- application to application
- protocols used by internet applications running on hosts
- HTTP, DNS, FTP, SMTP
| Architecture | Desc |
|---|---|
| client-server | - server: listens and waits, provides a service - client: initiates contact |
| peer to peer(P2P) | - end hosts communicate directly - scalable: new users add more capacity - difficult to manage |
| hybrid | - central server helps to link end hosts |
| Requirements |
- data integrity: file transfer requires lossless; streaming can tolerate data loss
- timing: games need low latency
- throughput: multimedia requires minimum amount of bandwidth to be effective
- security: encryption, authentication
Transport layer
| Stakeholder | Role |
|---|---|
| sender | break message into segments |
| receiver | reassemble segment into messages |
| routers | inspect dest ip and route |
ususally, routers are in the network layer
Network layer
- host to host
- routers - forwards packets between networks
- best-effort and unreliable
- no guarantees for:
- successful datagram delivery
- timing/order of delivery
- bandwidth provided
- pros:
- simple mechanism - wide adoption
- sufficient provisioning of bandwidth - good enough most of the time
- distributed services - multiple providers
- no guarantees for:
- control plane(application layer protocols):
- data plane:
Link layer
- communication between adjacent nodes only
- switch - smart forwarding
- implemented in network interface cards(NIC) in hardware, integrated closely with the physical layer
- ARP