CSE 4213: Computer Networks II

Similar documents
Suprakash Datta. Office: CSEB 3043 Phone: ext Course page:

32 bits. source port # dest port # sequence number acknowledgement number not used. checksum. Options (variable length)

Transport Layer: outline

Lecture 08: The Transport Layer (Part 2) The Transport Layer Protocol (TCP) Dr. Anis Koubaa

Transport Layer: Outline

Chapter 3 Transport Layer

Chapter 3 Transport Layer

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

Lecture 5. Transport Layer. Transport Layer 1-1

Chapter 3 Transport Layer

Chapter 3 outline. 3.5 connection-oriented transport: TCP segment structure reliable data transfer flow control connection management

Correcting mistakes. TCP: Overview RFCs: 793, 1122, 1323, 2018, TCP seq. # s and ACKs. GBN in action. TCP segment structure

RSC Part III: Transport Layer 3. TCP

Chapter 6 Transport Layer

10 minutes survey (anonymous)

Chapter 3: Transport Layer. Chapter 3 Transport Layer. Chapter 3 outline. Transport services and protocols

Computer Networking Introduction

Chapter 3 Transport Layer

Chapter III: Transport Layer

CS 4390 Computer Networks. Pointers to Corresponding Section of Textbook

Lecture 8. TCP/IP Transport Layer (2)

COMP 431 Internet Services & Protocols. Transport Layer Protocols & Services Outline. The Transport Layer Reliable data delivery & flow control in TCP

Chapter 3 Transport Layer

Chapter 3 Transport Layer

TCP (Part 2) Session 10 INST 346 Technologies, Infrastructure and Architecture

Master Course Computer Networks IN2097

Chapter 3 Transport Layer

CS Lecture 1 Review of Basic Protocols

The Transport Layer Reliable data delivery & flow control in TCP. Transport Layer Protocols & Services Outline

CSCE 463/612 Networks and Distributed Processing Spring 2017

Foundations of Telematics

CSC 4900 Computer Networks: TCP

CSCI Topics: Internet Programming Fall 2008

CSC 401 Data and Computer Communications Networks

CC451 Computer Networks

Chapter 3 outline. 3.5 Connection-oriented transport: TCP. 3.6 Principles of congestion control 3.7 TCP congestion control

The Transport Layer Reliable data delivery & flow control in TCP. Transport Layer Protocols & Services Outline

TCP. TCP: Overview. TCP Segment Structure. Maximum Segment Size (MSS) Computer Networks 10/19/2009. CSC 257/457 - Fall

CNT 6885 Network Review on Transport Layer

Chapter 3- parte B outline

TCP: Overview RFCs: 793, 1122, 1323, 2018, 2581

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

Outline. TCP: Overview RFCs: 793, 1122, 1323, 2018, Development of reliable protocol Sliding window protocols

CS450 Introduc0on to Networking Lecture 14 TCP. Phu Phung Feb 13, 2015

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

Chapter 3 Transport Layer

Outline. TCP: Overview RFCs: 793, 1122, 1323, 2018, steam: r Development of reliable protocol r Sliding window protocols

By Ossi Mokryn, Based also on slides from: the Computer Networking: A Top Down Approach Featuring the Internet by Kurose and Ross

Chapter 3 outline. TDTS06 Computer networks. Principles of Reliable data transfer. Reliable data transfer: getting started

Distributed Systems. 5. Transport Protocols

Computer Communication Networks Midterm Review

Distributed Systems. 5. Transport Protocols. Werner Nutt

Chapter 3 outline. 3.5 Connection-oriented transport: TCP. 3.6 Principles of congestion control 3.7 TCP congestion control

CS 4390 Computer Networks. Transport Services and Protocols

Go-Back-N. Pipelining: increased utilization. Pipelined protocols. GBN: sender extended FSM

Chapter 3 Transport Layer

Fall 2012: FCM 708 Bridge Foundation I

Computer Networking: A Top Down Approach

CSCD 330 Network Programming

Application. Transport. Network. Link. Physical

CMSC 332 Computer Networks Transport Layer

Master Course Computer Networks IN2097

Computer Networks & Security 2016/2017

Chapter 3 Transport Layer

Internet and Intranet Protocols and Applications

The Transport Layer: TCP & Reliable Data Transfer

Chapter 3: Transport Layer

Transmission Control Protocol

Chapter III: Transport Layer

Chapter 3: Transport Layer Part A

TCP : Fundamentals of Computer Networks Bill Nace

