Intro to Networking
CS 161 - Lecture 16
Computer Science 161
Announcements
2
Computer Science 161
Last Time: SQL Injection
3
Computer Science 161
Last Time: CAPTCHAs
4
Computer Science 161
Today: Intro to Networking
5
Computer Science 161
What’s the Internet?
6
Computer Science 161
What’s the Internet?
7
Computer Science 161
Protocols
8
Computer Science 161
Layering: The OSI Model
9
Computer Science 161
Layering
10
Code You Write
Run-Time Library
System Calls
Device Drivers
Voltage Levels/Magnetic Domains
Fully isolated from user programs
Computer Science 161
Example: Sending Mail
11
Alice
Bob
I am hungry.
Computer Science 161
Example: Sending Mail
12
Alice
Bob
Send to: Bob
I am hungry.
Computer Science 161
Example: Sending Mail
13
Alice
Bob
Mail to: 123 Bob St
Send to: Bob
I am hungry.
Computer Science 161
Example: Sending Mail
14
Alice
Bob
Mail to: 123 Bob St
Send to: Bob
I am hungry.
Computer Science 161
Example: Sending Mail
15
Alice
Bob
Send to: Bob
I am hungry.
Computer Science 161
Example: Sending Mail
16
Alice
Bob
I am hungry.
Computer Science 161
Example: Sending Mail
17
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
OSI Model
18
Application
Transport
(Inter) Network
Link
Physical
1
2
3
4
7
Computer Science 161
Layer 1: Physical Layer
19
Physical
1
Application
Transport
(Inter) Network
Link
2
3
4
7
Computer Science 161
Layer 1: Physical Layer
20
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
21
Physical
1
Application
Transport
(Inter) Network
3
4
7
Link
2
Computer Science 161
Layer 2: Link Layer
22
Source: A
Destination: C
“Hello, this is A…”
A
B
D
C
Computer Science 161
Layer 2: Link Layer
23
Source: A
Dest: C
“Hello, this is A…”
A
B
C
D
E
Computer Science 161
Ethernet and MAC Addresses
Ethernet header
24
Source MAC Address (6 bytes) | |||||
Destination MAC Address (6 bytes) | |||||
VLAN Tag (4 bytes) | Type (2 bytes) | ||||
Data (variable-length) | |||||
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)
IPv4 header
32
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
Internet Protocol (IP)
33
Computer Science 161
Reliability
34
Computer Science 161
Layer 3: Network Layer
35
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
36
Physical
1
Application
7
Link
2
(Inter) Network
3
Transport
4
Computer Science 161
Layer 4: Transport Layer
37
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
38
Physical
1
Link
2
(Inter) Network
3
Transport
4
Application
7
Computer Science 161
Layers of Abstraction and Headers
39
Computer Science 161
Example: HTTP Request
40
HTTP
TCP
IP
Ethernet
Wires
HTTP
TCP
IP
Ethernet
Wires
GET / HTTP/1.1
...
Computer Science 161
Example: HTTP Request
41
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
42
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
43
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
44
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
45
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
46
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
47
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
48
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
49
HTTP
TCP
IP
Ethernet
Wires
HTTP
TCP
IP
Ethernet
Wires
GET / HTTP/1.1
...
Computer Science 161
Example: HTTP Request
50
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
51
Application
Transport
(Inter) Network
Link
Physical
1
2
3
4
7
Computer Science 161