Transmission Control Protocol

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

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

Transport Layer: outline

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

Transport Layer: Outline

Lecture 8. TCP/IP Transport Layer (2)

CC451 Computer Networks

CSE 4213: Computer Networks II

Chapter 3- parte B outline

TCP. TCP: Overview. TCP Segment Structure. Maximum Segment Size (MSS) Computer Networks 10/19/2009. CSC 257/457 - Fall

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

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

10 minutes survey (anonymous)

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

Chapter 3 Transport Layer

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

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

TCP: Overview RFCs: 793, 1122, 1323, 2018, 2581

CNT 6885 Network Review on Transport Layer

Chapter 3 Transport Layer

Chapter 3 Transport Layer

TCP (Part 2) Session 10 INST 346 Technologies, Infrastructure and Architecture

CS 4390 Computer Networks. Pointers to Corresponding Section of Textbook

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

Chapter 3 Transport Layer

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

Chapter III: Transport Layer

Computer Networking Introduction

COMP 431 Internet Services & Protocols. Transport Layer Protocols & Services Outline. The Transport Layer Reliable data delivery & flow control in TCP

RSC Part III: Transport Layer 3. TCP

CSC 401 Data and Computer Communications Networks

Chapter III: Transport Layer

Chapter 3 Transport Layer

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

CS Lecture 1 Review of Basic Protocols

Go-Back-N. Pipelining: increased utilization. Pipelined protocols. GBN: sender extended FSM

Fall 2012: FCM 708 Bridge Foundation I

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

Flow and Congestion Control (Hosts)

The Transport Layer Reliable data delivery & flow control in TCP. Transport Layer Protocols & Services Outline

CSCE 463/612 Networks and Distributed Processing Spring 2017

Chapter 3 Transport Layer

CS450 Introduc0on to Networking Lecture 14 TCP. Phu Phung Feb 13, 2015

The Transport Layer Reliable data delivery & flow control in TCP. Transport Layer Protocols & Services Outline

TCP: Overview RFCs: 793,1122,1323, 2018, 2581

CSCI Topics: Internet Programming Fall 2008

CSCD 330 Network Programming

Master Course Computer Networks IN2097

Chapter 3 Transport Layer

Chapter 3 Transport Layer

CSC 8560 Computer Networks: TCP

Computer Communication Networks Midterm Review

CSC 4900 Computer Networks: TCP

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

Chapter 3 Transport Layer

Chapter 3 outline. TDTS06 Computer networks. Principles of Reliable data transfer. Reliable data transfer: getting started

Foundations of Telematics

Lecture 5. Transport Layer. Transport Layer 1-1

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

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

By Ossi Mokryn, Based also on slides from: the Computer Networking: A Top Down Approach Featuring the Internet by Kurose and Ross

Course on Computer Communication and Networks. Lecture 5 Chapter 3; Transport Layer, Part B

Transport Protocols and TCP

Internet Protocols Fall Outline

Transmission Control Protocol. ITS 413 Internet Technologies and Applications

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

Chapter 6 Transport Layer

Lecture 11. Transport Layer (cont d) Transport Layer 1

The Transport Layer: TCP & Reliable Data Transfer

Chapter 3 Transport Layer

Lecture 3 The Transport Control Protocol (TCP) Antonio Cianfrani DIET Department Networking Group netlab.uniroma1.it

Transport Layer PREPARED BY AHMED ABDEL-RAOUF

Application. Transport. Network. Link. Physical

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

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

Routers. Session 12 INST 346 Technologies, Infrastructure and Architecture

Chapter 3: Transport Layer

CSCD 330 Network Programming Winter 2015

TCP : Fundamentals of Computer Networks Bill Nace

Lecture 12: Transport Layer TCP again

Computer Networking: A Top Down Approach

CSCI-1680 Transport Layer II Data over TCP Rodrigo Fonseca

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

Chapter 3: Transport Layer. Chapter 3 Transport Layer. Chapter 3 outline. Transport services and protocols

Master Course Computer Networks IN2097

Wireless TCP Performance Issues

Computer Communication Networks Midterm Review

Transport protocols. Transport Layer 3-1

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

rdt3.0: channels with errors and loss

Flow and Congestion Control Marcos Vieira

