Transport Protocols Reading: Sections 2.5, 5.1, and 5.2

Similar documents
Transport Protocols Reading: Sections 2.5, 5.1, and 5.2. Goals for Todayʼs Lecture. Role of Transport Layer

CS457 Transport Protocols. CS 457 Fall 2014

Transport Protocols Reading: Sections 2.5, 5.1, and 5.2

Flow and Congestion Control

Multiple unconnected networks

Goals for Today s Lecture

TCP Service Model. Today s Lecture. TCP Support for Reliable Delivery. EE 122:TCP, Connection Setup, Reliability

Announcements. IP Forwarding & Transport Protocols. Goals of Today s Lecture. Are 32-bit Addresses Enough? Summary of IP Addressing.

TCP Service Model. Announcements. TCP: Reliable, In-Order Delivery. Today s Lecture. TCP Support for Reliable Delivery. TCP Header

EE 122: IP Forwarding and Transport Protocols

Communication Networks

CS4700/CS5700 Fundamentals of Computer Networks

User Datagram Protocol

Communication Networks

Department of Computer and IT Engineering University of Kurdistan. Transport Layer. By: Dr. Alireza Abdollahpouri

Islamic University of Gaza Faculty of Engineering Department of Computer Engineering ECOM 4021: Networks Discussion. Chapter 5 - Part 2

User Datagram Protocol (UDP):

CSCD 330 Network Programming

Transport Layer. Application / Transport Interface. Transport Layer Services. Transport Layer Connections

Lecture 5. Transport Layer. Transport Layer 1-1

UNIT IV -- TRANSPORT LAYER

EE 122: Transport Protocols. Kevin Lai October 16, 2002

TCP : Fundamentals of Computer Networks Bill Nace

Announcements Computer Networking. Outline. Transport Protocols. Transport introduction. Error recovery & flow control. Mid-semester grades

Transmission Control Protocol. ITS 413 Internet Technologies and Applications

The Transmission Control Protocol (TCP)

TCP. CSU CS557, Spring 2018 Instructor: Lorenzo De Carli (Slides by Christos Papadopoulos, remixed by Lorenzo De Carli)

CCNA 1 Chapter 7 v5.0 Exam Answers 2013

TCP Performance. EE 122: Intro to Communication Networks. Fall 2006 (MW 4-5:30 in Donner 155) Vern Paxson TAs: Dilip Antony Joseph and Sukun Kim

ITS323: Introduction to Data Communications

COMPUTER NETWORKS CS CS 55201

COMPUTER NETWORKS CS CS 55201

CSC 401 Data and Computer Communications Networks

ECE 650 Systems Programming & Engineering. Spring 2018

Computer Communication Networks Midterm Review

CCNA R&S: Introduction to Networks. Chapter 7: The Transport Layer

UDP and TCP. Introduction. So far we have studied some data link layer protocols such as PPP which are responsible for getting data

EE 122: Transport Protocols: UDP and TCP

Introduction to TCP/IP networking

CSCI-GA Operating Systems. Networking. Hubertus Franke

TSIN02 - Internetworking

Announcements Computer Networking. What was hard. Midterm. Lecture 16 Transport Protocols. Avg: 62 Med: 67 STD: 13.

Transport Layer. Gursharan Singh Tatla. Upendra Sharma. 1

Guide To TCP/IP, Second Edition UDP Header Source Port Number (16 bits) IP HEADER Protocol Field = 17 Destination Port Number (16 bit) 15 16

Networking Technologies and Applications

Lecture 5: Flow Control. CSE 123: Computer Networks Alex C. Snoeren

Lecture 3: The Transport Layer: UDP and TCP

Fundamentals of Computer Networks ECE 478/578. Transport Layer. End- to- End Protocols 4/16/13. Spring Application. Application.

Transmission Control Protocol (TCP)

Suprakash Datta. Office: CSEB 3043 Phone: ext Course page:

TSIN02 - Internetworking

The Transport Layer: TCP & Reliable Data Transfer

CMPE150 Midterm Solutions

OSI Transport Layer. objectives

Transport layer. UDP: User Datagram Protocol [RFC 768] Review principles: Instantiation in the Internet UDP TCP

ECE697AA Lecture 3. Today s lecture

Transport layer. Review principles: Instantiation in the Internet UDP TCP. Reliable data transfer Flow control Congestion control

