Reliable Transport I: Concepts and TCP Protocol

Similar documents
Reliable Transport I: Concepts and TCP Protocol

Reliable Transport II: TCP and Congestion Control

Reliable Transport II: TCP and Congestion Control

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

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

CS457 Transport Protocols. CS 457 Fall 2014

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

CSCD 330 Network Programming

Transport Layer Marcos Vieira

TCP : Fundamentals of Computer Networks Bill Nace

CSC 4900 Computer Networks: TCP

CS4700/CS5700 Fundamentals of Computer Networks

ECE697AA Lecture 3. Today s lecture

Transport Layer: outline

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

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

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

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

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

Transport Protocols Reading: Sections 2.5, 5.1, and 5.2

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

NWEN 243. Networked Applications. Layer 4 TCP and UDP

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

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

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

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

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

The Transport Layer: TCP & Reliable Data Transfer

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

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

Transport Layer: Outline

The Transport Layer Reliability

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

Basic Reliable Transport Protocols

Lecture 4: Congestion Control

Transport Protocols and TCP

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

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

CSCE 463/612 Networks and Distributed Processing Spring 2017

Lecture 8. TCP/IP Transport Layer (2)

Sequence Number. Acknowledgment Number. Data

CS 716: Introduction to communication networks th class; 7 th Oct Instructor: Sridhar Iyer IIT Bombay

Lecture 3: The Transport Layer: UDP and TCP

Computer Networks. Sándor Laki ELTE-Ericsson Communication Networks Laboratory

L12: end to end layer

CSC 401 Data and Computer Communications Networks

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

Question 1 (6 points) Compare circuit-switching and packet-switching networks based on the following criteria:

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

Transmission Control Protocol. ITS 413 Internet Technologies and Applications

Introduction to Networks and the Internet

CS519: Computer Networks. Lecture 5, Part 1: Mar 3, 2004 Transport: UDP/TCP demux and flow control / sequencing

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

Lecture 5. Transport Layer. Transport Layer 1-1

Transport protocols. Transport Layer 3-1

Outline. CS5984 Mobile Computing

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

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

Chapter 24. Transport-Layer Protocols

Networked Systems and Services, Fall 2018 Chapter 3

Transport Protocols Reading: Sections 2.5, 5.1, and 5.2

ECE 650 Systems Programming & Engineering. Spring 2018

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

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

Lecture 7: Flow Control"

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

6.033 Computer System Engineering

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

UNIT IV -- TRANSPORT LAYER

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

Problem 7. Problem 8. Problem 9

Reliable Byte-Stream (TCP)

Applied Networks & Security

CSE 4213: Computer Networks II

10 minutes survey (anonymous)

Computer Communication Networks Midterm Review

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

Transport Layer Protocols TCP

Programming Assignment 3: Transmission Control Protocol

Chapter 3 Transport Layer

Chapter 3- parte B outline

Transmission Control Protocol (TCP)

User Datagram Protocol

Outline Computer Networking. Functionality Split. Transport Protocols

CSE 123: Computer Networks Alex C. Snoeren. HW 1 due NOW!

CSCD 330 Network Programming Winter 2015

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

Computer Networking Introduction

User Datagram Protocol (UDP):

Transport Layer (TCP/UDP)

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

COMP/ELEC 429/556 Introduction to Computer Networks

Computer Networking. Reliable Transport. Reliable Transport. Principles of reliable data transfer. Reliable data transfer. Elements of Procedure

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

Networked Systems and Services, Fall 2017 Reliability with TCP

Internet and Intranet Protocols and Applications

Communications Software. CSE 123b. CSE 123b. Spring Lecture 3: Reliable Communications. Stefan Savage. Some slides couresty David Wetherall

CS 640 Introduction to Computer Networks Spring 2009

Transport Layer PREPARED BY AHMED ABDEL-RAOUF

Transcription:

Reliable Transport I: Concepts and TCP Protocol Brad Karp UCL Computer Science CS 3035/GZ01 29 th October 2013

Part I: Transport Concepts Layering context Transport goals Transport mechanisms 2

