Tcp part ii
1 / 49

TCP - Part II - PowerPoint PPT Presentation

  • Uploaded on

TCP - Part II. Relates to Lab 5. This is an extended module that covers TCP data transport, and flow control, congestion control, and error control in TCP. Interactive and bulk data. TCP applications can be put into the following categories bulk data transfer - ftp, mail, http

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

PowerPoint Slideshow about 'TCP - Part II' - dorcas

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
Tcp part ii

TCP - Part II

Relates to Lab 5. This is an extended module that covers TCP data transport, and flow control, congestion control, and error control in TCP.

Interactive and bulk data
Interactive and bulk data

TCP applications can be put into the following categories

bulk data transfer - ftp, mail, http

interactive data transfer - telnet, rlogin

TCP has algorithms to deal which each type of applications efficiently.

Tcpdump of an rlogin session
tcpdump of an rlogin session

This is the output of typing 3 (three) characters :

44.062449 > P 0:1(1) ack 1

44.063317 > P 1:2(1) ack 1 win 8760

44.182705 > . ack 2 win 17520

48.946471 > P 1:2(1) ack 2 win 17520

48.947326 > P 2:3(1) ack 2 win 8760

48.982786 > . ack 3 win 17520

55:00.116581 > P 2:3(1) ack 3 win 17520

55:00.117497 > P 3:4(1) ack 3 win 8760

55:00.183694 > . ack 4 win 17520


  • “Rlogin” is a remote terminal application

  • Originally built only for Unix systems.

  • Rlogin sends one segment per character (keystroke)

  • Receiver echoes the character back.

  • So, we really expect to have four segments per keystroke


  • We would expect that tcpdump shows this pattern:

  • However, tcpdump shows this pattern:

  • So, TCP has delayed the transmission of an ACK

Delayed acknowledgement
Delayed Acknowledgement

  • TCP delays transmission of ACKs for up to 200ms

  • The hope is to have data ready in that time frame. Then, the ACK can be piggybacked with the data segment.

  • Delayed ACKs explain why the ACK and the “echo of character” are sent in the same segment.

Tcpdump of a wide area rlogin session
tcpdump of a wide-area rlogin session

This is the output of typing 9 characters :

54:16.401963 > tenet.CS.Berkeley.EDU.login: P 1:2(1) ack 2 win 16384

54:16.481929 tenet.CS.Berkeley.EDU.login > P 2:3(1) ack 2 win 16384

54:16.482154 > tenet.CS.Berkeley.EDU.login: P 2:3(1) ack 3 win 16383

54:16.559447 tenet.CS.Berkeley.EDU.login > P 3:4(1) ack 3 win 16384

54:16.559684 > tenet.CS.Berkeley.EDU.login: P 3:4(1) ack 4 win 16383

54:16.640508 tenet.CS.Berkeley.EDU.login > P 4:5(1) ack 4 win 16384

54:16.640761 > tenet.CS.Berkeley.EDU.login: P 4:8(4) ack 5 win 16383

54:16.728402 tenet.CS.Berkeley.EDU.login > P 5:9(4) ack 8 win 16384

Wide area rlogin observation 1
Wide-area Rlogin: Observation 1

  • Transmission of segments follows a different pattern.

  • The delayed acknowled-gment does not kick in

  • Reason is that there is always data at aida when the ACK arrives.

Wide area rlogin observation 2
Wide-area Rlogin: Observation 2

  • There are fewer transmissions than there are characters.

  • Aida never has multiple segments outstanding.

  • This is due to Nagle’s Algorithm:

    Each TCP connection can have only one small (1-byte) segment outstanding that has not been acknowledged.

  • Implementation:Send one byte and buffer all subsequent bytes until acknowledgement is received.Then send all buffered bytes in a single segment. (Only enforced if data is arriving from application one byte at a time)

  • Nagle’s rule reduces the amount of small segments.The algorithm can be disabled.

Flow control congestion control error control


Flow Control Congestion ControlError Control

