9. A Closer Look at TCP

Similar documents
Transport Layer Protocols

Computer Networks. Chapter 5 Transport Protocols

Transport Layer and Data Center TCP

CSE 473 Introduction to Computer Networks. Exam 2 Solutions. Your name: 10/31/2013

This sequence diagram was generated with EventStudio System Designer (

Outline. TCP connection setup/data transfer Computer Networking. TCP Reliability. Congestion sources and collapse. Congestion control basics

B-2 Analyzing TCP/IP Networks with Wireshark. Ray Tompkins Founder of Gearbit

ICOM : Computer Networks Chapter 6: The Transport Layer. By Dr Yi Qian Department of Electronic and Computer Engineering Fall 2006 UPRM

Computer Networks - CS132/EECS148 - Spring

Prefix AggregaNon. Company X and Company Y connect to the same ISP, and they are assigned the prefixes:

COMP 3331/9331: Computer Networks and Applications. Lab Exercise 3: TCP and UDP (Solutions)

TCP in Wireless Mobile Networks

Final for ECE374 05/06/13 Solution!!

TCP/IP Optimization for Wide Area Storage Networks. Dr. Joseph L White Juniper Networks

Computer Networks UDP and TCP

COMP 361 Computer Communications Networks. Fall Semester Midterm Examination

First Midterm for ECE374 03/09/12 Solution!!

q Connection establishment (if connection-oriented) q Data transfer q Connection release (if conn-oriented) q Addressing the transport user

Chapter 5. Transport layer protocols

La couche transport dans l'internet (la suite TCP/IP)

TCP Performance Management for Dummies

Names & Addresses. Names & Addresses. Hop-by-Hop Packet Forwarding. Longest-Prefix-Match Forwarding. Longest-Prefix-Match Forwarding

[Prof. Rupesh G Vaishnav] Page 1

Transport Layer. Chapter 3.4. Think about

TCP over Multi-hop Wireless Networks * Overview of Transmission Control Protocol / Internet Protocol (TCP/IP) Internet Protocol (IP)

Exam 1 Review Questions

TCP Flow Control. TCP Receiver Window. Sliding Window. Computer Networks. Lecture 30: Flow Control, Reliable Delivery

Visualizations and Correlations in Troubleshooting

La couche transport dans l'internet (la suite TCP/IP)

15-441: Computer Networks Homework 2 Solution

CSE331: Introduction to Networks and Security. Lecture 9 Fall 2006

Exercises TCP/IP Networking. Solution. With Solutions

Configuring TCP Intercept (Preventing Denial-of-Service Attacks)

Data Networks Summer 2007 Homework #3

First Midterm for ECE374 02/25/15 Solution!!

Data Communications & Networks. Session 6 Main Theme Reliable Data Transfer. Dr. Jean-Claude Franchitti

Midterm Exam CMPSCI 453: Computer Networks Fall 2011 Prof. Jim Kurose

Pig Laboratory. Additional documentation for the laboratory. Exercises and Rules. Tstat Data

Computer Networks Practicum 2015

First Midterm for ECE374 03/24/11 Solution!!

2 TCP-like Design. Answer

Multipath TCP in Practice (Work in Progress) Mark Handley Damon Wischik Costin Raiciu Alan Ford

D. SamKnows Methodology 20 Each deployed Whitebox performs the following tests: Primary measure(s)

Ethernet. Ethernet. Network Devices

TCP Adaptation for MPI on Long-and-Fat Networks

Computer Networks. Data Link Layer

Homework 3 assignment for ECE374 Posted: 03/13/15 Due: 03/27/15

Mobile Communications Chapter 9: Mobile Transport Layer

Chapter 3. TCP/IP Networks. 3.1 Internet Protocol version 4 (IPv4)

Networking Overview. (as usual, thanks to Dave Wagner and Vern Paxson)

How do I get to

High Speed Internet Access Using Satellite-Based DVB Networks

TCP and Wireless Networks Classical Approaches Optimizations TCP for 2.5G/3G Systems. Lehrstuhl für Informatik 4 Kommunikation und verteilte Systeme

Lecture Objectives. Lecture 07 Mobile Networks: TCP in Wireless Networks. Agenda. TCP Flow Control. Flow Control Can Limit Throughput (1)

Advanced Computer Networks Project 2: File Transfer Application

Lecture 15: Congestion Control. CSE 123: Computer Networks Stefan Savage

A Transport Protocol for Multimedia Wireless Sensor Networks

IP - The Internet Protocol

Network Security: Workshop. Dr. Anat Bremler-Barr. Assignment #2 Analyze dump files Solution Taken from

Project 4: (E)DoS Attacks

Low-rate TCP-targeted Denial of Service Attack Defense

Chapter 6 Congestion Control and Resource Allocation

CHAPTER 1 PRINCIPLES OF NETWORK MONITORING

A Survey on Congestion Control Mechanisms for Performance Improvement of TCP

Application Level Congestion Control Enhancements in High BDP Networks. Anupama Sundaresan

IP address format: Dotted decimal notation:

Improving the Performance of TCP Using Window Adjustment Procedure and Bandwidth Estimation

TCP for Wireless Networks

Homework 2 assignment for ECE374 Posted: 02/21/14 Due: 02/28/14

Stop And Wait. ACK received; transmit frame 2 CS 455 3

Applications. Network Application Performance Analysis. Laboratory. Objective. Overview

The present and the future of TCP/IP

Higher Layer Protocols: UDP, TCP, ATM, MPLS

Command Manual - Network Protocol Quidway S3000 Series Ethernet Switches. Table of Contents

8-bit Microcontroller. Application Note. AVR460: Embedded Web Server. Introduction. System Description

Congestions and Control Mechanisms n Wired and Wireless Networks

TCP/IP Networking for Wireless Systems. Integrated Communication Systems Group Ilmenau University of Technology

Host Fingerprinting and Firewalking With hping

Answer: that dprop equals dtrans. seconds. a) d prop. b) d trans

