[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
- TCP TIME_WAIT狀態最佳化TCPAI
- 網路狀態檢測的利器 - ss命令
- gRPC-網路現狀及測試RPC
- 俄羅斯力推“脫離網際網路”測試計劃 確保應急狀態下的境內網路安全內網
- 網路測試
- SpringStateMachine狀態機之八-整合測試SpringMac
- TCP連線的TIME_WAIT和CLOSE_WAIT 狀態解說TCPAI
- [20230317]關於TIME_WAIT問題.txtAI
- 模擬網路狀態的利器TC
- 為什麼tcp的TIME_WAIT狀態要維持2MSLTCPAI
- UDP網路測試UDP
- Linux和Windows下網路測試工具的安裝使用(iperf)LinuxWindows
- 網路基礎問題整理:為什麼TCP四次揮手最後需要TIME_WAIT狀態?TCPAI
- windows10系統印表機狀態空白且無法列印測試頁如何解決Windows
- 在 TIME_WAIT 狀態的 TCP 連線,收到 SYN 後會發生什麼?AITCP
- Linux基礎命令---netstat顯示網路狀態Linux
- 測試開發之網路篇-網路路由路由
- 網路安全滲透測試
- 雲網路效能測試流程
- 伺服器網路測試伺服器
- 網路基礎-常用網路測試工具
- 在Linux中,如何檢視網路介面的狀態?Linux
- 網路連線狀態檢視工具:Internet Status for MacMac
- Internet Status Mac網路連線狀態檢視工具Mac
- 網路遊戲同步方式(幀同步和狀態同步)遊戲
- openwrt,狀態監測netdata
- 網際網路App應用程式測試流程及測試總結APP
- 常見網路測試命令使用
- 3.05 EOS單點測試網路
- 網路安全測試---ARP欺騙
- 什麼是網路滲透測試?網路滲透測試分為幾種型別?型別
- Mac網路連線狀態檢視工具:Internet Status for MacMac
- 網路測試儀測試交換機的基本指標指標
- [20211231]函式索引測試.txt函式索引
- [20220531]測試quiz night.txtUI
- 淺談移動網際網路App測試APP