What is flow congestion error control
What is Flow/Congestion/Error Control ?

  • Flow Control: Algorithms to prevent that the sender overruns the receiver with information?

  • Congestion Control: Algorithms to prevent that the sender overloads the network

  • Error Control: Algorithms to recover or conceal the effects from packet losses

     The goal of each of the control mechanisms is different.

     But the implementation is combined

Tcp flow control1
TCP Flow Control

  • TCP implements sliding window flow control

    • Sending acknowledgements is separated from setting the window size at sender.

    • Acknowledgements do not automatically increase the window size

    • Acknowledgements are cumulative

Sliding window flow control
Sliding Window Flow Control

Sliding Window Protocol is performed at the byte level:

Here: Sender can transmit sequence numbers 6,7,8.

Sliding window window closes
Sliding Window: “Window Closes”

Transmission of a single byte (with SeqNo = 6) and acknowledgement is received (AckNo = 5, Win=4):

Sliding window window opens
Sliding Window: “Window Opens”

Acknowledgement is received that enlarges the window to the right (AckNo = 5, Win=6):

A receiver opens a window when TCP buffer empties (meaning that data is delivered to the application).

Sliding window window shrinks
Sliding Window: “Window Shrinks”

Acknowledgement is received that reduces the window from the right (AckNo = 5, Win=3):

Shrinking a window should not be used