CSC358 Week 5. Adapted from slides by J.F. Kurose and K. W. Ross. All material copyright J.F Kurose and K.W. Ross, All Rights Reserved

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

Chapter 3 Transport Layer

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

Chapter 3 Transport Layer

Distributed Systems. 5. Transport Protocols

cs/ee 143 Communication Networks

Distributed Systems. 5. Transport Protocols. Werner Nutt

Our goals: understand d principles. behind transport layer protocols in the. Internet: layer services:

Transcription:

TDTS06: Computer Networks Instructor: Niklas Carlsson Email: niklas.carlsson@liu.se Transmission Control Protocol Notes derived from Computer Networking: A Top Down Approach, by Jim Kurose and Keith Ross, Addison-Wesley. The slides are adapted and modified based on slides from the book s companion Web site, as well as modified slides by Anirban Mahanti and Carey Williamson. CPSC 441:TCP 2 TCP segment structure URG: urgent data (generally not used) : # valid PSH: push data now (generally not used) RST, SYN, FIN: connection estab (setup, teardown commands) Internet checksum (as in UDP) 32 bits source port # dest port # sequence number acknowledgement number head not UAP Receive window len used RSF checksum Urg data pnter Options (variable length) application data (variable length) counting by bytes of data (not segments!) # bytes rcvr willing to accept CPSC 441:TCP 3 Sequence and Acknowledgement Number TCP views data as unstructured, but ordered stream of bytes. Sequence numbers are over bytes, not segments Initial sequence number is chosen randomly TCP is full duplex numbering of data is independent in each direction Acknowledgement number sequence number of the next byte expected from the sender s are cumulative CPSC 441:TCP 4 TCP seq. # s and s Seq. # s: byte stream number of first byte in segment s data s: seq # of next byte expected from other side cumulative Q: how receiver handles out-of-order segments A: TCP spec doesn t say, - up to implementor 1000 byte data Host sends another 500 bytes Host A Host B host s receipt of data time CPSC 441:TCP 5 TCP reliable data transfer TCP creates rdt service on top of IP s unreliable service Pipelined segments Cumulative acks TCP uses single retransmission timer Retransmissions are triggered by: timeout events duplicate acks Initially consider simplified TCP sender: ignore duplicate acks ignore flow control, congestion control CPSC 441:TCP 6 1

TCP sender events: data rcvd from app: Create segment with seq # seq # is byte-stream number of first data byte in segment start timer if not already running (think of timer as for oldest unacked segment) expiration interval: OutInterval timeout: retransmit segment that caused timeout restart timer Ack rcvd: If acknowledges previously unacked segments update what is known to be acked start timer if there are outstanding segments CPSC 441:TCP 7 Next = Initial SendBase = Initial loop (forever) { switch(event) event: data received from application above create TCP segment with sequence number Next if (timer currently not running) start timer pass segment to IP Next = Next length(data) event: timer timeout retransmit not-yet-acknowledged segment with smallest sequence number start timer event: received, with field value of y if (y > SendBase) { SendBase = y if (there are currently not-yet-acknowledged segments) start timer } } /* end of loop forever */ TCP sender (simplified) Comment: SendBase-1: last cumulatively ack ed byte Example: SendBase-1 = 71; y= 73, so the rcvr wants 73 ; y > SendBase, so that new data is acked CPSC 441:TCP 8 TCP Flow Control receive side of TCP connection has a receive buffer: app process may be slow at reading from buffer flow control sender won t overflow receiver s buffer by transmitting too much, too fast speed-matching service: matching the send rate to the receiving app s drain rate TCP Flow control: how it works (Suppose TCP receiver discards out-of-order segments) spare room in buffer = RcvWindow = RcvBuffer-[LastByteRcvd - LastByteRead] Rcvr advertises spare room by including value of RcvWindow in segments Sender limits uned data to RcvWindow guarantees receive buffer doesn t overflow CPSC 441:TCP 9 CPSC 441:TCP 10 Silly Window Syndrome Recall: TCP uses sliding window Silly Window occurs when small-sized segments are transmitted, resulting in inefficient use of the network pipe For e.g., suppose that TCP sender generates data slowly, 1-byte at a time Solution: wait until sender has enough data to transmit Nagle s Algorithm Nagle s Algorithm 1. TCP sender sends the first piece of data obtained from the application (even if data is only a few bytes). 2. Wait until enough bytes have accumulated in the TCP send buffer or until an is received. 3. Repeat step 2 for the remainder of the transmission. CPSC 441:TCP 11 CPSC 441:TCP 12 2

