CS162 Operating Systems and Systems Programming Lecture 15 Reliability, Transport Protocols March 16, 2011 Ion Stoica

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

1 Transport Protocols & TCP CSE 3213 Fall April 2015.
EE 4272Spring, 2003 Chapter 17 Transport Protocols Connection-Oriented Transport Protocol  Under Reliable Network Service  Design Issues  Under Unreliable.
CSCI 4550/8556 Computer Networks
Fundamentals of Computer Networks ECE 478/578 Lecture #20: Transmission Control Protocol Instructor: Loukas Lazos Dept of Electrical and Computer Engineering.
1 Transport Layer Lecture 9 Imran Ahmed University of Management & Technology.
1 CS492B Project #2 TCP Tutorial # Jin Hyun Ju.
Winter 2008CS244a Handout #61 CS244a: An Introduction to Computer Networks Handout 6: The Transport Layer, Transmission Control Protocol (TCP), and User.
Transport Layer – TCP (Part1) Dr. Sanjay P. Ahuja, Ph.D. Fidelity National Financial Distinguished Professor of CIS School of Computing, UNF.
OSI 7-Layer Model. Implementation of UDP and TCP CS587x Lecture 2 Department of Computer Science Iowa State University.
Computer Networks 2 Lecture 2 TCP – I - Transport Protocols: TCP Segments, Flow control and Connection Setup.
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 Transport Layer r To learn about transport layer protocols in the Internet: m TCP: connection-oriented protocol m Reliability protocol.
Transport Layer 3-1 Transport Layer r To learn about transport layer protocols in the Internet: m TCP: connection-oriented protocol m Reliability protocol.
Lecture 7 Transport Protocols: UDP, TCP
Computer Networks Transport Layer. Topics F Introduction  F Connection Issues F TCP.
Department of Electronic Engineering City University of Hong Kong EE3900 Computer Networks Transport Protocols Slide 1 Transport Protocols.
TCP. Learning objectives Reliable Transport in TCP TCP flow and Congestion Control.
3-1 Transport services and protocols r provide logical communication between app processes running on different hosts r transport protocols run in end.
EE 4272Spring, 2003 Chapter 17 Transport Protocols Connection-Oriented Transport Protocol  Reliable Network Service: Design Issues  Unreliable Network.
Transport Layer TCP and UDP IS250 Spring 2010
Spring 2002CS 4611 Reliable Byte-Stream (TCP) Outline Connection Establishment/Termination Sliding Window Revisited Flow Control Adaptive Timeout.
Gursharan Singh Tatla Transport Layer 16-May
What Can IP Do? Deliver datagrams to hosts – The IP address in a datagram header identify a host IP treats a computer as an endpoint of communication Best.
Process-to-Process Delivery:
Ch 3. Transport Layer Myungchul Kim
1 Transport Layer Computer Networks. 2 Where are we?
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.
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.
CS332, Ch. 26: TCP Victor Norman Calvin College 1.
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 2.5 Internetworking Chapter 25 (Transport Protocols, UDP and TCP, Protocol Port Numbers)
TCP1 Transmission Control Protocol (TCP). TCP2 Outline Transmission Control Protocol.
The Transport Layer CS168, Fall 2014 Scott Shenker (understudy to Sylvia Ratnasamy) Material thanks to Ion Stoica,
Transport Layer Moving Segments. Transport Layer Protocols Provide a logical communication link between processes running on different hosts as if directly.
1 Introduction to Computer Networks University of ilam Dr. Mozafar Bag-Mohammadi Transport Layer.
1 TCP: Reliable Transport Service. 2 Transmission Control Protocol (TCP) Major transport protocol used in Internet Heavily used Completely reliable transfer.
Lec 17. 4/2/14 Anthony D. Joseph CS162 ©UCB Spring 2014 CS162 S ECTION 8.
81 Sidevõrgud IRT 0020 loeng okt Avo Ots telekommunikatsiooni õppetool, TTÜ raadio- ja sidetehnika inst.
CS/ECE 4381 Concepts Reverse-path forwarding Regular routing protocols compute shortest path tree, so forward multicast packets along “reverse” of this.
Transport Protocols.
Transport Layer: Sliding Window Reliability
4343 X2 – The Transport Layer Tanenbaum Ch.6.
IP1 The Underlying Technologies. What is inside the Internet? Or What are the key underlying technologies that make it work so successfully? –Packet Switching.
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:
EE 122: Transport Protocols Kevin Lai October 16, 2002.
IT 424 Networks2 IT 424 Networks2 Ack.: Slides are adapted from the slides of the book: “Computer Networking” – J. Kurose, K. Ross Chapter 3: Transport.
McGraw-Hill Chapter 23 Process-to-Process Delivery: UDP, TCP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
1 End-to-End Protocols UDP TCP –Connection Establishment/Termination –Sliding Window Revisited –Flow Control –Congestion Control –Adaptive Timeout.
TCP/IP1 Address Resolution Protocol Internet uses IP address to recognize a computer. But IP address needs to be translated to physical address (NIC).
11 CS716 Advanced Computer Networks By Dr. Amir Qayyum.
1 TCP ProtocolsLayer name DNSApplication TCP, UDPTransport IPInternet (Network ) WiFi, Ethernet Link (Physical)
Computer Networking Lecture 16 – Reliable Transport.
Ch 3. Transport Layer Myungchul Kim
CS162 Operating Systems and Systems Programming Lecture 11 Reliability, Transport Protocols October 5, 2011 Anthony D. Joseph and Ion Stoica
Fast Retransmit For sliding windows flow control we waited for a timer to expire before beginning retransmission of a packet TCP uses an additional mechanism.
Introduction to Networks
PART 5 Transport Layer Computer Networks.
Introduction of Transport Protocols
Transport Layer Unit 5.
Anthony D. Joseph and Ion Stoica
Process-to-Process Delivery:
Transport Protocols: TCP Segments, Flow control and Connection Setup
Introduction to Computer Networks
Transport Protocols: TCP Segments, Flow control and Connection Setup
Process-to-Process Delivery: UDP, TCP
November 26th, 2018 Prof. Ion Stoica
Transport Layer 9/22/2019.
Presentation transcript:

