The Transmission Control Protocol (TCP) - PowerPoint PPT Presentation

About This Presentation
Title:

The Transmission Control Protocol (TCP)

Description:

The Transmission Control Protocol TCP – PowerPoint PPT presentation

Number of Views:466
Avg rating:3.0/5.0
Slides: 33
Provided by: Tjade
Learn more at: https://users.cs.jmu.edu
Category:

less

Transcript and Presenter's Notes

Title: The Transmission Control Protocol (TCP)


1
The Transmission Control Protocol (TCP)

2
The Transmission Control Protocol (TCP)
  • TCP is a protocol that specifies
  • How to distinguish among multiple destinations on
    a given machine
  • How to initiate and terminate a stream transfer
  • Format of the data and acknowledgments that two
    computers exchange to achieve a reliable transfer
  • Procedures the computers use to ensure that the
    data arrives correctly

3
TCP Segment Format
  • TCP divides the data stream into segments for
    transmission

4
TCP Segment Header Fields
  • Code bits - identify the contents of the segment
  • Window - how much data the sender is willing to
    accept (flow control)
  • Urgent pointer - specifies the position in the
    segment where urgent data ends

5
Out of Band Data
  • TCP provides a mechanism to handle urgent data
  • Urgent data is received before octets already in
    the stream
  • Sender
  • Sets urgent bit in segment header
  • Puts urgent data at the beginning of the data
    field
  • Sets urgent pointer to the end of the urgent data
  • Receiver
  • Notified of the urgent data as soon as it arrives
  • Enters urgent mode until all urgent data has
    been consumed
  • Returns to normal mode

6
TCP Segment Header Fields (cont)
  • Checksum - used to verify the integrity of the
    segment
  • Computed over
  • Segment header
  • Segment data
  • Pseudo header
  • 1s complement addition algorithm
  • Options - signal various options
  • Maximum segment size

7
TCP - Acknowledgments and Retransmission
  • Uses cumulative acknowledgment scheme
  • ACK 7 all octets up to but not including
    number 7 have been received correctly
  • Advantages
  • ACKs are easy to generate and unambiguous
  • Lost acknowledgments do not force retransmission
  • Disadvantages
  • Sender does not receive information about all
    successful transmissions

8
TCP - Timeout and Retransmission
  • For each segment sent
  • Start timer and wait for acknowledgment
  • Retransmit if timer expires
  • TCP uses an adaptive retransmission algorithm
    because internet delays are so variable
  • Round trip time of each connection is recomputed
    every time an acknowledgment arrives
  • Timeout value is adjusted accordingly

9
TCP - Timeout and Retransmission (cont)
  • How should the most recent round trip sample
    (RTS) effect the round trip time (RTT)?
  • New RTT (a RTT) ((1-a) RTS)
  • a 0
  • a 1
  • How should RTT be used to compute timeout?
  • Timeout b RTT
  • b 1
  • b gt 1

10
Accurate Measurement ofRound Trip Samples
  • Simple answer
  • Difference in time segment sent and time ACK
    received
  • But what about retransmissions?
  • Does ACK correspond to first or second copy of
    segment sent?
  • Assuming ACK is for the earliest transmission
    causes problems
  • Assuming ACK is for the latest transmission
    causes problems
  • TCP acknowledgments are ambiguous

11
Accurate Measurement ofRound Trip Samples
  • To avoid problems with ambiguous ACKs
  • TCP should not update the RTT for retransmitted
    segments
  • Problem if timeout value is too small all
    segments will cause retransmissions and RTT will
    never be updated
  • Timer back-off if the timer expires and causes a
    retransmission TCP increases the timeout
  • New timeout c timeout

12
Karns Algorithm
  • When computing the round trip estimate, ignore
    samples that correspond to retransmitted
    segments, but use a backoff strategy, and retain
    the timeout value from a retransmitted packet for
    subsequent packets until a valid sample is
    obtained.

13
Responding to HighVariance in Delay
  • Often a good estimate of the round trip time is
    not very useful because internet delays tend to
    have a high variance
  • Most TCP implementations estimate
  • Average round trip time
  • Variance
  • Using the variance
  • Timeout b RTT

14
Responding to Congestion
  • Endpoints cannot know the details of where in the
    internet congestion has occurred or why
  • Congestion will usually lengthen delays
  • TCPs response to lengthened delays
    (retransmission) can cause congestion collapse
  • Instead, TCP must reduce transmission rates when
    congestion occurs

15
Responding to Congestion (cont)
  • Augment the TCP transmission window with a
    congestion window
  • Windowmin(receiver advertisement,congestion
    window)
  • Multiplicative Decrease Congestion Avoidance
  • Upon loss of a segment reduce the congestion
    window by half (down to a minimum of one segment)
  • Backoff the retransmission timer exponentially

16
Responding to Congestion (cont)
  • Slow-start (additive) recovery
  • When starting traffic on a new connection or
    increasing traffic after a period of congestion
  • Start the congestion window at the size of a
    single segment and increase the congestion window
    by one segment each time an ACK arrives
  • Congestion avoidance phase (during recovery)
  • Once the congestion window reaches half of its
    original size before congestion occurred
  • Increase the size of the congestion window by 1
    only if all segments in the window have been
    acknowledged

17
TCP Timeout and Retransmission - Summary
  • What do we get for all this stuff
  • Slow-start increase
  • Multiplicitive decrease
  • Congestion avoidance
  • Measurement of RTT and variance
  • Exponential timer backoff
  • Dramatic improvement of TCP performance without
    adding significant computational overhead

18
Establishing a TCP Connection
  • The 3-way handshake
  • Guarantee that both sides are ready for
    connection
  • Allows both sides to agree on initial sequence
    numbers

Receive SYN
19
Closing a TCP Connection
  • Applications should close a connection when they
    have no more data to transmit
  • Connection can be closed in either one or both
    directions
  • Site 1 finishes transmitting data and waits for
    ACK from site 2
  • Site 1 transmits a segment with the FIN bit set
  • Site 2 acknowledges the FIN segment
  • Site 2 notifies the application that no more data
    is coming
  • Data can still be transmitted from site 2 to site
    1
  • Site 1 will still receive and acknowledge data
    from site 2
  • Eventually, site 2 will finish transmitting and
    close its connection
  • Both endpoints delete record of the connection

20
Closing a TCP Connection (cont)
Site 1
Network
Site 2

(app closes connection)
Send FIN seqx
Receive FIN Send ACK x1
(inform application)
Receive ACK
(app closes connection)
Send FIN seqy, ACK x1
Receive FINACK
Send ACK y1
Receive ACK
21
TCP Connection Reset
  • Applications normally close connections
  • Sometimes abnormal conditions arise that break a
    connection
  • Broken connections can be reset
  • Site 1 sends a segment with the RST bit set
  • Site 2 receives segment and aborts the connection
  • Transfers in both directions cease immediately
  • Resources for the connection are released
  • Applications programs are informed

22
Forcing Data Delivery
  • TCP divides the stream of octets into segments
    for transmission
  • This improves efficiency since octets can be
    buffered until a good-sized segment can be sent
  • TCP provides a push operation for applications
    that want to force delivery of octets
  • Set PSH bit
  • Send segment

23
Reserved TCP Port Numbers
  • Like UDP
  • Static port bindings for commonly used services
  • Ports 0-1024 are reserved
  • Dynamic port bindings
  • Port numbers over 1024
  • Port numbers for services accessible by both UDP
    and TCP usually match
  • ECHO (7)
  • TIME (37)

24
Reserved TCP Port Numbers
  • Port number Service
  • 0 Reserved
  • 7 Echo
  • 17 Quote of the day
  • 21 FTP
  • 23 TELNET
  • 25 SMTP
  • 37 Time
  • 79 Finger
  • 80 HTTP
  • 119 NNTP

25
TCP Performance
  • Silly Window Syndrome
  • Sender generates data quickly
  • Receiver reads incoming data one octet at a time

Sender
Receiver
26
TCP Performance (cont)
  • Silly Window Syndrome
  • Each ACK advertises a small amount of space
  • Each segment carries a small amount of data
  • Problems
  • Poor use of network bandwidth
  • Unnecessary computational overhead

27
TCP Performance (cont)
  • Avoiding Silly Window Syndrome
  • Use heuristics at sender to avoid transmitting a
    small amount of data in each segment
  • Use heuristics at receiver to avoid sending small
    window advisements
  • Receive-side silly window avoidance
  • Monitor receive window size
  • Delay advertising an increase until a
    significant increase is possible
  • Significant min(half the window, maximum
    segment size)

28
Receive-Side Silly Window Avoidance Example

Receive 6 octets, send ACK 7 with window
advisement of 0
Application reads one octet
Application reads one octet
Application reads one octet
Send window advisement of 3, receive 3 octets
29
Receive-Side SillyWindow Avoidance
  • Two approaches
  • Receiver can ACK received octets but does not
    advertise an increase in its window until the
    increase is significant
  • Receiver can not send ACKs when the window is not
    large enough to advertise
  • Advantages/disadvantages?

30
Send-Side SillyWindow Avoidance
  • Goal avoid sending small segments
  • Application can generate data in small blocks
  • TCP must collect data sent by application into a
    single large segment (clump) for transmission
  • TCP must delay sending a segment until it
    contains a reasonable amount of data
  • How long should TCP wait before transmitting data?

31
Send-Side Silly Window Avoidance (cont)
  • The Nagle Algorithm
  • Application generates data to be sent over a
    connection that has already transmitted some data
  • If all previous transmissions have been
    acknowledged send the data immediately
  • If any ACKs are still pending do not transmit
    until
  • Maximum segment size is reached, or
  • An ACK arrives
  • Self-clocking - does not compute delays
  • Applies even if the application requests a push

32
TCP Summary
  • Provides reliable stream delivery service
  • Full duplex
  • Out-of-band for urgent data
  • Makes efficient use of the network
  • Piggybacking
  • Sliding windows
  • Efficiency
  • End-to-end flow control
  • Acknowledgment and retransmission
  • Congestion recovery/avoidance
Write a Comment
User Comments (0)
About PowerShow.com