Chapter 3: Transport Layer

Similar documents
Data Communications & Networks. Session 6 Main Theme Reliable Data Transfer. Dr. Jean-Claude Franchitti

Transport Layer Protocols

Names & Addresses. Names & Addresses. Hop-by-Hop Packet Forwarding. Longest-Prefix-Match Forwarding. Longest-Prefix-Match Forwarding

Midterm Exam CMPSCI 453: Computer Networks Fall 2011 Prof. Jim Kurose

Computer Networks. Chapter 5 Transport Protocols

Indian Institute of Technology Kharagpur. TCP/IP Part I. Prof Indranil Sengupta Computer Science and Engineering Indian Institute of Technology

Protocols and Architecture. Protocol Architecture.

SIP: Session Initiation Protocol

Ethernet. Ethernet. Network Devices

CPS221 Lecture: Layered Network Architecture

IP - The Internet Protocol

Network Layer: Network Layer and IP Protocol

Chapter 3. TCP/IP Networks. 3.1 Internet Protocol version 4 (IPv4)

Architecture and Performance of the Internet

Computer Networks UDP and TCP

EITF25 Internet Techniques and Applications L5: Wide Area Networks (WAN) Stefan Höst

Computer Networks. Data Link Layer

Note! The problem set consists of two parts: Part I: The problem specifications pages Part II: The answer pages

Overview. Securing TCP/IP. Introduction to TCP/IP (cont d) Introduction to TCP/IP

Objectives of Lecture. Network Architecture. Protocols. Contents

IP Network Layer. Datagram ID FLAG Fragment Offset. IP Datagrams. IP Addresses. IP Addresses. CSCE 515: Computer Network Programming TCP/IP

Access Control: Firewalls (1)

The OSI model has seven layers. The principles that were applied to arrive at the seven layers can be briefly summarized as follows:

RARP: Reverse Address Resolution Protocol

COMP 361 Computer Communications Networks. Fall Semester Midterm Examination

ICOM : Computer Networks Chapter 6: The Transport Layer. By Dr Yi Qian Department of Electronic and Computer Engineering Fall 2006 UPRM

[Prof. Rupesh G Vaishnav] Page 1

Final for ECE374 05/06/13 Solution!!

How To Design A Layered Network In A Computer Network

CMPE 150 Winter 2009

Network Programming TDC 561

Chapter 11. User Datagram Protocol (UDP)

Networking Test 4 Study Guide

Understanding TCP/IP. Introduction. What is an Architectural Model? APPENDIX

Data Link Layer(1) Principal service: Transferring data from the network layer of the source machine to the one of the destination machine

CSE331: Introduction to Networks and Security. Lecture 9 Fall 2006

Transport Layer. Chapter 3.4. Think about

8.2 The Internet Protocol

First Midterm for ECE374 03/09/12 Solution!!

Internet Concepts. What is a Network?

Protocols. Packets. What's in an IP packet

TCP in Wireless Mobile Networks

CSE 473 Introduction to Computer Networks. Exam 2 Solutions. Your name: 10/31/2013

Internet Control Protocols Reading: Chapter 3

TCP Flow Control. TCP Receiver Window. Sliding Window. Computer Networks. Lecture 30: Flow Control, Reliable Delivery

PART OF THE PICTURE: The TCP/IP Communications Architecture

COMP 3331/9331: Computer Networks and Applications. Lab Exercise 3: TCP and UDP (Solutions)

Stop And Wait. ACK received; transmit frame 2 CS 455 3

SFWR 4C03: Computer Networks & Computer Security Jan 3-7, Lecturer: Kartik Krishnan Lecture 1-3

Lecture 2: Protocols and Layering. CSE 123: Computer Networks Stefan Savage

TCP Offload Engines. As network interconnect speeds advance to Gigabit. Introduction to

Networking part 3: the transport layer

Basic Networking Concepts. 1. Introduction 2. Protocols 3. Protocol Layers 4. Network Interconnection/Internet

Transport and Network Layer

B-2 Analyzing TCP/IP Networks with Wireshark. Ray Tompkins Founder of Gearbit

Lecture 28: Internet Protocols

Internet Protocols. Background CHAPTER

Computer Network. Interconnected collection of autonomous computers that are able to exchange information

Course Overview: Learn the essential skills needed to set up, configure, support, and troubleshoot your TCP/IP-based network.

Chapter 5. Transport layer protocols

Network-Oriented Software Development. Course: CSc4360/CSc6360 Instructor: Dr. Beyah Sessions: M-W, 3:00 4:40pm Lecture 2

How do I get to

Computer Networks and the Internet

Note! The problem set consists of two parts: Part I: The problem specifications pages Part II: The answer pages

What is CSG150 about? Fundamentals of Computer Networking. Course Outline. Lecture 1 Outline. Guevara Noubir noubir@ccs.neu.

Data Link Layer. Flow Control. Flow Control

Asynchronous Transfer Mode: ATM. ATM architecture. ATM: network or link layer? ATM Adaptation Layer (AAL)

Module 1. Introduction. Version 2 CSE IIT, Kharagpur

(Refer Slide Time: 02:17)

Protocol Data Units and Encapsulation

PART-A Questions. 9. What are the two parts of message inside the envelope?

How To Understand The Internet Of S (Netware)

Chapter 3. Internet Applications and Network Programming

Improving the Performance of TCP Using Window Adjustment Procedure and Bandwidth Estimation

Strategies. Addressing and Routing

Computer Networks & Security 2014/2015

Multimedia Communications Voice over IP

The OSI Model and the TCP/IP Protocol Suite PROTOCOL LAYERS. Hierarchy. Services THE OSI MODEL

Communications and Computer Networks

Data Communication and Computer Network

Outline. TCP connection setup/data transfer Computer Networking. TCP Reliability. Congestion sources and collapse. Congestion control basics

Data Link Layer Overview

R2. The word protocol is often used to describe diplomatic relations. How does Wikipedia describe diplomatic protocol?

CS268 Exam Solutions. 1) End-to-End (20 pts)

Final Exam. Route Computation: One reason why link state routing is preferable to distance vector style routing.

