Transport Layer: Outline

Similar documents
Transport Layer: outline

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

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

CSE 4213: Computer Networks II

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

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

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

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

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

Chapter 3 Transport Layer

10 minutes survey (anonymous)

Computer Networking Introduction

Chapter 3 Transport Layer

Chapter 3 Transport Layer

Chapter 3 Transport Layer

CS 4390 Computer Networks. Pointers to Corresponding Section of Textbook

Chapter III: Transport Layer

Lecture 8. TCP/IP Transport Layer (2)

RSC Part III: Transport Layer 3. TCP

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

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

CSC 401 Data and Computer Communications Networks

CC451 Computer Networks

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

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

Chapter 3- parte B outline

CSC 4900 Computer Networks: TCP

CSCI Topics: Internet Programming Fall 2008

CSCE 463/612 Networks and Distributed Processing Spring 2017

Chapter 3 Transport Layer

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

Chapter 3 Transport Layer

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

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

CNT 6885 Network Review on Transport Layer

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

Chapter 3 Transport Layer

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

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

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

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

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

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

Chapter 3 Transport Layer

Master Course Computer Networks IN2097

TCP Basics : Computer Networking. Overview. What s Different From Link Layers? Introduction to TCP. TCP reliability Assigned reading

Fall 2012: FCM 708 Bridge Foundation I

The Transport Layer: TCP & Reliable Data Transfer

Transmission Control Protocol

TCP : Fundamentals of Computer Networks Bill Nace

Lecture 5. Transport Layer. Transport Layer 1-1

CSCD 330 Network Programming

Chapter 6 Transport Layer

Chapter III: Transport Layer

Functionality Split Computer Networking. Transport Protocols. Overview. Multiplexing & Demultiplexing

Foundations of Telematics

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

Computer Communication Networks Midterm Review

Lecture 12: Transport Layer TCP again

Distributed Systems. 5. Transport Protocols

Distributed Systems. 5. Transport Protocols. Werner Nutt

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

CSC 8560 Computer Networks: TCP

Chapter 3 Transport Layer

Chapter 3 Transport Layer

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

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

Transport Protocols and TCP

Master Course Computer Networks IN2097

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

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

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

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

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

Routers. Session 12 INST 346 Technologies, Infrastructure and Architecture

Computer Networks & Security 2016/2017

Flow and Congestion Control (Hosts)

Chapter 3: Transport Layer

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

Computer Networking: A Top Down Approach

Computer Communication Networks Midterm Review

Internet Protocols Fall Outline

Chapter 3 Transport Layer

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

Lecture 11. Transport Layer (cont d) Transport Layer 1

CSC358 Week 5. Adapted from slides by J.F. Kurose and K. W. Ross. All material copyright J.F Kurose and K.W. Ross, All Rights Reserved

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

Transmission Control Protocol (TCP)

Chapter 3 Transport Layer

NWEN 243. Networked Applications. Layer 4 TCP and UDP

Internet and Intranet Protocols and Applications

CS457 Transport Protocols. CS 457 Fall 2014

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

rdt3.0: channels with errors and loss

Chapter 3 Transport Layer

05 Transmission Control Protocol (TCP)

Lecture 11: Transport Layer Reliable Data Transfer and TCP

TCP Adaptive Retransmission Algorithm - Original TCP. TCP Adaptive Retransmission Algorithm Jacobson

Transcription:

Transport Layer: Outline Transport-layer services Multiplexing and demultiplexing Connectionless transport: UDP Principles of reliable data transfer Connection-oriented transport: TCP Segment structure Reliable data transfer Flow control Connection management Principles of congestion control TCP congestion control 1

TCP: Overview RFCs: 793, 1122, 1323, 2018, 2581 Point-to-point: One sender, one receiver Reliable, in-order byte stream: No message boundaries Pipelined: TCP congestion and flow control set window size Send & receive buffers socket door application writes data TCP send buffer segment application reads data TCP receive buffer Full duplex data: Bi-directional data flow in same connection MSS: maximum segment size Connection-oriented: Handshaking (exchange of control msgs) init s sender, receiver state before data exchange Flow controlled: socket door Sender will not overwhelm receiver 2

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 # head len sequence number acknowledgement number not used U A P R S F checksum rcvr window size ptr urgent data Options (variable length) application data (variable length) counting by bytes of data (not segments!) # bytes rcvr willing to accept 3

Transport layer: Outline Transport-layer services Multiplexing and demultiplexing Connectionless transport: UDP Principles of reliable data transfer Connection-oriented transport: TCP Segment structure Reliable data transfer Flow control Connection management Principles of congestion control TCP congestion control 4

TCP reliable data transfer TCP creates rdt service on top of IP s unreliable service Pipelined segments Cumulative acks TCP uses single retransmission timer Retransmissions are triggered by: Timeout events Duplicate acks Initially consider simplified TCP sender: Ignore duplicate acks Ignore flow control, congestion control One way dataflow 5