Announcements. No book chapter for this topic! Slides are posted online as usual Homework: Will be posted online Due 12/6

6.1 Internet Transport Layer Architecture 6.2 UDP (User Datagram Protocol) 6.3 TCP (Transmission Control Protocol) 6. Transport Layer 6-1

TCP. 1 Administrivia. Tom Kelliher, CS 325. Apr. 2, Announcements. Assignment. Read From Last Time

Computer Networking Introduction

Lecture 20 Overview. Last Lecture. This Lecture. Next Lecture. Transport Control Protocol (1) Transport Control Protocol (2) Source: chapters 23, 24

IS370 Data Communications and Computer Networks. Chapter 5 : Transport Layer

Fall 2012: FCM 708 Bridge Foundation I

CMPE 150/L : Introduction to Computer Networks. Chen Qian Computer Engineering UCSC Baskin Engineering Lecture 9

Introduction to Networks and the Internet

Reliable Transport I: Concepts and TCP Protocol

TSIN02 - Internetworking

TCP and Congestion Control (Day 1) Yoshifumi Nishida Sony Computer Science Labs, Inc. Today's Lecture

TSIN02 - Internetworking

Page 1. Goals for Today" Discussion" Example: Reliable File Transfer" CS162 Operating Systems and Systems Programming Lecture 11

Lecture 08: The Transport Layer (Part 2) The Transport Layer Protocol (TCP) Dr. Anis Koubaa

Outline Computer Networking. Functionality Split. Transport Protocols

Reliable Byte-Stream (TCP)

No book chapter for this topic! Slides are posted online as usual Homework: Will be posted online Due 12/6

EEC-682/782 Computer Networks I

Chapter 3 Transport Layer

Correcting mistakes. TCP: Overview RFCs: 793, 1122, 1323, 2018, TCP seq. # s and ACKs. GBN in action. TCP segment structure

Transport Layer: outline

Problem. Chapter Outline. Chapter Goal. End-to-end Protocols. End-to-end Protocols. Chapter 5. End-to-End Protocols

Application. Transport. Network. Link. Physical

Chapter 3 outline. 3.5 connection-oriented transport: TCP segment structure reliable data transfer flow control connection management

Transport Layer. -UDP (User Datagram Protocol) -TCP (Transport Control Protocol)

Transport Layer: Outline

ICS 451: Today's plan. Sliding Window Reliable Transmission Acknowledgements Windows and Bandwidth-Delay Product Retransmission Timers Connections

32 bits. source port # dest port # sequence number acknowledgement number not used. checksum. Options (variable length)

CSE 4213: Computer Networks II

Reliable Transport I: Concepts and TCP Protocol

Chapter 5 End-to-End Protocols

Chapter 3 outline. 3.5 Connection-oriented transport: TCP. 3.6 Principles of congestion control 3.7 TCP congestion control

TCP Basics : Computer Networking. Overview. What s Different From Link Layers? Introduction to TCP. TCP reliability Assigned reading

CS 43: Computer Networks. 18: Transmission Control Protocol October 12-29, 2018

Transport Protocols. ISO Defined Types of Network Service: rate and acceptable rate of signaled failures.

CS 5520/ECE 5590NA: Network Architecture I Spring Lecture 13: UDP and TCP

TCP/IP Networking. Part 4: Network and Transport Layer Protocols

Outline. TCP: Overview RFCs: 793, 1122, 1323, 2018, steam: r Development of reliable protocol r Sliding window protocols

10 minutes survey (anonymous)

Page 1. Goals for Today" Placing Network Functionality" Basic Observation" CS162 Operating Systems and Systems Programming Lecture 15

Functionality Split Computer Networking. Transport Protocols. Overview. Multiplexing & Demultiplexing

Lecture 8. TCP/IP Transport Layer (2)

Transcription:

Transport Protocols Reading: Sections 2.5, 5.1, and 5.2 CE443 - Fall 1390 Acknowledgments: Lecture slides are from Computer networks course thought by Jennifer Rexford at Princeton University. When slides are obtained from other sources, a a reference will be noted on the bottom of that slide. A full list of references is provided on the last slide. 1