CS162 Operating Systems and Systems Programming Lecture 15 Reliability, Transport Protocols March 16, 2011 Ion Stoica

Lec /16Ion Stoica CS162 ©UCB Spring 2011 Goals for Today Finish e2e argument & fate sharing Transport: TCP/UDP –Reliability –Flow control

Lec /16Ion Stoica CS162 ©UCB Spring 2011 Placing Network Functionality Hugely influential paper: “End-to-End Arguments in System Design” by Saltzer, Reed, and Clark (‘84) “Sacred Text” of the Internet –Endless disputes about what it means –Everyone cites it as supporting their position

Lec /16Ion Stoica CS162 ©UCB Spring 2011 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

Lec /16Ion Stoica CS162 ©UCB Spring 2011 Example: Reliable File Transfer Solution 1: make each step reliable, and then concatenate them Solution 2: end-to-end check and try again if necessary OS Appl. OS Appl. Host AHost B OK

Lec /16Ion Stoica CS162 ©UCB Spring 2011 Discussion Solution 1 is incomplete –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

Lec /16Ion Stoica CS162 ©UCB Spring 2011 Summary of 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 losy link

Lec /16Ion Stoica CS162 ©UCB Spring 2011 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

Lec /16Ion Stoica CS162 ©UCB Spring 2011 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

Lec /16Ion Stoica CS162 ©UCB Spring 2011 Related Notion of Fate-Sharing Idea: when storing state in a distributed system, keep it co-located with the entities that ultimately rely on the state Fate-sharing is a technique for dealing with failure –Only way that failure can cause loss of the critical state is if the entity that cares about it also fails... –… in which case it doesn’t matter Often argues for keeping network state at end hosts rather than inside routers –In keeping with End-to-End principle –E.g., packet-switching rather than circuit-switching –E.g., NFS file handles, HTTP “cookies”

Lec /16Ion Stoica CS162 ©UCB Spring 2011 Reliable Transfer Retransmit missing packets –Numbering of packets and ACKs Do this efficiently –Keep transmitting whenever possible –Detect missing ACKs and retransmit quickly Two schemes –Stop & Wait –Sliding Window (Go-back-n and Selective Repeat)

Lec /16Ion Stoica CS162 ©UCB Spring 2011 Stop & Wait ACK DATA Time Sender Receiver RTT Send; wait for ack If timeout, retransmit; else repeat Inefficient if TRANS << RTT Inefficient if TRANS << RTT TRANS

Lec /16Ion Stoica CS162 ©UCB Spring 2011 Sliding Window window = set of adjacent sequence numbers The size of the set is the window size Assume window size is n Let A be the last ack’d packet of sender without gap; then window of sender = {A+1, A+2, …, A+n} Sender can send packets in its window Let B be the last received packet without gap by receiver, then window of receiver = {B+1,…, B+n} Receiver can accept out of sequence, if in window

Lec /16Ion Stoica CS162 ©UCB Spring 2011 Go-Back-n (GBN) Transmit up to n unacknowledged packets If timeout for ACK(k), retransmit k, k+1, …

