November 26th, 2018 Prof. Ion Stoica

Slides:



Advertisements
Similar presentations
TCP Sliding Windows, Flow Control, and Congestion Control Lecture material taken from Computer Networks A Systems Approach, Fourth Ed.,Peterson and Davie,
Advertisements

CSCI-1680 Transport Layer II Based partly on lecture notes by David Mazières, Phil Levis, John Jannotti Rodrigo Fonseca.
Advanced Computer Networks : TCP Sliding Windows1 TCP Sliding Windows, Flow Control, and Congestion Control Lecture material taken from “Computer Networks.
Introduction 1 Lecture 13 Transport Layer (Transmission Control Protocol) slides are modified from J. Kurose & K. Ross University of Nevada – Reno Computer.
Fundamentals of Computer Networks ECE 478/578 Lecture #21: TCP Window Mechanism Instructor: Loukas Lazos Dept of Electrical and Computer Engineering University.
Transport Layer 3-1 outline r TCP m segment structure m reliable data transfer m flow control m congestion control.
Transport Layer 3-1 Outline r TCP m Congestion control m Flow control.
ACN: TCP Sliding Windows1 TCP Sliding Windows, with Flow Control, and Congestion Control Based on Peterson and Davie Textbook.
Advanced Computer Networks : TCP Sliding Windows1 TCP Sliding Windows, Flow Control, and Congestion Control Lecture material taken from “Computer Networks.
CSE 461: Sliding Windows & ARQ. Next Topic  We begin on the Transport layer  Focus  How do we send information reliably?  Topics  The Transport layer.
1 Reliable Data Transfer. 2 r Problem: Reliability  Want an abstraction of a reliable link even though packets can be corrupted or get lost r Solution:
TCP: flow and congestion control. Flow Control Flow Control is a technique for speed-matching of transmitter and receiver. Flow control ensures that a.
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.
TCP : Transmission Control Protocol Computer Network System Sirak Kaewjamnong.
26-TCP Dr. John P. Abraham Professor UTPA. TCP  Transmission control protocol, another transport layer protocol.  Reliable delivery  Tcp must compensate.
© Janice Regan, CMPT 128, CMPT 371 Data Communications and Networking Flow Control 0.
1 Introduction to Computer Networks University of ilam Dr. Mozafar Bag-Mohammadi Transport Layer.
1 Transport Layer Lecture 10 Imran Ahmed University of Management & Technology.
Consistency David E. Culler CS162 – Operating Systems and Systems Programming Lecture 35 Nov 19, 2014 Read:
CS162 Operating Systems and Systems Programming Lecture 15 Reliability, Transport Protocols March 16, 2011 Ion Stoica
CS162 Operating Systems and Systems Programming Lecture 17 TCP, Flow Control, Reliability April 3, 2013 Anthony D. Joseph
TCP Flow Control – an illustration of distributed system thinking David E. Culler CS162 – Operating Systems and Systems Programming
CSE/EE 461 Sliding Windows and ARQ. 2 Last Time We finished up the Network layer –Internetworks (IP) –Routing (DV/RIP, LS/OSPF) It was all about routing:
1 End-to-End Protocols UDP TCP –Connection Establishment/Termination –Sliding Window Revisited –Flow Control –Congestion Control –Adaptive Timeout.
Transmission Control Protocol (TCP) TCP Flow Control and Congestion Control CS 60008: Internet Architecture and Protocols Department of CSE, IIT Kharagpur.
CS162 Operating Systems and Systems Programming Lecture 11 Reliability, Transport Protocols October 5, 2011 Anthony D. Joseph and Ion Stoica
Advanced Computer Networks
3. END-TO-END PROTOCOLS (PART 2) Rocky K. C. Chang Department of Computing The Hong Kong Polytechnic University 22 March
09-Transport Layer: TCP Transport Layer.
Data Link Layer Flow Control.
CS450 – Introduction to Networking Lecture 19 – Congestion Control (2)
Introduction to Networks
Transport Control Protocol
COMP 431 Internet Services & Protocols
Introduction of Transport Protocols
Chapter 5 TCP Sliding Window
Transport Layer Unit 5.
Precept 2: TCP Congestion Control Review
TCP - Part II Relates to Lab 5. This is an extended module that covers TCP flow control, congestion control, and error control in TCP.
Overview Jaringan Komputer (2)
Anthony D. Joseph and Ion Stoica
Anthony D. Joseph and Ion Stoica
Process-to-Process Delivery:
E2E Arguments & Project Suggestions (Lecture 4, cs262a)
TCP Overview Connection-oriented Byte-stream Full duplex
April 2, 2014 Anthony D. Joseph CS162 Operating Systems and Systems Programming Lecture 17 TCP, Flow Control, Reliability.
Anthony D. Joseph and John Canny
Transport Control Protocol
Dr. John P. Abraham Professor UTPA
October 31, 2012 Ion Stoica CS162 Operating Systems and Systems Programming Lecture 18 TCP’s Flow Control, Transactions.
5. End-to-end protocols (part 2)
TCP Sliding Windows, Flow Control, and Congestion Control
CS4470 Computer Networking Protocols
Dr. John P. Abraham Professor UTPA
Transmission Control Protocol (TCP) Part II Neil Tang 11/21/2008
State Transition Diagram
CS4470 Computer Networking Protocols
Advanced Computer Networks
The University of Adelaide, School of Computer Science
EE 122: Lecture 10 (Congestion Control)
The Transport Layer Reliability
Transport Protocols: TCP Segments, Flow control and Connection Setup
Anthony D. Joseph and Ion Stoica
Chapter 5 TCP Sliding Window
Transport Protocols: TCP Segments, Flow control and Connection Setup
Process-to-Process Delivery: UDP, TCP
TCP flow and congestion control
TCP Sliding Windows, Flow Control, and Congestion Control
Transport Layer 9/22/2019.
TCP Sliding Windows, Flow Control, and Congestion Control
Presentation transcript:

