Lecture 5 Transport [Compatibility Mode]

  • Upload
    masih65

  • View
    217

  • Download
    0

Embed Size (px)

Citation preview

  • 8/14/2019 Lecture 5 Transport [Compatibility Mode]

    1/12

    1

    Advanced Computer Networks

    Lecture 5

    The Transport Layer, TransmissionControl Protocol (TCP), and User

    Datagram Protocol (UDP)

    1

    Outline

    The Transport Layer

    The TCP Protocol

    TCP Characteristics TCP Connection setup

    TCP Segments

    TCP Sequence Numbers

    TCP Slidin Window

    2

    Timeouts and Retransmission

    (Congestion Control and Avoidance)

    The UDP Protocol

  • 8/14/2019 Lecture 5 Transport [Compatibility Mode]

    2/12

    2

    The Transport Layer

    What characteristics might it have? Reliable delivery

    Flow control

    3

    Review of the transport layerLeland.Stanford.edu Athena.MIT.edu

    Application Layer

    Nick Dave

    Network La er

    Transport Layer

    O.S. O.S.HeaderData HeaderData

    4

    Link Layer

    HD

    HD

    HD

    HD HD

  • 8/14/2019 Lecture 5 Transport [Compatibility Mode]

    3/12

    3

    Layering: The OSI ModelApplication Application

    layer-to-layer communication

    Session

    Network

    Presentation

    Transport

    Network Network

    Transport

    Session

    Presentation

    Network

    Peer-layer communication

    Router Router

    3

    4

    5

    6

    3

    4

    5

    6

    5

    Link

    PhysicalPhysicalPhysical

    Link LinkLink

    Physical1

    2

    1

    2

    Layering: Our FTP Example

    ApplicationFTP

    Network

    Transport

    Presentation

    SessionTransport

    Network

    ASCII/Binary

    IP

    TCP

    6

    LinkLin

    Physical

    The 7-layer OSI Model The 4-layer Internet Model

    Ethernet

  • 8/14/2019 Lecture 5 Transport [Compatibility Mode]

    4/12

    4

    TCP Characteristics TCP is connection-oriented.

    3-way handshake used for connection setup.

    TCP provides a stream-of-bytesservice. 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-se uenced data is re-se uenced.

    7

    (Window-based) Flow control prevents over-run of receiver.

    TCP uses congestion controlto share networkcapacity among users. Well study this in the nextlecture.

    TCP is connection-oriented

    (Active)Client

    (Passive)Server

    (Active)Client

    (Passive)Server

    Syn + Ack

    Ack

    (Data +) Ack

    Fin

    Ack

    8

    Connection Setup3-way handshake

    Connection Close/Teardown2 x 2-way handshake

  • 8/14/2019 Lecture 5 Transport [Compatibility Mode]

    5/12

    5

    TCP supports a stream of

    bytes serviceHost A

    9

    Host B

    which is emulated using TCPsegments

    Host A

    TCP Data Segment sent when:1. Segment full (MSS bytes),2. Not full, but times out, or3. Pushed by application.

    10

    Host BTCP Data

  • 8/14/2019 Lecture 5 Transport [Compatibility Mode]

    6/12

    6

    The TCP Segment Format

    IP HdrIP Data

    TCP HdrTCP Data

    Src port Dst port

    Sequence #

    Ack Sequence #

    HLEN4

    RSVD6

    URG

    ACK

    PSH

    RST

    SYN

    FIN

    FlagsWindow Size

    0 15 31

    TCP Headerand Data + IP

    Addresses

    Src/dst port numbersand IP addresses

    uniquely identify socket

    11

    (TCP Options)

    TCP Data

    Sequence NumbersHost A

    ISN (initial sequence number)

    TCP Data TCPHDR

    Sequencenumber = 1st

    byte Ack sequencenumber = nextexpected byte

    12

    Host BTCP Data TCP

    HDR

  • 8/14/2019 Lecture 5 Transport [Compatibility Mode]

    7/12

    7

    Initial Sequence Numbers

    (Active)Client

    (Passive)Server

    A

    Syn + Ack +ISNB

    Ack

    13

    Connection Setup3-way handshake

    TCP Sliding Window

    How much data can a TCP sender haveoutstan ing in t e network?

    How much data should TCP retransmitwhen an error occurs? Just selectivelyrepeat the missing data?

    How does the TCP sender avoid over-

    14

    running the receivers buffers?

  • 8/14/2019 Lecture 5 Transport [Compatibility Mode]

    8/12

    8

    TCP Sliding WindowWindow Size

    OutstandingUn-ackd data

    Data OKto send

    Data not OKto send yet

    Data ACKd

    15

    Window is meaningful to the sender. Current window size is advertised by receiver

    (usually 4k 8k Bytes when connection set-up). TCPs Retransmission policy is Go Back N.

    TCP Sliding Window

    Round-trip time

    Round-trip time

    Host A

    Host B

    ???

    16

    (1) RTT > Window size (2) RTT = Window size

  • 8/14/2019 Lecture 5 Transport [Compatibility Mode]

    9/12

    9

    TCP: Retransmission andTimeoutsRound-trip time (RTT) Retransmission TimeOut (RTO)

    Host A

    Host B

    ACK ACK

    Estimated RTT

    Data1 Data2

    GuardBand

    17

    TCP uses an adaptive retransmission timeout value:Congestion

    Changes in RoutingRTT changesfrequently

    TCP: Retransmission and Timeouts

    Picking the RTO is important: Pick a values thats too big and it will wait too long to

    retransmit a acket Pick a value too small, and it will unnecessarily retransmit

    packets.

    The original algorithm for picking RTO:

    1. EstimatedRTTk= EstimatedRTTk-1 + (1 - ) SampleRTT2. RTO = 2 * EstimatedRTT

    Determined

    18

    Characteristics of the original algorithm: Variance is assumed to be fixed. But in practice, variance increases as congestion increases.

  • 8/14/2019 Lecture 5 Transport [Compatibility Mode]

    10/12

    10

    TCP: Retransmission and Timeouts There will be some (unknown) distribution

    of RTTs. We are trying to estimate an RTO to

    Router queues grow when there is moretraffic, until they become unstable.

    As load grows, variance of delay growsminimize t e pro a i ity o a a se timeout.

    Probability

    AverageQueueingDelay

    Variancegrows rapidly

    with load

    rap y.

    19

    RTTmean

    variance

    Load(Amount of traffic

    arriving to router)

    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

    Same as

    before

    20

    1

    4

  • 8/14/2019 Lecture 5 Transport [Compatibility Mode]

    11/12

    11

    TCP: Retransmission and TimeoutsKarns Algorithm

    Host A Host B Host A Host B

    Retransmission

    Wrong RTTSample

    Retransmission

    Wrong RTTSample

    21

    Problem:How can we estimate RTT when packets are retransmitted?Solution:

    On retransmission, dont update estimated RTT (and double RTO).

    User Datagram Protocol (UDP)Characteristics

    UDP is a connectionless datagram service.

    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

    ackets.

    22

    No mechanism for automatic retransmission. No mechanism for flow control, and so can over-run the

    receiver.

  • 8/14/2019 Lecture 5 Transport [Compatibility Mode]

    12/12

    User-Datagram Protocol (UDP)A1 A2 B1 B2

    App App App App

    UDP

    OS

    23

    IP

    Like TCP, UDP usesport number todemultiplex packets

    SRC port DST port

    User-Datagram Protocol (UDP)Packet format

    checksum length

    DATA

    Wh do we have UDP?

    ,covers the header.

    24

    It is used by applications that dont need reliable delivery, or Applications that have their own special needs, such asstreaming of real-time audio/video.