Lec /16Ion Stoica CS162 ©UCB Spring 2011 GBN Example w/o Errors Time Window size = 3 packets SenderReceiver 1 {1} 2 {1, 2} 3 {1, 2, 3} 4 {2, 3, 4} 5 {3, 4, 5} Sender Window Receiver Window {} 6 {4, 5, 6} {}

Lec /16Ion Stoica CS162 ©UCB Spring 2011 GBN Example with Errors Window size = 3 packets SenderReceiver {} 6 {5} {5,6} 4 is missing Timeout Packet {}

Lec /16Ion Stoica CS162 ©UCB Spring 2011 Selective Repeat (SR) Sender: transmit up to n unacknowledged packets; assume packet k is lost Receiver: indicate packet k is missing Sender: retransmit packet k

Lec /16Ion Stoica CS162 ©UCB Spring 2011 SR Example with Errors Time SenderReceiver Nack = 4 Window size = 3 packets {1} {1, 2} {1, 2, 3} {2, 3, 4} {3, 4, 5} {4, 5, 6} {7}

Lec /16Ion Stoica CS162 ©UCB Spring 2011 Observations With sliding windows, it is possible to 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 /16Ion Stoica CS162 ©UCB Spring 2011 Motivation for Transport Protocols IP provides a weak, but efficient service model (best-effort) –Packets can be delayed, dropped, reordered, duplicated –Packets have limited size (why?) IP packets are addressed to a host –How to decide which application gets which packets? How should hosts send packets into the network? –Too fast may overwhelm the network –Too slow is not efficient

Lec /16Ion Stoica CS162 ©UCB Spring 2011 Transport Layer Provide a way to decide which packets go to which applications (multiplexing/demultiplexing) Can –Provide reliability, in order delivery, at most once delivery –Support messages of arbitrary length –Govern when hosts should send data  can implement congestion and flow control

Lec /16Ion Stoica CS162 ©UCB Spring 2011 Congestion vs. Flow Control Flow Control – avoid overflowing the receiver Congestion Control – avoid congesting the network What is network congestion?

Lec /16Ion Stoica CS162 ©UCB Spring 2011 Transport Layer (cont’d) IP Transport ABC [A | B | p1 | p2 | …] p1p2p1p2p3p1p2 ports Application HTTP DNS SSH UDP: Not reliable TCP: Ordered, reliable, well-paced

Lec /16Ion Stoica CS162 ©UCB Spring 2011 Ports Need to decide which application gets which packets Solution: map each socket to a port Client must know server’s port Separate 16-bit port address space for UDP and TCP –(src_IP, src_port, dst_IP, dst_port) uniquely identifies TCP connection Well known ports (0-1023): everyone agrees which services run on these ports –e.g., ssh:22, –On UNIX, must be root to gain access to these ports (why?) Ephemeral ports (most ): given to clients –e.g. chat clients, p2p networks

Lec /16Ion Stoica CS162 ©UCB Spring 2011 Headers IP header  used for IP routing, fragmentation, error detection UDP header  used for multiplexing/demultiplexing, error detection TCP header  used for multiplexing/demultiplexing, flow and congestion control IP TCP UDP dataTCP/UDP dataTCP/UDPIP Application Sender data IP TCP UDP Application Receiver dataTCP/UDP dataTCP/UDPIP data

Lec /16Ion Stoica CS162 ©UCB Spring 2011 UDP: User (Unreliable) Data Protocol Minimalist transport protocol Same best-effort service model as IP Messages up to 64KB Provides multiplexing/demultiplexing to IP Does not provide flow and congestion control Application examples: video/audio streaming

Lec /16Ion Stoica CS162 ©UCB Spring 2011 UDP Service & Header Service: –Send datagram from (IPa, Port1) to (IPb, Port2) –Service is unreliable, but error detection possible Header: Source port Destination port UDP lengthUDP checksum Payload (variable) UDP length is UDP packet length (including UDP header and payload, but not IP header) Optional UDP checksum is over UDP packet

Lec /16Ion Stoica CS162 ©UCB Spring 2011 TCP: Transport Control Protocol Reliable, in-order, and at most once delivery Stream oriented: messages can be of arbitrary length Provides multiplexing/demultiplexing to IP Provides congestion control and avoidance Application examples: file transfer, chat

Lec /16Ion Stoica CS162 ©UCB Spring 2011 TCP Service  Open connection: 3-way handshaking  Reliable byte stream transfer from (IPa, TCP_Port1) to (IPb, TCP_Port2) Indication if connection fails: Reset  Close (tear-down) connection

