1 Transport Protocols Reading: Sections 2.5, 5.1, and 5.2 COS 461: Computer Networks Spring 2008 (MW 1:30-2:50 in COS 105) Jennifer Rexford Teaching Assistants:

Slides:



Advertisements
Similar presentations
Congestion Control Jennifer Rexford Advanced Computer Networks Tuesdays/Thursdays 1:30pm-2:50pm.
Advertisements

CCNA – Network Fundamentals
© 2007 Cisco Systems, Inc. All rights reserved.Cisco Public ITE PC v4.0 Chapter 1 1 OSI Transport Layer Network Fundamentals – Chapter 4.
Fundamentals of Computer Networks ECE 478/578 Lecture #20: Transmission Control Protocol Instructor: Loukas Lazos Dept of Electrical and Computer Engineering.
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.
CSEE W4140 Networking Laboratory Lecture 6: TCP and UDP Jong Yul Kim
Data Communications and Computer Networks Chapter 3 CS 3830 Lecture 16 Omar Meqdadi Department of Computer Science and Software Engineering University.
UDP & TCP Where would we be without them!. UDP User Datagram Protocol.
1 Transport Layer Lecture 9 Imran Ahmed University of Management & Technology.
1 CS492B Project #2 TCP Tutorial # Jin Hyun Ju.
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.
BZUPAGES.COM 1 User Datagram Protocol - UDP RFC 768, Protocol 17 Provides unreliable, connectionless on top of IP Minimal overhead, high performance –No.
Transport Layer – TCP (Part1) Dr. Sanjay P. Ahuja, Ph.D. Fidelity National Financial Distinguished Professor of CIS School of Computing, UNF.
Computer Networks 2 Lecture 2 TCP – I - Transport Protocols: TCP Segments, Flow control and Connection Setup.
Professor Yashar Ganjali Department of Computer Science University of Toronto
TCP EE 122, Fall 2013 Sylvia Ratnasamy Material thanks to Ion Stoica, Scott Shenker, Jennifer Rexford, Nick McKeown,
Copyright 1999, S.D. Personick. All Rights Reserved. Telecommunications Networking II Lecture 32 Transmission Control Protocol (TCP) Ref: Tanenbaum pp:
Chapter 3 outline 3.1 transport-layer services
Transport Protocols Reading: Sections 5.1 and 5.2 COS 461: Computer Networks Spring 2011 Mike Freedman
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.
CSEE W4140 Networking Laboratory Lecture 6: TCP and UDP Jong Yul Kim
1 Transport Protocols Reading: Sections 2.5, 5.1, and 5.2 COS 461: Computer Networks Spring 2006 (MW 1:30-2:50 in Friend 109) Jennifer Rexford Teaching.
Transport Protocols Reading: Sections 2.5, 5.1, and 5.2 COS 461: Computer Networks Spring 2009 (MW 1:30-2:50 in COS 105) Mike Freedman
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
Gursharan Singh Tatla Transport Layer 16-May
Process-to-Process Delivery:
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.
Fundamentals of Computer Networks ECE 478/578 Lecture #19: Transport Layer Instructor: Loukas Lazos Dept of Electrical and Computer Engineering University.
Copyright 2002, S.D. Personick. All Rights Reserved.1 Telecommunications Networking II Topic 20 Transmission Control Protocol (TCP) Ref: Tanenbaum pp:
TCP1 Transmission Control Protocol (TCP). TCP2 Outline Transmission Control Protocol.
Transport Layer3-1 Chapter 3: Transport Layer Our goals: r understand principles behind transport layer services: m multiplexing/demultipl exing m reliable.
Transport Layer Moving Segments. Transport Layer Protocols Provide a logical communication link between processes running on different hosts as if directly.
CSE679: Computer Network Review r Review of the uncounted quiz r Computer network review.
Transport Layer Mike Freedman COS 461: Computer Networks Best-effort local packet delivery Best-effort.
1 End-to-End Protocols (UDP, TCP, Connection Management)
4-1 Lecture 04: Transport Layer r Transport layer protocols in the Internet: m UDP: connectionless transport m TCP: connection-oriented transport m TCP.
Networking Basics CCNA 1 Chapter 11.
81 Sidevõrgud IRT 0020 loeng okt Avo Ots telekommunikatsiooni õppetool, TTÜ raadio- ja sidetehnika inst.
TCP EE 122, Fall 2013 Sylvia Ratnasamy
Transport Protocols.
Transport Layer: Sliding Window Reliability
UDP & TCP Where would we be without them!. UDP User Datagram Protocol.
Retransmission. Automatic Repeat reQuest (ARQ) 2 Time Packet ACK Timeout Automatic Repeat Request –Receiver sends acknowledgment (ACK) when it receives.
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).
CSEN 404 Transport Layer II Amr El Mougy Lamia AlBadrawy.
11 CS716 Advanced Computer Networks By Dr. Amir Qayyum.
Computer Networks 1000-Transport layer, TCP Gergely Windisch v spring.
1 TCP ProtocolsLayer name DNSApplication TCP, UDPTransport IPInternet (Network ) WiFi, Ethernet Link (Physical)
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
Professor Ayse Karaman Announcements Programming assignment 1 Due: Friday, October 30 th (5PM) If you submit 10 days (by the.
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
Process-to-Process Delivery
Process-to-Process Delivery:
Transport Layer Jennifer Rexford COS 461: Computer Networks
Transport Protocols: TCP Segments, Flow control and Connection Setup
Handout # 10: Transport Protocols
Transport Protocols: TCP Segments, Flow control and Connection Setup
Process-to-Process Delivery: UDP, TCP
Presentation transcript:

1 Transport Protocols Reading: Sections 2.5, 5.1, and 5.2 COS 461: Computer Networks Spring 2008 (MW 1:30-2:50 in COS 105) Jennifer Rexford Teaching Assistants: Sunghwan Ihm and Yaping Zhu

2 Goals for Today’s Lecture Principles underlying transport-layer services –(De)multiplexing –Detecting corruption –Reliable delivery –Flow control Transport-layer protocols in the Internet –User Datagram Protocol (UDP)  Simple (unreliable) message delivery  Realized by a SOCK_DGRAM socket –Transmission Control Protocol (TCP)  Reliable bidirectional stream of bytes  Realized by a SOCK_STREAM socket

3 Role of Transport Layer Application layer –Between applications (e.g., browsers and servers) –E.g., HyperText Transfer Protocol (HTTP), File Transfer Protocol (FTP), Network News Transfer Protocol (NNTP) Transport layer –Between processes (e.g., sockets) –Relies on network layer and serves the application layer –E.g., TCP and UDP Network layer –Between nodes (e.g., routers and hosts) –Hides details of the link technology –E.g., IP

4 Transport Protocols Provide logical communication between application processes running on different hosts Run on end hosts –Sender: breaks application messages into segments, and passes to network layer –Receiver: reassembles segments into messages, passes to application layer Multiple transport protocols available to applications –Internet: TCP and UDP application transport network data link physical application transport network data link physical network data link physical network data link physical network data link physical network data link physical network data link physical logical end-end transport

5 Two Basic Transport Features Demultiplexing: port numbers Error detection: checksums Web server (port 80) Client host Server host Echo server (port 7) Service request for :80 (i.e., the Web server) OS Client IPpayload detect corruption

6 User Datagram Protocol (UDP) Datagram messaging service –Demultiplexing of messages: port numbers –Detecting corrupted messages: checksum Lightweight communication between processes –Send messages to and receive them from a socket –Avoid overhead and delays of ordered, reliable delivery SRC port DST port checksumlength DATA

7 Why Would Anyone Use UDP? Fine control over what data is sent and when –As soon as an application process writes into the socket –… UDP will package the data and send the packet No delay for connection establishment –UDP just blasts away without any formal preliminaries –… which avoids introducing any unnecessary delays No connection state –No allocation of buffers, parameters, sequence #s, etc. –… making it easier to handle many active clients at once Small packet header overhead –UDP header is only eight-bytes long

8 Popular Applications That Use UDP Multimedia streaming –Retransmitting lost/corrupted packets is not worthwhile –By the time the packet is retransmitted, it’s too late –E.g., telephone calls, video conferencing, gaming Simple query protocols like Domain Name System –Overhead of connection establishment is overkill –Easier to have the application retransmit if needed “Address for “ ”

9 Transmission Control Protocol (TCP) Stream-of-bytes service –Sends and receives a stream of bytes, not messages Reliable, in-order delivery –Checksums to detect corrupted data –Sequence numbers to detect losses and reorder data –Acknowledgments & retransmissions for reliable delivery Connection oriented –Explicit set-up and tear-down of TCP session Flow control – Prevent overflow of the receiver’s buffer space Congestion control (next class!) –Adapt to network congestion for the greater good

10 Breaking a Stream of Bytes into TCP Segments

11 TCP “Stream of Bytes” Service Byte 0Byte 1 Byte 2Byte 3 Byte 0Byte 1Byte 2Byte 3 Host A Host B Byte 80

12 …Emulated Using TCP “Segments” Byte 0Byte 1 Byte 2Byte 3 Byte 0Byte 1Byte 2Byte 3 Host A Host B Byte 80 TCP Data Byte 80 Segment sent when: 1.Segment full (Max Segment Size), 2.Not full, but times out, or 3.“Pushed” by application.

13 TCP Segment IP packet –No bigger than Maximum Transmission Unit (MTU) –E.g., up to 1500 bytes on an Ethernet TCP packet –IP packet with a TCP header and data inside –TCP header is typically 20 bytes long TCP segment –No more than Maximum Segment Size (MSS) bytes –E.g., up to 1460 consecutive bytes from the stream IP Hdr IP Data TCP HdrTCP Data (segment)

14 Sequence Number Host A Host B TCP Data ISN (initial sequence number) Sequence number = 1 st byte Byte 81

15 Initial Sequence Number (ISN) Sequence number for the very first byte –E.g., Why not a de facto ISN of 0? Practical issue –IP addresses and port #s uniquely identify a connection –Eventually, though, these port #s do get used again –… and there is a chance an old packet is still in flight –… and might be associated with the new connection So, TCP requires changing the ISN over time –Set from a 32-bit clock that ticks every 4 microseconds –… which only wraps around once every 4.55 hours! But, this means the hosts need to exchange ISNs

16 Reliable Delivery on a Lossy Channel With Bit Errors

17 An Analogy: Talking on a Cell Phone Alice and Bob on their cell phones –Both Alice and Bob are talking What if Alice couldn’t understand Bob? –Bob asks Alice to repeat what she said What if Bob hasn’t heard Alice for a while? –Is Alice just being quiet? –Or, have Bob and Alice lost reception? –How long should Bob just keep on talking? –Maybe Alice should periodically say “uh huh” –… or Bob should ask “Can you hear me now?”

18 Some Take-Aways from the Example Acknowledgments from receiver –Positive: “okay” or “uh huh” or “ACK” –Negative: “please repeat that” or “NACK” Timeout by the sender (“stop and wait”) –Don’t wait indefinitely without receiving some response –… whether a positive or a negative acknowledgment Retransmission by the sender –After receiving a “NACK” from the receiver –After receiving no feedback from the receiver

19 Challenges of Reliable Data Transfer Over a perfectly reliable channel –All of the data arrives in order, just as it was sent –Simple: sender sends data, and receiver receives data Over a channel with bit errors –All of the data arrives in order, but some bits corrupted –Receiver detects errors and says “please repeat that” –Sender retransmits the data that were corrupted Over a lossy channel with bit errors –Some data are missing, and some bits are corrupted –Receiver detects errors but cannot always detect loss –Sender must wait for acknowledgment (“ACK” or “OK”) –… and retransmit data after some time if no ACK arrives

20 TCP Support for Reliable Delivery Detect bit errors: checksum – Used to detect corrupted data at the receiver – …leading the receiver to drop the packet Detect missing data: sequence number – Used to detect a gap in the stream of bytes –... and for putting the data back in order Recover from lost data: retransmission – Sender retransmits lost or corrupted data – Two main ways to detect lost packets

21 TCP Acknowledgments Host A Host B TCP Data TCP HDR TCP HDR ISN (initial sequence number) Sequence number = 1 st byte ACK sequence number = next expected byte

22 Automatic Repeat reQuest (ARQ) Time Packet ACK Timeout Automatic Repeat reQuest –Receiver sends acknowledgment (ACK) when it receives packet –Sender waits for ACK and timeouts if it does not arrive within some time period Simplest ARQ protocol –Stop and wait –Send a packet, stop and wait until ACK arrives SenderReceiver

23 Reasons for Retransmission Packet ACK Timeout Packet ACK Timeout Packet Timeout Packet ACK Timeout Packet ACK Timeout Packet ACK Timeout ACK lost DUPLICATE PACKET Packet lost Early timeout DUPLICATE PACKETS

24 How Long Should Sender Wait? Sender sets a timeout to wait for an ACK –Too short: wasted retransmissions –Too long: excessive delays when packet lost TCP sets timeout as a function of the RTT –Expect ACK to arrive after an “round-trip time” –… plus a fudge factor to account for queuing But, how does the sender know the RTT? –Can estimate the RTT by watching the ACKs –Smooth estimate: keep a running average of the RTT  EstimatedRTT = a * EstimatedRTT + (1 –a ) * SampleRTT –Compute timeout: TimeOut = 2 * EstimatedRTT

25 Example RTT Estimation

26 A Flaw in This Approach An ACK doesn’t really acknowledge a transmission –Rather, it acknowledges receipt of the data Consider a retransmission of a lost packet –If you assume the ACK goes with the 1st transmission –… the SampleRTT comes out way too large Consider a duplicate packet –If you assume the ACK goes with the 2nd transmission –… the Sample RTT comes out way too small Simple solution in the Karn/Partridge algorithm –Only collect samples for segments sent one single time

27 Still, Timeouts are Inefficient Timeout-based retransmission –Sender transmits a packet and waits until timer expires –… and then retransmits from the lost packet onward

28 Fast Retransmission Better solution possible under sliding window –Although packet n might have been lost –… packets n+1, n+2, and so on might get through Idea: have the receiver send ACK packets –ACK says that receiver is still awaiting n th packet  And repeated ACKs suggest later packets have arrived –Sender can view the “duplicate ACKs” as an early hint  … that the n th packet must have been lost  … and perform the retransmission early Fast retransmission –Sender retransmits data after the triple duplicate ACK

29 Effectiveness of Fast Retransmit When does Fast Retransmit work best? –Long data transfers  High likelihood of many packets in flight –High window size  High likelihood of many packets in flight –Low burstiness in packet losses  Higher likelihood that later packets arrive successfully Implications for Web traffic –Most Web transfers are short (e.g., 10 packets)  Short HTML files or small images –So, often there aren’t many packets in flight –… making fast retransmit less likely to “kick in” –Forcing users to like “reload” more often…

30 Starting and Ending a Connection: TCP Handshakes

31 Establishing a TCP Connection Three-way handshake to establish connection –Host A sends a SYN (open) to the host B –Host B returns a SYN acknowledgment (SYN ACK) –Host A sends an ACK to acknowledge the SYN ACK SYN SYN ACK ACK Data A B Each host tells its ISN to the other host.

32 TCP Header Source portDestination port Sequence number Acknowledgment Advertised window HdrLen Flags 0 ChecksumUrgent pointer Options (variable) Data Flags: SYN FIN RST PSH URG ACK

33 Step 1: A’s Initial SYN Packet A’s portB’s port A’s Initial Sequence Number Acknowledgment Advertised window 20 Flags 0 ChecksumUrgent pointer Options (variable) Flags: SYN FIN RST PSH URG ACK A tells B it wants to open a connection…

34 Step 2: B’s SYN-ACK Packet B’s portA’s port B’s Initial Sequence Number A’s ISN plus 1 Advertised window 20 Flags 0 ChecksumUrgent pointer Options (variable) Flags: SYN FIN RST PSH URG ACK B tells A it accepts, and is ready to hear the next byte… … upon receiving this packet, A can start sending data

35 Step 3: A’s ACK of the SYN-ACK A’s portB’s port B’s ISN plus 1 Advertised window 20 Flags 0 ChecksumUrgent pointer Options (variable) Flags: SYN FIN RST PSH URG ACK A tells B it is okay to start sending Sequence number … upon receiving this packet, B can start sending data

36 What if the SYN Packet Gets Lost? Suppose the SYN packet gets lost –Packet is lost inside the network, or –Server rejects the packet (e.g., listen queue is full) Eventually, no SYN-ACK arrives –Sender sets a timer and wait for the SYN-ACK –… and retransmits the SYN if needed How should the TCP sender set the timer? –Sender has no idea how far away the receiver is –Hard to guess a reasonable length of time to wait –Some TCPs use a default of 3 or 6 seconds

37 SYN Loss and Web Downloads User clicks on a hypertext link –Browser creates a socket and does a “connect” –The “connect” triggers the OS to transmit a SYN If the SYN is lost… –The 3-6 seconds of delay may be very long –The user may get impatient –… and click the hyperlink again, or click “reload” User triggers an “abort” of the “connect” –Browser creates a new socket and does a “connect” –Essentially, forces a faster send of a new SYN packet! –Sometimes very effective, and the page comes fast

38 Tearing Down the Connection Closing (each end of) the connection –Finish (FIN) to close and receive remaining bytes –And other host sends a FIN ACK to acknowledge –Reset (RST) to close and not receive remaining bytes SYN SYN ACK ACK Data FIN ACK time A B FIN ACK

39 Sending/Receiving the FIN Packet Sending a FIN: close() –Process is done sending data via the socket –Process invokes “close()” to close the socket –Once TCP has sent all of the outstanding bytes… –… then TCP sends a FIN Receiving a FIN: EOF –Process is reading data from the socket –Eventually, the attempt to read returns an EOF

40 Flow Control: TCP Sliding Window

41 Motivation for Sliding Window Stop-and-wait is inefficient –Only one TCP segment is “in flight” at a time –Especially bad when delay-bandwidth product is high Numerical example –1.5 Mbps link with a 45 msec round-trip time (RTT)  Delay-bandwidth product is 67.5 Kbits (or 8 KBytes) –But, sender can send at most one packet per RTT  Assuming a segment size of 1 KB (8 Kbits)  … leads to 8 Kbits/segment / 45 msec/segment  182 Kbps  That’s just one-eighth of the 1.5 Mbps link capacity

42 Sliding Window Allow a larger amount of data “in flight” –Allow sender to get ahead of the receiver –… though not too far ahead Sending processReceiving process Last byte ACKed Last byte sent TCP Next byte expected Last byte written Last byte read Last byte received

43 Receiver Buffering Window size –Amount that can be sent without acknowledgment –Receiver needs to be able to store this amount of data Receiver advertises the window to the receiver –Tells the receiver the amount of free space left –… and the sender agrees not to exceed this amount Window Size Outstanding Un-ack’d data Data OK to send Data not OK to send yet Data ACK’d

44 TCP Header for Receiver Buffering Source portDestination port Sequence number Acknowledgment Advertised windowHdrLen Flags 0 ChecksumUrgent pointer Options (variable) Data Flags: SYN FIN RST PSH URG ACK

45 Conclusions Transport protocols –Multiplexing and demultiplexing –Checksum-based error detection –Sequence numbers –Retransmission –Window-based flow control Reading for this week –Sections 2.5, , and Next lecture –Congestion control