Two approaches to Flow Control. Cranking up to speed. Sliding windows in action

Similar documents
CS UDP: User Datagram Protocol, Other Transports, Sockets. congestion worse);

Transmission Control Protocol. ITS 413 Internet Technologies and Applications

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

05 Transmission Control Protocol (TCP)

Lecture 3: The Transport Layer: UDP and TCP

TSIN02 - Internetworking

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

User Datagram Protocol

ITS323: Introduction to Data Communications

Transport Layer. <protocol, local-addr,local-port,foreign-addr,foreign-port> ϒ Client uses ephemeral ports /10 Joseph Cordina 2005

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

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

TSIN02 - Internetworking

TCP/IP Performance ITL

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

Mobile Transport Layer Lesson 10 Timeout Freezing, Selective Retransmission, Transaction Oriented TCP and Explicit Notification Methods

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

Protocol Overview. TCP/IP Performance. Connection Types in TCP/IP. Resource Management. Router Queues. Control Mechanisms ITL

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

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

Application. Transport. Network. Link. Physical

ECE 650 Systems Programming & Engineering. Spring 2018

ECE 333: Introduction to Communication Networks Fall 2001

CS118 Discussion 1A, Week 4. Zengwen Yuan Dodd Hall 78, Friday 10:00 11:50 a.m.

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

Networking Technologies and Applications

Sequence Number. Acknowledgment Number. Data

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

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

Arhitecturi și Protocoale de Comunicații (APC) Protocoale de nivel Transport

Transport Layer. Gursharan Singh Tatla. Upendra Sharma. 1

9th Slide Set Computer Networks

CS457 Transport Protocols. CS 457 Fall 2014

6. The Transport Layer and protocols

TCP: Transmission Control Protocol UDP: User Datagram Protocol TCP - 1

Multiple unconnected networks

The Transport Layer. Part 1

TSIN02 - Internetworking

Congestion / Flow Control in TCP

Basic Reliable Transport Protocols

The Transport Layer. Internet solutions. Nixu Oy PL 21. (Mäkelänkatu 91) Helsinki, Finland. tel fax.

QUIZ: Longest Matching Prefix

TSIN02 - Internetworking

Simulation of TCP Layer

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

CSCI-1680 Transport Layer I Rodrigo Fonseca

Transport Protocols & TCP TCP

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

Transport Layer Marcos Vieira

Kent State University

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

CSCI-GA Operating Systems. Networking. Hubertus Franke

User Datagram Protocol (UDP):

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

Chapter 7. The Transport Layer

CSCI-1680 Transport Layer I Rodrigo Fonseca

Transport Layer TCP / UDP

Introduction to Networks and the Internet

TCP/IP Protocol Suite 1

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

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

Chapter 5 End-to-End Protocols

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

TCP Strategies. Keepalive Timer. implementations do not have it as it is occasionally regarded as controversial. between source and destination

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

Sequence Number. Acknowledgment Number. Checksum. Urgent Pointer plus Sequence Number indicates end of some URGENT data in the packet

Chapter 6. What happens at the Transport Layer? Services provided Transport protocols UDP TCP Flow control Congestion control

UNIT IV -- TRANSPORT LAYER

CNT 6885 Network Review on Transport Layer

TCP /IP Fundamentals Mr. Cantu

CS419: Computer Networks. Lecture 10, Part 2: Apr 11, 2005 Transport: TCP mechanics (RFCs: 793, 1122, 1323, 2018, 2581)

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

Stream Control Transmission Protocol

CSCD 330 Network Programming

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

Transmission Control Protocol (TCP)

Transport Protocols Reading: Sections 2.5, 5.1, and 5.2

ETSF05/ETSF10 Internet Protocols Transport Layer Protocols

Introduction to TCP/IP networking

ECE 435 Network Engineering Lecture 9

Information Network 1 TCP 1/2. Youki Kadobayashi NAIST

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

Flow and Congestion Control

CS4700/CS5700 Fundamentals of Computer Networks

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

Computer Communication Networks Midterm Review

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

UNIT V. Computer Networks [10MCA32] 1

Outline Computer Networking. Functionality Split. Transport Protocols

TCP/IP. Chapter 5: Transport Layer TCP/IP Protocols

Introduc)on to Computer Networks

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

Topics. TCP sliding window protocol TCP PUSH flag TCP slow start Bulk data throughput

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

