The Transport Layer Chapter 6. The Transport Service The transport layer is the heart of the whole...
-
Upload
jasper-griffin -
Category
Documents
-
view
223 -
download
0
Transcript of The Transport Layer Chapter 6. The Transport Service The transport layer is the heart of the whole...
The Transport Layer
Chapter 6
The Transport Service• The transport layer is the heart of the whole protocol hierarchy
• It provides reliable data transport end to end
• It masks the diversity of communication subnets, provide a common interface to the upper layer
• It provides multiple SAPs sharing one network link
The Transport Function
net 1 net 2AP1
AP2
AP3
AP4
transport entity
AP1
transport entity
AP4
subnet
end to end
主机 A 主机 B
Services Provided to the Upper Layers
The network, transport, and application layers.
Transport Service Primitives
The primitives for a simple transport service.
Transport Service Primitives (2)
The nesting of TPDUs, packets, and frames.
Transport Service Primitives (3)
A state diagram for a simple connection management scheme. Transitions labeled in italics are caused by packet arrivals. The solid lines show the client's state sequence. The dashed lines show the server's state sequence.
Berkeley Sockets
The socket primitives for TCP.
Elements of Transport Protocols
• Addressing
• Connection Establishment
• Connection Release
• Flow Control and Buffering
• Multiplexing
• Crash Recovery
Comparison of Transport Protocol & Data Link Protocol(1)
(a) Environment of the data link layer.(b) Environment of the transport layer.
Comparison of Transport Protocol & Data Link Protocol(2)
• Both have to deal with error control, sequencing, flow control
• Environment differences• Explicit addressing of destinations
• Initial connection establishment
• Storage capacity in the subnet
• Allocation of buffers
Addressing
TSAPs, NSAPs and transport connections.
Addressing(2)• How the client gets the server’s TSAP?
• Well-known TSAP
• Look up a name server or directory server
Addressing(3)
How a user process in host 1 establishes a connection with a time-of-day server in host 2.
Connection Establishment• The connection establishment TPDU could be delayed or duplicated
see P497 example
• Solution & flaw• If using throwaway transport addresses, no process server
• If giving each connection a connection identifier (i.e., a incremented sequence number), a crashed machine can not know which identifier have been used
• Packet lifetime should be restricted• Restricted subnet design
• Putting a hop counter in each packet
• Timestamping each packet
Connection EstablishmentTomlinson
• T: n times of maximum packet lifetime• Make sure both a packet and it’s acknowledgement are dead
• Each host equipped with a time-of-day clock• The clocks at different hosts need not be synchronized
• Each clock is a binary counter incremented at a small interval (tick)
• The clock should not stop even if the host goes down
• Allocate sequence for each TPDU • Sequence is long enough, so it won’t be reused before period T
• When a connection is set up, the lower-order k bits of the clock are used as the initial sequence number
• The sequence space is larger than the one data link layer used, it limits the throughput of host
• Prevent sequence numbers from being used for a time T before their potential use as initial sequence numbers (i.e., one TPDU per clock tick)
Connection EstablishmentTomlinson(2)
(a) TPDUs may enter the forbidden region if host send too fast or too slow (b) The resynchronization problem. (too slow)
Connection Establishment (3)
Three protocol scenarios for establishing a connection using a three-way handshake. CR denotes CONNECTION REQUEST. (a) Normal operation, (b) Old CONNECTION REQUEST appearing out of nowhere. (c) Duplicate CONNECTION REQUEST and duplicate ACK.
Connection ReleaseAsymmetric
Abrupt disconnection with loss of data.
Connection Release (2)
The two-army problem.
Connection Release (3)
Four protocol scenarios for releasing a connection. (a) Normal case of a three-way handshake. (b) final ACK lost.
6-14, a, b
Connection Release (4)
(c) Response lost. (d) Response lost and subsequent DRs lost.
6-14, c,d
Flow Control and Buffering
(a) Chained fixed-size buffers. (b) Chained variable-sized buffers. (c) One large circular buffer per connection.
Flow Control and Buffering(2) • Why transport entity allocates buffers dynamically?
• Too much connection in transport layer
• Each connection may be opened or closed frequently
• Solution• Explicit window in acknowledgement
• Variable-sized window
• Two flow control factor• Buffer space available in the receiver
explicit window indication
• The capacity of the subnet
sender monitor the network’s carrying capacity
Flow Control and Buffering (3)
Dynamic buffer allocation. The arrows show the direction of transmission. An ellipsis (…) indicates a lost TPDU.
Multiplexing
(a) Upward multiplexing. (b) Downward multiplexing.
The Internet Transport Protocols• TCP
• Transmission Control Protocol
• RFC793
• Connection-oriented protocol
• Byte-stream
• UDP• User Datagram Protocol
• RFC768
• Connectionless Protocol
TCP/IP STACK
ApplicationApplication
TCP UDPTCP UDP
Host-to-NetworkHost-to-Network
IPIP
UDP
The UDP header.
The TCP Service Model• Socket
• IP address (NSAP) and Port (16-bit, TSAP)
• Each connection is identified by a pair of sockets
• Well-known ports• Reserved for standard services
• RFC1700
• TCP connection• Full-duplex
• Point-to-point
• Byte-stream, not message stream
The TCP Service Model
Some well-known ports.
Port Protocol Use21 FTP File transfer23 Telnet Remote login25 SMTP E-mail69 TFTP Trivial File Transfer Protocol79 Finger Lookup info about a user80 HTTP World Wide Web
110 POP-3 Remote e-mail access119 NNTP USENET news
The TCP Service Model (2)
(a) Four 512-byte segments sent as separate IP datagrams.
(b) The 2048 bytes of data delivered to the application in a single READ CALL.
TCP Protocol• 32-bits sequence
• Count byte, not segment
• Segment=20bytes head + n bytes data
• MSS (Maximum Segment Size)• Limited by IP datagram length
• Limited by MTU of each data link, so router could fragment a segment
• Variable sized sliding window• Limited by IP datagram length
• Limited by MTU of each data link, so router could fragment a segment
• Reorder the segment• Disordered and duplicated segments received by the receiver
• Accumulated acknowledgement
The TCP Segment Header
TCP Header.
The TCP Segment Header (2)
The pseudoheader included in the TCP checksum.
TCP Options• MSS
• Window scale RFC1323
• Selective repeat RFC1106
TCP Connection Establishmentthree-way handshake
(a) TCP connection establishment in the normal case.(b) Call collision.
6-31
TCP Connection Release
Host 1 Host 2
FIN=1, Seq=x
Ack= x+1
Application request releasing connection
Notify application
Application request releasing connectionNotify
application
FIN=1, Seq= y
Ack= y+1
Release the whole connection
Use timer to avoid the two-army problem
TCP Connection Management Modeling
The states used in the TCP connection management finite state machine.
TCP Connection Management Modeling (2)
TCP connection management finite state machine. The heavy solid line is the normal path for a client. The heavy dashed line is the normal path for a server. The light lines are unusual events. Each transition is labeled by the event causing it and the action resulting from it, separated by a slash.
TCP Transmission Policywindow management
Window management in TCP.
TCP Transmission Policyefficiency
• TCP/IP overhead=20 bytes TCP head + 20 bytes IP head
• When used in TELNET connection, 1 data bytes carried with 40 bytes overhead
• Improvement algorithm• Delay acknowledgement and window update
reduce the load placed by the receiver
• Nagle’s algorithm
send one segment unless either of the following condition exist:
1. acknowledgement to last segment has been received
2. buffered data fills half the window or a maximum segment
TCP Transmission Policysilly window syndrome
Clark’s solution
The receiver should not send a window update until it can handle the MSS or its buffer is half empty, whichever is smaller
TCP Congestion Control• The reason for packet timeout
• Noise on a transmission line
• Packet discard at a congested router
• TCP congestion control algorithm• Assumption: all timeouts are caused by congestion
• Two flow factor
1. receiver capacity: receiver window
2. network capacity: congestion window
TCP Congestion Controlnetwork capacity and receiver capacity
(a) A fast network feeding a low capacity receiver.(b) A slow network feeding a high-capacity receiver.
TCP Congestion ControlSlow Start Algorithm
An example of the Internet congestion algorithm.
TCP Timer Management
(a) Probability density of ACK arrival times in the data link layer.
(b) Probability density of ACK arrival times for TCP.
TCP Timer ManagementJacobson dynamic algorithm
• M how long the successful acknowledgement took
• α a smoothing factor that determines how much weight is given to the old value. Typically a = 7/8.
• RTT (Round Trip Time) the best current estimate of the round-trip time to the destination RTT= αRTT+(1- α)M
• D mean deviation of estimate
D=αD+(1-α)|RTT-M|
• Timeout=RTT+4*D• Karn’s algorithm
do not update RTT on any segments that have been retransmitted, instead, the timeout is doubled on each failure until the segments get through the first time