Networking
CS 4410 Operating Systems
[R. Agarwal, L. Alvisi, A. Bracy, M. George, Kurose, Ross, E. 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, Kurose, Ross, E. Sirer, R. Van Renesse] Introduction Application Layer Transport Layer Network Layer Remote Procedure Calls These slides are being posted far
[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
14
datagrams
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
18
21
by Jim Kurose, Keith Ross
reuse the same IP address
you change your ISP
23
Distributed, Hierarchical Database
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
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
logical end-end transport
application transport network link physical application transport network link physical
42
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
55
SYN S Y N , A C K
S Y N ACK of SYN
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 DATA, ACK FIN, ACK A C K
61
D A T A , s e q = 1 7 ack=17 DATA, seq=18 D A T A , s e q = 1 8 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, seq=17 ack=17 DATA, seq=18 DATA, seq=19 DATA, seq=20 ack=18 ack=19 ack=20 DATA, seq=21 DATA, seq=22 DATA, seq=23 DATA, seq=24
65
66
d a t a 1 7 ack 17 ack 17 ack 17 d a t a 1 8 d a t a 1 9 d a t a 2 d a t a 1 8 d a t a 1 8 ack 20 ack 20 X
68
Time Bandwidth Max Bandwidth
69
70
71
R R
Connection 1 throughput Connection 2 throughput
72
Host A
RTT
Host B time
two segments four segments
73
Time Bandwidth Max Bandwidth
74
75
76
by Jim Kurose, Keith Ross
application transport network data link physical application transport network data link physical network data link physical network data link physical network data link physical network data link physical network data link physical network data link physical network data link physical network data link physical network data link physical network data link physical network data link physical
77
78
line termination link layer protocol (receive) lookup, forwarding queueing
§ using header field values, lookup output port using forwarding table in input port memory (“match plus action”) § traditionally: forward based on destination IP address
physical layer: bit-level reception data link layer: e.g., Ethernet
switch fabric
79
line termination link layer protocol (send) switch fabric datagram buffer queueing
80
forwarding table
routing protocols
IP protocol
ICMP protocol
transport layer: TCP, UDP link layer physical layer
4-81 Network Layer: Data Plane
ver length 32 bits
data (variable length, typically a TCP
16-bit identifier header checksum time to live 32 bit source IP address head. len type of service flgs fragment
upper layer 32 bit destination IP address
IP protocol version number header length (bytes) upper layer protocol to deliver payload to total datagram length (bytes) type of data for fragmentation/ reassembly max number remaining hops (decremented at each router) e.g. timestamp, record route taken, specify list of routers to visit.
how much overhead?
v 20 bytes of TCP v 20 bytes of IP v = 40 bytes + app
layer overhead
4-82 Network Layer: Data Plane
fragmentation: in: one large datagram
reassembly
4-83 Network Layer: Data Plane
84
85
86
87
88
89
90
91
92
93
94
95
1 Initialization: 2 N' = {u} 3 for all nodes v 4 if v adjacent to u 5 then D(v) = c(u,v) 6 else D(v) = ∞ 7 8 Loop 9 find w not in N' such that D(w) is a minimum 10 add w to N' 11 update D(v) for all v adjacent to w & not in N' : 12 D(v) = min( D(v), D(w) + c(w,v) ) 13 /* new cost to v either: old cost to v or known 14 shortest path cost to w plus cost from w to v */ 15 until all nodes in N'
96
97
Step N' 1 2 3 4 5
D(z), p(z)
u
7,u 3,u 5,u uw ∞ 11,w 6,w 5,u 14,x 11,w 6,w uwx uwxv 14,x 10,v uwxvy 12,y uwxvyz
p(x): predecessor node along path from source to node x
D(y), p(y) D(x), p(x) D(w), p(w) D(v), p(v)
D(v): current cost of path from source to v
98
99
v1
v 3
100
101
102
X updates its own DV “If Y can get to Z in 1, then *I* can get to Z in 3!”
time Y sends X its DV
103
time
Y detects link-cost changes 2 à 1 Updates DV, broadcasts
X updates its own DV, broadcasts
104
“Well, I can’t reach Z anymore, but Y can do that in 1, so I can still get to Z in 3.” “Well, I can’t reach Z anymore, but X can do that in 3, so I can still get to Z in 5.” Next: Y sends X its new DV, X updates Y’s DV, reruns BF, x à z increases from 3 à 7 … Next…!!
105
106
107
108
109
110
111
Presentation (ish)
by Andrew Tanenbaum & Maarten van Steen
112
113
114
115
116
[Tanenbaum & van Steen, Fig 4-5]
117
[Tanenbaum & van Steen, Fig 4-6] (typically blocked on receive() at first)
118 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
119 call foo(x,y) proc foo(a,b) call foo(x,y) proc foo(a,b) begin foo... end foo
c l i e n t p r
r a m client stub RPC runtime RPC runtime server stub server program
(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
120 call foo(x,y) proc foo(a,b) call foo(x,y) proc foo(a,b) begin foo... end foo
client program client stub RPC runtime RPC runtime server stub server program
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
121
122
123
124
125
126
[Tanenbaum & van Steen, Fig 4-7]
127
128
129
130
131
132
133
134
135
136