CSIS CSIS 3230 Spring Networking, its all about the apps! Apps on the Edge. Application Architectures. Pure P2P Architecture

BCS THE CHARTERED INSTITUTE FOR IT. BCS HIGHER EDUCATION QUALIFICATIONS BCS Level 5 Diploma in IT COMPUTER NETWORKS

How Does Ping Really Work?

THE TCP/IP PROTOCOL SUITE

TCP over Multi-hop Wireless Networks * Overview of Transmission Control Protocol / Internet Protocol (TCP/IP) Internet Protocol (IP)

How To Understand The Layered Architecture Of A Network

Per-Flow Queuing Allot's Approach to Bandwidth Management

- Hubs vs. Switches vs. Routers -

Network Simulation Traffic, Paths and Impairment

Advanced Computer Networks Project 2: File Transfer Application

Computer Networks. A Top-Down Approach. Behrouz A. Forouzan. and. Firouz Mosharraf. \Connect Mc \ Learn. Hill

Improved Digital Media Delivery with Telestream HyperLaunch

First Workshop on Open Source and Internet Technology for Scientific Environment: with case studies from Environmental Monitoring

Title: DEVELOPING TCP/IP AND UDP TRAFFIC MONITORING TOOL. RAFIQ BIN CHE MAT ( )

technology standards and protocol for ip telephony solutions

Transcription:

Chapter 3: Transport Layer Silvia Giordano ICA, EPFL 3: Transport Layer 3-1 The transport layer has the critical role of providing communication services directly to the application processes running on different hosts in the network. We examine the possible services provided by a transport-layer protocol and the principles underlying various approaches toward providing these services. We'll also look at how these services are implemented and instantiated in existing protocols; as usual, particular emphasis will be given to the Internet protocols, namely, the TCP and UDP transport-layer protocols. 1

Transport Layer Chapter goals: understand principles behind transport layer services: multiplexing/demultiplex ing reliable data transfer flow control congestion control Chapter Overview: transport layer services multiplexing/demultiplexing connectionless transport: UDP principles of reliable data transfer connection-oriented transport: TCP reliable transfer flow control connection management principles of congestion control TCP congestion control 3: Transport Layer 3-2 2

Transport services and protocols provide logical communication between app processes running on different hosts transport protocols run in end systems application transport network data link physical network data link physical logical end -end transport network data link physical network data link physical network data link physical network data link physical application transport network data link physical 3: Transport Layer 3-3 A transport-layer protocol provides for logical communication between application processes running on different hosts. By logical communication, we mean that although the communicating application processes are not physically connected to each other (indeed, they may be on different sides of the planet, connected via numerous routers and a wide range of link types), from the applications' viewpoint, it is as if they were physically connected. Application processes use the logical communication provided by the transport layer to send messages to each other, free from the worry of the details of the physical infrastructure used to carry these messages. Transport-layer protocols are implemented in the end systems but not in network routers. Network routers only act on the network-layer fields of the layer-3 PDUs; they do not act on the transport-layer fields. On the sending side, the transport layer converts the messages it receives from a sending application process into layer-4 PDUs (that is, transport-layer protocol data units). This is done by (possibly) breaking the application messages into smaller chunks and adding a transport-layer header to each chunk to create layer-4 PDUs. The transport layer then passes the layer-4 PDUs to the network layer, where each layer-4 PDU is encapsulated into a layer-3 PDU. On the receiving side, the transport layer receives the layer-4 PDUs from the network layer, removes the transport header from the layer-4 PDUs, reassembles the messages, and passes them to a receiving application process. 3

transport vs network layer services segment - unit of data exchanged between transport layer entities aka TPDU: transport protocol data unit IP service model: best-effort delivery service network layer: data transfer between end systems transport layer: data transfer between processes relies on, enhances, network layer services source destination Ht Hn Ht Hl Hn Ht M M M M application transport network link physical PDU SDU application transport network link physical Ht HnHt Hl HnHt M M M M message segment datagram frame 3: Transport Layer 3-4 To simplify terminology, when in an Internet context, we refer to the 4-PDU as a segment. We mention, however, that the Internet literature (for example, the RFCs) also refers to the PDU for TCP as a segment but often refers to the PDU for UDP as a datagram. But this same Internet literature also uses the terminology datagram for the network-layer PDU! The Internet's network-layer protocol has a name--ip, for Internet Protocol. IP provides logical communication between hosts. The IP service model is a besteffort delivery service. This means that IP makes its "best effort" to deliver segments between communicating hosts, but it makes no guarantees. In particular, it does not guarantee segment delivery, it does not guarantee orderly delivery of segments, and it does not guarantee the integrity of the data in the segments. For these reasons, IP is said to be an unreliable service. Every host has a unique IP address. The transport layer lies just above the network layer in the protocol stack. Whereas a transport-layer protocol provides logical communication between processes running on different hosts, a network-layer protocol provides logical communication between hosts. This distinction is subtle but important. 4

Transport-layer protocols Internet transport services: reliable, in-order unicast delivery (TCP) congestion flow control connection setup unreliable ( best-effort ), unordered unicast or multicast delivery: UDP services not available: real-time bandwidth guarantees reliable multicast application transport network data link physical network data link physical logical end -end transport network data link physical network data link physical network data link physical network data link physical application transport network data link physical 3: Transport Layer 3-5 A computer network can make more than one transport-layer protocol available to network applications. The Internet, and more generally a TCP/IP network, makes available two distinct transport -layer protocols to the application layer: UDP (User Datagram Protocol), which provides an unreliable, connectionless service to the invoking application, and TCP (Transmission Control Protocol), which provides a reliable, connection-oriented service to the invoking application. When designing a network application, the application developer must specify one of these two transport protocols when creating sockets. Having taken a glimpse at the IP service model, let's now summarize the service model of UDP and TCP. The most fundamental responsibility of UDP and TCP is to extend IP's delivery service between two end systems to a delivery service between two processes running on the end systems. Extending host-to-host delivery to process-to-process delivery is called application multiplexing and demultiplexing. We'll discuss application multiplexing and demultiplexing in the next section. UDP and TCP also provide integrity checking by including error-detection fields in their headers. These two minimal transport -layer services--process-to-process data delivery and error checking--are the only two services that UDP provides! In particular, like IP, UDP is an unreliable service--it does not guarantee that data sent by one process will arrive intact to the destination process. TCP, on the other hand, offers several additional services to applications. First and foremost, it provides reliable data transfer. Using flow control, sequence numbers, acknowledgments, and timers (techniques we'll explore in detail in this chapter), TCP ensures that data is delivered from sending process to receiving process, correctly and in order. TCP thus converts IP's unreliable service between end systems into a reliable data transport service between processes. TCP also uses congestion control. Congestion control is not so much a service provided to the invoking application as it is a service for the Internet as a whole, a service for the general good. In loose terms, TCP congestion control prevents any one TCP connection from swamping the links and switches between communicating hosts with an excessive amount of traffic. In principle, TCP permits TCP connections traversing a congested network link to equally share that link's bandwidth. This is done by regulating the rate at which the sending-side TCPs can send traffic into the network. UDP traffic, on the other hand, is unregulated. An application using UDP transport can send at any rate it pleases, for as long as it pleases. 5