November 26th, 2018 Prof. Ion Stoica http://cs162.eecs.Berkeley.edu CS162 Operating Systems and Systems Programming Lecture 22 E2E Argument, TCP Flow Control November 26th, 2018 Prof. Ion Stoica http://cs162.eecs.Berkeley.edu

Goals of Today’s Lecture End-to-end principle (argument) TCP flow control

Basic Observation Some types of network functionality can only be correctly implemented end-to-end Reliability, security, etc Because of this, end hosts: Can satisfy the requirement without network’s help Will/must do so, since can’t rely on network’s help Therefore don’t go out of your way to implement them in the network

Example: Reliable File Transfer Host A Host B Appl. Appl. OK OS OS Solution 1: make each step reliable, and then concatenate them Solution 2: end-to-end check and try again if necessary

Discussion Solution 1 is incomplete Solution 2 is complete What happens if memory is corrupted? Receiver has to do the check anyway! Solution 2 is complete Full functionality can be entirely implemented at application layer with no need for reliability from lower layers Is there any need to implement reliability at lower layers? Well, it could be more efficient

End-to-End Principle Implementing this functionality in the network: Doesn’t reduce host implementation complexity Does increase network complexity Probably imposes delay and overhead on all applications, even if they don’t need functionality However, implementing in network can enhance performance in some cases E.g., very lossy link

Conservative Interpretation of E2E Don’t implement a function at the lower levels of the system unless it can be completely implemented at this level Unless you can relieve the burden from hosts, don’t bother

Moderate Interpretation Think twice before implementing functionality in the network If hosts can implement functionality correctly, implement it in a lower layer only as a performance enhancement But do so only if it does not impose burden on applications that do not require that functionality This is the interpretation we are using

Break

Administrivia Midterm 3 coming up on Wen 11/28 5:00-6:30PM All topics: Focus will be on Lectures 18 – 23 and associated readings, and Projects 3 But expect 20-30% questions from materials from Lectures 1-17 Closed book 2 pages hand-written notes both sides

Goals of Today’s Lecture End-to-end principle (argument) TCP flow control

