UDP 可以重传丢失的数据吗? [英] Can UDP retransmit lost data?

查看:90
本文介绍了UDP 可以重传丢失的数据吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道该协议不支持这一点,但是对于需要某种程度的可靠性以在其应用程序中构建一种用于在发现数据包损坏时请求重新传输数据包的方法的客户来说,这是否常见?

I know the protocol doesn't support this but is it common for clients that require some level of reliability to build into their application a method for requesting retransmission of a packet if found to be corrupt?

推荐答案

如果客户需要可靠性(或者有时只是一些可靠性)但不是任何可靠性,那么在 UDP 之上实现可靠性是很常见的TCP 提供的其他东西,例如严格的按顺序交付,如果他们想要,同时低延迟(或多播,在它工作的地方).

It is common for clients to implement reliability on top of UDP if they need reliability (or sometimes just some reliability) but not any of the other things that TCP offers, for example strict in-order delivery, and if they want, at the same time, low latency (or multicast, where it works).

一般来说,如果有紧急原因(需要非常低的延迟和高速,例如抽搐游戏),您只会希望使用可靠的 UDP.在每种正常"情况下,简单地使用 TCP 都会为您提供同样或更好的服务.
另请注意,在 UDP 之上实现自己的堆栈很容易,该堆栈的性能比 TCP 差.

In general, you will only want to use reliable UDP if there are urgent reasons (very low latency and high speed needed, e.g. for a twitch game). In every "normal" case, simply using TCP will serve you equally well or better.
Also note that it is easy to implement your own stack on top of UDP that performs worse than TCP.

请参阅 enet 以获取在UDP(Raknet 或 HawkNL 是其他示例).

See enet for an example of a library that implements reliability (and some other features) on top of UDP (Raknet or HawkNL would be other examples).

这篇关于UDP 可以重传丢失的数据吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