Presentation is loading. Please wait.

Presentation is loading. Please wait.

CHAPTER 3: TRANSPORT LAYER TRANSPORT LAYER Transport Layer Services Transport Layer Services Establishing/Releasing Connections Establishing/Releasing.

Similar presentations


Presentation on theme: "CHAPTER 3: TRANSPORT LAYER TRANSPORT LAYER Transport Layer Services Transport Layer Services Establishing/Releasing Connections Establishing/Releasing."— Presentation transcript:

1

2 CHAPTER 3: TRANSPORT LAYER TRANSPORT LAYER Transport Layer Services Transport Layer Services Establishing/Releasing Connections Establishing/Releasing Connections Multiplexing/Demultiplexing Multiplexing/Demultiplexing User Datagram Protocol (UDP) User Datagram Protocol (UDP) Reliable Data Transfer Reliable Data Transfer Flow Control Flow Control Error Control Error Control Transmission Control Protocol (TCP) Transmission Control Protocol (TCP) Congestion Control Congestion Control

3 TRANSPORT LAYER SERVICES Page 58Chapter 3CS 447

4 OUTPUT PROCESS: FROM APPLICATION TO HARDWARE Page 59Chapter 3CS 447 Hardware Operating System Application Programs An application calls system routines to have UDP allocate an IP datagram, fill in the proper destination address, encapsulate the UDP packet, and send it to the IP process for delivery. An application calls a system routine to buffer data, and notify the output process. The output process segments the data stream, encapsulates the TCP packets, and sends them to the IP process for delivery. UDP Output TCPOutputProcessTCPTimerProcess Net 2 Hardware Net 2 Device Net 1 Hardware Net 1 Device Net n Hardware Net n Device IPProcess Control Messages Control Messages TCP Output Port TCP Output Port Queue For Datagrams Sent To IP Queue For Datagrams Sent To IP Queues For Outgoing Packets Queues For Outgoing Packets TCP Output When the IP process enqueues an outgoing datagram, a device driver routine is called to start the hardware. When the output has occurred, the interrupt handler dequeues the datagram and restarts the hardware to send the next datagram. Source: Internetworking with TCP/IP, Volume II by Douglas E. Comer and David L. Stevens

5 INPUT PROCESS: FROM HARDWARE TO APPLICATION Page 60Chapter 3CS 447 Hardware Operating System Application Programs UDP packets are delivered to UDP ports, from which application programs read them. IP demultiplexes packets and delivers them to appropriate transport protocol. Incoming IP datagrams are queued for the IP process. Source: Internetworking with TCP/IP, Volume II by Douglas E. Comer and David L. Stevens Net 2 Hardware Net 2 Device Net 1 Hardware Net 1 Device Net n Hardware Net n Device Queues For Packets Sent To IP Queues For Packets Sent To IP TCP Input UDP Input Semaphore-ControlledBuffersSemaphore-ControlledBuffers Port For Segments Sent To TCP Port For Segments Sent To TCP UDPDatagramPortsUDPDatagramPorts TCP packets are delivered to TCP buffers, from which application programs read them.

6 ESTABLISHING CONNECTIONS Page 61Chapter 3CS 447 In the Transport Layer, the common approach for establishing an end-to-end connection involves a three-way handshake. This approach helps to determine whether connection requests or acknowledgements are disposable duplicates or not.

7 RELEASING CONNECTIONS Page 62Chapter 3CS 447 The three-way handshake is also used to release an end-to-end connection, since it facilitates the detection of lost disconnect messages and/or ACKs. Connection Released When Timer Expires Connection Released When Timer Expires Connection Released When Timer Expires N Times

8 TRANSPORT LAYER COMMUNICATION Page 63Chapter 3CS 447 The Transport Layer only deals with logical end-to-end message transport, but those messages are physically relayed through intermediary devices operating at lower layers.

9 INTERNET TRANSPORT-LAYER PROTOCOLS Page 64Chapter 3CS 447 Transmission Control Protocol (TCP) Connection-Oriented (end- to-end session is set up in advance) Connection-Oriented (end- to-end session is set up in advance) Reliable, In-Order Delivery (packets are numbered and any missing packets are sent again) Reliable, In-Order Delivery (packets are numbered and any missing packets are sent again) Flow Control (transmission rate adjusted to receiver’s capacity to receive) Flow Control (transmission rate adjusted to receiver’s capacity to receive) Congestion Control (throttles traffic to avoid bottlenecks) Congestion Control (throttles traffic to avoid bottlenecks) User Datagram Protocol (UDP) Connectionless (no end- to-end session is set up) Connectionless (no end- to-end session is set up) Unreliable, Unordered Delivery (depends on IP for “best delivery”) Unreliable, Unordered Delivery (depends on IP for “best delivery”) No Congestion Avoidance (could hog excessive bandwidth) No Congestion Avoidance (could hog excessive bandwidth)

10 MULTIPLEXING Page 65Chapter 3CS 447 Depending on the application layer service being used, a source host specifies a 16-bit source port number and a 16-bit destination port number, attaching a header to the outgoing application information that includes these port numbers. Transport Layer Segment Source Port # Destination Other Header Fields Application Layer Payload The endpoint in a Transport Layer communication is called a socket, with the port number and IP address comprising the socket address. Any specific Transport Layer communication uses two sockets, the source port and IP address, and the destination port and IP address, all of which together comprises a socket pair.

11 DEMULTIPLEXING (CONNECTIONLESS) Page 66Chapter 3CS 447 In connectionless Transport Layer service (e.g., UDP), sockets are created with port numbers that are local to the host. Process 1 Process 2 Process 3 DatagramSocket clientSocketA = new DatagramSocket(8945) DatagramSocket clientSocketA = new DatagramSocket(9601) DatagramSocket serverSocketC = new DatagramSocket(6734) Port 8945 Port 9601 Port payload,etc.payload,etc response,etc.response,etc payload,etc.payload,etc response,etc.response,etc. Note that IP datagrams with different source IP addresses and/or source port numbers may be directed to same socket.

12 DEMULTIPLEXING (CONNECTION-ORIENTED) Page 67Chapter 3CS 447 In connection-oriented Transport Layer service (e.g., TCP), a receiving host uses all four values (the source and destination ports, and the source and destination IP addresses) to direct a segment to the appropriate socket. Process 1 Process 3 Process 5 Port 7530 Port 4378 Port 8641 Process 4 Process 6 Process 2 Port payload,etc.payload,etc.E.F.G.HE.F.G.HW.X.Y.ZW.X.Y.Z payload,etc.payload,etc.L.M.N.OL.M.N.OW.X.Y.ZW.X.Y.Z payload,etc.payload,etc.L.M.N.OL.M.N.OW.X.Y.ZW.X.Y.Z A server host may support several simultaneous TCP sockets (each socket identified by its own 4-tuple), and web servers have different sockets for each connecting client.

13 USER DATAGRAM PROTOCOL Page 68Chapter 3CS 447 Source Port Destination Port Message Length Checksum UDP provides an unreliable delivery service using IP to transport messages between machines. As an unreliable service, it supports: No flow control and no congestion control No acknowledgements, no timers, and no retransmissions Error recovery, using the same checksums as TCP Source Port: Application’s UDP port number at the source station. Message Length: # of bytes in the UDP datagram, including header and data. Destination Port: Application’s UDP port number at the destination station. Source Port Destination Port Message Length Checksum Checksum: 1’s complement of 1’s complement sum of all 16-bit words in header, data, & “pseudoheader”. The UDP Header An application using UDP accepts full responsibility for handling reliability, including: message loss, duplication, delay, out-of-order delivery, and loss of connectivity!

14 UDP/TCP PSEUDOHEADER Page 69Chapter 3CS 447 Source Address Transport Segment Length Destination Address Protocol # Destination Address: IP address of the destination station. Protocol Number: IP’s identification of the protocol type being used (i.e., 6 for TCP, 17 for UDP). Source Address: IP address of the source station : Padding. Segment Length: Number of bytes in the Transport segment, including header and data. Source Address Transport Segment Length Destination Address Protocol # When the destination receives an IP datagram, IP passes the source and destination IP addresses, the datagram’s total length, and its protocol ID, to the Transport Layer, along with the Transport segment itself. The Transport protocol formulates the pseudoheader, and then calculates and checks the checksum. Note that the pseudoheader is not counted in the segment length (since it’s not part of the segment!) and is not transmitted! The Transport protocol uses the pseudoheader as part of its checksum calculation in order to verify both the source and destination sockets when the Transport segment is delivered.

