TCP 与 UDP。在关闭的端口上发送数据

eby*_*ock 5 tcp udp packet

我试图了解 TCP 和 UDP 数据包在错误检查方面的差异。我知道 UDP 数据包是无连接的,并不关心数据包是否会安全到达目的地。而 TCP 数据包与 UDP 正好相反。

我的问题是,如果数据包发送到远程主机的关闭端口,UDP 和 TCP 数据包会发生什么动作?

UDP 数据包 - 使用 ICMP(代码 3)响应?TCP 数据包 - 使用 RST 数据包响应?

And*_*s J 7

根据RFC 793重置生成规则:

As a general rule, reset (RST) must be sent whenever a segment arrives
which apparently is not intended for the current connection.  A reset
must not be sent if it is not clear that this is the case.

There are three groups of states:

 1.  If the connection does not exist (CLOSED) then a reset is sent
 in response to any incoming segment except another reset.  In
 particular, SYNs addressed to a non-existent connection are rejected
 by this means.
Run Code Online (Sandbox Code Playgroud)

由于端口已关闭(不侦听或通信),因此没有连接,因此 TCP 应该使用 RST 包进行回复。

用于 UDP 的RFC 768未指定对关闭端口的任何操作,但ICMP RFC 792指定消息类型 3 代码 3,目标无法访问:目标端口无法访问,可以发送。

但是,端口只有在未经过滤的情况下才会真正执行此操作。过滤后的连接根本不回复,只是丢弃数据包。过滤通常由任何名副其实的防火墙完成,因为它通过提供更少的信息使攻击者的工作更加困难。