Flow Control Recall: Flow control ensures a fast sender does not overwhelm a slow receiver Example: Producer-consumer with bounded buffer (Lecture 5) A buffer between producer and consumer Producer puts items into buffer as long as buffer not full Consumer consumes items from buffer buffer Produ-cer Con-sumer

TCP Flow Control TCP: sliding window protocol at byte (not packet) level Go-back-N: TCP Tahoe, Reno, New Reno Selective Repeat (SR): TCP Sack Receiver tells sender how many more bytes it can receive without overflowing its buffer (i.e., AdvertisedWindow) The ack(nowledgement) contains sequence number N of next byte the receiver expects, i.e., receiver has received all bytes in sequence up to and including N-1

TCP Flow Control OS (TCP/IP) OS (TCP/IP) Sending Process Receiving Process OS (TCP/IP) OS (TCP/IP) TCP/IP implemented by OS (Kernel) Cannot do context switching on sending/receiving every packet At 1Gbps, it takes 12 usec to send an 1500 bytes, and 0.8usec to send an 100 byte packet Need buffers to match … sending app with sending TCP receiving TCP with receiving app

TCP Flow Control Three pairs of producer-consumer’s Sending Process Receiving Process TCP layer 1 3 TCP layer OS IP layer IP layer 2 Three pairs of producer-consumer’s sending process  sending TCP Sending TCP  receiving TCP receiving TCP  receiving process

TCP Flow Control Example assumptions: Sending Process Receiving Process TCP layer TCP layer 300 bytes OS IP layer IP layer Example assumptions: Maximum IP packet size = 100 bytes Size of the receiving buffer (MaxRcvBuf) = 300 bytes Recall, ack indicates the next expected byte in-sequence, not the last received byte Use circular buffers

Circular Buffer Assume A buffer of size N A stream of bytes, where bytes have increasing sequence numbers Think of stream as an unbounded array of bytes and of sequence number as indexes in this array Buffer stores at most N consecutive bytes from the stream Byte k stored at position (k mod N) + 1 in the buffer buffered data sequence # 27 28 29 30 31 32 33 34 35 36 H E L L O W O R L (35 mod 10) + 1 = 6 (28 mod 10) + 1 = 9 Circular buffer (N = 10) L O R W E E 1 2 3 4 5 6 7 8 9 10 start end

TCP Flow Control LastByteWritten: last byte written by sending process Receiving Process LastByteWritten(0) LastByteRead(0) LastByteAcked(0) LastByteSent(0) LastByteRcvd(0) NextByteExpected(1) LastByteWritten: last byte written by sending process LastByteSent: last byte sent by sender to receiver LastByteAcked: last ack received by sender from receiver LastByteRcvd: last byte received by receiver from sender NextByteExpected: last in-sequence byte expected by receiver LastByteRead: last byte read by the receiving process

TCP Flow Control LastByteAcked Sending Process LastByteWritten LastByteSent Receiving Process LastByteRead MaxSendBuffer MaxRcvBuffer NextByteExpected LastByteRcvd AdvertisedWindow: number of bytes TCP receiver can receive SenderWindow: number of bytes TCP sender can send AdvertisedWindow = MaxRcvBuffer – (LastByteRcvd – LastByteRead) SenderWindow = AdvertisedWindow – (LastByteSent – LastByteAcked)

TCP Flow Control Still true if receiver missed data…. LastByteAcked Sending Process LastByteWritten LastByteSent Receiving Process LastByteRead MaxSendBuffer MaxRcvBuffer NextByteExpected LastByteRcvd Still true if receiver missed data…. WriteWindow: number of bytes sending process can write AdvertisedWindow = MaxRcvBuffer – (LastByteRcvd – LastByteRead) WriteWindow = MaxSendBuffer – (LastByteWritten – LastByteAcked)

TCP Flow Control Sending app sends 350 bytes Recall: Sending Process Receiving Process LastByteWritten(350) LastByteRead(0) 1, 350 LastByteAcked(0) LastByteSent(0) LastByteRcvd(0) NextByteExpected(1) Sending app sends 350 bytes Recall: We assume IP only accepts packets no larger than 100 bytes MaxRcvBuf = 300 bytes, so initial Advertised Window = 300 byets

