简体   繁体   English

当UDP头校验和不正确时,UDP包是否被丢弃?

[英]Are UDP Packets dropped when UDP header checksum is incorrect?

如果我打开一个原始套接字,并发送带有错误校验和的udp数据包,那么数据包是否会被tcp / ip堆栈丢弃?

Yes they would be dropped. 是的,他们会被丢弃。 If you need more reliable communication you're much better off using TCP. 如果您需要更可靠的通信,那么使用TCP会更好。

for more information, take a look at this: http://www.diffen.com/difference/TCP_vs_UDP 有关更多信息,请查看: http//www.diffen.com/difference/TCP_vs_UDP

UDP there's no guarantee that the packets will even be sent, let alone received. UDP不保证甚至会发送数据包,更不用说接收了。 If they are in fact received though, they are checked. 如果他们确实收到了,他们会被检查。 If they fail checksum they are dropped. 如果他们的校验和失败,他们就会被丢弃

EDIT: also to add to that, udp does not by default order the packets as they are sent, that has to be done at the application level. 编辑:也是为了补充一点,udp默认情况下不会在发送数据包时对数据包进行排序,这必须在应用程序级别完成。 Bear this in mind if you still intend on using UDP. 如果您仍打算使用UDP,请记住这一点。

If comes packet with wrong checksum, OS will drop it before passing it to the socket. 如果数据包的校验和错误,操作系统会在将其传递给套接字之前删除它。

Destination application cannot determine if packet was lost or comes with wrong checksum. 目标应用程序无法确定数据包是丢失还是校验和错误。 I think that it also cannot force else behavior. 我认为它也不能强迫其他行为。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM