Networking
CS 4410 Operating Systems
[R. Agarwal, L. Alvisi, A. Bracy, M. George, F.B. Schneider, E.G. Sirer, R. Van Renesse]
Networking CS 4410 Operating Systems [R. Agarwal, L. Alvisi, A. - - PowerPoint PPT Presentation
Networking CS 4410 Operating Systems [R. Agarwal, L. Alvisi, A. Bracy, M. George, F.B. Schneider, E.G. Sirer, R. Van Renesse] Outline Big overall picture Then bottom-up 2 Basic Network Abstraction A process can create
[R. Agarwal, L. Alvisi, A. Bracy, M. George, F.B. Schneider, E.G. Sirer, R. Van Renesse]
2
3
4
5
6
Network-aware applications, clients & servers
Translation between network and application formats (e.g., RPC packages)
Connection management
Reliability, segmenting, retransmission. Multiple apps share 1 physical network connection
Path determination across multiple network segments, logical addressing
Decides whose turn it is to talk, finds physical device on network
Exchanges bits on the media (electrical, optical, etc.)
7
Application exchanges messages HTTP, FTP, DNS, SSH, Skype, … Transport Transports messages; exchanges segments TCP, UDP Network Transports segments; exchanges datagrams IP, ICMP (ping) Link Transports datagrams; exchanges frames Ethernet, WiFi Physical Transports frames; exchanges bits wires, signal encoding
8
Application HTTP, FTP, DNS Transport TCP, UDP Network IP, ICMP (ping) Link Ethernet, WiFi Physical wires, signal encoding
physical transmission
controller CPU memory bus NIC OS
app app
9
10
11
datagrams
Ports (http: 80, DNS: 53, Telnet: 23) IP addresses (192.168.100.254) MAC Addresses (00:12:F4:AB:0C:82) Application-specific multiplexing
12
Router1 Router2
datagrams
network link physical application transport network link physical
HT message
M
application transport network link physical M
segment HT
M
HN datagram HT
M
HN HL frame HT
M
HN HL HT
M
HN HT
M
HN HT
M
HN HL HT
M
HN HL HT
M
HN
M
HT
M
13
Transport
src & dst ports + …
Network
src & dest IP addr + …
Link
src & dest MAC addr + …
14
Why burden the network with properties that can, and must, be implemented at the periphery?
15
16
18
19
20
21
22
23
24
25
26
27
28
29
30
32
33
34
35
36
37
from: http://if-we.clients.labzero.com/code/posts/what-title-ii-means-for-tcp/
38
39
DHCP is used to learn IP address and subnet mask (and more)
DHCP = Dynamic Host Configuration Protocol
“I just got here. My physical address is 1a:34:2c:9a:de:cc. What’s my IP?”
“Your IP is 128.84.96.89 for the next 24 hours”
40
and respond with that
case
41
“What is the physical address of the host named 128.84.96.89”
“I’m at 1a:34:2c:9a:de:cc”
42
43
Version IHL TOS Total Length Identification Flags Fragment Offset TTL Protocol Header Checksum Source Address Destination Address Options Payload 44
1 2 3
45
46
47
50
51
52
53
54
55
56
57
58
datagrams
Ports (http: 80, DNS: 53, Telnet: 23) IP addresses (192.168.100.254) MAC Addresses (00:12:F4:AB:0C:82) Application-specific multiplexing
59
60
Address IF or Port MAC 128.84.216/23 en0 c4:2c:03:28:a1:39 127/8 lo0 127.0.0.1 128.84.216.36/32 en0 74:ea:3a:ef:60:03 128.84.216.80/32 en0 20:aa:4b:38:03:24 128.84.217.255/32 en0 ff:ff:ff:ff:ff:ff
61
62
63
64
65
66
NIC (your laptop) 192.168.1.100 NIC (Google) 74.125.141.147 NIC 2 (outside) 128.84.34.124 NIC 1 (inside) 192.168.1.1
dst: 74.125.141.147:80 src: 192.168.1.100:4410 dst: 74.125.141.147:80 src: 128.84.34.124:123
67
68
69
by Jim Kurose, Keith Ross
segments, passes to network layer
passes to application layer
70
logical end-end transport
application transport network link physical application transport network link physical
71
72
74
src IP addr | dst IP addr src port # | dst port #
75
application transport network link physical
P1 P2
53 87
port
application transport network link physical
P3
9157
application transport network link physical
P4
host: IP address A host: IP address C server: IP address B 5775
B | C
src dst
B | A
src dst
87 | 9157 53 | 5775
C | B
src dst
A | B
src dst
76
application transport network link physical
P1 P2
application transport network link physical
P3
application transport network link physical
P4
host: IP address A host: IP address C server: IP address B 53 87 9157 5775 9157| 87 5775| 53
77
C | B
src dst
A | B
src dst
78
application transport network link physical
P1
application transport network link physical
P3
application transport network link physical
P4
host: IP address A host: IP address C server: IP address B
9157 5775 6428
9157| 6428 5785| 6428
79
32 bits
80
81
82
83
32 bits
source port # dest port # sequence number acknowledgment number HL U A P R S F receive window checksum urg data pointer
payload
4410 simplification: assume all payloads of size 1
84
85
86
SYN S Y N , A C K
S Y N A C K
S Y N
87
88
90
SYN SYN, ACK of SYN ACK of SYN DATA D A T A , A C K F I N , A C K A C K
91
D A T A , s e q = 1 7 ack=17 DATA, seq=18 DATA, seq=18 Send timeout
Here's a joke about TCP. Did you get it? Did you get it? Did you get it? Did you get it?
ack=18
92
93
à throughput goes to zero as L grows to infinity
94
95
data packetà ß ß ack packet data packetsà ß ß ack packets
96
DATA, seq=17 a c k = 1 7 DATA, seq=18 DATA, seq=19 DATA, seq=20 a c k = 1 8 a c k = 1 9 a c k = 2 DATA, seq=21 DATA, seq=22 DATA, seq=23 DATA, seq=24
97
+ Shares bandwidth well with other TCP connections
98
Time Bandwidth Max Bandwidth
99
100
101
R R
Connection 1 throughput Connection 2 throughput
congestion avoidance: additive increase loss: decrease window by factor of 2 congestion avoidance: additive increase loss: decrease window by factor of 2
a window size that matches the link bandwidth*delay
à TCP spends a lot of time with small windows, never reaching large window size
102
Host A
RTT
Host B time
two segments four segments
103
Time Bandwidth Max Bandwidth
104
d a t a 1 7 ack 17 a c k 1 7 a c k 1 7 d a t a 1 8 d a t a 1 9 d a t a 2 d a t a 1 8 ack 20 X
105
106
by Jim Kurose, Keith Ross
reuse the same IP address
you change your ISP
107
Not to be confused with dots in IP addresses (in which the order of least significant to most significant is reversed)
108
.com DNS servers .org DNS servers .edu DNS servers cornell.edu DNS servers utexas.edu DNS servers yahoo.com DNS servers amazon.com DNS servers pbs.org DNS servers
… …
Contacted by local name server that cannot resolve top-level name
109
(5 other sites)
(41 other sites)
Palo Alto, CA (and 48 other sites)
OH (5 other sites)
13 root name “servers” worldwide
1. the client asks its local nameserver 2. the local nameserver asks one of the root nameservers 3. the root nameserver replies with the address of the authoritative nameserver 4. the server then queries that nameserver 5. repeat until host is reached, cache result. Example: Client wants IP addr of www.amazon.com 1. Queries root server to find com DNS server 2. Queries .com DNS server to get amazon.com DNS server 3. Queries amazon.com DNS server to get IP address for www.amazon.com
110
Simple, hierarchical namespace works well
to several IP addresses)
Q: Why not centralize?
A: Does not scale! What about security? (don’t ask!)
111
112
application transport network link physical application transport network link physical
113
internet
process
process
114
116
create socket:
create serversocket, bind to port x
create clientsocket create message send message to (serverIP, port x) via clientsocket read data (and clientAddr) from serversocket send response data to clientAddr via serversocket receive message (and serverAddr) from clientsocket close clientsocket
import socket #include Python’s socket library serverName = ‘servername’ serverPort = 12000 #create UPD socket clientSocket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) #get user input message = input('Input lowercase sentence: ‘) # send with server name + port clientSocket.sendto(message.encode(), (serverName, serverPort)) # get reply from socket and print it reply, serverAddress = clientSocket.recvfrom(2048) print(reply.decode()) clientSocket.close()
117
118
import socket #include Python’s socket library serverPort = 12000 #create UPD socket & bind to local port 12000 serverSocket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) serverSocket.bind(('', serverPort)) print("The server is ready to receive") while True: # Read from serverSocket into message, # getting client’s address (client IP and port) message, clientAddress = serverSocket.recvfrom(2048) print("received message: "+message.decode()) modifiedMsg = message.decode().upper() print("sending back to client") # send uppercase string back to client serverSocket.sendto(modifiedMsg.encode(), clientAddress)
119
120
create socket:
create welcoming serversocket, bind to port x
create clientsocket connect to (hostID, port x) create message send message via clientsocket read data from connectionsocket send response data to clientAddr via connectionsocket receive message from clientsocket close clientsocket in response to connection request, create connectionsocket close connectionsocket
import socket #include Python’s socket library serverName = ‘servername’ serverPort = 12000 #create TCP socket for server on port 12000 clientSocket = socket.socket(socket.AF_INET,socket.SOCK_STREAM) clientSocket.connect((serverName,serverPort)) #get user input message = input('Input lowercase sentence: ‘) # send (no need for server name + port) clientSocket.send(message.encode()) # get reply from socket and print it reply, serverAddress = clientSocket.recvfrom(1024) print(reply.decode()) clientSocket.close()
121
122
import socket #include Python’s socket library serverPort = 12000 #create TCP welcoming socket & bind to server port 12000 serverSocket = socket.socket(socket.AF_INET,socket.SOCK_STREAM) serverSocket.bind(('', serverPort)) #server begins listening for incoming TCP requests serverSocket.listen(1) print("The server is ready to receive") while True: # server waits on accept() for incoming requests # new socket created on return connectionSocket, addr = serverSocket.accept() message = connectionSocket.recv(1024).decode() print("received message: "+message) modifiedMsg = message.upper() # send uppercase string back to client connectionSocket.send(modifiedMsg.encode()) # close connection to this client, but not welcoming socket connectionSocket.close()