TCP Flow Control Sending Process Receiving Process LastByteWritten(350) LastByteRead(0) 1, 350 1, 100 101, 350 1, 100 LastByteSent(100) NextByteExpected(101) LastByteRcvd(100) LastByteAcked(0) Data[1,100] {[1,100]} Sender sends first packet (i.e., first 100 bytes) and receiver gets the packet time

Receiver sends ack for 1st packet TCP Flow Control Sending Process Receiving Process LastByteWritten(350) LastByteRead(0) 1, 100 1, 350 101, 350 1, 100 LastByteSent(100) NextByteExpected(101) LastByteRcvd(100) LastByteAcked(0) Data[1,100] {[1,100]} Ack=101, AdvWin = 200 Receiver sends ack for 1st packet AdvWin = MaxRcvBuffer – (LastByteRcvd – LastByteRead) = 300 – (100 – 0) = 200

TCP Flow Control Sending Process Receiving Process LastByteWritten(350) LastByteRead(0) 1, 100 101, 200 101, 350 201, 350 1, 100 101, 200 LastByteSent(200) NextByteExpected(201) LastByteRcvd(200) LastByteAcked(0) Data[1,100] {[1,100]} Data[101,200] {[1,200]} Ack=101, AdvWin = 200 Sender sends 2nd packet (i.e., next 100 bytes) and receiver gets the packet

TCP Flow Control Sending Process Receiving Process LastByteWritten(350) LastByteRead(0) 1, 200 101, 350 201, 350 1, 200 LastByteSent(200) NextByteExpected(201) LastByteRcvd(200) LastByteAcked(0) Data[1,100] {[1,100]} Data[101,200] {[1,200]} Ack=101, AdvWin = 200 Sender sends 2nd packet (i.e., next 100 bytes) and receiver gets the packet

Receiving TCP delivers first 100 bytes to recienving process TCP Flow Control Sending Process Receiving Process 1, 100 LastByteWritten(350) LastByteRead(100) 1, 200 101, 350 201, 350 101, 200 LastByteSent(200) NextByteExpected(201) LastByteRcvd(200) LastByteAcked(0) Data[1,100] {[1,100]} Data[101,200] {[1,200]} Ack=101, AdvWin = 200 Receiving TCP delivers first 100 bytes to recienving process

Receiver sends ack for 2nd packet TCP Flow Control Sending Process Receiving Process LastByteWritten(350) LastByteRead(100) 1, 200 101, 350 201, 350 101, 200 LastByteSent(200) NextByteExpected(201) LastByteRcvd(200) LastByteAcked(0) Data[1,100] {[1,100]} Data[101,200] {[1,200]} Ack=101, AdvWin = 200 Ack=201, AdvWin = 200 Receiver sends ack for 2nd packet AdvWin = MaxRcvBuffer – (LastByteRcvd – LastByteRead) = 300 – (200 – 100) = 200

Sender sends 3rd packet (i.e., next 100 bytes) and the packet is lost TCP Flow Control Sending Process Receiving Process LastByteWritten(350) LastByteRead(100) 1, 200 101, 350 201, 300 201, 350 301, 350 101, 200 LastByteSent(300) NextByteExpected(201) LastByteRcvd(200) LastByteAcked(0) Data[1,100] {[1,100]} Data[101,200] {[1,200]} {[1,300]} Data[201,300] Sender sends 3rd packet (i.e., next 100 bytes) and the packet is lost

Sender stops sending as window full TCP Flow Control Sending Process Receiving Process LastByteWritten(350) LastByteRead(100) 1,300 101, 350 201, 350 301, 350 101, 200 LastByteSent(300) NextByteExpected(201) LastByteRcvd(200) LastByteAcked(0) Data[1,100] {[1,100]} Data[101,200] {[1,200]} {[1,300]} Data[201,300] Sender stops sending as window full SndWin = AdvWin – (LastByteSent – LastByteAcked) = 300 – (300 – 0) = 0

