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

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

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

Transport Layer: outline

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

Transport Layer: Outline

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

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

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

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

CSE 4213: Computer Networks II

CS 4390 Computer Networks. Pointers to Corresponding Section of Textbook

Chapter 3 Transport Layer

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

Computer Networking Introduction

RSC Part III: Transport Layer 3. TCP

Chapter III: Transport Layer

Chapter 3 Transport Layer

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

10 minutes survey (anonymous)

CSCE 463/612 Networks and Distributed Processing Spring 2017

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

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

CSC 401 Data and Computer Communications Networks

Lecture 8. TCP/IP Transport Layer (2)

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

CSC 4900 Computer Networks: TCP

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

TCP : Fundamentals of Computer Networks Bill Nace

Chapter 3 Transport Layer

Chapter 3 Transport Layer

CSCD 330 Network Programming

Chapter 3- parte B outline

Chapter 3 Transport Layer

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

CS Lecture 1 Review of Basic Protocols

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

The Transport Layer: TCP & Reliable Data Transfer

Chapter 3 Transport Layer

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

CSCI Topics: Internet Programming Fall 2008

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

CC451 Computer Networks

Chapter 3 Transport Layer

CNT 6885 Network Review on Transport Layer

Chapter III: Transport Layer

Fall 2012: FCM 708 Bridge Foundation I

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

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

Lecture 5. Transport Layer. Transport Layer 1-1

Distributed Systems. 5. Transport Protocols

Distributed Systems. 5. Transport Protocols. Werner Nutt

Chapter 6 Transport Layer

Master Course Computer Networks IN2097

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

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

Computer Communication Networks Midterm Review

Chapter 3 Transport Layer

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

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

Transmission Control Protocol (TCP)

Chapter 3 Transport Layer

Chapter 3 Transport Layer

Transmission Control Protocol

Foundations of Telematics

Lecture 12: Transport Layer TCP again

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

The Transport Layer Multiplexing, Error Detection, & UDP

Internet and Intranet Protocols and Applications

Lecture 11: Transport Layer Reliable Data Transfer and TCP

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

CSC 8560 Computer Networks: TCP

Master Course Computer Networks IN2097

Computer Networks & Security 2016/2017

Transport Protocols and TCP

Chapter 3: Transport Layer

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

NWEN 243. Networked Applications. Layer 4 TCP and UDP

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

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

Connection-oriented (virtual circuit) Reliable Transfer Buffered Transfer Unstructured Stream Full Duplex Point-to-point Connection End-to-end service

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

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

7. TCP 최양희서울대학교컴퓨터공학부

Data Communications & Networks. Session 9 Main Theme Network Congestion Causes, Effects, Controls, and TCP Applications. Dr. Jean-Claude Franchitti

TCP = Transmission Control Protocol Connection-oriented protocol Provides a reliable unicast end-to-end byte stream over an unreliable internetwork.

Chapter 3 outline. Chapter 3: Transport Layer. Transport vs. network layer. Transport services and protocols. Internet transport-layer protocols

Computer Networking: A Top Down Approach

Pipelined protocols: overview

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

Computer Communication Networks Midterm Review

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

Transmission Control Protocol (TCP)

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

Routers. Session 12 INST 346 Technologies, Infrastructure and Architecture

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

I TCP 1/2. Internet TA: Connection-oriented (virtual circuit) Connectionless (datagram) (flow control) (congestion control) TCP Connection-oriented

Transport Layer Marcos Vieira

Flow and Congestion Control (Hosts)

Chapter 3: Transport Layer. Chapter 3 Transport Layer. Transport layer. Position of transport layer. Transport layer.

Information Network 1 TCP 1/2. Youki Kadobayashi NAIST

Transcription:

CPSC 360 Network Programming The Transport Layer Reliable data delivery & flow control in TCP Michele Weigle Department of Computer Science Clemson University mweigle@cs.clemson.edu http://www.cs.clemson.edu/~mweigle/courses/cpsc360 1 Transport Layer Protocols & Services Outline! Fundamental transport layer services» Multiplexing/Demultiplexing» Error detection» Reliable data delivery» Pipelining» Flow control» Congestion control! Internet transport protocols» UDP» TCP... Logical end-toend transport... application transport network link physical...... network link physical network link physical application transport network link physical 2

