COMP/ELEC 429/556 Introduction to Computer Networks

Similar documents
CS4700/CS5700 Fundamentals of Computer Networks

CS3600 SYSTEMS AND NETWORKS

CS4700/CS5700 Fundamentals of Computer Networks

Transmission Control Protocol. ITS 413 Internet Technologies and Applications

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

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

TCP Congestion Control

TCP Congestion Control

Chapter 24. Transport-Layer Protocols

Transport Layer Marcos Vieira

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

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

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

CS 356: Introduction to Computer Networks. Lecture 16: Transmission Control Protocol (TCP) Chap. 5.2, 6.3. Xiaowei Yang

CS 43: Computer Networks. 19: TCP Flow and Congestion Control October 31, Nov 2, 2018

TCP Review. Carey Williamson Department of Computer Science University of Calgary Winter 2018

Outline Computer Networking. Functionality Split. Transport Protocols

CMSC 417. Computer Networks Prof. Ashok K Agrawala Ashok Agrawala. October 25, 2018

Congestion / Flow Control in TCP

Computer Networking Introduction

Outline Computer Networking. TCP slow start. TCP modeling. TCP details AIMD. Congestion Avoidance. Lecture 18 TCP Performance Peter Steenkiste

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

Networked Systems and Services, Fall 2018 Chapter 3

Flow and Congestion Control (Hosts)

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

Lecture 4: Congestion Control

COMP/ELEC 429/556 Introduction to Computer Networks

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

Chapter III: Transport Layer

Networked Systems and Services, Fall 2017 Reliability with TCP

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

Chapter 3- parte B outline

User Datagram Protocol (UDP):

Transport Protocols and TCP

CE693 Advanced Computer Networks

Outline. Internet. Router. Network Model. Internet Protocol (IP) Design Principles

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

Network Protocols. Transmission Control Protocol (TCP) TDC375 Autumn 2009/10 John Kristoff DePaul University 1

User Datagram Protocol

CMSC 417. Computer Networks Prof. Ashok K Agrawala Ashok Agrawala. October 30, 2018

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

Fall 2012: FCM 708 Bridge Foundation I

Page 1. Review: Internet Protocol Stack. Transport Layer Services. Design Issue EEC173B/ECS152C. Review: TCP

Communication Networks

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

CS457 Transport Protocols. CS 457 Fall 2014

TCP congestion control:

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

TCP reliable data transfer. Chapter 3 outline. TCP sender events: TCP sender (simplified) TCP: retransmission scenarios. TCP: retransmission scenarios

Chapter 3 Transport Layer

CS321: Computer Networks Congestion Control in TCP

Page 1. Review: Internet Protocol Stack. Transport Layer Services EEC173B/ECS152C. Review: TCP. Transport Layer: Connectionless Service

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

Bandwidth Allocation & TCP

Internet Transport Protocols UDP and TCP

ECE 333: Introduction to Communication Networks Fall 2001

CSC 4900 Computer Networks: TCP

Outline. CS5984 Mobile Computing

Fast Retransmit. Problem: coarsegrain. timeouts lead to idle periods Fast retransmit: use duplicate ACKs to trigger retransmission

Mid Term Exam Results

Transport Protocols & TCP TCP

UNIT IV -- TRANSPORT LAYER

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

Computer Networks and Data Systems

Transport Layer: outline

Computer Networks. Wenzhong Li. Nanjing University

End-to-End Protocols. Transport Protocols. User Datagram Protocol (UDP) Application Layer Expectations

Introduction to Networking. Operating Systems In Depth XXVII 1 Copyright 2017 Thomas W. Doeppner. All rights reserved.

9th Slide Set Computer Networks

Transport Over IP. CSCI 690 Michael Hutt New York Institute of Technology

COMP/ELEC 429/556 Introduction to Computer Networks

Transport Layer PREPARED BY AHMED ABDEL-RAOUF

Chapter 7. The Transport Layer

CSC 8560 Computer Networks: TCP

Transport Protocols and TCP: Review

Congestion Control End Hosts. CSE 561 Lecture 7, Spring David Wetherall. How fast should the sender transmit data?