TCP Flow Control Sender gets ack for 1st packet AdWin = 200 {[1,100]} Sending Process Receiving Process LastByteWritten(350) LastByteRead(100) 1,300 101, 350 201, 350 301, 350 101, 200 LastByteSent(300) NextByteExpected(201) LastByteRcvd(200) LastByteAcked(0) Data[1,100] {[1,100]} Data[101,200] {[1,200]} Ack=101, AdvWin = 200 {[1,300]} Data[201,300] Sender gets ack for 1st packet AdWin = 200

TCP Flow Control Sending Process Receiving Process LastByteWritten(350) LastByteRead(100) 101,300 101, 350 201, 350 301, 350 101, 200 LastByteSent(300) NextByteExpected(201) LastByteRcvd(200) LastByteAcked(100) Data[1,100] {[1,100]} Data[101,200] {[1,200]} Ack=101, AdvWin = 200 {101, 300} {[1,300]} Data[201,300] Ack for 1st packet (ack indicates next byte expected by receiver) Receiver no longer needs first 100 bytes

Sender still cannot send as window full TCP Flow Control Sending Process Receiving Process LastByteWritten(350) LastByteRead(100) 101,300 101, 350 201, 350 301, 350 101, 200 LastByteSent(300) NextByteExpected(201) LastByteRcvd(200) LastByteAcked(100) Data[1,100] {[1,100]} Data[101,200] {[1,200]} Ack=101, AdvWin = 200 {101, 300} {[1,300]} Data[201,300] Sender still cannot send as window full SndWin = AdvWin – (LastByteSent – LastByteAcked) = 200 – (300 – 100) = 0

TCP Flow Control Receiver gets ack for 2nd packet AdvWin = 200 bytes Sending Process Receiving Process LastByteWritten(350) LastByteRead(100) 101,300 101, 350 201, 350 301, 350 101, 200 LastByteSent(300) NextByteExpected(201) LastByteRcvd(200) LastByteAcked(100) Data[1,100] {[1,100]} Data[101,200] {[1,200]} {[101,200]} {101, 300} {[1,300]} Data[201,300] Ack=201, AdvWin = 200 {201, 300} Receiver gets ack for 2nd packet AdvWin = 200 bytes

TCP Flow Control SndWin = AdvWin – (LasByteSent – LastByteAcked) = 100 Sending Process Receiving Process LastByteWritten(350) LastByteRead(100) 201,300 101, 350 201, 350 301, 350 101, 200 LastByteSent(300) NextByteExpected(201) LastByteRcvd(200) LastByteAcked(200) Data[1,100] {[1,100]} Data[101,200] {[1,200]} {[101,200]} {101, 300} {[1,300]} Data[201,300] Ack=201, AdvWin = 200 {201, 300} Sender can now send new data! SndWin = AdvWin – (LasByteSent – LastByteAcked) = 100

TCP Flow Control {[1,100]} Data[1,100] {[1,200]} Data[101,200] Sending Process Receiving Process LastByteWritten(350) LastByteRead(100) 201,300 101, 350 201, 350 301,350 301, 350 101, 200 301, 350 LastByteSent(350) NextByteExpected(201) LastByteRcvd(350) LastByteAcked(200) Data[1,100] {[1,100]} Data[101,200] {[1,200]} {[101,200]} {101, 300} {[1,300]} Data[201,300] Data[301,350] {[201,350]} {[101,200],[301,350]}

TCP Flow Control {[1,100]} Data[1,100] {[1,200]} Data[101,200] Sending Process Receiving Process LastByteWritten(350) LastByteRead(100) 101, 350 201,300 201, 350 301,350 301, 350 101, 200 301, 350 LastByteSent(350) NextByteExpected(201) LastByteRcvd(350) LastByteAcked(200) Data[1,100] {[1,100]} Data[101,200] {[1,200]} {[101,200]} {101, 300} {[1,300]} Data[201,300] Data[301,350] {[201,350]} {[101,200],[301,350]} Ack=201, AdvWin = 50 {201, 350}

