10 Networking
10 Networking
10 Networking
Operating Systems
Brad Campbell – [email protected]
https://www.cs.virginia.edu/~bjc8c/class/cs6456-f19/
1
Transport services and protocols
applicatio
n
provide logical communication transport
network
between app processes data link
running on different hosts physical
lo
transport protocols run in end
gi
ca
systems
enl
d-
• send side: breaks app
to
-e
messages into
nd
tra
segments, passes to
ns
network layer
po
rt
• rcv side: reassembles applicatio
segments into n
transport
3-5
TCP seq. numbers, ACKs
outgoing segment from sender
sequence numbers: source port # dest port #
sequence number
• byte stream “number” acknowledgement
of first byte in number rwnd
checksum urg pointer
segment’s data
window size
acknowledgements: N
• seq # of next byte
expected from other
sender sequence number space
side
• cumulative ACK sent sent, not- usable not
ACKed yet ACKed but not usable
Q: how receiver handles out- (“in- yet sent
of-order segments flight”)
incoming segment to sender
• A: TCP spec doesn’t source port # dest port #
say, - up to sequence number
acknowledgement
implementer number A rwnd
checksum urg pointer
3-6
TCP seq. numbers, ACKs
Host A Host B
User
types
‘C’ Seq=42, ACK=79, data = ‘C’
host ACKs
receipt of
‘C’, echoes
Seq=79, ACK=43, data = ‘C’ back ‘C’
host ACKs
receipt
of echoed
‘C’ Seq=43, ACK=80
3-7
TCP: retransmission scenarios
Host A Host B Host A Host B
SendBase=92
Seq=92, 8 bytes of data Seq=92, 8 bytes of data
timeout
timeout
Seq=100, 20 bytes of data
ACK=100
X
ACK=100
ACK=120
SendBase=120
timeout ACK=100
ACK=100
ACK=100
ACK=100
time
3-11
TCP Slow Start
Host A Host B
when connection
begins, increase rate
exponentially until one segm
ent
RTT
first loss event:
• initially cwnd = 1 MSS two segm
ents
• double cwnd every RTT
• done by incrementing
four segm
cwnd for every ACK ents
received
summary: initial rate
is slow but ramps up
time
exponentially fast
3-12
Why is TCP fair?
two competing sessions:
additive increase gives slope of 1, as throughout increases
multiplicative decrease decreases throughput proportionally
R
Connection 2 throughput equal bandwidth share
Connection 1 throughput R
3-13
Network layer: data plane, control plane
link layer
physical layer
4-15
IPv4 datagram format
IP protocol version 32 bits
number total datagram
header length type of length (bytes)
ver head. length
(bytes) len service for
“type” of data fragment fragmentation/
16-bit identifier flgs
offset reassembly
max number time to upper header
remaining hops live layer checksum
(decremented at
32 bit source IP address
each router)
32 bit destination IP address
upper layer protocol
to deliver payload to options (if any) e.g. timestamp,
record route
how much data taken, specify
overhead? (variable length, list of routers
20 bytes of TCP typically a TCP to visit.
20 bytes of IP or UDP segment)
= 40 bytes + app
layer overhead
4-16
IPv4 addressing: introduction
223.1.1.1
• interface:
connection between 223.1.3.27
223.1.1.3
host/router and physical 223.1.2.2
link
• router’s typically have multiple
interfaces
223.1.3.1 223.1.3.2
• host typically has one or two
interfaces (e.g., wired Ethernet,
wireless 802.11)
• IP addresses 223.1.1.1 = 11011111 00000001 00000001 00000001
associated with each
interface 223 1 1 1
4-17
IPv4 addressing: CIDR
4-18
How many IPv4 addresses are left?
• https://ipv4.potaroo.net
Available /8 address blocks
4-19
NAT: network address translation
10.0.0.4
10.0.0.2
138.76.29.7
10.0.0.3
data
32 bits
4-22
IPv6 Addresses
• Similar to IPv4 addresses, but 128 bits
• Example:
• 2601:5c2:300:c062:14a7:efa1:78b5:e8a
• CIDR still applies:
• 2601:5c2:300:c062:14a7:efa1:78b5:e8a/64
prefix
• Subnets are commonly 64 bits!
A local network can support 264 devices.
• No need for DHCP (although it still exists)
• Devices can choose their own address
(stateless autoconfiguration). Collisions are
unlikely with 264 addresses.
• Zero groups can be omitted:
• 2601:0000:0000:0000:0000:0000:0000:0008/16
• 2601::8/16
4-23
IPv6: adoption
• Google: 25% of clients access
services via IPv6 (Jan, 2019)
• NIST: 1/3 of all US government
domains are IPv6 capable
• Long (long!) time for deployment,
use
•20 years and counting!
•think of application-level changes in last 20
years: WWW, Facebook, streaming media, Skype,
…
4-24
IPv6: adoption (2019 update)
4-25
IPv6 for IoT?
• Reality: already 10s of billions of
devices
• IPv6 address space (2128) would enable
an IP address per device.
• IoT devices could directly interact with
the Internet, and use familiar protocols.
• However, power and software
complexity issues make it challenging
to run full IPv6 stacks on IoT devices.
• Security challenges?
• Networking challenges? 4-26
https://twitter.com/_inherlane/status/1034430721971118081 27
Socket programming with TCP
client must contact server • when contacted by client, server
• server process must first be TCP creates new socket for server
running process to communicate with that
particular client
• server must have created socket
• allows server to talk with
(door) that welcomes client’s
multiple clients
contact
• source port numbers used to
client contacts server by: distinguish clients (more in
• creating TCP socket, specifying Chap 3)
IP address, port number of
server process application viewpoint:
• when client creates socket: TCP provides reliable, in-order
client TCP establishes
byte-stream transfer (“pipe”)
connection to server TCP between client and server
2-28
Client/server socket interaction: TCP
server (running on hostid) client
create socket,
port=x, for incoming request:
serverSocket = socket()
write reply to
connectionSocket read reply from
clientSocket
close
connectionSocket close
clientSocket
2-29
Example app: Python TCP client
2-30
Example app: Python TCP server
2-31
HTTP overview
HTTP: hypertext
transfer protocol HT
TP
• Web’s application layer req
ues
protocol PC running HT t
Firefox browser TP
• client/server model res
pon
se
• client: browser that
requests, receives, st
ue
(using HTTP re q
e server
TP ns running
protocol) and HT
res
po
“displays” Web HT TP Apache Web
server
objects
• server: Web server
iphone running
sends (using HTTP Safari browser
protocol) objects in
response to requests
2-32
HTTP overview (continued)
HTTP/1.0: HTTP/1.1:
• GET • GET, POST, HEAD
• POST • PUT
• HEAD • uploads file in entity
• asks server to leave body to path
requested object out specified in URL
of response field
• DELETE
• deletes file specified
in the URL field
2-34
HTTP request message
• two types of HTTP messages: request, response
• HTTP request message:
• ASCII (human-readable format)
2-38
DNS: services, structure
DNS services why not centralize DNS?
• hostname to IP address • single point of failure
translation • traffic volume
• host aliasing • distant centralized database
• canonical, alias names • maintenance
• mail server aliasing A: doesn’t scale!
• load distribution
• replicated Web
servers: many IP
addresses correspond
to one name
2-39
DNS: a distributed, hierarchical database
Root DNS Servers
… …
2-40
DNS name root DNS server
resolution example
2
• host at cs.virginia.edu 3
TLD DNS server
wants IP address for 4
cs.berkeley.edu 5
cs.berkeley.edu
(23.253.180.102)
2-41
DNS records
DNS: distributed db storing resource records (RR)
RR format: (name, value, type, ttl)
type=A type=CNAME
name is hostname name is alias name for some
value is IP address “canonical” (the real) name
www.ibm.com is really
type=NS
• name is domain (e.g., servereast.backup2.ibm.c
foo.com) om
• value is hostname of value is canonical name
authoritative name server for type=MX
this domain value is name of mailserver
associated with name
2-42
DNS protocol, messages
• query and reply messages, both with same message format
2 bytes 2 bytes
2-43
Puzzle: DNS True/False