TCP - PowerPoint PPT Presentation

1 / 13
About This Presentation
Title:

TCP

Description:

Three-Way Handshake. It takes 3 TCP segments to establish a connection. 11/14/09 ... Question: How do you verify that your implementation conforms to the ... – PowerPoint PPT presentation

Number of Views:31
Avg rating:3.0/5.0
Slides: 14
Provided by: egBuc
Category:
Tags: tcp | threeway

less

Transcript and Presenter's Notes

Title: TCP


1
  • TCP

2
Socket Functions
socket()
TCP Server
bind()
TCP Client
socket()
listen()
accept()
connect()
TCP 3-way handshake
block until connection from client
data (request)
write()
read()
process request
data (reply)
write()
read()
end-of-file notification
read()
close()
close()
3
TCP Connection Establishment
Three-Way Handshake
It takes 3 TCP segments to establish a connection.
4
TCP Connection Termination
(client)
(server)
FIN, SequenceNumM
close (active close)
(passive close) read returns 0
ACK,AcknowledgementM1
FIN,SequenceNumN
close
ACK, AcknowledgementN1
It takes 4 TCP segments to terminate a connection.
5
State Transition Diagram
Question How do your implement such a complex
protocol?
Question How do you verify that your
implementation conforms to the specifications?
Note Arcs are labeled with event/action.
6
Sliding Window
  • TCPs sliding window algorithm
  • Guarantees reliable delivery.
  • Guarantees in-order delivery.
  • Enforces flow control.
  • Look again at the TCP segment header

The receiver tells the sender the number of
unacknowledged bytes of data it will allow (based
on buffer size).
7
Flow Control
LastByteAcked6LastByteSent
LastByteReadltNextByteExpected
LastByteSent6LastByteWritten
NextByteExpected6LastByteRcvd1
LastByteSent-LastByteAcked6AdvertisedWindow
LastByteRcvd LastByteRead 6MaxRcvBuffer
EffectiveWindowAdvertisedWindow-
(LastByteSent-LastByteAcked)
AdvertisedWindow MaxRcvBuffer
((NextByteExpected-1)-LastByteRead)
LastByteWritten LastByteAcked 6MaxSendBuffer
8
When The Window Hits Zero
  • If the AdvertisedWindow reaches zero, the sender
    is not permitted to send any more data.
  • TCP always sends a segment in response to a
    received data segment with the latest values for
    Acknowledge and AdvertisedWindow. The receiver
    doesnt, however, send a spontaneous segment with
    this information.

Question How does would the sender learn that
the AdvertisedWindow has become greater than zero?
9
Triggering Transmission
  • Question How should TCP decide to send a
    segment?
  • (You can answer this ignoring flow control for
    now.)

Sending application
  • As soon as MSS (maximum segment size) bytes have
    been collected from sender.
  • Whenever the sending application explicitly
    requests it (push).
  • Whenever a timer fires and then however many
    bytes have been buffered so far are sent.

TCP
10
Maximum Segment Size (MSS)
Rule of thumb Usually set to the size of the
largest segment TCP can send without causing the
local IP to fragment.
IP header
TCP header
MSS sizeof(MTU) - sizeof(IP header)
sizeof(TCP header)
MTU of the directly connected network
11
Aggressive Send
  • Now, consider what happens in the presence of
    flow control
  • AdvertisedWindow0, so the sender is accumulating
    bytes to send.
  • ACK arrives and AdvertisedWindowMSS/2.
  • Question Should the sender go ahead and send
    MSS/2 or wait for AdvertisedWindow to increase
    all the way to MSS?

12
Silly Window Syndrome
  • Consequence of aggressively taking advantage of
    any available window. Think of the TCP stream as
    a conveyor belt

full data containers
empty data containers (ACKs)
If the sender fills an empty container as soon as
it arrives, the any small container introduced
into the system remains indefinitely it is
immediately filled and emptied in each end.
13
Nagles Algorithm
  • Goal Make the sender application wait long
    enough so that small containers are coalesced
    into larger ones, but not so much that
    interactive applications will suffer.

Algorithm when (application has data to send)
if (available datagtMSS) (AdvertisedWindowgtMS
S) send full segment else if (unACKed data
in transit) buffer the new data until an ACK
arrives else send all the new data
immediately
PS On by default on a TCP socket option
TCP_NODELAY turns it off.
Write a Comment
User Comments (0)
About PowerShow.com