1
CS 168, Spring 2025 @ UC Berkeley
Slides credit: Sylvia Ratnasamy, Rob Shakir, Peyrin Kao
Slides template credit: Josh Hug, Lisa Yan
Introduction, Layers of the Internet
Lecture 1 (Intro 1)
Course Logistics
Lecture 1, CS 168, Spring 2025
Course Logistics
What is the Internet?
Layers of the Internet
Headers
Course Logistics
All course logistics are available on our website: https://sp25.cs168.io
Joining Ed, bCourses, and Gradescope:
Course Logistics
Discussions and office hours start next week (January 27).
Exam dates are on the website.
Stress management and accommodations:
Our Talented Course Staff!
Peyrin Kao
he/him
Sylvia Ratnasamy
she/her
Aditya Tummala
he/him
David Li
he/him
Hongbo Wei
he/him
Ian Dong
he/him
Anita Ding
she/her
Arjun Damerla
he/him
Ziming Mao
he/him
Jaewon Lee
he/him
What is the Internet?
Lecture 1, CS 168, Spring 2025
Course Logistics
What is the Internet?
Layers of the Internet
Headers
What is the Internet?
The Internet transfers data between computers.
We'll focus on the infrastructure that ties these devices together.
Our running analogy: Postal system.
Why Study the Internet?
The Internet has and is transforming everything!
Why is the Internet Interesting?
Networking is different from many traditional computer science fields.
Internet Design Challenges – Federation
Challenge: The Internet is federated.
Internet Design Challenges – Scale, Evolution, and Diversity
Challenge: The Internet is scalable.
Challenge: The Internet is constantly evolving.
Challenge: The Internet is diverse.
Internet Design Challenges – Asynchrony
Challenge: The Internet is asynchronous.
4,125 km distance.
Speed of light is 300,000 km/s.
Trip takes 13.75 ms.
By the time the message is sent, our 3 GHz CPU has executed 42,000,000 more cycles!
Internet Design Challenges – Fault Tolerance
Challenge: The Internet must handle failures at scale.
If we had 50 components, each working 99% of the time,�there's a 39.5% chance that at least one of them fails!
Sender
Recipient
Challenges of the Internet – Recap
The Internet:
Why Is the Internet Interesting?
Designing the Internet required new ways of thinking.
We have no theoretical model or performance benchmark.
Writing code that works is not enough.
Protocols
The Internet is all about designing protocols.
Layers of the Internet: Building Layers 1–3
Lecture 1, CS 168, Spring 2025
Course Logistics
What is the Internet?
Layers of the Internet
Headers
Layer 1 – Moving Bits Across Space
We need some physical technology to move data across space.
Are pigeons faster than the Internet?
Layer 1 – Moving Bits Across Space
We need some physical technology to move bits across space.
Won't go into detail in this class.
Layer 2 – Local Networks
Postal analogy: Use our physical technology to connect everybody in the local town.
Forming a local network:
Layer 3 – Connecting Local Networks
Postal analogy: How do we connect houses from different towns?
Layer 3 – Connecting Local Networks
Postal analogy: How do we connect houses from different towns?
Layer 3 – Connecting Local Networks
To send a letter to the other town:
Layer 3 Characteristics
Lecture 1, CS 168, Spring 2025
Course Logistics
What is the Internet?
Layers of the Internet
Headers
Network of Networks
With enough post offices, we can connect all the towns in the world!
The Internet is a network of networks.
Hosts vs. Switches
End hosts are the machines communicating over the Internet.
Switches (aka routers) receive packets and forward them toward their destination.
Layers of Abstraction
Modularity: In our design, we decomposed the system into layers of abstraction.
Abstraction is very powerful.
Physical
Link
Internet
Layer 1:
Layer 2:
Layer 3:
Move bits across space.
Create links in a local network.
Connect many local networks to form the Internet.
Global Delivery at Layer 3
A packet can take multiple hops to reach its destination.
Global Delivery at Layer 3
A packet can travel across multiple networks to reach its destination.
Wired links
Optical link
Wireless link
Wired link
Optical links
Layer 3 is Best-Effort
Layer 3 offers a best-effort service model.
We need to build more layers if we want to guarantee packet delivery.
Layers of the Internet: Building Layers 4–7
Lecture 1, CS 168, Spring 2025
Course Logistics
What is the Internet?
Layers of the Internet
Headers
Layer 4 – Reliability
Transport layer builds on top of Layer 3 (global packet delivery).
Physical
Link
Internet
Layer 1:
Layer 2:
Layer 3:
Move bits across space.
Create links in a local network.
Connect many local networks to form the Internet.
Transport
Layer 4:
Reliably deliver packets, forming connections.
Layer 7 – Application
Application layer builds services (e.g. websites, video streaming) on top of Layer 4.
Note: Layers 5 and 6 are now obsolete.
Physical
Link
Internet
Layer 1:
Layer 2:
Layer 3:
Move bits across space.
Create links in a local network.
Connect many local networks to form the Internet.
Transport
Layer 4:
Reliably deliver packets, forming connections.
Application
Layer 7:
Implement services on top of the Internet infrastructure.
Header Fields
Lecture 1, CS 168, Spring 2025
Course Logistics
What is the Internet?
Layers of the Internet
Headers
Why Do We Need Headers?
Suppose A wants to send an image to B.
The packet needs some extra metadata, to tell us what to do with the packet.
R1
A
R2
R3
B
Sender
Recipient
Router
Router
Router
01000111100010101001
???
Common Header Fields
The packet header contains metadata describing how the data should be sent.
Some common fields in a header:
The actual data in the packet is called the payload.
R1
A
R2
R3
B
Sender
Recipient
Router
Router
Router
From: A
To: B
01000111100010101001
Headers
Payload
Headers are Standardized
Everybody needs to agree on the format of the header.
R1
A
R2
R3
B
Sender
Recipient
Router
Router
Router
From: A
To: B
01000111100010101001
Headers
Payload
Multiple Headers (Endpoints Only)
Lecture 1, CS 168, Spring 2025
Course Logistics
What is the Internet?
Layers of the Internet
Headers
Postal Analogy
CEO Alice wants to send a message to CEO Bob.
Alice writes a letter.
Mail Room
Secretary
CEO
Mail Room
Secretary
CEO
"Your days are numbered."
Postal Analogy
Alice passes the letter down to her secretary.
Her secretary puts the letter in an envelope.
From: Alice, To: Bob
Mail Room
Secretary
CEO
Mail Room
Secretary
CEO
"Your days are numbered."
Postal Analogy
Her secretary passes the letter down to the mailman.
The mailman puts the envelope in a box.
From: 123 Alice St
To: 456 Bob St
From: Alice, To: Bob
Mail Room
Secretary
CEO
Mail Room
Secretary
CEO
"Your days are numbered."
Postal Analogy
The packet travels through the postal system, to Bob's building.
From: 123 Alice St
To: 456 Bob St
From: Alice, To: Bob
Mail Room
Secretary
CEO
Mail Room
Secretary
CEO
"Your days are numbered."
Postal Analogy
The mailman unwraps the box, revealing the envelope inside.
The mailman passes the envelope up to the secretary.
From: Alice, To: Bob
Mail Room
Secretary
CEO
Mail Room
Secretary
CEO
"Your days are numbered."
Postal Analogy
The secretary unwraps the envelope, revealing the letter inside.
The secretary passes the letter up to Bob.
Mail Room
Secretary
CEO
Mail Room
Secretary
CEO
"Your days are numbered."
Postal Analogy
As we move to lower layers, we wrap additional headers around the packet.
As we move to higher layers, we peel off headers, revealing the inner headers.
Mail Room
Secretary
CEO
Mail Room
Secretary
CEO
From: 123 Alice St
To: 456 Bob St
From: Alice, To: Bob
"Your days are numbered."
From: Alice, To: Bob
"Your days are numbered."
"Your days are numbered."
Postal Analogy
Each person only cares about the headers at their layer.
Each person communicates with its peers at the same layer.
Mail Room
Secretary
CEO
Mail Room
Secretary
CEO
From: 123 Alice St
To: 456 Bob St
From: Alice, To: Bob
"Your days are numbered."
Mailman only cares about this.
Secretary only cares about this.
CEO only cares about this.
Addressing at Different Layers
Notice: Different layers use different addressing schemes.
From: 123 Alice St
To: 456 Bob St
From: Alice, To: Bob
"Your days are numbered."
These addresses make sense to the mailman.
These names make sense to the secretary.
Multiple Headers
As we move to lower layers, we wrap additional headers around the packet.
Layer 2 Header
Physical
Link
Internet
Layer 1:
Layer 2:
Layer 3:
Transport
Layer 4:
Application
Layer 7:
Physical
Link
Internet
Transport
Application
Layer 3 Header
Layer 4 Header
"Your days are numbered."
Converted to bits and transmitted.
Multiple Headers
As we move to higher layers, we peel off headers, revealing the inner headers.
Layer 2 Header
Layer 3 Header
Layer 4 Header
"Your days are numbered."
Bits received over wire.
Physical
Link
Internet
Layer 1:
Layer 2:
Layer 3:
Transport
Layer 4:
Application
Layer 7:
Physical
Link
Internet
Transport
Application
Multiple Headers
Peers at the same layer communicate with each other using the header at that layer.
Physical
Link
Internet
Layer 1:
Layer 2:
Layer 3:
Transport
Layer 4:
Application
Layer 7:
Physical
Link
Internet
Transport
Application
HTTP, DNS
TCP, UDP
IP
Ethernet
Physical wire
Multiple Headers (With Routers)
Lecture 1, CS 168, Spring 2025
Course Logistics
What is the Internet?
Layers of the Internet
Headers
Postal Analogy
The letter might hop across multiple post offices.�Each post office unwraps the box, revealing the envelope inside.�Then, it puts the letter in a new box, destined for the next post office.
From: Post Office 7
To: Post Office 2
Post Office 2
Mail Room A
Secretary A
CEO A
Post Office 5
Mail Room B
Secretary A
CEO A
Post Office 7
Post Office 9
From: 123 Alice St
To: 456 Bob St
From: A, To: B
"Your days are numbered."
Postal Analogy
The letter might hop across multiple post offices.�Each post office unwraps the box, revealing the envelope inside.�Then, it puts the letter in a new box, destined for the next post office.
From: Post Office 7
To: Post Office 2
From: Post Office 2
To: Post Office 5
Post Office 2
Mail Room A
Secretary A
CEO A
Post Office 5
Mail Room B
Secretary A
CEO A
Post Office 7
Post Office 9
From: 123 Alice St
To: 456 Bob St
From: A, To: B
"Your days are numbered."
Postal Analogy
The letter might hop across multiple post offices.�Each post office unwraps the box, revealing the envelope inside.�Then, it puts the letter in a new box, destined for the next post office.
From: Post Office 2
To: Post Office 5
From: Post Office 5
To: Post Office 9
Post Office 2
Mail Room A
Secretary A
CEO A
Post Office 5
Mail Room B
Secretary A
CEO A
Post Office 7
Post Office 9
From: 123 Alice St
To: 456 Bob St
From: A, To: B
"Your days are numbered."
Postal Analogy
The letter might hop across multiple post offices.�Each post office unwraps the box, revealing the envelope inside.�Then, it puts the letter in a new box, destined for the next post office.
Post Office 2
Mail Room A
Secretary A
CEO A
Post Office 5
Mail Room B
Secretary A
CEO A
Post Office 7
Post Office 9
From: Post Office 5
To: Post Office 9
From: 123 Alice St
To: 456 Bob St
From: A, To: B
"Your days are numbered."
Postal Analogy
The letter might hop across multiple post offices.�Each post office unwraps the box, revealing the envelope inside.�Then, it puts the letter in a new box, destined for the next post office.
Post Office 2
Mail Room A
Secretary A
CEO A
Post Office 5
Mail Room B
Secretary A
CEO A
Post Office 7
Post Office 9
From: Post Office 2
To: Post Office 5
From: 123 Alice St
To: 456 Bob St
From: A, To: B
"Your days are numbered."
Intermediate post offices remove and add this header.
But only the endpoints care about the higher-layer headers.
Postal Analogy
Recall: Different layers use different addressing schemes.
From: Post Office 2
To: Post Office 5
From: 123 Alice St
To: 456 Bob St
From: A, To: B
"Your days are numbered."
Layer 2 header: Destination is the next intermediate post office.
Layer 3 header: Destination is always the actual endpoint.
Layer 4 header: A and B identify specific people in the endpoint (inside the building).
Implementing Layers at Routers and End Hosts
End hosts implement all the layers.
Routers only implement Layers 1–3.
2. Link
3. IP
1. Physical
4. Transport
7. Application
End Host (Sender)
2. Link
3. IP
1. Physical
4. Transport
7. Application
End Host (Recipient)
2. Link
3. IP
1. Physical
Router
2. Link
3. IP
1. Physical
Router
2. Link
3. IP
1. Physical
Router
Multiple Headers with Routers
Routers unwrap the Layer 2 header, and add a new Layer 2 header for the next hop.
Physical
Link
Internet
Layer 1:
Layer 2:
Layer 3:
Transport
Layer 4:
Application
Layer 7:
Physical
Link
Internet
Physical
Link
Internet
Physical
Link
Internet
Transport
Application
Layer 2 Header
Layer 3 Header
Layer 4 Header
"Potato."
Bits sent over wire.
End Host (Sender)
End Host (Recipient)
Router
Router
Multiple Headers with Routers
Routers unwrap the Layer 2 header, and add a new Layer 2 header for the next hop.
Layer 2 Header
Bits received over wire.
New Layer 2 Header
Bits sent over wire.
Physical
Link
Internet
Layer 1:
Layer 2:
Layer 3:
Transport
Layer 4:
Application
Layer 7:
Physical
Link
Internet
Physical
Link
Internet
Physical
Link
Internet
Transport
Application
Layer 3 Header
Layer 4 Header
"Potato."
End Host (Sender)
End Host (Recipient)
Router
Router
Multiple Headers with Routers
Routers unwrap the Layer 2 header, and add a new Layer 2 header for the next hop.
Layer 2 Header
Bits received over wire.
New Layer 2 Header
Bits sent over wire.
Physical
Link
Internet
Layer 1:
Layer 2:
Layer 3:
Transport
Layer 4:
Application
Layer 7:
Physical
Link
Internet
Physical
Link
Internet
Physical
Link
Internet
Transport
Application
Layer 3 Header
Layer 4 Header
"Potato."
End Host (Sender)
End Host (Recipient)
Router
Router
Multiple Headers with Routers
Routers unwrap the Layer 2 header, and add a new Layer 2 header for the next hop.
Physical
Link
Internet
Layer 1:
Layer 2:
Layer 3:
Transport
Layer 4:
Application
Layer 7:
Physical
Link
Internet
Physical
Link
Internet
Physical
Link
Internet
Transport
Application
End Host (Sender)
End Host (Recipient)
Router
Router
Layer 2 Header
Layer 3 Header
Layer 4 Header
"Potato."
Bits received over wire.
Multiple Headers with Routers
Routers unwrap the Layer 2 header, and add a new Layer 2 header for the next hop.
Physical
Link
Internet
Layer 1:
Layer 2:
Layer 3:
Transport
Layer 4:
Application
Layer 7:
Physical
Link
Internet
Physical
Link
Internet
Physical
Link
Internet
Transport
Application
End Host (Sender)
End Host (Recipient)
Router
Router
Postal Analogy
Recall: Different layers use different addressing schemes.
From: Router 2
To: Router 5
From: Alice's computer
To: Bob's computer
From: Alice's Firefox
To: Bob's Chrome
"Potato."
Layer 2 header: Destination is the next intermediate router.
Layer 3 header: Destination is always the end host.
Layer 4 header: Identifies specific application on the end host.
Postal Analogy
Routers don't care about Layer 4 and Layer 7.
Router parses Layers 1–3 to determine where to forward the packet.
Router unwraps Layer 2 header, and adds a new Layer 2 header for the next hop.
From: Router 2
To: Router 5
From: Alice's computer
To: Bob's computer
From: Alice's Firefox
To: Bob's Chrome
"Potato."
From: Alice's computer
To: Bob's computer
From: Alice's Firefox
To: Bob's Chrome
"Potato."
From: Router 5
To: Router 9
From: Alice's computer
To: Bob's computer
From: Alice's Firefox
To: Bob's Chrome
"Potato."
Unwrap Layer 2 header.
Add new Layer 2 header.
Parse Layer 3 header to figure out where to forward the packet.
Multiple Headers with Routers
Each hop could use a different Layer 2 protocol.
Physical
Link
Internet
Layer 1:
Layer 2:
Layer 3:
Transport
Layer 4:
Application
Layer 7:
Physical
Link
Internet
Physical
Link
Internet
Physical
Link
Internet
Transport
Application
End Host (Sender)
End Host (Recipient)
Router
Router
This link could be wired.
This link could be optical.
This link could be wireless.
This router unwraps wired Layer 2 header, and adds an optical Layer 2 header.
This router unwraps optical Layer 2 header, and adds a wireless Layer 2 header.
Summary: Layers of the Internet
Physical
Link
Internet
Layer 1:
Layer 2:
Layer 3:
Transport
Layer 4:
Application
Layer 7:
L1
L2
L3
L4
L7
Host
L1
L2
L3
Router
L1
L2
L3
Router
L1
L2
L3
L4
L7
Host
From: Router 2, To: Router 5
From: Alice's computer
To: Bob's computer
From: Alice's Firefox
To: Bob's Chrome
"Potato."
L2 header: Destination is the next intermediate router.
L3 header: Destination is always the end host.
L4 header (port): Identifies specific application on the end host.