Internet Networking recitation #10 TCP New Reno Vs. Reno

Overview. TCP congestion control Computer Networking. TCP modern loss recovery. TCP modeling. TCP Congestion Control AIMD

Flow and Congestion Control Marcos Vieira

Recap. TCP connection setup/teardown Sliding window, flow control Retransmission timeouts Fairness, max-min fairness AIMD achieves max-min fairness

Multiple unconnected networks

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

Advanced Network Design

Transport Layer: Outline

Chapter 23 Process-to-Process Delivery: UDP, TCP, and SCTP 23.1

Transport Protocols. Raj Jain. Washington University in St. Louis

Transport Layer Protocols TCP

CSCD 330 Network Programming Winter 2015

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

The Transmission Control Protocol (TCP)

CNT 6885 Network Review on Transport Layer

8. TCP Congestion Control

Chapter 3 Transport Layer

TCP so far Computer Networking Outline. How Was TCP Able to Evolve

ECE 435 Network Engineering Lecture 10

Lecture 3: The Transport Layer: UDP and TCP

Answers to Sample Questions on Transport Layer

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

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

TSIN02 - Internetworking

Transcription:

COMP/ELEC 429/556 Introduction to Computer Networks The TCP Protocol Some slides used with permissions from Edward W. Knightly, T. S. Eugene Ng, Ion Stoica, Hui Zhang T. S. Eugene Ng eugeneng at cs.rice.edu Rice University 1

Transport Layer Purpose 1: Demultiplexing of data streams to different application processes Purpose 2: Provide value-added services that many applications want Recall network layer in Internet provides a Best-effort service only, transport layer can add value to that Application may want reliability, etc No need to reinvent the wheel each time you write a new application Application Layer Transport Layer Network Layer Data Link Layer web, voip, email,... TCP, UDP,... IP Ethernet, Wi-Fi,... T. S. Eugene Ng eugeneng at cs.rice.edu Rice University 2

A very simple transport protocol: User Datagram Protocol (UDP) Connectionless datagram Socket: SOCK_DGRAM Port number used for demultiplexing port numbers = connection/application endpoint Adds end-to-end error checking through optional checksum some protection against data corruption errors between source and destination (links, switches/routers, bus) does not protect against packet loss, duplication or reordering 0 16 32 Source Port Length Dest. Port Checksum T. S. Eugene Ng eugeneng at cs.rice.edu Rice University 3

Using Transport Layer Port Number to Demultiplex traffic Host 1 Host 2 Host 3 Application Transport IP app1 app2 app2 app1 app3 app3 app2 p1 p2 p1 p2 p3 p1 p2 Demux on port # Demux on protocol # T. S. Eugene Ng eugeneng at cs.rice.edu Rice University 4

Usages of UDP Custom protocols/applications can be implemented on top of UDP use the port addressing provided by UDP implement specialized reliability, flow control, ordering, congestion control as the app sees fit Examples: remote procedure call multimedia streaming (real time protocol) cluster computing communication libraries T. S. Eugene Ng eugeneng at cs.rice.edu Rice University 5

Transmission Control Protocol (TCP) Reliable bidirectional in-order byte stream Socket: SOCK_STREAM Connections established & torn down Multiplexing/ demultiplexing Ports at both ends Error control Users see correct, ordered byte sequences End-to-end flow control Avoid overwhelming receiver at each end Congestion control Avoid creating traffic jams within network 0 16 32 Source Port Dest. Port Sequence Number Acknowledgment Number HL/Flags Advertised Win. Checksum Urgent Pointer Options.. T. S. Eugene Ng eugeneng at cs.rice.edu Rice University 6

Connection Setup Why need connection setup? Mainly to agree on starting sequence numbers Starting sequence number is randomly chosen Reason: to reduce the chance that sequence numbers of old and new connections from overlapping T. S. Eugene Ng eugeneng at cs.rice.edu Rice University 7

SYN: Synchronize Important TCP Flags Used when setting up connection FIN: Finish Used when tearing down connection ACK Acknowledging received data T. S. Eugene Ng eugeneng at cs.rice.edu Rice University 8