TCP Overview TCP is! Point-to-point, full-duplex» Bi-directional data flow within a connection! Reliable, in-order byte steam» No message boundaries! Connection-oriented» Handshaking initializes sender and receiver state before data exchange! Pipelined» Congestion and flow control determine window size» Each endpoint has two buffers: a send and receive buffer Application writes data TCP send buffer door segments Application reads data TCP receive buffer RFCs: 793, 1122, 1323, 2018, 2581! Congestion controlled» Internet would cease to function without this!! Flow controlled» Sender and receiver have synchronized windows to ensure receiver is not overwhelmed 3 TCP Segment Structure Header and payload format Urgent data ( URG ) ACK number is valid Push data now ( PSH ) Connection establishment and teardown commands ( RST, SYN, FIN ) Same checksum as in UDP 32 bits source port # dest port # sequence number head len acknowledgement number not used UAP R S F checksum rcvr window size ptr urgent data Options (variable length) Application data (variable length) s of data sent/received are numbered (not segments) Number of bytes the receiver is willing to accept payload! MSS (Maximum Segment Size) 4

TCP Sequence Numbers and ACKs Telnet example! Sequence numbers:» stream index of the first byte in the segment s payload! ACKs:» Sequence number of next byte expected from the other side» ACKs are cumulative! How does receiver handle out-of-order segments?» TCP spec doesn t say, it s up to the implementor User types C time host ACKs receipt of echoed C Host A Host B Seq=42, ACK=79, data =!C" Seq=79, ACK=43, data = C Seq=43, ACK=80, data = host ACKs receipt of C, echoes back C 5 Reliable Data Transfer in TCP Sender s state machine TCP_send(data) create segment udt_send(segment nextseqnum) start_timer receive ACK for segment y update timers advance the window to y retransmit y if third duplicate ACK timeout for segment y udt_send(segment y) start timer wait for event! TCP retransmits segments if:» An expected ACK times out» 3 duplicate ACKs for a segment are received 6