Silly Window Continued Suppose that the receiver consumes data slowly Receive Window opens slowly, and thus sender is forced to send small-sized segments Solutions Delayed Advertise Receive Window = 0, until reasonable amount of space available in receiver s buffer TCP Connection Management Recall: TCP sender, receiver establish connection before exchanging data segments initialize TCP variables: seq. #s buffers, flow control info (e.g. RcvWindow) client: connection initiator Socket clientsocket = new Socket("hostname","port number"); server: contacted by client Socket connectionsocket = welcomesocket.accept(); Three way handshake: Step 1: client host sends TCP SYN segment to server specifies initial seq # no data Step 2: server host receives SYN, replies with SYN segment server allocates buffers specifies server initial seq. # Step 3: client receives SYN, replies with segment, which may contain data CPSC 441:TCP 13 CPSC 441:TCP 14 TCP Connection Establishment TCP Connection Termination SYN/SYN SYN_RCVD Passive open CLOSED LISTEN Established Solid line for client Dashed line for server Active open; SYN SYN_SENT SYN/ client server closing FIN_WAIT1 FIN_WAIT2 TIME_WAIT CLOSED timed wait client server CLOSE_WAIT LAST_ CLOSED CPSC 441:TCP 15 CPSC 441:TCP 16 Principles of Congestion Control Congestion: informally: too many sources sending too much data too fast for network to handle Different from flow control! Manifestations: Packet loss (buffer overflow at routers) Increased end-to-end delays (queuing in router buffers) Results in unfairness and poor utilization of network resources Resources used by dropped packets (before they were lost) Retransmissions Poor resource allocation at high load Historical Perspective October 1986, Internet had its first congestion collapse Link LBL to UC Berkeley 400 yards, 3 hops, 32 Kbps throughput dropped to 40 bps factor of ~1000 drop! Van Jacobson proposes TCP Congestion Control: Achieve high utilization Avoid congestion Share bandwidth CPSC 441:TCP 17 CPSC 441:TCP 18 3

Congestion Control: Approaches Goal: Throttle senders as needed to ensure load on the network is reasonable End-end congestion control: no explicit feedback from network congestion inferred from end-system observed loss, delay approach taken by TCP Network-assisted congestion control: routers provide feedback to end systems single bit indicating congestion (e.g., ECN) explicit rate sender should send at TCP Congestion Control: Overview end-end control (no network assistance) Limit the number of packets in the network to window W Roughly, rate = W RTT Bytes/sec W is dynamic, function of perceived network congestion CPSC 441:TCP 19 CPSC 441:TCP 20 TCP Congestion Controls Tahoe (Jacobson 1988) Slow Start Congestion Avoidance Fast Retransmit Reno (Jacobson 1990) Fast Recovery S Vegas (Brakmo & Peterson 1994) Delay and loss as indicators of congestion CPSC 441:TCP 21 Slow Start Slow Start is used to reach the equilibrium state Initially: W = 1 (slow start) On each successful : W W 1 Exponential growth of W each RTT: W 2 x W Enter CA when W >= ssthresh ssthresh: window size after which TCP cautiously probes for bandwidth sender cwnd 1 2 3 4 5 67 8 data segment receiver CPSC 441:TCP 22 Congestion Avoidance Starts when W ssthresh On each successful : W W 1/W Linear growth of W each RTT: W W 1 sender 1 2 3 4 data segment receiver CA: Additive Increase, Multiplicative Decrease We have additive increase in the absence of loss events After loss event, decrease congestion window by half multiplicative decrease ssthresh = W/2 Enter Slow Start CPSC 441:TCP 23 CPSC 441:TCP 24 4