Establishing Connection SYN: SeqC! Client! Server! ACK: SeqC+1! SYN: SeqS! ACK: SeqS+1! Three-Way Handshake Each side notifies other of starting sequence number it will use for sending Each side acknowledges other s sequence number SYN-ACK: Acknowledge sequence number + 1 Can combine second SYN with first ACK T. S. Eugene Ng eugeneng at cs.rice.edu Rice University 9

Tearing Down Connection Either Side Can Initiate Tear Down Send FIN signal I m not going to send any more data Other Side Can Continue Sending Data Half open connection Must continue to acknowledge Acknowledging FIN Acknowledge last sequence number + 1 A! B! FIN, SeqA! ACK, SeqA+1! Data! ACK! FIN, SeqB! ACK, SeqB+1! T. S. Eugene Ng eugeneng at cs.rice.edu Rice University 10

Sequence Number Space Each byte in byte stream is numbered 32 bit value Wraps around Initial values selected at start up time TCP breaks up the byte stream into segments Each segment transmitted by a packet Limited by the Maximum Segment Size Set to prevent packet fragmentation Each segment has a sequence number Indicates where it fits in the byte stream 13450! 14950! 16050! 17550! segment! segment! segment! T. S. Eugene Ng eugeneng at cs.rice.edu Rice University 11

Bidirectional Communication Send seq 2000! Ack seq 2001! Send seq 42000! Ack seq 42001! Each Side of Connection can Send and Receive What this Means Maintain different sequence numbers for each direction A single packet can contain new data for one direction, plus acknowledgement for other, may also contain only data or only acknowledgement When there is a loss, e.g. seq # 2000, 2002, 2003, 2004 are received, TCP receiver acks 2001, 2001, 2001, 2001 Called duplicate ACKs There are TCP variants that don t do this beyond our scope T. S. Eugene Ng eugeneng at cs.rice.edu Rice University 12

Sequence Numbers 32 Bits, Unsigned Why So Big? For sliding window, must have Sequence Space > 2* Sending Window Sending window size of basic TCP is at most 2^16 bytes 2^32 > 2 * 2^16; no problem Also, want to guard against stray packets With IP, assume packets have maximum segment lifetime (MSL) of 120s i.e. can linger in network for upto 120s Sequence number would wrap around in this time at 286Mbps T. S. Eugene Ng eugeneng at cs.rice.edu Rice University 13

Error Control Checksum provides some end-to-end error protection Sequence numbers detect packet sequencing problems: Duplicate: ignore Reordered: reorder or drop Lost: retransmit Lost segments retransmitted by sender Use time out to detect lack of acknowledgment Need estimate of the roundtrip time to set timeout Retransmission requires that sender keep copy of the data Copy is discarded when ack is received T. S. Eugene Ng eugeneng at cs.rice.edu Rice University 14

TCP Must Operate Over Any Internet Path Retransmission time-out should be set based on round-trip delay But round-trip delay different for each path! Must estimate RTT dynamically T. S. Eugene Ng eugeneng at cs.rice.edu Rice University 15

Setting Retransmission Timeout (RTO) Initial Send! Initial Send! RTO! Retry! RTO! Ack! Retry! Ack! Detect dropped packet! RTO too short! Time between sending & resending segment Challenge Too long: Add latency to communication when packets dropped Too short: Send too many duplicate packets General principle: Must be > 1 Round Trip Time (RTT) T. S. Eugene Ng eugeneng at cs.rice.edu Rice University 16

Round-trip Time Estimation Every Data/Ack pair gives new RTT estimate Data! Sample! Ack! Can Get Lots of Short-Term Fluctuations How to address this problem? T. S. Eugene Ng eugeneng at cs.rice.edu Rice University 17

Exponential Smoothing Technique Round trip times estimated as a moving average: Smoothed RTT = α (Smoothed RTT) + (1 - α) (new RTT sample) Recommended value for α: 0.8-0.9 Retransmission timeout (RTO) is a function of Smoothed RTT (SRTT) RTT variation (RTTVAR) RTO = SRTT + 4 * RTTVAR Details in RFC 6298 T. S. Eugene Ng eugeneng at cs.rice.edu Rice University 18

