cs244a an introduction to computer networks n.
Download
Skip this Video
Download Presentation
CS244a: An Introduction to Computer Networks

Loading in 2 Seconds...

play fullscreen
1 / 24

CS244a: An Introduction to Computer Networks - PowerPoint PPT Presentation


  • 108 Views
  • Uploaded on

CS244a: An Introduction to Computer Networks. Handout 6: The Transport Layer, Transmission Control Protocol (TCP), and User Datagram Protocol (UDP). Nick McKeown Professor of Electrical Engineering and Computer Science, Stanford University nickm@stanford.edu http://www.stanford.edu/~nickm.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'CS244a: An Introduction to Computer Networks' - cooper-davidson


Download Now An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
cs244a an introduction to computer networks

CS244a: An Introduction to Computer Networks

Handout 6: The Transport Layer, Transmission Control Protocol (TCP), and User Datagram Protocol (UDP)

Nick McKeown

Professor of Electrical Engineering

and Computer Science, Stanford University

nickm@stanford.edu

http://www.stanford.edu/~nickm

CS244a Handout #6

outline
Outline
  • The Transport Layer
  • The TCP Protocol
    • TCP Characteristics
    • TCP Connection setup
    • TCP Segments
    • TCP Sequence Numbers
    • TCP Sliding Window
    • Timeouts and Retransmission
    • (Congestion Control and Avoidance)
  • The UDP Protocol

CS244a Handout #6

the transport layer
The Transport Layer
  • What is the transport layer for?
  • What characteristics might it have?
    • Reliable delivery
    • Flow control

CS244a Handout #6

review of the transport layer

Application Layer

Transport Layer

O.S.

O.S.

Link Layer

Network Layer

D

D

D

D

D

D

H

H

H

H

H

H

Data

Data

Header

Header

Review of the transport layer

Athena.MIT.edu

Leland.Stanford.edu

Nick

Dave

CS244a Handout #6

layering the osi model
Layering: The OSI Model

layer-to-layer communication

Application

Application

7

7

Presentation

Presentation

6

6

Session

Session

5

5

Peer-layer communication

Transport

Transport

Router

Router

4

4

Network

Network

Network

Network

3

3

Link

Link

Link

Link

2

2

Physical

Physical

Physical

Physical

1

1

CS244a Handout #6

layering our ftp example

FTP

ASCII/Binary

TCP

IP

Ethernet

Layering: Our FTP Example

Application

Application

Presentation

Transport

Session

Transport

Network

Network

Link

Link

Physical

The 4-layer Internet model

The 7-layer OSI Model

CS244a Handout #6

tcp characteristics
TCP Characteristics
  • TCP is connection-oriented.
    • 3-way handshake used for connection setup.
  • TCP provides a stream-of-bytes service.
  • TCP is reliable:
    • Acknowledgements indicate delivery of data.
    • Checksums are used to detect corrupted data.
    • Sequence numbers detect missing, or mis-sequenced data.
    • Corrupted data is retransmitted after a timeout.
    • Mis-sequenced data is re-sequenced.
    • (Window-based) Flow control prevents over-run of receiver.
  • TCP uses congestion control to share network capacity among users. We’ll study this in the next lecture.

CS244a Handout #6

tcp is connection oriented
TCP is connection-oriented

(Active)

Client

(Passive)

Server

(Active)

Client

(Passive)

Server

Syn

Fin

Syn + Ack

(Data +) Ack

Ack

Fin

Ack

Connection Setup

3-way handshake

Connection Close/Teardown

2 x 2-way handshake

CS244a Handout #6

tcp supports a stream of bytes service
TCP supports a “stream of bytes” service

Host A

Byte 0

Byte 1

Byte 2

Byte 3

Byte 80

Host B

Byte 0

Byte 1

Byte 2

Byte 3

Byte 80

CS244a Handout #6

which is emulated using tcp segments
…which is emulated using TCP “segments”

Host A

Byte 0

Byte 1

Byte 2

Byte 3

Byte 80

  • Segment sent when:
  • Segment full (MSS bytes),
  • Not full, but times out, or
  • “Pushed” by application.

TCP Data

TCP Data

Host B

Byte 0

Byte 1

Byte 2

Byte 3

Byte 80

CS244a Handout #6

the tcp segment format
The TCP Segment Format

IP Data

IP Hdr

TCP Data

TCP Hdr

0

15

31

Src port

Dst port

Sequence #

Src/dst port numbers

and IP addresses uniquely identify socket

Ack Sequence #

TCP Header and Data + IP Addresses

Flags

Window Size

RSVD

6

HLEN

4

SYN

PSH

URG

RST

FIN

ACK

Checksum

Urg Pointer

(TCP Options)

TCP Data

CS244a Handout #6

sequence numbers
Sequence Numbers

Host A