Multiplexing/demultiplexing Multiplexing: gathering data at source from different app layer processes and put them on the same link Demultiplexing: delivering received segments to correct app layer processes M/D: based on sender, receiver port numbers, IP addresses Statistical and non-statistical multiplexing receiver application-layer data segment P3 header segment P1 M application transport network H t M H n segment multiplexing M M M application transport network P4 P5 P2 P6 M M application transport network receiver network data link physical demultiplexing 3: Transport Layer 3-6 A multiplexing/demultiplexing service is needed for all computer networks. Each transport-layer segment has a set of fields that determine the process to which the segment's data is to be delivered. At the receiving end, the transport layer can then examine these fields to determine the receiving process and then direct the segment to that process. This job of delivering the data in a transport-layer segment to the correct application process is called demultiplexing. The job of gathering data at the source host from different application processes, enveloping the data with header information (that will later be used in demultiplexing) to create segments, and passing the segments to the network layer is called multiplexing. Multiplexing can be statistical (packet switching) and non-statistical (i.e. time division circuit switching). With statistical multiplexing the network bit rate is less than the sum of the bit rates produced by the different application layer processes. This may produce packet loss (therefore it implies congestion control). 6

UDP: User Datagram Protocol [RFC 768] no frills, bare bones Internet transport protocol best effort service, UDP segments may be: lost delivered out of order to app connectionless: no handshaking between UDP sender, receiver each UDP segment handled independently of others Why is there a UDP? no connection establishment (which can add delay) simple: no connection state at sender, receiver small segment header no congestion control: UDP can blast away as fast as desired 3: Transport Layer 3-7 UDP is a vacuous transport protocol, that does just about as little as a transport protocol can do. In particular, on the sending side, it does not provide much more than taking the messages from the application process and passing them directly to the network layer; and on the receiving side, more than taking the messages arriving from the network layer and passing them directly to the application process. More than this, UDP provides a multiplexing/demultiplexing service in order to pass data between the network layer and the correct process. However, aside from the multiplexing/demultiplexing function and some light error checking, it adds nothing to IP. In fact, if the application developer chooses UDP instead of TCP, then the application is almost directly talking with IP. UDP takes messages from the application process, attaches source and destination port number fields for the multiplexing/demultiplexing service, adds two other small fields, and passes the resulting segment to the network layer. The network layer encapsulates the segment into an IP datagram and then makes a best-effort attempt to deliver the segment to the receiving host. If the segment arrives at the receiving host, UDP uses the port numbers and the IP destination address to deliver the segment's data to the correct application process. Note that with UDP there is no handshaking between sending and receiving transport-layer entities before sending a segment. For this reason, UDP is said to be connectionless. No connection establishment. As we'll discuss later, TCP uses a three-way handshake before it starts to transfer data. UDP just blasts away without any formal preliminaries. Thus UDP does not introduce any delay to establish a connection. No connection state. UDP does not maintain connection state (receive and send buffers, congestion-control parameters, and sequence and acknowledgment number parameters ) and does not track any of these parameters. For this reason, a server devoted to a particular application can typically support several active clients when the application runs over UDP. Small packet header overhead. The UDP segment has only 8 bytes of header overhead in every segment. Unregulated send rate. The speed at which UDP sends data is only constrained by the rate at which the application generates data, the capabilities of the source (CPU, clock rate, and so on) and the access bandwidth to the Internet. We should keep in mind, however, that the receiving host does not necessarily receive all the data. When the network is congested, some of the data could be lost due to router buffer overflow. Thus, the receive rate can be limited by network congestion even if the sending rate is not constrained. 7

UDP: more often used for streaming multimedia apps loss tolerant rate sensitive other UDP uses DNS SNMP reliable transfer over UDP: add reliability at application layer application-specific error recover! Length, in bytes of UDP segment, including header source port # dest port # length 32 bits Application data (message) checksum UDP segment format 3: Transport Layer 3-8 Many important applications run over UDP. UDP is used for RIP routing table updates, because the updates are sent periodically (typically every five minutes), so that lost updates are replaced by more recent updates. UDP is used to carry network management (SNMP) data. UDP is preferred to the more reliable TCP in this case, since network management applications must often run when the network is in a stressed state--precisely when reliable, congestioncontrolled data transfer is difficult to achieve. Also DNS runs over UDP, thereby having no connection-establishment delays. UDP is also commonly used today with multimedia applications, such as Internet phone, real-time video conferencing, and streaming of stored audio and video. all of these applications can tolerate a small fraction of packet loss, so that reliable data transfer is not absolutely critical for the success of the application. Furthermore, real-time applications, like Internet phone and video conferencing, react very poorly to (TCP's) congestion control. For these reasons, developers of multimedia applications often choose to run their applications over UDP instead of TCP. Finally, because TCP cannot be employed with multicast, multicast applications run over UDP. Although commonly done today, running multimedia applications over UDP is controversial to say the least. In fact, UDP has no congestion control. But congestion control is needed to prevent the network from entering a state in which very little useful work is done. It is possible for an application to have reliable data transfer when using UDP. This can be done if reliability is built into the application itself (for example, by adding acknowledgment and retransmission mechanisms, such as those we shall study in the next section). In the UDP segment structure the application data occupies the data field of the UDP datagram. The UDP header has only four fields, each consisting of two bytes. The port numbers allow the destination host to pass the application data to the correct process running on the destination (that is, the demultiplexing function). The checksum is used by the receiving host to check if errors have been introduced into the segment. The length field specifies the length of the UDP segment, including the header, in bytes. 8