Context: Transport Layer Best-effort network layer drops packets delays packets reorders packets corrupts packet contents Many applications want reliable transport all data reach receiver in order they were sent no data corrupted reliable byte stream Need a transport protocol, e.g., Internet s Transmission Control Protocol (TCP) 3

Ports: Identifying Senders and Receivers Host may run multiple, concurrent apps Typical layered multiplexing: transport protocol multiplexed by applications above Transport protocol must identify sending and receiving application instance Application instance ID: port Port owned by one application instance on host Servers often run on well-known ports e.g., HTTP tcp/80, SMTP tcp/25, ssh tcp/22 TCP port number: 16 bits, one each for sender and receiver 4

TCP: Connection-Oriented, Reliable Byte Stream Transport Sending application offers a sequence of bytes: d 0, d 1, d 2, Receiving application sees all bytes arrive in same sequence: d 0, d 1, d 2 not all applications need in-order behavior (e.g., ssh does, but does file transfer, really?) result: reliable byte stream transport Each byte stream: connection, or flow Each connection uniquely identified by: <sender IP, sender port, receiver IP, receiver port> 5

TCP s Many End-to-End Goals Recover from data loss Avoid receipt of duplicated data Preserve data ordering Provide integrity against corruption Avoid sending faster than receiver can accept data Prevent (most) third party hosts from originating connections as other hosts Avoid congesting network 6

Fundamental Problem: Ensuring At-Least-Once Delivery Network drops packets Strategy to ensure delivery: Sender attaches unique number, or nonce, to each data packet sent; keeps copy of sent packet Receiver returns acknowledgement (ACK) to sender for each data packet received, containing nonce Sender sets timer on each transmission if timer expires before ACK returns, retransmit that packet if ACK returns, cancel timer, discard saved copy of that packet Sender limits maximum number of retransmissions How long should retransmit timer be? 7

Fundamental Problem: Estimating RTT Expected time for ACK to return is round-trip time (RTT) end-to-end delay for data to reach receiver and ACK to reach sender propagation delay on links serialization delay at each hop queuing delay at routers Straw man: use fixed timer (e.g., 250 ms) what if the route changes? what if congestion occurs at one or more routers? Too small a value: needless retransmissions Too large a value: needless delay detecting loss 8

Fundamental Problem: Estimating RTT Expected time for ACK to return is round-trip time (RTT) end-to-end delay for data to reach receiver and ACK to reach sender propagation delay on links serialization delay at each hop queuing delay at routers Fixed timer violates end-to-end argument; details of link behavior should be left to link layer! Straw man: use fixed timer (e.g., 250 ms) Hard-coded what if the timers route changes? lead to brittle behavior as technology what if congestion evolves occurs at one or more routers? Too small a value: needless retransmissions Too large a value: needless delay detecting loss 9

Estimating RTT: Exponentially Weighted Moving Average (EWMA) Measurements of RTT readily available note time t when packet sent corresponding ACK returns at time t RTT measurement = m = t -t Single sample too brittle queuing, routing dynamic Adapt over time, using EWMA: measurements: m 0, m 1, m 2, fractional weight for new measurement, α RTT i = ((1-α) x RTT i-1 + α x m i ) 10

Estimating RTT: Exponentially Weighted Moving Average (EWMA) Measurements of RTT readily available note time t when packet sent corresponding ACK returns at time t RTT measurement = m = t -t Single sample too brittle EWMA weights newest samples most queuing, routing dynamic How to choose α? (TCP uses 1/8) Adapt over time, using EWMA: Is mean sufficient to capture RTT behavior over measurements: time? (more later) m 0, m 1, m 2, fractional weight for new measurement, α RTT i = ((1-α) x RTT i-1 + α x m i ) 11

Retransmission and Duplicate Delivery When sender s retransmit timer expires, two indistinguishable cases: data packet dropped en route to receiver, or ACK dropped en route to sender In both cases, sender retransmits In latter case, duplicate data packet reaches receiver! How to prevent receiver from passing duplicates to application? 12