A RTT Sample Ambiguity B A B Sample RTT Original transmission RTO X retransmission Sample RTT Original transmission RTO ACK retransmission ACK Ignore sample for segment that has been retransmitted T. S. Eugene Ng eugeneng at cs.rice.edu Rice University 19

Sliding window protocol TCP Speed Control For window size n, can send up to n bytes without receiving new acknowledgement Speed proportional to n/rtt When the data are acknowledged then the window slides forward 0 16 32 Send window size set to minimum (advertised window, congestion window) Source Port Dest. Port Sequence Number Acknowledgment Number HL/Flags Advertised Win. Checksum Urgent Pointer Options.. T. S. Eugene Ng eugeneng at cs.rice.edu Rice University 20

Window Flow Control: Send Side window Sent and acked Sent but not acked Not yet sent Next to be sent Must retain for possible retransmission! T. S. Eugene Ng eugeneng at cs.rice.edu Rice University 21

Window Flow Control: Receive Side Receive buffer Acked but not delivered to user Not yet acked window TCP receiver can delete acknowledged data only after the data has been delivered to the application So, depending on how fast the application is reading the data, the receiver s window size may change!!! T. S. Eugene Ng eugeneng at cs.rice.edu Rice University 22

Solution Receiver tells sender the current advertised window size in every packet it transmits to the sender Sender uses this current advertised window size as an upper bound send window size = minimum (advertised window, congestion window) Advertised window size is continuously changing Can go to zero! Sender not allowed to send anything! T. S. Eugene Ng eugeneng at cs.rice.edu Rice University 23

Setting Congestion Window Send window size = minimum (advertised window, congestion window) Phases of TCP congestion control 1. Slow start (getting to equilibrium) Want to find this very very fast and not waste time 2. Congestion Avoidance Additive increase - gradually probing for additional bandwidth Multiplicative decrease decreasing congestion window upon loss/timeout T. S. Eugene Ng eugeneng at cs.rice.edu Rice University 24

Variables Used in Implementation Congestion Window (cwnd) Initial value is 1 MSS (=maximum segment size) counted as bytes Actual sender window size used by TCP = minimum (advertised win, cwnd) Slow-start threshold Value (ss_thresh) Initial value is the advertised window size slow start (cwnd < ssthresh) congestion avoidance (cwnd >= ssthresh) T. S. Eugene Ng eugeneng at cs.rice.edu Rice University 25

TCP: Slow Start Goal: discover roughly the proper sending rate quickly Whenever starting traffic on a new connection, or whenever increasing traffic after congestion was experienced: Intialize cwnd = 1 MSS (max segment size) Each time a segment is acknowledged, increment cwnd by one MSS (cwnd++). Continue until Reach ss_thresh or Packet loss T. S. Eugene Ng eugeneng at cs.rice.edu Rice University 26

Slow Start Illustration The congestion window size grows very rapidly Observe: Each ACK generates two packets slow start increases rate exponentially fast (doubled every RTT)! cwnd = 1 cwnd = 2 cwnd = 4 cwnd = 8 segment 1 ACK for segment 2 segment 2 segment 3 segment 4 segment 5 segment 6 segment 7 ACKs for segments 3 + 4 ACK for segments 5+6+7+8 T. S. Eugene Ng eugeneng at cs.rice.edu Rice University 27

Congestion Avoidance Slow Start figures out roughly the rate at which the network starts getting congested Congestion Avoidance continues to react to network condition Probes for more bandwidth, increase cwnd if more bandwidth available If congestion detected, aggressive cut back cwnd T. S. Eugene Ng eugeneng at cs.rice.edu Rice University 28

Congestion Avoidance: Additive Increase Slowly increase cwnd to probe for additional available bandwidth If cwnd >= ss_thresh then each time a segment is newly acknowledged cwnd += 1/cwnd cwnd is increased by one MSS only if all segments in the window have been acknowledged Increases by 1 per RTT T. S. Eugene Ng eugeneng at cs.rice.edu Rice University 29