UDP checksum Verify source and destination addresses Verify port numbers Verify the data Sender: treat segment contents as sequence of 16-bit integers checksum: addition (1 s complement sum) of segment contents sender puts checksum value into UDP checksum field Receiver: compute checksum of received segment check if computed checksum equals checksum field value: NO - error detected YES - no error detected. But maybe errors nonethless? More later. 3: Transport Layer 3-9 The UDP checksum provides for error detection. The checksum is used by the receiving host to check if errors have been introduced into the segment. UDP at the sender side performs the one's complement of the sum of all the 16-bit words in the segment. This result is put in the checksum field of the UDP segment. You can find details about efficient implementation of the calculation in the RFC 1071. UDP provides a checksum, even if many link-layer protocols (including the popular Ethernet protocol) also provide error checking, because there is no guarantee that all the links between source and destination provide error checking--one of the links may use a protocol that does not provide error checking. Because IP is supposed to run over just about any layer-2 protocol, it is useful for the transport layer to provide error checking as a safety measure. Although UDP provides error checking, it does not do anything to recover from an error. Some implementations of UDP simply discard the damaged segment; others pass the damaged segment to the application with a warning. 9

Checksum example As an example, suppose that we have the following three 16-bit words: 0110011001100110 0101010101010101 0000111100001111 The sum of these 16-bit words is 110011001100110 0101010101010101 0000111100001111 1100101011001010 The 1's complement is obtained by converting all the 0s to 1s and converting all the 1s to 0s: checksu m is 0011010100110101 At the receiver, all four 16-bit words are added, including the checksum. If no errors are introduced into the packet, then clearly the sum at the receiver will be 1111111111111111. If one of the bits is a zero, then we know that errors have been introduced into the packet. What if more than one bit is garbled? 3: Transport Layer 3-10 As an example, suppose that we have the following three 16-bit words: 0110011001100110 0101010101010101 0000111100001111 The sum of first of these 16-bit words is 0110011001100110 0101010101010101 1011101110111011 Adding the third word to the above sum gives 1011101110111011 0000111100001111 1100101011001010 The 1's complement is obtained by converting all the 0s to 1s and converting all the 1s to 0s. Thus the 1's complement of the sum 1100101011001010 is 0011010100110101, which becomes the checksum. At the receiver, all four 16-bit words are added, including the checksum. If no errors are introduced into the packet, then clearly the sum at the receiver will be 1111111111111111. If one of the bits is a zero, then we know that errors have been introduced into the packet. The checksum is also calculated over a few of the fields in the IP header in addition to the UDP segment. 10

Principles of Reliable data transfer important in app., transport, link layers data are received ordered and error-free characteristics of unreliable channel will determine complexity of reliable data transfer protocol (rdt) 3: Transport Layer 3-11 Reliable data transfer means that the data are received ordered and error-free. The problem of implementing reliable data transfer occurs not only at the transport layer, but also at the link layer and the application layer as well. The service abstraction provided to the upper layer entities is that of a reliable channel, where no transferred data bits are corrupted or lost, and all are delivered in the order in which they were sent. This is precisely the service model offered by TCP to the Internet applications that invoke it. It is the responsibility of a reliable data transfer protocol to implement this service abstraction. This task is made difficult by the fact that the layer below the reliable data transfer protocol may be unreliable. For example, TCP is a reliable data transfer protocol that is implemented on top of an unreliable (IP) end-end network layer. 11

Reliable data transfer Our approach: analyze reliable data transfer protocol (rdt) use finite state machines (FSM) to specify the model introduce gradually the Elements of Procedure (EoP) state: when in this state next state uniquely determined by next event state 1 event causing state transition actions taken on state transition event actions state 2 3: Transport Layer 3-12 We analyze the main elements of a reliable data transfer protocol, using finite state machine to specify the models of the sender and the receiver. The generic term "packet" is seen as more appropriate, and used here rather than "segment" for the protocol data unit, given that the concepts of a reliable data transfer protocol applies to computer networks in general. We talk about Elements of Procedure (EoP) as the elements for obtaining a reliable data transfer that are not limited to transport layer, but exist in general in Communication Networks. 12

Elements of Procedure Elements of Procedure transform a raw, unreliable frame transport mechanism into a reliable data pipe ordered delivery of packets loss-free as long as the connection is alive no buffer overflow Elements of procedure usually means the set of following functions Error detection and correction (e.g. ARQ - Automatic Repeat request) Flow Control Connection Management Elements of procedure exist in reliable transport (TCP for the TCP/IP architecture) (layer 4) also: in reliable data link (ex: over radio channels, over modems - layer 2) as HDLC Congestion Control 3: Transport Layer 3-13 The Elements of Procedure (EoP) transform a raw, unreliable frame transport mechanism into a reliable data pipe by delivering the packets in order and without losses, and avoiding buffer overflow. With EoP is usually addressed three following functions: Error detection and correction Various ways exists to carry out this process. However, techniques based on checks (parity) bits are not generally adopted for data networking, because they need too many bits to ensure the level of error correction required. Instead, ARQ (Automatic Repeat request) protocols - reliable data transfer protocols based on retransmission has been universally adopted. Flow-Control to eliminate the possibility of the sender overflowing the receiver's buffer. Flow control is thus a speed matching service--matching the rate at which the sender is sending to the rate at which the receiving application is reading. Connection Management: reliable data transfer must be connection oriented. In order to control the connection two phases are needed: connection setup and connection release. Applications that use UDP must implement some form of equivalent control, if the application cares about not loosing data. UDP applications (like NFS, DNS) typically send data blocks and expect a response, which can be used as an application layer acknowledgement. Finally, as is the case of TCP, we can also have congestion control to avoid network congestion. 13

