Networking
CS 4410 Operating Systems
[R. Agarwal, L. Alvisi, A. Bracy, M. George, Kurose, Ross, E. Sirer, R. Van Renesse]
Introduction Application Layer Transport Layer Network Layer - - PowerPoint PPT Presentation
Networking CS 4410 Operating Systems [R. Agarwal, L. Alvisi, A. Bracy, M. George, Kurose, Ross, E. Sirer, R. Van Renesse] Introduction Application Layer Transport Layer Network Layer Remote Procedure Calls 2 Basic Network Abstraction
[R. Agarwal, L. Alvisi, A. Bracy, M. George, Kurose, Ross, E. Sirer, R. Van Renesse]
2
3
4
5
6
Network-aware applications, clients & servers
Translation between network and application formats (e.g., RPC packages, sockets)
Connection management
Data transfer, reliability, packetization, retransmission. Lets multiple apps share 1 network connection
Path determination across multiple network segments, routing, logical addressing.
Decides whose turn it is to talk, finds physical device on network.
Exchanges bits on the media (electrical, optical, etc.)
7
8
Application HTTP, FTP, DNS
(these^ are usually in libraries)
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
1 2 3 4 5 6 7
FROM: Tim 107 Hoy Rd Ithaca TO: Kim 100 Baker Dr Stockholm
Analogy by Shubham Dubey on Quora
11
1 2 3 4 5 6 7
FROM: Tim 107 Hoy Rd Ithaca TO: Kim 100 Baker Dr Stockholm
Ithaca Postman Stockholm Postman
1 2 3 4 5 6 7
FROM: Tim 107 Hoy Rd Ithaca TO: Kim 100 Baker Dr Stockholm FROM: Tim 107 Hoy Rd Ithaca TO: Kim 100 Baker Dr Stockholm FROM: Tim 107 Hoy Rd Ithaca TO: Kim 100 Baker Dr Stockholm FROM: Tim 107 Hoy Rd Ithaca TO: Kim 100 Baker Dr Stockholm
Ithaca Sorting Office
12
Ithaca Sorting Office Stockholm Sorting Office
1
FROM: Tim 107 Hoy Rd Ithaca TO: Kim 100 Baker Dr Stockholm
TO: Stockholm Sorting Office
13
1 2 3 4 5 6 7
FROM: Tim 107 Hoy Rd Ithaca TO: Kim 100 Baker Dr Stockholm FROM: Tim 107 Hoy Rd Ithaca TO: Kim 100 Baker Dr Stockholm FROM: Tim 107 Hoy Rd Ithaca TO: Kim 100 Baker Dr Stockholm FROM: Tim 107 Hoy Rd Ithaca TO: Kim 100 Baker Dr Stockholm
Ithaca Sorting Office
2
14
datagrams
Ports (http: 80, DNS: 53, Telnet: 23) IP addresses (192.168.100.254) MAC Addresses (00:12:F4:AB:0C:82)
15
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
16
Transport src & dst ports + … Network
src & dest IP addr + …
Link
src & dest MAC addr + …
17
Why burden the network with properties that can, and must, be implemented at the periphery?
18
19
20
21
by Jim Kurose, Keith Ross
22
and reuse the same IP address
when you change your ISP
23
Distributed, Hierarchical Database
communicate to resolve names
Not to be confused with dots in IP addresses (in which the order of least significant to most significant is reversed)
24
.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
… …
25
(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
www.amazon.com
26
27
28
application transport network link physical application transport network link physical
29
internet
process
process
30
31
32
33
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 modified data to clientAddr via serversocket receive message (and serverAddr) from clientsocket modify data 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 modifiedMessage, serverAddress = clientSocket.recvfrom(2048) print(modifiedMessage.decode()) clientSocket.close()
34
35
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)
36
37
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 modified data to clientAddr via connectionsocket receive message from clientsocket modify data 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 modifiedMessage, serverAddress = clientSocket.recvfrom(1024) print(modifiedMessage.decode()) clientSocket.close()
38
39
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()
40
by Jim Kurose, Keith Ross
41
application transport network link physical application transport network link physical
42
43
44
src IP addr | dst IP addr src port # | dst port #
45
application transport network link physical
P1 P2
53 80
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 80 | 9157 53 | 5775
C | B
src dst
A | B
src dst
46
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 80 9157 5775
9157| 80 5775| 53
47
C | B
src dst
A | B
src dst
48
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
49
32 bits
50
51
52
53
54
32 bits
source port # dest port # sequence number acknowledgment number HL U A P R S F receive window checksum urg data pointer
application message (payload)
55
S Y N , A C K
S Y N A C K
S Y N
I would tell you a joke about TCP... If only to be acknowledged 😣
56
57
58
application transport network link physical
P1
application transport network link physical
P4
application transport network link physical
P5
host: IP address A host: IP address C server: IP address B
915 B| 80 A|915
P2 P6
517 915
P3
B| 80 C|517 B| 80 C|915
915 | 80 A | B 915 | 80 C | B 517 | 80 C | B
src dst
59
60
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
61
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
62
63
64
data packetà ß ack packet data packetsà ß ack packets
65
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
66
67
data 17 ack 17 a c k 1 7 a c k 1 7 data 18 data 19 data 20 data 18 data 18 ack 20 ack 20 X
68
data 17 ack 17 a c k 1 7 a c k 1 7 data 18 data 19 data 20 data 18 data 18 ack 20 ack 20 X data 21
69
Time Bandwidth Max Bandwidth
70
71
72
R R
Connection 1 throughput C
n e c t i
2 t h r
g h p u t
73
Host A
RTT
Host B time
two segments four segments
74
Time Bandwidth Max Bandwidth
75
77
78
79
80
81
82
83
84
85
86
87
88
89
91
92
93
94
95
96
from: http://if-we.clients.labzero.com/code/posts/what-title-ii-means-for-tcp/
97
98
“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”
99
address and respond with that
100
“What is the physical address of the host named 128.84.96.89”
“I’m at 1a:34:2c:9a:de:cc”
101
102
Version IHL TOS Total Length Identification Flags Fragment Offset TTL Protocol Header Checksum Source Address Destination Address Options Payload 103
1 2 3
104
105
106
not implemented
107
109
110
111
112
113
114
115
116
117
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
118
119
120
121
122
123
NIC (your laptop) 192.168.1.100 NIC (Google) 74.125.141.147 NIC 128.84.34.124 NIC 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
124
125
Presentation (ish)
by Andrew Tanenbaum & Maarten van Steen
126
127
128
129
130
[Tanenbaum & van Steen, Fig
Basic idea:
call details are hidden in libraries)
131
[Tanenbaum & van Steen, Fig (typically blocked on receive() at first)
132 call foo(x,y) proc foo(a,b)
client program
call foo
call foo(x,y) proc foo(a,b) begin foo... end foo
server stub Server program call foo client stub
133 call foo(x,y) proc foo(a,b) call foo(x,y) proc foo(a,b) begin foo... end foo
(1) calls local stub fn (3) sends msg to remote node (6) does the work! (5) unpacks params, makes call (4) receives msg, calls stub call foo send msg call foo msg received (2) builds msg, calls OS
134 call foo(x,y) proc foo(a,b) call foo(x,y) proc foo(a,b) begin foo... end foo
client continues (3) unpacks msg, returns to client (4) receives msg, gives to stub (1) returns result to stub (2) packs result in msg, calls OS (3) responds to original msg return msg received return send msg
135
Stub compiler
each server procedure: (1) client-side stub (2) a server-side stub
136
137
DCE = Distributed Computing Environment
138
139
140
[Tanenbaum & van Steen, Fig
141
142
143
144
145
146
147
+ easy: no response? A re-sends − only works for idempotent functions − server operations must be stateless
− requires server to detect duplicate packets + works for non-idempotent functions
148
149
150