Example of Slow Start + Congestion Avoidance Assume that ss_thresh = 8 Cwnd (in segments) ssthresh Roundtrip times T. S. Eugene Ng eugeneng at cs.rice.edu Rice University 30

Detecting Congestion via Timeout If there is a packet loss, the ACK for that packet will not be received The packet will eventually timeout No ack is seen as a sign of congestion T. S. Eugene Ng eugeneng at cs.rice.edu Rice University 31

Congestion Avoidance: Multiplicative Decrease Each time when timeout occurs ss_thresh is set to half the current size of the congestion window: ss_thresh = cwnd / 2 cwnd is reset to one: cwnd = 1 and slow-start is entered T. S. Eugene Ng eugeneng at cs.rice.edu Rice University 32

Packet Pacing ACKs self-pace the data to avoid a burst of packets to be sent Observe: received ACK spacing bottleneck bandwidth Data T T T sender receiver T T T Tiny ACK T. S. Eugene Ng eugeneng at cs.rice.edu Rice University 33

TCP (Tahoe variant) Illustration cwnd ss_thresh Timeout Slow Start Congestion Avoidance Timeout ss_thresh Time T. S. Eugene Ng eugeneng at cs.rice.edu Rice University 34

Many Variants of TCP Common variants of TCP TCP Tahoe - the basic algorithm (discussed previously) TCP Reno - Tahoe + fast retransmit & fast recovery Many end hosts today implement TCP Reno and many more: TCP Vegas (use timing of ACKs to avoid loss) TCP SACK (selective ACK) T. S. Eugene Ng eugeneng at cs.rice.edu Rice University 35

TCP Reno Problem with Tahoe: If a segment is lost, there is a long wait until timeout Reno adds a fast retransmit and fast recovery mechanisms Upon receiving 3 duplicate ACKs, retransmit the presumed lost segment ( fast retransmit ) But do not enter slow-start. Instead enter congestion avoidance ( fast recovery ) T. S. Eugene Ng eugeneng at cs.rice.edu Rice University 36

Resend a segment after 3 duplicate ACKs remember a duplicate ACK means that an out-of sequence segment was received ACK-n means packets 1,, n-1 all received Notes: duplicate ACKs can be due to packet reordering! if window is small, may not get 3 duplicate ACKs! Fast Retransmit 3 duplicate ACKs cwnd = 1 cwnd = 2 cwnd = 4 ACK 2 ACK 3 ACK 4 ACK 4 ACK 4 ACK 4 segment 1 segment 2 segment 3 segment 4 segment 5 segment 6 segment 7 T. S. Eugene Ng eugeneng at cs.rice.edu Rice University 37

Fast Recovery After a fast-retransmit cwnd = cwnd/2 ss_thresh = cwnd i.e. starts congestion avoidance at new cwnd After a timeout Same as TCP Tahoe ss_thresh = cwnd/2 cwnd = 1 Do slow start T. S. Eugene Ng eugeneng at cs.rice.edu Rice University 38

Fast Retransmit and Fast Recovery cwnd Slow Start Congestion Avoidance Time Retransmit after 3 duplicate ACKs prevent expensive timeouts Slow start only once per session (if no timeouts) In steady state, cwnd oscillates around the ideal window size. T. S. Eugene Ng eugeneng at cs.rice.edu Rice University 39

TCP Reno Summary Slow-Start if cwnd < ss_thresh cwnd++ upon every new ACK (exponential growth) Timeout: ss_thresh = cwnd/2 and cwnd = 1 Congestion avoidance if cwnd >= ss_thresh Additive Increase Multiplicative Decrease (AIMD) ACK: cwnd = cwnd + 1/cwnd Timeout: ss_thresh = cwnd/2 and cwnd = 1 Fast Retransmit & Recovery 3 duplicate ACKs (interpret as packet loss) Retransmit lost packet cwnd=cwnd/2, ss_thresh = cwnd T. S. Eugene Ng eugeneng at cs.rice.edu Rice University 40

TCP Reno Saw Tooth Behavior Congestion Window Timeouts may still occur Initial Slow start Slow start to pace packets Fast Retransmit and Recovery Time T. S. Eugene Ng eugeneng at cs.rice.edu Rice University 41