學習使用PSTools工具中的psping


初識PsTools

    在工作中我們都會想探測某個IP是否能通,基本上都使用過ping命令,但是某些服務器禁用了ping,而且有些時候也想探測某個IP的某個端口是否能通。之前的我一般都是用“telnet ip port”,但是我發現一個不好的體驗就是沒啥明顯的結果,不通的時候會超時要等一下下,通的時候也沒啥友好的提示。所以就搜到了【PStools下載】,里面的“psping”命令就很適合我這個要求。
    PsTools是一款非常好用的遠程管理工具應用軟件,PsTools軟件為用戶提供了非常強大的功能,支持遠程打開文件、終止進程、關閉重啟計算機等。非常的實用。

其中包含的工具簡介如下:

命令名 命令用途
PsExec 遠程執行進程
PsFile 顯示遠程打開的文件
PsGetSid 顯示計算機或用戶的 SID
PsInfo 列出有關系統的信息
PsKill 按名稱或進程 ID 終止進程
PsList 列出有關進程的詳細信息
PsLoggedOn 查看在本地通過資源共享(包含所有資源)登錄的用戶
PsLogList 轉儲事件日志記錄
PsPasswd 更改帳戶密碼
PsService 查看和控制服務
PsShutdown 關閉並重新啟動(可選)計算機
PsSuspend 暫停進程
PsUptime 最后重啟后系統運行的時間
psping ICMP Ping、TCP Ping、延遲測試、帶寬測試

psping

    下面是“psing -?”查看的幫助信息

PsPing v2.10 - PsPing - ping, latency, bandwidth measurement utility
Copyright (C) 2012-2016 Mark Russinovich
Sysinternals - www.sysinternals.com

PsPing implements Ping functionality, TCP ping, UDP/TCP latency, and UDP / TCP
bandwidth measurement.

Help usage: psping -? [i|t|l|b]
   -? i   Usage for ICMP ping.
   -? t   Usage for TCP ping.
   -? l   Usage for latency test.
   -? b   Usage for bandwidth test.
  -nobanner   Do not display the startup banner and copyright message.

1.使用ICMP ping

    執行“psping -? i

PsPing v2.10 - PsPing - ping, latency, bandwidth measurement utility
Copyright (C) 2012-2016 Mark Russinovich
Sysinternals - www.sysinternals.com

ICMP ping usage: psping [-t|-n count[s]] [-i interval] [-w count] [-q] [-h [buckets|val1,val2,...]] [-l requestsize[k]] [-6|-4] destination
  -t    Ping until stopped with Ctrl+C and type Ctrl+Break
        for statistics.
  -n    Number of pings or append 's' to specify seconds e.g. '10s'.
  -i    Interval in seconds. Specify 0 for fast ping.
  -w    Warmup with the specified number of iterations (default is 1).
  -q    Don't output during pings.
  -h    Print histogram (default bucket count is 20).
        If you specify a single argument, it's interpreted as a bucket
        count and the histogram will contain that number of
        buckets covering the entire time range of values.
        Specify a comma-separated list of times to create a custom
        histogram (e.g. "0.01,0.05,1,5,10").
  -l    Request size. Append 'k' for kilobytes.
  -4    Force using IPv4.
  -6    Force using IPv6.

For high-speed ping tests use -q and -i 0.

執行psping -4 -n 10 -w 2 -h 10 www.baidu.com

  • -4 代表強制使用IPv4聯機
  • -n 代表正式ping包的個數,或者定義使用秒s作為單位
  • -w 代表熱身ping包的個數,即正式測試前先進行多少次熱身測試連接
  • -h 代表最小與最大延遲毫秒數

另外幾個參數解釋如下:

  • -i 代表間隔秒數,快ping則設置為0
  • -l 代表ping包大小,默認單位是byte。使用 k為單位代表kilobytes(KB),使用m為單位代表megabytes(MB)
  • -q 代表ping過程中不一個個輸出值
  • -t 代表長ping不停
  • -6 代表強制使用IPv6聯機

2.使用TCP ping

    執行“psping -? t

PsPing v2.10 - PsPing - ping, latency, bandwidth measurement utility
Copyright (C) 2012-2016 Mark Russinovich
Sysinternals - www.sysinternals.com

TCP ping usage: psping [-t|-n count[s]] [-i interval] [-w count] [-q] [-h [buckets|val1,val2,...]] [-6|-4] destination:port
  -t    Ping until stopped with Ctrl+C and type Ctrl+Break
        for statistics.
  -n    Number of pings or append 's' to specify seconds e.g. '10s'.
  -i    Interval in seconds. Specify 0 for fast ping.
  -w    Warmup with the specified number of iterations (default is 1).
  -q    Don't output during pings.
  -h    Print histogram (default bucket count is 20).
        If you specify a single argument, it's interpreted as a bucket
        count and the histogram will contain that number of
        buckets covering the entire time range of values.
        Specify a comma-separated list of times to create a custom
        histogram (e.g. "0.01,0.05,1,5,10").
  -4    Force using IPv4.
  -6    Force using IPv6.

