确保UDP中的数据包顺序 [英] Ensuring packet order in UDP

查看:1719
本文介绍了确保UDP中的数据包顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用两台带有一个应用程序的计算机来发送和接收udp数据报.没有流量控制,并且禁用了ICMP.通常,当我通过应用程序以UDP数据报的形式发送文件时,会收到两个数据包,它们的顺序发生了变化,因此发生了数据包丢失.

I'm using 2 computers with an application to send and receive udp datagrams. There is no flow control and ICMP is disabled. Frequently when I send a file as UDP datagrams via the application, I get two packets changing their order and therefore - packet loss.

我已经禁用了防火墙,并且在计算机之间没有连接硬件开关(它们是直接连接的).

I've disabled and kind of firewall and there is no hardware switch connected between the computers (they are directly wired).

是否有办法确保Winsock和send()将以与到达目的地相同的方式发送数据包?

Is there a way to make sure Winsock and send() will send the packets the same way they got there?

还是操作系统正在这样做?

Or is the OS doing that?

还是需要配置网络设备?

Or network device configuration needed?

推荐答案

UDP是一种轻量级协议,根据设计,它不处理诸如数据包排序之类的事情.如果您想要可靠的数据包传递和排序,TCP是一个更好的选择.

UDP is a lightweight protocol that by design doesn't handle things like packet sequencing. TCP is a better choice if you want robust packet delivery and sequencing.

UDP通常是为那些数据包丢失可以接受或优于TCP必须重新请求数据包而引起的延迟的应用程序而设计的.因此,UDP通常用于媒体流.

UDP is generally designed for applications where packet loss is acceptable or preferable to the delay which TCP incurs when it has to re-request packets. UDP is therefore commonly used for media streaming.

如果限于使用UDP,则必须开发一种方法来识别乱序数据包并对其重新排序.

If you're limited to using UDP you would have to develop a method of identifying the out of sequence packets and resequencing them.

这篇关于确保UDP中的数据包顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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