Network Technology 1 5th - Transport Protocol. Mario Lombardo -

Transport Protocols and TCP: Review

Computer Networks. Wenzhong Li. Nanjing University

What is TCP? Transport Layer Protocol

Transcription:

CS314-27 TCP: Transmission Control Protocol IP is an unreliable datagram protocol congestion or transmission errors cause lost packets multiple routes may lead to out-of-order delivery If senders send too fast, routers or receivers cannot keep up (making congestion worse) When many senders compete, capacity must be fairly shared TCP's job is to fix those three problems flow control retransmission after errors Two approaches to Flow Control Rate Control - sender determines the maximum safe sending rate and never exceeds it Sliding Window - sender sends up to a window full of data but then pauses for an acknowledgement Window size is adjusted dynamically to match network capacity Window size is also known as "credit" Missing acknowledgement causes retransmission TCP is a sliding window protocol 1 2 Sliding windows in action Cranking up to speed To user Ready for user Transmit window Packets in flight in the network Receive window Input queue of packets Output queue of packets Must wait Windows increase as throughput increases. At full speed, these packets add up to the delay-bandwidth product. From user 3 TCP starts slowly Initial window size is small Send packets until window is empty Increase window size as data flow accelerates Decrease window size if data flow slows down Retransmit when acknowledgments don't arrive Note that when A is talking to B and B is talking to A, the paths may be asymmetric, so TCP windows work independently in the two directions Note that TCP transmits a stream of bytes as far as user programs are concerned, broken up into segments by TCP itself 4

Why is this better than rate control? The sliding window approach works over an enormous range of speeds It was designed in the days of 9600 baud modems, and it works (with some tuning) in the days of 10 Gb/s links Rate control works best in fixed-speed networks It works reasonably well as router load increases towards 100% Sharing between thousands or millions of competing TCP sessions is reasonably fair Rate control has real trouble sharing fairly at that scale Retransmission fits naturally into TCP Rate control protocols have to break step to deal with retransmissions TCP connection phases A TCP connection has three main phases: Establishment Data transfer Disconnection One end (the listener ) has to be willing to accept incoming TCP connections, and the other end (the initiator ) has to choose to start The listener is listening to a specific port number which serves as a meeting point IP address + port number = Layer 4 address 5 6 Connection establishment Initiator Send SYN Wait Connection OK Listener Send SYN Wait Connection OK Disconnection A B Send FIN Wait Send FIN Closed Closed Note that whoever goes first, there is one SYN and one ACK in each direction This will work even if both initiate simultaneously Doesn't matter which end closes first If one end dies, a timeout will eventually close the other end 7 8

TCBs During connection establishment, each end creates a TCB (transmission control block) data structure A TCB links the user program at each end to the TCP process Typical TCB contents: local and remote port numbers for this connection current send and receive window sizes pointers into the send and receive buffers status of send and receive sequence numbers To understand this we need to look at the TCP header format The TCP header follows the IP header in a packet, when Protocol Number (IPv4) or Next Header (IPv6) is 6 TCP header 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 Source Port Destination Port Sequence Number Acknowledgment Number Data U A P R S F Offset Reserved R C S S Y I Window G K H T N N Checksum Urgent Pointer Options Zero Padding data segment... +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Protocol Number or Next Header is 6 9 10 TCP header fields (1) Port numbers - used to find TCBs at each end Sequence number the sequence number of the first data byte in this TCP segment goes up by 1 for each data byte sent on the connection initialised in SYN packet (random value) Acknowledgement number only valid in ACK packet next sequence number the sender of the segment is expecting in other words, sending Ack Number 12345 means I have correctly received up to byte 12344 a duplicate ACK means I've still only received up to byte 12344 TCP header fields (2) Data offset Size of TCP header in 32 bit words URG - urgent bit (not too important) ACK - this is an ACK packet PSH - push bit (kick received data to the user) RST - reset bit (emergency disconnect) SYN - SYN packet ( synchronise sequence numbers ) FIN - FIN packet ( finished, starts normal disconnect) 11 12