Transport Layer. Chapter 3: Transport Layer

CSC 401 Data and Computer Communications Networks

Chapter 3 Transport Layer

TCP. 1 Administrivia. Tom Kelliher, CS 325. Apr. 2, Announcements. Assignment. Read From Last Time

Chapter III: Transport Layer

Transport layer. Our goals: Understand principles behind transport layer services: Learn about transport layer protocols in the Internet:

Transport layer: Outline

Chapter 3 Transport Layer

LECTURE 3 - TRANSPORT LAYER

CSC 4900 Computer Networks: Transport Layer

CSC358 Week 4. Adapted from slides by J.F. Kurose and K. W. Ross. All material copyright J.F Kurose and K.W. Ross, All Rights Reserved

COSC4377. Useful Linux Tool: screen

CSEN 503 Introduction to Communication Networks. Mervat AbuElkheir Hana Medhat Ayman Dayf. ** Slides are attributed to J. F.

Chapter 3 Transport Layer

TCP: Overview RFCs: 793,1122,1323, 2018, 2581

Our goals: understand d principles. behind transport layer protocols in the. Internet: layer services:

Transport services and protocols. Chapter 3 outline. Internet transport-layer protocols Chapter 3 outline. Multiplexing/demultiplexing

Input ports, switching fabric, output ports Switching via memory, bus, crossbar Queueing, head-of-line blocking

Lecture 12: Transport Layer TCP again

CC451 Computer Networks

Chapter 3 outline. Chapter 3: Transport Layer. Transport vs. network layer. Transport services and protocols. Internet transport-layer protocols

Computer Communication Networks Midterm Review

Chapter 3: Transport Layer. Chapter 3 Transport Layer. Chapter 3 outline. Transport services and protocols

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

Chapter 3 Transport Layer

Transport Protocols and TCP

Chapter 3 Transport Layer

Chapter 3: Transport Layer. Chapter 3 Transport Layer. Chapter 3 outline. Transport services and protocols

Development of reliable protocol Sliding window protocols. C = channel capacity in bps I = interrupt/service time + propagation delay

Transcription:

Next CSE 4213: Computer Networks II The layer Suprakash Datta datta@cs.yorku.ca Office: CSEB 3043 Phone: 416-736-2100 ext 77875 Course page: http://www.cs.yorku.ca/course/4213 These slides are adapted from Jim Kurose s slides. 1/31/2007 COSC 4213 - S.Datta 1 1/31/2007 COSC 4213 - S.Datta 2 Chapter 3: Transport Layer Our goals: understand principles behind layer services: multiplexing/demultiplexin g congestion learn about layer protocols in the Internet: UDP: connectionless TCP: connection-oriented TCP congestion 3.1 Transport-layer services 3.3 Connectionless : UDP 3.4 Principles of reliable data transfer - LEAVE OUT : TCP 3.6 Principles of congestion 3.7 TCP congestion 1/31/2007 COSC 4213 - S.Datta 3 1/31/2007 COSC 4213 - S.Datta 4 Transport services and protocols Transport vs. layer provide logical communication between app processes running on different hosts protocols run in end systems send side: breaks app messages into segments, passes to layer rcv side: reassembles segments into messages, passes to app layer more than one protocol available to apps Internet: TCP and UDP logical end-end layer: logical communication between hosts layer: logical communication between processes relies on, enhances, layer services Household analogy: 12 kids sending letters to 12 kids processes = kids app messages = letters in envelopes hosts = houses protocol = Ann and Bill -layer protocol = postal service 1/31/2007 COSC 4213 - S.Datta 5 1/31/2007 COSC 4213 - S.Datta 6