TCP seq. # s 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 Q: How receiver handles out-of-order segments A: TCP spec doesn t say, - up to implementor User types C 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 simple telnet scenario host ACKs receipt of C, echoes back C time 6

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 acknowledges previously unacked segments Update what is known to be acked Start timer if there are outstanding segments 7

TCP: reliable data transfer event: data received from application above create, send segment Simplified sender, assuming One way data transfer No flow, congestion control wait for event event: timer timeout retransmit segment event: ACK received, with ACK # y ACK processing 8

TCP sender (simplified) 00 sendbase = initial_sequence number 01 nextseqnum = initial_sequence number 02 03 loop (forever) { 04 switch(event) 05 event: data received from application above 06 create TCP segment with sequence number nextseqnum 07 if (timer currently not running) start timer 08 pass segment to IP 09 nextseqnum = nextseqnum + length(data) 10 event: timer timeout 11 retransmit not-yet-acknowledged segment with 12 smallest sequence number 13 restart timer 14 event: ACK received, with ACK field value of y 15 if (y > sendbase) { /* cumulative ACK of all data up to y */ 17 sendbase = y 18 if (currently not-yet-acknowledged segments) { 19 restart timer 20 } 21 } 22 } /* end of loop forever */ 9

TCP retransmission scenarios Host A Host B Host A Host B 10 Seq=92, 8 bytes data Seq=92, 8 bytes data Seq=100, 20 bytes data ACK=120 ACK=100 Seq=92 timeout ACK=100 X timeout loss Seq=92, 8 bytes data Seq=92, 8 bytes data ACK=120 Seq=92 timeout ACK=100 SendBase = 100 time lost ACK scenario Sendbase = 100 SendBase = 120 SendBase = 120 time premature timeout

TCP retransmission scenarios (2.) Host A Host B 11 Seq=92, 8 bytes data ACK=100 X Seq=100, 20 bytes data timeout loss ACK=120 SendBase = 120 time Cumulative ACK scenario

TCP round trip time and timeout Q: How to set TCP timeout value? Longer than RTT Note: RTT will vary 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, cumulatively ACKed segments SampleRTT will vary, want estimated RTT smoother Use several recent measurements, not just current SampleRTT 12

TCP round trip time and timeout EstimatedRTT = (1 - α)* EstimatedRTT + α * SampleRTT Exponential weighted moving average Influence of given sample decreases exponentially fast Typical value of α: 0.125 Key observation: At high loads round trip variance is high 13

Example RTT estimation RTT: gaia.cs.umass.edu to fantasia.eurecom.fr 350 300 RTT (milliseconds) 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 14

TCP round trip time and timeout Setting the timeout EstimtedRTT plus safety margin Large variation in EstimatedRTT -> 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 15

Retransmission ambiguity A B 16 Original transmission Sample RTT RTO A B Original transmission X retransmission retransmission Sample RTT ACK ACK RTO

Karn s RTT estimator Accounts for retransmission ambiguity If a segment has been retransmitted: Don t count RTT sample on ACKs for this segment Keep backed off time-out for next packet Reuse RTT estimate only after one successful transmission 17

Timestamp extension Used to improve timeout mechanism by more accurate measurement of RTT When sending a packet, insert current timestamp into option 4 bytes for seconds, 4 bytes for microseconds Receiver echoes timestamp in ACK Actually will echo whatever is in timestamp Removes retransmission ambiguity Can get RTT sample on any packet 18

Timer granularity Many TCP implementations set RTO in multiples of 200, 500, 1000ms Why? Avoid spurious timeouts RTTs can vary quickly due to cross traffic Make timers interrupts efficient 19

TCP ACK generation [RFC 1122, RFC 2581] Event at Receiver In-order segment with expected seq #. All data up to expected seq # already ACKed In-order segment with expected seq #. One other segment has ACK pending Out-of-order segment higher-than-expect seq. #. Gap detected 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 20

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 be many duplicate ACKs. If sender receives 3 ACKs for the same data, it supposes that segment after ACKed data was lost: Fast retransmit: resend segment before timer expires 21

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) 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 } Duplicate ACK for already ACKed segment Fast retransmit 22

Transport layer: outline Transport-layer services Multiplexing and demultiplexing Connectionless transport: UDP Principles of reliable data transfer Connection-oriented transport: TCP Segment structure Reliable data transfer Flow control Connection management Principles of congestion control TCP congestion control 23

TCP flow control Receive side of TCP connection has a receive buffer: flow control sender won t overflow receiver s buffer by transmitting too much, too fast App process may be slow at reading from buffer Speed-matching service: match the send rate to the receiving app s drain rate 24

