Difference between revisions of "网络问题排查"

From VerySM
Jump to: navigation, search
(Created page with "== 网络相关工具 == ====查看本机IP==== <code> curl ip.seeip.org </code> ====查看服务端IP==== <code> dig api.map.baidu.com </code> ====检查网络丢包状...")
 
(No difference)

Latest revision as of 19:37, 8 October 2019

网络相关工具

查看本机IP

curl ip.seeip.org

查看服务端IP

dig api.map.baidu.com

检查网络丢包状况

ping api.map.baidu.com -c 60

查看路由信息(需要root权限)

traceroute -Tp 80 api.map.baidu.com -q 9

查看请求各阶段延时

 curl  -v -s -w  '\nhttp:%{http_code}\tdns:%{time_namelookup}\tconnect:%{time_connect}\tstart:%{time_starttransfer}\ttotal:%{time_total}\n' \
 'http://api.map.baidu.com/geocoder/v2/?ak=fUwAMrNu7TrcuoP8OnOccQb9wEMeByvN&output=json&location=12948060.96,4845143.02&coordtype=bd09mc&latest_admin=1'  

抓取指定域名的通信包(需要root权限)

tcpdump host api.map.baidu.com -w bmap.pcap

读取抓包数据

tcpdump -r bmap.pcap -A

综合测试

#抓取指定域名的通信包(需要root权限)
tcpdump host api.map.baidu.com  -w  bmap.pcap
 
#发送2000次请求,打印各阶段耗时(如果能直接抓取线上数据,可省略此步)
for n in {1..2000} ; do \
curl  -v -s -w  '\nhttp:%{http_code}\tdns:%{time_namelookup}\tconnect:%{time_connect}\tstart:%{time_starttransfer}\ttotal:%{time_total}\n' \
 'http://api.map.baidu.com/geocoder/v2/?ak=fUwAMrNu7TrcuoP8OnOccQb9wEMeByvN&output=json&location=12948060.96,4845143.02&coordtype=bd09mc&latest_admin=1' \
; done  &>http.test.txt
 
#按 Control-C 停止抓包,将抓包数据拿来分析
tcpdump -r bmap.pcap -A