Transport Control Protocol (TCP)

Similar documents
Transport Layer and Data Center TCP

Transport Layer Protocols

Computer Networks. Chapter 5 Transport Protocols

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

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

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

Chapter 5. Transport layer protocols

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

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

This sequence diagram was generated with EventStudio System Designer (

TCP in Wireless Mobile Networks

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

Final for ECE374 05/06/13 Solution!!

Computer Networks - CS132/EECS148 - Spring

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

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

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

TCP Performance Management for Dummies

A Survey on Congestion Control Mechanisms for Performance Improvement of TCP

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

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

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

Computer Networks UDP and TCP

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

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

Transport Layer. Chapter 3.4. Think about

Higher Layer Protocols: UDP, TCP, ATM, MPLS

[Prof. Rupesh G Vaishnav] Page 1

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

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

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

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

Visualizations and Correlations in Troubleshooting

How do I get to

Networks: IP and TCP. Internet Protocol

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

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

15-441: Computer Networks Homework 2 Solution

Chapter 6 Congestion Control and Resource Allocation

Transport Protocols and Distributed Applications

Simulation-Based Comparisons of Solutions for TCP Packet Reordering in Wireless Network

Ethernet. Ethernet. Network Devices

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

2 TCP-like Design. Answer

TCP Adaptation for MPI on Long-and-Fat Networks

Congestions and Control Mechanisms n Wired and Wireless Networks

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

TCP over Wireless Networks

Transport layer protocols for ad hoc networks

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

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

Data Networks Summer 2007 Homework #3

Improved Digital Media Delivery with Telestream HyperLaunch

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

Mobile Communications Chapter 9: Mobile Transport Layer

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

Low-rate TCP-targeted Denial of Service Attack Defense

Access Control: Firewalls (1)

COMP 361 Computer Communications Networks. Fall Semester Midterm Examination

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

TCP Westwood for Wireless

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

TCP/IP Over Lossy Links - TCP SACK without Congestion Control

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

High Speed Internet Access Using Satellite-Based DVB Networks

Parallel TCP Data Transfers: A Practical Model and its Application

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

IP address format: Dotted decimal notation:

SELECTIVE-TCP FOR WIRED/WIRELESS NETWORKS

Recent advances in transport protocols

High-Speed TCP Performance Characterization under Various Operating Systems

Advanced Computer Networks Project 2: File Transfer Application

A Study on TCP Performance over Mobile Ad Hoc Networks

2.1 Introduction. 2.2 Voice over IP (VoIP)

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

What is a DoS attack?

IP - The Internet Protocol

TCP for Wireless Networks

Internet Protocols. Background CHAPTER

Note! The problem set consists of two parts: Part I: The problem specifications pages Part II: The answer pages

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

TCP/IP Inside the Data Center and Beyond. Dr. Joseph L White, Juniper Networks

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

Servicesin ns-3. Outline SIMULACIÓN DE PROTOCOLOS DE ENRUTAMIENTO PARA REDES MÓVILES AD-HOC MEDIANTE HERRRAMIENTA DE SIMULACIÓN NS-3

Data Communication & Networks G

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

Digital Audio and Video Data

Communication Systems Transport Layer - Protocols

Architecture and Performance of the Internet

Active Queue Management (AQM) based Internet Congestion Control

Effect of Packet-Size over Network Performance

CHAPTER 1 PRINCIPLES OF NETWORK MONITORING

Computer Networks. Data Link Layer

The Problem with TCP. Overcoming TCP s Drawbacks

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

Overview of TCP/IP. TCP/IP and Internet

TCP PACKET CONTROL FOR WIRELESS NETWORKS

SJBIT, Bangalore, KARNATAKA

TCP in Wireless Networks

Master Course Computer Networks IN2097

Transcription:

Transport Control Protocol (TCP) Richard T. B. Ma School of Computing National University of Singapore CS 3103: Compute Networks and Protocols

Transport services and protocols provide logical communication between app processes running on different hosts application transport network data link physical protocols run in end systems send side: breaks app messages into segments, passes to network layer rcv side: reassembles segments into messages, passes to app layer more than one transport protocol available to apps Internet: TCP and UDP application transport network data link physical

Internet transport-layer protocols reliable, in-order delivery (TCP) congestion control flow control connection setup unreliable, unordered delivery: UDP no-frills extension of best-effort IP services not available: delay guarantees application transport network data link physical network data link physical network data link physical network data link physical network data link physical network data link physical network data link physical network data link physical application transport network data link physical bandwidth guarantees

UDP: User Datagram Protocol [RFC 768] bare bones Internet transport protocol best effort service, UDP segments may be: lost delivered out-of-order connectionless: no handshaking between UDP sender, receiver each UDP segment handled independently of others UDP use: streaming multimedia apps (loss tolerant, rate sensitive) DNS reliable transfer over UDP: add reliability at application layer application-specific error recovery!

UDP: segment header 32 bits source port # dest port # length application data (payload) checksum UDP segment format length, in bytes of UDP segment, including header why is there a UDP? no connection establishment (which can add delay) simple: no connection state at sender, receiver small header size no congestion control: UDP can blast away as fast as desired

TCP segment structure URG: urgent data (generally not used) ACK: ACK # 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 head len acknowledgement number not used U A P R S F checksum receive window application data (variable length) Urg data pointer options (variable length) counting by bytes of data (not segments!) # bytes rcvr willing to accept

TCP seq. numbers, ACKs sequence numbers: byte stream number of the first byte in segment s data outgoing segment from sender source port # dest port # sequence number acknowledgement number rwnd checksum urg pointer window size N acknowledgements: seq # of next byte expected from other side cumulative ACK Q: how receiver handles out-of-order segments A: TCP spec doesn t say, - up to implementor sent ACKed sender sequence number space sent, not-yet ACKed ( in-flight ) incoming segment to sender source port # dest port # sequence number acknowledgement number rwnd A checksum usable but not yet sent urg pointer not usable

TCP seq. numbers, ACKs Host A Host B User types C host ACKs receipt of echoed C Seq=42, ACK=79, data = C Seq=79, ACK=43, data = C Seq=43, ACK=80 host ACKs receipt of C, echoes back C simple telnet scenario

TCP reliable data transfer TCP creates rdt service on top of IP s unreliable service pipelined segments cumulative acks single retransmission timer retransmissions triggered by: timeout events duplicate acks let s initially consider simplified TCP sender: ignore duplicate acks ignore flow control, congestion control

TCP round trip time, timeout Q: how to set TCP timeout value? longer than RTT but RTT varies too short: premature timeout, unnecessary retransmissions too long: slow reaction to segment loss Q: how to estimate RTT? SampleRTT: measured time from segment transmission until ACK receipt ignore retransmissions SampleRTT will vary, want estimated RTT smoother average several recent measurements, not just current SampleRTT

TCP round trip time, timeout EstimatedRTT = (1- α)*estimatedrtt + α*samplertt exponential weighted moving average influence of past sample decreases exponentially fast typical value: α = RTT: 0.125 gaia.cs.umass.edu to fantasia.eurecom.fr 350 RTT: gaia.cs.umass.edu to fantasia.eurecom.fr RTT (milliseconds) RTT (milliseconds) 300 250 200 150 samplertt EstimatedRTT 100 1 8 15 22 29 36 43 50 57 64 71 78 85 92 99 106 time (seconnds) time (seconds) SampleRTT Estimated RTT

TCP round trip time, timeout timeout interval: EstimatedRTT plus safety margin large variation in EstimatedRTT -> larger safety margin estimate SampleRTT deviation from EstimatedRTT: DevRTT = (1-β)*DevRTT + β* SampleRTT-EstimatedRTT (typically, β = 0.25) TimeoutInterval = EstimatedRTT + 4*DevRTT estimated RTT safety margin

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: TimeOutInterval timeout: retransmit segment that caused timeout restart timer ack rcvd: if ack acknowledges previously unacked segments update what is known to be ACKed start timer if there are still unacked segments

TCP: retransmission scenarios Host A Host B Host A Host B Seq=92, 8 bytes of data SendBase=92 Seq=92, 8 bytes of data timeout X ACK=100 timeout Seq=100, 20 bytes of data ACK=100 ACK=120 Seq=92, 8 bytes of data ACK=100 lost ACK scenario SendBase=100 SendBase=120 SendBase=120 Seq=92, 8 bytes of data ACK=120 premature timeout

TCP: retransmission scenarios Host A Host B Seq=92, 8 bytes of data Seq=100, 20 bytes of data timeout X ACK=100 ACK=120 Seq=120, 15 bytes of data cumulative ACK

TCP ACK generation [RFC 1122, RFC 2581] event at receiver 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 TCP receiver action delayed ACK. Wait up to 500ms 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 immediate send ACK, provided that segment starts at lower end of gap

TCP 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-toback if segment is lost, there will likely be many duplicate ACKs. TCP fast retransmit if sender receives 3 ACKs for same data ( triple duplicate ACKs ), resend unacked segment with smallest seq # likely that unacked segment lost, so don t wait for timeout

TCP fast retransmit Host A Host B Seq=92, 8 bytes of data Seq=100, 20 bytes of data X ACK=100 timeout ACK=100 ACK=100 ACK=100 Seq=100, 20 bytes of data fast retransmit after sender receipt of triple duplicate ACK

TCP flow control application may remove data from TCP socket buffers. slower than TCP receiver is delivering (sender is sending) application process TCP socket receiver buffers TCP code application OS flow control receiver controls sender, so sender won t overflow receiver s buffer by transmitting too much, too fast from sender IP code receiver protocol stack

TCP flow control receiver advertises free buffer space by including rwnd in header of receiverto-sender segments RcvBuffer size set via socket options (typical default is 4096 bytes) many operating systems autoadjust RcvBuffer sender limits amount of unacked ( in-flight ) data to receiver s rwnd value guarantees receive buffer will not overflow RcvBuffer rwnd to application process buffered data free buffer space TCP segment payloads receiver-side buffering

TCP congestion control: additive increase multiplicative decrease approach: sender increases transmission rate (window size), probing for usable bandwidth, until loss occurs additive increase: increase cwnd by 1 MSS every RTT until loss detected multiplicative decrease: cut cwnd in half after loss AIMD saw tooth behavior: probing for bandwidth cwnd: TCP sender congestion window size additively increase window size. until loss occurs (then cut window in half) time

TCP Congestion Control: details sender sequence number space cwnd last byte ACKed sent, not-yet ACKed ( in-flight ) last byte sent TCP sending rate: roughly: send cwnd bytes, wait RTT for ACKS, then send more bytes sender limits transmission: rate ~ cwnd RTT bytes/sec LastByteSent- LastByteAcked < cwnd cwnd is dynamic, a function of perceived network congestion

TCP Slow Start when connection begins, increase rate exponentially until first loss event: initially cwnd = 1 MSS double cwnd every RTT done by incrementing cwnd for every ACK received summary: initial rate is slow but ramps up exponentially fast Host A RTT Host B time

TCP: detecting, reacting to loss loss indicated by timeout: cwnd set to 1 MSS; window then grows exponentially (as in slow start) to threshold, then grows linearly loss indicated by 3 duplicate ACKs: TCP RENO dup ACKs indicate network capable of delivering some segments cwnd is cut in half window then grows linearly TCP Tahoe always sets cwnd to 1 (timeout or 3 duplicate acks)

TCP: from slow start to CA Q: when should the exponential increase switch to linear? A: when cwnd gets to 1/2 of its value before timeout. Implementation: variable ssthresh on loss event, ssthresh is set to 1/2 of cwnd just before loss event

TCP throughput avg. TCP throughput as function of window size, RTT? ignore slow start, assume always data to send W: window size (measured in bytes) where loss occurs avg. window size (# in-flight bytes) is ¾ W avg. thruput is 3/4W per RTT W avg TCP thruput = 3 4 W RTT bytes/sec W/2

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 TCP connection 2 bottleneck router capacity R

Why is TCP fair? two competing sessions: additive increase gives slope of 1, as throughout increases multiplicative decrease decreases throughput proportionally R equal bandwidth share loss: decrease window by factor of 2 congestion avoidance: additive increase loss: decrease window by factor of 2 congestion avoidance: additive increase Connection 1 throughput R

Fairness (more) Fairness and UDP multimedia apps often do not use TCP do not want rate throttled by congestion control instead use UDP: send audio/video at constant rate, tolerate packet loss Fairness, parallel TCP connections application can open multiple parallel connections between two hosts web browsers do this e.g., link of rate R with 9 existing connections: new app asks for 1 TCP, gets rate R/10 new app asks for 11 TCPs, gets more than R/2

Connection Management before exchanging data, sender/receiver handshake : agree to establish connection (each knowing the other willing to establish connection) agree on connection parameters application connection state: ESTAB connection variables: seq # client-to-server server-to-client rcvbuffer size at server,client network application connection state: ESTAB connection Variables: seq # client-to-server server-to-client rcvbuffer size at server,client network Socket clientsocket = newsocket("hostname","port number"); Socket connectionsocket = welcomesocket.accept();

Agreeing to establish a connection 2-way handshake: Let s talk ESTAB OK choose x req_conn(x) ESTAB acc_conn(x) ESTAB ESTAB Q: will 2-way handshake always work in network? variable delays retransmitted messages (e.g. req_conn(x)) due to message loss message reordering can t see other side

Agreeing to establish a connection 2-way handshake failure scenarios: 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)

TCP 3-way handshake client state LISTEN SYNSENT ESTAB choose init seq num, x send TCP SYN msg received SYNACK(x) indicates server is live; send ACK for SYNACK; this segment may contain client-to-server data SYNbit=1, Seq=x SYNbit=1, Seq=y ACKbit=1; ACKnum=x+1 ACKbit=1, ACKnum=y+1 choose init seq num, y send TCP SYNACK msg, acking SYN received ACK(y) indicates client is live server state LISTEN SYN RCVD ESTAB

TCP: closing a connection client, server each close their side of connection send TCP segment with FIN bit = 1 respond to received FIN with ACK on receiving FIN, ACK can be combined with own FIN simultaneous FIN exchanges can be handled

TCP: closing a connection client state server state ESTAB ESTAB clientsocket.close() FIN_WAIT_1 FIN_WAIT_2 can no longer send but can receive data wait for server close FINbit=1, seq=x ACKbit=1; ACKnum=x+1 can still send data CLOSE_WAIT TIMED_WAIT timed wait for 2*max segment lifetime FINbit=1, seq=y ACKbit=1; ACKnum=y+1 can no longer send data LAST_ACK CLOSED CLOSED