如何使用套接字编程控制文件传输中的下载速率/上传速率
我是网络编程新手,正在尝试使用 C++ 中的套接字编程为我的网络课程作业开发一个用于速率可控文件传输的应用程序。我想知道如何控制文件传输的下载速率/上传速率。其实有没有办法测量主机的带宽呢? (这样我们就可以知道用send()发送的数据被接收的时间)。
I am new to network programming and am trying to develop an application for rate controllable file transfer using socket programming in C++ for my networks' course assignment. I would like to know how to control the download rate/upload rate in file transfer. In fact, is there a way to measure the bandwidth of the host? (so that we can know the time for a data sent with the send() to be received).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最常见的速率限制方法是使用令牌桶。基本上,您按照想要发送的速率递增计数器,然后当您发送数据时,递减该计数器,并且仅发送计数器表示可用的字节数。
The most common method of rate limiting is to use a token bucket. Basically, you increment a counter at the rate you want to send, then when you send the data, you decrement that counter and only send as many bytes as the counter says is available.