Eliminating Duplicates: Exactly Once Delivery Each packet sent with unique nonce Straw man: receiver remembers nonces previously seen if received packet seen before, drop, but resend ACK to sender How many tombstones must receiver store? Longest gap between duplicates unknown! Unbounded storage Better plan: sequence numbers sender marks each packet with monotonically increasing sequence number (non-random nonce) sender includes greatest ACKed sequence number in its packets receiver remembers only greatest received sequence number, drops received packets with smaller ones still results in one tombstone per connection (partial) fix: expire state at receiver after maximum retry delay 13

Eliminating Duplicates: Exactly Once Delivery Each packet sent with unique nonce Straw man: receiver remembers nonces previously seen Doesn t guarantee delivery! Properties: Longest gap between duplicates unknown! If delivered, Unbounded storage then only once. If undelivered, sender will not think delivered. If ACK not seen, data may have been delivered, but sender will not know. if received packet seen before, drop, but resend ACK to sender How many tombstones must receiver store? Better plan: sequence numbers sender marks each packet with monotonically increasing sequence number (non-random nonce) sender includes greatest ACKed sequence number in its packets receiver remembers only greatest received sequence number, drops received packets with smaller ones still results in one tombstone per connection (partial) fix: expire state at receiver after maximum retry delay 14

End-to-End Integrity Achieved by using transport checksum Protects against things link-layer reliability cannot: router memory corruption, software bugs, &c. Covers data in packet, transport protocol header Also should cover layer-3 source and destination! misdelivered packet should not be inserted into data stream at receiver, nor should be acknowledged receiver drops packets w/failed transport checksum TCP pseudo header covers IP source and destination (more later) 15

Segmentation and Reassembly Application data unbounded in length Link layers typically enforce maximum length Transport layer must at sender, segment data too long for one packet into multiple packets at receiver, reassemble these packets into original data Segmentation: divide into packets; mark each with range of bytes in original data Reassembly: buffer received packets in correct order; track which have arrived; pass to application only when all received 16

Window-Based Flow Control: Motivation Suppose sender sends one packet, awaits ACK, repeats Result: one packet sent per RTT e.g., 70 ms RTT, 1500-byte packets Max throughput: 171 Kbps 17

Fixed Window-Based Flow Control Pipeline transmissions to keep pipe full ; overlap ACKs with data Sender sends window of packets sequentially, without awaiting ACKs Sender retains packets until they are ACKed, tracks which have been ACKed Sender sets retransmit timer for each window; when expires, resends all unacked packets in window 18

Fixed Window-Based Flow Control 1 RTT idle time between grant of new window and arrival of data at receiver Better approach, used by TCP: sliding window, extends on-the-fly as ACKs return; no idle time! Pipeline transmissions to keep pipe full ; overlap ACKs with data Sender sends window of packets sequentially, without awaiting ACKs Sender retains packets until they are ACKed, tracks which have been ACKed Sender sets retransmit timer for each window; when expires, resends all unacked packets in window 19

Choosing Window Size: Bandwidth-Delay Product How large a window is required at sender to keep the pipe full? Network bottleneck: point of slowest rate along path between sender and receiver To keep pipe full window size RTT bottleneck rate Window too small: can t fill pipe Window too large: unnecessary network load/queuing/loss 20

Choosing Window Size: Bandwidth-Delay Product How large a window is required at sender to keep the pipe full? Network bottleneck: point of slowest rate along path between sender and receiver To keep pipe full Goal: window size = RTT bottleneck rate e.g., window to achieve size bottleneck RTT bottleneck rate of 1 Mbps, rate across a 70 ms RTT, need window size: W = (10 6 bps.07 s) = 70 Kbits = 8.75 KB Window too small: can t fill pipe Window too large: unnecessary network load/queuing/loss 21

Closing of Connections Connection life cycle: Open connection Send/receive data Close connection Criteria for connection close: Receiver must know all data received Sender and receiver must agree last packet reached receiver, and connection ended Sender forgets conn state last data ACK end end ACK done Receiver time forgets conn state 22

Closing of Connections Connection life cycle: last data Open connection Send/receive data ACK Close connection end Criteria Risk: new for connection opened; delayed data close: from old connection arrive at receiver during new Receiver one must know all end ACK Fix: data one received endpoint remembers forgets connection for longer Sender than and maximum receiver packet conn delay; done disallows must agree last packet reached receiver, and connection ended Sender Receiver state new connections from other endpoint during this forgets period conn state time 23