ARQ Protocols and Services There is not one ARQ protocol, but a family of protocols. Examples: TCP (transport layer of the Internet) HDLC or MNP (data link layer over modems) LLC-2 (data link layer over LANs, used with SNA) Stop and Go (interface between a CPU and a peripheral) The service offered by all ARQ protocols is ordered, loss-free, error-free delivery of packets ARQ protocol differs in their design point does the lower layer preserve sequence? yes: HDLC, LLC-2 no: TCP 3: Transport Layer 3-14 ARQ (Automatic Repeat request) protocols offers services of packet ordering (packets are delivered in the same ordered they are sent); loss-free: packets are delivered without losses; error free: packets are guaranteed to be delivered without errors. ARQ protocols are based on retransmission. For example, when you listen to someone else, you either let him know you got the message with a positive acknowledgments (e.g. "OK") or that you lost the message and you want him to repeat it with a negative acknowledgments (e.g. "Please repeat that."). ARQ is not a single protocol but rather a family of protocols (at different layers, transport, datalink, etc ) that have in common the usage of retransmission and the service they offer, but that differ in their design point. 14

Elements of ARQ The elements of an ARQ protocol are: Sliding window: used by all protocols Error and Loss detection at sender versus at source timeout versus gap detection Acknowledgements: short control packets cumulative versus selective positive (ACK) versus negative (NAK) Retransmission Strategy Selective Repeat Go Back n Others 3: Transport Layer 3-15 All ARQ protocols we will use are based on the principle of sliding window. Loss detection can be performed by a timer at the source (see the Stop and Wait example). Other methods are: gap detection at the destination (see the Go Back n example and TCP s fast retransmit heuristic). Acknowledgements can be cumulative : acknowledging n means all data numbered up to n has been received. Selective acknowledgements mean that only a given packet, or explicit lis t of packets is acknowledged. A positive acknowledgement indicates that the data has been received. A negative acknowledgement indicates that the data has not been received; it is a request for retransmission, issued by the destination. The retransmission strategy can be go back n, selective repeat, or any combination. Go back n, selective repeat are explained in the following slides. Fundamentally, three additional protocol capabilities are required in ARQ protocols to handle the presence of bit errors: Error detection. First, a mechanism is needed to allow the receiver to detect when bit errors have occurred. We saw that UDP uses the Internet checksum field for error detection, but we also need techniques to allow the receiver, once detected) to possibly correct packet bit errors. These techniques require that extra bits (beyond the bits of original data to be transferred) be sent from the sender to receiver; these bits will be gathered into the packet checksum field of the data packet. Receiver feedback. Since the sender and receiver are typically executing on different end systems, possibly separated by thousands of miles, the only way for the sender to learn whether or not a packet was received correctly by the receiver is for the receiver to provide explicit feedback to the sender. The positive (ACK) and negative (NAK) acknowledgment replies are examples of such feedback. In principle, these packets need only be one bit long; for example, a 0 value could indicate a NAK and a value of 1 could indicate an ACK. Retransmission. A packet that is received in error at the receiver will be retransmitted by the sender. 15

The Principle of Sliding Window (W=4) Legend 0 1 2 3 4 5 6 7 8 9 10 11 12 P = 0 0 1 2 3 4 5 6 7 8 9 10 11 12 A = 0 Maximum Send Window = Offered Window ( = 4 here) Usable Window 0 1 2 3 4 5 6 7 8 9 10 11 12 0 1 2 3 4 5 6 7 8 9 10 11 12 0 1 2 3 4 5 6 7 8 9 10 11 12 0 1 2 3 4 5 6 7 8 9 10 11 12 0 1 2 3 4 5 6 7 8 9 10 11 12 0 1 2 3 4 5 6 7 8 9 10 11 12 wait 0 1 2 3 4 5 6 7 8 9 10 11 12 0 1 2 3 4 5 6 7 8 9 10 11 12 0 1 2 3 4 5 6 7 8 9 10 11 12 0 1 2 3 4 5 6 7 8 9 10 11 12 0 1 2 3 4 5 6 7 8 9 10 11 12 0 1 2 3 4 5 6 7 8 9 10 11 12 P = 1 P = 2 P = 3 P = 4 P = 5 P = 6 P = 7 P = 8 P = 9 P = 10 A =1 A =2 A =3 A =4 A =5 A =6 A =7 3: Transport Layer 3-16 The sliding window principle works as follows (on the example, packets are numbered 0, 1, 2,..): - a window size W is defined. On this example it is fixed. In general, it can vary based on messages sent by the receiver. The sliding window principles requires that, at any time: number of unacknowledged packets at the receiver <= W - the maximum send window, also called offered window is the set of packet numbers for packets that either have been sent but are not (yet) acknowledged or have not been sent but may be sent. - the usable window is the set of packet numbers for packetst hat may be sent for the first time. The usable window is always contained in the maximum send window. - the lower bound of the maximum send window is the smallest packet number that has been sent and not acknowledged - the maximum window slides (moves to the right) if the acknowledgement for the packet with the lowest number in the window is received A sliding window protocol is a protocol that uses the sliding window principle. With a sliding window protocol, W is the maximum number of packets that the receiver needs to buffer in the resequencing (= receive) buffer. If there are no losses, a sliding window protocol can have a throughput of 100% of link rate (if overhead is not accounted for) if the window size satisfies: W b / L, where b is the bandwidth delay product, and L the packet size. Counted in bytes, this means that the minimum window size for 100% utilization is the bandwidth-delay product. 16

Last Week Our study of network apps is now complete! application service requirements: reliability, bandwidth, delay client-server paradigm Internet transport service model connection-oriented, reliable: TCP unreliable, datagrams: UDP specific protocols: http ftp smtp socket programming client/server implementation using tcp, udp sockets java programms 3: Transport Layer 3-17 17