15 RELIABLE DATA TRANSFER Page 70Chapter 3CS 447 A Transport protocol is considered reliable if it delivers all bits uncorrupted and in the correct order, regardless of how unreliable the underlying network is. Common Reliability Concerns w/Common Solutions Error Control Use ACKs, NAKs, Timeouts ACK/NAK Loss Or Corruption Resend Packet Duplicate Packets Due To Resend Use Sequence Numbers Duplicate Packets Due To Timeout Use Sequence Numbers Flow Control Automatic Repeat Request (ARQ) Receiver Burdened With Bookkeeping Use Go-Back-N Pipeline Burdened With Retransmissions Use Selective Repeat Congestion Control Vary Transmission Rates Inability To Locate Precise Problem Multiplicative Decrease Congestion Avoidance Inability To Recognize Recovery Additive Increase Slow- Start Recovery

16 Segment 0 ACK 1 Segment 1 ACK 2 Segment 2 ACK 3 Segment 3 ACK4ACK4 Segment 0 ACK1ACK1 Segment 4 ACK5ACK5 Segment 1 ACK2ACK2 Segment 5 ACK 6 Segment 6 NAK 6 Segment 6 NAK 6 Segment 6 ACK 7 Segment 7 ACK 8 Segment 8 ACK 9 Segment 9 FLOW CONTROL Page 71Chapter 3CS 447 When an endstation transmits segments faster than the recipient can “digest” them, either due to a lack of memory capacity or a preoccupation with other tasks, the recipient will usually just discard the excess frames. The “Stop-and-Wait” approach to Transport Layer flow control has the recipient respond with an acknowledgement (ACK) whenever it has finished dealing with the previous transport segment and is ready to receive the next segment. “Piggybacking” ACKs on segments going the opposite direction on the link, in order to reduce channel utilization. Sending negative acknowledgements (NAKs) whenever a segment is corrupted or not received in a timely fashion. Retransmitting a segment automatically whenever an ACK is not received in a timely fashion. Variations on this approach include:

17 SLIDING WINDOWS Page 72Chapter 3CS 447 By increasing the memory on each endstation and using a more sophisticated algorithm for keeping track of which Transport segments have and haven’t been accepted, traffic can flow more smoothly between the endstations. The “sliding windows” approach sets a particular window size for the total number of segments that the receiving station has either not received, not acknowledged, or not delivered to the current application. Every time the receiver transmits a segment to the sender, it includes a field advertising the number of slots in the window that are not occupied by segments that have been received and acknowledged, but not yet delivered. That number serves as a limit on how many more segments the sender can send to the receiver. Each segment is numbered with a “sequence number” so lost or duplicate segments can be determined, and the sequence numbers cycle back to zero to start repeating when the likelihood decreases that duplicate numbers will occur.