An enhanced TCP mechanism Fast-TCP in IP networks with wireless links

Improving Effective WAN Throughput for Large Data Flows By Peter Sevcik and Rebecca Wetzel November 2008

Access Control: Firewalls (1)

Ina Minei Reuven Cohen. The Technion. Haifa 32000, Israel. Abstract

Overview. Securing TCP/IP. Introduction to TCP/IP (cont d) Introduction to TCP/IP

Sample Network Analysis Report

CS268 Exam Solutions. 1) End-to-End (20 pts)

TFTP TRIVIAL FILE TRANSFER PROTOCOL OVERVIEW OF TFTP, A VERY SIMPLE FILE TRANSFER PROTOCOL FOR SIMPLE AND CONSTRAINED DEVICES

IP Network Layer. Datagram ID FLAG Fragment Offset. IP Datagrams. IP Addresses. IP Addresses. CSCE 515: Computer Network Programming TCP/IP

Communication Systems Transport Layer - Protocols

A Congestion Control Algorithm for Data Center Area Communications

On Inferring TCP Behavior

The Transport Layer and Implica4ons for Network Monitoring. CS 410/510 Spring 2014

1. The subnet must prevent additional packets from entering the congested region until those already present can be processed.

Mike Canney Principal Network Analyst getpackets.com

Lecture 2-ter. 2. A communication example Managing a HTTP v1.0 connection. G.Bianchi, G.Neglia, V.Mancuso

MODBUS MESSAGING ON TCP/IP IMPLEMENTATION GUIDE V1.0b CONTENTS

THE UNIVERSITY OF AUCKLAND

Congestion Control Review Computer Networking. Resource Management Approaches. Traffic and Resource Management. What is congestion control?

Data Link Layer(1) Principal service: Transferring data from the network layer of the source machine to the one of the destination machine

