In its basic form, TCP may have a window size of 1
which means that for every segment transmitted by the sender
the receiver sends an acknowledgement for that individual segment.
This however slows down the throughput dramatically
because the sender cannot transmit anymore data
until it to receives acknowledgement of that single segment transmitted.
The throughput would be very low
depending on the round trip timer
between sending data and receiving the acknowledgement.
TCP however thus allow for greater window sizes
to allow for more segments
to be transmitted before receiving an acknowledgement.
The window is the number of data segments
the sender is allowed to send
without getting an acknowledgement from the receiver.
In this case we’ve set it to 1
that means when host A wants to send traffic to host B
it can send 1 segment because the window size is set to 1
host B, once it receives that segment, sends an acknowledgement.
In this example, let’s assume that host A, send the segment with the sequence number of 1
host B would acknowledge for segment 2.
Host A will then send segment 2
and host B, once successfully receiving that segment
will acknowledge or ACK for segment 3.
Host A will then send segment 3 to host B.
This process will then continue for the duration of the session
this is obviously very reliable however, the throughput is very low.
A would need to buffer outgoing segments
until it receive an acknowledgement for the segment transmitted.
now for argument sake
let’s assume that it takes 1 second for traffic
with the start with the small window size
and then exponentially increase the window size to gauge
the amount of data that the receiver can receive and what the network can handle.
You’ve probably notice this, when downloading a file from the internet
initially the download speed is slow
but then increases to a certain point over time.
This is because the window size initially are small
but then increases exponentially until a packet is dropped
or the receiving host cannot handle the amount of data it's receiving.
So you’ll notice initially, that the download speed is very slow
increases very quickly and then gets to a point
and then stays around that speed.
So once again, let’s assume
that the hosts in this example have a fixed window size of 3.
That means that A can send 3 segments before receiving an acknowledgement.
So in this case host A sends segment 1,2 and 3
host B acknowledges for segment 4
thus letting A know that it successfully received segment 1,2 and 3
host A then sends segment 4,5 and 6 because it has a fix window size of 3
and host B acknowledges for segment 7
thus letting A know, that it had received segments 4,5 and 6.
Remember with acknowledgements, acknowledge the next segment that you want to received
not the segment that you have already received.
So host B does not acknowledge for segment 6
but acknowledges segment 7.
As I've mentioned, a sliding window allows hosts to gauge
the amount of data the receiver can receive and what the network can handle.
So in this example let’s assume that the host are using a sliding window
the way that they determine what the network can handle
is when a packet is dropped by the network, the host will slow down.
This information is covered in a lot more detail
in courses that contain quality of service.
With this course just assume that when a packet gets drop
they reduced their window size dramatically
in brief, the window size is either the window granted to the sender by the receiver
or a calculated window called the congestion window or CWND
the congestion window or CWND is initially set to very low value
at connection establishment and then increases at an exponential rate.
For every lost segment, the congestion window is half
after lost segment has been successfully re-transmitted
the congestion window grows again until it reaches
a value half of the original congestion window
it then slows down its growth, using an algorithm called congestion avoidance.
It does exponentially grows up to half the original congestion window size
and then increases slowly at the linear rate.
In quality of service Weighted Random Early Detection or WRED
can be used improve efficiency of TCP transmissions across the link
as packets are randomly dropped from various flows or various sessions
going across an individual interface
rather than packets from multiple senders being drop at the same time.
this avoid an issue called global synchronization
where packets from multiple TCP sessions are drop at the same time
and therefore multiple host reduce their window size and slowdown at the same time
and then gradually increase their window size
and therefore their throughput at the same time.
So you have a many hosts slowing down and speeding up at the same time
with WRED some hosts will be slowing down
and other hosts will be increasing their throughput because or random drops.
Please refer to quality of service documentation for more detail about WRED
In this example let’s assume that we start with the initial window size of 3.
So A transmits 3 segments to B, however only segment 1 and 2 arrive at host B
segment 3 goes missing.
Host B may reduce its window size in this example to 2 and acknowledge segment 3.
Remember the acknowledgement is for the next packet that that hosts expects to receive
and because host B did not receive segment 3
it’s acknowledging successful receipt of segment 1 and 2.
Host A will re-transmit segment 3 and in this example send segment 4
but also request a window size of 3.
Both those segment are successfully received by host B
so host B will acknowledge for segment 5
but in this example, still wants a window size of 2.
Host A will only send 2 segments because the negotiated window size is 2
but A may still request that the window size be increase to 3.
With the sliding window, there is dynamic negotiation of a window size
and that window size may change dramatically during a session
depending on what the receiver can process and what the network can handle.