·
TCP protocol runs
in the Transport layer
o Transport layer is responsible to
establish/tear-down sessions (called virtual connections)
·
TCP is one type of Transport
layer protocols which defines how to establish/tear-down sessions and how to
transmit upper-layers
·
TCP uses a
combination of headers between sender and receiver to manage each session
o Application data is carried over these sessions
(which is a combination of application headers and raw-data)
·
Why not
to send application data over IP Layer directly instead of introducing
Transport Layer?
·
Application
Data don't have mechanisms to avoid data loss and corruption therefore they are
encapsulated over transport layer which enable features like error detection,
retransmissions, etc. For example, HTTP protocol which
carries HTTP data don't have headers for error detection or recovery. However,
because its encapsulated over TCP, lost data segments will be detected and
retransmitted
·
Summary of TCP headers,
size of each header and role of each header
·
TCP Windowing
o TCP protocol divides the actual application data
into segments
o The size of each segment is communicated using
TCP Option Max Segment Size (MSS) during session handshake
o Because of TCP reliability each segment needs to
be acknowledged with ACK Flag packet
o While sender is waiting for ACK packet, it
will send other TCP segments for faster communication
o The number of segments allowed to be sent without
receiving ACK packets for them is called Window Size
·
Window Size will be
selected by operating system
·
Max possible
Windows Size is 2^16 = 65,536 bytes
·
This means for MSS
1420 bytes, the max number of segments to be sent without ACK = 65536 / 1420 =
46.1521 segments
·
If no ACK
received for X-Allowed packets within timeout, the sender will
retransmit
Example#1
Host B is sending data to Host A,
using a window size equal to one. This means that Host B is expecting an
"ACK" for each data segment it sends to Host A. Once the first data
segment is sent, Host A receives it and sends an "ACK 2" to Host B.
You might be wondering why "ACK 2" and not just "ACK"?
The "ACK 2" is translated
by Host B to say: 'I acknowledge (ACK) the packet you just sent me and I am
ready to receive the second (2) segment'. So Host B gets the second data
segment ready and sends it off to Host A, expecting an "ACK 3"
response from Host A so it can send the third data segment for which, as the
picture shows, it receives the "ACK 3".
However, if it received an "ACK
2" again, this would mean something went wrong with the previous
transmission and Host B will retransmit the lost segment. We will see how this
works in the Acknowledgments section later on.
Example#2
We have a
window size equal to 3, which means that Host B can send 3 data segments to
Host A before expecting an "ACK" back. Host B sends the first 3
segments (Send 1, Send 2 and Send 3), Host A receives them all in good
condition and then sends the "ACK 4" to Host B. This means that Host
A acknowledged the 3 data segments Host B sent and awaits the next data segments
which, in this case, would be 4, 5 and 6
·
TCP Acknowledgment. How it works?
o TCP uses positive acknowledgement retransmission method
o In this method, the sender will transmit segments based on the received
windows size
o Once the sender transmits, it will start a timer to track the ACK
response
o If no ACK response received, sender will transmit the segments again
o Additionally, if the
receiver gets packets not in right sequence, it sends ACK message to
sender indicating to retransmit the missing segment
No comments:
Post a Comment