Case Study: F5 Load Balancer and TCP Idle Timer / fastl4 Profile

Transcription:

9. A Closer Look at TCP TCP connection management Reliable data transport in TCP (simplified) How TCP selects a timeout value From Jon Turner, adapted from Kurose and Ross 1

TCP Reliable Data Transfer TCP creates reliable service on top of (unreliable) IP»keeps track of outstanding byte segments through cumulative acks»retransmissions are triggered by timeout events duplicate acks TCP uses single retransmission timer»controls retransmission of oldest unacknowledged segment»when lost segment eventually received, cumulative acks can avoid retransmission of subsequent segments For simplicity, we will initially ignore» duplicate acks (they make retransmissions faster)» flow control, congestion control (separate from reliability) 2 2

Reminder - TCP Segment Format Sequence number is sequence 16 bits 16 bits number of first byte in payload src port Ack number is sequence number of next expected byte Flags include» SYN and FIN bits used to setup and teardown connections» RST used to reset connection» ACK flag indicates valid ack #» URG flag generally not used» PSH flag generally not used Receive window specifies amount of buffer space available at rcvr» used for flow control hdr leng sequence # dst port acknowledgment # leng - flags recv window checksum options application data urgent data 3 3

TCP Connection Establishment open socket and configure as listening socket open Socket and connect connection established accept (and wait) connection socket opened source address, port associated with socket now connected a 3-way handshake also used to negotiate connection parameters 4 4

Why A 3-Way Handshake? choose x retransmit req_conn(x) req_conn(x) acc_conn(x) ESTAB choose x retransmit req_conn(x) req_conn(x) acc_conn(x) ESTAB ESTAB client terminates req_conn(x) connection x completes server forgets x ESTAB retransmit data(x+1) client terminates data(x+1) connection x completes req_conn(x) accept data(x+1) server forgets x ESTAB half open connection! (no client!) data(x+1) ESTAB accept data(x+1) 5 5

Typical Connection Close application closes socket all acks received cannot send, but can still receive can still send application closes socket all acks received timed wait Socket closed_ cannot send socket closed if final ACK is lost, server re-sends FIN, client re-sends ACK 6 6

TCP Server Life Cycle receive ACK send nothing closed server application opens listening socket last ack LISTEN app closes socket, wait for pending acks, send FIN close wait SYN received receive SYN, send SYN & ACK receive FIN send ACK established receive ACK send nothing 7 7

TCP Client Life Cycle wait 30 seconds closed client application initiates TCP connection time wait SYN sent receive FIN send ACK receives SYN & ACK send ACK FIN wait 2 established receive ACK send nothing FIN wait 1 client application initiates close wait for pending acks, send FIN 8 8

TCP Sequence Numbers and ACKs Seq. # s:» byte stream number of first byte in segment s data ACKs:» seq # of next byte expected from other side» cumulative ACK Out-of-order segments» out-of-order segments are usually buffered at receiver» TCP RFC doesn t actually specify Host A User types C host ACKs receipt of echoed C simple telnet scenario Host B host ACKs receipt of C, echoes back C 9 9

Exercises Socket clientsocket = newsocket("hostname", "port number"); Socket connectionsocket = welcomesocket.accept(); 1. Draw a spacetime diagram showing the complete lifecycle of a TCP connection. Label the vertical line at the client with the client states. Label the vertical line at the server with the server states. 10 10

Exercises Socket clientsocket = newsocket("hostname", "port number"); SYN sent Socket connectionsocket = welcomesocket.accept(); SYN rcvd create new client socket 1. Draw a spacetime diagram showing the complete lifecycle of a TCP connection. Label the vertical line at the client with the client states. Label the vertical line at the server with the server states. Established clientsocket.close() FIN_WAIT_1 FIN_WAIT_2 TIMED_WAIT 2*max seg. lifetime ~ 30sec CLOSED... Established CLOSE_WAIT LAST_ACK CLOSED 11 11

