如何控制套接字速率?

发布于 2024-10-02 02:54:22 字数 137 浏览 3 评论 0原文

我想知道如何控制我的网络接口的速率,事实上,我想以 32 Kbits/s 的速率接收并将接收到的数据以 1 Mbits/s 的速率发送到网络......您对如何控制界面速率有什么想法吗?...或者您知道任何可以帮助的技巧吗?...

提前致谢..

I want to know how can I control the rate of my network interface, In fact, I want to receive with a rate of 32 Kbits/s and send the received data to the network with a rate of 1 Mbits/s....do you have any ideas on how to control the interface's rate?....or do you know any tricks that could help?...

Thanks in advance..

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

陌伤浅笑 2024-10-09 02:54:22

数据吞吐率和连接波特率之间存在差异。一般来说,您希望波特率尽可能快(当然没有错误)。一些低级驱动程序或操作系统可能允许您控制这一点,但这从根本上来说是低级硬件/驱动程序问题。

对于数据吞吐率,限制发送很容易,只要不要那么快地调用 send() 即可。这要求您跟踪每个时间段发送的数量并通过睡眠来限制它。

接收可以以同样的方式工作,但您必须考虑到,如果有人发送的速度比您接收的速度快,则可能会出现问题。

There is a difference between data throughput rate and the baud rate of the connection. Generally, you want the baud rate to be as fast as possible (without errors of course). Some low level drivers or the OS may allow you to control this, but it is fundamentally a low-level hardware/driver issue.

For data throughput rate, throttling sending is easy, just don't call send() as fast. This requires that you track how much you are sending per time period and limiting it with sleeps.

Receiving can work the same way, but you have to consider that if someone is sending faster than the rate you are receiving, there may be issues.

说谎友 2024-10-09 02:54:22

你可以做到这一点,你必须只控制时间,并且在第二次和发送时的相同实践中进行不超过或小于32kbits的接收(你可以在函数参数中设置它)。

You can do this, you must only control time and carry about not recv more and less than 32kbits (you can set this in function arguments) in second and same practice on send.

卸妝后依然美 2024-10-09 02:54:22

我已经用“困难的方法”做到了这一点(不知道是否有更简单的方法)。具体来说,我通过控制调用 send() 和/或 receive() 的速率以及我表示愿意在每个调用中发送/接收的数据量来做到这一点。需要一些数学知识才能正确完成,但这并非不可能。

I've done this "the hard way" (dunno if there is an easier way). Specifically, I did it by controlling the rate at which I called send() and/or recv(), and how much data I indicated I was willing to send/receive in each of those calls. It takes a bit of math to do it right, but it's not impossible.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文