SlideShare a Scribd company logo
Presented By
Anurag Jagetiya
Astt. Prof.
MLV Textile & Engineering College, Bhilwara
Anurag Jagetiya 1TCP: 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 2TCP: 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 3TCP: 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 4TCP: 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 5TCP: Flow Control
TCP Flow Control Data Link Flow Control
Byte oriented Uses Frames
TCP sliding window is of variable
size
Fixed Size window
• 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 6TCP: Flow Control
1 2 3 4 5 6 7 8 9 10
WindowFigure 1: SlidingWindow
• 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 7TCP: Flow Control
Figure 2: SlidingWindow Representation
• 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 8TCP: 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 9TCP: Flow Control
NOTE: These activities are controlled by the Receiver and depend
on the congestion in the Network
Figure 3: SlidingWindow terminology
• 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 10TCP: Flow Control
NOTE: Left wall cannot move to left, as this will revoke some of
previously sent Acknowledges (ACKs)
• 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 11TCP: 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 12TCP: 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 13TCP: Flow Control
NOTE: In reality the window size is thousands of Bytes
Example of Flow Control
Anurag Jagetiya 14TCP: Flow Control
In this
example, It is
assumed that
there is only
unidirectional
communicatio
n between
client and
server
Figure 4:
Flow Control [1]
• 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 15TCP: 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 16TCP: 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 17TCP: 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 18TCP: 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 19TCP: Flow Control
Figure 5: Receiver’s Silly
Window [2]
• 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 20TCP: Flow Control
GOAL: Sender should not send small segment and the
receiver not ask for them
• 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 21TCP: Flow Control
• NET-SEAL
[Teaching Computer NETwork Through
Simulation Experiment and Animation Library]
Simulation of TCP Flow Control
Anurag Jagetiya 22TCP: 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 23TCP: 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 24TCP: Flow Control
Calculating Checksum Verifying Checksum
Sum
Checksum
10101001
00111001
-----------
11100010
00011101 Sum
Complement
10101001
00111001
00011101
-----------
11111111
0000000
• 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 25TCP: 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 26TCP: Flow Control
Q: How to set this time out value for the RetransmissionTimer?
• 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 27TCP: Flow Control
Segment 1
Segment 4
ACK for Segment 1
Segment 2
Segment 3
ACK for Segment 2 + 3
Segment 5
ACK for Segment 4
ACK for Segment 5
RTT#1RTT#2RTT#3
Figure 6: RTT [1]
• 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 28TCP: 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 29TCP: 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 30TCP: Flow Control
Example of Fast Retransmission
Anurag Jagetiya 31TCP: Flow Control
Figure 7: 3 ACK [1]
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 32TCP: Flow Control
Anurag Jagetiya 33TCP: Flow Control

More Related Content

TCP protocol flow control

  • 1. Presented By Anurag Jagetiya Astt. Prof. MLV Textile & Engineering College, Bhilwara Anurag Jagetiya 1TCP: Flow Control
  • 2. • 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 2TCP: Flow Control
  • 3. • 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 3TCP: Flow Control
  • 4. • 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 4TCP: Flow Control
  • 5. • 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 5TCP: Flow Control TCP Flow Control Data Link Flow Control Byte oriented Uses Frames TCP sliding window is of variable size Fixed Size window
  • 6. • 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 6TCP: Flow Control 1 2 3 4 5 6 7 8 9 10 WindowFigure 1: SlidingWindow
  • 7. • 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 7TCP: Flow Control Figure 2: SlidingWindow Representation
  • 8. • 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 8TCP: Flow Control
  • 9. 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 9TCP: Flow Control NOTE: These activities are controlled by the Receiver and depend on the congestion in the Network Figure 3: SlidingWindow terminology
  • 10. • 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 10TCP: Flow Control NOTE: Left wall cannot move to left, as this will revoke some of previously sent Acknowledges (ACKs)
  • 11. • 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 11TCP: Flow Control
  • 12. • 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 12TCP: Flow Control
  • 13. • 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 13TCP: Flow Control NOTE: In reality the window size is thousands of Bytes
  • 14. Example of Flow Control Anurag Jagetiya 14TCP: Flow Control In this example, It is assumed that there is only unidirectional communicatio n between client and server Figure 4: Flow Control [1]
  • 15. • 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 15TCP: Flow Control
  • 16. • 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 16TCP: Flow Control
  • 17. •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 17TCP: Flow Control
  • 18. • 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 18TCP: Flow Control
  • 19. • In the given figure: • The receiving TCP announces a window size of 1 byte. • The sending TCP sends only 1 byte. Contd… Anurag Jagetiya 19TCP: Flow Control Figure 5: Receiver’s Silly Window [2]
  • 20. • 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 20TCP: Flow Control GOAL: Sender should not send small segment and the receiver not ask for them
  • 21. • 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 21TCP: Flow Control
  • 22. • NET-SEAL [Teaching Computer NETwork Through Simulation Experiment and Animation Library] Simulation of TCP Flow Control Anurag Jagetiya 22TCP: Flow Control
  • 23. • 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 23TCP: Flow Control
  • 24. • 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 24TCP: Flow Control Calculating Checksum Verifying Checksum Sum Checksum 10101001 00111001 ----------- 11100010 00011101 Sum Complement 10101001 00111001 00011101 ----------- 11111111 0000000
  • 25. • 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 25TCP: Flow Control
  • 26. • 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 26TCP: Flow Control Q: How to set this time out value for the RetransmissionTimer?
  • 27. • 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 27TCP: Flow Control Segment 1 Segment 4 ACK for Segment 1 Segment 2 Segment 3 ACK for Segment 2 + 3 Segment 5 ACK for Segment 4 ACK for Segment 5 RTT#1RTT#2RTT#3 Figure 6: RTT [1]
  • 28. • 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 28TCP: Flow Control
  • 29. • 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 29TCP: Flow Control
  • 30. • 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 30TCP: Flow Control
  • 31. Example of Fast Retransmission Anurag Jagetiya 31TCP: Flow Control Figure 7: 3 ACK [1]
  • 32. 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 32TCP: Flow Control
  • 33. Anurag Jagetiya 33TCP: Flow Control