Page 1. CS194-3/CS16x Introduction to Systems. Lecture 22. TCP congestion control, Two-Phase Commit. 3-way handshake. ½ close.

Similar documents
CS162 Operating Systems and Systems Programming Lecture 23

CS162 Operating Systems and Systems Programming Lecture 23. Networking III

CS162 Operating Systems and Systems Programming Lecture 23. Network Communication Abstractions / Distributed Programming

Computer Network Fundamentals Spring Week 10 Congestion Control Andreas Terzis

CS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring Lecture 21: Network Protocols (and 2 Phase Commit)

CS162 Operating Systems and Systems Programming Lecture 23. Network Communication Abstractions / Distributed Programming

CS162 Operating Systems and Systems Programming Lecture 24. Network Communication Abstractions / Distributed Programming

CS162 Operating Systems and Systems Programming Lecture 22. Networking II

CS3600 SYSTEMS AND NETWORKS

CS4700/CS5700 Fundamentals of Computer Networks

Page 1. CS194-3/CS16x Introduction to Systems. Lecture 21. Networking II. Review: Networking Definitions

Goals of Today s Lecture! Congestion Control! Course So Far.! Congestion Control Overview! It s Not Just The Sender & Receiver! Congestion is Natural!

Page 1. Goals for Today" Discussion" Example: Reliable File Transfer" CS162 Operating Systems and Systems Programming Lecture 11

Communication Networks

Network Protocols. Sarah Diesburg Operating Systems CS 3430

COMP/ELEC 429/556 Introduction to Computer Networks

CS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring Lecture 22: Remote Procedure Call (RPC)

Page 1. Goals for Today" Atomic Read-Modify-Write instructions" Examples of Read-Modify-Write "

COMP/ELEC 429/556 Introduction to Computer Networks

Page 1. Goals for Today. Atomic Read-Modify-Write instructions. Examples of Read-Modify-Write

Lecture 21: Congestion Control" CSE 123: Computer Networks Alex C. Snoeren

Page 1. CS194-3/CS16x Introduction to Systems. Lecture 8. Database concurrency control, Serializability, conflict serializability, 2PL and strict 2PL

Overview. TCP & router queuing Computer Networking. TCP details. Workloads. TCP Performance. TCP Performance. Lecture 10 TCP & Routers

CS Networks and Distributed Systems. Lecture 10: Congestion Control

6.033 Computer System Engineering

CSE 123A Computer Networks

Lecture 14: Congestion Control"

Page 1. Goals for Today" Placing Network Functionality" Basic Observation" CS162 Operating Systems and Systems Programming Lecture 15

Outline Computer Networking. TCP slow start. TCP modeling. TCP details AIMD. Congestion Avoidance. Lecture 18 TCP Performance Peter Steenkiste

TCP so far Computer Networking Outline. How Was TCP Able to Evolve

Page 1. Review: Internet Protocol Stack. Transport Layer Services EEC173B/ECS152C. Review: TCP. Transport Layer: Connectionless Service

CS4700/CS5700 Fundamentals of Computer Networks

Reliable Transport II: TCP and Congestion Control

Page 1. Review: Internet Protocol Stack. Transport Layer Services. Design Issue EEC173B/ECS152C. Review: TCP

Topics. TCP sliding window protocol TCP PUSH flag TCP slow start Bulk data throughput

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

Page 1. Recap: ATM Bank Server" Recap: Challenge of Threads"

Bandwidth Allocation & TCP

Lecture 20 Overview. Last Lecture. This Lecture. Next Lecture. Transport Control Protocol (1) Transport Control Protocol (2) Source: chapters 23, 24

6.1 Internet Transport Layer Architecture 6.2 UDP (User Datagram Protocol) 6.3 TCP (Transmission Control Protocol) 6. Transport Layer 6-1

Page 1. Goals for Today" Important Aspects of Memory Multiplexing" Virtualizing Resources" CS162 Operating Systems and Systems Programming Lecture 9

TCP. CSU CS557, Spring 2018 Instructor: Lorenzo De Carli (Slides by Christos Papadopoulos, remixed by Lorenzo De Carli)

CS321: Computer Networks Congestion Control in TCP