18 ERROR CONTROL Page 73Chapter 3CS 447 When a Transport segment is determined to be corrupted, there are two principal response alternatives. Go-Back-N Have the sending station resend the faulty segment and all subsequent segments. Go-Back-N Have the sending station resend the faulty segment and all subsequent segments. Simplifies processing on the endstations. Yields a lot of unnecessary retransmissions. Simplifies processing on the endstations. Yields a lot of unnecessary retransmissions. Selective Repeat Have the sending station resend only the segment that was faulty. Selective Repeat Have the sending station resend only the segment that was faulty. More productive use of bandwidth. More sophisticated (i.e., expensive) endstations. More productive use of bandwidth. More sophisticated (i.e., expensive) endstations. Sliding Window Size 4 Current Window Gap 4 Last Sent Segment - Last Received Segment - Last Acknowledged Segment - Sliding Window Size 4 Current Window Gap 3 Last Sent Segment 0 Last Received Segment 0 Last Acknowledged Segment - Sliding Window Size 4 Current Window Gap 2 Last Sent Segment 1 Last Received Segment 1 Last Acknowledged Segment - Sliding Window Size 4 Current Window Gap 1 Last Sent Segment 2 Last Received Segment 2 Last Acknowledged Segment - Last Received Segment 2 Last Acknowledged Segment 1 Sliding Window Size 4 Current Window Gap 3 Last Sent Segment 2 Sliding Window Size 4 Current Window Gap 2 Last Sent Segment 3 Sliding Window Size 4 Current Window Gap 1 Last Sent Segment 4 Sliding Window Size 4 Current Window Gap 0 Last Sent Segment 5 Sliding Window Size 4 Current Window Gap 4 Last Sent Segment 2 Sliding Window Size 4 Current Window Gap 3 Last Sent Segment 3 Sliding Window Size 4 Current Window Gap 2 Last Sent Segment 4 Sliding Window Size 4 Current Window Gap 1 Last Sent Segment 5 Sliding Window Size 4 Current Window Gap 0 Last Sent Segment 6 Sliding Window Size 4 Current Window Gap 3 Last Sent Segment 6 Sliding Window Size 4 Current Window Gap 2 Last Sent Segment 7 Sliding Window Size 4 Current Window Gap 1 Last Sent Segment 0 Sliding Window Size 4 Current Window Gap 0 Last Sent Segment 1 Sliding Window Size 4 Current Window Gap 4 Last Sent Segment 7 Sliding Window Size 4 Current Window Gap 3 Last Sent Segment 0 Sliding Window Size 4 Current Window Gap 2 Last Sent Segment 1 Sliding Window Size 4 Current Window Gap 1 Last Sent Segment 2 Sliding Window Size 4 Current Window Gap 0 Last Sent Segment 3 Last Received Segment 3 Last Acknowledged Segment 1 Last Received Segment 4 Last Acknowledged Segment 1 Last Received Segment 5 Last Acknowledged Segment 1 Last Received Segment 2 Last Acknowledged Segment 2 Last Received Segment 3 Last Acknowledged Segment 2 Last Received Segment 4 Last Acknowledged Segment 2 Last Received Segment 5 Last Acknowledged Segment 2 Last Received Segment 6 Last Acknowledged Segment 2 Last Received Segment 6 Last Acknowledged Segment 5 Last Received Segment 7 Last Acknowledged Segment 5 Last Received Segment 0 Last Acknowledged Segment 5 Last Received Segment 1 Last Acknowledged Segment 5 Last Received Segment 7 Last Acknowledged Segment 7 Last Received Segment 0 Last Acknowledged Segment 7 Last Received Segment 1 Last Acknowledged Segment 7 Last Received Segment 2 Last Acknowledged Segment 7 Last Received Segment 3 Last Acknowledged Segment 7 Segment 0 ACK 2 Segment 1 Segment 2 Segment 3 Segment 4 Segment 5 Segment 3 Segment 4 Segment 5 NAK 3 Segment 6 Segment 7 Segment 0 ACK 6 NAK 0 Segment 1 Segment 0 Segment 1 Segment 2 Segment 3 Sliding Window Size 4 Current Window Gap 4 Sent Segments - Received Segments - Last Acknowledged Segment - Segment 0 ACK 2 Segment 1 Segment 2 Segment 3 Segment 4 Segment 5 Segment 3 NAK 3 Segment 6 Segment 7 Segment 0 ACK 5 NAK 0 Segment 1 Segment 0 Segment 2 Segment 3 Sliding Window Size 4 Current Window Gap 3 Sent Segments 0 Received Segments 0 Last Acknowledged Segment - Sliding Window Size 4 Current Window Gap 2 Sent Segments 0,1 Received Segments 0,1 Last Acknowledged Segment - Sliding Window Size 4 Current Window Gap 1 Sent Segments 0,1,2 Received Segments 0,1,2 Last Acknowledged Segment - Sliding Window Size 4 Current Window Gap 3 Sent Segments 2 Received Segments 2 Last Acknowledged Segment 1 Sliding Window Size 4 Current Window Gap 2 Sent Segments 2,3 Received Segments 2,3 Last Acknowledged Segment 1 Sliding Window Size 4 Current Window Gap 1 Sent Segments 2,3,4 Received Segments 2,3,4 Last Acknowledged Segment 1 Sliding Window Size 4 Current Window Gap 0 Sent Segments 2,3,4,5 Received Segments 2,3,4,5 Last Acknowledged Segment 1 Sliding Window Size 4 Current Window Gap 1 Sent Segments 4,5 Received Segments 4,5 Last Acknowledged Segment 2 Sliding Window Size 4 Current Window Gap 1 Sent Segments 4,5,3 Received Segments 4,5,3 Last Acknowledged Segment 2 Sliding Window Size 4 Current Window Gap 0 Sent Segments 4,5,3,6 Received Segments 4,5,3,6 Last Acknowledged Segment 2 Sliding Window Size 4 Current Window Gap 2 Sent Segments 5,6 Received Segments 5,6 Last Acknowledged Segment 4 Sliding Window Size 4 Current Window Gap 1 Sent Segments 5,6,7 Received Segments 5,6,7 Last Acknowledged Segment 4 Sliding Window Size 4 Current Window Gap 0 Sent Segments 5,6,7,0 Received Segments 5,6,7,0 Last Acknowledged Segment 4 ACK 7 Sliding Window Size 4 Current Window Gap 2 Sent Segments 7,0 Received Segments 7,0 Last Acknowledged Segment 6 Sliding Window Size 4 Current Window Gap 1 Sent Segments 7,0,1 Received Segments 7,0,1 Last Acknowledged Segment 6 Sliding Window Size 4 Current Window Gap 0 Sent Segments 7,0,1,2 Received Segments 7,0,1,2 Last Acknowledged Segment 6 Sliding Window Size 4 Current Window Gap 1 Sent Segments 1,2 Received Segments 1,2 Last Acknowledged Segment 7 Sliding Window Size 4 Current Window Gap 1 Sent Segments 1,2,0 Received Segments 1,2,0 Last Acknowledged Segment 7 Sliding Window Size 4 Current Window Gap 0 Sent Segments 1,2,0,3 Received Segments 1,2,0,3 Last Acknowledged Segment 7