Internet -layer protocols reliable, in-order delivery (TCP) congestion connection setup unreliable, unordered delivery: UDP no-frills extension of besteffort IP services not available: delay guarantees bandwidth guarantees logical end-end 3.1 Transport-layer services 3.3 Connectionless : UDP 3.4 Principles of reliable data transfer : TCP 3.6 Principles of congestion 3.7 TCP congestion 1/31/2007 COSC 4213 - S.Datta 7 1/31/2007 COSC 4213 - S.Datta 8 Multiplexing/ How works Demultiplexing at rcv host: delivering received segments to correct socket link = socket P3 = process P1 P1 link host 1 host 2 Multiplexing at send host: gathering data from multiple sockets, enveloping data with header (later used for ) P2 P4 host 3 link host receives IP datagrams each datagram has source IP address, destination IP address each datagram carries 1 -layer segment each segment has source, destination port number (recall: well-known port numbers for specific s) host uses IP addresses & port numbers to direct segment to appropriate socket 32 bits source port # dest port # other header fields data (message) TCP/UDP segment format 1/31/2007 COSC 4213 - S.Datta 9 1/31/2007 COSC 4213 - S.Datta 10 Connectionless Create sockets with port numbers: DatagramSocket mysocket1 = new DatagramSocket(99111); DatagramSocket mysocket2 = new DatagramSocket(99222); UDP socket identified by two-tuple: (dest IP address, dest port number) When host receives UDP segment: checks destination port number in segment directs UDP segment to socket with that port number IP datagrams with different source IP addresses and/or source port numbers directed to same socket Connectionless demux (cont) DatagramSocket Socket = new DatagramSocket(6428); P2 IP: A DP: 6428 SP: 6428 DP: 9157 P3 IP: C SP: 6428 DP: 5775 SP: 5775 DP: 6428 P1P1 Client IP:B SP provides return address 1/31/2007 COSC 4213 - S.Datta 11 1/31/2007 COSC 4213 - S.Datta 12

Connection-oriented demux Connection-oriented demux (cont) TCP socket identified by 4- tuple: source IP address source port number dest IP address dest port number recv host uses all four values to direct segment to appropriate socket Server host may support many simultaneous TCP sockets: each socket identified by its own 4-tuple Web s have different sockets for each connecting non-persistent HTTP will have different socket for each request P1 IP: A S-IP: A P4 IP: C P5 P6 P2 P1P3 SP: 5775 S-IP: B S-IP: B Client IP:B 1/31/2007 COSC 4213 - S.Datta 13 1/31/2007 COSC 4213 - S.Datta 14 Connection-oriented demux: Threaded Web Server 3.1 Transport-layer services : TCP P1 IP: A S-IP: A P4 IP: C SP: 5775 S-IP: B S-IP: B P2 P1P3 Client IP:B 3.3 Connectionless : UDP 3.4 Principles of reliable data transfer 3.6 Principles of congestion 3.7 TCP congestion 1/31/2007 COSC 4213 - S.Datta 15 1/31/2007 COSC 4213 - S.Datta 16 UDP: User Datagram Protocol [RFC 768] UDP: more no frills, bare bones Internet protocol best effort service, UDP segments may be: lost delivered out of order to app connectionless: no handshaking between UDP sender, receiver each UDP segment handled independently of others Why is there a UDP? no connection establishment (which can add delay) simple: no connection state at sender, receiver small segment header no congestion : UDP can blast away as fast as desired often used for streaming multimedia apps loss tolerant Length, in rate sensitive bytes of UDP segment, other UDP uses including DNS header SNMP reliable transfer over UDP: add reliability at layer -specific error recovery! source port # dest port # length 32 bits Application data (message) checksum UDP segment format 1/31/2007 COSC 4213 - S.Datta 17 1/31/2007 COSC 4213 - S.Datta 18

Sender: treat segment contents as sequence of 16-bit integers checksum: addition (1 s complement sum) of segment contents sender puts checksum value into UDP checksum field UDP checksum Goal: detect errors (e.g., flipped bits) in transmitted segment Receiver: compute checksum of received segment check if computed checksum equals checksum field value: NO - error detected YES - no error detected. But maybe errors nonetheless? More later. 1/31/2007 COSC 4213 - S.Datta 19 Note Internet Checksum Example When adding numbers, a carryout from the most significant bit needs to be added to the result Example: add two 16-bit integers wraparound sum checksum 1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 0 1 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 1 1/31/2007 COSC 4213 - S.Datta 20 3.1 Transport-layer services 3.3 Connectionless : UDP 3.4 Principles of reliable data transfer : TCP 3.6 Principles of congestion 3.7 TCP congestion TCP: Overview RFCs: 793, 1122, 1323, 2018, 2581 point-to-point: one sender, one receiver reliable, in-order byte steam: no message boundaries pipelined: TCP congestion and flow set window size send & receive buffers full duplex data: bi-directional data flow in same connection MSS: maximum segment size connection-oriented: handshaking (exchange of msgs) init s sender, receiver state before data exchange led: sender will not overwhelm receiver socket door writes data TCP send buffer reads data TCP receive buffer socket door segment 1/31/2007 COSC 4213 - S.Datta 21 1/31/2007 COSC 4213 - S.Datta 22 TCP segment structure TCP seq. # s and ACKs URG: urgent data (generally not used) ACK: ACK # valid PSH: push data now (generally not used) RST, SYN, FIN: connection estab (setup, teardown commands) Internet checksum (as in UDP) 32 bits source port # dest port # sequence number acknowledgement number head not UAP len used R S F Receive window checksum Urg data pnter Options (variable length) data (variable length) counting by bytes of data (not segments!) # bytes rcvr willing to accept Seq. # s: byte stream number of first byte in segment s data ACKs: seq # of next byte expected from other side cumulative ACK Q: how receiver handles outof-order segments A: TCP spec doesn t say, - up to implementor User types C host ACKs receipt of echoed C Host A Host B Seq=42, ACK=79, data = C Seq=79, ACK=43, data = C Seq=43, ACK=80 simple telnet scenario host ACKs receipt of C, echoes back C time 1/31/2007 COSC 4213 - S.Datta 23 1/31/2007 COSC 4213 - S.Datta 24

