Wide Area Networking Lecture 4: TCP protocol - PowerPoint PPT Presentation

1 / 30
About This Presentation
Title:

Wide Area Networking Lecture 4: TCP protocol

Description:

Connection-oriented reliable byte-stream service over connectionless and unreliable IP ... Appli-cation close. 12. Flow control. Sliding window mechanism ... – PowerPoint PPT presentation

Number of Views:29
Avg rating:3.0/5.0
Slides: 31
Provided by: rafalsob
Category:

less

Transcript and Presenter's Notes

Title: Wide Area Networking Lecture 4: TCP protocol


1
Wide Area NetworkingLecture 4 TCP protocol
2
Transport layer - TCP
  • Connection-oriented reliable byte-stream service
    over connectionless and unreliable IP
  • More complex transmitter receiver
  • Connection-oriented full-duplex connection
    between client server processes
  • Connection setup, connection state, connection
    release
  • Higher header overhead
  • Error control, flow control, and congestion
    control
  • Higher delay than UDP
  • Applications using TCP
  • HTTP, SMTP, FTP, TELNET, POP3, VoIP signalling
    protocols, ...

3
TCP operation principles
  • TCP splits application data into the so-called
    segments, numbers them and sends
  • Received segments have to be acknowledged by the
    receiver, otherwise segments are retransmitted
  • Receiver reassembles the segments by numbers
  • Error recovery
  • Missed or corupted segments are retransmited
  • Timeout mechanism to detect lost segments
  • TCP deploys flow/congestion control mechanisms
    for better utilization of network bandwidth

4
TCP
  • Connection-oriented
  • Byte stream service
  • Application sends byte blocks
  • TCP forms them into segments transported in IP
    packets
  • Receiving application reads received bytes
  • Duplex connection
  • Flow control Receiver controls rate at which
    sender transmits to prevent buffer overflow
  • Congestion control Transmitter dynamically
    adjusts the rate according to congestion as
    indicated by RTT (round trip time) ACKs

IP packet
TCP segment
TCP data
TCP header20 bytes
IP header20 bytes
5
TCP
  • TCP segment header

6
TCP
  • Port Numbers
  • A socket is a common name for IP address paired
    with a port number
  • A connection is fully specified by a socket pair
  • Well-known ports FTP 20 Telnet 23
  • DNS 53 HTTP 80
  • Sequence Number
  • 32 bits long byte count with initial sequence
    number selected during connection setup
  • Acknowledgement Number
  • SN of next byte expected by receiver
  • Acknowledges that all prior bytes in stream have
    been received correctly
  • Valid if ACK flag is set
  • Header length
  • 4 bits length of header in multiples of 32-bit
    words
  • Min. header length is 20 bytes, max. is 60 bytes

7
TCP
  • Control (6 bits)
  • URG urgent pointer flag
  • Urgent message end SN urgent pointer
  • ACK ACK packet flag
  • PSH override TCP buffering
  • RST reset connection
  • Upon receipt of RST, connection is terminated and
    application layer notified
  • SYN establish connection
  • FIN close connection

8
TCP
  • Window Size
  • 16 bits to advertise window size
  • Used for flow control
  • Sender will accept bytes with SN from ACK to ACK
    window
  • Maximum window size is 65535 bytes
  • TCP Checksum
  • Internet checksum method
  • TCP pseudo header TCP segment
  • Options
  • Variable length
  • NOP (No Operation) option is used to pad TCP
    header to multiple of 32 bits
  • Timestamp option is used for round trip
    measurements
  • Maximum Segment Size (MSS) option specifies
    largest segment a receiver wants to receive
  • Window Scale option increases TCP window from 16
    to 32 bits

9
TCP Connection management
  • Connection establishment Three-way Handshake

10
TCP connection management
  • Connection teardown

11
TCP States
12
Flow control
  • Sliding window mechanism
  • a window determines a number of bytes that can be
    injected to the network without acknowledgement