19 TRANSMISSION CONTROL PROTOCOL Page 74Chapter 3CS 447 To provide reliable Transport service, TCP must use a much more elaborate header than UDP. Source Port: TCP port number of the application at the source station. Acknowledgement Number: Sequence number of the next Transport segment expected from the destination. Reserved: Not currently used. Sequence Number: Position in the sender’s byte stream of this Transport segment. Destination Port: TCP port number of the application at the destination station. Header Length: Total length of the header (in 32-bit multiples). Window Size: Current sliding window size (in bytes) - for end-to-end flow control. Urgent Pointer: Position in the Transport segment where urgent data ends. Code Bits: 6 flags: URG (Is Urgent pointer field valid?), ACK (Is Ack. # Valid?), PSH (Push delivery w/o waiting for full buffer), RST (Reset connection), SYN (Synchronize sequence #s), FIN (End of sender’s byte stream) Checksum: 1’s complement of 1’s complement sum of 16-bit words in header, data, & pseudoheader. Options & Padding: For example, Maximum-Segment-Size, Selective-Repeat, Delay-ACKs. Source Port Destination Port Sequence Number Window Size HdrLen Checksum Options & Padding Acknowledgement Number Urgent Pointer Reserved Code Bits Source Port Destination Port Sequence Number Window Size HdrLen Checksum Options & Padding Acknowledgement Number Urgent Pointer Reserved Code Bits

20 TCP CONGESTION CONTROL Page 75Chapter 3CS 447 Flow control deals with one pair of endstations adjusting transmission rates to accommodate the receiver’s capacity, but congestion control deals with a station’s perception that it might be contributing to an overall network traffic problem. How does a station “perceive” a congestion problem? Duplicate Acknowledgements While ACKs usually indicate that something is successfully getting through the network, duplicate ACK numbers indicate that the segment in question has been lost or corrupted. Acknowledgement Timeouts If no ACK is received in the required time, then it is unknown whether anything is getting through the network and a problem definitely exists.

21 MULTIPLICATIVE DECREASE CONGESTION AVOIDANCE Page 76Chapter 3CS 447 Since endstations cannot pinpoint the cause of perceived congestion problems, TCP dictates that they respond dramatically, as if they are the source of the problem. The standard TCP response to a perceived congestion problem is to have the endstation try to avoid contributing to the problem by setting ssthresh to ½cwnd and then resetting cwnd to mss. This prevents the station from having too many segments, without ACKs, and from returning to a high transmission rate, until the traffic problem has dissipated. TCP handles this response by means of three values: The maximum TCP segment size (mss) that the receiving endstation can accommodate. The slow-start threshold (ssthresh) that prevents a station from recovering too quickly after it has perceived congestion. The congestion window (cwnd) that limits how much unacknowledged traffic a station can have on the network. old cwnd old ssthresh  new cwnd new ssthresh

22 ADDITIVE INCREASE SLOW-START RECOVERY Page 77Chapter 3CS 447 While TCP’s Congestion Avoidance scheme responds severely to bad news about congestion, TCP responds very cautiously to good news about successful transmissions. Whenever a positive ACK is received, the station increases cwnd by 1mss for each acknowledged segment until cwnd reaches ssthresh. To prevent a recurrence of the congestion problem, once cwnd reaches ssthresh, cwnd only increases by 1 mss for every passage of rtt milliseconds (where rtt is the estimated round-trip time for a segment to successfully travel across this connection to its destination and for an ACK to return).


Download ppt "CHAPTER 3: TRANSPORT LAYER TRANSPORT LAYER Transport Layer Services Transport Layer Services Establishing/Releasing Connections Establishing/Releasing."

Similar presentations


Ads by Google