构建ASP.Net网页来测试用户连接(带宽)
我们需要在我们的网站上添加一项功能,允许用户测试他的连接速度(上传/下载)。经过一番研究,我发现完成此操作的方法是下载/上传文件,并将文件大小除以该任务所需的时间,如下所示 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
获取下载速度(以位/秒为单位)的公式:
下载:
在服务器上托管一个您知道其下载大小的数据块(html 文档、图像或其他内容),发出 AJAX GET 请求来获取它并测量下载开始和完成之间的时间量。
这可以仅使用 Javascript 代码来完成,但我可能建议您在生成有效负载时包含时间戳,以便计算延迟。
上传:
向您填充了特定大小的垃圾数据的服务器发出 AJAX POST 请求,计算执行此 POST 所花费的时间。
要记住的事项列表:
有关该主题的其他链接
注意:我还没有构建任何这样的服务,但它应该可以解决问题。
The formula for getting the downloadspeed in bit/s:
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:
Other links on the subject
Note: I have not built any service like this, but it should do the trick.