Last week(2) started to transfer the apps data: Transport Layer Logical communication between processes multiplexing/demultiplexing Internet: connectionless transport: UDP: just IP + mux/demux & checksum connection-oriented transport: TCP Reliable data transfer data are received ordered and error-free Elements of procedure usually means the set of following functions Error detection and correction (e.g. ARQ ) Flow Control Connection Management Automatic Repeat request Sliding window: Error and Loss detection Acknowledgements: short control packets Retransmission Strategy Stop & Go Selective Repeat Go Back n 3: Transport Layer 3-18 18

ACK/NAK handling ACKs & NAKs: short control packets cumulative versus selective positive (ACK) versus negative (NAK) Stop and wait The sender waits for an ACK/NAK Only one packet at time can be transmitted Go back N packets are transmitted without waiting for an ACK All following packets are resent on receipt of NAK Selective repeat procedure Only packets negatively acknowledged are resent 3: Transport Layer 3-19 There are a number of ways of handling the response to ACK/NAK. The three most commonly identified procedures are the following: Stop and wait: The sender can send only one packet at time and have to wait for an ACK/NAK. If a NAK is received or a timeout expires the packet is retransmitted. If an ACK arrives the current packet is dropped by the sender buffer. Go back N: The packets are transmitted without waiting for an ACK. If a NAK is received or a timeout expires the packet in question and all the packets following are retransmitted. Selective repeat procedure Only packets negatively acknowledged, or for which the timeout has expired without receiving an ACK, are resent. 19

Retransmission Strategies underlying channel can garble and lose packets (data or ACKs) checksum, seq. #, ACKs, retransmissions will be of help, but not enough to deal with loss & errors: sender waits until certain time, then retransmits duplicate Approach: sender waits reasonable amount of time for ACK retransmits if no ACK or NAK received in this time if pkt (or ACK) just delayed (not lost): retransmission will be duplicate, but use of seq. # s already handles this receiver must specify seq # of pkt being ACKed requires countdown timer 3: Transport Layer 3-20 If the underlying channel can lose packets as well, two additional concerns must now be addressed by the protocol: how to detect packet loss and what to do when packet loss occurs. This can be done with the use of checksumming, sequence numbers, ACK packets, and retransmissions. To deal with loss, the sender could wait long enough so that it is certain that a packet has been lost, and then t can simply retransmit the data packet. However, cannot wait forever. The sender must clearly wait at least as long as a round-trip delay between the sender and receiver (which may include buffering at intermediate routers or gateways) plus whatever amount of time is needed to process a packet at the receiver. In many networks, this worst-case maximum delay is very difficult to even estimate, much less know with certainty. Moreover, the protocol should ideally recover from packet loss as soon as possible; waiting for a worstcase delay could mean a long wait until error recovery is initiated. The approach thus adopted in practice is for the sender to "judiciously" choose a time value such that packet loss is likely, although not guaranteed, to have happened. If an ACK is not received within this time, the packet is retransmitted. Note that if a packet experiences a particularly large delay, the sender may retransmit the packet even though neither the data packet nor its ACK have been lost. This introduces the possibility of duplicate data packets in the sender-to-receiver channel, that we already see how to handle. From the sender's viewpoint, retransmission is a panacea. The sender does not know whether a data packet was lost, an ACK was lost, or if the packet or ACK was simply overly delayed. In all cases, the action is the same: retransmit. In order to imple ment a time-based retransmission mechanism, a countdown timer will be needed that can interrupt the sender after a given amount of timer has expired. The sender will thus need to be able to (1) start the timer each time a packet (either a first-time packet, or a retransmission) is sent, (2) respond to a timer interrupt (taking appropriate actions), and (3) stop the timer. 20

Stop-and-Wait stop and wait Sender sends one packet, then waits for receiver response Maximum Send Window = 1 Usable Window 0 1 2 3 4 5 6 7 8 9 10 11 12 0 1 2 3 4 5 6 7 8 9 10 11 12 wait 0 1 2 3 4 5 6 7 8 9 10 11 12 0 1 2 3 4 5 6 7 8 9 10 11 12 wait 0 1 2 3 4 5 6 7 8 9 10 11 12 0 1 2 3 4 5 6 7 8 9 10 11 12 wait 2 problems: Ack/Nak corrupted long idle periods P = 0 A = 0 P = 1 A =1 P = 2 3: Transport Layer 3-21 The send side has two states. In one state, the send-side protocol is waiting for data to be passed down from the upper layer. In the other state, the sender protocol is waiting for an ACK or a NAK packet from the receiver. It is important to note that when the receiver is in the wait-for-ack-or-nak state, it cannot get more data from the upper layer; that will only happen after the sender receives an ACK and leaves this state. Thus, the sender will not send a new piece of data until it is sure that the receiver has correctly received the current packet. Because of this behavior, protocols such as this one are known as stop-and-wait protocols. The receiver-side FSM has a single state. On packet arrival, the receiver replies with either an ACK or a NAK, depending on whether or not the received packet is corrupted. There are two limitations with Stop and Wait: ACK and NAK can get corrupted. A solution is to introduce sequence numbers. a little efficiency because of idle periods, when the bandwidth delay product is not negligible. A solution is to allow multiple transmissions, which in turn requires a sliding window in order to avoid unlimited buffer at the destination. 21