TCP flow control: How it works (Suppose TCP receiver discards out-of-order segments) Spare room in buffer = RcvWindow = RcvBuffer-[LastByteRcvd - LastByteRead] Rcvr advertises spare room by including value of RcvWindow in segments Sender limits unacked data to RcvWindow Guarantees receive buffer doesn t overflow 25

TCP flow control: How it works (2.) TCP is a sliding window protocol For window size n, can send up to n bytes without receiving an acknowledgement When the data is acknowledged then the window slides forward Each packet advertises a window size Indicates number of bytes the receiver has space for Original TCP always sent entire window Congestion control now limits this 26

Window flow control: Sender side window Sent and acked Sent but not acked Not yet sent Next to be sent 27

Window flow control: Receiver side Receive buffer Acked but not delivered to user Not yet acked window 28

TCP persist What happens if window is 0? Receiver updates window when application reads data What if this update is lost? TCP persist state Sender periodically sends 1 byte packets Receiver responds with ACK even if it can t store the packet 29

Transport layer: Outline Transport-layer services Multiplexing and demultiplexing Connectionless transport: UDP Principles of reliable data transfer Connection-oriented transport: TCP Segment structure Reliable data transfer Flow control Connection management Principles of congestion control TCP congestion control 30

TCP connection management Recall: TCP sender, receiver establish connection before exchanging data segments Initialize TCP variables: seq. #s buffers, flow control info (e.g. RcvWindow) client: connection initiator Socket clientsocket = new Socket("hostname","port number"); server: contacted by client Socket connectionsocket = welcomesocket.accept(); 31

Connection establishment Use 3-way handshake A B SYN + Seq A SYN+ACK-A + Seq B ACK-B 32

Sequence number selection Why not simply chose 0? Must avoid overlap with earlier incarnation 33

TCP connection: Three way handshake Step 1: Client end system sends TCP SYN control segment to server Specifies initial seq # Specifies initial window # Step 2: Server end system receives SYN, replies with SYNACK control segment ACKs received SYN Allocates buffers Specifies server-> receiver initial seq. # Specifies initial window # Step 3: Client system receives SYNACK, replies with ACK segment which may contain data 34

TCP connection management (2.) Closing a connection: client closes socket: clientsocket.close(); Step 1: Client end system sends TCP FIN control segment to server close client FIN ACK FIN server close Step 2: Server receives FIN, replies with ACK. Closes connection, sends FIN. 35

TCP connection management (3.) Step 3: Client receives FIN, replies with ACK. client server Enters timed wait - will respond with ACK to received FINs closing FIN Step 4: Server, receives ACK. Connection closed. ACK FIN closing Note: With small modification, can handle simultaneous FINs. timed wait ACK closed closed 36

Tear-down packet exchange Sender FIN FIN-ACK Receiver Data write Data ack FIN FIN-ACK 37

TCP connection management (cont.) TCP client lifecycle 38

TCP connection management (cont.) TCP server lifecycle 39

Detecting half-open connections TCP A TCP B 1. (CRASH) 2. CLOSED 3. SYN-SENT <SEQ=400><CTL=SYN> 4. (!!) <SEQ=300><ACK=100><CTL=ACK> 5. SYN-SENT <SEQ=100><CTL=RST> 6. SYN-SENT 7. SYN-SENT <SEQ=400><CTL=SYN> (send 300, receive 100) ESTABLISHED (??) ESTABLISHED (Abort!!) CLOSED 40

Observed TCP problems Too many small packets Silly window syndrome Nagel s algorithm Initial sequence number selection Amount of state maintained 41

Silly window syndrome Problem: (Clark, 1982) If receiver advertises small increases in the receive window then the sender may waste time sending lots of small packets Solution Receiver must not advertise small window increases Increase window by min(mss,recvbuffer/2) 42

Nagel s algorithm Small packet problem: Don t want to send a 41 byte packet for each keystroke How long to wait for more data? Solution: Allow only one outstanding small (not full sized) segment that has not yet been acknowledged 43

Why is selecting ISN important? Suppose machine X selects ISN based on predictable sequence Fred has.rhosts to allow login to X from Y Evil Ed attacks Disables host Y denial of service attack Make a bunch of connections to host X Determine ISN pattern and guess next ISN Fake pkt1: [<src Y><dst X>, guessed ISN] Fake pkt2: desired command 44

Time Wait issues Web servers not clients close connection first Established Fin-Waits Time-Wait Closed Why would this be a problem? Time-Wait state lasts for 2 * MSL MSL is should be 120 seconds (is often 60s) Servers often have order of magnitude more connections in Time-Wait 45

Transport layer: Outline Transport-layer services Multiplexing and demultiplexing Connectionless transport: UDP Principles of reliable data transfer Connection-oriented transport: TCP Segment structure Reliable data transfer Flow control Connection management Principles of congestion control TCP congestion control 46