mirror of
https://github.com/linkedin/school-of-sre
synced 2026-01-18 14:38:02 +00:00
Deployed 52e7ed5 with MkDocs version: 1.1.2
This commit is contained in:
@@ -1271,11 +1271,11 @@
|
||||
<p>TCP is a transport layer protocol like UDP but it guarantees reliability, flow control and congestion control.
|
||||
TCP guarantees reliable delivery by using sequence numbers. A TCP connection is established by a three way handshake. In our case, the client sends a SYN packet along with the starting sequence number it plans to use, the server acknowledges the SYN packet and sends a SYN with its sequence number. Once the client acknowledges the syn packet, the connection is established. Each data transferred from here on is considered delivered reliably once acknowledgement for that sequence is received by the concerned party</p>
|
||||
<p><img alt="3-way handshake" src="../images/established.png" /></p>
|
||||
<div class="highlight"><pre><span></span><code><span class="c1">#To understand handshake run packet capture on one bash session</span>
|
||||
tcpdump -S -i any port <span class="m">80</span>
|
||||
<span class="c1">#Run curl on one bash session</span>
|
||||
<pre><code class="language-bash">#To understand handshake run packet capture on one bash session
|
||||
tcpdump -S -i any port 80
|
||||
#Run curl on one bash session
|
||||
curl www.linkedin.com
|
||||
</code></pre></div>
|
||||
</code></pre>
|
||||
<p><img alt="tcpdump-3way" src="../images/pcap.png" /></p>
|
||||
<p>Here client sends a syn flag shown by [S] flag with a sequence number 1522264672. The server acknowledges receipt of SYN with an ack [.] flag and a Syn flag for its sequence number[S]. The server uses the sequence number 1063230400 and acknowledges the client it’s expecting sequence number 1522264673 (client sequence+1). Client sends a zero length acknowledgement packet to the server(server sequence+1) and connection stands established. This is called three way handshake. The client sends a 76 bytes length packet after this and increments its sequence number by 76. Server sends a 170 byte response and closes the connection. This was the difference we were talking about between HTTP/1.1 and HTTP/1.0. In HTTP/1.1 this same connection can be reused which reduces overhead of 3 way handshake for each HTTP request. If a packet is missed between client and server, server won’t send an ack to the client and client would retry sending the packet till the ACK is received. This guarantees reliability.
|
||||
The flow control is established by the win size field in each segment. The win size says available TCP buffer length in the kernel which can be used to buffer received segments. A size 0 means the receiver has a lot of lag to catch from its socket buffer and the sender has to pause sending packets so that receiver can cope up. This flow control protects from slow receiver and fast sender problem</p>
|
||||
|
||||
Reference in New Issue
Block a user