speedtest的原理

Speedtest.net operates entirely over HTTP for maximum compatibility. It tests ping (latency), download speed and upload speed.

(speedtest是承载在HTTP协议之上的,包括ping测试,下载测试和上传测试)

Ping

  1. This test sends HTTP requests to the selected server, and measures the time it takes to get a response. (选择好server后,发送HTTP请求server,根据返回响应的时间来计算ping时间)

Download Speed

  1. Your computer downloads small binary files from the web server to the client, and we measure that download to estimate the connection speed.
  2. Based off this result, we choose how much data to download for the real test. Our goal is to pick the right amount of data that you can download in 10 seconds, ensuring we get enough for an accurate result but not take too long.(下载测试只持续10s钟)
  3. We prevent caches from throwing off results by appending random strings to each download.(每次测试前都会清楚一下cache,避免假测)
  4. Once we start downloading, we use up to four HTTP threads to saturate your connection and get an accurate measurement.(启动4个HTTP线程来进行测试)
  5. Throughput samples are received at up to 30 times per second.(每秒采样30次)
  6. These samples are then aggregated into 20 slices (each being 5% of the samples).(每个采样分成20片)
  7. The fastest 10% and slowest 30% of the slices are then discarded. We'll explain that more below.(最快的10%和最慢的30%分片去掉)
  8. The remaining slices are averaged together to determine the final result.(结果是剩余分片的平均)

Since we are measuring data transported over HTTP (via Flash), there are the following factors that can affect speed: potential protocol overhead, buffering due to the many layers between our application and the raw data transfer, and throughput bursting due primarily to CPU usage. These factors lead us to drop the top 10% and bottom 10% of our slices as outliers.(考虑到一些外在的因素影响,因此把最快的和最慢的部分去掉)

Additionally, we keep the default test length short for user experience. Because the test is shorter, the ramp-up period can take a significant part of the beginning of the test, leading us to drop another 20% of the bottom result slices.

Upload Test

  1. A small amount of random data is generated in the client and sent to the web server to estimate the connection speed.(上次随机生成的数据到服务器)
  2. Based on this result, and appropriately sized chunck of randomly generated data is selected for upload.(选择合适的生成数据进行上传)
  3. The upload test is then performed in chunks of uniform size, pushed to the server-side script via POST.
  4. We'll use up to four HTTP threads here as well to saturate the connection.(使用4个HTTP线程进行上传测试)
  5. Chunks are sorted by speed, and the fastest half is averaged to eliminate anomalies and determine the result.

Deciding the number of threads

Speedtest.net will use up to four http threads during the download and upload portions of the test. However, it will only use more than two threads if they are needed to accurately measure the speed, so as to minimize the effect of HTTP overhead on lower-speed connections. After the pre-test, if the connection speed is at least 4 megabits per second, then Speedtest.net will use four threads. Otherwise, it will default to two threads.(只有预测试超过4Mbps,才会使用4线程;否则使用2线程)

However, there is a hurdle on older browsers: on Internet Explorer 7 and earlier (as well as Firefox 2 and earlier), the browser strictly adheres to the HTTP specification of only two threads per hostname. So for those older browsers, in order to scale up to four threads we must open the third and fourth thread to a secondary URL provided by the host that points to the same server. This way, we can work around the limitations of those older browsers and still measure higher-speed connections accurately. Most of our hosts do have a working secondary URL, but if you're testing from an older browser to a host that doesn't, Speedtest.net will be limited to two threads at maximum. This is one reason why we recommend that all visitors use up-to-date browsers.(在老的浏览器上怎样来操作使用4线程测速)

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值