Download DownloadNotes - Department of Electronic Engineering

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Recursive InterNetwork Architecture (RINA) wikipedia , lookup

TCP congestion control wikipedia , lookup

Internet protocol suite wikipedia , lookup

Transcript
Department of Electronic Engineering
City University of Hong Kong
Transport Protocols
EE3900 Computer Networks
Transport Protocols
Slide 1
Department of Electronic Engineering
City University of Hong Kong
Outline
• Introduction
•TCP
• UDP
EE3900 Computer Networks
Transport Protocols
Slide 2
Department of Electronic Engineering
City University of Hong Kong
Introduction
• Internet Protocol (IP) provides “unreliable
datagram service” between hosts
• Transport protocols provide end-to-end
delivery between endpoints of a connection;
e.g., processes or programs
EE3900 Computer Networks
Transport Protocols
Slide 3
Department of Electronic Engineering
City University of Hong Kong
Introduction (cont’d)
• shield the user from the details of the
underlying communications systems
• relieves applications and other upper-layer
protocols from changing communications
networks and services
• eg: User Datagram Protocol (UDP),
Transmission Control Protocol (TCP)
EE3900 Computer Networks
Transport Protocols
Slide 4
Department of Electronic Engineering
City University of Hong Kong
UDP and TCP/IP Layering
• Use IP to provide data delivery for
applications, TCP end-to-end protocol
EE3900 Computer Networks
Transport Protocols
Slide 5
Department of Electronic Engineering
City University of Hong Kong
Outline
• Introduction
• TCP
• UDP
EE3900 Computer Networks
Transport Protocols
Slide 6
Department of Electronic Engineering
City University of Hong Kong
TCP
• TCP is the most widely used transport protocol
• Provides reliable data delivery by using unreliable
IP datagrams
• Recovery from loss, or duplication of packets
• Reliable delivery to the high-level applications
EE3900 Computer Networks
Transport Protocols
Slide 7
Department of Electronic Engineering
City University of Hong Kong
Features of TCP
• Connection oriented: application requests
connection to destination and then uses the
connection to deliver data
• Point-to-point: A TCP connection has two
endpoints
• Reliability: TCP guarantees data will be
delivered without loss, duplication or
transmission error
EE3900 Computer Networks
Transport Protocols
Slide 8
Department of Electronic Engineering
City University of Hong Kong
Features of TCP (cont’d)
• Full duplex: the endpoints of a TCP connection
exchange data in both directions simultaneously
• Stream interface: application delivers data to the
TCP as a continuous stream, with no boundaries
• Reliable connection establishment: three-way
handshake guarantees reliable, synchronized
startup between endpoints
• Graceful connection shutdown: TCP guarantees
delivery of all data after shutdown requested by
application
EE3900 Computer Networks
Transport Protocols
Slide 9
Department of Electronic Engineering
City University of Hong Kong
Design Issues
•
•
•
•
•
•
•
Addressing
Ordered delivery
Retransmission strategy
Duplicate detection
Flow control
Connection establishment
Connection termination
EE3900 Computer Networks
Transport Protocols
Slide 10
Department of Electronic Engineering
City University of Hong Kong
Addressing
• A protocol port represents a particular transport service
(TS) user
• TCP defines an endpoint as a pair of integers (host, port),
eg: (128.10.2.3, 25)
• TCP uses the connection, not the protocol port, as its
fundamental abstraction; connections are identified by a
pair of endpoints,
eg: (128.10.2.3, 25) and (128.26.0.36, 1069) defines a
connection
• Because TCP identifies a connection by a pair of
endpoints, a given TCP port number can be shared by
multiple connections on the same machine
EE3900 Computer Networks
Transport Protocols
Slide 11
Department of Electronic Engineering
City University of Hong Kong
Ordered Delivery
• Application delivers arbitrarily large chunks of data to TCP
as a “stream”
• TCP breaks this data into segments, each of which fits into
an IP datagram
• Segments may arrive out of order
• TCP numbers each sent data octet sequentially
• Segments are numbered by the number of the first octet in
the segment
EE3900 Computer Networks
Transport Protocols
Slide 12
Department of Electronic Engineering
City University of Hong Kong
Retransmission Strategy
• When segment is lost, or damaged in transit,
transmitter does not know its failure
• Receiver must acknowledge successful
receipt of data – positive ack
• One ACK can acknowledge many segments
(cumulative acknowledgement)
• Time out waiting for ACK triggers
re-transmission
EE3900 Computer Networks
Transport Protocols
Slide 13
Department of Electronic Engineering
EE3900 Computer Networks
City University of Hong Kong
Transport Protocols
Slide 14
Department of Electronic Engineering
City University of Hong Kong
Setting the Timeout
• Inappropriate timeout can cause poor performance:
– Too long - sender waits longer than necessary before
retransmission
– Too short - sender generates unnecessary traffic
• Timeout must be different for each connection and set
dynamically
– Hosts on same LAN should have shorter timeout than
hosts 20 hops away
– Delivery time across internet may change over time
because of loading; timeout must accommodate changes
EE3900 Computer Networks
Transport Protocols
Slide 15
Department of Electronic Engineering
City University of Hong Kong
Picking a timeout value
• Timeout should be based on round trip time (RTT)
• Sender does not know RTT of any packet before
transmission
• Sender picks retransmission timeout (RTO) based
on previous RTTs
• Specific method is called adaptive retransmission
algorithm
EE3900 Computer Networks
Transport Protocols
Slide 16
Department of Electronic Engineering
City University of Hong Kong
RTOs for Different Network Delays
EE3900 Computer Networks
Transport Protocols
Slide 17
Department of Electronic Engineering
City University of Hong Kong
Flow Control
• TCP uses sliding window for flow control
• Receiver specifies window
–
–
–
–
(AN = i , W = j )
Called window advertisement (W=j)
Specifies which bytes in the data stream can be sent
Carried in segment along with ACK (AN= i)
• Sender can transmit any bytes, in any size
segment, between last acknowledged byte and
within window size
EE3900 Computer Networks
Transport Protocols
Slide 18
Department of Electronic Engineering
City University of Hong Kong
Sliding window with acknowledgments
EE3900 Computer Networks
Transport Protocols
Slide 19
Department of Electronic Engineering
City University of Hong Kong
Connection Establishment
• If the network is reliable, Two-way Handshake
suffices:
– A send SYN, B replies with SYN
– Lost SYN handled by re-transmission, can lead
to duplicate SYNs
– Ignore duplicate SYNs once connected
EE3900 Computer Networks
Transport Protocols
Slide 20
Department of Electronic Engineering
City University of Hong Kong
Connection Termination
•
•
•
•
Either or both sides
By mutual agreement
Abrupt termination
Or graceful termination
– Close Wait state must accept incoming data
until ACK for FIN received
EE3900 Computer Networks
Transport Protocols
Slide 21
Department of Electronic Engineering
City University of Hong Kong
Problems with Two-way
Handshake
• In an unreliable network, lost or delayed segments
can cause problems in connection or termination
EE3900 Computer Networks
Transport Protocols
Slide 22
Department of Electronic Engineering
City University of Hong Kong
Problem 1:
Obsolete
Data
Segment
EE3900 Computer Networks
Transport Protocols
Slide 23
Department of Electronic Engineering
City University of Hong Kong
Problem 2: obsolete SYN Segment
EE3900 Computer Networks
Transport Protocols
Slide 24
Department of Electronic Engineering
City University of Hong Kong
Solution: Three-way Handshake
EE3900 Computer Networks
Transport Protocols
Slide 25
Department of Electronic Engineering
City University of Hong Kong
Three-way
Handshake:
Examples
EE3900 Computer Networks
Transport Protocols
Slide 26
Department of Electronic Engineering
City University of Hong Kong
Close a TCP Connection
EE3900 Computer Networks
Transport Protocols
Slide 27
Department of Electronic Engineering
City University of Hong Kong
Close a TCP Connection (cont’d)
• A modified three-way handshake is used to close a TCP
connection (full duplex)
• To close its half of the connection, the sending TCP
finishes transmitting the remaining data, waits for the
receiver to acknowledge it, and then send a FIN segment.
Then, the receiving TCP acknowledges the FIN segment.
• Meanwhile, data can continue to flow in the other half of
the connection, until it is closed
• Associate sequence number with FIN
• Receiver waits for all segments before FIN sequence
number
EE3900 Computer Networks
Transport Protocols
Slide 28
Department of Electronic Engineering
City University of Hong Kong
Congestion Control
•
•
•
•
Implemented by senders
Dynamic window flow control
Two phases: Slow Start and Congestion Avoidance
3 parameters are used:
– W_max, maximum window size advertised by
receiver
– W_t, threshold, initially set to half of W_max
– W, congestion window
EE3900 Computer Networks
Transport Protocols
Slide 29
Department of Electronic Engineering
City University of Hong Kong
Slow Start
• Initially, W=1, increasing W for each Ack
received before timeout (exponential increase:
W=1,2,4,8,16 …)
• when W=W_t, congestion avoidance mode is
entered
• when a packet loss is detected, W_t=0.5W,
and then set W=1
EE3900 Computer Networks
Transport Protocols
Slide 30
Department of Electronic Engineering
City University of Hong Kong
Congestion Avoidance
• W increases by 1 when all Acks for a full
congestion window of packets are received
• W cannot exceed W_max
• same as Slow Start, when a packet loss is
detected, W_t=0.5W, W=1
EE3900 Computer Networks
Transport Protocols
Slide 31
Department of Electronic Engineering
City University of Hong Kong
Window Dynamics (an example)
window size
EE3900 Computer Networks
Transport Protocols
Slide 32
Department of Electronic Engineering
City University of Hong Kong
Features
• Slow Start allows users to
quickly/exponentially attain maximum
transmission rates when bandwidth is
available (not slow at all!)
• Congestion Avoidance forces users to
cautiously/linearly increase the window size
near congestion point, allowing them to
make use of the bandwidth that may become
available
EE3900 Computer Networks
Transport Protocols
Slide 33
Department of Electronic Engineering
City University of Hong Kong
TCP Header
Figure 17.14 TCP Header
EE3900 Computer Networks
Transport Protocols
Slide 34
Department of Electronic Engineering
City University of Hong Kong
Outline
• Introduction
• TCP
• UDP
EE3900 Computer Networks
Transport Protocols
Slide 35
Department of Electronic Engineering
City University of Hong Kong
UDP
• Provide a connectionless (unreliable) service;
delivery and duplicate protection are not
guaranteed.
• Low overhead, which may be adequate in
many cases, e.g. for network management
• There is a checksum in the header. If an error
is detected, the segment is discarded and no
further action is taken.
EE3900 Computer Networks
Transport Protocols
Slide 36
Department of Electronic Engineering
City University of Hong Kong
UDP Header
EE3900 Computer Networks
Transport Protocols
Slide 37