Sample TCP (HTTP) Exchange 12 12

Sample TCP Flow 13 13

TCP Sender Events: data rcvd from app: add bytes to send buffer» send segment(s), if allowed» seq # is byte-stream number of first data byte in segment Start timer if not already running» timer controls retransmission of oldest un-acked segment Expiration interval TimeOutInterval» determined dynamically based on RTT (more on this soon) timeout: Retransmit segment that caused timeout Restart timer Ack rcvd: If ack matches previously un-acked segment(s)» discard bytes that have been acked» re-start timer if there are still un-acked segments 14 14

Simplified TCP Sender sendbase nextseqnum nextseqnum = initialseqnum sendbase = initialseqnum loop (forever) { switch(event) event: data received from application above un-acked bytes add received bytes to send buffer (as many, as will fit) if allowed, create/send segment(s) using bytes in send buffer if timer currently not running, start timer pass segment to IP nextseqnum = nextseqnum + length(segment) event: timeout retransmit not-yet-acknowledged segment with smallest sequence number re-start timer event: ACK received, with ACK field value of y if (y > sendbase) { sendbase = y if there are currently not-yet-acknowledged segments, start timer } } /* end of loop forever */ 15 15

TCP Retransmission Scenarios lost ACK scenario premature timeout Host A Host B Host A Host B time eout loss 2 timeout Seq=9 sendbase = 100 time sendbase = 100 sendbase = 120 sendbase = 120 timeout Seq=92 time 16 16

TCP Retransmission Scenarios Cumulative ACK scenario Host A Host B timeout t loss sendbase = 120 time 17 17

TCP ACK Generation [RFC 1122, RFC 2581] Event at Receiver TCP Receiver action Arrival of in-order segment with expected seq #. All data up to expected seq # already ACKed Arrival of in-order segment with expected seq #. One other segment has ACK pending Arrival of out-of-order segment higher-than-expect seq. #. Gap detected Arrival of segment that partially or completely fills gap Delayed ACK. Wait up to 500 ms for next segment. If no next segment, send ACK Immediately send single cumulative ACK, ACKing both in-order segments Immediately send duplicate ACK, indicating seq. # of next expected byte Immediately send ACK, provided that segment starts at lower end of gap 18 18

Exercises 1. Draw a space-time diagram showing two hosts communicating with TCP. Suppose A sends 8 packets to B, each containing 8 bytes of data, and that the fourth and fifth packets are lost. Show these packets and the acks sent by B. Show the sequence numbers in the ACKs. Suppose that when A retransmits the fourth packet, it is also lost, but the fifth packet gets through. Show these packets and resulting ACKs. Finally, show what happens when the fourth packet is retransmitted the second time and successfully delivered to B. At what point in this scenario does the application at B receive the eighth packet? 19 19

Exercises 1. Draw a space-time diagram showing two hosts communicating with TCP. Suppose A sends 8 packets to B, each containing 8 bytes of data, and that the fourth and fifth packets are lost. Show these packets and the acks sent by B. Show the sequence numbers in the ACKs. Suppose that when A retransmits the fourth packet, it is also lost, but the fifth packet gets through. Show these packets and resulting ACKs. Finally, show what happens when the fourth packet is retransmitted the second time and successfully delivered to B. At what point in this scenario does the application at B receive the eighth packet? DATA(seq=x) DATA(seq=x+8) DATA(seq=x+16) DATA(seq=x+24) DATA(seq=x+32) DATA(seq=x+40) DATA(seq=x+48) DATA(seq=x+56) timeout DATA(seq=x+24) timeout DATA(seq=x+24) timeout DATA(seq=x+32) x x x ACK(ACKnum=x+16) ACK(ACKnum=x+24) ACK(ACKnum=x+24) ACK(ACKnum=x+24) ACK(ACKnum=x+32) ACK(ACKnum=x+64) 20 20

