UDP, TCP - CSCI 6433 Internet Protocols

advertisement
CSCI 6433
Internet Protocols
Class 5
Dave Roberts
1
Internet Protocol Principles
0 Good Citizen Principle
0 When a resource is scarce, use less of it
0 Conservation of Router Time
0 Minimize the work done by routers
0 Soft State
0 Save information that takes traffic to obtain that might
be used again; age and replace it
2
Tonight
0 Network Address Translation (NAT)
0 User Datagram Protocol (UDP)
0 Reliable Stream Transfer Service (TCP)
3
NAT
0 Developed in order to extend life of IP address pool
0 Used these characteristics of Internet connections:
0 Most hosts are clients that don’t need to be publicly
accessible
0 Not all hosts access the Internet at the same time
0 Internet connections are routed
0 NAT shares globally unique IP addresses among the
hosts that are actually using an Internet connection
4
Analogy
0 Think of a NAT router as a company’s telephone
operator
0 Connects outside callers to local extensions
0 Connects local extensions to the outside network
5
NAT
0 Extends the pool of addresses
0 Creates a form of two-level addressing
0 Could be used even more widely to extend the pool of
IPv4 addresses
0 Does not allow for a server inside the NAT network to
hosts outside
0 Can be port-based or not
6
How It Works
7
Limitation
0 Traditional NAT is said to be “unidirectional”, allows
only for transactions originated inside the network
0 No allowance for a server inside the network that
serves users across the Internet
0 Domain Naming Services (DNS) can be used to make a
name visible outside the local network (to be
discussed)
8
On to UDP and TCP!
9
What Does IP Do?
0 Addressing
0 Data encapsulation
0 Fragmentation and reassembly
0 Routing/indirect delivery
10
UDP and TCP
11
Ports
0 Destination of a datagram is a program
0 Selection is by protocol port number
0 Messages carry source and destination port
numbers
0 UDP and TCP provide protocol ports, provide
ability to distinguish among destinations
within a given host
12
UDP and TCP in Operation
13
UDP--User Datagram Protocol
0 UDP provides unreliable, best-effort, connectionless
datagram delivery services to multiple destinations
within a single host computer, using IP to carry
messages
14
UDP Message Format
15
UDP Message Format
Question: How many
different UDP ports can there
be on a PC?
16
UDP Layering
Application programs access UDP, and
UDP uses IP to send and receive
datagrams
UDP message is encapsulated in an IP
datagram
18
UDP Demultiplexing
19
Question
0 What good is data that’s not delivered correctly?
0 Why would we want errors in data?
0 What is UDP used for?
0 Does ICMP use UDP?
20
Well-Known Port
Assignments
21
Summary
0 UDP is a “thin” protocol
0 Unreliable
0 Best-effort
0 Distinguishes between applications
0 16-bit port number is used
0 UDP lies in the transport layer
22
On to TCP!
23
What TCP Does
0 Addressing and multiplexing
0 Connection establishment, management and
termination
0 Data handling and packaging
0 Provides reliability and transmission quality services
0 Provides flow control and congestion avoidance
features
24
How TCP Does Its Job
0 Connection-oriented
0 Bidirectional
0 Multiply-connected
0 Reliable
0 Acknowledged
0 Stream-oriented
0 Data-unstructured
0 Data flow managed
25
Why Stream Delivery?
0 Using stream delivery protocol frees the application
from any concern about network delivery of data
0 Packets may arrive out of order
0 Packet data may contain errors
0 Application program doesn’t want to know optimal
packet size
26
TCP—Reliable Stream Transport
Service
0 Stream orientation—receiver gets the same sequence
of octets sent by the sender
0 Unstructured stream—no way to mark boundaries,
applications must use a stream
0 Virtual circuit connection—source and destination
operate at the same time, interact during the transfer
0 Buffered transfer—large blocks can be transferred,
fed to receiver as needed
0 Full duplex connection—communication can take
place in both directions
27
Reliable Delivery, Unreliable Transport
0 Ethernet is unreliable
0 IP is unreliable
0 But TCP, that runs over IP, is reliable
0 How?
28
Unreliable Transport
29
Positive Acknowledgement with
Retransmission
0 Sender starts a timer when sending, saves data
0 Receiver sends acknowledgement (ACK) when data
arrives successfully
0 When ACK arrives, sender cancels timer, deletes data
0 If timer expires, sender retransmits data, starts
another timer
30
Reliable Transport
31
Delays
A positive acknowledgement protocol
introduces a number of delays because it
delays sending a new packet until it receives
an acknowledgement for the previous packet.
32
Sliding Windows
To solve the problem, we use the sliding window
approach to decouple transmissions from reception of
acknowledgements.
The sender transmits multiple packets before waiting
for an acknowledgement. The number of packets is
said to be the window size.
33
Sliding Window Approach
34
Sliding Window Example
35
Enhanced Positive
Acknowledgement
36
Sliding Window Approach
Question: Suppose the IP link travels over a
very high-capacity satellite connection that
has ¼ second latency in each direction. What
is the effect on throughput if the window size
is set to 1? What if it is set to, say, 1,000?
37
TCP Protocol Enhancements
0 There are a number of protocol extensions
and hardware products designed to speed up
TCP in the presence of delays
0 Generally they involve some form of providing
ACKs to the sender before the receiver has
received the packet
0 The extension then has to provide some form
of retransmission itself, since TCP counts
success when it receives an ACK
38
TCP and UDP Layering
39
Ports and Connections
0 UDP uses the port as a queue to process incoming
data
0 TCP uses port numbers, but the port number is part of
identifying a connection
0 A connection is identified as a pair of pairs in the form
<host, port>
• Question: can two programs both use the
same TCP port on the same machine at once?
40
TCP Segments and Streams
Data stream divided into segments.
Window used to send multiple segments
before acknowledgement arrives. Allows
receiver to restrict transmission until it has
buffer space.
41
Flow Control
0 Each ack includes a window advertisement, giving
the number of additional octets the receiver is
willing to accept
0 Sender increases or decreases its window size
based on the window advertisement
0 The sliding window provides end-to-end flow
control
0 Congestion, that can occur at intermediate points,
is dealt with by congestion control mechanisms
42
MSS
0 MSS—maximum segment size is negotiated
0 MSS may be the MTU of a single connecting network,
if both ends are on the same network
0 MSS may be the MTU of path if sender and receiver
are on different networks
0 Risk of poor performance if MSS is too large or too
small
43
Problems with Wrong MSS
0 If too large: segments will be fragmented,
requiring extra network messages and routing
0 If too small: fixed size of TCP header, IP
header, Ethernet header all are still required
for a small amount of data
Question: what’s the right size for a
TCP segment?
44
TCP Segment Format
45
Code Bits
Code bits determine purpose, contents of the
segment
46
Urgent TCP Data
0 Programs may need to send “out of band” data
0 That is, data is treated as being sent through another
connection
0 In TCP, this can be done by setting the urgent flag
0 Receiving program processes urgent data ahead of the
rest of the data stream
47
TCP Acknowledgements
0 TCP acknowledgements can’t refer to datagram or
segment numbers, since retransmission can change
message size
0 TCP ack specifies sequence number of the next octet
the receiver expects to receive
0 Called a cumulative acknowledgement
0 Both efficient and inefficient
48
Timeout, Retransmission
0 Great variation in transit times, from local net to
distant network
0 Adaptive retransmission algorithm—monitors the
performance of each connection, deduces
reasonable timeout value
0 Stores round trip time, uses new RTT to change
stored RTT slowly
0 Timeout is some constant times RTT
0 Note that acknowledgements are ambiguous in
case of retransmissions
49
Karn’s Algorithm
0 Timer backoff strategy
0 Compute an initial timeout
0 If retransmission, then increase timeout
0 Often, double the timeout
0 Timeout increases have an upper limit
0 Karn uses only unambiguous acknowledgements to
compute RTT
new_timeout = γ * old_timeout
50
Response to Congestion
0 No way for TCP to directly know about congestion, which
causes retransmission, increasing congestion even further
0 Multiplicative
decrease
congestion
avoidance—when
Karn’s
Algorithm
is an example
of
segment is lost,
sender
congestion
window
is reduced by half
which
principle
of Internet
protocols?
(starts same as receiver advertisement), ack timer is
increased
0 Allowed window=min(receiver_advertisement,
congestion_window)
0 Slow-start recovery—start congestion window at single
segment size, increase by one for each ack
51
Explicit And Explicit Notification
0 Most versions of TCP use implicit feedback
mechanisms—using timeout and multiple ACKs to
detect loss and congestion
0 Some versions of explicit feedback have been
developed for TCP/IP
0 Selective acknowledgement—receiver identifies
left edge, right edge of received segments
0 Explicit congestion notification—routers add
notification to TCP header, then receiver notifies
sender in next ACK
52
Global Synchronization
0 When router is congested, early routers used tail-
drop strategy
0 Tail-drop—drop most recent datagram
0 This can cause drops from many TCP sources at
the same time, leads to global synchronization
0 Random Early Discard (RED)—uses min and max.
If fewer than min datagrams in queue, add it. If
more than min, randomly discard one datagram.
More than max, then drop new datagram.
53
Establishing TCP Connections
Three-way handshake is used to establish
TCP connection.
54
Close TCP Connection
55
The TCP FSM
56
Well-Known Port Assignments
57
Silly-Window Syndrome
0 Receiver reports buffer space available as
WINDOW field in ACK
0 Advertising single byte window causes sender to
send one-octet segment
0 Avoid it by:
0 Receiver doesn’t advertise until space has accumulated
0 Sender doesn’t send unless enough data to fill medium-
size segment. But sends data when an ack arrives, even
if still accumulating
58
Summary
0 TCP provides an important service: Full duplex,
reliable connection between two machines
0 Segment as basic unit of interchange
0 Flow control through advertising, backoff
0 Many additional techniques to increase performance
Since TCP provides reliable communication, why do
we need UDP? Why not just use TCP for all Internet
communication?
59
Download