Cisco – Can anyone explain to me the difference between the PSH and URG flags in TCP segment

ciscolayer4networkingtcptransport-protocol

According to me when PSH flag is set, it indicates that data will have to be sent immediately to the wire and on receiving side the data has to be pushed to the application immediately.

When URG flag is set it indicates that urgent data has to be sent immediately to wire from sender side and on receiving end the urgent data has to be sent immediately to application.

Urgent pointer in TCP segment is used to indicate that amount of urgent data present in TCP segment. So, for example, if the segment contained 400 bytes of urgent data followed by 200 bytes of regular data, the URG bit would be set and the Urgent Pointer field would have a value of 400.

The problem here is this: is urgent data is same as push data?
If yes, then why are two different URG and PSH flag are used in TCP segment?
Please help me to clear my doubts in simple language.

I am new to networking field and preparing for the CCNA exam.
Thanks in advance 🙂

Best Answer

Jeremy Stretch has a good article on this.

This is where the PSH flag comes in. The socket that TCP makes available at the session level can be written to by the application with the option of "pushing" data out immediately, rather than waiting for additional data to enter the buffer. When this happens, the PSH flag in the outgoing TCP packet is set to 1 (on). Upon receiving a packet with the PSH flag set, the other side of the connection knows to immediately forward the segment up to the application. To summarize, TCP's push capability accomplishes two things:

• The sending application informs TCP that data should be sent immediately.

• The PSH flag in the TCP header informs the receiving host that the data should be pushed up to the receiving application immediately.

The URG flag is used to inform a receiving station that certain data within a segment is urgent and should be prioritized. If the URG flag is set, the receiving station evaluates the urgent pointer, a 16-bit field in the TCP header. This pointer indicates how much of the data in the segment, counting from the first byte, is urgent.