TCP Round Trip Time and Timeout TCP Round Trip Time and Timeout Q: how to set TCP timeout value? longer than RTT but RTT varies too short: premature timeout unnecessary retransmissions too long: slow reaction to segment loss Q: how to estimate RTT? SampleRTT: measured time from segment transmission until ACK receipt ignore retransmissions SampleRTT will vary, want estimated RTT smoother average several recent measurements, not just current SampleRTT EstimatedRTT = (1- α)*estimatedrtt + α*samplertt Exponential weighted moving average influence of past sample decreases exponentially fast typical value: α = 0.125 1/31/2007 COSC 4213 - S.Datta 25 1/31/2007 COSC 4213 - S.Datta 26 Example RTT estimation: TCP Round Trip Time and Timeout 350 300 RTT: gaia.cs.umass.edu to fantasia.eurecom.fr Setting the timeout EstimtedRTT plus safety margin large variation in EstimatedRTT -> larger safety margin first estimate of how much SampleRTT deviates from EstimatedRTT: RTT (milliseconds) 250 200 DevRTT = (1-β)*DevRTT + β* SampleRTT-EstimatedRTT 150 100 1 8 15 22 29 36 43 50 57 64 71 78 85 92 99 106 time (seconnds) (typically, β = 0.25) Then set timeout interval: TimeoutInterval = EstimatedRTT + 4*DevRTT SampleRTT Estimated RTT 1/31/2007 COSC 4213 - S.Datta 27 1/31/2007 COSC 4213 - S.Datta 28 TCP reliable data transfer 3.1 Transport-layer services 3.3 Connectionless : UDP 3.4 Principles of reliable data transfer : TCP 3.6 Principles of congestion 3.7 TCP congestion TCP creates rdt service on top of IP s unreliable service Pipelined segments Cumulative acks TCP uses single retransmission timer Retransmissions are triggered by: timeout events duplicate acks Initially consider simplified TCP sender: ignore duplicate acks ignore flow, congestion 1/31/2007 COSC 4213 - S.Datta 29 1/31/2007 COSC 4213 - S.Datta 30

