COMP 431 Internet Services & Protocols

Slides:



Advertisements
Similar presentations
Introduction 1 Lecture 13 Transport Layer (Transmission Control Protocol) slides are modified from J. Kurose & K. Ross University of Nevada – Reno Computer.
Advertisements

2: Transport Layer 31 Transport Layer 3. 2: Transport Layer 32 TCP Flow Control receiver: explicitly informs sender of (dynamically changing) amount of.
Transportation Layer. Very similar to the data link layer. – two hosts connected by a link or two hosts connected by a network differences: – When two.
Transport Layer3-1 TCP. Transport Layer3-2 TCP: Overview RFCs: 793, 1122, 1323, 2018, 2581 r full duplex data: m bi-directional data flow in same connection.
Data Communications and Computer Networks Chapter 3 CS 3830 Lecture 16 Omar Meqdadi Department of Computer Science and Software Engineering University.
1 Chapter 3 Transport Layer. 2 Chapter 3 outline 3.1 Transport-layer services 3.2 Multiplexing and demultiplexing 3.3 Connectionless transport: UDP 3.4.
1 Transport Layer Lecture 9 Imran Ahmed University of Management & Technology.
Transport Layer3-1 Summary of Reliable Data Transfer Checksums help us detect errors ACKs and NAKs help us deal with errors If ACK/NAK has errors sender.
Week 9 TCP9-1 Week 9 TCP 3 outline r 3.5 Connection-oriented transport: TCP m segment structure m reliable data transfer m flow control m connection management.
Transport Layer3-1 Pipelined protocols Pipelining: sender allows multiple, “in-flight”, yet-to- be-acknowledged pkts m range of sequence numbers must be.
Transport Layer1 TCP: Overview RFCs: 793, 1122, 1323, 2018, 2581 r reliable, in-order byte steam: m no “message boundaries” r pipelined: m TCP congestion.
3: Transport Layer3b-1 TCP: Overview RFCs: 793, 1122, 1323, 2018, 2581 r full duplex data: m bi-directional data flow in same connection m MSS: maximum.
Chapter 3 outline 3.1 transport-layer services
Transport Layer 3-1 Transport Layer r To learn about transport layer protocols in the Internet: m TCP: connection-oriented protocol m Reliability protocol.
Transport Layer Transport Layer: TCP. Transport Layer 3-2 TCP: Overview RFCs: 793, 1122, 1323, 2018, 2581 r full duplex data: m bi-directional.
Transport Layer 3-1 Transport Layer r To learn about transport layer protocols in the Internet: m TCP: connection-oriented protocol m Reliability protocol.
1 Announcement r Project 2 out m Much harder than project 1, start early! r Homework 2 due next Tuesday.
Transport Layer3-1 Chapter 3 Transport Layer Computer Networking: A Top Down Approach Featuring the Internet, 3 rd edition. Jim Kurose, Keith Ross Addison-Wesley,
Announcement Project 2 out –Much harder than project 1, start early! Homework 2 due next Tu.
Chapter 3 Transport Layer
The Future r Let’s look at the homework r The next test is coming the 19 th (just before turkey day!) r Monday will finish TCP canned slides r Wednesday.
Transport Layer3-1 Data Communication and Networks Lecture 7 Transport Protocols: TCP October 21, 2004.
Announcement Homework 1 graded Homework 2 out –Due in a week, 1/30 Project 2 problems –Minet can only compile w/ old version of gcc (2.96). –Only tlab-login.
Transport Layer session 1 TELE3118: Network Technologies Week 9: Transport Layer Basics Some slides have been taken from: r Computer Networking:
EEC-484/584 Computer Networks Lecture 13 Wenbing Zhao (Part of the slides are based on Drs. Kurose & Ross ’ s slides for their Computer.
TCP: Overview RFCs: 793, 1122, 1323, 2018, 2581 point-to-point:
Transport Layer 3-1 Chapter 3b outline 3.1 connection-oriented transport: TCP  segment structure  reliable data transfer  flow control  connection.
Transport Layer3-1 TCP sender (simplified) NextSeqNum = InitialSeqNum SendBase = InitialSeqNum loop (forever) { switch(event) event: data received from.
Network LayerII-1 RSC Part III: Transport Layer 3. TCP Redes y Servicios de Comunicaciones Universidad Carlos III de Madrid These slides are, mainly, part.
Transport Layer1 Reliable Transfer Ram Dantu (compiled from various text books)
3: Transport Layer3b-1 TCP: Overview RFCs: 793, 1122, 1323, 2018, 2581 r full duplex data: m bi-directional data flow in same connection m MSS: maximum.
2: Transport Layer 21 Transport Layer 2. 2: Transport Layer 22 TCP: Overview RFCs: 793, 1122, 1323, 2018, 2581 r full duplex data: m bi-directional data.
TCOM 509 – Internet Protocols (TCP/IP) Lecture 04_b Transport Protocols - TCP Instructor: Dr. Li-Chuan Chen Date: 09/22/2003 Based in part upon slides.
1 End-to-End Protocols (UDP, TCP, Connection Management)
Transport Layer3-1 Transport Layer Our lives begin to end, the day we become silent about things that matter.
September 26 th, 2013 CS1652 The slides are adapted from the publisher’s material All material copyright J.F Kurose and K.W. Ross, All Rights.
Transport Layer3-1 Chapter 3 outline r 3.1 Transport-layer services r 3.2 Multiplexing and demultiplexing r 3.3 Connectionless transport: UDP r 3.4 Principles.
Connection-oriented transport: TCP. Transport Layer 3-2 TCP: Overview RFCs: 793,1122,1323, 2018, 2581  full duplex data:  bi-directional data flow in.
Transport Layer3-1 Chapter 3 Transport Layer Computer Networking: A Top Down Approach 5 th edition. Jim Kurose, Keith Ross Addison-Wesley, April 2009.
Transport Layer3-1 Transport Layer If you are going through Hell Keep going.
Transport Layer1 Goals: r understand principles behind transport layer services and protocols: m UDP m TCP Overview: r transport layer services r multiplexing/demultiplexing.
Chapter 3 Transport Layer Computer Networking: A Top Down Approach 6 th edition Jim Kurose, Keith Ross Addison-Wesley March 2012 A note on the use of these.
CSEN 404 Transport Layer II Amr El Mougy Lamia AlBadrawy.
DMET 602: Networks and Media Lab Amr El Mougy Yasmeen EssamAlaa Tarek.
@Yuan Xue A special acknowledge goes to J.F Kurose and K.W. Ross Some of the slides used in this lecture are adapted from their.
09-Transport Layer: TCP Transport Layer.
Chapter 3 Transport Layer
Chapter 3 outline 3.1 Transport-layer services
DMET 602: Networks and Media Lab
Chapter 3 outline 3.1 transport-layer services
CS 1652 Jack Lange University of Pittsburgh
Slides have been adapted from:
TCP: Overview RFCs: 793, 1122, 1323, 2018, 2581 full duplex data:
Introduction to Networks
CS1652 TCP Jack Lange University of Pittsburgh
Review: UDP demultiplexing TCP demultiplexing Multiplexing?
Chapter 3 Transport Layer
Transport Layer Goals: Overview:
Chapter 5 TCP Transmission Control
CSCD 330 Network Programming
CSE 4213: Computer Networks II
CS4470 Computer Networking Protocols
Chapter 3 outline 3.1 Transport-layer services
TCP Review.
TCP 3: Transport Layer.
Transmission Control Protocol (TCP)
Transportation Layer.
TCP: Overview RFCs: 793, 1122, 1323, 2018, 2581 point-to-point:
Chapter 3 Transport Layer
Lecture 5 – Chapter 3 CIS 5617, Spring2019 Anduo Wang
Presentation transcript:

COMP 431 Internet Services & Protocols The Transport Layer Reliable data delivery & flow control in TCP Jasleen Kaur March 31, 2016

Transport Layer Protocols & Services Outline application transport network data link physical Fundamental transport layer services Multiplexing/Demultiplexing Error detection Reliable data delivery Pipelining Flow control Congestion control Internet transport protocols UDP TCP network data link physical ... network data link physical ... Logical end-to-end transport ... ... application transport network data link physical

TCP Overview TCP is… Point-to-point, full-duplex Application writes data Application reads data Point-to-point, full-duplex Bi-directional data flow within a connection Reliable, in-order byte stream No “message boundaries” Connection-oriented Handshaking initializes sender and receiver state before data exchange Pipelined Congestion and flow control determine window size Each endpoint has two buffers: a send and receive buffer socket door TCP send buffer TCP receive buffer segments RFCs: 793, 1122, 1323, 2018, 2581 Congestion controlled Internet would cease to function without this! Flow controlled Sender and receiver have synchronized windows to ensure receiver is not overwhelmed

TCP Segment Structure Header and payload format 32 bits “Urgent data” (“URG”) source port # dest port # Bytes of data sent/received are numbered (not segments) sequence number “ ACK number is valid” acknowledgement number head len not used U A P R S F rcvr window size “Push data now” (“PSH”) checksum ptr urgent data Number of bytes the receiver is willing to accept Options (variable length) Connection establishment and teardown commands (“RST, SYN, FIN”) Application data (variable length) payload ≤ MSS (Maximum Segment Size) Same checksum as in UDP

TCP Sequence Numbers and ACKs Telnet example Byte stream “index” of the first byte in the segment’s payload ACKs: Sequence number of next byte expected from the other side ACKs are cumulative Host A Host B User types ‘C’ Seq=42, ACK=79, data = ‘C’ host ACKs receipt of ‘C’, echoes back ‘C’ time Seq=79, ACK=43, data = ‘C’ host ACKs receipt of echoed ‘C’ How does receiver handle out-of-order segments? TCP spec doesn’t say, it’s up to the implementor Seq=43, ACK=80, data = “”

TCP Reliable Data Transfer (RDT) Retransmissions are triggered by: timeout events duplicate ACKs Initially consider simplified TCP sender: ignore flow control, congestion control (they determine the window size dynamically) TCP creates RDT service on top of IP’s unreliable service Pipelined segments Cumulative ACKs TCP uses single retransmission timer

Reliable Data Transfer in TCP Sender’s state machine receive ACK for segment y update timers advance the window to y retransmit y if third duplicate ACK TCP_send(data) create segment udt_send(segment nextseqnum) start_timer wait for event timeout for segment y udt_send(segment y) start timer TCP retransmits segments if: An expected ACK times out 3 duplicate ACKs for a segment are received

Reliable Data Transfer in TCP Simplified sender Byte sequence Sliding window Sent and ACK’ed unACK’ed Usable but unsent Not usable SendBase NextSeqNum Comment: SendBase – 1 = last cumulatively ACKed byte Example: SendBase-1 = 71; ACK= 73, so the receiver wants 73+ ACK > SendBase, so new data (SeqNum = 72) is ACKed

Reliable Data Transfer in TCP Simplified sender’s state machine Sliding window Sent and ACK’ed Sent and unACK’ed Unsent and eligible Unsent and ineligible Byte sequence 1st Byte Last Byte send base next sequence number create TCP segment with sequence number nextseqnum start timer for segment with nextseqnum pass segment to IP nextseqnum = nextseqnum + length(data) sendbase = initial_sequence number nextseqnum = initial_sequence number loop (forever) { switch(event) event: data received from application above event: timer timeout for segment with sequence number y event: ACK received with value y } retransmit segment with sequence number y (“segment y”) compute new timeout interval for segment y restart timer for segment y

Reliable Data Transfer in TCP Simplified sender’s state machine Sliding window Sent and ACK’ed Sent and unACK’ed Unsent and eligible Unsent and ineligible Byte sequence 1st Byte Last Byte send base next sequence number if (y > sendbase) { /* Cumulative ACK of all data up to y */ cancel timers for segments with sequence numbers ≤ y sendbase := y } else if ( y == sendbase) { /* A duplicate ACK */ increment number of duplicate ACKs received if (number of duplicate ACKS received == 3) { /* Fast retransmit */ resend segment with sequence number sendbase restart timer for segment sendbase sendbase = initial_sequence number nextseqnum = initial_sequence number loop (forever) { switch(event) event: data received from application above event: timer timeout for segment with sequence number y event: ACK received with value y }

Reliable Data Transfer in TCP Retransmission examples Host A Host A Host B Host B Seq=92, 8 data bytes Seq=92, 8 data bytes Seq=100, 20 data bytes ACK=100 Seq=92 timeout timeout X ACK=100 ACK=120 Seq=100 timeout Seq=92, 8 data bytes Seq=92, 8 data bytes time ACK=120 ACK=100 Lost ACK scenario Premature timeout

Reliable Data Transfer in TCP Retransmission examples Host A Seq=92, 8 data bytes ACK=100 Host B X timeout ACK=120 Seq=100, 20 data bytes Host A Host B Seq=92, 8 data bytes Seq=100, 20 data bytes Seq=92 timeout ACK=100 ACK=120 Seq=100 timeout Seq=92, 8 data bytes time ACK=120 Cumulative ACKs potentially avoid retransmissions Premature timeout

Reliable Data Transfer in TCP Setting the ACK timer How large should the ACK timeout value be? Too short: Premature timeouts result in unnecessary retransmissions Too long: Slow reaction to loss results in poor performance because the sender’s windows stops advancing Timer should be longer than the RTT, but how do we estimate RTT? Measure the time from segment transmission until receipt of ACK (“SampleRTT”) Ignore retransmissions Measure only one segment’s RTT at a time SampleRTT will vary, so we compute an average RTT based on several recent RTT samples

Reliable Data Transfer in TCP Estimating round-trip-time EstimatedRTT = (1-x)*EstimatedRTT + x*SampleRTT Timeout = EstimatedRTT + 4*Deviation Deviation = (1-x)*Deviation + x*|SampleRTT-EstimatedRTT| The estimated RTT is an exponential weighted moving average (EWMA) Computes a “smooth” average Influence of a given sample decreases exponentially fast En = x*Sn + x(1-x)Sn-1 + x(1-x)2Sn-2 + … + x(1-x)iSn-i + … Typical value of x is 0.125 Timeout is EstimtedRTT plus “safety margin” Large variation in EstimatedRTT results in a larger safety margin

Example RTT Estimate (smoothed)

Fast Retransmit Time-out period often relatively long: long delay before resending lost packet timer granularity ~ 10-200 ms minimum RTO ~ 200-1200 ms Detect lost segments via duplicate ACKs. Sender often sends many segments back-to-back If a segment is lost, there will likely be many duplicate ACKs (one for each segment that arrives safely) If sender receives 3 ACKs for the same data, it assumes that the segment after ACKed data was lost: fast retransmit: resend segment before timer expires Why wait for 3?

Reliable Data Transfer in TCP ACK generation rules [RFC 1122, RFC 2581] Event TCP Receiver action In-order segment arrival, no gaps, all previous data already ACKed Delayed ACK. Wait 200 ms (up to 500 ms allowed) for next segment. If no segment received, send ACK In-order segment arrival, no gaps, one delayed ACK pending Immediately send single cumulative ACK Out-of-order segment arrival (higher than expected sequence number) — Gap detected Send duplicate ACK, indicating sequence number of next expected byte Arrival of segment that partially or completely fills gap Immediate ACK if segment starts at lower end of gap

TCP Flow Control Window control Receiver’s buffer (RcvBuffer) Byte sequence 1st Byte Last Byte Delivered to application Received, ACKed, not delivered Acceptable but not received Not expected, not received Receiver’s window (RcvWindow) Flow control is the problem of ensuring the receiver is not overwhelmed The receiver can become overwhelmed if the application reads too slow or the sender transmits too fast The receiver’s window represents its remaining buffer capacity The window advances as the application reads received data

TCP Flow Control Window control Receiver’s buffer (RcvBuffer) Byte sequence 1st Byte Last Byte Delivered to application Received, ACKed, not delivered Acceptable but not received Not expected, not received The receiver explicitly informs the sender of the amount of free buffer space in RcvBuffer RcvWindow field in TCP segment The sender keeps the amount of transmitted, unACKed data less than most recently received RcvWindow Receiver’s window source port dest port Application data sequence number ack number receiver window size urgent data checksum flags head len not used TCP options

TCP Flow Control Window control RcvBuffer Byte sequence 1st Byte Last Byte Delivered to application Received, ACKed, not delivered Acceptable but not received Not expected, not received LastByteRead LastByteRcvd RcvWindow The goal is to ensure: LastByteRcvd - LastByteRead ≤ RcvBuffer Sender is sent: RcvWindow = RcvBuffer - (LastByteRcvd-LastByteRead)

TCP Flow Control Window control Sender’s buffer Byte sequence 1st Byte Last Byte Application blocked from sending Sent and ACKed Sent and not ACKed Eligible to be sent Ineligible LastByteACKed LastByteSent RcvWindow The sender ensures: LastByteSent - LastByteACKed ≤ RcvWindow

TCP Connection Management The three-way handshake Server Client “welcoming” socket TCP 3-way handshake client socket bytes connection socket TCP endpoints establish a “connection” before exchanging data segments client: connection initiator Socket clientSocket = new Socket("hostname", "port number") server: contacted by client Socket connectionSocket = welcomeSocket.accept()

TCP Connection Management The three-way handshake Client sends SYN segment to server The SYN specifies the client’s initial sequence number Server receives SYN, replies with SYN+ACK segment ACKs received SYN Allocates buffers Specifies server’s initial sequence number client server Connection request (SYN=1, ACK=0 seq=client_isn) Connection granted (SYN=1, ACK=1 seq=server_isn, ack=client_ins+1) ACK (SYN=0, ACK=1 seq=client_isn+1, ack=server_isn+1) ACK (SYN=0, ACK=1 seq=client_isn+1, ack=server_isn+1, data=“…”) Third segment may be an ACK only or an ACK+data

TCP Connection Management Closing a connection Client sends FIN segment to server Server receives FIN, replies with ACK Server closes connection, sends FIN Client receives FIN, replies with ACK Client enters “timed wait” state Client will ACK any received FIN client server close() FIN ACK close() FIN ACK Timed Wait Connection closed

TCP Connection Management Client/Server lifecycles Wait 30 seconds Closed connect() send SYN Server creates listen socket receive ACK send nothing Closed receive FIN send ACK Timed Wait SYN Sent Last ACK Listen receive FIN send ACK receive SYN+ACK send ACK receive SYN send SYN & ACK close() send FIN FIN Wait 2 Estab- lished Close Wait SYN Received FIN Wait 1 Estab- lished receive FIN send ACK receive ACK send nothing close() send FIN receive ACK send nothing TCP client lifecycle TCP server lifecycle