[20200310]測試網路狀態TIME_WAIT(windows).txt
[20200310]測試網路狀態TIME_WAIT(windows).txt
--//簡單探究windows下出現TIME_WAIT時,需要多少時間消失。我前面的測試:http://blog.itpub.net/267265/viewspace-2678684/
--//實際上這個時間是寫死在net/tcp.h標頭檔案裡面的,參考:/usr/src/kernels/2.6.39-300.26.1.el5uek/include/net/tcp.h可以發現如下:
#define TCP_TIMEWAIT_LEN (60*HZ) /* how long to wait to destroy TIME-WAIT
* state, about 60 seconds */
#define TCP_FIN_TIMEOUT TCP_TIMEWAIT_LEN
/* BSD style FIN_WAIT2 deadlock breaker.
* It used to be 3min, new value is 60sec,
* to combine FIN-WAIT-2 timeout with
* TIME-WAIT timer.
*/
--//除非你修改標頭檔案並且重新編譯核心,否則都是無效的。
1.測試環境:
--//測試windows下的情況,我的測試環境是windows 7:
--//client: 192.168.98.6
--//server: 192.168.100.78 linux
--// 批處理 ts.bat指令碼如下,注意安裝gawk,可以安裝UnxUtils包。
@echo off
gawk "{ print strftime(\"[%%Y-%%m-%%d %%H:%%M:%%S]\"), $0 }"
2.測試:
SCOTT@78> @ spid
SID SERIAL# PROCESS SERVER SPID PID P_SERIAL# C50
---------- ---------- ------------------------ --------- -------------------- ------- ---------- --------------------------------------------------
30 671 5592:5488 DEDICATED 42739 26 252 alter system kill session '30,671' immediate;
--//記下spid=42739:
$ netstat -nopt 2>/dev/null | grep 42739
tcp 0 0 192.168.100.78:1521 192.168.98.6:52233 ESTABLISHED 42739/oraclebook off (0.00/0/0)
--//這樣就知道client使用的埠號42739。實際上不需要這麼麻煩,client僅僅1個連線。
--//在客戶端執行:
R:\>seq 1000 | xargs -iQ cmd /c "netstat -na | grep 192.168.100.78:1521 | ts && sleep 1"
[2020-03-10 10:12:37] TCP 192.168.98.6:52233 192.168.100.78:1521 ESTABLISHED
[2020-03-10 10:12:38] TCP 192.168.98.6:52233 192.168.100.78:1521 ESTABLISHED
[2020-03-10 10:12:40] TCP 192.168.98.6:52233 192.168.100.78:1521 ESTABLISHED
[2020-03-10 10:12:41] TCP 192.168.98.6:52233 192.168.100.78:1521 ESTABLISHED
[2020-03-10 10:12:42] TCP 192.168.98.6:52233 192.168.100.78:1521 ESTABLISHED
[2020-03-10 10:12:43] TCP 192.168.98.6:52233 192.168.100.78:1521 ESTABLISHED
--//在sqlplus下執行quit退出,出現state=TIME_WAIT.
[2020-03-10 10:12:45] TCP 192.168.98.6:52233 192.168.100.78:1521 TIME_WAIT
[2020-03-10 10:12:46] TCP 192.168.98.6:52233 192.168.100.78:1521 TIME_WAIT
[2020-03-10 10:12:47] TCP 192.168.98.6:52233 192.168.100.78:1521 TIME_WAIT
...
[2020-03-10 10:14:37] TCP 192.168.98.6:52233 192.168.100.78:1521 TIME_WAIT
[2020-03-10 10:14:38] TCP 192.168.98.6:52233 192.168.100.78:1521 TIME_WAIT
[2020-03-10 10:14:39] TCP 192.168.98.6:52233 192.168.100.78:1521 TIME_WAIT
[2020-03-10 10:14:41] TCP 192.168.98.6:52233 192.168.100.78:1521 TIME_WAIT
[2020-03-10 10:14:42] TCP 192.168.98.6:52233 192.168.100.78:1521 TIME_WAIT
[2020-03-10 10:14:43] TCP 192.168.98.6:52233 192.168.100.78:1521 TIME_WAIT
--//可以看出2分鐘消失,也就是120秒。
--//另外注意:這個情況出現state=TIME_WAIT僅僅發生在客戶端。
3.修改註冊看看:
--//網路上查了一些資料,提示在登錄檔(regedit)的HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters上添
--//加一個DWORD型別的值TcpTimedWaitDelay,值就是秒數,即可。重啟機器才能測試:
--//timewait.reg
REGEDIT4
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Tcpip\Parameters]
"TcpTimedWaitDelay"=dword:0000001e
R:\>seq 1000 | xargs -iQ cmd /c "netstat -na | grep 192.168.100.78:1521 | ts && sleep 1"
[2020-03-10 10:37:28] TCP 192.168.98.6:49387 192.168.100.78:1521 ESTABLISHED
[2020-03-10 10:37:29] TCP 192.168.98.6:49387 192.168.100.78:1521 ESTABLISHED
[2020-03-10 10:37:31] TCP 192.168.98.6:49387 192.168.100.78:1521 ESTABLISHED
[2020-03-10 10:37:32] TCP 192.168.98.6:49387 192.168.100.78:1521 ESTABLISHED
[2020-03-10 10:37:33] TCP 192.168.98.6:49387 192.168.100.78:1521 TIME_WAIT
[2020-03-10 10:37:34] TCP 192.168.98.6:49387 192.168.100.78:1521 TIME_WAIT
[2020-03-10 10:37:35] TCP 192.168.98.6:49387 192.168.100.78:1521 TIME_WAIT
[2020-03-10 10:37:37] TCP 192.168.98.6:49387 192.168.100.78:1521 TIME_WAIT
[2020-03-10 10:37:38] TCP 192.168.98.6:49387 192.168.100.78:1521 TIME_WAIT
[2020-03-10 10:37:39] TCP 192.168.98.6:49387 192.168.100.78:1521 TIME_WAIT
[2020-03-10 10:37:40] TCP 192.168.98.6:49387 192.168.100.78:1521 TIME_WAIT
[2020-03-10 10:37:42] TCP 192.168.98.6:49387 192.168.100.78:1521 TIME_WAIT
[2020-03-10 10:37:43] TCP 192.168.98.6:49387 192.168.100.78:1521 TIME_WAIT
[2020-03-10 10:37:44] TCP 192.168.98.6:49387 192.168.100.78:1521 TIME_WAIT
[2020-03-10 10:37:45] TCP 192.168.98.6:49387 192.168.100.78:1521 TIME_WAIT
[2020-03-10 10:37:46] TCP 192.168.98.6:49387 192.168.100.78:1521 TIME_WAIT
[2020-03-10 10:37:48] TCP 192.168.98.6:49387 192.168.100.78:1521 TIME_WAIT
[2020-03-10 10:37:49] TCP 192.168.98.6:49387 192.168.100.78:1521 TIME_WAIT
[2020-03-10 10:37:50] TCP 192.168.98.6:49387 192.168.100.78:1521 TIME_WAIT
[2020-03-10 10:37:51] TCP 192.168.98.6:49387 192.168.100.78:1521 TIME_WAIT
[2020-03-10 10:37:52] TCP 192.168.98.6:49387 192.168.100.78:1521 TIME_WAIT
[2020-03-10 10:37:54] TCP 192.168.98.6:49387 192.168.100.78:1521 TIME_WAIT
[2020-03-10 10:37:55] TCP 192.168.98.6:49387 192.168.100.78:1521 TIME_WAIT
[2020-03-10 10:37:56] TCP 192.168.98.6:49387 192.168.100.78:1521 TIME_WAIT
[2020-03-10 10:37:57] TCP 192.168.98.6:49387 192.168.100.78:1521 TIME_WAIT
[2020-03-10 10:37:58] TCP 192.168.98.6:49387 192.168.100.78:1521 TIME_WAIT
[2020-03-10 10:37:59] TCP 192.168.98.6:49387 192.168.100.78:1521 TIME_WAIT
[2020-03-10 10:38:01] TCP 192.168.98.6:49387 192.168.100.78:1521 TIME_WAIT
--//30秒消失.補充測試我發現最小設定30秒,我設定10秒無效。
--//查詢一些連結提示:在Parameters子鍵下建立或修改名為TcpTimedWaitDelay的REG_DWORD值,該值的範圍是從0到300,建議將該值設
--//置為30。
4.總結:
--//在測試時我遇到很奇怪的情況,開機第一次連線後退出不會出現state=TIME_WAIT的情況。
--//另外我做了其它測試,發現一些奇怪的情況。有時間另外寫一篇。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2679356/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 檢測網路狀態
- [20200304]測試網路狀態TIME_WAIT.txtAI
- 檢測網路狀態 - flutterFlutter
- iOS 檢測網路狀態iOS
- SCNetworkReachabilityRef監測網路狀態
- 網路狀態檢測的利器 - ss命令
- TCP連線狀態和time_waitTCPAI
- TCP TIME_WAIT狀態最佳化TCPAI
- gRPC-網路現狀及測試RPC
- Android檢測網路狀態,判斷當前網路是否可用Android
- 查詢網路狀態
- 第三篇:關於TIME_WAIT狀態AI
- 俄羅斯力推“脫離網際網路”測試計劃 確保應急狀態下的境內網路安全內網
- 網路測試
- 使用AFNetworking進行網路狀態的監測
- iOS判斷網路狀態iOS
- 網路安全netstat監聽網路狀態。
- 研究者通過社交網路狀態更新預測自殺
- Android之監測手機網路狀態的廣播Android
- UDP網路測試UDP
- iOS AFN監聽網路狀態iOS
- 2.檢查網路狀態
- Information Codes 及網路狀態ORM
- SpringStateMachine狀態機之八-整合測試SpringMac
- [網路效能測試]iperf適用於linux以及windowsLinuxWindows
- Linux下用netstat檢視網路狀態、埠狀態Linux
- RxJava2 實戰知識梳理(11) 檢測網路狀態並自動重試請求RxJava
- TCP埠狀態說明ESTABLISHED、TIME_WAIT、 CLOSE_WAITTCPAI
- 模擬網路狀態的利器TC
- iOS 使用 Reachability 監聽網路狀態iOS
- [React Native]獲取網路狀態React Native
- 用c#監控網路狀態C#
- iOS模擬各種網路狀態iOS
- IPERF 網路效能測試
- 網路流量測試工具
- 網路效能測試-perf
- windows10系統印表機狀態空白且無法列印測試頁如何解決Windows
- 網路狀態的檢查和MJRefresh