EE 122: Transport Protocols. Kevin Lai October 16, 2002

Recap. TCP connection setup/teardown Sliding window, flow control Retransmission timeouts Fairness, max-min fairness AIMD achieves max-min fairness

ETSF05/ETSF10 Internet Protocols Transport Layer Protocols

Overview. TCP congestion control Computer Networking. TCP modern loss recovery. TCP modeling. TCP Congestion Control AIMD

Congestion Control. Brighten Godfrey CS 538 January Based in part on slides by Ion Stoica

Transport Protocols and TCP

6.033 Spring 2015 Lecture #11: Transport Layer Congestion Control Hari Balakrishnan Scribed by Qian Long

Outline. Internet. Router. Network Model. Internet Protocol (IP) Design Principles

Transport Layer Protocols TCP

TCP Congestion Control : Computer Networking. Introduction to TCP. Key Things You Should Know Already. Congestion Control RED

Announcements Computer Networking. Outline. Transport Protocols. Transport introduction. Error recovery & flow control. Mid-semester grades

9/17/12! Ion Stoica CS162 UCB Fall 2012!

User Datagram Protocol

Congestion Control End Hosts. CSE 561 Lecture 7, Spring David Wetherall. How fast should the sender transmit data?

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

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

Midterm Review. EECS 489 Computer Networks Z. Morley Mao Monday Feb 19, 2007

Transmission Control Protocol. ITS 413 Internet Technologies and Applications

Information Network 1 TCP 1/2. Youki Kadobayashi NAIST

Transport Layer Chapter 6

Lecture 5: Flow Control. CSE 123: Computer Networks Alex C. Snoeren

Network Protocols. Transmission Control Protocol (TCP) TDC375 Autumn 2009/10 John Kristoff DePaul University 1

Question. Reliable Transport: The Prequel. Don t parse my words too carefully. Don t be intimidated. Decisions and Their Principles.

Congestion Collapse in the 1980s

CSCD 330 Network Programming Winter 2015

Reliable Transport II: TCP and Congestion Control

TCP Congestion Control

EE 122: Transport Protocols: UDP and TCP

Announcements Computer Networking. What was hard. Midterm. Lecture 16 Transport Protocols. Avg: 62 Med: 67 STD: 13.

Multiple unconnected networks

Flow & Congestion Control

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

10/7/13! Anthony D. Joseph and John Canny CS162 UCB Fall 2013! " (0xE0)" " " " (0x70)" " (0x50)"

Good Ideas So Far Computer Networking. Outline. Sequence Numbers (reminder) TCP flow control. Congestion sources and collapse

8. TCP Congestion Control

ECE 650 Systems Programming & Engineering. Spring 2018

CS 5520/ECE 5590NA: Network Architecture I Spring Lecture 13: UDP and TCP

CS268: Beyond TCP Congestion Control

Lecture 15: TCP over wireless networks. Mythili Vutukuru CS 653 Spring 2014 March 13, Thursday

Distributed Computing. CS439: Principles of Computer Systems November 20, 2017

Transport Protocols Reading: Sections 2.5, 5.1, and 5.2. Goals for Todayʼs Lecture. Role of Transport Layer

9th Slide Set Computer Networks

CS457 Transport Protocols. CS 457 Fall 2014

CS162 Operating Systems and Systems Programming Lecture 21. Networking. Page 1

Lecture 15 Networking Fundamentals. Today s Plan

Computer Networking Introduction

Transport Layer (TCP/UDP)

Lecture 3: The Transport Layer: UDP and TCP

CMSC 417. Computer Networks Prof. Ashok K Agrawala Ashok Agrawala. October 11, 2018

MPTCP: Design and Deployment. Day 11

ECE 435 Network Engineering Lecture 10

CS 268: Lecture 7 (Beyond TCP Congestion Control)

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

CS519: Computer Networks. Lecture 5, Part 4: Mar 29, 2004 Transport: TCP congestion control

Transport Layer Marcos Vieira

Networks and distributed computing

Transport Layer (Congestion Control)

Transcription:

CS194-3/CS16x Introduction to Systems Lecture 22 TCP congestion control, Two-Phase Commit November 14, 2007 Prof. Anthony D. Joseph http://www.cs.berkeley.edu/~adj/cs16x Review: Networking Definitions Layering: building complex services from simpler ones Datagram: independent, self-contained message whose arrival, arrival time, and content are not guaranteed Performance metrics Overhead: CPU time to put packet on wire Throughput: Maximum number of bytes per second Latency: time until first bit of packet arrives at receiver Arbitrary Sized messages: Fragment into multiple packets; reassemble at destination Ordered messages: Use sequence numbers and reorder at destination Reliable messages: Use Acknowledgements Want a window larger than 1 in order to increase throughput TCP: Reliable byte stream between two processes on different machines over Internet (read, write, flush) Lec 22.2 Goals for Today TCP congestion avoidance and flow control TCP sockets Distributed applications Two-phase commit Open connect. TCP Timing Diagram SYN k SYN n; ACK k+1 DATA k+1; ACK n+1 3-way handshake Transfer ACK k+n+1 data exchange Note: Some slides and/or pictures in the following are adapted from slides 2005 Silberschatz, Galvin, and Gagne. Slides courtesy of Kubiatowicz, AJ Shankar, George Necula, Alex Aiken, Eric Brewer, Ras Bodik, Ion Stoica, Doug Tygar, and David Wagner. Lec 22.3 Close connect. FIN ACK FIN FIN FIN ACK 4 ½ close ½ close Lec 22.4 Page 1

Sliding Window window = set of adjacent sequence numbers Size of set is window size or n Can fully utilize a link, provided the window size is large enough Throughput is ~ (n/rtt) Stop & Wait is like n = 1 Sender has to buffer all unacknowledged packets, because they may require retransmission Receiver may be able to accept out-of-order packets, but only up to its buffer limits Lec 22.5 A1 A2 A3 How Fast to Send? 100 Mbps Sending Hosts Buffer in Router Receiving Hosts Send too slow: link is not fully utilized Wastes time Send too fast: link is fully utilized but... Queue builds up in router buffer (delay) Overflow buffers in routers Overflow buffers in receiving host (ignore) B1 B2 B3 Lec 22.6 Three Congestion Control Problems Reality Adjusting to bottleneck bandwidth Without any a priori knowledge Could be gigabit link, could be a modem Adjusting to variations in bandwidth Assuming you have rough idea of bandwidth Sharing bandwidth between flows Two Issues:» Adjust total sending rate to match bandwidth» Allocation of bandwidth between flows Lec 22.7 Congestion control is a resource allocation problem involving many flows, many links, and complicated global dynamics Lec 22.8 Page 2

Delay Throughput Knee point after which Throughput increases very slow Delay increases fast Cliff point after which What s Really Happening? View from a Single Flow Throughput starts to decrease very fast to zero (congestion collapse) Delay approaches infinity knee cliff Load Load packet loss congestion collapse Lec 22.9 General Approaches Send without care Many packet drops Not as stupid as it seems UDP Dynamic Adjustment Probe network to test level of congestion Speed up when no congestion Slow down when congestion Suboptimal, messy dynamics, simple to implement For TCP, dynamic adjustment is the most appropriate Due to pricing structure, traffic characteristics, and good citizenship ( TCP-Friendly ) Lec 22.10 Administrivia TCP Congestion Control Project 3 design due Monday 11/19 Midterm 2 Exam Avg 64.8 Median 63 Std Dev 9.5 Lec 22.11 TCP connection has window Controls number of unacknowledged packets Limits how much data can be in transit Implemented as # of bytes Described as # packets in this lecture Sending rate: ~Window/RTT Vary window size to control sending rate Two basic components: Detecting congestion Rate adjustment algorithm» Three sub-problems within adjustment problem Finding fixed bandwidth Adjusting to bandwidth variations Sharing bandwidth Lec 22.12 Page 3