Stop and Wait improvement - a flag to the packets: sequence # What happens if ACK/NAK corrupted? sender doesn t know what happened at receiver! can t just retransmit: possible duplicate What to do? sender ACKs/NAKs receiver s ACK/NAK? What if sender ACK/NAK lost? retransmit, but this might cause retransmission of correctly received pkt! Handling duplicates: sender adds a flag to each pkt sender retransmits current pkt if ACK/NAK garbled receiver discards (doesn t deliver up) duplicate pkt Packet loss: receiver adds an acknowledgment field to each ACK sender knows which packet has been received 3: Transport Layer 3-22 Minimally, we will need to add checksum bits to ACK/NAK packets in order to detect such errors. The more difficult question is how the protocol should recover from errors in ACK or NAK packets. The difficulty here is that if an ACK or NAK is corrupted, the sender has no way of knowing whether or not the receiver has correctly received the last piece of transmitted data. If we add a new message (e.g. "What did you say?" ) even this message can get lost, and we are at the same point. If we just retransmit we could introduce duplicate packets into the sender-to-receiver channel. The fundamental difficulty with duplicate packets is that the receiver doesn't know whether the ACK or NAK it last sent was received correctly at the sender. Thus, it cannot know a priori whether an arriving packet contains new data or is a retransmission! A simple solution to this new problem (and one adopted in almost all existing data-transfer protocols including TCP) is to add a new field to the data packet and have the sender number its data packets by putting a flag (sometimes referred to as sequence number) into this field. The receiver then need only check this sequence number to determine whether or not the received packet is a retransmission. The existence of sender-generated duplicate packets and packet (data, ACK) loss also complicates the sender's processing of any ACK packet it receives. If an ACK is received, how is the sender to know if it was sent by the receiver in response to its (sender's) own most recently transmitted packet, or is a delayed ACK sent in response to an earlier transmission of a different data packet? The solution to this dilemma is to augment the ACK packet with an acknowledgment field. When the receiver generates an ACK, it will copy the sequence number of the data packet being acknowledged into this acknowledgment field. By examining the contents of the acknowledgment field, the sender can determine the sequence number of the packet being positively acknowledged. 22

Performance of Stop and Go example: 1 Gbps link, 15 ms e-e prop. delay, 1KB packet: T propagation T transmit = 8kb/pkt 10**9 b/sec = 8 microsec T = 15+0.008 = 30.016 msec total = T + transmit T propagation fraction of time Utilization = U = = sender busy sending 8 microsec 30.016 msec = 0.00015 1KB pkt every 30 msec -> 33kB/sec thruput over 1 Gbps link network protocol limits use of physical resources! 3: Transport Layer 3-23 Stop and Wait protocol based are functionally correct protocols, but it is unlikely that anyone would be happy with its performance, particularly in today's high-speed networks. To appreciate the performance impact of this stop-and-wait behavior, consider an idealized case of two end hosts, one located on the West Coast of the United States and the other located on the East Coast. The speed-of-light propagation delay, T prop, between these two end systems is approximately 15 milliseconds. Suppose that they are connected by a channel with a capacity, C, of 1 gigabit (10 9 bits) per second. With a packet size, SP, of 1 Kbytes per packet including both header fields and data, the time needed to actually transmit the packet into the 1Gbps link is With our stop-and-wait protocol, if the sender begins sending the packet at t = 0, then at t = 8 microseconds, the last bit enters the channel at the sender side. The packet then makes its 15- msec cross-country journey, with the last bit of the packet emerging at the receiver at t = 15.008 msec. Assuming for simplicity that ACK packets are the same size as data packets and that the receiver can begin sending an ACK packet as soon as the last bit of a data packet is received, the last bit of the ACK packet emerges back at the receiver at t = 30.016 msec. Thus, in 30.016 msec, the sender was busy (sending or receiving) for only 0.016 msec. If we define the utilization of the sender (or the channel) as the fraction of time the sender is actually busy sending bits via the channel, we have a rather dismal sender utilization, U sender. That is, the sender was busy only 1.5 hundredths of one percent of the time. Viewed another way, the sender was only able to send 1 kilobyte in 30.016 milliseconds, an effective throughput of only 33 kilobytes per second--even though a 1 gigabit per second link was available. 23

Pipelined protocols Pipelining: sender allows multiple, in-flight, yet-tobe-acknowledged pkts range of sequence numbers must be increased buffering at sender and/or receiver Two generic forms of pipelined protocols: go-back-n, selective repeat 3: Transport Layer 3-24 The solution to this particular performance problem is a simple one: rather than operate in a stop-and-wait manner, the sender is allowed to send multiple packets without waiting for acknowledgments, as shown in Figure 3.17(b). Since the many in-transit sender-to-receiver packets can be visualized as filling a pipeline, this technique is known as pipelining. Pipelining has several consequences for reliable data transfer protocols: The range of sequence numbers must be increased, since each in-transit packet (not counting retransmissions) must have a unique sequence number and there may be multiple, in-transit, unacknowledged packets. The sender and receiver sides of the protocols may have to buffer more than one packet. Minimally, the sender will have to buffer packets that have been transmitted, but not yet acknowledged. Buffering of correctly received packets may also be needed at the receiver, as discussed below. The range of sequence numbers needed and the buffering requirements will depend on the manner in which a data transfer protocol responds to lost, corrupted, and overly delayed packets. Two basic approaches toward pipelined error recovery can be identified: Go-Back-N and selective repeat. Both these protocols are based on the principle of sliding window. 24

Go-Back-N (GBN) Sender: k-bit seq # in pkt header window of up to N, consecutive unack ed pkts allowed ACK(n): ACKs all pkts up to, including seq # n - cumulative ACK may deceive duplicate ACKs (see receiver) timer for each in-flight pkt timeout(n): retransmit pkt n and all higher seq # pkts in window 3: Transport Layer 3-25 In a Go -Back-N (GBN) protocol, the sender is allowed to transmit multiple packets (when available) without waiting for an acknowledgment, but is constrained to have no more than some maximum allowable number, N, of unacknowledged packets in the pipeline. The figure shows the sender's view of the range of sequence numbers in a GBN protocol. If we define base to be the sequence number of the oldest unacknowledged packet and nextseqnum to be the smallest unused sequence number (that is, the sequence number of the next packet to be sent), then four intervals in the range of sequence numbers can be identified. Sequence numbers in the interval [0,base-1] correspond to packets that have already been transmitted and acknowledged. The interval [base,nextseqnum-1] corresponds to packets that have been sent but not yet acknowledged. Sequence numbers in the interval [nextseqnum,base+n-1] can be used for packets that can be sent immediately, should data arrive from the upper layer. Finally, sequence numbers greater than or equal to base+n cannot be used until an unacknowledged packet currently in the pipeline has been acknowledged. The range of permissible sequence numbers for transmitted but not-yetacknowledged packets can be viewed as a "window" of size N. N is often referred to as the window size and the GBN protocol itself as a sliding-window protocol. In practice, a packet's sequence number is carried in a fixed-length field in the packet header. If k is the number of bits in the packet sequence number field, the range of sequence numbers is thus [0,2 k - 1]. With a finite range of sequence numbers, all arithmetic involving sequence numbers must then be done using modulo 2 k arithmetic. In the GBN protocol, an acknowledgment for packet with sequence number n will be taken to be a cumulative acknowledgment, indicating that all packets with a sequence number up to and including n have been correctly received at the receiver. The protocol's name, "Go -Back-N," is derived from the sender's behavior in the presence of lost or overly delayed packets. If a timeout occurs, the sender resends all packets (at most N) that have been previously sent but that have not yet been acknowledged. 25

