TCP protocol flow control
-
Upload
anuragjagetiya -
Category
Engineering
-
view
149 -
download
1
Transcript of TCP protocol flow control
1TCP: Flow Control
Presented ByAnurag Jagetiya
Astt. Prof. MLV Textile & Engineering College, Bhilwara
Flow Control in TCP
Anurag Jagetiya
2TCP: Flow Control
• Introduction• Flow Control in TCP• Sliding Window
– Introduction– Terminology – Flow Control Through Sliding Window
• Problems with TCP transmission– Delay ACK– Silly Window Syndrome– Solutions to Silly Window Syndrome
• TCP Error Control– Checksum– Ack– Retransmission
• References
Outline
Anurag Jagetiya
3TCP: Flow Control
• Flow Control balances the Sender’s rate (lightly loaded) of sending data with the Receiver’s rate (heavily loaded) of properly receiving data.
• Otherwise: – Receiver will lost the data Sender has
to retransmit the data unnecessarily Consume resources Cost increases Performance decreases User Frustration…
Introduction
Anurag Jagetiya
4TCP: Flow Control
• Sender can not overrun receiver with lots of information.
• Allows receiver to restrict transmission until it has sufficient buffer space to accommodate more data
• Flow control in TCP is similar to Data Link layer’s Go Back N and Selective Repeat in following manners:
.
Flow Control in TCP
Data Link Layer
Protocol
Similarities with TCP Flow Control
Go Back N It does not use NAK
Selective Repeat Holds out of order segments until missing
one arrives
Anurag Jagetiya
5TCP: Flow Control
• But, there are differences as well in flow control mechanism of TCP and Data Link layer
• TCP uses Sliding Window to handle flow control.
Contd…
Anurag Jagetiya
TCP Flow Control Data Link Flow Control
Byte oriented Uses Frames
TCP sliding window is of variable size
Fixed Size window
6TCP: Flow Control
• Introduction – All packets inside the window can be
transmitted.
– When an acknowledgment for packet 1 is received the window slides to the right and allows the transmission of packet 9
Sliding Window in TCP
Anurag Jagetiya
1 2 3 4 5 6 7 8 9 10
WindowFigure 1: Sliding Window
7TCP: Flow Control
• Conceptually partitions the window into three classes:– Sent and acknowledged [left side, out side the window]– Being Transmitted [inside the window]– Waiting to be transmitted [right side, out side the
window]
Contd..
Anurag Jagetiya
Figure 2: Sliding Window Representation
8TCP: Flow Control
• Only unacknowledged packets are retransmitted– TCP keeps separate timer for each packet.
• Performance:– Depends on the window size and the speed of
the underlying network.– Increase window size so that sender is
transmitting packets as fast as the network can carry them.
– Eliminates network idle time.
Contd…
Anurag Jagetiya
9TCP: Flow Control
Terminology used in Sliding Window:– Imaginary window with two walls: Left and
right– The window can perform three activities
namely:– Opening, Closing, and Shrinking
Contd…
Anurag Jagetiya
NOTE: These activities are controlled by the Receiver and depend on the congestion in the Network
Figure 3: Sliding Window terminology
10TCP: Flow Control
• Opening a window– Moving the right wall to the right– Allows more new bytes in the buffer that are
eligible for sending• Closing a window
– Moving left wall to right– Some bytes have been acknowledged
• Shrinking a window– Moving right wall to left.– Removing eligibility of some packets.– [Warning: Strongly discouraged and not
allowed in some implementation ]
Contd…
Anurag Jagetiya
NOTE: Left wall cannot move to left, as this will revoke some of previously sent Acknowledges (ACKs)
11TCP: Flow Control
• Sliding window takes the help of two other windows namely:– Receiver window (rwnd)– Congestion window (cwnd)
• Receiver window (rwnd)– Value advertised by the opposite end in a
segment containing ACK.– It is number of Bytes which can be accepted by
the other end before its buffer overflows.
Contd…
Anurag Jagetiya
12TCP: Flow Control
• Congestion window (cwnd)– Value determined by the Network (MTU) to
avoid congestion.
• The size of sliding window at one end is determined by the lesser of two values: i.e. Window_Size = Min (rwnd,
cwnd)
• TCP window can be open/ close by the receiver. But should not shrunk.
Contd…
Anurag Jagetiya
13TCP: Flow Control
• Each window can vary in size over time– Each ACK contains a window advisement– Specifies how many additional Bytes of data
the receiver is willing to accept– Sender increases or decreases sending window
sized based on the receiver’s advise
• Provides end-to-end flow control while Data link layer provides
Flow Control through Sliding Window
Anurag Jagetiya
NOTE: In reality the window size is thousands of Bytes
14TCP: Flow Control
Example of Flow Control
Anurag Jagetiya
In this example, It is assumed that there is only unidirectional communication between client and serverFigure 4:
Flow Control [1]
15TCP: Flow Control
• Sender will send the data based upon Receiver’s Advertized Window Size (Free space in Buffer)
• If, this Window is Zero, sender will not send data. And, what if Receiver’s advertisements are getting lost??-------------Deadlock
• Sender may send a One byte segment to make the receiver re-announce its next byte expected and window size
Problems with TCP Transmission
Anurag Jagetiya
16TCP: Flow Control
• Sending data in very small segments.– E.g. Telnet connection to an interactive editor
that reacts to every key-stroke– Worst Case: When a single character is
arrived at TCP, TCP creates a 21 Bytes segment and further, IP creates 41 Bytes Datagram…..
– Receiver, on the other hand, acknowledge by 40 Bytes ACK. --------------------Wastage of scarce Band width
– Solution:• Delay Acknowledgement and window
advertisement
Contd…
Anurag Jagetiya
17TCP: Flow Control
•The receiver waits until there is decent amount of space in its incoming buffer before acknowledging the arrived segments•The delayed acknowledgement can be piggyback on the returning data• Reduces traffic•Disadvantage: it may force the sender to retransmit the unacknowledged segments•To balance: should not be delayed by more than 500ms
Delayed Acknowledgement
Anurag Jagetiya
18TCP: Flow Control
• Sending application program creates data slowly or the receiving application program consumes data slowly, or both. (e.g. 1 byte at a time)
• Server application asks client to create data slowly if it goes continue, window size goes smaller and smaller.
• At a time, it becomes smaller than its header size, Making data transmission extremely inefficient.
Silly Window Syndrome
Anurag Jagetiya
19TCP: Flow Control
• In the given figure:• The receiving TCP announces a window size of
1 byte.• The sending TCP sends only 1 byte.
Contd…
Anurag Jagetiya
Figure 5: Receiver’s Silly Window [2]
20TCP: Flow Control
• Clark’s Solution: For receiving application– Do not send a window update of 1 byte until
there is enough space to accommodate a segment of max. size or until half of the buffer is empty.
•Nagle’s Solution: For sending application– When data come into sender one byte at a
time.– Send first byte and buffer all the rest until the
outgoing byte is acknowledged.
Solution to Silly Window Syndrome
Anurag Jagetiya
GOAL: Sender should not send small segment and the receiver not ask for them
21TCP: Flow Control
• Alternative method– Receiving TCP will buffer data, and it can
BLOCK a READ request from application until it has large chunk of data.
– This will reduce number of calls to TCP and Overhead.
– Trade-Off: Response time will also increase– Acceptable in Non-Interactive applications
like: file transfer.
Anurag Jagetiya
22TCP: Flow Control
• NET-SEAL
[Teaching Computer NETwork Through
Simulation Experiment and Animation Library]
Simulation of TCP Flow Control
Anurag Jagetiya
23TCP: Flow Control
• TCP is reliable so it will deliver entire stream to the destination without error/ loss/ duplicity.
• TCP error control provides mechanism for detecting corrupted/ lost/ out of order and duplicate segment.
• Error detection and correction in TCP is achieved through:– Checksum– Acknowledgement (ACK)– Time out
Error Control in TCP
Anurag Jagetiya
24TCP: Flow Control
• Checksum is used to find out whether the segments are corrupted or not.
• TCP uses 16 bit checksum: Mandatory in every segment.
• E.g. 8 bit checksum
Checksum
Anurag Jagetiya
Calculating Checksum Verifying Checksum
SumChecksum
1010100100111001-----------1110001000011101 Sum
Complement
101010010011100100011101-----------111111110000000
25TCP: Flow Control
• TCP uses ACK to confirm receipt of data segments.
• Control segments that carry no data but consume a sequence number are also Acknowledged.
• An ACK do not consume sequence number and it is never Acknowledged.
Acknowledgement (ACK)
Anurag Jagetiya
26TCP: Flow Control
• When a segment is corrupted, lost, or delayed, it is retransmitted.
• TCP maintains a Retransmission Timer for each connection– The timer is started during a transmission. A
timeout causes a retransmission.
Retransmission
Anurag Jagetiya
Q: How to set this time out value for the Retransmission Timer?
27TCP: Flow Control
• Round Trip Time measurement– The RTT is based on time difference between
segment transmission and ACK.– But, TCP does not ACK each segment Each
connection has only one timer.
Retransmission (Contd…)
Anurag Jagetiya
RT
T #1
RT
T #2
RT
T #3
Figure 6: RTT [1]
28TCP: Flow Control
• 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 Dynamic.
Retransmission (Contd…)
Anurag Jagetiya
29TCP: Flow Control
• Retransmission Time Out (RTO)• If the timer of any segment is expired, that
segment is simply re sent to the destination
• Fast Retransmission: – If Retransmission time is large, one segment is
lost and receiver received so many out of order segments
– Store out of order segments in buffer– Worse Case: Limited Buffer Size – Remedy: Three duplicate ACKs rule
Retransmission (Contd…)
Anurag Jagetiya
30TCP: Flow Control
• If three or more duplicate ACKs are received in a row, the TCP sender believes that a segment has been lost.
• Then TCP performs a retransmission of what seems to be the missing segment, without waiting for a timeout to happen.
Fast Retransmission (3 ACK Rule)
Anurag Jagetiya
31TCP: Flow Control
Example of Fast Retransmission
Anurag Jagetiya
Figure 7: 3 ACK [1]
32TCP: Flow Control
1. Behrouz A Forouzan, “Transport Layer”, in Data Communication and Networking, 4th Edition, Tata McGraw Hill, Special Indian Edition, 2006.
2. Andrew S. Tanenbaum, “The Transport Layer”, in Computer Network, 4th Edition, Prentice Hall India, 2005
3. www.Net-seal.net
References
Anurag Jagetiya
33TCP: Flow ControlAnurag Jagetiya
Queries…Thank you…