URG和PSH

Push is conventionally used to indicate that the buffer at the side sending the packet has been emptied in conjunction with sending the packet. In other words, when the packet with the PSH bit field set left the sender, the sender had no more data to send.AND the receiver should pass this data to the application as soon as possible.

When you send urgent data, your TCP creates a special segment in which it sets the URG flag and also the urgent pointer field. This causes the receiving TCP to forward the urgent data on a separate channel to the application (for instance on Unix your process gets a SIGURG).

以上两段分别说明了PSH和URG的作用。其中PSH是as soon as possible发送数据,并且the sender had no more data to send,即将缓存中尚未交付的数据一并发送。

而URG则是receiving TCP to forward the urgent data on a separate channel to the application ,接收TCP在一单独通道上转发紧急数据到应用。

下面就简单了解一下两个标志位的概念与区别。

URG紧急位

URG=1,该tcp报文为紧急报文;其中的紧急数据需要直接交付给接收端的进程,而不进入缓存。

​ 紧急数据的长度=紧急指针;

​ 紧急数据的起始点=序号;

​ 紧急数据的终止点=序号+紧急指针;

(综上,紧急指针就是记录紧急数据的字节数,紧急指针永远为正数)

​ 1)在紧急数据后面的数据为普通数据,需要按序缓存

​ 2)窗口为0也可以发送紧急数据

​ 3)紧急数据都处理完成后,tcp就告诉进程恢复到正常操作

PSH推送位

PSH=1,该报文希望,到达对端时,将这个报文及缓存区之间缓存尚未交付的数据一并交付给进程。

​ 1)PSH的数据=本报文数据+缓存区数据

​ 2)PSH的方向—>单方向(接收PSH报文的一端)

区别

  • URG交付给进程的数据:只有紧急数据。
  • PSH交付给进程的数据:缓冲区排好序的数据及当前报文中的数据。