TCP header fields (3) Window The number of data bytes beginning with the one indicated in the acknowledgment field which the sender of this segment is willing to accept Checksum (next slide) Urgent pointer (not too important) Options For example, specify maximum receive segment size TCP checksum This is the primary protection against transmission errors in the Internet 16 bit one's-complement of the one's-complement sum of all 16 bit words in the TCP header and data If a segment contains an odd number of bytes to be checksummed, the last byte is padded on the right with zeros to form a 16 bit word for checksum purposes. (The padding is not transmitted as part of the segment) While computing the checksum, the checksum field itself is replaced with zeros The checksum also covers a pseudo header conceptually prefixed to the TCP header. This pseudo header contains the Source & Destination IP Addresses, the Protocol or Next Header Number, and TCP segment length 13 14 Sequence number state at sender and receiver Sent & ACKed Sent but no ACK May be sent Must queue SND.UNA SND.NXT increasing seq. number SND.WND Received & ACKed Reception allowed Forbidden RCV.NXT RCV.WND increasing seq. number TCP data transfer phase After SYN/ACK, the two ends know initial sequence numbers and initial window sizes Both ends may start sending, as long as they stay within the allowed sending window sending a segment moves SND.NXT along receiving an ACK for a given sequence number moves SND.UNA along if SND.NXT = SND.UNA+SND.WND, wait Both ends receive when a segment arrives, increase RCV.NXT and send ACK if RCV.NXT reaches end of window (i.e. RCV.WND=0), only ACKs will be treated. Incoming data is discarded and not ACKed 15 16

Adjusting the Window The size of the send window (SND.WND) decides how much data can be sent without waiting for an ACK SND.WND must be decreased when things are going slowly, and can be increased when things are going well SND.WND tracks RCV.WND via ACK messages The algorithm for adjusting RCV.WND is the most critical feature of a TCP implementation and has been modified many times See comments below on congestion control Background slide Algorithm for Send Window to track Receive Window Variables SND.NXT - next sequence number to be sent SND.WND - current send window size LatestAckSeq - acknowledgement number in latest ACK CurrentSeq - sequence number of segment carrying ACK AckWindow - receiver's window size in ACK PreviousSeq, PreviousAck - from previous window update Algorithm if LatestAckSeq <= SND.NXT then # waiting for ACKs if (PreviousSeq < CurrentSeq or # don't use stale (PreviousSeq == CurrentSeq # window size and PreviousAck <= LatestAckSeq)) then {SND.WND := AckWindow; # update window PreviousSeq := CurrentSeq; PreviousAck := LatestAckSeq;} 17 18 Retransmission If an ACK does not arrive within a certain timeout, all segments since the previous ACK will be retransmitted no difference whether packet was discarded due to congestion or lost due to transmission fault or checksum error can be optimised with Selective ACK to avoid retransmitting correctly received segments The retransmission timeout is dynamically calculated Typically by measuring a running average Round Trip Time (RTT) between sending a segment and receiving its ACK Then set the timeout to, say, 2xRTT Clarification about delay-bandwidth product The one-way delay in a TCP session is roughly half the RTT Therefore, the delay-bandwidth product is roughly bandwidth x RTT 2 The TCP window size in a stable state is roughly bandwidth x RTT which is double the delay-bandwidth product, because the window has to allow for ACKs to come back 'roughly' because the outbound delay (for data) and the return (for ACKs) will never be exactly equal some web references get this wrong bandwidth = link transmission rate (b/s) 19 20

Congestion control TCP as described above is greedy - it will pump as much data as the path will take With millions of connections, this leads to congestive collapse where saturated routers must discard most packets Modern TCPs use various techniques to avoid this, all of which amount to being good neighbours Slow Start: start small and expand window gently Congestion Avoidance: when duplicate ACKs indicate that later segments were lost, limit number of (re)transmissions Fast Recovery: after 3 duplicate ACKs, retransmit once and wait. If still no ACK, revert to Slow Start Modern routers keep an eye out for greedy cheats and selectively discard their packets A day in the life of a TCP session User A: Listen (porta) User B: Open (AddressA, porta) SYN/ACK exchange Data transfer phase User A: Send (DataA) Retransmission, User B: Receive (DataA) windowing, and User B: Send (DataB) congestion User A: Receive (DataB) control (repeat as required by application) as needed User B: Close FIN/ACK exchange User A: Listen (porta) 21 22 References Shay 11.4 Any of the TCP/IP books listed for IPv4 RFCs: RFC 793, the original definition Many advisory RFCs and other publications on implementation techniques to tune performance. (Implementing TCP is not for amateurs!) RFC 2460 (IPv6) modifies TCP s checksum formula RFC 3168 adds Explicit Congestion Notification to TCP and IP RFC 4614 is a roadmap for TCP specifications 23