receiver window
current window
1
2
3
4
5
6
7
8
9
10
11
...
sent but not acknowledged
have to wait for available window
sent and acknowledged
can be sent immediately
13
TCP Congestion Control
  • Advertised window size
  • used to ensure that receivers buffer will not
    overflow
  • However, buffers at intermediate routers between
    source and destination may overflow
  • Congestion occurs when total arrival rate from
    all packet flows exceeds R over a sustained
    period of time
  • Buffers at multiplexer will fill and packets will
    be lost

R
Throughput (bps)
Arrival Rate
Delay (sec)
Arrival Rate
R
14
Window Congestion Control
  • Window mechanism has a desired operating point
  • Sources must control their sending rates so that
    aggregate arrival rate is just before the
    congestion point
  • TCP sender maintains a congestion window cwnd to
    control congestion at intermediate routers
  • Effective window is minimum of congestion window
    and advertised window
  • Problem source does not know what its fair
    share of available bandwidth should be
  • Solution adapt dynamically to available BW
  • Sources probe the network by increasing cwnd
  • When congestion detected, sources reduce rate
  • Ideally, sources sending rate stabilizes near
    ideal point

15
Congestion Window
  • TCP congestion algorithm changes congestion
    window dynamically according to the network state
  • At light traffic each segment is ACKed quickly
  • Increase cwnd aggressively
  • Near congestion point segment ACKs arrive, but
    more slowly
  • Slow down increase in cwnd
  • At congestion segments encounter large delays
    (so retransmission timeouts occur) segments are
    dropped in router buffers (resulting in duplicate
    ACKs)
  • Reduce transmission rate, then probe again

16
TCP Congestion Control Slow Start
  • Slow start increase congestion window size by
    one segment upon receiving an ACK from receiver
  • initialized at ? 2 segments
  • used at (re)start of data transfer
  • congestion window increases exponentially

Seg
ACK
17
TCP Congestion Control Congestion Avoidance
  • Algorithm progressively sets a congestion
    threshold
  • When cwnd gt threshold, slow down rate at which
    cwnd is increased
  • Increase congestion window size by one segment
    per round-trip-time (RTT)
  • Each time an ACK arrives, cwnd is increased by
    1/cwnd
  • In one RTT, cwnd segments are sent, so total
    increase in cwnd is cwnd x 1/cwnd 1
  • cwnd grows linearly with time

18
TCP Congestion Control Congestion
  • Congestion is detected upon timeout or receipt of
    duplicate ACKs
  • Assume current cwnd corresponds to available
    bandwidth
  • Adjust congestion threshold ½ x current cwnd
  • Reset cwnd to 1
  • Go back to slow-start
  • Over several cycles expect to converge to
    congestion threshold equal to about ½ the
    available bandwidth

19
Fast Retransmit Fast Recovery
  • Congestion causes many segments to be dropped
  • If only a single segment is dropped, then
    subsequent segments trigger duplicate ACKs before
    timeout
  • Can avoid large decrease in cwnd as follows
  • When three duplicate ACKs arrive, retransmit lost
    segment immediately
  • Reset congestion threshold to ½ cwnd
  • Reset cwnd to congestion threshold 3 to account
    for the three segments that triggered duplicate
    ACKs
  • Remain in congestion avoidance phase
  • However if timeout expires, reset cwnd to 1
  • In absence of timeouts, cwnd will oscillate
    around optimal value

SN1
ACK2
SN2
SN3
SN4
ACK2
SN5
ACK2
ACK2
20
TCP Congestion Control Fast Retransmit Fast
Recovery
Congestion avoidance
20
Time-out
15
Threshold
Congestion window
10
Slow start
5
0
Round-trip times
21
TCP observations
  • TCP connection throughput sawtooth curve
  • TCP is an adaptive or feedback-based protocol
    it will try to exploit available bandwidth as
    much as possible (until limitations arise)