Two Basic Components Detecting congestion Packet dropping is best sign of congestion» Delay-based methods are hard and risky How do you detect packet drops? No ACKs» TCP uses ACKs to signal receipt of data» No ACK after certain time interval: time-out Rate adjustment basic structure: Upon receipt of ACK (of new data): increase rate Upon detection of loss: decrease rate Problem #1: Single Flow, Fixed BW Want to get a first-order estimate of the available bandwidth Assume bandwidth is fixed Ignore presence of other flows Want to start slow, but rapidly increase rate until packet drop occurs ( slow-start ) Adjustment: cwnd initially set to 1 cwnd++ upon receipt of ACK Lec 22.13 Lec 22.14 Slow-Start cwnd increases exponentially: cwnd doubles every time a full cwnd of packets has been sent Each ACK releases two packets Slow-start is called slow because of starting point cwnd = 1 cwnd = 2 cwnd = 3 cwnd = 4 cwnd = 8 Problems with Slow-Start Slow-start can result in many losses Roughly the size of cwnd ~ BW*RTT Example: At some point, cwnd is enough to fill pipe After another RTT, cwnd is double its previous value All the excess packets are dropped! Need a more gentle adjustment algorithm once have rough estimate of bandwidth Switch after first loss Lec 22.15 Lec 22.16 Page 4

1 28 55 82 109 136 163 190 217 244 271 298 325 352 379 406 433 460 487 Problems #2 and #3 Problem #2: Single Flow, Varying BW Want to be able to track available bandwidth, oscillating around its current value Ideal variation: (in terms of RTTs)» Additive increase : cwnd cwnd + 1/cwnd (Increase cwnd by 1 only if all segments in cwnd are ACK d)» Multiplicative decrease: cwnd ½*cwnd» AIMD: gentle increase, drastic decrease Problem #3: Multiple Flows Want steady state to be fair Many notions of fairness, but here all we require is that two identical flows end up with same BW 60 50 40 30 20 A D AIMD Sharing Dynamics x y No congestion rate increases by one packet/rtt every RTT Congestion decrease rate by factor 2 Rates equalize fair share B E 10 0 Lec 22.17 Lec 22.18 TCP Congestion Control Summary Measure available bandwidth Slow start: fast, hard on network AIMD: slow, gentle on network Detect congestion using timeout based on RTT Robust, causes low throughput BREAK Lec 22.19 Page 5

Use of TCP: Sockets Socket: an abstraction of a network I/O queue Embodies one side of a communication channel» Same interface regardless of location of other end» Could be local machine (called UNIX socket ) or remote machine (called network socket ) First introduced in 4.2 BSD UNIX: big innovation at time» Now most operating systems provide some notion of socket Using Sockets for Client-Server (C/C++ interface): On server: set up server-socket» Create socket, Bind to protocol (TCP), local address, port» Call listen(): tells server socket to accept incoming requests» Perform multiple accept() calls on socket to accept incoming connection request» Each successful accept() returns a new socket for a new connection; can pass this off to handler thread On client:» Create socket, Bind to protocol (TCP), remote address, port» Perform connect() on socket to make connection» If connect() successful, have socket connected to server Lec 22.21 Socket Example (Java) server: //Makes socket, binds addr/port, calls listen() ServerSocket sock = new ServerSocket(6013); while(true) { Socket client = sock.accept(); PrintWriter pout = new PrintWriter(client.getOutputStream(),true); } pout.println( Here is data sent to client! ); client.close(); client: // Makes socket, binds addr/port, calls connect() Socket sock = new Socket( 169.229.60.38,6013); BufferedReader bin = new BufferedReader( new InputStreamReader(sock.getInputStream)); String line; while ((line = bin.readline())!=null) System.out.println(line); sock.close(); Lec 22.22 Distributed Applications How do you actually program a distributed application? Need to synchronize multiple threads, running on different machines» No shared memory, so cannot use test&set Send Network One Abstraction: send/receive messages» Already atomic: no receiver gets portion of a message and two receivers cannot get same message Interface: Mailbox (mbox): temporary holding area for messages» Includes both destination location and queue Send(message,mbox)» Send message to remote mailbox identified by mbox Receive(buffer,mbox)» Wait until mbox has message, copy into buffer, and return» If threads sleeping on this mbox, wake up one of them Receive Lec 22.23 Using Messages: Send/Receive behavior When should send(message,mbox) return? When receiver gets message? (i.e. ack received) When message is safely buffered on destination? Right away, if message is buffered on source node? Actually two questions here: When can the sender be sure that the receiver actually received the message? When can sender reuse the memory containing message? Mailbox provides 1-way communication from T1 T2 T1 buffer T2 Very similar to producer/consumer» Send = V, Receive = P» However, can t tell if sender/receiver is local or not! Lec 22.24 Page 6

