Saturday, March 2, 2013

TCP 3-WAY HANDSHAKE

TCP the transport control protocol, its a reliable communication protocol and provides end-to-end services.
The applications HTTP,FTP,TELNET,SMTP,IMAP uses the TCP because these protocols need the connection oriented services and TCP provides the Flow control and Congestion control.
UDP is less overhead when comparing with TCP, TCP header has many fields and these are used for the accurate data delivery without a packet loss. Have a look at the TCP and UDP headers.

                                                                 TCP Header


UDP Header


As TCP is connection oriented protocol it has to keep track of the established connections and carries all the required fields.

UDP is simple and less overhead protocol which is used by applications like DNS,DHCP,RTP,SNMP

3-way handshake:
Before any data is transferred by TCP first it establishes the connection which is called as 3-way handshake.The TCP connection is established with 3 packets [SYN],[SYN,ACK],[ACK].



lets see how the Telnet connection is established between the two routers,

Telnet from 10.0.0.2 to 10.0.0.1

First packet from node 10.0.0.2 to 10.0.0.1, seq no=0,Des port is 23 telnet application ,sync bit is set ,window size is 4128



Now 10.0.0.1 replies to this packet with SYN,ACK bit set,with its own seq number and window size



The 10.0.0.2 replies with ACK to 10.0.0.2 with seq=1


Connection is established between the two nodes once the 3 packets are exchanged, the node 10.0.0.2 can execute the commands in the telnet session established to 10.0.0.1 node. Once the user exit the telnet session the 10.0.0.1 sends a packet to 10.0.0.2 to tear off the connection with FIN bit set