22
Delayed ACK
  • Sending empty ACK packets (only ACK, no data)
    consumes network bandwidth
  • Ineffective network utilisation
  • Short packet problem
  • Delayed ACK
  • Receiver waits up to 200 ms to send ACK if it has
    no data to send
  • Every second segment is acknowledged without
    waiting for delay ACK timeout
  • When ACK timeout expires the acknowledgement is
    sent hopefully with data that was buffered
    meantime

23
Nagles Algorithm
  • Very short datagrams (tinygrams) consume network
    resource ineffectively
  • Nagles algorithms mitigates this problem
  • Only one short segment can be outstanding for
    acknowledgement
  • While waiting for acknowledgement the arriving
    (from upper layer) data is buffered
  • When acknowledgement arrive or there is enough
    data to fill the packet the next packet can be
    send
  • Nagles algorithm initially buffers some data and
    then starts sending packets
  • Nagles algorithm automatically adopts to the
    network state (RTT)
  • Short RTT- no influence
  • Large RTT more data will be buffed, larger
    initial delay
  • No short packets - no influence

24
Nagles algorithm example
  • (1) first segment is send immediately
  • (2) the arriving data is buffered
  • (3) when the acknowledgement arrives all buffered
    data is send (up to window size)
  • (4) in the steady state the efficiency of the TCP
    connection with Nagles algorithm is the same as
    original TCP protocol

25
Timeout and retransmission
  • The reliable data transfer is ensured by the
    acknowledgement and retransmission mechanism
  • After sending the segment the timer is started
  • When the ACK is not received before timeout
    expires the segments (starting from the last
    acknowledged segment) are automatically
    retransmitted
  • The timeout (RTO) value has significant impact on
    the TCP performance
  • Too short RTO unnecessary retransmission
    network overload, slow start triggering, low
    throughput
  • Too large RTO long inactivity periods low
    throughput
  • How to set the value of RTO
  • Adaptive measurement procedure

26
RTO measurement (1)
  • The RTO is measured based on the RTT (Round Trip
    Time) estimation
  • The average RTT is estimated by so called
    weighted moving average
  • R aR(1-a)M
  • R - estimated average value of RTT M - the RTT
    value from last measurement
  • a estimator weight
  • The RTO (timeout) value is given by
  • RTO Rb
  • b - is the assumed measure of RTT variance
    (equal 2).
  • The above procedure does not work well when the
    RTT fluctuations are high

27
RTO measurement (1)
  • To improve the RTO measurement the variance of
    the RTT must be taken into account
  • The average RTT is estimated by the following
    procedure
  • Err M - A
  • A A gErr
  • A - estimated average value of RTT M - the RTT
    value from last measurement
  • g estimator weight 0.125
  • The variance of RTT is estimated by the following
    procedure
  • D D h(Err - D)
  • h - algorithm parameter 0,25
  • The RTO (timeout) value is given by
  • RTO A 4D

28
Karns Algorithm (1)
  • RTO measurement uncertainty
  • During retransmission we cannot distinguish the
    following situations
  • (A) measured RTT is related to originally
    transmitted segment
  • (B) measured RTT is related to retransmitted
    segment
  • Using rule (A) will increase RTO and decrease the
    TCP throughput in case of transmission errors
  • i.e. on wireless links
  • Using rule (B) will increase the number of
    unnecessary retransmission again lowering TCP
    throughput

Segment
RTO
retransmission
(A)
Ack
(B)
What is true (A) or (B)?
29
Karns Algorithm (2)
  • Use only these RTT values that are not related to
    retransmission
  • Shall retransmission occur, double the RTO value
    (up to maximum value of 64 sec.) - exponential
    backoff
  • The protection against keeping too short values
    of RTO for long time

30
Useful equation
  • ThroughputltTCP Window Size/RTT
  • TCP Window SizegtBandwidthRTT
  • Buffer Size gt 2BandwidthRTT
  • After 3BandwidthRTT data has been send the TCP
    will reach the optimal performance
  • Throughput 0,7MTU/RTT/SqrtPloss
Write a Comment
User Comments (0)
About PowerShow.com