09cs 6048 amrik singh sidhu

Upload: amriksingh24

Post on 30-May-2018

227 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/14/2019 09CS 6048 Amrik Singh Sidhu

    1/63

    09CS 6048 Amrik Singh SidhuTransport Layer

  • 8/14/2019 09CS 6048 Amrik Singh Sidhu

    2/63

    THE BASICSADDRESSING &CONNECTIONS

    BUFFERS &FLOWMANAGEMENT

    TCP

    PREVIEW

  • 8/14/2019 09CS 6048 Amrik Singh Sidhu

    3/63

    THE BASICS

    Transport Layer

  • 8/14/2019 09CS 6048 Amrik Singh Sidhu

    4/63

    Where are we?

    Connection controlSequencingApplicationMultiplexing

    Congestion controlFlow controlError control

    Where are We?????

  • 8/14/2019 09CS 6048 Amrik Singh Sidhu

    5/63

    Provides Efficient, Reliable, Cost Effective Service

    Software/ hardware within the tpt layer that does the work is

    called theTransport Entity.

    Types of Services

    Connection Oriented

    Connection Less

    Same type of services are provided by NW Layer. Why therepetition?

    Services Provided to Transport Layer

  • 8/14/2019 09CS 6048 Amrik Singh Sidhu

    6/63

    Users have no control over the subnet - cannot solve theproblem of poor service

    Another layer on top of NW layer reqd to improve qualityof service.

    Existence of tpt layer makes it possible for tpt service to bemore reliable than underlying NW service.

    Isolate upper layers from technology, design andimperfections of the subnet

    Requirement of a Tpt Layer

  • 8/14/2019 09CS 6048 Amrik Singh Sidhu

    7/63

    The network, transport, and application layers.

    Services Provided to the Upper Layers

  • 8/14/2019 09CS 6048 Amrik Singh Sidhu

    8/63

    Provide application-to-application communication

    Need extended addressing mechanism to identify applications

    First end-to-end layer

    Provides:

    Reliability

    Flow Control

    Congestion Control

    Transport interface allows application programs to establish, use,

    and release connections.

    Transport Protocols

  • 8/14/2019 09CS 6048 Amrik Singh Sidhu

    9/63

    Explicit addressing scheme reqd for destinations

    Connection establishment

    Release of connections

    Storage capacity of the subnet

    Buffering and Flow control

    Crash Recovery

    Elements of Transport Protocols

  • 8/14/2019 09CS 6048 Amrik Singh Sidhu

    10/63

    ADDRESSING

    Transport Layer

  • 8/14/2019 09CS 6048 Amrik Singh Sidhu

    11/63

    TSAP: Transport Service Access Point

    Communication End Points

    Define a tpt address to which processes can listen for

    connection requests. End points (Also called Sockets) consist of an IP address

    and a Local Port Number (16 bit in case of TCP)

    NSAP : Network Service Access Point

    32 bit IP address

    TSAP = NSAP + Local Port Number

    Addressing

  • 8/14/2019 09CS 6048 Amrik Singh Sidhu

    12/63TSAPs, NSAPs and transport connections

    Addressing

  • 8/14/2019 09CS 6048 Amrik Singh Sidhu

    13/63

    How do you know the destination TSAP ?

    Well known ports are one way.

    But to cater for lesser well known services the schemesused are :

    Initial Connection RequestEvery machine runs a special processserver that acts as a proxy for lesser used services.

    Name Server / Directory Server

    Addressing

  • 8/14/2019 09CS 6048 Amrik Singh Sidhu

    14/63

    Name Server/ Directory Server

    Name/Directory Server listens to a well known port

    User sets up a connection to the Name/Directory Server User sends a message specifying the service name.

    Name Server sends back the TSAP address.

    User then releases the connection with Name Server andestablishes new connection with desired service.

    When a new service is created it registers itself with Name

    Server giving its Service name and TSAP address.

    AddressingAlternate Scheme

  • 8/14/2019 09CS 6048 Amrik Singh Sidhu

    15/63

    CONNECTIONS

    Transport Layer

  • 8/14/2019 09CS 6048 Amrik Singh Sidhu

    16/63

    Clock based numbering scheme

    Each host equipped with a clock

    A clock is assumed to be running even if the host isdown

    Lower order bits of the clock used as sequencenumber

    Each connection starts numbering its TPDU with aunique sequence number

    Connection Establishment

  • 8/14/2019 09CS 6048 Amrik Singh Sidhu

    17/63

    Connection Establishment

    Three-way Handshake Protocol for Connection Est.

    Connection Establishment

  • 8/14/2019 09CS 6048 Amrik Singh Sidhu

    18/63

    Three-way Handshake Protocol

    Old CONNECTION REQUEST appearing out of nowhere.

    Three Way Hanshake Protocol

  • 8/14/2019 09CS 6048 Amrik Singh Sidhu

    19/63

    Three-way Handshake Protocol

    Duplicate CR and duplicate ACK.

    Three Way Hanshake Protocol

  • 8/14/2019 09CS 6048 Amrik Singh Sidhu

    20/63

    Connection Release

    Two types of connection release:

    Symmetric- Each side closes connection independently

    Asymmetric- Either side sends a DISCONNECTTPDU. Upon arrival the connection is released.

    Asymmetric release is abrupt and may leadto loss of data

    Connection Release

  • 8/14/2019 09CS 6048 Amrik Singh Sidhu

    21/63

    Asymmetric Connection Release

    Abrupt disconnection with loss of data.

    Asymmetric Connection Release

  • 8/14/2019 09CS 6048 Amrik Singh Sidhu

    22/63

    Symmetric Connection Release

    Connection in each direction is closedindependently

    Here host can continue to receive data even afterit has sent a Disconnection TPDU.

    Symmetric Connection Release

  • 8/14/2019 09CS 6048 Amrik Singh Sidhu

    23/63

    Connection Release

    Consider a protocol as follows:

    Host 1: I am done, are you done! Host 2: I am done too. Goodbye.

    Connection is safely released.

    Will this work?

    Connection Release

  • 8/14/2019 09CS 6048 Amrik Singh Sidhu

    24/63

    Connection Release

    The two-army problem.

    Connection Release

  • 8/14/2019 09CS 6048 Amrik Singh Sidhu

    25/63

    Three-way Handshake ProtocolNormal case.

    Connection Release - Solution

  • 8/14/2019 09CS 6048 Amrik Singh Sidhu

    26/63

    Connection Release - Solution

    Final ACK lost.

    Connection Release - Solution

  • 8/14/2019 09CS 6048 Amrik Singh Sidhu

    27/63

    Connection Release - Solution

    Response lost.

    Connection Release - Solution

  • 8/14/2019 09CS 6048 Amrik Singh Sidhu

    28/63

    Response lost and subsequent DRs lost .

    Connection Release - Solution

  • 8/14/2019 09CS 6048 Amrik Singh Sidhu

    29/63

    Buffers & Flow Control

    Transport Layer

  • 8/14/2019 09CS 6048 Amrik Singh Sidhu

    30/63

    Flow Control and Buffering

    A Sliding Window protocol required toavoid swamping of a slower receiverby a faster sender.

    Requirement of Buffers

    For an unreliable Network service buffering reqdat the sender end.

    Buffering reqd at the receiver for a protocol

    working on the basis of Selective repeat.

    Flow Control & Buffering

  • 8/14/2019 09CS 6048 Amrik Singh Sidhu

    31/63

    Flow Control and Buffering

    Size of the buffer a crucial issue.

    Fixed size buffers

    Buffer size = Size of the largest possible TPDU Buffer size < Size of the largest possible TPDU

    Unused space

    Chained fixed sizebuffers

    Flow Control & Buffering

  • 8/14/2019 09CS 6048 Amrik Singh Sidhu

    32/63

    Flow Control and Buffering

    Variable size buffers - Better memory utilizationbut complicated buffer management

    Unused space

    Chained variablesize buffers

    Flow Control & Buffering

  • 8/14/2019 09CS 6048 Amrik Singh Sidhu

    33/63

    Flow Control and Buffering

    Unused space

    TPDU 1

    TPDU 2

    TPDU 3

    Single Large circularbuffer per Connection

    Flow Control & Buffering

  • 8/14/2019 09CS 6048 Amrik Singh Sidhu

    34/63

    BufferingTrade Offs

    For low bandwidth bursty traffic, buffering should beconcentrated at the sender side.

    For high bandwidth smooth traffic, buffering capacity at thereceiver side should be more

    Sender and Receiver should dynamically adjust their bufferallocations as per changes in traffic pattern.

    BufferingTrade Offs

  • 8/14/2019 09CS 6048 Amrik Singh Sidhu

    35/63

    Buffering - Dynamic Allocation

    Tpt layer protocol should thus allow sender torequest buffer space at receive end.

    Sender requests for allocation of buffers usingcontrol TPDUs and receiver grants as many as itcan afford.

    Sender decrements allocation on everytransmission and stops when allocation reached

    zero.

    BufferingDynamic Allocation

  • 8/14/2019 09CS 6048 Amrik Singh Sidhu

    36/63

    Receiver piggybacks ACKs and fresh bufferallocation onto reverse traffic.

    Here, buffering is decoupled from ACKs resulting

    in variable size sliding window protocol.

    Control TPDUs may be lost resulting in deadlock.

    Thus, control TDPUs sent periodically givingbuffer status.

    BufferingDynamic Allocation

  • 8/14/2019 09CS 6048 Amrik Singh Sidhu

    37/63

    Dynamic Buffer Allocation

    PROTOCOLS

    Transport Layer

  • 8/14/2019 09CS 6048 Amrik Singh Sidhu

    38/63

  • 8/14/2019 09CS 6048 Amrik Singh Sidhu

    39/63

    Dynamic Buffer Allocation

    TCP

    Transport Layer

  • 8/14/2019 09CS 6048 Amrik Singh Sidhu

    40/63

    Transmission Control Protocol

    TCP Protocol specifically designed to:

    providea reliable end-to-end byte streamoveran unreliable internetwork

    dynamically adapt to properties of

    Internetwork be robust in face of many kinds of failures

    Transmission Control Protocol

  • 8/14/2019 09CS 6048 Amrik Singh Sidhu

    41/63

    Transmission Control Protocol

    At sender side, TCP entity:

    accepts user data streams from local processes breaks them into pieces not exceeding 64 KB

    hands over to IP layer as separate datagrams.

    At receiver side,TCP entity reconstructs theoriginal byte stream from received IPdatagrams.

    Transmission Control Protocol

  • 8/14/2019 09CS 6048 Amrik Singh Sidhu

    42/63

    Transmission Control Protocol

    As underlying subnet is unreliable,TCP is responsible for:

    Maintenance of timers

    Retransmission on delivery failure

    Reassemble segments in propersequence.

    Transmission Control Protocol

  • 8/14/2019 09CS 6048 Amrik Singh Sidhu

    43/63

    TCP Service Model

    TCP service is obtained by having both Sender andReceiver create end points calledsockets .

    Each socket has a socket number consisting of

    IP address of host

    16 bit number local to the host calledport.

    Connections are identified by socket identifiers atboth ends.

    TCP Service Model

  • 8/14/2019 09CS 6048 Amrik Singh Sidhu

    44/63

    TCP Service Model

    A socket may be used for multiple connections at the sametime.

    All TCP connections arefull duplex.

    TCP does not support multicasting and broadcasting.

    TCP connection is a byte stream, not a message stream.Message boundaries are not preserved end to end.

    TCP Service Model

  • 8/14/2019 09CS 6048 Amrik Singh Sidhu

    45/63

    TCP Service Model

    Four 512-bytesegments sent asseparate IPdatagrams.

    The 2048 bytes ofdata delivered to the

    application in a singleREAD CALL.

    TCP Service Model

  • 8/14/2019 09CS 6048 Amrik Singh Sidhu

    46/63

    TCP Service Model

    When an application passes data to TCP, it may:

    send it immediately or buffer it at its own discretion.

    If application wants the data to be sent immediately, it can use thePUSH flag, which tells the TCP not to delay the transmission.

    Eg.Carriage return after typing Command on Command Line

    TCP Service Model

  • 8/14/2019 09CS 6048 Amrik Singh Sidhu

    47/63

    TCP Service Model

    Urgent DataEg.-Control-C

    Control info along with Urgent flag causes the sending TCP entityto stop accumulating data and transmit everything immediately.

    When the urgent data is received at destination, the receivingapplication is interrupted to read the data stream to find theurgent data.

    TCP Service Model

  • 8/14/2019 09CS 6048 Amrik Singh Sidhu

    48/63

    Every byte on a TCP connection has its own32 bit sequence number.

    Separate 32 bit sequence numbers are used foracks and the window mechanism.

    Sending and receiving TCP entities exchangedata in terms ofsegments.

    The TCP Protocol

  • 8/14/2019 09CS 6048 Amrik Singh Sidhu

    49/63

    A segment consists of a fixed 20 byte header + an optionalpart + zero or more data bytes.

    Size of segments decided by TCP

    Data from several writes can be put into one segment or

    Can split data of one write over multiple segments

    Limits to segment size

    Data + Header must fit in IP datagram payload (64 KB)

    Dependent on Maximum Transfer Unit (MTU) of the network

    Max payload =64k-20(TCP header)-20(IP header) =64k-40bytes

    The TCP Protocol

  • 8/14/2019 09CS 6048 Amrik Singh Sidhu

    50/63

    TCP Segment Header

  • 8/14/2019 09CS 6048 Amrik Singh Sidhu

    51/63

    Pseudoheader in TCP ChecksumPsuedo Header in TCP Checksum

    It is a pseudo-IP-header, only used for

    the checksum calculation

  • 8/14/2019 09CS 6048 Amrik Singh Sidhu

    52/63

  • 8/14/2019 09CS 6048 Amrik Singh Sidhu

    53/63

    Four TCP segments required

    One FIN and one ACK in each direction

    ACK to others FIN and own FIN may be containedin the same segment.

    To avoid Two Army Problem timers are used.

    TCP Connection Release

  • 8/14/2019 09CS 6048 Amrik Singh Sidhu

    54/63

    Window management in TCP

    TCP Transmission Policy

  • 8/14/2019 09CS 6048 Amrik Singh Sidhu

    55/63

    When the window size is 0 the sender may not sendnormal segments with the following exceptions

    Urgent data may be sent to kill a process on the remote end Sender may send a 1 byte segment to make the receiver

    announce the next byte expected and window size.

    TCP provides this option to prevent a deadlock.

    Flow control

    Sliding window with selective repeat is resorted to.

    TCP Transmission Policy

  • 8/14/2019 09CS 6048 Amrik Singh Sidhu

    56/63

    Improvements on Receiver side

    Wait for data. Send the ACK and windowsize advertisement together

    Improvements on Transmitter side

    Nagles Algorithm

    TCP Transmission Policy

  • 8/14/2019 09CS 6048 Amrik Singh Sidhu

    57/63

    Send the first byte and buffer all the rest till first byteis ack

    Then send the rest and again buffer till the previousbatch is ack.

    Additionally allows to send when enough data tricklesdown to fill half the window size or max segment size.

    Nagles algorithm may not be desirable in some

    situations. Eg mouse movements on remote desktops

    TCP Transmission Policy

    Nagles Algorithm

  • 8/14/2019 09CS 6048 Amrik Singh Sidhu

    58/63

    Clarks Solution- Prevent receiver from advertising a window size of one byte. Instead

    wait till the window is half empty or the window size = full segment size.

    TCP Transmission Policy

    Silly Window Syndrome

  • 8/14/2019 09CS 6048 Amrik Singh Sidhu

    59/63

    Congestion causing factors

    Receiver capacity - Limitedbuffer size of the receiver.

    Sender transmits only as perwindow size advertised by receiver

    Network capacity - Internalcongestion within the NW

    TCP Congestion Control

  • 8/14/2019 09CS 6048 Amrik Singh Sidhu

    60/63

    Two windows maintained by the sender, eachreflecting number of bytes it can transmit. These are:

    Window granted by receiver and

    The Congestion window.

    Effective sending window is the lesser of the two.

    TCP Congestion Control

    Slow Start Algorithm

  • 8/14/2019 09CS 6048 Amrik Singh Sidhu

    61/63

    At connection est time the congestion window is set tomax segment size in use on the connection.

    The congestion window grows exponentially witheach ack, till either a time out occurs or the receiverswindow size is reached.

    TCP Congestion Control

    Slow Start Algorithm

  • 8/14/2019 09CS 6048 Amrik Singh Sidhu

    62/63

    Uses a third parameter called threshold.

    Initially set to a high value of 64KB

    When time out occurs, it is set to half of the current congestion window and thecongestion window is set to max segment size.

    Slow start is then used

    Exponential growth stops at the threshold and the congestion window increaseslinearly (one max segment size per ACK) till the receiver window size is reached.

    TCP Congestion Control

    Internet Congestion algorithm

  • 8/14/2019 09CS 6048 Amrik Singh Sidhu

    63/63