TCP Round Trip Time and Timeout How should TCP select its timeout value?»must be longer than RTT, but not too much longer if too long, retransmissions needlessly delayed if too short, may retransmit when not necessary» but different connections have different RTTs and RTT varies during a connection as well How to estimate RTT?» SampleRTT: measured time from segment transmission until ACK receipt» ignore retransmissions» SampleRTT will fluctuate, want estimated RTT smoother average several recent measurements, not just current SampleRTT EstimatedRTT = (1-)*EstimatedRTT + *SampleRTT where is typically 0.125; this method called exponential weighted moving average 21 21

22 Exponential Averaging n n n w w w w w w n w w 1 0 1 0 1 0 0 1 1 ) (1 and 0,, ) (1 w w w w w w w w 2 1 0 2 2 1 0 2 1 0 1 0 1 ) (1 ) (1 ) (1 ) (1 ) ( 22 n i i i n n w w 0 ) (1

Computing the Timeout Timeout should be EstimatedRTT plus safety margin» if large variation in EstimatedRTT need larger safety margin First estimate of how much SampleRTT deviates from EstimatedRTT DevRTT = (1-)*DevRTT + * SampleRTT-EstimatedRTT typically, = 0.25 Then set timeout interval TimeoutInterval = EstimatedRTT + 4*DevRTT 23 23

Example RTT estimation: 350 300 RTT (millisecond ds) 250 200 150 100 1 8 15 22 29 36 43 50 57 64 71 78 85 92 99 106 time (seconnds) SampleRTT Estimated RTT 24 24

Exercises 1. Consider a TCP connection linking a residential client A to a remote server that is 2000 km away from A. Suppose the DSL link connecting A to its ISP has a download rate of 2 Mb/s and can store packets with a total length of 64 KB. Ignoring all other considerations, what is the minimum delay on the path from the server to A? If the queue is oscillating rapidly between being empty and full, what would you expect the estimated RTT to be? What about the DevRTT value? Compute the resulting timeout interval. Is this value safe? Is it too conservative? 25 25

Exercises 1. Consider a TCP connection linking a residential client A to a remote server that is 2000 km away from A. Suppose the DSL link connecting A to its ISP has a download rate of 2 Mb/s and can store packets with a total length of 64 KB. Ignoring all other considerations, what is the minimum delay on the path from the server to A? If the queue is oscillating rapidly between being empty and full, what would you expect the estimated RTT to be? What about the DevRTT value? Compute the resulting timeout interval. Is this value safe? Is it too conservative? Minimum roundtrip delay is propagation delay of about 20ms. If the queue alternate between empty and full, the RTT will toggle between 20ms and 20ms+64,000*8/2x10 6 =276ms. Under those assumptions, EstimatedRTT alternates between 139.5ms and 156.5ms with DevRTT converging to about 120ms. This produces a time out value that will alternate between 617.3ms and 634.4ms. This value is clearly safe, but much too conservative in that it exceeds even the maximum possible RTT of 276ms 26 26

Fast Retransmit Time-out period often relatively long» long delay before resending lost packet Detect lost segments via duplicate ACKs» sender often sends many segments back-to-back» if segment is lost, there will likely l be many duplicate ACKs If sender receives 3 duplicate ACKs for the same data, it concludes that segment after ACKed data was lost:» fast retransmit: re-send segment before timer expires Why wait for 3 duplicate ACKs?» since IP may deliver segments out-of-order, a duplicate ACK does not necessarily mean a lost segment» but, with 3 duplicate ACKs, a lost segment is likely 27 27

Fast Retransmit Illustration Host A Host B timeout Acknowledges all packets received up to 6 th segment 28 28

Fast Retransmit Algorithm event: ACK received, with ACK field value of y if (y > sendbase) { sendbase = y if (there are currently not-yet-acknowledged segments) re-start timer } else { increment count of dup ACKs received for y if (count of dup ACKs received for y == 3) resend segment with sequence number y } a duplicate ACK for already ACKed segment fast retransmit 29 29