TCP Stands for “Transmission Control Protocol”. It is a way of communication that uses the Network Layer to transfer the data among the nodes. If you don’t know and want to read more about “Network Layers”, click here. TCP Uses the flags to communicate before the data transmission and uses handshakes to establish and close the connection. You can read more about TCP Handshakes here. Without any further ado let’s get started with the article on what are the TCP Flags and how they are used by TCP.
TCP is a way of Secure communication in which the network makes sure that every data packet has reached its destination without any loss in the packets. It uses the Flags to communicate with the receiver and ask for a confirmation on each packet it sends. It also uses the flags to establish the connection with the receiver so that it can know that receiver is able and willing to receive the data. Here is a detailed description of the most common TCP Flags and their function.
Synchronization SYN TCP Flag
TCP uses the SYN flag to establish the connection between client and server. This is a flag that TCP uses to synchronize itself to the receiver so that it can start sending the data. This flag also tells the receiver that, in what sequence the packets are coming.
Acknowledgment ACK TCP Flag
The ACK flag ensures the delivery of the packet. The receiver sends an ACK flag to the sender each time it receives a packet. This is how the sender knows that receiver has received my packet. Each packet has a sequence number and the receiver sends an ACK flag with a number corresponding to the sequence number on the packet. For Example, if the sender sends three packets in a sequence of “SYN-1, SYN-2, and SYN-3”. Then the receiver will send “ACK-1, ACK-2, ACK-3” to the sender. Three-Way Handshake also uses the SYN and ACK flags to establish the connection.
Finish FIN TCP Flag
To terminate or finish the connection, TCP uses the FIN flag. The sender attaches a FIN flag with the last packet of the data to let the receiver know that the sender has finished sending the data and wants to terminate the communication. Four-Way Handshake uses the FIN flag to terminate the connection between sender and receiver.
TCP uses the RST flag to terminate the connection as well. When the receiver feel that something is wrong with the packet so it sends a RST flag to the sender to let him know that there is something wrong and the we have to terminate the connection. It also happens when a receiver receives a packet but it was not expecting any packet.
Difference Between FIN and RST TCP Flag
|Finish (FIN)||Reset (RST)|
|To end the connection gracefully||RST flag is used to terminate the connection if something wrong happens with the TCP connection|
|Ensures no data loss||All the data will be discarded if the RST flag is sent|
|The receiver can continue the connection if the receiver wants to even after the FIN is sent||The connection has to be stopped|
|To finish one side of the connection||The whole conversation is stopped|
When the Sender wants to send a packet which is urgent then it includes a URG flag in its header. The packet with URG flag has the most priority over other packets. It forwards the packet with this flag to the application layer immediately even if there are other pending packets in the queue to the application layer. When the transmission is successful, the receiver is notified.
Transport layer usually uses the buffer space to store packets for a few amount of time before sending it over the network so that equal amount of data is send every time. Buffer is a small space where all the packets wait for a while before the router send them to the internet. Some applications does not want their packets to wait like messaging applications.
When a transport layer receives a packet with PSH flag it does not wait for the correct amount of data rather it immediately transmits all the data over the internet.
The same thing happen on receiver\’s end. When it receives the packet with PSH flag it knows that this packet cannot wait and I have to process it immediately. Please keep in mind that PSH flag will not transmit out of order. The receiver will process all the packets in the queue in order.
Difference Between PSH and URG TCP Flag
|Push (PSH)||Urgent (URG)|
|All the data in the buffer is pushed for processing||It only sends the urgent data to the receiver|
|The data is delivered in a sequence in which it has been sent||The data is delivered out of sequence|
Thank you for visiting our website CSinfos.com! If you have any queries or if you want to talk about anything you can join our community on our Facebook page “Computer Science“. and you can ask whatever is on your mind right now. You can suggest to us any topic that you want us to explain just like this article.