Part II: TCP Protocol Packet header format Connection establishment Data transmission Retransmit timeouts RTT estimator AIMD Congestion control Throughput, loss, and RTT equation Connection teardown Protocol state machine 24

TCP Packet Header TCP packet: IP header + TCP header + data TCP header: 20 bytes long Checksum covers header + pseudo header IP header source and destination addresses, protocol Length of TCP segment (TCP header + data) 25

TCP Header Details Connections inherently bidirectional; all TCP headers carry both data and ACK sequence numbers 32-bit sequence numbers are in units of bytes Source and destination ports multiplexing of TCP by applications UNIX: local ports below 1024 reserved (only root may use them) Window: advertisement of number of bytes advertiser willing to accept 26

TCP Connection Establishment: Motivation Goals: Start TCP connection between two hosts Avoid mixing data from old connection in new connection Avoid confusing previous connection attempts with current one Prevent (most) third parties from impersonating (spoofing) one endpoint SYN packets (SYN flag in TCP header set) used to establish connections Use retransmission timer to recover from lost SYNs What protocol meets above goals? 27

TCP Connection Establishment: Non-Solution (I) Use two-way handshake A sends SYN to B B accepts by returning SYN to A A retransmits SYN if not received A and B can ignore duplicate SYNs after connection established What about delayed data packets from old connection? A SYN SYN data, seqno = 1 data, seqno = 512 SYN SYN data, seqno = 1 data, seqno = 512 data, seqno = 1024 B closed time 28

TCP Connection Establishment: Non-Solution (I) Use two-way handshake A sends SYN to B B accepts by returning SYN to A A retransmits SYN if not received A and B can ignore duplicate SYNs after connection established What about delayed data packets from old connection? A SYN SYN data, seqno = 1 data, seqno = 512 SYN SYN data, seqno = 1 data, seqno = 512 data, seqno = 1024 B closed Connections shouldn t start with constant sequence number; risks mixing data between old and new connections time 29

TCP Connection Establishment: Non-Solution (II) Two-way handshake, as before But enclose random initial sequence numbers on SYNs What about delayed SYNs from old connection? A wrongly believes connection successfully established B will drop all of A s data! A SYN, seqno = k data, seqno = k+1 B closed time data ignored! 30

TCP Connection Establishment: Non-Solution (II) Two-way handshake, as before But enclose random initial sequence numbers on SYNs What about delayed Connection SYNs from attempts old should explicitly acknowledge which SYN they are accepting! connection? A wrongly believes connection successfully established B will drop all of A s data! A SYN, seqno = k data, seqno = k+1 B closed time data ignored! 31

TCP Connection Establishment: 3-Way Handshake Set SYN on connection request Each side chooses random initial sequence number Each side explicitly ACKs the sequence number of the SYN it s responding to A SYN, seqno = i SYN, seqno = j, ACK = i+1 seqno = i+1, ACK = j+1 B time 32

Robustness of 3-Way Handshake: Delayed SYN Suppose A s SYN i delayed, arrives at B after connection closed B responds with SYN/ ACK for i+1 A doesn t recognize i +1; responds with reset, RST flag set in TCP header A rejects connection A SYN, seqno = i SYN, seqno = j, ACK = i+1 RST, ACK = j+1 B closed time 33

Robustness of 3-Way Handshake: Delayed SYN/ACK A attempts connection to B Suppose B s SYN k/ ACK p delayed, arrives at A during new connection attempt A rejects SYN k; sends RST to B Connection from A to B succeeds unimpeded A SYN, seqno = i RST, ACK = k seqno = i+1, ACK = j+1 B closed time 34

Robustness of 3-Way Handshake: Source Spoofing Suppose host B trusts host A, based on A s IP address e.g., allows any account creation request from host A Adversary M may not control host A, but may seek to impersonate, or spoof, host A Adversary may not need to receive data from B; only send data (e.g., create an account l33thax0r ) Can M establish a connection to B as A? A M B 35

