Showing posts with label syn. Show all posts
Showing posts with label syn. Show all posts

Sunday, 20 May 2018

TCP Three-way Handshake

The TCP three-way handshake also called the TCP-handshake.  Three message handshake and/or SYN SYN-ACK ACK is the method used by TCP set up a TCP/IP connection over an IP based network. TCP's three-way handshaking is often referred to as SYN, SYN-ACK, ACK technique because there are three messages transmitted by TCP to negotiate and start a TCP session between two hosts.


Hosts on the network follow each data segment within a session and exchange information about what data is received using the information in the TCP header. TCP is a full-duplex protocol, where each connection represents two one-way communication streams or sessions. To establish the connection, the hosts perform a TCP three-way handshake. Control bits in the TCP header indicate the progress and status of the connection.


The TCP handshaking mechanism is designed that two hosts attempting to communicate can negotiate the parameters of the. TCP socket connection before transmitting data. This 3-way handshake process is also designed so that both ends can initiate and negotiate separate TCP socket connections at the same time. Being able to negotiate multiple TCP socket connections in both directions at the same time allows a single physical network interface, such as Ethernet, to be multiplexed to transfer multiple streams of TCP data simultaneously.




The step of the TCP three-way handshake



  • Establishes that the destination device is present on the network; Host A sends a TCP SYNchronize packet to Host B

  • Verifies that the destination device has an active service and is accepting requests on the destination port number that the initiating Host intends to use. Host B receives A's SYN and then Host B sends a SYNchronize-ACKnowledgement

  • Informs the destination device that the source Host intends to establish a communication session on that port number; Host A receives host B's SYN-ACK and then Host A sends ACKnowledge

  • Host B receives Host A’s ACK. And then TCP socket connection is ESTABLISHED.


The figure illustrates the step of the three-way handshake.


TCP three-way handshake


After the data sending is completed, the sessions are closed, and the connection is terminated. The connection and session mechanisms enable TCP’s reliability function. Here, another 3-way communication is performed to tear down the TCP socket connection. This setup and teardown of a TCP socket connection is part of what qualifies TCP a reliable protocol. TCP also acknowledges that data is successfully received and guarantees the data is reassembled in the correct order.

Monday, 14 May 2018

TCP Server Processes

All application processes running on the server are configured to use a different port number. The port can be configured by default or manually, by a network administrator. On the same server cannot have two services assigned the same port number within the same transport layer services. For example, a host running FTP server and a web server cannot have both configured to use the same port (for example, TCP port 80 for both or port 21 FTP server port for both).


An active server application assigned a specific port, mean that port is considered to be open, which means that the transport layer accepts and processes segments addressed to that specific port number. Every incoming client request addressed to the correct socket is accepted, and the data is passed to the application on the server. There may be many ports open at the same time on a server, one for each active server application.


TCP Connection Establishment


Shake Hands!  When two persons meet each other, they often welcome each other by shaking hands. This act of hands shake is understood by both as a sign for a friendly welcoming. Connections on the network are similar to the handshaking.




A TCP connection between host and server or between two hosts is established in three steps:


Step 1 - The initiating client send requests a client-to-server communication session with the server.


Step 2 – After receiving the request the server acknowledges the client-to-server communication session and requests a server-to-client communication session.


Step 3 – Then the initiating client acknowledges the server-to-client communication session.




[caption id="attachment_7930" align="alignnone" width="569"]tcp TCP Connection Establishment[/caption]


In the figure, you can see the TCP connection establishment.   


TCP Session Termination


For connection closing, the FIN control flag must be set in the segment header. To end each one-way TCP session, a two-way handshake, with a FIN segment and an Acknowledgment (ACK) segment, is used. So, to terminate a single TCP conversation, four exchanges are required to end both sessions.


Step 1 - When the Host-A Send All data and no more data remain to send in the stream, it sends a segment with the FIN flag set to Host-B.


Step 2 - The Host-B sends an ACK to acknowledge the receipt of the FIN to finish the session from Host- A to Host-B.


Step 3 - The Host-B sends a FIN to the Host-A to finish the Host-B to Host-A session.


Step 4 - The Host-A responds with an ACK to acknowledge the FIN from the Host-B.


When all segments have been acknowledged, the session is closed.


The Figure below illustrates the TCP session termination process.




[caption id="attachment_7931" align="alignleft" width="504"]tcp TCP Session Termination[/caption]