T. S. Eugene Ngeugeneng at cs.rice.edu Rice University1 COMP/ELEC 429 Introduction to Computer Networks Lecture 13: TCP Slides used with permissions from.

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

CSCI 4550/8556 Computer Networks
Transmission Control Protocol (TCP)
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.
UDP & TCP Where would we be without them!. UDP User Datagram Protocol.
1 Transport Layer Lecture 9 Imran Ahmed University of Management & Technology.
1 TCP - Part I Relates to Lab 5. First module on TCP which covers packet format, data transfer, and connection management.
Winter 2008CS244a Handout #61 CS244a: An Introduction to Computer Networks Handout 6: The Transport Layer, Transmission Control Protocol (TCP), and User.
1 CS 4396 Computer Networks Lab Transmission Control Protocol (TCP) Part I.
BZUPAGES.COM 1 User Datagram Protocol - UDP RFC 768, Protocol 17 Provides unreliable, connectionless on top of IP Minimal overhead, high performance –No.
TELE202 Lecture 14 TCP/UDP (2) 1 Lecturer Dr Z. Huang Overview ¥Last Lecture »TCP/UDP (1) »Source: chapter 17 ¥This Lecture »TCP/UDP (2) »Source: chapter.
Computer Networks 2 Lecture 2 TCP – I - Transport Protocols: TCP Segments, Flow control and Connection Setup.
CSE534 – Fundamentals of Computer Networks Lecture 8-9: Transport (UDP, but mostly TCP) Based on slides by D. Choffnes Northeastern U Revised by P. Gill.
The Transport Layer. 2 Purpose of this layer Interface end-to-end applications and protocols –Turn best-effort IP into a usable interface Data transfer.
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.
Computer Networking Lecture 16 – More 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.
Transport Layer TCP and UDP IS250 Spring 2010
IP-UDP-RTP Computer Networking (In Chap 3, 4, 7) 건국대학교 인터넷미디어공학부 임 창 훈.
Gursharan Singh Tatla Transport Layer 16-May
Process-to-Process Delivery:
1 Transport Layer Computer Networks. 2 Where are we?
Transport Layer 3-1 Chapter 3 Transport Layer Computer Networking: A Top Down Approach 6 th edition Jim Kurose, Keith Ross Addison-Wesley March 2012 All.
– 1 – TCP Connection Management, Error Control Mar. 29, 2004 Slides – Randy Bryant, Hui Zhang, Ion Stoica, Dave Eckhardt L17a_TCP Computer.
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.
SMUCSE 4344 transport layer. SMUCSE 4344 transport layer end-to-end protocols –transport code runs only on endpoint hosts encapsulates network communications.
Fundamentals of Computer Networks ECE 478/578 Lecture #19: Transport Layer Instructor: Loukas Lazos Dept of Electrical and Computer Engineering University.
ECE453 – Introduction to Computer Networks Lecture 14 – Transport Layer (I)
TCP1 Transmission Control Protocol (TCP). TCP2 Outline Transmission Control Protocol.
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.
Networking Fundamentals. Basics Network – collection of nodes and links that cooperate for communication Nodes – computer systems –Internal (routers,
Andmeside IRT 0030 loeng 605. okt Avo Ots telekommunikatsiooni õppetool raadio- ja sidetehnika instituut
Networking Basics CCNA 1 Chapter 11.
Lecture 18 – More TCP & Congestion Control
81 Sidevõrgud IRT 0020 loeng okt Avo Ots telekommunikatsiooni õppetool, TTÜ raadio- ja sidetehnika inst.
T. S. Eugene Ngeugeneng at cs.rice.edu Rice University1 COMP/ELEC 429/556 Introduction to Computer Networks The TCP Protocol Some slides used with permissions.
Computer Networks23-1 PART 5 Transport Layer. Computer Networks23-2 Position of Transport Layer Responsible for the delivery of a message from one process.
T. S. Eugene Ngeugeneng at cs.rice.edu Rice University1 COMP/ELEC 429/556 Introduction to Computer Networks Principles of Congestion Control Some slides.
Transport Protocols.
Computer Networks Lecture 9: Transport layer Part II Based on slides from D. Choffnes Northeastern U. and P. Gill from StonyBrook University Revised Autumn.
1 Transport Layer: Basics Outline Intro to transport UDP Congestion control basics.
IP1 The Underlying Technologies. What is inside the Internet? Or What are the key underlying technologies that make it work so successfully? –Packet Switching.
Transmission Control Protocol (TCP) connection-oriented stream data transfer data sent as an unstructured stream of bytes reliability acknowledgements.
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.
Transport Layer3-1 Transport Layer If you are going through Hell Keep going.
McGraw-Hill Chapter 23 Process-to-Process Delivery: UDP, TCP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
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.
DMET 602: Networks and Media Lab Amr El Mougy Yasmeen EssamAlaa Tarek.
3. END-TO-END PROTOCOLS (PART 1) Rocky K. C. Chang Department of Computing The Hong Kong Polytechnic University 22 March
DMET 602: Networks and Media Lab
Introduction to TCP/IP networking
Introduction to Networks
5. End-to-end protocols (part 1)
PART 5 Transport Layer Computer Networks.
Introduction of Transport Protocols
COMP/ELEC 429/556 Introduction to Computer Networks
Lecture 18 – More TCP & Congestion Control
Chapter 5 Transport Layer Introduction
Transport Protocols: TCP Segments, Flow control and Connection Setup
Transport Protocols: TCP Segments, Flow control and Connection Setup
Process-to-Process Delivery: UDP, TCP
Presentation transcript:

T. S. Eugene Ngeugeneng at cs.rice.edu Rice University1 COMP/ELEC 429 Introduction to Computer Networks Lecture 13: TCP Slides used with permissions from Edward W. Knightly, T. S. Eugene Ng, Ion Stoica, Hui Zhang

T. S. Eugene Ngeugeneng at cs.rice.edu Rice University2 What Layers are Needed in a Basic Telephone Network? Supports a single application: Telephone An end host is a telephone Each telephone makes only one voice stream –Even with call-waiting and 3-way calling Application Layer Network Layer (Data) Link Layer Telephone Telephone numbering, signaling, routing TDMA

T. S. Eugene Ngeugeneng at cs.rice.edu Rice University3 Is this Enough for a Datagram Computer Network? Supports many applications Each end host is usually a general purpose computer Each end host can be generating many data streams simultaneously In theory, each data stream can be identified as a different “Protocol” in the IP header for demultiplexing –At most 256 streams Insert Transport Layer to create an interface for different applications –Provide (de)multiplexing –Provide value-added functions Application Layer Transport Layer Network Layer (Data) Link Layer telnet, ftp, TCP, UDP IP 802.3,

T. S. Eugene Ngeugeneng at cs.rice.edu Rice University4 E.g. Using Transport Layer Port Number to (De)multiplex traffic IP TCP Transport ABC p1p2p1p2p3p1p2 ports Application HTTP ssh telnet In TCP, a data stream is identified by a set of numbers: (Source Address, Destination Address, Source Port, Destination Port)

T. S. Eugene Ngeugeneng at cs.rice.edu Rice University5 Transport Layer in Internet Purpose 1: (De)multiplexing of data streams to different application processes Purpose 2: Provide value-added services that many applications want –Recall network layer in Internet provides a “Best-effort” service only, transport layer can add value to that Application may want reliability, etc –No need to reinvent the wheel each time you write a new application

T. S. Eugene Ngeugeneng at cs.rice.edu Rice University6 Transport Protocols Concern only End Hosts, not Routers Lowest level end-to-end protocol. –Header generated by sender is interpreted only by the destination –Routers view transport header as part of the payload Adds functionality to the best-effort packet delivery IP service. –Make up for the shortcomings of the core network Transport IP Datalink Physical Transport IP Datalink Physical IP router

T. S. Eugene Ngeugeneng at cs.rice.edu Rice University7 (Possible) Transport Protocol Functions Multiplexing/demultiplexing for multiple applications. –Port abstraction Connection establishment. –Logical end-to-end connection –Connection state to optimize performance Error control. –Hide unreliability of the network layer from applications –Many types of errors: corruption, loss, duplication, reordering. End-to-end flow control. –Avoid flooding the receiver Congestion control. –Avoid flooding the network More….

T. S. Eugene Ngeugeneng at cs.rice.edu Rice University8 User Datagram Protocol (UDP) Connectionless datagram –Socket: SOCK_DGRAM Port number used for (de)multiplexing –port numbers = connection/application endpoint Adds end-to-end reliability through optional checksum –protects against data corruption errors between source and destination (links, switches/routers, bus) –does not protect against packet loss, duplication or reordering Source Port Dest. Port Length Checksum

T. S. Eugene Ngeugeneng at cs.rice.edu Rice University9 Using UDP Custom protocols/applications can be implemented on top of UDP –use the port addressing provided by UDP –implement own reliability, flow control, ordering, congestion control as it sees fit Examples: –remote procedure call –Multimedia streaming (real time protocol) –distributed computing communication libraries

T. S. Eugene Ngeugeneng at cs.rice.edu Rice University10 Transmission Control Protocol (TCP) Reliable bidirectional in-order byte stream –Socket: SOCK_STREAM Connections established & torn down Multiplexing/ demultiplexing –Ports at both ends Error control –Users see correct, ordered byte sequences End-end flow control –Avoid overwhelming machines at each end Congestion avoidance –Avoid creating traffic jams within network Source Port Dest. Port Sequence Number Acknowledgment Number HL/Flags Advertised Win. Checksum Urgent Pointer Options

T. S. Eugene Ngeugeneng at cs.rice.edu Rice University11 High Level TCP Features Sliding window protocol –Use sequence numbers Bi-directional –Each host can be a receiver and a sender simultaneously –For clarity, we will usually discuss only one direction

T. S. Eugene Ngeugeneng at cs.rice.edu Rice University12 Connection Setup Why need connection setup? Mainly to agree on starting sequence numbers –Starting sequence number is randomly chosen –Reason, to reduce the chance that sequence numbers of old and new connections from overlapping

T. S. Eugene Ngeugeneng at cs.rice.edu Rice University13 Important TCP Flags SYN: Synchronize –Used when setting up connection FIN: Finish –Used when tearing down connection ACK –Acknowledging received data

T. S. Eugene Ngeugeneng at cs.rice.edu Rice University14 Establishing Connection Three-Way Handshake –Each side notifies other of starting sequence number it will use for sending –Each side acknowledges other’s sequence number SYN-ACK: Acknowledge sequence number + 1 –Can combine second SYN with first ACK SYN: SeqC ACK: SeqC+1 SYN: SeqS ACK: SeqS+1 Client Server

T. S. Eugene Ngeugeneng at cs.rice.edu Rice University15 TCP State Diagram: Connection Setup CLOSED SYN SENT SYN RCVD ESTAB LISTEN active OPEN Snd SYN passive OPEN CLOSE delete TCB CLOSE snd SYN SEND snd SYN ACK rcv SYN Send FIN CLOSE rcv ACK of SYN Snd ACK Rcv SYN, ACK rcv SYN snd ACK Client Server

T. S. Eugene Ngeugeneng at cs.rice.edu Rice University16 Tearing Down Connection Either Side Can Initiate Tear Down –Send FIN signal –“I’m not going to send any more data” Other Side Can Continue Sending Data –Half open connection –Must continue to acknowledge Acknowledging FIN –Acknowledge last sequence number + 1 AB FIN, SeqA ACK, SeqA+1 ACK Data ACK, SeqB+1 FIN, SeqB

T. S. Eugene Ngeugeneng at cs.rice.edu Rice University17 State Diagram: Connection Tear-down CLOSING CLOSE WAIT FIN WAIT-1 ESTAB TIME WAIT snd FIN CLOSE send FIN CLOSE rcv ACK of FIN LAST-ACK CLOSED FIN WAIT-2 snd ACK rcv FIN Timeout=2 MSL send FIN CLOSE send ACK rcv FIN snd ACK rcv FIN rcv ACK of FIN snd ACK rcv FIN+ACK ACK Active Close Passive Close

T. S. Eugene Ngeugeneng at cs.rice.edu Rice University18 Sequence Number Space Each byte in byte stream is numbered. –32 bit value –Wraps around –Initial values selected at start up time TCP breaks up the byte stream in packets (“segments”) –Packet size is limited to the Maximum Segment Size –Set to prevent packet fragmentation Each segment has a sequence number. –Indicates where it fits in the byte stream segment 8segment 9segment

T. S. Eugene Ngeugeneng at cs.rice.edu Rice University19 Sequence Numbers 32 Bits, Unsigned Why So Big? –For sliding window, must have |Sequence Space| > 2* |Sending Window| 2^32 > 2 * 2^16. No problem –Also, want to guard against stray packets With IP, assume packets have maximum segment lifetime (MSL) of 120s –i.e. can linger in network for upto 120s Sequence number would wrap around in this time at 286Mbps

T. S. Eugene Ngeugeneng at cs.rice.edu Rice University20 Error Control Checksum (mostly) guarantees end-end data integrity. Sequence numbers detect packet sequencing problems: –Duplicate: ignore –Reordered: reorder or drop –Lost: retransmit Lost segments detected by sender. –Use time out to detect lack of acknowledgment –Need estimate of the roundtrip time to set timeout Retransmission requires that sender keep copy of the data. –Copy is discarded when ack is received

T. S. Eugene Ngeugeneng at cs.rice.edu Rice University21 Bidirectional Communication Each Side of Connection can Send and Receive What this Means –Maintain different sequence numbers for each direction –Single segment can contain new data for one direction, plus acknowledgement for other But some contain only data & others only acknowledgement Send seq 2000 Ack seq 2001 Send seq Ack seq 42001

T. S. Eugene Ngeugeneng at cs.rice.edu Rice University22 TCP Flow Control Sliding window protocol –For window size n, can send up to n bytes without receiving an acknowledgement –When the data are acknowledged then the window slides forward Window size determines –How much unacknowledged data can the sender sends But there is more detail

T. S. Eugene Ngeugeneng at cs.rice.edu Rice University23 Complication! TCP receiver can delete acknowledged data only after the data has been delivered to the application So, depending on how fast the application is reading the data, the receiver’s window size may change!!!

T. S. Eugene Ngeugeneng at cs.rice.edu Rice University24 Solution Receiver tells sender what is the current window size in every packet it transmits to the sender Sender uses this current window size instead of a fixed value Window size (also called Advertised window) is continuously changing Can go to zero! –Sender not allowed to send anything!

T. S. Eugene Ngeugeneng at cs.rice.edu Rice University25 Acked but not delivered to user Not yet acked Receive buffer window Window Flow Control: Receive Side

T. S. Eugene Ngeugeneng at cs.rice.edu Rice University26 Window Flow Control: Send Side Sent but not ackedNot yet sent window Next to be sent Sent and acked Must retain for possible retransmission

T. S. Eugene Ngeugeneng at cs.rice.edu Rice University27 acknowledgedsentto be sentoutside window Source Port Dest. Port Sequence Number Acknowledgment HL/Flags Window D. Checksum Urgent Pointer Options.. Source Port Dest. Port Sequence Number Acknowledgment HL/Flags Window D. Checksum Urgent Pointer Options.. Packet Sent Packet Received App write Window Flow Control: Send Side

T. S. Eugene Ngeugeneng at cs.rice.edu Rice University28 Ongoing Communication Bidirectional Communication –Each side acts as sender & receiver –Every message contains acknowledgement of received sequence Even if no new data have been received –Every message advertises window size Size of its receiving window –Every message contains sent sequence number Even if no new data being sent When Does Sender Actually Send Message? –When sending buffer contains at least max. segment size (- header sizes) bytes –When application tells it Set PUSH flag for last segment sent –When timer expires

T. S. Eugene Ngeugeneng at cs.rice.edu Rice University29 TCP Must Operates Over Any Internet Path Retransmission time-out should be set based on round-trip delay But round-trip delay different for each path! Must estimate RTT dynamically

T. S. Eugene Ngeugeneng at cs.rice.edu Rice University30 Setting Retransmission Timeout (RTO) –Time between sending & resending segment Challenge –Too long: Add latency to communication when packets dropped –Too short: Send too many duplicate packets –General principle: Must be > 1 Round Trip Time (RTT) Initial Send Retry Ack RTO Initial Send Retry Ack RTO Detect dropped packetRTO too short

T. S. Eugene Ngeugeneng at cs.rice.edu Rice University31 Round-trip Time Estimation Every Data/Ack pair gives new RTT estimate Can Get Lots of Short-Term Fluctuations Data Ack Sample

T. S. Eugene Ngeugeneng at cs.rice.edu Rice University32 Original TCP Round-trip Estimator Round trip times estimated as a moving average: –New RTT =  (old RTT) + (1 -  ) (new sample) –Recommended value for  : for most TCP’s Retransmit timer set to  RTT, where  = 2 –Want to be somewhat conservative about retransmitting

T. S. Eugene Ngeugeneng at cs.rice.edu Rice University33 RTT Sample Ambiguity Ignore sample for segment that has been retransmitted AB ACK Sample RTT Original transmission retransmission RTO AB Original transmission retransmission Sample RTT ACK RTO X

T. S. Eugene Ngeugeneng at cs.rice.edu Rice University34 What is Congestion? The load placed on the network is higher than the capacity of the network –Not surprising: independent senders place load on network Results in packet loss: routers have no choice –Can only buffer finite amount of data –End-to-end protocol will typically react, e.g. TCP

T. S. Eugene Ngeugeneng at cs.rice.edu Rice University35 Why is Congestion Bad? Wasted bandwidth: retransmission of dropped packets Poor user service : unpredictable delay, low user goodput Increased load can even result in lower network goodput –Switched nets: packet losses create lots of retransmissions –Broadcast Ethernet: high demand -> many collisions Load Goodput “congestion collapse”

T. S. Eugene Ngeugeneng at cs.rice.edu Rice University36 Sending Rate of Sliding Window Protocol Suppose A uses a sliding window protocol to transmit a large data file to B Window size = 64KB Network round-trip delay is 1 second What’s the expected sending rate? 64KB/second What if a network link is only 64KB/second but there are 1000 people who are transferring files over that link using the sliding window protocol? Packet losses, timeouts, retransmissions, more packet losses… nothing useful gets through, congestion collapse!

T. S. Eugene Ngeugeneng at cs.rice.edu Rice University37 acknowledgedsentto be sentoutside window Source Port Dest. Port Sequence Number Acknowledgment HL/Flags Window D. Checksum Urgent Pointer Options.. Source Port Dest. Port Sequence Number Acknowledgment HL/Flags Window D. Checksum Urgent Pointer Options.. Packet Sent Packet Received App write TCP Window Flow Control

T. S. Eugene Ngeugeneng at cs.rice.edu Rice University38 TCP Flow Control Alone Is Not Enough We have talked about how TCP’s advertised window is used for flow control –To keep sender sending faster than the receiver can handle If the receiver is sufficiently fast, then the advertised window will be maximized at all time But clearly, this will lead to congestion collapse as the previous example if there are too many senders or network is too slow Key 1: Window size determines sending rate Key 2: Window size must be dynamically adjusted to prevent congestion collapse

T. S. Eugene Ngeugeneng at cs.rice.edu Rice University39 How Fast to Send? What’s at Stake? Send too slow: link sits idle –wastes time Send too fast: link is kept busy but.... –queue builds up in router buffer (delay) –overflow buffers in routers (loss) –Many retransmissions, many losses –Network goodput goes down Load Goodput safe operating point

T. S. Eugene Ngeugeneng at cs.rice.edu Rice University40 Abstract View We ignore internal structure of network and model it as having a single bottleneck link Sending Host Buffer in bottleneck Router Receiving Host AB

T. S. Eugene Ngeugeneng at cs.rice.edu Rice University41 Three Congestion Control Problems Adjusting to bottleneck bandwidth Adjusting to variations in bandwidth Sharing bandwidth between flows

T. S. Eugene Ngeugeneng at cs.rice.edu Rice University42 Single Flow, Fixed Bandwidth Adjust rate to match bottleneck bandwidth –without any a priori knowledge –could be gigabit link, could be a modem AB 100 Mbps

T. S. Eugene Ngeugeneng at cs.rice.edu Rice University43 Single Flow, Varying Bandwidth Adjust rate to match instantaneous bandwidth Bottleneck can change because of a routing change AB BW(t)

T. S. Eugene Ngeugeneng at cs.rice.edu Rice University44 Multiple Flows Two Issues: Adjust total sending rate to match bottleneck bandwidth Allocation of bandwidth between flows A2B2 100 Mbps A1 A3 B3 B1