问题描述
我将多个udp数据包连续发送到远程PC.问题是,如果数据量太大,则通道之间的某个设备会遇到缓冲区溢出的情况.我打算限制/限制/控制udp数据包的发送速率.有人可以给我一些如何找到最佳速率发送间隔的指南吗?
Im sending multiple udp packets consecutively to a remote pc. the problem is, if the amount of data is too high, some device somewhere between the channel experience buffer overflow. i intent to limit/throttle/control sending rate of the udp packets. can somebody give me some guide on how to find the optimal rate sending interval?
顺便说一句,请不要在udp上建议tcp.目的不是可靠地发送数据,而是测量最大吞吐量.
By the way, please stop suggesting tcp over udp. the objective is not to send data reliably, but to measure maximum throughput.
推荐答案
然后尝试以下方法:
- 例如从1KB大小的数据包开始.
- 对于他们,计算每秒可以发送多少个数据包-例如-1GB以太网= 100MBytes的原始带宽-> 100000个数据包
- 创建一个压缩包,因此前4个字节将是序列号,其余可以是任何东西-如果您在此处进行测试,请在其中填充零或噪声(随机数据)
- 在发送端,创建一个数据包,并以RATE(先前计算)的速度将其推送一秒钟.计算花费的时间,并
Sleep()
其余时间等待新的时隙. - 在接收端,收集数据包并查看其序列号.如果数据包丢失,请向发送者发送(另一个连接)有关它的一些信息.
- 发件人,关于丢失数据包的信息,应执行
RATE = RATE * .9
之类的操作-将发送速率降低到上一个的90% - 发件人如果没有收到任何丢失的数据包"消息,应每隔几秒钟逐渐提高速率(例如1%)
- 一段时间后,您的RATE将会收敛到您最初想要的东西
- Start with packets of 1KB size (for example).
- For them, calculate how many packets per second will be OK to send - for example - 1GB ethernet = 100MBytes of raw bandwidth -> 100000 packets
- create a packed so first 4 bytes would be the serial number, rest could be anything - if you are testing here, fill it with zeroes or noise (random data)
- on sending side, create a packets and push them at the speed of RATE (previously calculated) for one second. calculate time spent, and
Sleep()
the rest of the time, waiting for new time slot. - on receiving end, gather packets and look into their serial numbers. if packets are missing, send (another connection) some info to the sender about it.
- sender, on info about lost packets, should do something like
RATE = RATE * .9
- reduce sending rate to 90% of a previous one - sender should gradually increase rate (say 1%) every few seconds if it doesn't get any 'lost packets' message
- after some time you RATE will converge to something that you wanted in the first place
一些注意事项:-如果反向连接是TCP,那么那里会有一些开销-如果反向连接是UDP,则您也可以在此处丢弃数据包(因为您正在淹没通道),并且发送方永远不会知道数据包已丢弃-上面的算法无法解决丢失数据或乱序数据的问题,它只会测量吞吐量.
Some considerations:- if back connection is TCP, you'll have some overhead there- if back connection is UDP, you can also have dropped packets here (because you are flooding the channel) and sender could never know that packets are dropped- algorithm above won't solve missing data issue or out-of-order data issue, it will just measure the throughput.
这篇关于C#中的UDP客户端速率控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!