TCP (Transmission Control Protocol) is one of main Transport Layer protocol which provides reliable, connection-oriented communication over IP networks between two end stations. When data is provided to the IP protocol, it encapsulates them in IP datagrams.TCP is defined by the Internet Engineering Task Force (IETF) in the Request for Comment (RFC) standards document number 793.
Related- TCP vs UDP
With TCP protocol applications can communicate securely independent from the lower layers. The Layer 3 devices (Router/Layer 3 Switch etc.) only need to route data as datagrams, without concerning about data control since congestion control and monitoring is performed by the transport layer.
BELOW ARE THE SALIENT FEATURES OF TCP PROTOCOL –
Connection Oriented – TCP is a connection orientated protocol, i.e. it enables two machines which are communicating to control the status of the transmission.
Reliability – TCP guarantees reliable, synchronized startup between endpoints (using “3-way handshake”)
Multiplexing – TCP makes it possible to multiplex data, i.e. so that information coming from distinct sources (applications for example) on the same line can be circulated simultaneously. Multitasking is achieved through the use of port numbers to convey data from various applications on the same line .
Flow control – Network devices may be operating at different data rates. It may happen a sending device to send data at a much faster rate than the receiver can handle. TCP uses concept of sliding window for implementing flow control.The TCP at the receiving device, when sending an ACK back to the sender, also indicates to the TCP at the sending device, the number of bytes it can receive (beyond the last received TCP segment) without causing serious problems in its internal buffers.
Ordered data transfer – TCP makes it possible to put datagrams back in order when coming from the IP protocol.
Congestion control – Congestion control can be used to calculate the amount of data the sender can send to the destination on the network.TCP congestion control algorithms are used to detect and control congestion. Following are some of the congestion algorithms used by TCP –
- Additive Increase/ Multiplicative Decrease.
- Slow Start
- Congestion Avoidance
- Fast Retransmit
- Fast recovery
Gracefully connection closure – TCP guarantees delivery of all data after endpoint Shutdown. Connection termination is implemented so that each device terminates its end of the connection separately. This means that device will no longer send data, but can continue to receive it until the other device has decided to stop sending. This allows all data that is pending to be sent by both sides of the communication to be flushed before the connection is ended.
Related – TCP FIN and RST
TCP HEADER FORMAT
MEANING OF THE DIFFERENT FIELDS:
- Source port (16 bits): Port related to the application in progress on the source machine
- Destination port (16 bits): Port related to the application in progress on the destination machine
- Sequence number (32 bits): When the SYN flag is set to 0, the sequence number is that of the first word of the current segment.When SYN is set to 1, the sequence number is equal to the initial sequence number used to synchronize the sequence numbers (ISN)
- Acknowledgement number (32 bits): Also called the acquittal number relates to the sequence number of the last segment expected and not the number of the last segment received.
- Data offset (4 bits): This makes it possible to locate the start of the data in the packet. Here, the offset is vital because the option field is a variable size
- Reserved (6 bits): A currently unused field but provided for future use
- Flags (6×1 bit): The flags represent additional information: •URG: if this flag is set to 1 the packet must be processed urgently
- ACK: if this flag is set to 1 the packet is an acknowledgement.
- PSH (PUSH): if this flag is set to 1 the packet operates according to the PUSH method.
- RST: if this flag is set to 1 the connection is reset.
- SYN: The TCP SYN flag indicates a request to establish a connection.
- FIN: if this flag is set to 1 the connection is interrupted.
- Window (16 bits): Field making it possible to know the number of bytes that the recipient wants to receive without acknowledgement
- Checksum (CRC): The checksum is conducted by taking the sum of the header data field, so as to be able to check the integrity of the header
- Urgent pointer (16 bits): Indicates the sequence number after which information becomes urgent
- Options (variable size): Various options
- Padding: Space remaining after the options is padded with zeros to have a length which is a multiple of 32 bits