TCP, or Transmission Control Protocol, is a communications protocol in the IP (Internet Protocol) suite which occurs in the fourth layer of the OSI Reference Model.
TCP is a connection-oriented transmission protocol, which means before any transmission occurs, TCP will need to establish a connection.
In order to establish a connection, TCP goes through a three-way handshake operation.
- Device A wants to establish communication with Device B. Device A sends out a segment with the Syn flag set to 1.
- Device B receives the segment with the Syn flag set to 1 from Device A and returns a segment with a Syn and Ack flag set to 1.
- Device A receives the segment with the Syn and Ack flag set to 1 from Device B and return a segment with an Ack flag set to 1.
After the three-way handshake is complete, data transmission will then occur. Once the once the transmission is done, a segment with the Fin flag set to 1 will signal the termination of the connection.