ISN (initial sequence number)

Sequence number = 1st byte

TCP

HDR

TCP Data

Ack sequence number = next expected byte

TCP

HDR

TCP Data

Host B

CS244a Handout #6

initial sequence numbers
Initial Sequence Numbers

(Active)

Client

(Passive)

Server

Syn +ISNA

Syn + Ack +ISNB

Ack

Connection Setup

3-way handshake

CS244a Handout #6

tcp sliding window
TCP Sliding Window
  • How much data can a TCP sender have outstanding in the network?
  • How much data should TCP retransmit when an error occurs? Just selectively repeat the missing data?
  • How does the TCP sender avoid over-running the receiver’s buffers?

CS244a Handout #6

tcp sliding window1
TCP Sliding Window

Window Size

Data ACK’d

Outstanding

Un-ack’d data

Data OK

to send

Data not OK

to send yet

  • Window is meaningful to the sender.
  • Current window size is “advertised” by receiver
  • (usually 4k – 8k Bytes when connection set-up).
  • TCP’s Retransmission policy is “Go Back N”.

CS244a Handout #6

tcp sliding window2

Round-trip time

Window Size

Window Size

???

ACK

(2) RTT = Window size

TCP Sliding Window

Round-trip time

Window Size

Host A

Host B

ACK

ACK

(1) RTT > Window size

CS244a Handout #6

tcp retransmission and timeouts
TCP: Retransmission and Timeouts

Round-trip time (RTT)

Retransmission TimeOut (RTO)

Guard Band

Host A

Estimated RTT

Data1

Data2

ACK

ACK

Host B

  • TCP uses an adaptive retransmission timeout value:
        • Congestion
        • Changes in Routing

RTT changes frequently

CS244a Handout #6

tcp retransmission and timeouts1
TCP: Retransmission and Timeouts
  • Picking the RTO is important:
    • Pick a values that’s too big and it will wait too long to retransmit a packet,
    • Pick a value too small, and it will unnecessarily retransmit packets.
  • The original algorithm for picking RTO:
  • EstimatedRTTk=  EstimatedRTTk-1 + (1 - ) SampleRTT
  • RTO = 2 * EstimatedRTT
  • Characteristics of the original algorithm:
    • Variance is assumed to be fixed.
    • But in practice, variance increases as congestion increases.

Determined empirically

CS244a Handout #6

tcp retransmission and timeouts2

Average Queueing Delay

Variance grows rapidly with load

Load

(Amount of traffic

arriving to router)

TCP: Retransmission and Timeouts
  • Router queues grow when there is more traffic, until they become unstable.
  • As load grows, variance of delay grows rapidly.
  • There will be some (unknown) distribution of RTTs.
  • We are trying to estimate an RTO to minimize the probability of a false timeout.

Probability

variance

RTT

mean

CS244a Handout #6

tcp retransmission and timeouts3
TCP: Retransmission and Timeouts
  • Newer Algorithm includes estimate of variance in RTT:
  • Difference = SampleRTT - EstimatedRTT
  • EstimatedRTTk = EstimatedRTTk-1 + (*Difference)
  • Deviation = Deviation + *( |Difference| - Deviation )
  • RTO =  * EstimatedRTT +  * Deviation
          •   1
          •   4

Same as before

CS244a Handout #6

tcp retransmission and timeouts karn s algorithm
TCP: Retransmission and TimeoutsKarn’s Algorithm

Host A

Host B

Host A

Host B

Retransmission

Retransmission

Wrong RTT Sample

Wrong RTT Sample

Problem:

How can we estimate RTT when packets are retransmitted?

Solution:

On retransmission, don’t update estimated RTT (and double RTO).

CS244a Handout #6

user datagram protocol udp characteristics
User Datagram Protocol (UDP) Characteristics
  • UDP is a connectionless datagram service.
    • There is no connection establishment: packets may show up at any time.
  • UDP packets are self-contained.
  • UDP is unreliable:
    • No acknowledgements to indicate delivery of data.
    • Checksums cover the header, and only optionally cover the data.
    • Contains no mechanism to detect missing or mis-sequenced packets.
    • No mechanism for automatic retransmission.
    • No mechanism for flow control, and so can over-run the receiver.

CS244a Handout #6

user datagram protocol udp
User-Datagram Protocol (UDP)

A1

A2

B1

B2

App

App

App

App

OS

UDP

Like TCP, UDP uses port number to demultiplex packets

IP

CS244a Handout #6

user datagram protocol udp packet format
User-Datagram Protocol (UDP)Packet format

SRC port

DST port

By default, only covers the header.

checksum

length

DATA

  • Why do we have UDP?
    • It is used by applications that don’t need reliable delivery, or
    • Applications that have their own special needs, such as streaming of real-time audio/video.

CS244a Handout #6