TCP 与 UDP 吞吐量
假设我们在容量为 C 的同一链路上有 tcp 和 udp 连接。 Tcp 的传输速率为 C,而 UDP 的传输速率为 8C。哪个会更有效率?
Suppose we have tcp and udp connection over the same link of capacity C . Tcp has transfer rate of C whereas UDP has 8C as its transfer rate . Which will be more efficient ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
理论上,如果任何数据包在传输过程中没有发生任何事情,UDP 会更快。 UDP 不需要像 TCP 那样确认每个数据包(ACK 标志)。此外,不需要握手,也不需要断开连接。在理想网络中,UDP 是更快的选择,不会丢失任何数据包。
问题是,在现实世界的示例中,UDP 会丢失数据包。你会变慢,因为你也必须在 UDP 中实现像 TCP 那样的数据包控制。 UDP 不确认数据包的接收,也不会敲门查看是否有人在家(TCP SYN)。 UDP 数据包的结构比 TCP 数据包更容易,但因其大小而牺牲了安全性。 http://www.diffen.com/difference/TCP_vs_UDP 描述了差异。
所以对于你的例子来说。如果电缆可以容纳 C 个数据包/秒,TCP 的速率为 C 个数据包/秒,UDP 的速率为 8*C 个数据包/秒,那么 UDP 会快得多。
Theoretically, if nothing on the way happens to any of the packets, UDP would be faster. UDP doesn't require to acknowledge every packet like TCP does (ACK Flag). Also, no handshake and no connection tear-down is required. UDP would be the faster choice in an ideal network, where no packets get dropped.
The problem is, in a real world example, UDP would lose packets. You would be slower, because you would have to implement a packet control like in TCP in UDP too. UDP does not acknowledge the receival of packets, and it also does not knock on the door to see if anybody is home (TCP SYN). UDP Packets are easier structured than TCP packets, but sacrifice security for their size. http://www.diffen.com/difference/TCP_vs_UDP describes the differences.
So for your example. With a cable that can hold C packets/s, and TCP at a rate of C packets/s and UDP at a rate of 8*C packets/s, UDP would be much faster.