Intro to Networking
CS 161 Fall 2025 - Lecture 17
Computer Science 161
Last Time: SQL Injection
2
Computer Science 161
Last Time: CAPTCHAs
3
Computer Science 161
Today: Intro to Networking
4
Computer Science 161
What’s the Internet?
5
Textbook Chapter 25
Computer Science 161
What’s the Internet?
6
Computer Science 161
Protocols
7
Computer Science 161
Internet Analogy: Mail
8
Computer Science 161
What’s the goal of the Internet?
9
Computer Science 161
Building block 1: Something That Moves Data
10
Are pigeons faster than the Internet?
Computer Science 161
Building block 1: Something That Moves Data
11
An example of packet loss.
Computer Science 161
Building block 2: Talking to the Apartment Complex
12
Building block 1: wires
Building block 2: local network
Computer Science 161
Building block 3: Post offices
13
Building block 1: wires�Building block 2: local network��
Building block 3: wide area network
Computer Science 161
Building block 3: The Internet
14
Building block 1: wires
Building block 3: the Internet
Building block 2: local network
Computer Science 161
Building block 3: The Internet
15
Building block 1: wires
Building block 3: the Internet
Building block 2: local network
Computer Science 161
Layers of abstraction
Layer 3: Connect many local networks to form a global network
Layer 2: Create links in a local area
Layer 1: Move bits across space
16
Computer Science 161
Layering: The OSI Model
17
Computer Science 161
Layering
18
Code You Write
Run-Time Library
System Calls
Device Drivers
Voltage Levels/Magnetic Domains
Fully isolated from user programs
Computer Science 161
OSI Model
19
Application
Transport
(Inter) Network
Link
Physical
1
2
3
4
7
Computer Science 161
Layer 1: Physical Layer
20
Physical
1
Application
Transport
(Inter) Network
Link
2
3
4
7
Computer Science 161
Layer 1: Physical Layer
21
Physical
1
Application
Transport
(Inter) Network
Link
2
3
4
7
A
B
01110111…01
Physical layer: “How do I transmit this sequence of 0’s and 1’s from A to B?”
Next: How do we talk to more than one device?
Computer Science 161
Layer 2: Link Layer
22
Physical
1
Application
Transport
(Inter) Network
3
4
7
Link
2
Computer Science 161
Layer 2: Link Layer
23
Source: A
Destination: C
“Hello, this is A…”
A
B
D
C
Computer Science 161
Layer 2: Link Layer
24
Source: A
Dest: C
“Hello, this is A…”
A
B
C
D
E
Computer Science 161
Ethernet and MAC Addresses
25
Computer Science 161
Layer 2: Link Layer
26
Physical
1
Application
Transport
(Inter) Network
3
4
7
Link
2
Source: A
Dest: C
“Hello, this is A…”
Link layer: “How do I transmit this frame from A to C, making sure that no one else thinks the message is for them?”
Next: How do we address every device in existence?
A
B
D
C
Computer Science 161
Layer 3: Network Layer
27
Physical
1
Application
Transport
4
7
(Inter) Network
3
Link
2
Computer Science 161
Layer 3: Network Layer
28
A
B
D
C
E
F
G
H
Router
Computer Science 161
Layer 3: Network Layer
29
A
Router
C
D
E
B
Router
Router
Router
Router
Router
Router
Source: A
Destination: D
“Hello, this is A…”
Computer Science 161
Layer 3: Network Layer
30
A
Router
C
D
E
B
Router
Router
Router
Router
Router
Router
Source: A
Destination: D
“Hello, this is A…”
This link could be Wi-Fi
And this link could be Ethernet
But the Internet protocol stays the same, end to end
Computer Science 161
Layer 3: Network Layer
31
Computer Science 161
Internet Protocol (IP)
32
Computer Science 161
Reliability
33
Computer Science 161
Layer 3: Network Layer
34
A
Router
C
D
E
B
Router
Router
Router
Router
Router
Router
Source: A
Destination: D
“Hello, this is A…”
Layer 3: “How do I get this packet from A to D?”
Next: How do we reliably send any length of data, not just packets?
Computer Science 161
Layer 4: Transport Layer
35
Physical
1
Application
7
Link
2
(Inter) Network
3
Transport
4
Computer Science 161
Layer 4: Transport Layer
36
A
D
I am now sending an arbitrary length message that will probably be broken into several packets…
Unreliable Internet
Layer 4: “How do I transport this arbitrary data over an unreliable medium?”
Computer Science 161
Layer 7: Application Layer
37
Physical
1
Link
2
(Inter) Network
3
Transport
4
Application
7
Computer Science 161
Headers
38
Computer Science 161
Example: Sending Mail
39
Alice
Bob
I am hungry.
Computer Science 161
Example: Sending Mail
40
Alice
Bob
Send to: Bob
I am hungry.
Computer Science 161
Example: Sending Mail
41
Alice
Bob
Mail to: 123 Bob St
Send to: Bob
I am hungry.
Computer Science 161
Example: Sending Mail
42
Alice
Bob
Mail to: 123 Bob St
Send to: Bob
I am hungry.
Computer Science 161
Example: Sending Mail
43
Alice
Bob
Send to: Bob
I am hungry.
Computer Science 161
Example: Sending Mail
44
Alice
Bob
I am hungry.
Computer Science 161
Example: Sending Mail
45
Alice
Bob
Each layer communicates with each other, relying on abstractions below them!
Relies upon: Sending messages to people
Provides: Sending messages to people
Relies upon: Sending messages to addresses
Provides: Sending messages to addresses
Computer Science 161
Layers of Abstraction and Headers
46
Mail to: 123 Bob St
I’m hungry.
Send to: Bob
I’m hungry.
Send to: Bob
I’m hungry.
Lower layer, more headers
Higher layer, fewer headers
Computer Science 161
Layers of Abstraction and Headers
47
Computer Science 161
Layer 2 Header
Ethernet and MAC address headers
48
Source MAC Address (6 bytes) | |||||
Destination MAC Address (6 bytes) | |||||
VLAN Tag (4 bytes) | Type (2 bytes) | ||||
Data (variable-length) |
Computer Science 161
Layer 3 Header
IPv4 header
49
Version (4 bits) | Header Length (4 bits) | Type of Service (6 bits) | ECN (2 bits) | Total Length (16 bits) | |||||||||||
Identification (16 bits) | Flags (3 bits) | Fragment Offset (13 bits) | |||||||||||||
Time to Live (8 bits) | Protocol (8 bits) | Header Checksum (16 bits) | |||||||||||||
Source Address (32 bits) | |||||||||||||||
Destination Address (32 bits) | |||||||||||||||
Options (variable length) | |||||||||||||||
Data (variable length) |
Computer Science 161
Example: HTTP Request
50
HTTP
TCP
IP
Ethernet
Wires
HTTP
TCP
IP
Ethernet
Wires
GET / HTTP/1.1
...
Computer Science 161
Example: HTTP Request
51
HTTP
TCP
IP
Ethernet
Wires
HTTP
TCP
IP
Ethernet
Wires
From: Port 1234
To: Port 80
GET / HTTP/1.1
...
Computer Science 161
Example: HTTP Request
52
HTTP
TCP
IP
Ethernet
Wires
HTTP
TCP
IP
Ethernet
Wires
From: 1.2.3.4
To: 5.6.7.8
From: Port 1234
To: Port 80
GET / HTTP/1.1
...
Final destination
Computer Science 161
Example: HTTP Request
53
HTTP
TCP
IP
Ethernet
Wires
HTTP
TCP
IP
Ethernet
Wires
From: 20:61:84:3a:a9:52
To: 6d:36:ff:4a:32:92
From: 1.2.3.4
To: 5.6.7.8
From: Port 1234
To: Port 80
GET / HTTP/1.1
...
Address of next hop
Computer Science 161
Example: HTTP Request
54
HTTP
TCP
IP
Ethernet
Wires
HTTP
TCP
IP
Ethernet
Wires
From: 20:61:84:3a:a9:52
To: 6d:36:ff:4a:32:92
From: 1.2.3.4
To: 5.6.7.8
From: Port 1234
To: Port 80
GET / HTTP/1.1
...
Converted into bits and transmitted
Computer Science 161
Example: HTTP Request
55
HTTP
TCP
IP
Ethernet
Wires
HTTP
TCP
IP
Ethernet
Wires
From: 89:8d:33:25:47:24
To: d5:a9:20:68:e0:80
From: 1.2.3.4
To: 5.6.7.8
From: Port 1234
To: Port 80
GET / HTTP/1.1
...
Received over the physical medium
Notice: The MAC addresses changed because the recipient is on a different network
Computer Science 161
Example: HTTP Request
56
HTTP
TCP
IP
Ethernet
Wires
HTTP
TCP
IP
Ethernet
Wires
From: 89:8d:33:25:47:24
To: d5:a9:20:68:e0:80
From: 1.2.3.4
To: 5.6.7.8
From: Port 1234
To: Port 80
GET / HTTP/1.1
...
Computer Science 161
Example: HTTP Request
57
HTTP
TCP
IP
Ethernet
Wires
HTTP
TCP
IP
Ethernet
Wires
From: 1.2.3.4
To: 5.6.7.8
From: Port 1234
To: Port 80
GET / HTTP/1.1
...
Computer Science 161
Example: HTTP Request
58
HTTP
TCP
IP
Ethernet
Wires
HTTP
TCP
IP
Ethernet
Wires
From: Port 1234
To: Port 80
GET / HTTP/1.1
...
Computer Science 161
Example: HTTP Request
59
HTTP
TCP
IP
Ethernet
Wires
HTTP
TCP
IP
Ethernet
Wires
GET / HTTP/1.1
...
Computer Science 161
Example: HTTP Request
60
HTTP
TCP
IP
Ethernet
Wires
HTTP
TCP
IP
Ethernet
Wires
Relies upon: Transport of data
Provides: Transport of data
Relies upon: Global packet delivery
Provides: Global packet delivery
Relies upon: Local frame delivery
Provides: Local frame delivery
Relies upon: Communication of bits
Provides: Communication of bits
Computer Science 161
Intro to Networking: Summary
61
Application
Transport
(Inter) Network
Link
Physical
1
2
3
4
7
Computer Science 161