Robustness of 3-Way Handshake: Source Spoofing Suppose host B trusts host A, based on A s IP address e.g., allows any account creation request from host A Adversary M may not control host A, but may seek to impersonate, or spoof, host A Adversary may not need to receive data from B; only send data (e.g., create an account l33thax0r ) Can M establish a connection to B as A? A M B 36

Robustness of 3-Way Handshake: Source Spoofing Suppose host B trusts host A, based on A s IP address e.g., allows any account creation request from host A Adversary M may not control host A, but may seek to impersonate, or spoof, host A Adversary may not need to receive data from B; only send data (e.g., create an account l33thax0r ) Can M establish a connection to B as A? A SYN, seqno = j, ACK = i+1 M B 37

Robustness of 3-Way Handshake: Source Spoofing Suppose host B trusts host A, based on A s IP address e.g., allows any account creation request from host A Adversary M may not control host A, but may seek to impersonate, or spoof, host A Adversary may not need to receive data from B; only send data (e.g., create an account l33thax0r ) Can M establish a connection to B as A? A SYN, seqno = j, ACK = i+1 M B 38

Robustness of 3-Way Handshake: Source Spoofing Suppose host B trusts host A, based on A s IP address e.g., allows any account creation request from host A Adversary M may not control host A, but may seek to impersonate, or spoof, host A Unless he is on path between A and M B, adversary cannot spoof A to B or vice-versa! Why: Adversary random may not ISNs need to on SYNs receive data from B; only send data (e.g., create an account l33thax0r ) Can M establish a connection to B as A? A SYN, seqno = j, ACK = i+1 B 39

TCP: Data Transmission (I) Each byte numbered sequentially, mod 2 32 Sender buffers data in case retransmission required Receiver buffers data for in-order reassembly Sequence number (seqno) field in TCP header indicates first user payload byte in packet Receiver indicates receive window size explicitly to sender in window field in TCP header corresponds to available buffer space at receiver 40

TCP: Data Transmission (II) Sender s transmit window size: amount of buffer space at sender Sender uses window that is minimum of send and receive window sizes Receiver sends cumulative ACKs ACK number in TCP header names highest contiguous byte number received thus far, +1 one ACK per received packet, OR Delayed ACK also possible: receiver batches ACKs, sends one for every pair of data packets (200 ms max delay) Current window at sender: low byte advances as packets sent high byte advances as receive window updates arrive 41

Outline Packet header format Connection establishment Data transmission Retransmit timeouts RTT estimator AIMD Congestion control Throughput, loss, and RTT equation Connection teardown Protocol state machine 42

TCP: Retransmit Timeouts Sender sets timer for each sent packet when ACK returns, timer canceled if timer expires before ACK returns, packet resent Expected time for ACK to return: RTT TCP estimates round-trip time using EWMA measurements m i from timed packet/ack pairs RTT i = ((1-α) x RTT i-1 + α x m i ) Retransmit timeout: RTO i = β RTT i original TCP: β = 2 Is this accurate enough? Recall dangers of too-short and too-long RTT estimates from previous lecture 43

Mean and Variance: Jacobson s RTT Estimator Above link load of 30% at router, β RTT i will retransmit too early! Response to increasing load: waste bandwidth on duplicate packets Result: congestion collapse! [Jacobson 88]: estimate v i, mean deviation (EWMA of m i RTT i ), stand-in for variance v i = v i-1 (1-γ) + γ m i -RTT i Use RTO i = RTT i + 4v i 44

Mean and Variance: Jacobson s RTT Estimator Above link load of 30% at router, β RTT i will retransmit too early! Response to increasing load: waste bandwidth on duplicate packets Mean Result: and congestion Variance RTT estimator collapse! used by all modern [Jacobson TCPs 88]: estimate v i, mean deviation (EWMA of m i RTT i ), stand-in for variance v i = v i-1 (1-γ) + γ m i -RTT i Use RTO i = RTT i + 4v i 45

Reminder: Reading for Next Lecture Jacboson, V., Congestion Avoidance and Control Read before Thursday s lecture A true classic in networking one of the most influential ideas in the area Paper is available in PDF on calendar page of class web site