Reliable Data Transfer in TCP Simplified sender s state machine Sliding window Sent and ACK ed Sent and unack ed Unsent and eligible Unsent and ineligible 1st sequence send base next sequence number sendbase = initial_sequence number nextseqnum = initial_sequence number loop (forever) { switch(event) event: data received from application above event: timer timeout for segment with sequence number y event: ACK received with value y } create TCP segment with sequence number nextseqnum start timer for segment with nextseqnum pass segment to IP nextseqnum = nextseqnum + length(data) retransmit segment with sequence number y ( segment y ) compute new timeout interval for segment y restart timer for segment y 7 Reliable Data Transfer in TCP Simplified sender s state machine Sliding window Sent and ACK ed 1st sequence send base Sent and unack ed Unsent and eligible Unsent and ineligible next sequence number if (y > sendbase) { /* Cumulative ACK of all data up to y */ cancel timers for segments with sequence numbers # y sendbase = initial_sequence number := y sendbase nextseqnum = initial_sequence number } else if ( y == sendbase) { /* A duplicate ACK */ loop (forever) { increment number of duplicate ACKs received switch(event) if (number of duplicate ACKS received == 3) event: data received from application { /* Fast retransmit */ above resend segment with sequence number sendbase event: timer timeout for segment with restart timer for segment sendbase sequence number y } event: ACK received with}value y } 8

TCP ACK generation rules [RFC 1122, RFC 2581] Event In-order segment arrival, no gaps, all previous data already ACKed In-order segment arrival, no gaps, one delayed ACK pending Out-of-order segment arrival (higher than expected sequence number) Gap detected Arrival of segment that partially or completely fills gap TCP Receiver action Delayed ACK. Wait 200 ms (up to 500 ms allowed) for next segment. If no segment received, send ACK Immediately send single cumulative ACK Send duplicate ACK, indicating sequence number of next expected byte Immediate ACK if segment starts at lower end of gap 9 Reliable Data Transfer in TCP Retransmission examples Host A Host B Host A Host B timeout X ACK=100 Seq=100 timeout Seq=92 timeout Seq=100, 20 data bytes ACK=100 ACK=120 ACK=100 time ACK=120! Lost ACK scenario! Premature timeout 10

Reliable Data Transfer in TCP Retransmission examples Host A Host B Host A Host B timeout Seq=100, 20 data bytes X ACK=100 ACK=120 Seq=100 timeout Seq=92 timeout Seq=100, 20 data bytes ACK=100 ACK=120 time ACK=120! Cumulative ACKs potentially avoid retransmissions! Premature timeout 11 Reliable Data Transfer in TCP Setting the ACK timer! How large should the ACK timeout value be?» Too short: Premature timeouts result in unnecessary retransmissions» Too long: Slow reaction to loss results in poor performance because the sender s windows stops advancing! Timer should be longer than the RTT, but how do we estimate RTT?» Measure the time from segment transmission until receipt of ACK ( SampleRTT ) " Ignore retransmissions " Measure only one segment s RTT at a time» SampleRTT will vary, so we compute an average RTT based on several recent RTT samples 12

Reliable Data Transfer in TCP Estimating round-trip-time EstimatedRTT = (1-!)*EstimatedRTT +! *SampleRTT Timeout = EstimatedRTT + 4*Deviation Deviation = (1-")*Deviation + " * SampleRTT-EstimatedRTT! The estimated RTT is an exponential weighted moving average (EWMA)» Computes a smooth average» Influence of a given sample decreases exponentially fast» Typical value of! is 0.125! Timeout is EstimtedRTT plus safety margin! Large variation in EstimatedRTT results in a larger safety margin 13 Reliable Data Transfer in TCP Estimating round-trip-time 14

TCP Flow Control Window control sequence 1 st Receiver!s buffer (RcvBuffer) Delivered to application Received, ACKed, not delivered Acceptable but not received Not expected, not received! Flow control is the problem of ensuring the receiver is not overwhelmed» The receiver can become overwhelmed if the application reads too slow or the sender transmits too fast Receiver!s window (RcvWindow)! The receiver s window represents its remaining buffer capacity! The window advances as the application reads received data 15 TCP Flow Control Window control sequence 1 st Receiver!s buffer (RcvBuffer) Delivered to application Received, ACKed, not delivered Acceptable but not received Not expected, not received! The receiver explicitly informs the sender of the amount of free buffer space in RcvBuffer» RcvWindow field in TCP segment! The sender keeps the amount of transmitted, unacked data less than most recently received RcvWindow source port dest port sequence number ack number not receiver used flags window size checksum urgent data head len Receiver!s window TCP options Application data 16

TCP Flow Control Window control sequence 1 st RcvBuffer Delivered to application Received, ACKed, not delivered Acceptable but not received Not expected, not received Read Rcvd RcvWindow! The goal is to ensure: Rcvd - Read! RcvBuffer! Sender is sent: RcvWindow = RcvBuffer - (Rcvd-Read) 17 TCP Flow Control Window control sequence 1 st Sent and ACKed Sent and not ACKed Sender!s buffer Eligible to be sent Ineligible Application blocked from sending ACKed Sent RcvWindow! The sender ensures: Sent - ACKed! RcvWindow 18

TCP Connection Management The three-way handshake Client client TCP 3-way handshake bytes Server welcoming connection! TCP endpoints establish a connection before exchanging data segments» client: connection initiator Socket clientsocket = new Socket("hostname", "port number")» server: contacted by client Socket connectionsocket = welcomesocket.accept() 19 TCP Connection Management The three-way handshake! Client sends SYN segment to server» The SYN specifies the client s initial sequence number! Server receives SYN, replies with SYN+ACK segment» ACKs received SYN» Allocates buffers» Specifies server s initial sequence number! Third segment may be an ACK only or an ACK+data client Connection request (SYN=1, ACK=0 seq=client_isn) server Connection granted (SYN=1, ACK=1 seq=server_isn, ack=client_ins+1) ACK (SYN=0, ACK=1 seq=client_isn+1, ack=server_isn+1) ACK (SYN=0, ACK=1 seq=client_isn+1, ack=server_isn+1, data= ) 20

TCP Connection Management Closing a connection! Client sends FIN segment to server! Server receives FIN, replies with ACK» Server closes connection, sends FIN! Client receives FIN, replies with ACK! Client enters timed wait state» Client will ACK any received FIN close() Timed Wait client server FIN ACK FIN ACK Connection closed close() 21 TCP Connection Management Client/Server lifecycles receive FIN send ACK Wait 30 seconds Closed connect() send SYN receive ACK send nothing Closed Server creates listen Timed Wait SYN Sent ACK Listen receive FIN send ACK FIN Wait 2 receive SYN+ACK send ACK Established close() send FIN Close Wait receive SYN send SYN & ACK SYN Received receive ACK send nothing FIN Wait 1 close() send FIN receive FIN send ACK Established receive ACK send nothing! TCP client lifecycle! TCP server lifecycle 22

hufflepuff:[~]% sudo tcpdump host hufflepuff and host www.cs.clemson.edu and tcp tcpdump: verbose output suppressed, use -v or -vv for full protocol decode listening on en0, link-type EN10MB (Ethernet), capture size 96 bytes TCP Traces 11:08:22.816917 IP hufflepuff.cs.clemson.edu.54071 > www.cs.clemson.edu.http: S 1990840413:1990840413(0) win 65535 <mss 1460,nop,wscale 0,nop,nop,timestamp 1273416398 0> 11:08:22.817253 IP www.cs.clemson.edu.http > hufflepuff.cs.clemson.edu.54071: S 150440752:150440752(0) ack 1990840414 win 49232 <nop,nop,timestamp 1628316 1273416398,mss 1460,nop,wscale 0> 11:08:22.817331 IP hufflepuff.cs.clemson.edu.54071 > www.cs.clemson.edu.http:. ack 1 win 65535 11:08:22.821890 IP hufflepuff.cs.clemson.edu.54071 > www.cs.clemson.edu.http: P 1:506(505) ack 1 win 65535 11:08:22.822224 IP www.cs.clemson.edu.http > hufflepuff.cs.clemson.edu.54071:. ack 506 win 49232 11:08:22.828103 IP www.cs.clemson.edu.http > hufflepuff.cs.clemson.edu.54071:. 1:1449(1448) ack 506 win 49232 11:08:22.828112 IP www.cs.clemson.edu.http > hufflepuff.cs.clemson.edu.54071: P 1449:2208(759) ack 506 win 49232 11:08:22.880198 IP hufflepuff.cs.clemson.edu.54071 > www.cs.clemson.edu.http: P 506:1123(617) ack 2208 win 65535 11:08:22.880580 IP www.cs.clemson.edu.http > hufflepuff.cs.clemson.edu.54071:. ack 1123 win 49232 11:08:22.883328 IP www.cs.clemson.edu.http > hufflepuff.cs.clemson.edu.54071: P 2208:2388(180) ack 1123 win 49232 11:08:22.884907 IP hufflepuff.cs.clemson.edu.54071 > www.cs.clemson.edu.http: F 1123:1123(0) ack 2388 win 65535 11:08:22.885087 IP www.cs.clemson.edu.http > hufflepuff.cs.clemson.edu.54071:. ack 1124 win 49232 11:08:22.836032 IP www.cs.clemson.edu.http > hufflepuff.cs.clemson.edu.54071: F 2388:2388(0) ack 1124 win 49232 11:08:22.836067 IP hufflepuff.cs.clemson.edu.54071 > www.cs.clemson.edu.http:. ack 2389 win 65535 ^C 14 packets captured 127 packets received by filter 0 packets dropped by kernel For more info: % man tcpdump 23