47
The Transport Layer Chapter 6

The Transport Layer Chapter 6. The Transport Service The transport layer is the heart of the whole protocol hierarchy It provides reliable data transport

Embed Size (px)

Citation preview

Page 1: The Transport Layer Chapter 6. The Transport Service The transport layer is the heart of the whole protocol hierarchy It provides reliable data transport

The Transport Layer

Chapter 6

Page 2: The Transport Layer Chapter 6. The Transport Service The transport layer is the heart of the whole protocol hierarchy It provides reliable data transport

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

Page 3: The Transport Layer Chapter 6. The Transport Service The transport layer is the heart of the whole protocol hierarchy It provides reliable data transport

The Transport Function

net 1 net 2AP1

AP2

AP3

AP4

transport entity

AP1

transport entity

AP4

subnet

end to end

主机 A 主机 B

Page 4: The Transport Layer Chapter 6. The Transport Service The transport layer is the heart of the whole protocol hierarchy It provides reliable data transport

Services Provided to the Upper Layers

The network, transport, and application layers.

Page 5: The Transport Layer Chapter 6. The Transport Service The transport layer is the heart of the whole protocol hierarchy It provides reliable data transport

Transport Service Primitives

The primitives for a simple transport service.

Page 6: The Transport Layer Chapter 6. The Transport Service The transport layer is the heart of the whole protocol hierarchy It provides reliable data transport

Transport Service Primitives (2)

The nesting of TPDUs, packets, and frames.

Page 7: The Transport Layer Chapter 6. The Transport Service The transport layer is the heart of the whole protocol hierarchy It provides reliable data transport

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.

Page 8: The Transport Layer Chapter 6. The Transport Service The transport layer is the heart of the whole protocol hierarchy It provides reliable data transport

Berkeley Sockets

The socket primitives for TCP.

Page 9: The Transport Layer Chapter 6. The Transport Service The transport layer is the heart of the whole protocol hierarchy It provides reliable data transport

Elements of Transport Protocols

• Addressing

• Connection Establishment

• Connection Release

• Flow Control and Buffering

• Multiplexing

• Crash Recovery

Page 10: The Transport Layer Chapter 6. The Transport Service The transport layer is the heart of the whole protocol hierarchy It provides reliable data transport

Comparison of Transport Protocol & Data Link Protocol(1)

(a) Environment of the data link layer.(b) Environment of the transport layer.

Page 11: The Transport Layer Chapter 6. The Transport Service The transport layer is the heart of the whole protocol hierarchy It provides reliable data transport

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

Page 12: The Transport Layer Chapter 6. The Transport Service The transport layer is the heart of the whole protocol hierarchy It provides reliable data transport

Addressing

TSAPs, NSAPs and transport connections.

Page 13: The Transport Layer Chapter 6. The Transport Service The transport layer is the heart of the whole protocol hierarchy It provides reliable data transport

Addressing(2)• How the client gets the server’s TSAP?

• Well-known TSAP

• Look up a name server or directory server

Page 14: The Transport Layer Chapter 6. The Transport Service The transport layer is the heart of the whole protocol hierarchy It provides reliable data transport

Addressing(3)

How a user process in host 1 establishes a connection with a time-of-day server in host 2.

Page 15: The Transport Layer Chapter 6. The Transport Service The transport layer is the heart of the whole protocol hierarchy It provides reliable data transport

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

Page 16: The Transport Layer Chapter 6. The Transport Service The transport layer is the heart of the whole protocol hierarchy It provides reliable data transport

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)

Page 17: The Transport Layer Chapter 6. The Transport Service The transport layer is the heart of the whole protocol hierarchy It provides reliable data transport

Connection EstablishmentTomlinson(2)

(a) TPDUs may enter the forbidden region if host send too fast or too slow (b) The resynchronization problem. (too slow)

Page 18: The Transport Layer Chapter 6. The Transport Service The transport layer is the heart of the whole protocol hierarchy It provides reliable data transport

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.

Page 19: The Transport Layer Chapter 6. The Transport Service The transport layer is the heart of the whole protocol hierarchy It provides reliable data transport

Connection ReleaseAsymmetric

Abrupt disconnection with loss of data.

Page 20: The Transport Layer Chapter 6. The Transport Service The transport layer is the heart of the whole protocol hierarchy It provides reliable data transport

Connection Release (2)

The two-army problem.

Page 21: The Transport Layer Chapter 6. The Transport Service The transport layer is the heart of the whole protocol hierarchy It provides reliable data transport

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

Page 22: The Transport Layer Chapter 6. The Transport Service The transport layer is the heart of the whole protocol hierarchy It provides reliable data transport

Connection Release (4)

(c) Response lost. (d) Response lost and subsequent DRs lost.