Window management in tcp
Window Management in TCP

  • The receiver is returning two parameters to the sender

  • The interpretation is:

    • I am ready to receive new data with

      SeqNo= AckNo, AckNo+1, …., AckNo+Win-1

  • Receiver can acknowledge data without opening the window

  • Receiver can change the window size without acknowledging data

  • Tcp congestion control1
    TCP Congestion Control

    • TCP has a mechanism for congestion control. The mechanism is implemented at the sender

    • The window size at the sender is set as follows:


    • flow control window is advertised by the receiver

    • congestion window is adjusted based on feedback from the network

    Send Window = MIN (flow control window, congestion window)

    Tcp congestion control2
    TCP Congestion Control

    • The sender has two additional parameters:

      • Congestion Window (cwnd)Initial value is 1 MSS (=maximum segment size) counted as bytes

      • Slow-start threshold Value (ssthresh)

        Initial value is the advertised window size)

    • Congestion control works in two modes:

      • slow start (cwnd < ssthresh)

      • congestion avoidance (cwnd >= ssthresh)

    Slow start
    Slow Start

    • Initial value:

      • cwnd = 1 segment

  • Note: cwnd is actually measured in bytes: 1 segment = MSS bytes

  • Each time an ACK is received, the congestion window is increased by MSS bytes.

    • cwnd = cwnd + MSS

  • If an ACK acknowledges two segments, cwnd is still increased by only 1 segment.

  • Even if ACK acknowledges a segment that is smaller than MSS bytes long, cwnd is increased by MSS.

  • Does Slow Start increment slowly? Not really. In fact, the increase of cwnd can be exponential

  • Slow start example
    Slow Start Example

    • The congestion window size grows very rapidly

      • For every ACK, we increase cwnd by 1 irrespective of the number of segments ACK’ed

    • TCP slows down the increase of cwnd when cwnd > ssthresh

    Congestion avoidance
    Congestion Avoidance

    • Congestion avoidance phase is started if cwnd has reached the slow-start threshold value

    • If cwnd >= ssthresh then each time an ACK is received, increment cwnd as follows:

      • cwnd = cwnd + MSS(MSS/ cwnd)

  • So cwnd is increased by one segment (=MSS bytes) only if all segments have been acknowledged.

  • Slow start congestion avoidance
    Slow Start / Congestion Avoidance

    • Here we give a more accurate version than in our earlier discussion of Slow Start:

      Ifcwnd <= ssthreshthenEach time an Ack is received: cwnd = cwnd +MSS

      else /* cwnd > ssthresh */

      Each time an Ack is received :cwnd = cwnd + MSS. MSS/ cwnd


    Example of slow start congestion avoidance
    Example of Slow Start/Congestion Avoidance

    Assume that ssthresh = 8


    Cwnd (in segments)

    Roundtrip times

    Responses to congestion
    Responses to Congestion

    • Most often, a packet loss in a network is due to an overflow at a congested router (rather than due to a transmission error)

    • So, TCP assumes there is congestion if it detects a packet loss

    • A TCP sender can detect lost packets via:

      • Timeout of a retransmission timer

      • Receipt of a duplicate ACK

  • When TCP assumes that a packet loss is caused by congestion it reduces the size of the sending window

  • Tcp tahoe
    TCP Tahoe

    • Congestion is assumed if sender has timeout or receipt of duplicate ACK

    • Each time when congestion occurs,

      • cwnd is reset to one:

        cwnd = MSS

      • ssthresh is set to half the current size of the congestion window:

        ssthressh = cwnd / 2

      • and slow-start is entered

    Slow start congestion avoidance1
    Slow Start / Congestion Avoidance

    • A typical plot of cwnd for a TCP connection (MSS = 1500 bytes) with TCP Tahoe:

    Tcp error control

    TCP Error Control

    Background on Error Control

    TCP Error Control

    Background arq error control
    Background: ARQ Error Control

    • Two types of errors:

      • Lost packets

      • Damaged packets

    • Most Error Control techniques are based on:

      1. Error Detection Scheme (Parity checks, CRC).

      2. Retransmission Scheme.

    • Error control schemes that involve error detection and retransmission of lost or corrupted packets are referred to as Automatic Repeat Request (ARQ) error control.

    Background arq error control1
    Background: ARQ Error Control

    All retransmission schemes use all or a subset of the following procedures:

    Positive acknowledgments (ACK)

    Negative acknowledgment (NACK)

    All retransmission schemes (using ACK, NACK or both) rely on the use of timers

    The most common ARQ retransmission schemes are:

    Stop-and-Wait ARQ

    Go-Back-N ARQ

    Selective Repeat ARQ

    Background arq error control2
    Background: ARQ Error Control

    • The most common ARQ retransmission schemes:

      • Stop-and-Wait ARQ

      • Go-Back-N ARQ

      • Selective Repeat ARQ

    • The protocol for sending ACKs in all ARQ protocols are based on the sliding window flow control scheme

    Background stop and wait arq
    Background: Stop-and-Wait ARQ

    • Stop-and-Wait ARQ is an addition to the Stop-and-Wait flow control protocol:

    • Packets have 1-bit sequence numbers (SN = 0 or 1)

    • Receiver sends an ACK (1-SN) if packet SN is correctly received

    • Sender waits for an ACK (1-SN) before transmitting the next packet with sequence number 1-SN

    • If sender does not receive anything before a timeout value expires, it retransmits packet SN

    Background stop and wait arq1

    Packet 1

    Packet 0

    Packet 1

    Packet 1

    ACK 0

    ACK 1

    ACK 0

    Background: Stop-and-Wait ARQ

    • Lost Packet




    Background go back n arq
    Background: Go-Back-N ARQ


    • A station may send multiple packets as allowed by the window size

    • Receiver sends a NAK i if packet i is in error. After that, the receiver discards all incoming packets until the packet in error was correctly retransmitted

    • If sender receives a NAK iit will retransmit packet i and all packets i+1, i+2,... which have been sent, but not been acknowledged

    Example of go back n arq

    In Go-back-N, if packets are correctly delivered, they are delivered in the correct sequence

    Therefore, the receiver does not need to keep track of `holes’ in the sequence of delivered packets

    Example of Go-Back-N ARQ

    Background go back n arq1

    Packet 0 delivered in the correct sequence

    Packet 6

    Packet 5

    Packet 2

    Packet 1

    Packet 3

    Packet 4

    Packet 5

    Packet 6

    Packet 4

    ACK 3

    ACK 6

    Background: Go-Back-N ARQ

    • Lost Packet


    for Packet 2

    Packets 4,5,6are retransmitted



    Packets 5 and 6

    are discarded

    Background selective repeat arq
    Background: Selective-Repeat ARQ delivered in the correct sequence

    • Similar to Go-Back-N ARQ. However, the sender only retransmits packets for which a time-out occured is received

    • Advantage over Go-Back-N:

      • Fewer Retransmissions.

    • Disadvantages:

      • More complexity at sender and receiver

      • Each packet must be acknowledged individually (no cumulative acknowledgements)

      • Receiver may receive packets out of sequence

    Example of selective repeat arq
    Example of Selective-Repeat ARQ delivered in the correct sequence

    Receiver must keep track of `holes’ in the sequence of delivered packets

    Sender must maintain one timer per outstanding packet

    Background selective repeat arq1

    Packet 0 delivered in the correct sequence

    Packet 2

    Packet 1

    Packet 3

    Packet 5

    Packet 6

    Packet 0

    Packet 4

    Packet 7

    Packet 4

    ACK 6

    ACK 2

    ACK 3

    ACK 4

    ACK 1

    ACK 1

    ACK 7

    ACK 5

    ACK 0

    Background: Selective-Repeat ARQ

    • Lost Packet

    Timeout for Packet 4:only Packet 4 is retransmitted



    Packets 5 and 6

    are buffered

    Error control in tcp
    Error Control in TCP delivered in the correct sequence

    • TCP implements a variation of the Go-back-N retransmission scheme

    • TCP maintains a Retransmission Timer for each connection:

      • The timer is started during a transmission. A timeout causes a retransmission

    • TCP couples error control and congestion control (I.e., it assumes that errors are caused by congestion)

    • TCP allows accelerated retransmissions (Fast Retransmit)

    Tcp retransmission timer
    TCP Retransmission Timer delivered in the correct sequence

    • Retransmission Timer:

      • The setting of the retransmission timer is crucial for efficiency

      • Timeout value too small results in unnecessary retransmissions

      • Timeout value too large long waiting time before a retransmission can be issued

      • A problem is that the delays in the network are not fixed

      • Therefore, the retransmission timers must be adaptive

    Round trip time measurements
    Round-Trip Time Measurements delivered in the correct sequence

    • The retransmission mechanism of TCP is adaptive

    • The retransmission timers are set based on round-trip time (RTT) measurements that TCP performs

    The RTT is based on time difference between segment transmission and ACK


    TCP does not ACK each segment

    Each connection has only one timer

    Round trip time measurements1
    Round-Trip Time Measurements delivered in the correct sequence

    • Retransmission timer is set to a Retransmission Timeout (RTO) value.

    • RTO is calculated based on the RTT measurements.

    • The RTT measurements are smoothed by the following estimators srtt and rttvar:

      srttn+1 = a RTT + (1- a ) srttn rttvarn+1 = b ( | RTT - srttn+1 | ) + (1- b ) rttvarn

      RTOn+1 = srttn+1 + 4 rttvarn+1

    • The gains are set toa =1/4 and b =1/8

    • srtt0 = 0 sec, rttvar0 = 3 sec, Also: RTO1 = srtt1 + 2 rttvar1

    Karn s algorithm
    Karn’s Algorithm delivered in the correct sequence

    • If an ACK for a retransmitted segment is received, the sender cannot tell if the ACK belongs to the original or the retransmission.

    Karn’s Algorithm:

    Don’t update srtt on any segments that have been retransmitted.

    Each time when TCP retransmits, it sets:RTOn+1 = max ( 2 RTOn, 64)(exponential backoff)

    Measuring tcp retransmission timers
    Measuring TCP Retransmission Timers delivered in the correct sequence

    Transfer file from Argon to neon

    Unplug Ethernet of Argon cable in the middle of file transfer

    Interpreting the measurements
    Interpreting the Measurements delivered in the correct sequence

    • The interval between retransmission attempts in seconds is:

      1.03, 3, 6, 12, 24, 48, 64, 64, 64, 64, 64, 64, 64.

    • Time between retrans-missions is doubled each time (Exponential Backoff Algorithm)

    • Timer is not increased beyond 64 seconds

    • TCP gives up after 13th attempt and 9 minutes.