Detecting Packet Loss Fast Retransmit Assumption: loss indicates congestion Option 1: time-out Waiting for a time-out can be long! Option 2: duplicate s How many? At least 3. 10 11 12 13 14 15 16 17 10 11 11 11 11 Sender Receiver Wait for a timeout is quite long Immediately retransmits after 3 dups without waiting for timeout Adjusts ssthresh ssthresh W/2 Enter Slow Start W = 1 CPSC 441:TCP 25 CPSC 441:TCP 26 How to Set TCP out Value? longer than RTT but RTT varies too short: premature timeout unnecessary retransmissions too long: slow reaction to segment loss How to Estimate RTT? SampleRTT: measured time from segment transmission until receipt ignore retransmissions SampleRTT will vary, want estimated RTT smoother average several recent measurements, not just current SampleRTT CPSC 441:TCP 27 CPSC 441:TCP 28 TCP Round-Trip and out EstimatedRTT = (1- α)*estimatedrtt α*samplertt EWMA influence of past sample decreases exponentially fast typical value: α = 0.125 RTT (milliseconds) 350 300 250 200 150 100 RTT: gaia.cs.umass.edu to fantasia.eurecom.fr 1 8 15 22 29 36 43 50 57 64 71 78 85 92 99 106 SampleRTT time (seconnds) Estimated RTT TCP Round Trip and out Setting the timeout EstimtedRTT plus safety margin large variation in EstimatedRTT -> larger safety margin first estimate how much SampleRTT deviates from EstimatedRTT: DevRTT = (1-β)*DevRTT β* SampleRTT-EstimatedRTT (typically, β = 0.25) Then set timeout interval: [Jacobson/Karels Algorithm] outinterval = µ*estimatedrtt Ø*DevRTT CPSC 441:TCP 29 Typically, µ =1 and Ø = 4. CPSC 441:TCP 30 5

