发送UDP数据包流 [英] Sending a stream of UDP packets

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

问题描述



我想编写一个通过UDP连接发送文件的应用程序。
现在我对可靠传输不感兴趣,我只想获得最大吞吐量字节。我注意到,如果我只是创建一个循环来连续发送数据,那么只有少数数据包可以实现。所以我使用sleep()函数在发送时引入了延迟。所以现在我每10个数据包睡10毫秒,这似乎导致没有数据包丢失(通过本地主机传输)但是这个发送速度仍然接近它应该是的。

所以我想知道,是否有更多"适当"的调节UDP数据包发送的方法,以实现最大吞吐量?

感谢

Hi,

I want to write an application that sends files over a UDP connection.
Right now I am not interested in reliable transfer, I just want to get the maximum throughput of bytes. I notice that if i just create a loop to send data continuously only a few packets actually make it. So I introduced delay while sending, using the sleep() function. So now I sleep 10 ms every 10 packets and this seems to result in no packet loss (over a local host transfer)but still this sending speed is nowhere close to what it should be.

So I wonder, is there a more "proper" way to regulate the sending of UDP packets such as to achieve maximum throughput?

Thanks

推荐答案

如何定义吞吐量?如果你的意思是从主机发送数据包而不考虑它们是否在目的地收到,那么一个简单的循环,甚至是你有N个发送数量的异步应用程序,并且当前一个发送完成时启动另一个发送应该执行特技。
How do you define thruput? If you mean sending packets from the host without regards to whether they were received at the destination, then a simple loop, or even an asynchronous app where you have N number of Sends outudstanding, and start another send when the previous one completes should do the trick.


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

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