构建ASP.Net网页来测试用户连接(带宽)

发布于 2024-12-17 15:04:00 字数 537 浏览 1 评论 0原文

我们需要在我们的网站上添加一项功能,允许用户测试他的连接速度(上传/下载)。经过一番研究,我发现完成此操作的方法是下载/上传文件,并将文件大小除以该任务所需的时间,如下所示 http://www.codeproject.com/KB/IP/speedtest.aspx 但是,这在我的情况下是不可能的,这应该是一个 Web 应用程序,因此出于明显的安全原因,我无法将文件下载到用户的计算机/从用户的计算机上传文件。据我所知,这个下载/上传任务应该在服务器上,但是如何呢? 这个网站正是我想要的,但是在 php http://www.brandonchecketts.com/open -源速度测试。不幸的是,我没有任何关于 php 的背景,而且这个任务非常紧急。 我真的不需要使用像 speedtest 这样的东西,

谢谢

We need to add a feature to our website that allows the user to test his connection speed (upload/download). After some research I found that the way this being done is downloading/uploading a file and divide the file size by the time required for that task, like here http://www.codeproject.com/KB/IP/speedtest.aspx
However, this is not possible in my case, this should be a web application so I can't download/upload files to/from user's machine for obvious security reasons. From what I have read this download/upload tasks should be on the server, but how?
This website has exactly what I have in mind but in php http://www.brandonchecketts.com/open-source-speedtest. Unfortunately, I don't have any background about php and this task is really urgent.
I really don't need to use stuff like speedtest

thanks

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

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

发布评论

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

评论(1

久伴你 2024-12-24 15:04:00

获取下载速度(以位/秒为单位)的公式:

DataSize in byte * 8 / (time in seconds to download - latency to the server).

下载:
在服务器上托管一个您知道其下载大小的数据块(html 文档、图像或其他内容),发出 AJAX GET 请求来获取它并测量下载开始和完成之间的时间量。

这可以仅使用 Javascript 代码来完成,但我可能建议您在生成有效负载时包含时间戳,以便计算延迟。

上传:
向您填充了特定大小的垃圾数据的服务器发出 AJAX POST 请求,计算执行此 POST 所花费的时间。

要记住的事项列表:

  • 您将无法测量比服务器更高的带宽
  • 并发用户将耗尽带宽,如果这将成为问题,请建立一个“限制”
  • 很难建立一项精确测量带宽的服务,您链接到的服务提供 5Mbit/s当我实际的时候根据 Bredbandskollen,速度约为 30Mbit/s。

有关该主题的其他链接

注意:我还没有构建任何这样的服务,但它应该可以解决问题。

The formula for getting the downloadspeed in bit/s:

DataSize in byte * 8 / (time in seconds to download - latency to the server).

Download:
Host a blob of data (html document, image or whatever) of which you know the downloadsize on your server, make a AJAX GET request to fetch it and measure the amount of time between the start of the download and when it's finished.

This can be done with only Javascript code, but I would probably recommend you to include a timestamp when the payload was generated in order to calculate the latency.

Upload:
Make a AJAX POST request towards the server which you fill with junk data of a specific size, calculate the time it took to perform this POST.

List of things to keep in mind:

  • You will not be able to measure higher bandwith than your servers
  • Concurrent users will drain the bandwith, build a "limit" if this will be a problem
  • It is hard to build a service to measure bandwidth with precision, the one you linked to is presenting 5Mbit/s to me when my actual speed is around 30Mbit/s according to Bredbandskollen.

Other links on the subject

Note: I have not built any service like this, but it should do the trick.

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