TCP Flow Control Ack still specifies 201 (first byte out of sequence) Sending Process Receiving Process LastByteWritten(350) LastByteRead(100) 201,300 101, 350 201, 350 301,350 301, 350 101, 200 301, 350 LastByteSent(350) NextByteExpected(201) LastByteRcvd(350) LastByteAcked(200) Data[301,350] {[201,350]} {[101,200],[301,350]} Ack=201, AdvWin = 50 {201, 350} Ack still specifies 201 (first byte out of sequence) AdvWin = 50, so can sender re-send 3rd packet?

TCP Flow Control Ack still specifies 201 (first byte out of sequence) Sending Process Receiving Process LastByteWritten(350) LastByteRead(100) 201,300 101, 350 201, 350 301,350 301, 350 101, 200 301, 350 LastByteSent(350) NextByteExpected(201) LastByteRcvd(350) LastByteAcked(200) Data[301,350] {[201,350]} {[101,200],[301,350]} Ack=201, AdvWin = 50 {201, 350} Ack still specifies 201 (first byte out of sequence) AdvWin = 50, so can sender re-send 3rd packet?

TCP Flow Control Sending Process Receiving Process LastByteWritten(350) LastByteRead(100) 101, 350 201,300 201, 350 301,350 301, 350 101, 200 201, 300 301, 350 LastByteSent(350) NextByteExpected(351) LastByteAcked(200) LastByteRcvd(350) Data[301,350] {[201,350]} {[101,200],[301,350]} Ack=201, AdvWin = 50 {201, 350} Data[201,300] {[201,350]} {[101,350]} Yes! Sender can re-send 2nd packet since it’s in existing window – won’t cause receiver window to grow

TCP Flow Control Sending Process Receiving Process LastByteWritten(350) LastByteRead(100) 201,300 101, 350 201, 350 301,350 301, 350 101, 350 LastByteSent(350) NextByteExpected(351) LastByteAcked(200) LastByteRcvd(350) Data[301,350] {[201,350]} {[101,200],[301,350]} Ack=201, AdvWin = 50 {201, 350} Data[201,300] {[201,350]} {[101,350]} Yes! Sender can re-send 2nd packet since it’s in existing window – won’t cause receiver window to grow

TCP Flow Control Sender gets 3rd packet and sends Ack for 351 Sending Process Receiving Process LastByteWritten(350) LastByteRead(100) 201,300 301,350 101, 350 LastByteSent(350) NextByteExpected(351) LastByteAcked(200) LastByteRcvd(350) Data[301,350] {[201,350]} {[101,200],[301,350]} Ack=201, AdvWin = 50 {201, 350} Data[201,300] {[201,350]} {[101,350]} Ack=351, AdvWin = 50 {} Sender gets 3rd packet and sends Ack for 351 AdvWin = 50

Sender DONE with sending all bytes! TCP Flow Control Sending Process Receiving Process LastByteWritten(350) LastByteRead(100) 101, 350 LastByteSent(350) NextByteExpected(351) LastByteAcked(350) LastByteRcvd(350) Data[301,350] {[201,350]} {[101,200],[301,350]} Ack=201, AdvWin = 50 {201, 350} Data[201,300] {[201,350]} {[101,350]} Ack=351, AdvWin = 50 {} Sender DONE with sending all bytes!

Discussion Why not have a huge buffer at the receiver (memory is cheap!)? Sending window (SndWnd) also depends on network congestion Congestion control: ensure that a fast receiver doesn’t overwhelm a router in the network (discussed in detail in cs168) In practice there is another set of buffers in the protocol stack, at the link layer (i.e., Network Interface Card)

Summary E2E argument encourages us to keep IP simple Flow control If higher layer can implement functionality correctly, implement it in a lower layer only if it improves the performance significantly for application that need that functionality, and it does not impose burden on applications that do not require that functionality Flow control Avoid the sender over-flowing the receiver buffer Receiver only reads in-sequence data, and acks with the next sequence number is waiting for Sender never sends more data than the receiver can hold in its buffer

Thanks, and good luck!