In TCP header, there are 6 flags, each of one byte. Those are as follows:
- URG
- ACK
- PSH
- RST
- SYN
- FIN
URG(Urgent Flag): If this flag is set:
- It indicates that the value of urgent pointer in the TCP header is valid.
- It indicates the receiver that certain amount of data/bytes within the current segment is urgent.
- This data need to be prioritized and should be send even out of order, if required to the application side.
- Thus this flag and urgent pointer filed of 16 bits in TCP header goes hand in hand.
Urgent pointer:
- This is a 16 bit field in TCP header, its not a flag.
- It indicates how much data in the current segment counting from the first byte is urgent.
- It defined the number which must be added to the sequence number to get the number of the last urgent bytes in the current segment.
- When the receiving TCP receives a segment with the URG bit set, it extracts the urgent data from the segment, using the value of this urgent pointer, and delivers them, out of order, to the receiving application program.
End of urgent byte: Sequence number of the first byte in the segment + Urgent pointer.
Example of urgent flag and urgent pointer: It is client server protocol helps for opening a command line on remote computer, typically a server.
So consider that sender is sending some data to the application running on different machine. If the problem appears, the host machine needs to abort the data transfer and also make sure that the other end should stop the data processing. Under normal circumstances, abort signal will be sent and segment will be queued up and will be processed in FIFO manner, however we can send the abort the signal with URG flag set so that this segment can be processed with priority and data processing can be stopped on other end.
ACK(Acknowledgement Flag):
If this flag is set, it indicates the successful receipt of the packets and again this works hand in hand with acknowledgment number field in TCP header which indicates the sequence number of the next byte that the receiver wish to receive.
PSH(PUSH Flag):
- This is the push flag and if this flag is set means sending TCP should not wait for the buffer to be filled as per to receiving window size.
- In case of TCP, there is a buffer present at both at sender and receiver side and data is buffered till it it reaches the window size of its partner. Once the data is buffered to window size, a segment is formed and send to the receiving side.
- But in case of some interactive application where data size can be as small as 1 bytes, a delayed transmission and delayed delivery of data may not be acceptable by the application program.
- In such scenarios push flag is set to indicates that data should not be buffered and segment should be formed and send immediately and even on receiving side it should not be buffered rather should be send to application program immediately.
Application:
The PSH flag is also used to facilitate real-time communication via TCP. The short Telnet session carrying Telnet data have the PSH flag set to prevent key presses from being buffered by TCP.
A simple example would be a TCP stream, e.g real player, where data must be sent and processed (by the receiver) immediately to ensure a smooth stream without any cut offs.
RST (Reset Flag):
- This is reset flag and is used for abnormal termination of TCP connection unlike FIN which is normal termination.
- That is some segment is received which it should not have been, in that case, the receiver sends a reply with RST flag set.
- It is used to terminate the connection from the sender side if it feels that something is wrong with TCP connection or the conversation should not exist.
- Reset flag can be used with urgent flag to terminate the connection immediately without any further processing of data.
- It does ceases the complete communication and there may be data loss.
SYN(Synchronization Flag):
This is also called synchronization flag and used to initiate the connection and this flag is set in the first packet send from each end.
FIN(Finished Flag):
This is used for normal termination of the connection and here connection should be terminated from both the ends unlike that of RST flag.
Difference between RST and FIN Flag:
- RST leads to abnormal termination of connection where as FIN is a normal termination.
- In RST, the complete communication is ceased by single party but in FIN it has be terminated from both parties.
- In RST, data may be lost but not in case of FIN.
Difference between URG and PSH Flag:
- In case of URG, not all the data is pushed to network layer(sender) and to application layer(receiver), only the urgent bytes is dealt with urgency while in case of PSH, complete data is dealt with urgency.
- In case of URG, data is delivered out of of sequence but in PSH, it is delivered in order.
Categories: Networking
Leave a Reply