91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

WIN2012 TCP ECN 啟用導致速度慢

發布時間:2020-06-12 19:45:56 來源:網絡 閱讀:2668 作者:天山三害 欄目:系統運維

測試偶爾訪問指定網站速度慢的原因
1 現象 某業務在客戶服務器上,開發人員反映周期性速度慢,開發人員反饋,由于需要到xxx.com去取數據,慢的原因是取數據慢
直接訪問該站點下載文件發下下載速度很快
2 測試腳本如下

3 測試結果發現 是每次第一次訪問xxx.com的時候的 建立連接的時間很慢,需要9秒以上

4 最終原因 操作系統啟用了TCP ECN,而目的地路由器未使用ECN 導致TCP握手時間延長
netsh interface tcp set global ecncapability=disabled 關閉后正常

5 沒有介紹TCP ECN 只是介紹如何發現問題原因


#!/bin/env python
# -*- coding: utf-8-*-
#author: skybug
#date: 2017-12-2
#web_perf_test
import urllib2,sys,pycurl,json,StringIO
import os,subprocess
import platform,_winreg
#ipvip = socket.gethostbyname ("www.xxx.com")#獲取DNS解析值 本次未用
reload(sys)
sys.setdefaultencoding('utf-8')
iplist = ["113.x.x.1","113.x.x.x","x.x.x.x","x.x.x.x","x.x.x.x"]#vipgate,vip,cnki,cnki2,chaoxing
urllist=["http://x.com","http://a.com"]
UA = "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Mobile Safari/537.36"
headers = {}
def header_function(header_line):  #獲取響應頭,本次未調用
    header_line = header_line.decode('iso-8859-1')
    if ':' not in header_line:
        return
    name, value = header_line.split(':', 1)
    name = name.strip()
    value = value.strip()
    name = name.lower()
    headers[name] = value
def webperf_keep(url,times=1): #獲取訪問頁面的性能數據
    b = StringIO.StringIO() #定義個IO流
    pc=pycurl.Curl()#創建pycurl對象
    cnt=0
    alldata=[]
    for i in range(int(times)):
        pc.setopt(pycurl.URL,url) #設置訪問url
        pc.setopt(pycurl.HTTPHEADER, ['Content-Type: application/json'])
        pc.setopt (pycurl.USERAGENT,UA)#設置UA
        pc.setopt(pycurl.MAXREDIRS,50) #MAX REDIRECT count#設置最大重定向次數
        pc.setopt(pycurl.WRITEFUNCTION, b.write)#把相應內容寫到流里
        pc.setopt( pycurl.FOLLOWLOCATION,1)#跟蹤重定向
        pc.setopt(pycurl.FORBID_REUSE, 0)#允許復用連接
        pc.setopt(pycurl.FRESH_CONNECT,0)
        pc.setopt (pycurl.HEADERFUNCTION, header_function)#把頭信息寫到頭函數里
        print "testing access {0} {1} times.....".format (url, cnt)
        pc.perform()#執行pycurl
        cnt+=1
        dns_time = pc.getinfo(pycurl.NAMELOOKUP_TIME)#dns解析時間
        conn_time = pc.getinfo(pycurl.CONNECT_TIME)#建立連接的時間(TCP握手)
        ttfb = pc.getinfo(pycurl.STARTTRANSFER_TIME)#TTFB的時間
        total_time = pc.getinfo(pycurl.TOTAL_TIME)#總時間
        http_code = pc.getinfo(pycurl.HTTP_CODE)#返回code
        http_conn_code= pc.getinfo(pycurl.HTTP_CONNECTCODE)#
        redirect_count = pc.getinfo(pycurl.REDIRECT_COUNT)#重定向次數
        size_upload = pc.getinfo(pycurl.SIZE_UPLOAD)
        size_download = pc.getinfo(pycurl.SIZE_DOWNLOAD)
        size_header = pc.getinfo(pycurl.HEADER_SIZE)
        size_request = pc.getinfo(pycurl.REQUEST_SIZE)
        content_type = pc.getinfo(pycurl.CONTENT_TYPE)
        reponse_code = pc.getinfo(pycurl.RESPONSE_CODE)
        transfer_time = pc.getinfo(pycurl.PRETRANSFER_TIME) #傳輸時間
        startrans_time= pc.getinfo(pycurl.STARTTRANSFER_TIME)#開始傳輸時間
        speed_download = pc.getinfo(pycurl.SPEED_DOWNLOAD)#下載速度
        speed_upload = pc.getinfo(pycurl.SPEED_UPLOAD)#上傳速度
        redirect_time = pc.getinfo(pycurl.REDIRECT_TIME)#重定向時間
        num_conn = pc.getinfo(pycurl.NUM_CONNECTS)#建立連接的次數
        last_socket= pc.getinfo(pycurl.LASTSOCKET)#最后一個socker
        data = []
        perfdata={"dns_time":dns_time,"ttfb":ttfb,"total_time":total_time,"http_code":http_code,"redirect_count":redirect_count
     ,"size_upload":size_upload,"size_download":size_download,"size_header":size_header,"size_request":size_request
     ,"content_type":content_type,"reponse_code":reponse_code,"conn_time":conn_time,"transfer_time":transfer_time,"speed_download":speed_download
    ,"speed_upload":speed_upload,"startrans_time":startrans_time,"redirect_time":redirect_time,"http_conn_code":http_conn_code,"num_conn":num_conn,"last_socket":last_socket}
        data.append(url)
        data.append(perfdata)
        alldata.append(cnt)
        alldata.append(data)
        #pc.close()
        #b.close()
        jsondata=json.dumps({"perfdata":alldata},indent=4)
    pc.close()
    b.close()
    return jsondata