Goals for Todayʼs Lecture Principles underlying transport-layer services (De)multiplexing Detecting corruption Reliable delivery Flow control Transport-layer protocols in the Internet User Datagram Protocol (UDP) Simple (unreliable) message delivery Realized by a SOCK_DGRAM socket Transmission Control Protocol (TCP) Reliable bidirectional stream of bytes Realized by a SOCK_STREAM socket 2

Role of Transport Layer Application layer Between applications (e.g., browsers and servers) E.g., HyperText Transfer Protocol (HTTP), File Transfer Protocol (FTP), Network News Transfer Protocol (NNTP) Transport layer Between processes (e.g., sockets) Relies on network layer and serves the application layer E.g., TCP and UDP Network layer Between nodes (e.g., routers and hosts) Hides details of the link technology E.g., IP 3

Transport Protocols Provide logical communication between application processes running on different hosts Run on end hosts Sender: breaks application messages into segments, and passes to network layer Receiver: reassembles segments into messages, passes to application layer Multiple transport protocols available to applications Internet: TCP and UDP applicatio n 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 applicatio n transport network data link physical 4

Two Basic Transport Features Demultiplexing: port numbers Client host Client Service request for 128.2.194.242:80 (i.e., the Web server) Server host 128.2.194.242 OS Web server (port 80) Echo server (port 7) Error detection: checksums IP payload detect corruption 5

User Datagram Protocol (UDP) Datagram messaging service Demultiplexing of messages: port numbers Detecting corrupted messages: checksum Lightweight communication between processes Send messages to and receive them from a socket Avoid overhead and delays of ordered, reliable delivery SRC port DST port checksum length DATA 6

Why Would Anyone Use UDP? Fine control over what data is sent and when As soon as an application process writes into the socket UDP will package the data and send the packet No delay for connection establishment UDP just blasts away without any formal preliminaries which avoids introducing any unnecessary delays No connection state No allocation of buffers, parameters, sequence #s, etc. making it easier to handle many active clients at once Small packet header overhead UDP header is only eight-bytes long 7

Popular Applications That Use UDP Multimedia streaming Retransmitting lost/corrupted packets is not worthwhile By the time the packet is retransmitted, it s too late E.g., telephone calls, video conferencing, gaming Simple query protocols like Domain Name System Overhead of connection establishment is overkill Easier to have the application retransmit if needed Address for www.cnn.com? 12.3.4.15 8

Transmission Control Protocol (TCP) Stream-of-bytes service Sends and receives a stream of bytes, not messages Reliable, in-order delivery Checksums to detect corrupted data Sequence numbers to detect losses and reorder data Acknowledgments & retransmissions for reliable delivery Connection oriented Explicit set-up and tear-down of TCP session Flow control Prevent overflow of the receiver s buffer space Congestion control (next class!) Adapt to network congestion for the greater good 9

Breaking a Stream of Bytes into TCP Segments 10

TCP Stream of Bytes Service Host A Byte 80 Byte 3 Byte 2 Byte 1 Byte 0 Host B Byte 80 Byte 3 Byte 2 Byte 1 Byte 0 11

Emulated Using TCP Segments Host A Byte 80 Byte 3 Byte 2 Byte 1 Byte 0 TCP Data Segment sent when: 1. Segment full (Max Segment Size), 2. Not full, but times out, or 3. Pushed by application. Host B TCP Data Byte 80 Byte 3 Byte 2 Byte 1 Byte 0 12

TCP Segment IP Data TCP Data (segment) TCP Hdr IP Hdr IP packet No bigger than Maximum Transmission Unit (MTU) E.g., up to 1500 bytes on an Ethernet TCP packet IP packet with a TCP header and data inside TCP header is typically 20 bytes long TCP segment No more than Maximum Segment Size (MSS) bytes E.g., up to 1460 consecutive bytes from the stream 13

Sequence Number Host A ISN (initial sequence number) Byte 81 Sequence number = 1 st byte TCP Data Host B TCP Data 14

Initial Sequence Number (ISN) Sequence number for the very first byte E.g., Why not a de facto ISN of 0? Practical issue IP addresses and port #s uniquely identify a connection Eventually, though, these port #s do get used again and there is a chance an old packet is still in flight and might be associated with the new connection So, TCP requires changing the ISN over time Set from a 32-bit clock that ticks every 4 microseconds which only wraps around once every 4.55 hours! But, this means the hosts need to exchange ISNs 15

Reliable Delivery on a Lossy Channel With Bit Errors 16

An Analogy: Talking on a Cell Phone Alice and Bob on their cell phones Both Alice and Bob are talking What if Alice couldn t understand Bob? Bob asks Alice to repeat what she said What if Bob hasn t heard Alice for a while? Is Alice just being quiet? Or, have Bob and Alice lost reception? How long should Bob just keep on talking? Maybe Alice should periodically say uh huh or Bob should ask Can you hear me now? 17

Some Take-Aways from the Example Acknowledgments from receiver Positive: okay or uh huh or ACK Negative: please repeat that or NACK Timeout by the sender ( stop and wait ) Don t wait indefinitely without receiving some response whether a positive or a negative acknowledgment Retransmission by the sender After receiving a NACK from the receiver After receiving no feedback from the receiver 18

Challenges of Reliable Data Transfer Over a perfectly reliable channel All of the data arrives in order, just as it was sent Simple: sender sends data, and receiver receives data Over a channel with bit errors All of the data arrives in order, but some bits corrupted Receiver detects errors and says please repeat that Sender retransmits the data that were corrupted Over a lossy channel with bit errors Some data are missing, and some bits are corrupted Receiver detects errors but cannot always detect loss Sender must wait for acknowledgment ( ACK or OK ) and retransmit data after some time if no ACK arrives 19

TCP Support for Reliable Delivery Detect bit errors: checksum Used to detect corrupted data at the receiver leading the receiver to drop the packet Detect missing data: sequence number Used to detect a gap in the stream of bytes... and for putting the data back in order Recover from lost data: retransmission Sender retransmits lost or corrupted data Two main ways to detect lost packets 20

TCP Acknowledgments Host A ISN (initial sequence number) Sequence number = 1 st byte TCP Data TCP HDR ACK sequence number = next expected byte Host B TCP Data TCP HDR 21

Automatic Repeat request (ARQ) Automatic Repeat request Receiver sends acknowledgment (ACK) when it receives packet Sender waits for ACK and timeouts if it does not arrive within some time period Simplest ARQ protocol Stop and wait Send a packet, stop and wait until ACK arrives Time Sender Receiver Timeout Packet ACK 22

Reasons for Retransmission Packet Packet Packet Timeout ACK Packet Timeout Timeout Packet Timeout Timeout ACK Packet ACK Timeout ACK ACK Packet lost ACK lost DUPLICATE PACKET Early timeout DUPLICATE PACKETS 23

How Long Should Sender Wait? Sender sets a timeout to wait for an ACK Too short: wasted retransmissions Too long: excessive delays when packet lost TCP sets timeout as a function of the RTT Expect ACK to arrive after a round-trip time plus a fudge factor to account for queuing But, how does the sender know the RTT? Can estimate the RTT by watching the ACKs Smooth estimate: keep a running average of the RTT EstimatedRTT = a * EstimatedRTT + (1 a ) * SampleRTT Compute timeout: TimeOut = 2 * EstimatedRTT 24

Example RTT Estimation 25

A Flaw in This Approach An ACK doesn t really acknowledge a transmission Rather, it acknowledges receipt of the data Consider a retransmission of a lost packet If you assume the ACK goes with the 1st transmission the SampleRTT comes out way too large Consider a duplicate packet If you assume the ACK goes with the 2nd transmission the Sample RTT comes out way too small Simple solution in the Karn/Partridge algorithm Only collect samples for segments sent one single time 26

Flow Control: TCP Sliding Window 27

Motivation for Sliding Window Stop-and-wait is inefficient Only one TCP segment is in flight at a time Especially bad when delay-bandwidth product is high Numerical example 1.5 Mbps link with a 45 msec round-trip time (RTT) Delay-bandwidth product is 67.5 Kbits (or 8 KBytes) But, sender can send at most one packet per RTT Assuming a segment size of 1 KB (8 Kbits) leads to 8 Kbits/segment / 45 msec/segment 182 Kbps That s just one-eighth of the 1.5 Mbps link capacity 28

Sliding Window Allow a larger amount of data in flight Allow sender to get ahead of the receiver though not too far ahead Sending process Receiving process TCP Last byte written TCP Last byte read Last byte ACKed Last byte sent Next byte expected Last byte received 29

Receiver Buffering Window size Amount that can be sent without acknowledgment Receiver needs to be able to store this amount of data Receiver advertises the window to the sender Tells the receiver the amount of free space left and the sender agrees not to exceed this amount Window Size Data ACK d Outstanding Un-ack d data Data OK to send Data not OK to send yet 30