TCP Tahoe: Summary Basic ideas Gently probe network for spare capacity Drastically reduce rate on congestion Windowing: self-clocking Other functions: round trip time estimation, error recovery for every { if (W < ssthresh) then W (SS) else W = 1/W (CA) TCP Tahoe Window W 2 W 1 ssthresh=w 2/2 ssthresh=w 1/2 W 1 /2 W 2 /2 } for every loss { ssthresh = W/2 W = 1 } CPSC 441:TCP 31 Reached initial ssthresh value; switch to CA mode Slow Start CPSC 441:TCP 32 Questions? TCP Reno Q. 1. To what value is ssthresh initialized to at the start of the algorithm? Window Note how there is Fast Recovery after cutting Window in half Q. 2. Why is Fast Retransmit triggered on receiving 3 duplicate s (i.e., why isn t it triggered on receiving a single duplicate )? Q. 3. Can we do better than TCP Tahoe? Reached initial ssthresh value; switch to CA mode Slow Start CPSC 441:TCP 33 CPSC 441:TCP 34 TCP Reno: Fast Recovery Objective: prevent `pipe from emptying after fast retransmit each dup represents a packet having left the pipe (successfully received) Let s enter the FR/FR mode on 3 dup s ssthresh W/2 retransmit lost packet W ssthresh ndup (window inflation) Wait till W is large enough; transmit new packet(s) On non-dup (1 RTT later) W ssthresh (window deflation) enter CA mode TCP Reno: Summary Fast Recovery along with Fast Retransmit used to avoid slow start On 3 duplicate s Fast retransmit and fast recovery On timeout Fast retransmit and slow start CPSC 441:TCP 35 CPSC 441:TCP 36 6

TCP Throughput TCP Futures What s the average throughout ot TCP as a function of window size and RTT? Ignore slow start Let W be the window size when loss occurs. When window is W, throughput is W/RTT Just after loss, window drops to W/2, throughput to W/2RTT. Average throughout:.75 W/RTT Example: 1500 byte segments, 100ms RTT, want 10 Gbps throughput Requires window size W = 83,333 in-flight segments Throughput in terms of loss rate: L = 2 10-10 Wow 1.22 MSS RTT New versions of TCP for high-speed needed! L CPSC 441:TCP 37 CPSC 441:TCP 38 TCP Fairness Fairness goal: if K TCP sessions share same bottleneck link of bandwidth R, each should have average rate of R/K TCP connection 1 Fairness (more) TCP fairness: dependency on RTT Connections with long RTT get less throughput Parallel TCP connections TCP friendliness for UDP streams TCP connection 2 bottleneck router capacity R CPSC 441:TCP 39 CPSC 441:TCP 40 Chapter 3: Summary Tutorial: TCP 101 principles behind transport layer services: multiplexing, demultiplexing reliable data transfer flow control congestion control instantiation and implementation in the Internet UDP TCP Next: leaving the network edge (application, transport layers) into the network core CPSC 441:TCP 41 The Transmission Control Protocol (TCP) is the protocol that sends your data reliably Used for email, Web, ftp, telnet, p2p, Makes sure that data is received correctly: right data, right order, exactly once Detects and recovers from any problems that occur at the IP network layer Mechanisms for reliable data transfer: sequence numbers, acknowledgements, timers, retransmissions, flow control... CPSC 601.38 42 7

TCP 101 (Cont d) TCP is a connection-oriented protocol TCP 101 (Cont d) TCP slow-start and congestion avoidance SYN SYN/ GET URL Web Client YOUR DATA HERE Web Server FIN FIN/ CPSC 601.38 43 CPSC 601.38 44 TCP 101 (Cont d) TCP slow-start and congestion avoidance TCP 101 (Cont d) TCP slow-start and congestion avoidance CPSC 601.38 45 CPSC 601.38 46 TCP 101 (Cont d) This (exponential growth) slow start process continues until either: packet loss: after a brief recovery phase, you enter a (linear growth) congestion avoidance phase based on slow-start threshold found limit reached: slow-start threshold, or maximum advertised receive window size all done: terminate connection and go home Tutorial: TCP 201 There is a beautiful way to plot and visualize the dynamics of TCP behaviour Called a TCP Sequence Number Plot Plot packet events (data and acks) as points in 2-D space, with time on the horizontal axis, and sequence number on the vertical axis Example: Consider a 14-packet transfer CPSC 601.38 47 CPSC 601.38 48 8

Key: Data Packet Ack Packet So What? What can it tell you? Everything!!! CPSC 601.38 49 CPSC 601.38 50 Key: Data Packet Ack Packet TCP Seg. Size Key: Data Packet Ack Packet RTT CPSC 601.38 51 CPSC 601.38 52 Key: Data Packet Ack Packet Num Bytes Sent Key: Data Packet Ack Packet TCP Connection Duration CPSC 601.38 53 CPSC 601.38 54 9

Key: Data Packet Ack Packet Sec Bytes Key: Data Packet Ack Packet Access Network Bandwidth (Bytes/Sec) CPSC 601.38 55 CPSC 601.38 56 Key: Data Packet Ack Packet Sender s Flow Control Window Size Key: Data Packet Ack Packet TCP Slow Start CPSC 601.38 57 CPSC 601.38 58 Key: Data Packet Ack Packet Delayed Key: Data Packet Ack Packet Packet Loss Duplicate CPSC 601.38 59 CPSC 601.38 60 10

Cumulative Key: Data Packet Ack Packet Retransmit Key: Data Packet Ack Packet RTO CPSC 601.38 61 CPSC 601.38 62 TCP 201 (Cont d) What happens when a packet loss occurs? Quiz... Consider a 14-packet Web document For simplicity, consider only a single packet loss Key: Data Packet Ack Packet CPSC 601.38 63 CPSC 601.38 64 Key: Data Packet Ack Packet? Key: Data Packet Ack Packet CPSC 601.38 65 CPSC 601.38 66 11

Key: Data Packet Ack Packet Key: Data Packet Ack Packet? CPSC 601.38 67 CPSC 601.38 68 Key: Data Packet Ack Packet Key: Data Packet Ack Packet CPSC 601.38 69 CPSC 601.38 70 Key: Data Packet Ack Packet? Key: Data Packet Ack Packet CPSC 601.38 71 CPSC 601.38 72 12

Key: Data Packet Ack Packet Key: Data Packet Ack Packet? CPSC 601.38 73 CPSC 601.38 74 Key: Data Packet Ack Packet TCP 201 (Cont d) Main observation: Not all packet losses are created equal Losses early in the transfer have a huge adverse impact on the transfer latency Losses near the end of the transfer always cost at least a retransmit timeout Losses in the middle may or may not hurt, depending on congestion window size at the time of the loss CPSC 601.38 75 CPSC 601.38 76 Congratulations! You are now a TCP expert! CPSC 601.38 77 13