def getos():#獲取操作系統版本
    os = {}
    if sys.platform == "win32":
        try:
            reg_key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion")
            if reg_key:
                ProductName = _winreg.QueryValueEx(reg_key, "ProductName")[0] or None
                EditionId = _winreg.QueryValueEx(reg_key, "EditionId")[0] or None
                ReleaseId = _winreg.QueryValueEx(reg_key, "ReleaseId")[0] or None
                CurrentBuild = _winreg.QueryValueEx(reg_key, "CurrentBuild")[0] or None
                BuildLabEx = _winreg.QueryValueEx(reg_key, "BuildLabEx")[0][:9] or None
                os = {"ProductName": ProductName, "EditionId": EditionId, "ReleaseId": ReleaseId,
                      "CurrentBuild": CurrentBuild, "BuildLabEx": BuildLabEx}
            jsondata = json.dumps({"OS": os}, indent=4)
            return jsondata
        except Exception as e:
            print e.message.decode(DEFAULT_LOCALE_ENCODING)
def getcmd(shell):#執行cmd
    ps = subprocess.Popen(shell, shell=True, stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
    out, err = ps.communicate()
    return  out.decode('cp936').encode('utf-8')
def writelog(str):
    with open("result.txt",'a+') as fr:
        fr.write(str)
        fr.write("################################")
if len(sys.argv) ==2 and sys.argv[1] == "full":
    cnt = 0
    print "test setp {0},Collect routing information....".format(cnt)
    cmd="route print "
    writelog(getcmd(cmd))#獲取路由表
    print "test setp {0} ,Collect routing information....OK".format(cnt)
    cnt = cnt+1
    print "test setp {0},Collecting network information....".format(cnt)
    cmd="ipconfig /all  "#獲取網卡配置
    writelog(getcmd(cmd))
    print "test setp {0},Collecting network information....OK".format(cnt)
    cnt = cnt+1
    print "test setp{0},Collecting TCP information....".format(cnt)
    cmd = "netsh  int  tcp  show  global"#獲取TCP全局配置
    writelog(getcmd(cmd))
    print "test setp{0},Collecting TCP information....OK".format(cnt)
    cnt=+1
    print  "test setp{0},Collecting OS information....".format(cnt)
    writelog(getos())#獲取操作系統版本
    print  "test setp{0},Collecting OS information....OK".format(cnt)
    for index,item in enumerate(iplist):
        cmd="tracert  "+item#獲取路由跟蹤
        print "test setp {0},Collecting route tracking information....".format(cnt)
        writelog(getcmd(cmd))
        print "test setp {0},Collecting route tracking information....OK".format(cnt)
        cnt=cnt+1
    for index,item in enumerate(urllist):
        print "test setp {0},Collecting web to access information data....".format(cnt)
        writelog(webperf_keep(item))
        print "test setp {0},Collecting web to access information data....OK".format(cnt)
        cnt=cnt+1
    print "All test data collection is completed!"
if len(sys.argv) ==3:
    url = sys.argv[1]
    times = sys.argv[2]
    print "pre test access {0} {1} times.....".format(url,times)
    writelog(webperf_keep(url,times))
if len(sys.argv)==1:
    print "Please run web.perf.test full to full test \nor run web.perf.test 'http://www.xxx.com/' 10 ro run 10 times access test"
向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

博罗县| 禄劝| 上犹县| 南陵县| 长武县| 余江县| 威信县| 庄河市| 泰宁县| 襄樊市| 保山市| 绵竹市| 贵州省| 德江县| 合阳县| 宾阳县| 蒙阴县| 淳安县| 太谷县| 阿克苏市| 香格里拉县| 于都县| 柘荣县| 宁晋县| 罗江县| 尚义县| 滕州市| 拉孜县| 新绛县| 黄石市| 江川县| 江城| 南昌县| 天峨县| 澄城县| 马鞍山市| 宁明县| 甘泉县| 格尔木市| 临漳县| 怀仁县|