这是发送序列大型UDP数据包的最佳方法 [英] Which is the best approach to send large UDP packets in sequence

查看:918
本文介绍了这是发送序列大型UDP数据包的最佳方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个需要通过协议UDP每100毫秒发送数据的Andr​​oid应用。每个UDP数据包有15000个字节的平均水平。数据包在广播发送

I have an android application that needs to send data through the protocol UDP every 100 milliseconds. Each UDP packet has 15000 bytes average. packets are sent in broadcast

每100毫秒以下行通过一个循环运行。

Every 100 milliseconds lines below are run through a loop.

DatagramPacket sendPacket = new DatagramPacket(sendData, sendData.length, broadcast, 9876); 
clientSocket.send(sendPacket);

应用程序开始工作正常,但约1分钟后收到的数据包的频率降低,直到数据包不会在抵达目的地。

Application starts working fine, but after about 1 minute frequency of received packets decreases until the packets do not arrive over the destination.

的理论极限(在Windows上)对于UDP数据包的最大尺寸为65507字节。

The theoretical limit (on Windows) for the maximum size of a UDP packet is 65507 bytes

我知道一个网络媒体MTU是1500字节,当我发送一个数据包越大它被分成几个片段,如果片段没有到达目的地的整个包丢失。

I know the media MTU of a network is 1500 bytes and when I send a packet bigger it is broken into several fragments and if a fragment does not reach the destination the whole package is lost.

我不明白,为什么在第一次1分钟的数据包被正确和而包不到货后多发。所以我想这将是解决这个问题最好的办法?

I do not understand why at first 1 minute the packets are sent correctly and after a while the packets do not arrive more. So I wonder what would be the best approach to solve this problem?

推荐答案

这正是您所描述的问题。每次广播数据包被分成44包。如果这些中的任何一个丢失,数据报丢失。只要你有足够的流量造成的,比如1%的丢包,你有35%的数据包丢失。 2%丢包率等于60%,报损。

It's exactly the problem you described. Each datagram you broadcast is split into 44 packets. If any one of those is lost, the datagram is lost. As soon as you have enough traffic to cause, say, 1% packet loss, you have 35% datagram loss. 2% packet loss equals 60% datagram loss.

您需要保持你的广播数据包足够小,以免片段。如果你有65,507字节块流这样的,你不能改变的事实,你必须有整个块的数据是有用的,那么天真UDP广播是的的选择。

You need to keep your broadcast datagrams small enough not to fragment. If you have a stream of 65,507 byte chunks such that you cannot change the fact that you must have the whole chunk for the data to be useful, then naive UDP broadcast was bad choice.

我不得不知道更多关于你的应用程序,以作出明智的建议的细节。但是,如果你身边有64​​KB的数据块,这样你需要整个块的数据是有用的,你不能改变这种状况,那么你应该使用划分的方法将数据成片的一些冗余,使得有些作品可能会丢失。与擦除编码,则可以将65,507个字节的数据为46块,每1,490个字节,使得原始数据可以从任何44块被重建。这将容忍大约只有在数据量增长了4%中度报损失。

I'd have to know a lot more about the specifics of your application to make a sensible recommendation. But if you have a chunk of data around 64KB such that you need the whole chunk for the data to be useful, and you can't change that, then you should be using an approach that divides that data into pieces with some redundancy such that some pieces can be lost. With erasure coding, you can divide 65,507 bytes of data into 46 chunks, each 1,490 bytes, such that the original data can be reconstructed from any 44 chunks. This would tolerate moderate datagram loss with only about a 4% increase in data size.

这篇关于这是发送序列大型UDP数据包的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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