Back to Timeouts 31

Still, Timeouts are Inefficient Timeout-based retransmission Sender transmits a packet and waits until timer expires and then retransmits from the lost packet onward 32

Fast Retransmission Better solution possible under sliding window Although packet n might have been lost packets n+1, n+2, and so on might get through Idea: have the receiver send ACK packets ACK says that receiver is still awaiting n th packet And repeated ACKs suggest later packets have arrived Sender can view the duplicate ACKs as an early hint that the n th packet must have been lost and perform the retransmission early Fast retransmission Sender retransmits data after the triple duplicate ACK 33

Effectiveness of Fast Retransmit When does Fast Retransmit work best? Long data transfers High likelihood of many packets in flight High window size High likelihood of many packets in flight Low burstiness in packet losses Higher likelihood that later packets arrive successfully Implications for Web traffic Most Web transfers are short (e.g., 10 packets) Short HTML files or small images So, often there aren t many packets in flight making fast retransmit less likely to kick in Forcing users to click reload more often 34

Starting and Ending a Connection: TCP Handshakes 35

Establishing a TCP Connection A SYN B SYN ACK ACK Each host tells its ISN to the other host. Data Data Three-way handshake to establish connection Host A sends a SYN (open) to the host B Host B returns a SYN acknowledgment (SYN ACK) Host A sends an ACK to acknowledge the SYN ACK 36

TCP Header Source port Destination port Flags: SYN FIN RST PSH URG ACK Sequence number Acknowledgment HdrLen 0 Flags Advertised window Checksum Urgent pointer Options (variable) Data 37

Step 1: Aʼs Initial SYN Packet A s port B s port Flags: SYN FIN RST PSH URG ACK A s Initial Sequence Number 20 Flags 0 Checksum Acknowledgment Options (variable) Advertised window Urgent pointer A tells B it wants to open a connection 38

Step 2: Bʼs SYN-ACK Packet B s port A s port Flags: SYN FIN RST PSH URG ACK B s Initial Sequence Number A s ISN plus 1 20 Flags 0 Checksum Options (variable) Advertised window Urgent pointer B tells A it accepts, and is ready to hear the next byte upon receiving this packet, A can start sending data 39

Step 3: Aʼs ACK of the SYN-ACK A s port B s port Flags: SYN FIN RST PSH URG ACK 20 Flags 0 Checksum Sequence number B s ISN plus 1 Options (variable) Advertised window Urgent pointer A tells B it is okay to start sending upon receiving this packet, B can start sending data 40

What if the SYN Packet Gets Lost? Suppose the SYN packet gets lost Packet is lost inside the network, or Server rejects the packet (e.g., listen queue is full) Eventually, no SYN-ACK arrives Sender sets a timer and wait for the SYN-ACK and retransmits the SYN if needed How should the TCP sender set the timer? Sender has no idea how far away the receiver is Hard to guess a reasonable length of time to wait Some TCPs use a default of 3 or 6 seconds 41

SYN Loss and Web Downloads User clicks on a hypertext link Browser creates a socket and does a connect The connect triggers the OS to transmit a SYN If the SYN is lost The 3-6 seconds of delay may be very long The user may get impatient and click the hyperlink again, or click reload User triggers an abort of the connect Browser creates a new socket and does a connect Essentially, forces a faster send of a new SYN packet! Sometimes very effective, and the page comes fast 42

Tearing Down the Connection B SYN SYN ACK ACK Data ACK FIN ACK FIN ACK A time Closing (each end of) the connection Finish (FIN) to close and receive remaining bytes And other host sends a FIN ACK to acknowledge Reset (RST) to close and not receive remaining bytes 43

Sending/Receiving the FIN Packet Sending a FIN: close() Process is done sending data via the socket Process invokes close() to close the socket Once TCP has sent all of the outstanding bytes then TCP sends a FIN Receiving a FIN: EOF Process is reading data from the socket Eventually, the attempt to read returns an EOF 44

Conclusions Transport protocols Multiplexing and demultiplexing Checksum-based error detection Sequence numbers Retransmission Window-based flow control Reading for this week Sections 2.5, 5.1-5.2, and 6.1-6.4 Next lecture Congestion control 45