Lecture 21: Networking & Protocol Stacks: CS 422/522 Design & Implementation of Operating Systems
Lecture 21: Networking & Protocol Stacks: CS 422/522 Design & Implementation of Operating Systems
Acknowledgement: some slides are taken from previous versions of the CS422/522 lectures taught by Prof. Bryan Ford
and Dr. David Wolinsky, and also from the official set of slides accompanying the OSPP textbook by Anderson and Dahlin.
Overview
• Introduction
– History, Basic Concepts
• Networking Fundamentals
– Layering, Internetworking, Addressing, Naming
• Internet Protocols
– Link Layer Protocols, IP, Transport Protocols (TCP, UDP)
• Network Programming
– BSD sockets
1
11/10/20
! History:
– 1960s: ARPAnet - Defense Advanced Research Projects
Agency
* research project into packet switching networks
* wanted communications infrastructure capable of exploiting redundancy
to route around damaged links
2
11/10/20
Internet model
! The Internet is a packet-switched network.
! All data transmission is broken into chunks
(packets).
! Each packet contains:
– the data to be transmitted (the payload)
– identification of the packet’s source and destination
! The key points to understand about packet
switching are:
– Each packet is processed independently of all other
packets.
– There is no need to set up a “connection” or “circuit” with
another node before sending it a packet.
3
11/10/20
Overview
• Introduction
– History, Basic Concepts
• Networking Fundamentals
– Layering, Internetworking, Addressing, Naming
• Internet Protocols
– Link Layer Protocols, IP, Transport Protocols (TCP, UDP)
• Network Programming
– BSD sockets
4
11/10/20
Ethernet
10
5
11/10/20
FTP Protocol
FTP client FTP server
TCP Protocol
TCP TCP
IP Protocol
IP IP
Ethernet
11
Internetworking
12
6
11/10/20
Routing
FTP Protocol
FTP client FTP server
TCP Protocol
TCP TCP
router
IP Protocol IP Protocol
IP IP IP
13
Routing, cont.
14
7
11/10/20
15
application data
TCP segment
Ethernet frame
16
8
11/10/20
Ethernet
driver
Ethernet frame
17
IP Addressing
18
9
11/10/20
IP Addressing, cont.
7 bits 24 bits
Class A 0 netid hostid
14 bits 16 bits
Class B 10 netid hostid
21 bits 8 bits
Class C 11 0 netid hostid
28 bits
Class D 11 1 0 multicast group ID
27 bits
Class E 11 1 1 0 reserved for future use
19
IP Addressing, cont.
20
10
11/10/20
21
22
11
11/10/20
DNS - Concepts
23
DNS, cont.
selenium.cchem.berkeley.edu
24
12
11/10/20
ns.cchem.berkeley.edu
…
cesium.cchem.berkeley.edu
6
selenium.cchem.berkeley.edu
…
25
Overview
• Introduction
– History, Basic Concepts
• Networking Fundamentals
– Layering, Internetworking, Addressing, Naming
• Internet Protocols
– Link Layer Protocols, IP, Transport Protocols (TCP, UDP)
• Network Programming
– BSD sockets
26
13
11/10/20
27
28
14
11/10/20
29
30
15
11/10/20
32-bit IP Address
ARP RARP
physical address
! Key Points:
– ARP and RARP work by broadcasting a query on the local
network.
– ARP and RARP are network-layer protocols, in parallel to
IP in layering diagrams.
– RARP is only used by a machine at boot-time to discover
its own IP address.
31
32
16
11/10/20
! IP is a
stateless,
connectionless,
unordered,
unreliable,
protocol. More sophisticated facilities such as logical
connections and reliability are provided by higher layers.
33
IP – basic concepts
34
17
11/10/20
35
Format of an IP datagram
data
36
18
11/10/20
37
38
19
11/10/20
39
40
20
11/10/20
41
TCP - implementation
42
21
11/10/20
43
UDP, Cont.
44
22
11/10/20
Overview
• Introduction
– History, Basic Concepts
• Networking Fundamentals
– Layering, Internetworking, Addressing, Naming
• Internet Protocols
– Link Layer Protocols, IP, Transport Protocols (TCP, UDP)
• Network Programming
– BSD sockets
45
Network programming
46
23
11/10/20
47
48
24
11/10/20
49
while (1) {
/* accept a new connection in clifd */
if ((clifd=accept(servfd,(struct sockaddr *) &cli_addr,
&clilen)) < 0) {
perror("accept");
exit(1);
}
printf("server accepted connection...\n");
done:
(void) close(clifd);
}
}
50
25