GBN: sender The GBN sender must respond to three types of events: packet to be sent. if the window is not full, send packet and variables are appropriately updated. otherwise upper layer waits. Cumulative ACK. Ack for packet n (sequence number) = all packets up to and including n have been correctly received. A timeout. If a timeout occurs, resends all packets yet-to-beacknowledged. If ACK, packets timer is restarted for yet-to-be-acknowledged 3: Transport Layer 3-26 The GBN sender must respond to three types of events: packet to be sent. The sender first checks to see if the window is full, that is, whether there are N outstanding, unacknowledged packets. If the window is not full, a packet is created and sent, and variables are appropriately updated. If the window is full, the sender simply returns the data back to the upper layer, an implicit indication that the window is full. The upper layer would presumably then have to try again later. In a real implementation, the sender would more likely have either buffered (but not immediately sent) this data, or would have a synchronization mechanism (for example, a semaphore or a flag) that would allow the upper layer to send packets only when the window is not full. Cumulative ACK. An acknowledgment for packet with sequence number n indicates that all packets with a sequence number up to and including n have been correctly received at the receiver. A timeout event. If a timeout occurs, the sender resends all packets that have been previously sent but that have not yet been acknowledged. If an ACK is received but there are still additional transmitted-but-yet-to-be-acknowledged packets, the timer is restarted. If there are no outstanding unacknowledged packets, the timer is stopped. 26

GBN: receiver The receiver is simple: ACK-only: always send ACK for correctly-received pkt with highest in-order seq # need only remember the expected seq # cumulative ack out-of-order pkt: discard (don t buffer) -> no receiver buffering! and no reordering ACK pkt with highest in-order seq # 3: Transport Layer 3-27 The receiver's actions in GBN are also simple. If a packet with sequence number n is received correctly and is in order (that is, the data last delivered to the upper layer came from a packet with sequence number n - 1), the receiver sends an ACK for packet n and delivers the data portion of the packet to the upper layer. In all other cases, the receiver discards the packet and resends an ACK for the most recently received in-order packet. Note that since packets are delivered one-at-a-time to the upper layer, if packet k has been received and delivered, then all packets with a sequence number lower than k have also been delivered. Thus, the use of cumulative acknowledgments is a natural choice for GBN. The receiver discards out-of-order packets, for the simplicity of receiver buffering (not as TCP). Thus, while the sender must maintain the upper and lower bounds of its window and the position of nextseqnum within this window, the only piece of information the receiver need maintain is the sequence number of the next in-order packet. 27

GBN in action 3: Transport Layer 3-28 The figure shows the operation of the GBN protocol for the case of a window size of four packets. Because of this window size limitation, the sender sends packets 0 through 3 but then must wait for one or more of these packets to be acknowledged before proceeding. As each successive ACK (for example, ACK0 and ACK1) is received, the window slides forward and the sender can transmit one new packet (pkt4 and pkt5, respectively). On the receiver side, packet 2 is lost and thus packets 3, 4, and 5 are found to be out-of-order and are discarded. 28

GBN problems large window size and bandwidth-delay product = many packets can be waiting for ACK a single packet error -> retransmit a large number of packets unnecessary As the probability of channel errors increases, the pipeline can become filled with these unnecessary retransmissions. 3: Transport Layer 3-29 With GBN, when the window size and bandwidth-delay product are both large, many packets can be in the pipeline. A single packet error can thus cause GBN to retransmit a large number of packets, many of which may be unnecessary. As the probability of channel errors increases, the pipeline can become filled with these unnecessary retransmissions. 29

Selective Repeat receiver individually acknowledges all correctly received pkts buffers pkts, as needed, for eventual in-order delivery to upper layer sender only resends pkts for which ACK not received sender timer for each unacked pkt sender window N consecutive seq # s again limits seq #s of sent, unacked pkts 3: Transport Layer 3-30 As the name suggests, Selective-Repeat protocols (SRP) avoid unnecessary retransmissions by having the sender retransmit only those packets that it suspects were received in error (that is, were lost or corrupted) at the receiver. This individual, as-needed, retransmission will require that the receiver individually acknowledge correctly received packets. A window size of N will again be used to limit the number of outstanding, unacknowledged packets in the pipeline. However, unlike GBN, the sender will have already received ACKs for some of the packets in the window. The SRP receiver will acknowledge a correctly received packet whether or not it is in-order. Out-oforder packets are buffered until any missing packets (that is, packets with lower sequence numbers) are received, at which point a batch of packets can be delivered in-order to the upper layer. 30

Selective repeat: sender, receiver windows 3: Transport Layer 3-31 31

Selective repeat: sender data from above : if next available seq # in window, send pkt timeout(n): resend pkt n, restart timer ACK(n) mark pkt n as received if n smallest unacked pkt, advance window base to next unacked seq # 3: Transport Layer 3-32 1. Data received from above. When data is received from above, the SRP sender checks the next available sequence number for the packet. If the sequence number is within the sender's window, the data is packetized and sent; otherwise it is either buffered or returned to the upper layer for later transmission, as in GBN. 2. Timeout. Timers are again used to protect against lost packets. However, each packet must now have its own logical timer, since only a single packet will be transmitted on timeout. A single hardware timer can be used to mimic the operation of multiple logical timers. 3. ACK received. If an ACK is received, the SRP sender marks that packet as having been received, provided it is in the window. If the packet's sequence number is equal to send-base, the window base is moved forward to the unacknowledged packet with the smallest sequence number. If the window moves and there are untransmitted packets with sequence numbers that now fall within the window, these packets are transmitted. 32