6-14, c,d

Page 23: The Transport Layer Chapter 6. The Transport Service The transport layer is the heart of the whole protocol hierarchy It provides reliable data transport

Flow Control and Buffering

(a) Chained fixed-size buffers. (b) Chained variable-sized buffers. (c) One large circular buffer per connection.

Page 24: The Transport Layer Chapter 6. The Transport Service The transport layer is the heart of the whole protocol hierarchy It provides reliable data transport

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

Page 25: The Transport Layer Chapter 6. The Transport Service The transport layer is the heart of the whole protocol hierarchy It provides reliable data transport

Flow Control and Buffering (3)

Dynamic buffer allocation. The arrows show the direction of transmission. An ellipsis (…) indicates a lost TPDU.

Page 26: The Transport Layer Chapter 6. The Transport Service The transport layer is the heart of the whole protocol hierarchy It provides reliable data transport

Multiplexing

(a) Upward multiplexing. (b) Downward multiplexing.

Page 27: The Transport Layer Chapter 6. The Transport Service The transport layer is the heart of the whole protocol hierarchy It provides reliable data transport

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

Page 28: The Transport Layer Chapter 6. The Transport Service The transport layer is the heart of the whole protocol hierarchy It provides reliable data transport

UDP

The UDP header.

Page 29: The Transport Layer Chapter 6. The Transport Service The transport layer is the heart of the whole protocol hierarchy It provides reliable data transport

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

Page 30: The Transport Layer Chapter 6. The Transport Service The transport layer is the heart of the whole protocol hierarchy It provides reliable data transport

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

Page 31: The Transport Layer Chapter 6. The Transport Service The transport layer is the heart of the whole protocol hierarchy It provides reliable data transport

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.

Page 32: The Transport Layer Chapter 6. The Transport Service The transport layer is the heart of the whole protocol hierarchy It provides reliable data transport

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

Page 33: The Transport Layer Chapter 6. The Transport Service The transport layer is the heart of the whole protocol hierarchy It provides reliable data transport

The TCP Segment Header

TCP Header.

Page 34: The Transport Layer Chapter 6. The Transport Service The transport layer is the heart of the whole protocol hierarchy It provides reliable data transport

The TCP Segment Header (2)

The pseudoheader included in the TCP checksum.

Page 35: The Transport Layer Chapter 6. The Transport Service The transport layer is the heart of the whole protocol hierarchy It provides reliable data transport

TCP Options• MSS

• Window scale RFC1323

• Selective repeat RFC1106

Page 36: The Transport Layer Chapter 6. The Transport Service The transport layer is the heart of the whole protocol hierarchy It provides reliable data transport

TCP Connection Establishmentthree-way handshake

(a) TCP connection establishment in the normal case.(b) Call collision.

6-31

Page 37: The Transport Layer Chapter 6. The Transport Service The transport layer is the heart of the whole protocol hierarchy It provides reliable data transport

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

Page 38: The Transport Layer Chapter 6. The Transport Service The transport layer is the heart of the whole protocol hierarchy It provides reliable data transport

TCP Connection Management Modeling

The states used in the TCP connection management finite state machine.

Page 39: The Transport Layer Chapter 6. The Transport Service The transport layer is the heart of the whole protocol hierarchy It provides reliable data transport

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.

Page 40: The Transport Layer Chapter 6. The Transport Service The transport layer is the heart of the whole protocol hierarchy It provides reliable data transport

TCP Transmission Policywindow management

Window management in TCP.

Page 41: The Transport Layer Chapter 6. The Transport Service The transport layer is the heart of the whole protocol hierarchy It provides reliable data transport

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

Page 42: The Transport Layer Chapter 6. The Transport Service The transport layer is the heart of the whole protocol hierarchy It provides reliable data transport

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

Page 43: The Transport Layer Chapter 6. The Transport Service The transport layer is the heart of the whole protocol hierarchy It provides reliable data transport

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

Page 44: The Transport Layer Chapter 6. The Transport Service The transport layer is the heart of the whole protocol hierarchy It provides reliable data transport

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.

Page 45: The Transport Layer Chapter 6. The Transport Service The transport layer is the heart of the whole protocol hierarchy It provides reliable data transport

TCP Congestion ControlSlow Start Algorithm

An example of the Internet congestion algorithm.

Page 46: The Transport Layer Chapter 6. The Transport Service The transport layer is the heart of the whole protocol hierarchy It provides reliable data transport

TCP Timer Management

(a) Probability density of ACK arrival times in the data link layer.

(b) Probability density of ACK arrival times for TCP.

Page 47: The Transport Layer Chapter 6. The Transport Service The transport layer is the heart of the whole protocol hierarchy It provides reliable data transport

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