TCP sender events: NextSeqNum = InitialSeqNum SendBase = InitialSeqNum data rcvd from app: Create segment with seq # seq # is byte-stream number of first data byte in segment start timer if not already running (think of timer as for oldest unacked segment) expiration interval: TimeOutInterval timeout: retransmit segment that caused timeout restart timer Ack rcvd: If acknowledges previously unacked segments update what is known to be acked start timer if there are outstanding segments loop (forever) { switch(event) event: data received from above create TCP segment with sequence number NextSeqNum if (timer currently not running) start timer pass segment to IP NextSeqNum = NextSeqNum + length(data) event: timer timeout retransmit not-yet-acknowledged segment with smallest sequence number start timer event: ACK received, with ACK field value of y if (y > SendBase) { SendBase = y if (there are currently not-yet-acknowledged segments) start timer } TCP sender (simplified) Comment: SendBase-1: last cumulatively ack ed byte Example: SendBase-1 = 71; y= 73, so the rcvr wants 73+ ; y > SendBase, so that new data is acked 1/31/2007 COSC 4213 - S.Datta 31 } /* end of loop forever */ 1/31/2007 COSC 4213 - S.Datta 32 TCP: retransmission scenarios TCP retransmission scenarios (more) Host A Host B Host A Host B Host A Host B timeout X loss ACK=100 ACK=100 Sendbase = 100 SendBase = 120 Seq=92 timeout Seq=92 timeout Seq=100, 20 bytes data ACK=100 ACK=120 ACK=120 SendBase = 100 SendBase = 120 premature timeout time time lost ACK scenario 1/31/2007 COSC 4213 - S.Datta 33 SendBase = 120 timeout Seq=100, 20 bytes data X loss ACK=120 ACK=100 time Cumulative ACK scenario 1/31/2007 COSC 4213 - S.Datta 34 TCP ACK generation [RFC 1122, RFC 2581] Fast Retransmit Event at Receiver Arrival of in-order segment with expected seq #. All data up to expected seq # already ACKed Arrival of in-order segment with expected seq #. One other segment has ACK pending Arrival of out-of-order segment higher-than-expect seq. #. Gap detected Arrival of segment that partially or completely fills gap TCP Receiver action Delayed ACK. Wait up to 500ms for next segment. If no next segment, send ACK Immediately send single cumulative ACK, ACKing both in-order segments Immediately send duplicate ACK, indicating seq. # of next expected byte Immediate send ACK, provided that segment starts at lower end of gap Time-out period often relatively long: long delay before resending lost packet Detect lost segments via duplicate ACKs. Sender often sends many segments back-to-back If segment is lost, there will likely be many duplicate ACKs. If sender receives 3 ACKs for the same data, it supposes that segment after ACKed data was lost: fast retransmit: resend segment before timer expires 1/31/2007 COSC 4213 - S.Datta 35 1/31/2007 COSC 4213 - S.Datta 36

Fast retransmit algorithm: event: ACK received, with ACK field value of y if (y > SendBase) { SendBase = y if (there are currently not-yet-acknowledged segments) start timer } else { increment count of dup ACKs received for y if (count of dup ACKs received for y = 3) { resend segment with sequence number y } 3.1 Transport-layer services 3.3 Connectionless : UDP 3.4 Principles of reliable data transfer : TCP 3.6 Principles of congestion 3.7 TCP congestion a duplicate ACK for already ACKed segment fast retransmit 1/31/2007 COSC 4213 - S.Datta 37 1/31/2007 COSC 4213 - S.Datta 38 TCP Flow Control TCP Flow : how it works receive side of TCP connection has a receive buffer: app process may be slow at reading from buffer flow sender won t overflow receiver s buffer by transmitting too much, too fast speed-matching service: matching the send rate to the receiving app s drain rate (Suppose TCP receiver discards out-oforder segments) spare room in buffer = RcvWindow = RcvBuffer-[LastByteRcvd - LastByteRead] Rcvr advertises spare room by including value of RcvWindow in segments Sender limits unacked data to RcvWindow guarantees receive buffer doesn t overflow 1/31/2007 COSC 4213 - S.Datta 39 1/31/2007 COSC 4213 - S.Datta 40 3.1 Transport-layer services 3.3 Connectionless : UDP 3.4 Principles of reliable data transfer : TCP 3.6 Principles of congestion 3.7 TCP congestion TCP Connection Management Recall: TCP sender, receiver establish connection before exchanging data segments initialize TCP variables: seq. #s buffers, flow info (e.g. RcvWindow) : connection initiator Socket Socket = new Socket("hostname","port number"); : contacted by Socket connectionsocket = welcomesocket.accept(); Three way handshake: Step 1: host sends TCP SYN segment to specifies initial seq # no data Step 2: host receives SYN, replies with SYNACK segment allocates buffers specifies initial seq. # Step 3: receives SYNACK, replies with ACK segment, which may contain data 1/31/2007 COSC 4213 - S.Datta 41 1/31/2007 COSC 4213 - S.Datta 42

TCP Connection Management (cont.) TCP Connection Management (cont.) Closing a connection: closes socket: Socket.close(); Step 1: end system sends TCP FIN segment to Step 2: receives FIN, replies with ACK. Closes connection, sends FIN. close timed wait closed FIN ACK FIN ACK close Step 3: receives FIN, replies with ACK. Enters timed wait - will respond with ACK to received FINs Step 4:, receives ACK. Connection closed. Note: with small modification, can handle simultaneous FINs. closing timed wait closed FIN ACK FIN ACK closing closed 1/31/2007 COSC 4213 - S.Datta 43 1/31/2007 COSC 4213 - S.Datta 44 TCP Connection Management (cont) TCP lifecycle TCP lifecycle 1/31/2007 COSC 4213 - S.Datta 45