ce80n introduction to networks & the internet
DESCRIPTION
CE80N Introduction to Networks & The Internet. Dr. Chane L. Fullmer UCSC Winter 2002. Next Week…. Jan 29 (T) Inside the Internet Chapter 17, Clients + Servers = Distributed Computing Chapter 18, Names for Computers Due Jan 29: Written Assignment #1 Web search engine evaluation - PowerPoint PPT PresentationTRANSCRIPT
CE80NCE80NIntroduction to NetworksIntroduction to Networks
&&The InternetThe Internet
Dr. Chane L. Fullmer
UCSC
Winter 2002
January 24, 2002 CE80N -- Lecture #7 2
Next Week…Next Week…
Jan 29 (T) Inside the Internet– Chapter 17, Clients + Servers = Distributed
Computing– Chapter 18, Names for Computers
Due Jan 29: Written Assignment #1 Web search engine evaluation
(10% of course grade)Jan 31 (Th) Midterm Exam
(20% of course grade)
January 24, 2002 CE80N -- Lecture #7 3
ReadingReading
Chapter 16 – – TCP: Software For Reliable Communications
Chapter 19 –– Why The Internet Works Well
January 24, 2002 CE80N -- Lecture #7 4
A Packet Switching System Can A Packet Switching System Can Be OverrunBe Overrun
Packet switching allows multiple computers to communicate without initial delay.– Requires that the computers divide data
into small packets– Requires additional communication
software to ensure that data is delivered reliably.
Figure 16.1 An example internet with four networks connected by routers.
Figure 16.2 Cars from two roads merging onto another road are analogous to packets from two networks merging onto a third network.
January 24, 2002 CE80N -- Lecture #7 6
Transport LayerTransport LayerOur goals: understand
principles behind transport layer services:– multiplexing– demultiplexing– reliable data transfer– flow control– congestion control
instantiation and implementation in the Internet
Overview: transport layer services multiplexing/demultiplexing connectionless transport: UDP principles of reliable data
transfer connection-oriented transport:
TCP– reliable transfer– flow control– connection management
principles of congestion control
TCP congestion control
January 24, 2002 CE80N -- Lecture #7 7
Transport services and protocolsTransport services and protocols
provide logical communication between processes running on different hosts
transport protocols run in end systems
transport vs network layer services:– network layer: data transfer
between end systems
– transport layer: data transfer between processes
• relies on, enhances, network layer services
application
transportnetworkdata linkphysical
application
transportnetworkdata linkphysical
networkdata linkphysical
networkdata linkphysical
networkdata linkphysical
networkdata linkphysicalnetwork
data linkphysical
logical end-end transport
January 24, 2002 CE80N -- Lecture #7 8
Transport-layer protocolsTransport-layer protocols
Internet transport services: reliable, in-order unicast
delivery (TCP)– congestion
– flow control
– connection setup unreliable (“best-effort”),
unordered unicast or multicast delivery: UDP
services not available: – real-time
– bandwidth guarantees
– reliable multicast
application
transportnetworkdata linkphysical
application
transportnetworkdata linkphysical
networkdata linkphysical
networkdata linkphysical
networkdata linkphysical
networkdata linkphysicalnetwork
data linkphysical
logical end-end transport
January 24, 2002 CE80N -- Lecture #7 9
applicationtransportnetwork
MP2
applicationtransportnetwork
Multiplexing/demultiplexingMultiplexing/demultiplexingSegmentSegment - unit of data
exchanged between
transport layer entities – aka TPDU: transport
protocol data unit receiver
HtHn
Demultiplexing: delivering received segments to correct app layer processes
segment
segment Mapplicationtransportnetwork
P1M
M MP3 P4
segmentheader
application-layerdata
January 24, 2002 CE80N -- Lecture #7 10
Multiplexing/demultiplexingMultiplexing/demultiplexing
multiplexing/demultiplexing: based on sender, receiver
port numbers, IP addresses– source, dest port #s in
each segment– Note: well-known port
numbers for specific applications
gathering data from multiple app processes, encapsulatingdata with header (later used for demultiplexing)
source port # dest port #
32 bits
applicationdata
(message)
other header fields
TCP/UDP segment format
Multiplexing:
January 24, 2002 CE80N -- Lecture #7 11
source port: xdest. port: 23
Multiplexing/demultiplexing: examplesMultiplexing/demultiplexing: examples
host A server B
source port:23dest. port: x
port use: simple telnet app
Web clienthost A
Webserver B
Web clienthost C
Source IP: CDest IP: B
source port: x
dest. port: 80
Source IP: CDest IP: B
source port: y
dest. port: 80
port use: Web server
Source IP: ADest IP: B
source port: x
dest. port: 80
January 24, 2002 CE80N -- Lecture #7 12
UDP: User Datagram Protocol UDP: User Datagram Protocol [RFC 768][RFC 768]
“no frills,” “bare bones” Internet transport protocol
“best effort” service, UDP segments may be:– lost– delivered out of order
to app connectionless:
– no handshaking between UDP sender, receiver
– each UDP segment handled independently of others
Why is there a UDP? no connection
establishment (which can add delay)
simple: no connection state at sender, receiver
small segment header no congestion control:
UDP can blast away as fast as desired
January 24, 2002 CE80N -- Lecture #7 13
UDP: moreUDP: more
often used for streaming multimedia apps– loss tolerant– rate sensitive
other UDP uses:– DNS– SNMP
reliable transfer over UDP: add reliability at application layer– application-specific
error recover!
source port # dest port #
32 bits
Applicationdata
(message)
UDP segment format
length checksumLength, in
bytes of UDPsegment,including
header
January 24, 2002 CE80N -- Lecture #7 14
UDP checksumUDP checksum
Sender: treat segment contents
as sequence of 16-bit integers
checksum: addition (1’s complement sum) of segment contents
sender puts checksum value into UDP checksum field
Receiver: compute checksum of
received segment check if computed
checksum equals checksum field value:– NO - error detected– YES - no error detected.
But maybe errors nonetheless?
Goal: detect “errors” (e.g., flipped bits) in transmitted segment
January 24, 2002 CE80N -- Lecture #7 15
TCP Helps IP Guarantee TCP Helps IP Guarantee DeliveryDelivery
When hardware in a router or network system fails, other routers start sending datagrams.
As a result, some datagrams:– Arrive in a different order
than they were sent– Checked by TCP – Put in order– Checked for duplicates by TCP
January 24, 2002 CE80N -- Lecture #7 16
TCP Provides A Connection TCP Provides A Connection Between Computer ProgramsBetween Computer Programs
TCP software makes it possible for two computer programs to communicate across the Internet.– Establishes a connection– Exchanges data– Terminates communication
January 24, 2002 CE80N -- Lecture #7 17
The Magic Of Recovering Lost The Magic Of Recovering Lost DatagramsDatagrams
TCP includes an identification of each datagram.– Ignores duplicate copies– Recovers lost datagrams
• Uses timers• Sends an acknowledgement
back to the source
January 24, 2002 CE80N -- Lecture #7 18
TCP Retransmission Is TCP Retransmission Is AutomaticAutomatic
TCP adapts to work everywhere on the Internet– Retransmits after a short time if destination
computer is close– Retransmits after a longer period
if destination computer is far– Measures delays– Adjusts the timeout factor automatically
January 24, 2002 CE80N -- Lecture #7 19
Go-Back-NGo-Back-NSender: k-bit seq # in pkt header “window” of up to N, consecutive unack’ed pkts allowed
ACK(n): ACKs all pkts up to, including seq # n - “cumulative ACK”
– may receive duplicate ACKs (see receiver) timer for each in-flight pkt timeout(n): retransmit pkt n and all higher seq # pkts in window
January 24, 2002 CE80N -- Lecture #7 20
GBN: receiverGBN: receiver
receiver simple: ACK-only: always send ACK for correctly-
received pkt with highest in-order seq #– may generate duplicate ACKs– need only remember expectedseqnum
out-of-order pkt: – discard (don’t buffer) -> no receiver buffering!– ACK pkt with highest in-order seq #
January 24, 2002 CE80N -- Lecture #7 22
Selective RepeatSelective Repeat
receiver individually acknowledges all correctly received pkts– buffers pkts, as needed, for eventual in-order delivery
to upper layer
sender only resends pkts for which ACK not received– sender timer for each unACKed pkt
sender window– N consecutive seq #’s– again limits seq #s of sent, unACKed pkts
January 24, 2002 CE80N -- Lecture #7 23
Selective repeat: sender, receiver windowsSelective repeat: sender, receiver windows
January 24, 2002 CE80N -- Lecture #7 24
Selective repeatSelective repeat
data from above : if next available seq # in
window, send pkt
timeout(n): resend pkt n, restart timer
ACK(n) in [sendbase,sendbase+N]:
mark pkt n as received if n smallest unACKed pkt,
advance window base to next unACKed seq #
sender
pkt n in [rcvbase, rcvbase+N-1]
send ACK(n) out-of-order: buffer in-order: deliver (also
deliver buffered, in-order pkts), advance window to next not-yet-received pkt
pkt n in [rcvbase-N,rcvbase-1]
ACK(n)
otherwise: ignore
receiver
January 24, 2002 CE80N -- Lecture #7 26
Selective repeat:Selective repeat: dilemma dilemmaExample: seq #’s: 0, 1, 2, 3 window size=3 receiver sees no
difference in two scenarios!
incorrectly passes duplicate data as new in (a)
Q: what relationship between seq # size and window size?
27
TCP: Overview TCP: Overview RFCs: 793, 1122, 1323, 2018, 2581RFCs: 793, 1122, 1323, 2018, 2581
full duplex data:– bi-directional data flow
in same connection– MSS: maximum
segment size
connection-oriented: – handshaking (exchange
of control msgs) init’s sender, receiver state before data exchange
flow controlled:– sender will not
overwhelm receiver
point-to-point:– one sender, one receiver
reliable, in-order byte steam:– no “message
boundaries”
pipelined:– TCP congestion and flow
control set window size
send & receive buffers
socketdoor
T C Psend buffer
T C Preceive buffer
socketdoor
segm ent
applicationwrites data
applicationreads data
January 24, 2002 CE80N -- Lecture #7 28
TCP segment structureTCP segment structure
source port # dest port #
32 bits
applicationdata
(variable length)
sequence number
acknowledgement numberrcvr window size
ptr urgent datachecksum
FSRPAUheadlen
notused
Options (variable length)
URG: urgent data (generally not used)
ACK: ACK #valid
PSH: push data now(generally not used)
RST, SYN, FIN:connection estab(setup, teardown
commands)
# bytes rcvr willingto accept
countingby bytes of data(not segments!)
Internetchecksum
(as in UDP)
January 24, 2002 CE80N -- Lecture #7 29
TCP seq. #’s and ACKsTCP seq. #’s and ACKs
Seq. #’s:– byte stream
“number” of first byte in segment’s data
ACKs:– seq # of next byte
expected from other side
– cumulative ACKQ: how receiver handles
out-of-order segments– A: TCP spec
doesn’t say, - up to implementor
time
Host A Host B
Seq=42, ACK=79, data = ‘C’
Seq=79, ACK=43, data = ‘C’
Seq=43, ACK=80
Usertypes
‘C’
host ACKsreceipt
of echoed‘C’
host ACKsreceipt of
‘C’, echoesback ‘C’
simple telnet scenario
January 24, 2002 CE80N -- Lecture #7 30
TCP: reliable data transferTCP: reliable data transfer
simplified sender, assuming
waitfor
event
waitfor
event
event: data received from application above
event: timer timeout for segment with seq # y
event: ACK received,with ACK # y
create, send segment
retransmit segment
ACK processing
•one way data transfer•no flow, congestion control
January 24, 2002 CE80N -- Lecture #7 31
TCP: TCP: reliable data reliable data transfertransfer
00 sendbase = initial_sequence number 01 nextseqnum = initial_sequence number 0203 loop (forever) { 04 switch(event) 05 event: data received from application above 06 create TCP segment with sequence number nextseqnum 07 start timer for segment nextseqnum 08 pass segment to IP 09 nextseqnum = nextseqnum + length(data) 10 event: timer timeout for segment with sequence number y 11 retransmit segment with sequence number y 12 compue new timeout interval for segment y 13 restart timer for sequence number y 14 event: ACK received, with ACK field value of y 15 if (y > sendbase) { /* cumulative ACK of all data up to y */ 16 cancel all timers for segments with sequence numbers < y 17 sendbase = y 18 } 19 else { /* a duplicate ACK for already ACKed segment */ 20 increment number of duplicate ACKs received for y 21 if (number of duplicate ACKS received for y == 3) { 22 /* TCP fast retransmit */ 23 resend segment with sequence number y 24 restart timer for segment y 25 } 26 } /* end of loop forever */
SimplifiedTCPsender
January 24, 2002 CE80N -- Lecture #7 32
TCP ACK generationTCP ACK generation [RFC 1122, RFC 2581][RFC 1122, RFC 2581]
Event
in-order segment arrival, no gaps,everything else already ACKed
in-order segment arrival, no gaps,one delayed ACK pending
out-of-order segment arrivalhigher-than-expect seq. #gap detected
arrival of segment that partially or completely fills gap
TCP Receiver action
delayed ACK. Wait up to 500msfor next segment. If no next segment,send ACK
immediately send singlecumulative ACK
send duplicate ACK, indicating seq. #of next expected byte
immediate ACK if segment startsat lower end of gap
January 24, 2002 CE80N -- Lecture #7 33
TCP: retransmission scenariosTCP: retransmission scenarios
Host A
Seq=92, 8 bytes data
ACK=100
loss
tim
eout
time lost ACK scenario
Host B
X
Seq=92, 8 bytes data
ACK=100
Host A
Seq=100, 20 bytes data
ACK=100
Seq=
92
tim
eout
time premature timeout,cumulative ACKs
Host B
Seq=92, 8 bytes data
ACK=120
Seq=92, 8 bytes data
Seq=
10
0 t
imeou
t
ACK=120
January 24, 2002 CE80N -- Lecture #7 34
TCP Flow ControlTCP Flow Control
receiver: explicitly informs sender of (dynamically changing) amount of free buffer space – RcvWindow field
in TCP segmentsender: keeps the
amount of transmitted, unACKed data less than most recently received RcvWindow
sender won’t overrun
receiver’s buffers bytransmitting too
much, too fast
flow control
receiver buffering
RcvBuffer = size or TCP Receive Buffer
RcvWindow = amount of spare room in Buffer
January 24, 2002 CE80N -- Lecture #7 35
TCP Round Trip Time (RTT) & TimeoutTCP Round Trip Time (RTT) & Timeout
Q: how to set TCP timeout value?
longer than RTT– note: RTT will vary
too short: premature timeout– unnecessary
retransmissions too long: slow reaction
to segment loss
Q: how to estimate RTT? SampleRTT: measured time from
segment transmission until ACK receipt– ignore retransmissions,
cumulatively ACKed segments
SampleRTT will vary, want estimated RTT “smoothed”– use several recent
measurements, not just current SampleRTT
January 24, 2002 CE80N -- Lecture #7 36
TCP Round Trip Time and TimeoutTCP Round Trip Time and Timeout
EstimatedRTT = (1-x)*EstimatedRTT + x*SampleRTT– Exponential weighted moving average– influence of given sample decreases exponentially
fast– typical value of x: 0.1
Setting the timeout EstimtedRTT plus “safety margin” large variation in EstimatedRTT -> larger safety margin
Timeout = EstimatedRTT + 4*Deviation
Deviation = (1-x)*Deviation + x*|SampleRTT-EstimatedRTT|
January 24, 2002 CE80N -- Lecture #7 37
TCP Connection ManagementTCP Connection Management
Recall: TCP sender, receiver establish “connection” before exchanging data segments
initialize TCP variables:– seq. #s– buffers, flow control info
• (e.g. RcvWindow) client: connection initiator Socket clientSocket = new
Socket("hostname","port number"); server: contacted by client Socket connectionSocket =
welcomeSocket.accept();
Three way handshake:
Step 1: client end system sends TCP SYN control segment to server– specifies initial seq #
Step 2: server end system receives SYN, replies with SYNACK control segment
– ACKs received SYN– allocates buffers– specifies server-> receiver
initial seq. Step 3: client receives SYNACK,
replies with ACK– ACKs SYN
January 24, 2002 CE80N -- Lecture #7 38
TCP Connection Management (cont.)TCP Connection Management (cont.)
Closing a connection:
client closes socket: clientSocket.close();
Step 1: client end system sends TCP FIN control
segment to server
Step 2: server receives FIN, replies with ACK. Closes connection, sends FIN.
client
FIN
server
ACK
ACK
FIN
close
close
closed
tim
ed w
ait
January 24, 2002 CE80N -- Lecture #7 39
TCP Connection Management (cont.)TCP Connection Management (cont.)
Step 3: client receives FIN, replies with ACK.
– Enters “timed wait” - will respond with ACK to received FINs
Step 4: server, receives ACK. Connection closed.
client
FIN
server
ACK
ACK
FIN
closing
closing
closed
tim
ed w
ait
closed
January 24, 2002 CE80N -- Lecture #7 40
TCP Connection Management (cont)TCP Connection Management (cont)
TCP clientlifecycle
TCP serverlifecycle
January 24, 2002 CE80N -- Lecture #7 41
Principles of Congestion ControlPrinciples of Congestion Control
Congestion: informally: “too many sources sending too much
data too fast for network to handle” different from flow control! manifestations:
– lost packets (buffer overflow at routers)– long delays (queueing in router buffers)
a top-10 problem!
January 24, 2002 CE80N -- Lecture #7 42
Causes/costs of congestion: scenario 1Causes/costs of congestion: scenario 1 two senders,
two receivers one router,
infinite buffers no
retransmission large delays
when congested
maximum achievable throughput
January 24, 2002 CE80N -- Lecture #7 43
Causes/costs of congestion: scenario 2Causes/costs of congestion: scenario 2 four senders multihop paths timeout/retransmit
in
Q: what happens as and increase ?
in
January 24, 2002 CE80N -- Lecture #7 44
Causes/costs of congestion: scenario 2Causes/costs of congestion: scenario 2
Another “cost” of congestion: when packet dropped, any “upstream
transmission capacity used for that packet was wasted!
January 24, 2002 CE80N -- Lecture #7 45
Approaches towards congestion controlApproaches towards congestion control
End-end congestion control:
no explicit feedback from network
congestion inferred from end-system observed loss, delay
approach taken by TCP
Network-assisted congestion control:
routers provide feedback to end systems– single bit indicating
congestion– explicit rate sender
should send at
Two broad approaches towards congestion control:Two broad approaches towards congestion control:
January 24, 2002 CE80N -- Lecture #7 46
TCP Congestion ControlTCP Congestion Control end-end control (no network assistance) transmission rate limited by congestion window size, Congwin,
over segments:
w segments, each with MSS bytes sent in one RTT:
throughput = w * MSS
RTT Bytes/sec
Congwin
January 24, 2002 CE80N -- Lecture #7 47
TCP congestion control:TCP congestion control:
two “phases”– slow start– congestion avoidance
important variables:– Congwin– threshold: defines
threshold between two slow start phase, congestion control phase
“probing” for usable bandwidth: – ideally: transmit as fast
as possible (Congwin as large as possible) without loss
– increase Congwin until loss (congestion)
– loss: decrease Congwin, then begin probing (increasing) again
January 24, 2002 CE80N -- Lecture #7 48
TCP SlowstartTCP Slowstart
exponential increase (per RTT) in window size (not so slow!)
loss event: timeout (Tahoe TCP) and/or or three duplicate ACKs (Reno TCP)
initialize: Congwin = 1for (each segment ACKed) Congwin++until (loss event OR CongWin > threshold)
Slowstart algorithm Host A
one segment
RTT
Host B
time
two segments
four segments
January 24, 2002 CE80N -- Lecture #7 49
TCP Congestion AvoidanceTCP Congestion Avoidance
/* slowstart is over */ /* Congwin > threshold */Until (loss event) { every w segments ACKed: Congwin++ }threshold = Congwin/2Congwin = 1perform slowstart
Congestion avoidance
1
1: TCP Reno skips slowstart (fast recovery) after three duplicate ACKs
January 24, 2002 CE80N -- Lecture #7 50
AIMD: additive increase, multiplicative decrease
– increase window by 1 per RTT– decrease window by factor of 2 on loss event
TCP congestion avoidanceTCP congestion avoidance
January 24, 2002 CE80N -- Lecture #7 51
TCP FairnessTCP Fairness
Fairness goal: if N TCP sessions share same bottleneck link, each should be able to get 1/N of link capacity
TCP connection 1
bottleneckrouter
capacity RTCP connection 2
January 24, 2002 CE80N -- Lecture #7 52
Why is TCP fair?Why is TCP fair?
Two competing sessions: Additive increase gives slope of 1, as throughput increases multiplicative decrease decreases throughput proportionally
R
R
equal bandwidth share
Connection 1 throughputConnect
ion 2
th
roughput
congestion avoidance: additive increaseloss: decrease window by factor of 2
congestion avoidance: additive increaseloss: decrease window by factor of 2
January 24, 2002 CE80N -- Lecture #7 53
TCP And IP Work TogetherTCP And IP Work Together
TCP handles the problems that IP does not handle without duplicating the work that IP does.– Designed at the same time to work as a
unified system– Engineered to:
• Cooperate with each other• Compliment each other
January 24, 2002 CE80N -- Lecture #7 54
The Internet Works WellThe Internet Works Well
The Internet is a marvel of technical accomplishment.
TCP/IP:– Accommodates growth and change not
imagined
January 24, 2002 CE80N -- Lecture #7 55
IP Provides FlexibilityIP Provides Flexibility
IP provides the flexibility to accommodate underlying hardware.– Allows multiple vendors to produce:
• computers • routers that can communicate and
interoperate
January 24, 2002 CE80N -- Lecture #7 56
TCP Provides ReliabilityTCP Provides ReliabilityTCP provides reliability.
– Handles communication problems– Communicates in applications– Handles rapid changes in performance– Adapts to congestion automatically
January 24, 2002 CE80N -- Lecture #7 57
TCP/IP Software Was TCP/IP Software Was Engineered For EfficiencyEngineered For Efficiency
TCP/IP sends only the minimum network packets.
Runs well on all computers.
TCP/IP
January 24, 2002 CE80N -- Lecture #7 58
TCP/IP Research Emphasized TCP/IP Research Emphasized Practical ResultsPractical Results
Scientists built, tested, and measured working communication systems.
All new ideas were based on experimental evidence.
January 24, 2002 CE80N -- Lecture #7 59
Rough Consensus and Working Rough Consensus and Working CodeCode
TCP/IP arose from a consensus among researchers.– Accepted ideas only after implementation
and demonstration– Allowed designers to correct problems
early
January 24, 2002 CE80N -- Lecture #7 60
Formula For SuccessFormula For Success
The Internet was extremely successful.– Due to:
• Talented, dedicated research team• Experimentation without economic gain• Built to operate efficiently• Each part worked well in practice before
adopted as a standard
January 24, 2002 CE80N -- Lecture #7 61
SummarySummary
principles behind transport layer services:– multiplexing/demultiplexing– reliable data transfer– flow control– congestion control
instantiation and implementation in the Internet– UDP– TCP
January 24, 2002 CE80N -- Lecture #7 62
GlossaryGlossary
Congestion – A problem in computer networks that
occurs when too many packets arrive at a point in the network.
Transmission Control Protocol– (TCP) One of the two major TCP/IP
protocols. TCP handles the difficult task of ensuring that all data arrives at the destination in the correct order.
January 24, 2002 CE80N -- Lecture #7 63
GlossaryGlossary
IP– Specification for the format of packets
computers use when they communicate across the Internet
TCP– The name of protocols that specify how
computer communicate on the Internet UDP
– User Datagram Protocol – UDP is a connectionless protocol, providing unreliable end-to-end packet delivery