Lec /16Ion Stoica CS162 ©UCB Spring 2011 Open Connection: 3-Way Handshaking Goal: agree on a set of parameters: the start sequence number for each side –Starting sequence numbers are random Client (initiator) Server SYN, SeqNum = x SYN and ACK, SeqNum = y and Ack = x + 1 ACK, Ack = y + 1 Active Open Passive Open connect()listen() accept() allocate buffer space

Lec /16Ion Stoica CS162 ©UCB Spring Way Handshaking (cont’d) Three-way handshake adds 1 RTT delay Why? –Congestion control: SYN (40 byte) acts as cheap probe –Protects against delayed packets from other connection (would confuse receiver)

Lec /16Ion Stoica CS162 ©UCB Spring 2011 Close Connection (Two-Army Problem) Goal: both sides agree to close the connection Two-army problem: –“Two blue armies need to simultaneously attack the white army to win; otherwise they will be defeated. The blue army can communicate only across the area controlled by the white army which can intercept the messengers.” What is the solution?

Lec /16Ion Stoica CS162 ©UCB Spring 2011 Close Connection 4-ways tear down connection FIN FIN ACK FIN FIN ACK Host 1Host 2 timeout  Avoid reincarnation  Can retransmit FIN ACK if it is lost closed close

Lec /16Ion Stoica CS162 ©UCB Spring 2011 TCP Flow Control Each byte has a sequence number Initial sequence numbers negotiated via SYN/SYN- ACK packets ACK contains the sequence number of the next byte expected by the receiver

Lec /16Ion Stoica CS162 ©UCB Spring 2011 TCP Flow Control Receiver window (MaxRcvBuf – maximum buffer size at receiver) Sender window (MaxSendBuf – maximum buffer size at sender) LastByteAckedLastByteSent LastByteWritten Sending Application NextByteExpectedLastByteRcvd LastByteRead Receiving Application sequence number increases AdvertisedWindow = MaxRcvBuffer – (LastByteRcvd – LastByteRead) SenderWindow = AdvertisedWindow – (LastByteSent – LastByteAcked) MaxSendBuffer >= LastByteWritten - LastByteAcked

Lec /16Ion Stoica CS162 ©UCB Spring 2011 Retransmission Timeout If haven’t received ack by timeout, retransmit packet after last acked packet How to set timeout?

Lec /16Ion Stoica CS162 ©UCB Spring 2011 Timing Illustration 1 1 Timeout too long  inefficiency 1 1 Timeout too short  duplicate packets RTT Timeout RTT

Lec /16Ion Stoica CS162 ©UCB Spring 2011 Retransmission Timeout (cont’d) If haven’t received ack by timeout, retransmit packet after last acked packet How to set timeout? –Too long: connection has low throughput –Too short: retransmit packet that was just delayed »Packet was probably delayed because of congestion »Sending another packet too soon just makes congestion worse Solution: make timeout proportional to RTT

Lec /16Ion Stoica CS162 ©UCB Spring 2011 RTT Estimation Use exponential averaging: EstimatedRTT Time SampleRTT

Lec /16Ion Stoica CS162 ©UCB Spring 2011 Exponential Averaging Example RTT time EstimatedRTT = α*EstimatedRTT + (1 – α)*SampleRTT Assume RTT is constant  SampleRTT = RTT EstimatedRTT (α = 0.8) EstimatedRTT (α = 0.5)

Lec /16Ion Stoica CS162 ©UCB Spring Problem How to differentiate between the real ACK, and ACK of the retransmitted packet? ACK Retransmission Original Transmission SampleRTT SenderReceiver ACK Retransmission Original Transmission SampleRTT SenderReceiver

Lec /16Ion Stoica CS162 ©UCB Spring 2011 Karn/Partridge Algorithm Measure SampleRTT only for original transmissions Exponential backoff  for each retransmission, double EstimatedRTT

Lec /16Ion Stoica CS162 ©UCB Spring 2011 Jacobson/Karels Algorithm Problem: exponential average is not enough –One solution: use standard deviation (requires expensive square root computation) –Use mean deviation instead

Lec /16Ion Stoica CS162 ©UCB Spring 2011 TCP Header Sequence number, acknowledgement, and advertised window – used by sliding-window based flow control HdrLen: TCP header length in 4-byte words Checksum: checksum of TCP header + payload Source port Destination port Options (variable) Sequence number Acknowledgement Advertised window ChecksumUrgent pointer FlagsHdrLen Payload (variable)

Lec /16Ion Stoica CS162 ©UCB Spring 2011 Summary Reliable transmission –S&W not efficient  Go-Back-n –What to ACK? (cumulative, …) UDP: Multiplex, detect errors TCP: Reliable Byte Stream –3-way handshaking –Flow control –Timer Value: based on measured RTT