Web Science/Part1: Foundations of the web/Transmission Control Protocol/Three way handshake
Three way handshake
- understand the concept of a logical connection (virtual communication channel) between two computers on the internet
- understand the importance of acknowledging received messages
- be able to understand the process of establishing a tcp / connection
TCP three-way handshake
One of the most important features of TCP is that we can make sure that packages really arrive at the other side when talking to host on the Internet. The basic ideas of achieving this goal is to acknowledge every send package. In order to do so we need to establish connection between the computers. This doesn’t mean physically interconnect the computers but rather to create virtual communication channel which can be used for reliable transmission of IP packages.
So when we wish to establish TCP-connection between 2 hosts on the WEB we need to make sure that both hosts can create this virtual cannel of communication and thereby establish the connection. This is achieved with 3-way handshake.
As you want to establish a connection with another computer you could just send him IP package stating your interest to talk to each other. You do this by sending IP package in which you place a TCP package. Inside the TCP header you specify your wish to synchronize so you set the SYN-bit. Additionally you generate a random 32-bit number between 0 and 2^32 that is called sequence number and send this over to the other host. In the case the recipient successfully receiver the package it can answer back an Acknowledgment message (ACK). This message contains your sequence number +1.
If you never receive this message (which can happen because your package was not delivered) you will receive an error message that the connection could not be established.
In the case you received the data your connection is still not ready. A connection should be symmetric in a sense that both hosts could initialize to send data at any point of time.
Your communication partner not only sends an acknowledgment message to you but also generates his own sequence number and sends it together with SYN-flag set. So as you receive a response you know that your connection is established but you also have to acknowledge your partner request to establish the connection. So you take his sequence number and add 1 and put it as an acknowledgment number to the TCP package. You increase your own sequence number by 1 and put it together with the data that you want to transfer into your next TCP package. This is the 3rd message to be delivered (or at least send).
Now whenever one of the communication participants send data packages the sequence number is increased. This will be used later to assemble packages to the file and the numbers are acknowledged by the other side. If packages are not acknowledged, the host will send package again and again. In this way TCP creates a reliable way of communication.
--Jane Kruch (discuss • contribs) 17:10, 3 November 2013 (UTC)