1、Chapter 6 The Transport Layer,College of Computer Science Chongqing University,Contents,6.1 The Transport Service 6.2 Elements of Transport Protocols 6.3 UDP 6.4 TCP,The end-user cannot control what is in the network.So the end-user establishes another layer,only at end hosts,to provide a transport
2、service that is more reliable than the underlying network service.Using this new network connection,it can send a query to its peer asking which data arrived and which did not,and then pick up from where it left off2.The transport layer allows several concurrent applications to use the transport ser
3、vice.3.Provides a common interface to application writers,regardless of the underlying network layer.In essence,an application writer can write code once using the transport layer primitive and use it on different networks(but with the same transport layer).,Why the transport layer?,Between the comm
4、unication subnet and resource subnet,shield the underlying details of network off the high-level user,6.1.1 Services Provided to the Upper Layers,6.1.1 Services Provided to the Upper Layers,The network layer is responsible for the delivery of individual packets from the source host to the destinatio
5、n host.,The transport layer is responsible for the delivery of a message from one process to another,6.1.1 Services Provided to the Upper Layers,Transport layer compared with network layer,Transport layer compared with data link layer,6.1.1 Services Provided to the Upper Layers,Similarities Both hav
6、e to deal with error control,sequencing,and flow control,among other issues,differences,Generally directed connectedPoint to Point basedconnection establishment is simple storage management is simple,Out-buffers/in-buffers,Connected via subnetexplicit addressing of destinations is required connectio
7、n establishment is more complicated Connection based in/out-buffer mangement,6.1.1 Services Provided to the Upper Layers,Transport layer compared with data link layer,Transport layer concept,6.1.1 Services Provided to the Upper Layers,The nesting of TPDUs,packets,and frames,6.1.1 Services Provided t
8、o the Upper Layers,End(normally processes in the application layer)to end deliveryReliable deliveryshield the underlying details of network off the high-level userFlow controlMultiplexing,The goal of the transport layer,6.1.1 Services Provided to the Upper Layers,connection-oriented transport servic
9、e(three phases)Establishment connection data transferrelease connectionconnectionless transport service,Two types of network service,6.1.1 Services Provided to the Upper Layers,6.1.2 Transport Service Primitives,The primitives for a simple connection-oriented transport service,6.1.2 Transport Servic
10、e Primitives,The state diagram for a simple connection-oriented transport connection management scheme,Transitions labeled in italics are caused by packet arrivals.The solid lines show the clients state sequence.The dashed lines show the servers state sequence,An Excample:Berkeley Sockets,6.1.2 Tran
11、sport Service Primitives,6.2 Elements of Transport Protocols,AddressingConnection EstablishmentConnection ReleaseBufferingReliable DeliveryFlow Control MultiplexingCrash Recovery,In transport layer,service access points identifies upper-layer services(applications).,6.2.1 Addressing,6.2.1 Addressing
12、,TSAPs Transport Service Access Point NSAPs Network SAP TCP calls TSAP s.ports ATM calls TSAPs.AAL-SAP,6.2.1 Addressing,Levels of Service Access PointsData link level protocols need to know which two computers within a network are communicating.MAC addressNetwork level protocols need to know which t
13、wo computers within an internet are communicating.IP addressTransport level protocols need to know which upper-layer protocols are communicating.Port,6.2.2 Connection Establishment,End-to-end delivery can be accomplished in either of two modes:Connection-oriented transmission has three stages:connec
14、tion establishment,data transfer,connection termination.Connectionless transmission,6.2.2 Connection Establishment,Connection-oriented Connection establishment(three-way handshaking),6.2.2 Connection Establishment,Three protocol scenarios for establishing a connection using a three-way handshake.CR
15、denotes CONNECTION REQUEST.(a)Normal operation,(b)Old CONNECTION REQUEST appearing out of nowhere.(c)Duplicate CONNECTION REQUEST and duplicate ACK.,Connection-oriented Connection release(three-way handshaking),Abrupt disconnection with loss of data.,6.2.3 Connection Release,CR=CONNECTION REQUESTDR=
16、DISCONNECTION REQUEST,6.2.3 Connection Release,The two-army problem.,Four protocol scenarios for releasing a connection.,6-14,a,b,6.2.3 Connection Release,(a)Normal case of a three-way handshake.(b)final ACK lost.,6-14,c,d,6.2.3 Connection Release,(c)Response lost.(d)Response lost and subsequent DRs
17、 lost.,Four protocol scenarios for releasing a connection.,6.2.4 Buffering,(a)Chained fixed-size buffers.(b)Chained variable-sized buffers.(c)One large circular buffer per connection.,6.2.5 Reliable Delivery,Segmentation and ReassemblyTransport layer adds a sequence number at each segment.This numbe
18、r indicates the order for reassembly.Each segment carries a field that indicates whether it is the final segment or middle segment of a transmission.Concatenation and SeparationWhen the size of the data unit belonging to a single session is so small that several units can fit together into a single
19、datagram.A sequence number at each unit allows correct separation at the destination.,Sequence Control,Error ControlMechanisms for error control are based on error detection and retransmission.Error detections are performed using algorithms implemented in software,such as checksum.We already have er
20、ror handling at the data link layer,why do we need it at the transport layer?,6.2.5 Reliable Delivery,Loss ControlSequence numbers allow the receivers transport layer protocol to identify any missing segments and request redelivery.,6.2.5 Reliable Delivery,Duplication ControlSequence numbers allow t
21、he receiver to identify and discard duplicate segments.,6.2.5 Reliable Delivery,6.2.6 Flow Control,Flow control at transport layer is performed end-to-end rather than across a single link.A sliding window is used to make data transmission more efficient as well as to control the flow of data so that
22、 the receiver does not become overwhelmed.Some points about sliding windows at the transport layer:The sender does not have to send a full windows worth of data.An acknowledgment can expand the size of the window based on the sequence number of the acknowledged data segment.The size of the window ca
23、n be increased or decreased by the receiver.The receiver can send an acknowledgment at anytime.,6.2.6 Flow Control,Sliding window,6.2.6 Flow Control,Sliding windows used at the transport layer are usually byte oriented rather than frame oriented.,Dynamic buffer allocation.The arrows show the directi
24、on of transmission.An ellipsis()indicates a lost TPDU.,6.2.6 Flow Control,6.2.7 Multiplexing,Upward MultiplexingThe transport layer can send several transmissions bound for the same destination along the same path.It is useful when the underlying networks have high throughput.Downward MultiplexingIt
25、 is useful when the underlying networks have low or slow capacity(e.g.,X.25s three bit sequence code).,Different combinations of client and server strategy.,6.2.8 Crash Recovery,6.3 The Internet Transport Protocols:UDP,“no frills,”“bare bones”Internet transport protocol“best effort”service,UDP segme
26、nts may be:lostdelivered out of order to appconnectionless:no handshaking between UDP sender,receivereach UDP segment handled independently of others,Why is there a UDP?no connection establishment(which can add delay)simple:no connection state at sender,receiversmall segment headerno congestion cont
27、rol:UDP can blast away as fast as desired,6.3 The Internet Transport Protocols:UDP,6.3.1 Port Numbers,client-server paradigmProcess on the local host,called client,needs services from a process on the remote host,called serverFor communication,we need to defineLocal hostLocal processRemote hostRemot
28、e process,Local and remote hosts are defined using IP addressesProcesses are defined by so called port numberThe port number in TCP/IP are integers between 0 to 65,535Client process randomly selects a port number by the UDP ephemeral port numberTCP/IP uses universal port numbers for servers well-kno
29、wn port numbers,6.3.1 Port Numbers,6.3.1 Port Numbers,IP addresses versus port numbers,6.3.1 Port Numbers,De/Multiplexer,De/Multiplexer,IP,IP,Internet,Processes,Buffers,Port Numbers,UDP/TCP,De/Multiplexing,6.3.1 Port Numbers,IANA ranges for the port numbers,6.3.1 Port Numbers,Well-known ports used w
30、ith UDP,Well-known ports used with TCP,6.3.2 Socket Address,Combination of an IP address and a port number is called a socket addressThe socket address uniquely defines a processIP header contains the IP addressesUDP/TCP header includes the port numbers,2000,Host C,(TCP,IPa,1500),(TCP,IPc,2000),(TCP
31、,IPa,1501),(TCP,IPb,1501),6.3.3 Structure of UDP,UDP packets are called user datagramHeader size is fixed and of 8 bytes,6.3.3 Structure of UDP,Length,16-bit fieldDefines the total length of the user datagram,including the dataMinimum length is 8 bytesThe length of data can be 0 to 65,507 bytes,UDP
32、length=IP length-IP headers length,6.3.3 Structure of UDP,Checksum,Includes three sectionsPseudo-header:necessary IP information for error checkingUDP headerData,Pseudo-header added to the UDP datagram,This information gives protection against misrouted datagrams.,6.3.3 Structure of UDP,Checksum cal
33、culation of a simple UDP user datagram,6.3.4 UDP Operation,Connectionless servicesCan not send a stream of dataBetter for short messageNo flow and error controlEncapsulation and decapsulationQueuingQueues are associated with portsQueues are identified by port numbersWhen process terminates,the queues are destroyedMultiplexing and demultiplexing,