Segment Format

download Segment Format

of 36

Transcript of Segment Format

  • 7/31/2019 Segment Format

    1/36

    CS 640 1

    Data structure and inputprocessing

  • 7/31/2019 Segment Format

    2/36

    CS 640 2

    Transport Control Protocol

    Outline

    TCP objectives revisited

    TCP basics

    New algorithms for RTOcalculation

  • 7/31/2019 Segment Format

    3/36

    CS 640 3

    TCP Overview

    TCP is the most widely used Internet protocol Web, Peer-to-peer, FTP, telnet,

    A two way, reliable, byte stream oriented end-to-endprotocol

    Includes flow and congestion control

    Closely tied to the Internet Protocol (IP)

    A focus of intense study for many years

    Our goal is to understand the RENO version of TCP RENO is most widely used TCP today RFC 2001 (now expired)

    RENO mainly specifies mechanisms for dealing with congestion

  • 7/31/2019 Segment Format

    4/36

    CS 640 4

    TCP Features Connection-oriented

    Byte-stream app writes bytes

    TCP sendssegments

    app reads bytes

    Reliable data transfer

    Application process

    Writebytes

    TCP

    Send buffer

    Segment Segment Segment

    Transmit segments

    Application process

    Readbytes

    TCP

    Receive buffer

    Full duplex

    Flow control: keep sender fromoverrunning receiver

    Congestion control: keepsender from overrunning

    network

  • 7/31/2019 Segment Format

    5/36

    CS 640 5

    12.11 TCP Package

    A TCP package involving a table called

    Transmission Control Blocks, a set of timers, and

    three software modules: main module, inputprocessing module, output processing module.

  • 7/31/2019 Segment Format

    6/36

    CS 640 6

    TCP Package (Contd)

    Transmission Control Block (TCBs)

    To control the connection, TCP uses a structure to hold

    information about each connection TCP keeps an array of TCBs in the form of a table

  • 7/31/2019 Segment Format

    7/36

    CS 640 7

    TCP Package (Contd)

    State : defining the state of the connection according to thestate transition diagram

    Process : defining the process using this connection at this

    machine as a client or a server Local IP address : defining the IP address of the local

    machine used by this connection

    Local port number : defining the local port number used by

    this connection Remote IP address

    Remote port address

    Interface : defining the local interface

    Local window : holding information about the window atthe local TCP

  • 7/31/2019 Segment Format

    8/36

    CS 640 8

    TCP Package (Contd)

    Sending sequence number

    Receiving sequence number

    Sending ACK number

    Time-out values : retransmission time-out,

    persistence time-out, keepalive time-out, and so on

    Buffer size : defining the size of the buffer at thelocal TCP

    Buffer pointer : pointer to buffer where the

    receiving data is kept until is read by the

    application

  • 7/31/2019 Segment Format

    9/36

    CS 640 9

    TCP Package (Contd) Main Module : The main module is invoked by an arrived

    TCP segment, a time-out, or a message from an application

    program

  • 7/31/2019 Segment Format

    10/36

    CS 640 10

    TCP Package (Contd)

    Main Module (contd)

  • 7/31/2019 Segment Format

    11/36

    CS 640 11

    TCP Package (Contd)

    Main Module (contd)

  • 7/31/2019 Segment Format

    12/36

    CS 640 12

    TCP Package (Contd) Main Module (contd)

  • 7/31/2019 Segment Format

    13/36

    CS 640 13

    TCP D Package (Contd) Main Module (contd)

  • 7/31/2019 Segment Format

    14/36

    CS 640 14

    TCP Package (Contd)

    Main Module (contd)

  • 7/31/2019 Segment Format

    15/36

    CS 640 15

    TCP Package (Contd)

    Main Module (contd)

  • 7/31/2019 Segment Format

    16/36

    CS 640 16

    TCP Package (Contd)

    Main Module (contd)

  • 7/31/2019 Segment Format

    17/36

    CS 640 17

    TCP Package (Contd)

    Main Module (contd)

  • 7/31/2019 Segment Format

    18/36

    CS 640 18

    TCP Package (Contd)

    Input processing module

    handles all the details needed to process data or

    acknowledgment received when TCP is in theESTABLISHED state

    sends an ACK if needed, takes care of the window size,

    does error checking, and so on

    Output processing module handles all the details needed to send out data received

    from application program when TCP is in the

    ESTABLISHED state

    handles retransmission time-outs, persistent time-outs,

  • 7/31/2019 Segment Format

    19/36

    CS 640 19

    Segment Format

  • 7/31/2019 Segment Format

    20/36

    CS 640 20

    Segment Format

    Options (variable)

    Data

    Checksum

    SrcPort DstPort

    HdrLen 0 Flags

    UrgPtr

    AdvertisedWindow

    SequenceNum

    Acknowledgment

    0 4 10 16 31

  • 7/31/2019 Segment Format

    21/36

    CS 640 21

    Segment Format (cont) Each connection identified with 4-tuple:

    (SrcPort, SrcIPAddr, DsrPort, DstIPAddr)

    Sliding window + flow control acknowledgment, SequenceNum, AdvertisedWinow

    Flags SYN, FIN, RESET, PUSH, URG, ACK

    Checksum is the same as UDP pseudo header + TCP header + data

    Sender

    Data(SequenceNum)

    Acknowledgment +AdvertisedWindow

    Receiver

  • 7/31/2019 Segment Format

    22/36

    CS 640 22

    Sequence Numbers

    32 bit sequence numbers Wrap around supported

    TCP breaks byte stream from application into packets

    (limited by Max. Segment Size) Each byte in the data stream is considered

    Each packet has a sequence number

    Initial number selected at connection time Subsequent numbers indicate first data byte number in packet

    ACKs indicate next byte expected

  • 7/31/2019 Segment Format

    23/36

    CS 640 23

    Comparison

  • 7/31/2019 Segment Format

    24/36

    CS 640 24

    Sequence Number Wrap Around

    Bandwidth Time Until Wrap Around

    T1 (1.5 Mbps) 6.4 hours

    Ethernet (10 Mbps) 57 minutesT3 (45 Mbps) 13 minutes

    FDDI (100 Mbps) 6 minutes

    STS-3 (155 Mbps) 4 minutes

    STS-12 (622 Mbps) 55 seconds

    STS-24 (1.2 Gbps) 28 seconds

    Protect against this by adding a 32-bit timestamp to TCP header

  • 7/31/2019 Segment Format

    25/36

    CS 640 25

    Connection Establishment

    Active participant(client)

    Passive participant(server)

    SYN,SequenceNum=x

    SYN+AC

    K,Sequen

    ceNum=y

    ,

    ACK,Acknowledgment=y+1

    Acknowled

    gment=x+

    1

  • 7/31/2019 Segment Format

    26/36

    CS 640 26

    Connection TerminationActive participant

    (server)Passive participant

    (client)

    FIN,SequenceNum= x

    Acknowledgment=y+1

    Acknowled

    gment=x+

    1

    FIN,Sequ

    enceNum=

    y

  • 7/31/2019 Segment Format

    27/36

    CS 640 27

    Finite state machineimplementation

  • 7/31/2019 Segment Format

    28/36

    CS 640 28

    State Transition DiagramCLOSED

    LISTEN

    SYN_RCVD SYN_SENT

    ESTABLISHED

    CLOSE_WAIT

    LAST_ACKCLOSING

    TIME_WAIT

    FIN_WAIT_2

    FIN_WAIT_1

    Passive open Close

    Send/SYN

    SYN/SYN + ACK

    SYN + ACK/ACK

    SYN/SYN + ACK

    ACK

    Close/FIN

    FIN/ACKClose/FIN

    FIN/ACKACK+FIN

    /ACK

    Timeout after twosegment lifetimes

    FIN/ACK

    ACK

    ACK

    ACK

    Close/FIN

    Close

    CLOSED

    Active open/SYN

  • 7/31/2019 Segment Format

    29/36

    CS 640 29

    Reliability in TCP

    Checksum used to detect bit level errors

    Sequence numbers used to detect sequencing errors

    Duplicates are ignored Reordered packets are reordered (or dropped)

    Lost packets are retransmitted

    Timeouts used to detect lost packets

    Requires RTO calculation

    Requires sender to maintain data until it is ACKed

  • 7/31/2019 Segment Format

    30/36

    CS 640 30

    Sliding Window Revisited

    Sending side LastByteAcked< =LastByteSent

    LastByteSent < =

    LastByteWritten buffer bytes between

    LastByteAckedandLastByteWritten

    Sending application

    LastByteWritten

    TCP

    LastByteSentLastByteAcked

    Receiving application

    LastByteRead

    TCP

    LastByteRcvdNextByteExpected

    Receiving side LastByteReadMaxSenderBuffer

    Always send ACK in response to arriving data segment

    Persist sending one byte seg. whenAdvertisedWindow= 0

  • 7/31/2019 Segment Format

    32/36

    CS 640 32

    Keeping the Pipe Full

    16-bitAdvertisedWindow controls amount of pipelining

    Assume RTT of 100ms

    Add scaling factor extension to header to enable larger windows

    Bandwidth Delay x Bandwidth Product

    T1 (1.5 Mbps) 18KB

    Ethernet (10 Mbps) 122KB

    T3 (45 Mbps) 549KB

    FDDI (100 Mbps) 1.2MBOC-3 (155 Mbps) 1.8MB

    OC-12 (622 Mbps) 7.4MB

    OC-24 (1.2 Gbps) 14.8MB

  • 7/31/2019 Segment Format

    33/36

    CS 640 33

    Making TCP More Efficient

    Delayed acknowledgements

    Delay for about 200ms

    Try to piggyback ACKs with data Acknowledge every other packet

    Many instances in transmission sequence which require

    an ACK

    Dont forget Nagles algorithm

    Can be switched off

  • 7/31/2019 Segment Format

    34/36

    CS 640 34

    Karn/Partridge Algorithm for RTO

    Two degenerate cases with timeouts and RTT measurements Solution: Do not sample RTT when retransmitting

    After each retransmission, set next RTO to be double the valueof the last Exponential backoff is well known control theory method

    Loss is most likely caused by congestion so be careful

    Sender Receiver

    Originaltransmission

    ACK

    SampleRTT

    Retransmission

    Sender Receiver

    Originaltransmission

    ACK

    SampleRTT

    Retransmission

  • 7/31/2019 Segment Format

    35/36

    CS 640 35

    Jacobson/ Karels Algorithm

    In late 80s, Internet was suffering from congestion collapse New Calculations for average RTT Jacobson 88

    Variance is not considered when setting timeout value If variance is small, we could set RTO = EstRTT

    If variance is large, we may need to set RTO > 2 x EstRTT

    New algorithm calculates both variance and mean for RTT

    Diff = sampleRTT - EstRTT

    EstRTT = EstRTT + (dx Diff) Dev = Dev + d ( |Diff| - Dev)

    Initially settings forEstRTT and Dev will be given to you where d is a factor between 0 and 1

    typical value is 0.125

  • 7/31/2019 Segment Format

    36/36

    CS 640 36

    Jacobson/ Karels contd.

    TimeOut = xEstRTT + xDev where = 1 and = 4

    When variance is small, TimeOut is close to EstRTT

    When variance is large Dev dominates the calculation

    Another benefit of this mechanism is that it is very efficient toimplement in code (does not require floating point)

    Notes algorithm only as good as granularity of clock (500ms on Unix)

    accurate timeout mechanism important to congestion control (later)

    These issues have been studied and dealt with in new RFCsfor RTO calculation.

    TCP RENO uses Jacobson/Karels