For high-speed ping tests use -q and -i 0.

與ping功能相同的參數定義:

  • -n 代表正式ping包的個數,或者定義使用秒s作為單位
  • -w 代表熱身ping包的個數,即正式測試前先進行多少次熱身測試連接
  • -h 代表最小與最大延遲毫秒數
  • -i 代表間隔秒數,快ping則設置為0
  • -l 代表ping包大小,默認單位是byte。使用 k為單位代表kilobytes(KB),使用m為單位代表megabytes(MB)
  • -q 代表ping過程中不一個個輸出值
  • -t 代表長ping不停
  • -4 代表強制使用IPv4聯機
  • -6 代表強制使用IPv6聯機

3.延遲測試

    執行“psping -? l

PsPing v2.10 - PsPing - ping, latency, bandwidth measurement utility
Copyright (C) 2012-2016 Mark Russinovich
Sysinternals - www.sysinternals.com

TCP and UDP latency usage:
server: psping [-6|-4] [-f] -s address:port
client: psping -l requestsize[k|m] -n count[s] [-r] [-u] [-w count] [-f] [-h [buckets|val1,val2,...]] [-6|-4] destination:port
  -l    Request size. Append 'k' for kilobytes and 'm' for megabytes.
  -n    Number of sends/receives. Append 's' to specify seconds e.g. '10s'.
  -r    Receive from the server instead of sending.
  -u    UDP (default is TCP).
  -w    Warmup with the specified number of iterations (default is 5).
  -f    Open source firewall port during the run.
  -h    Print histogram (default bucket count is 20).
        If you specify a single argument, it's interpreted as a bucket
        count and the histogram will contain that number of
        buckets covering the entire time range of values.
        Specify a comma-separated list of times to create a custom
        histogram (e.g. "0.01,0.05,1,5,10").
  -4    Force using IPv4.
  -6    Force using IPv6.
  -s    Server listening address and port.

The server can serve both latency and bandwidth tests and remains active until
you terminate it with Control-C.

執行psping -l 1500 -n 300 -h 10 www.qq.com:443

  • -l 1500代表我發送的數據包大小為每個1500 Bytes,TCP聯機在Layer 2 Ethernet中的MTU (Maximum Transmission Unit)通常以1500 Bytes為一個單位
  • -n 300代表放松300個封包

4.帶寬測試

PsPing v2.10 - PsPing - ping, latency, bandwidth measurement utility
Copyright (C) 2012-2016 Mark Russinovich
Sysinternals - www.sysinternals.com

TCP and UDP bandwidth usage:
server: psping [-6|-4] [-f] -s address:port
client: psping -b -l requestsize[k|m] -n count[s] [-r] [-u [target]] [-i outstanding] [-w count] [-f] [-h [buckets|val1,val2,...]] [-6|-4] destination:port
  -b    Bandwidth test.
  -l    Request size. Append 'k' for kilobytes and 'm' for megabytes.
  -n    Number of sends/receives. Append 's' to specify seconds e.g. '10s'.
  -r    Receive from the server instead of sending.
  -u    UDP (default is TCP). Specify target bandwidth in MB/s.
  -i    Number of outstanding I/Os (default is min of 16 and 2x CPU cores).
  -w    Warmup for the specified iterations (default is 2x CPU cores).
  -f    Open source firewall port during the run.
  -h    Print histogram (default bucket count is 20).
        If you specify a single argument, it's interpreted as a bucket
        count and the histogram will contain that number of
        buckets covering the entire time range of values.
        Specify a comma-separated list of times to create a custom
        histogram (e.g. "0.01,0.05,1,5,10").
  -4    Force using IPv4.
  -6    Force using IPv6.
  -s    Server listening address and port.

The server can serve both latency and bandwidth tests and remains active until
you terminate it with Control-C.

執行psping -b -l 1500 -n 15000 www.qq.com:443

  • -b 代表將進行帶寬測試
  • -l 1500代表使用大小1500Bytes的數據包
  • -n 15000代表使用15000個數據包

執行結果顯示我的PC和www.qq.com之間帶寬為:526.12 KB/s

5.同功能的tcping工具

    還有一個在禁止ping的情況下可以在windows上部署tcping64.exe或者tcping.exe工具來檢測服務器端口是否開放windows下【tcping工具下載】,執行命令“tcping -t www.baidu.com 443

總結

  1. 當發現當前做法有不方便時就是尋找更好解決方案的時候。
  2. 上面這些命令,相信在很多判斷網絡的場景很常用,以后可以happy了。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM