我使用的是 Ubuntu 12.04、Chromium 18.0.1025.151(Developer Build 130497 Linux)Ubuntu 12.04、Firefox 12.0,但浏览速度很慢。浏览器底部总是显示“正在等待 aaa.bbb.com”。我该如何调试并找出原因?我通过 Android 设备的蓝牙 PAN 网络连接到 3G 网络。下面是一些统计数据。
$ dig asdsa.com
; <<>> DiG 9.8.1-P1 <<>> asdsa.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 39878
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 13, ADDITIONAL: 13
;; QUESTION SECTION:
;asdsa.com. IN A
;; ANSWER SECTION:
asdsa.com. 307707 IN A 200.31.91.194
;; AUTHORITY SECTION:
com. 34662 IN NS e.gtld-servers.net.
com. 34662 IN NS a.gtld-servers.net.
com. 34662 IN NS k.gtld-servers.net.
com. 34662 IN NS h.gtld-servers.net.
com. 34662 IN NS g.gtld-servers.net.
com. 34662 IN NS l.gtld-servers.net.
com. 34662 IN NS j.gtld-servers.net.
com. 34662 IN NS c.gtld-servers.net.
com. 34662 IN NS b.gtld-servers.net.
com. 34662 IN NS m.gtld-servers.net.
com. 34662 IN NS d.gtld-servers.net.
com. 34662 IN NS f.gtld-servers.net.
com. 34662 IN NS i.gtld-servers.net.
;; ADDITIONAL SECTION:
a.gtld-servers.net. 50538 IN A 192.5.6.30
a.gtld-servers.net. 59333 IN AAAA 2001:503:a83e::2:30
b.gtld-servers.net. 40208 IN A 192.33.14.30
b.gtld-servers.net. 45531 IN AAAA 2001:503:231d::2:30
c.gtld-servers.net. 45531 IN A 192.26.92.30
d.gtld-servers.net. 45526 IN A 192.31.80.30
e.gtld-servers.net. 45526 IN A 192.12.94.30
f.gtld-servers.net. 40177 IN A 192.35.51.30
g.gtld-servers.net. 35936 IN A 192.42.93.30
h.gtld-servers.net. 40177 IN A 192.54.112.30
i.gtld-servers.net. 45526 IN A 192.43.172.30
j.gtld-servers.net. 45526 IN A 192.48.79.30
k.gtld-servers.net. 35936 IN A 192.52.178.30
;; Query time: 227 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Wed Jun 6 22:40:19 2012
;; MSG SIZE rcvd: 499
$ ping google.com
PING google.com (74.125.236.199) 56(84) bytes of data.
64 bytes from maa03s17-in-f7.1e100.net (74.125.236.199): icmp_req=1 ttl=54 time=173 ms
64 bytes from maa03s17-in-f7.1e100.net (74.125.236.199): icmp_req=2 ttl=54 time=162 ms
64 bytes from maa03s17-in-f7.1e100.net (74.125.236.199): icmp_req=3 ttl=54 time=228 ms
64 bytes from maa03s17-in-f7.1e100.net (74.125.236.199): icmp_req=4 ttl=54 time=236 ms
64 bytes from maa03s17-in-f7.1e100.net (74.125.236.199): icmp_req=5 ttl=54 time=162 ms
64 bytes from maa03s17-in-f7.1e100.net (74.125.236.199): icmp_req=6 ttl=54 time=215 ms
64 bytes from maa03s17-in-f7.1e100.net (74.125.236.199): icmp_req=7 ttl=54 time=218 ms
64 bytes from maa03s17-in-f7.1e100.net (74.125.236.199): icmp_req=8 ttl=54 time=232 ms
64 bytes from maa03s17-in-f7.1e100.net (74.125.236.199): icmp_req=9 ttl=54 time=212 ms
^C
--- google.com ping statistics ---
9 packets transmitted, 9 received, 0% packet loss, time 8007ms
rtt min/avg/max/mdev = 162.119/204.385/236.105/28.286 ms
另外,是否有浏览器在加载页面时提供更详细的信息?
编辑 :来自@izx 答案的更多信息
$ curl -w "@curl-timing.cfg" -o /dev/null -s http://www.google.com/
DNS lookup : 0.363
Connect to server (TCP) : 0.512
Connect to server (HTTP/S) : 0.000
Time from start until transfer began: 0.512
Time for redirection (if any) : 0.000
Total time before transfer started : 0.749
Total time : 0.749
Size of download (bytes) : 221
Average d/l speed (bytes/s) : 294.000
$ curl -w "@curl-timing.cfg" -o /dev/null -s http://india.gov.in
DNS lookup : 0.351
Connect to server (TCP) : 0.526
Connect to server (HTTP/S) : 0.000
Time from start until transfer began: 0.526
Time for redirection (if any) : 0.000
Total time before transfer started : 0.770
Total time : 1.643
Size of download (bytes) : 34346
Average d/l speed (bytes/s) : 20905.000
答案1
用于curl
找出网站加载过程中的哪个部分给您带来了麻烦
一般来说,您可以使用curl
该-w
选项来调试“浏览”(或 http/s)。
- 打开终端
sudo apt-get install curl
(如果你还没有的话) 在您的主目录中创建一个名为的文件
curl-timing.cfg
。在其中粘贴:\n DNS 查找:%{time_namelookup}\n 连接到服务器 (TCP) :%{time_connect}\n 连接到服务器 (HTTP/S) : %{time_appconnect}\n 从开始到传输开始的时间:%{time_pretransfer}\n 重定向时间(如果有):%{time_redirect}\n 传输开始前的总时间:%{time_starttransfer}\n \n 总时间:%{time_total}\n 下载大小(字节):%{size_download}\n 平均下载速度 (字节/秒) : %{speed_download}\n \n
然后,尝试下载任意 URL,假设是 Google,使用以下命令:
curl -w "@curl-timing.cfg" -o /dev/null -s http://www.google.com/
输出形式如下:
DNS lookup : 0.012 Connect to server (TCP) : 0.031 Connect to server (HTTP/S) : 0.000 Time from start until transfer began: 0.031 Time for redirection (if any) : 0.000 Total time before transfer started : 0.098 Total time : 0.117 Size of download (bytes) : 14527 Average d/l speed (bytes/s) : 124347.000
与从印度服务器获取网页到美国相比:
$ curl -w "@curl-timing.cfg" -o /dev/null -shttp://india.gov.in
DNS lookup : 0.377 Connect to server (TCP) : 0.716 Connect to server (HTTP/S) : 0.000 Time from start until transfer began: 0.716 Time for redirection (if any) : 0.000 Total time before transfer started : 1.974 Total time : 3.650 Size of download (bytes) : 34345 Average d/l speed (bytes/s) : 9408.000
- 这将告诉您哪些步骤是薄弱环节。尝试多个网站,甚至文件下载。如果
curl
总体上效果良好,则问题可能出在您的浏览器/应用程序上,而不是 TCP/HTTP 和您的网络连接上。 - 有关更多选项,请参阅curl 手册页。搜索
--writeout
可快速跳转到相关部分。