Messaging for Producer-Consumer Style Using send/receive for producer-consumer style: Producer: int msg1[1000]; while(1) { prepare message; send(msg1,mbox); } Consumer: int buffer[1000]; while(1) { receive(buffer,mbox); process message; } Send Message Receive Message No need for producer/consumer to keep track of space in mailbox: handled by send/receive One of the roles of the window in TCP window is bounded by size of buffer on far end: window = min(cwnd, available receiver buffer) Restricts sender to forward only what will fit in buffer Lec 22.25 Messaging for Request/Response communication What about two-way communication? Request/Response» Read a file stored on a remote machine» Request a web page from a remote web server Also called: client-server» Client requester, Server responder» Server provides service (file storage) to the client Example: File service Client: (requesting the file) char response[1000]; send( read rutabaga, server_mbox); receive(response, client_mbox); Server: (responding with the file) char command[1000], answer[1000]; receive(command, server_mbox); decode command; read file into answer; send(answer, client_mbox); Request File Get Response Receive Request Send Response Lec 22.26 General s Paradox General s paradox: Constraints of problem:» Two generals, on separate mountains» Can only communicate via messengers» Messengers can be captured Problem: need to coordinate attack» If they attack at different times, they all die» If they attack at same time, they win Named after Custer, who died at Little Big Horn because he arrived a couple of days too early General s Paradox Can messages over an unreliable network be used to guarantee two entities do something simultaneously? Remarkably, no, even if all messages get through No way to be sure last message gets through! Lec 22.27 Lec 22.28 Page 7

Two-Phase Commit Since we can t solve the General s Paradox (i.e. simultaneous action), let s solve a related problem Distributed transaction: Two machines agree to do something, or not do it, atomically Two-Phase Commit protocol does this Use a persistent, stable log on each machine to keep track of whether commit has happened» If a machine crashes, when it wakes up it first checks its log to recover state of world at time of crash Prepare Phase:» The global coordinator requests that all participants will promise to commit or rollback the transaction» Participants record promise in log, then acknowledge» If anyone votes to abort, coordinator writes abort in its log and tells everyone to abort; each records abort in log Commit Phase:» After all participants respond that they are prepared, then the coordinator writes commit to its log» Then asks all nodes to commit; they respond with ack» After receive acks, coordinator writes got commit to log Log can be used to complete this process such that all machines either commit or don t commit Lec 22.29 Two phase commit example Simple Example: A ATM machine, B The Bank Phase 1:» A writes Begin transaction to log A B: OK to transfer funds to me?» Not enough funds: B A: transaction aborted; A writes Abort to log» Enough funds: B: Write new account balance to log B A: OK, I can commit Phase 2: A can decide for both whether they will commit» A: write new account balance to log» Write commit to log» Send message to B that commit occurred; wait for ack» Write Got Commit to log What if B crashes at beginning? Wakes up, does nothing; A will timeout, abort and retry What if A crashes at beginning of phase 2? Wakes up, sees transaction in progress; sends abort to B What if B crashes at beginning of phase 2? B comes back up, look at log; when A sends it Commit message, it will say, oh, ok, commit Lec 22.30 Distributed Decision Making Discussion Two-Phase Commit: Blocking A Site can get stuck in a situation where it cannot continue until some other site (usually the coordinator) recovers. Example of how this could happen:» Participant site B writes a prepared to commit record to its log, sends a yes vote to the coordintor (site A) and crashes» Site A crashes» Site B wakes up, check its log, and realizes that it has voted yes on the update. It sends a message to site A asking what happened. At this point, B cannot change its mind and decide to abort, because update may have committed» B is blocked until A comes back Blocking is problematic because a blocked site must hold resources (locks on updated items, pages pinned in memory, etc) until it learns fate of update Alternative: There are alternatives such as Three Phase Commit which don t have this blocking problem Lec 22.31 Page 8