在speedtest.net下载和上传速度与速度不匹配 [英] Download and upload speed not matching with speed in speedtest.net
本文介绍了在speedtest.net下载和上传速度与速度不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图找到我的连接的下载和上传速度。为此我将有效载荷上传到另一个服务器并同时从同一服务器下载有效载荷。通过这种方式,我可以获得下载和上传速度。
问题是我无法像www.speedtest.net那样获得价值。这是我上传和下载的脚本。
上传
I m trying to find the download and upload speed of my connection. For that im uploading a payload to a another server and simultaneously downloading payload from the same server. This way i am able to get a download and upload speed.
The issue is that i am not being able to get values almost as that in www.speedtest.net. Here are my scripts for upload and download.
upload
var uploadhttp;
var url = "http://Server/abc/";
var params =PAYLOAD(arnd 100kb)
function handler() {//Call a function when the state changes.
if(uploadhttp.readyState == 4 && uploadhttp.status == 200) {
alert(uploadhttp.responseText);
}
}
function postMethod() {
try
{
getHTTPObject();
if(!uploadhttp)
alert("failed to create object");
uploadhttp.open("POST", url, true);//,"jio","rancore");
//Send the proper header infomation along with the request
uploadhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
uploadhttp.onreadystatechange = handler;
uploadhttp.send(params);
}
catch(e)
{
alert(e);
}
}
//I am callin postMethod ever 100ms so that it could upload the payload to the server hence giving me my upload speed.
//Similarly the download script is
var xhr;
xhr = new XMLHttpRequest();
var data;
function getDownload()
{
try
{
xhr.onreadystatechange=function()
{
if (xhr.readyState==4 && xhr.status==200)
{
//alert(xhr.responseText);
}
}
xhr.open("GET", "http://server/download/speedtest.php", true);
xhr.send();
data=xhr.responseText;
//alert(data);
}
catch(e)
{
alert(e);
}
}
//To download a payload i have included a php script which reads a 40MB file and returns payload as a responseText
header('Access-Control-Allow-Origin: *');
$filepath="/path/argo.MP4";
$filesize = filesize($filepath);
$val=readfile($filepath);
header('Cache-Control: no-cache');
header('Content-Transfer-Encoding: binary');
header('Content-Length: '. $filesize);
echo $val;
}
?>
推荐答案
filepath = / path / argo.MP4;
filepath="/path/argo.MP4";
filesize = filesize(
filesize = filesize(
filepath);
filepath);
这篇关于在speedtest.net下载和上传速度与速度不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文