幾款網絡測試工具總結


幾款網絡測試工具總結

 

 ping命令以前是一個很好用並且常用的網絡測試工具,它是基於ICMP協議,但是出於網絡安全等因素,大部分網絡環境以及雲環境可能都會禁止ICMP協議,所以在工作中,我們必須掌握一些其他比較流行的網絡測試工具,下面分別介紹tcppingtcpingpspinghpingpaping等幾款網絡測試工具。

 

關於ICMP概念:

 

ICMP是(Internet Control Message ProtocolInternet控制報文協議。它是TCP/IP協議族的一個子協議,用於在IP主機、路由器之間傳遞控制消息。控制消息是指網絡通不通、主機是否可達、路由是否可用等網絡本身的消息。這些控制消息雖然並不傳輸用戶數據,但是對於用戶數據的傳遞起着重要的作用。

 

 

 

tcpping介紹

 

 

tcpping工具工作在 TCP 層,通過發送偽造的 TCP SYN 包並偵聽來自服務器或中間設備返回的 SYN/ACK RST 。代碼100多行,源代碼在此鏈接http://www.vdberg.org/~richard/tcppingtcpping需要調用tcptraceroute。打印與ping近乎相同測試結果,目前版本為V1.7tcping的介紹參考鏈接http://www.vdberg.org/~richard/tcpping.html,這個是Richard van den Berg2002年編寫的,作者當時需要測量TCP往返時間。所以寫了這個腳本。tcpping只支持Linux。不支持Windows平台。

 

 

tcpping安裝

 

1:tcpping腳本依賴tcptraceroute組件,所以必須先安裝tcptraceroute

 

    #yum install tcptraceroute

 

2:下載tcpping文件

 

 wget http://www.vdberg.org/~richard/tcpping

 

3:將tcpping文件移動到/usr/bin下並授權。

 

# mv tcpping /usr/bin/

# cd /usr/bin

# chmod 755 tcpping

 

 

tcpping測試

 

tcpping幫助信息。

 

# tcpping

tcpping v1.7 Richard van den Berg <richard@vdberg.org>

 

Usage: tcpping [-d] [-c] [-C] [-w sec] [-q num] [-x count] ipaddress [port]

 

        -d   print timestamp before every result          

        -c   print a columned result line

        -C   print in the same format as fping's -C option

        -w   wait time in seconds (defaults to 3)

        -r   repeat every n seconds (defaults to 1)

        -x   repeat n times (defaults to unlimited)

 

See also: man tcptraceroute

 

參數

參數描述

-d

在每個結果輸出前打印時間戳

-c

將結果輸出在一列。

-C

輸出與fping-C選項相同的打印格式

-w

wait time in seconds (defaults to 3)

-r

-r n :n秒重復一次(默認為1

-x

重復n次(默認為無限制)

 

 

clip_image001[4]

 

clip_image002[4]

 

 

 

tcping介紹

 

tcping也是通過tcp端口工作,tcping還能監聽某個端口的狀態,注意tcpingtcpping是不同的兩款工具,另外tcping也有很多版本。如下所示:

 

來自 kirchner 源代碼的 TCPing

 

來自 Eli Fulkerson 源代碼的 TCPing

 

 

 

tcping安裝

 

Windows平台:

 

   https://www.elifulkerson.com/projects/tcping.php下載該工具后。放到C:\Windows\System32目錄下即可。無需安裝。

 

Linux平台:

 

    linux平台較多,安裝方式也較多,當然最簡單的莫過於yum安裝。測試感覺Linux下的這款工具功能過於簡單。

 

    yum install tcping

 

 

 

tcping測試

 

Eli Fulkerson寫的Windows下的tcping功能十分強大。參數多到不想去總結,實在是太多了,如果不清楚,每次使用的時候查看幫助文檔即可。

 

 

C:\Users>tcping www.aliyun.com

 

Probing 140.205.172.20:80/tcp - Port is open - time=2.444ms

Probing 140.205.172.20:80/tcp - Port is open - time=2.574ms

Probing 140.205.172.20:80/tcp - Port is open - time=2.965ms

Probing 140.205.172.20:80/tcp - Port is open - time=4.074ms

 

Ping statistics for 140.205.172.20:80

     4 probes sent.

     4 successful, 0 failed.

Approximate trip times in milli-seconds:

     Minimum = 2.444ms, Maximum = 4.074ms, Average = 3.014ms

 

C:\Users>tcping www.aliyun.com 80

 

Probing 140.205.172.20:80/tcp - Port is open - time=2.731ms

Probing 140.205.172.20:80/tcp - Port is open - time=2.126ms

Probing 140.205.172.20:80/tcp - Port is open - time=2.916ms

Probing 140.205.172.20:80/tcp - Port is open - time=2.609ms

 

Ping statistics for 140.205.172.20:80

     4 probes sent.

     4 successful, 0 failed.

Approximate trip times in milli-seconds:

     Minimum = 2.126ms, Maximum = 2.916ms, Average = 2.595ms

 

C:\Users>

 

Linux

 

Linux下的tcping命令功能非常簡單,如下所示,感覺沒有tcppingWindows下的tcping功能強大。

 

Usage: tcping [-q] [-t timeout_sec] [-u timeout_usec] <host> <port>

 

 

[root@DB-Server ~]# tcping  192.168.27.57 1433

192.168.27.57 port 1433 open.

 

 

 

PsPing介紹

 

 

 

下面是官方文檔以及Azure官方文檔關於PsPing的介紹資料,這些介紹已經全面的闡述了PsPing這款工具:

 

 

PsPing implements Ping functionality, TCP ping, latency and bandwidth measurement. Use the following command-line options to show the usage for each test type:

 

通常,我們測試數據包能否通過IP協議到達特定主機時,都習慣使用 ping 命令。工作時用ping向目標主機發送一個 IMCP Echo 請求的數據包,並等待接收 Echo 響應數據包,通過響應時間和成功響應的次數來估算丟包率和網絡時延。但是在 Azure ICMP包無法通過防火牆和負載均衡器,所以不能直接使用 ping 來測試 Azure 中的虛擬機和服務的連通性(VPN Express Route 通道中的流量不經過負載均衡器,所以只要鏈路上的防火牆允許 ICMP 包傳遞,ping 依然可用)。

 

為了在 Azure 中進行連通性測試,例如測試 RDPSSH 端口可用性,或者 HTTPHTTPS 服務穩定性,甚至測試從 Azure 向外部服務的連接,我們都推薦使用 PsPing PaPingPsPing 是微軟 PSTools 工具套件中的其中一個命令。除了ICMP ping 測試,它主要用來測試 TCP 端口的連通性,還可以測試 TCP/UDP 網絡時延和帶寬。不過, PsPing 只能在 Windows 中運行。如果您需要在 Linux 中發起 TCP 端口連通性和網路時延的測試,可以使用 PaPing PaPing 是一個跨平台的開源工具。它的功能相對 PsPing 而言更簡單,只支持 TCP 端口的相關測試,不支持 UDP 端口的測試。

 

 

PsPing安裝

 

 

PSTool工具包可以從微軟官方網址下載:https://docs.microsoft.com/zh-cn/sysinternals/downloads/psping 。 解壓PSTools.zip包后,將psping.exe拷貝到C:\Windows\System32下,那么你在cmd命令窗口的任意目錄都可以使用PsPing命令了。當然你也可以單獨將 psping.exe 命令解壓出來放在任意路徑,然后從命令提示符來運行。只是這樣就需要在運行命令前轉換到psping.exe所在的路徑。

 

 

 

PsPing參數

 

 

 

psping幫助信息查看,如下所示psping四個主要功能的幫助命令,四個功能分別是ICMP PingTCP Ping、延遲測試、帶寬測試。

 

 

clip_image003[4]

 

 

 

C:\Users>psping -? i

 

PsPing v2.01 - PsPing - ping, latency, bandwidth measurement utility

Copyright (C) 2012-2014 Mark Russinovich

Sysinternals - www.sysinternals.com

 

ICMP ping usage: psping [[-6]|[-4]] [-h [buckets|<val1>,<val2>,...]] [-i <inter

al>] [-l <requestsize>[k|m] [-q] [-t|-n <count>] [-w <count>] <destination>

  -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").

  -i    Interval in seconds. Specify 0 for fast ping.

  -l    Request size. Append 'k' for kilobytes and 'm' for megabytes.

  -n    Number of pings or append 's' to specify seconds e.g. '10s'.

  -q    Don't output during pings.

  -t    Ping until stopped with Ctrl+C and type Ctrl+Break

        for statistics.

  -w    Warmup with the specified number of iterations (default is 1).

  -4    Force using IPv4.

  -6    Force using IPv6.

 

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

 

 

 

參數

參數說明

-h

輸出直方圖(默認步長數量為20

-i

指定ping包的間隔秒數,快ping則設置為0

-l

指定ping包大小,默認單位是byte。使用 k為單位代表kilobytes(KB),使用m為單位代表megabytes(MB)

-n

指定測試次數。還可以指定測試的時間長度,以秒為單位,使用時在數字后加上 s,例如“10s”

-q

測試過程中不輸出結果,結束后顯示統計結果;

-t

類似於 ICMP 的長 ping 測試,直到按下 Ctrl+C 停止測試,並顯示統計結果;

-w

熱身次數,默認為 1 次;

-4

強制使用 IPv4

-6

強制使用 IPv6

  

 

 

clip_image004[4]

 

 

延遲測試多了參數-r,-u,-f

 

C:\Users>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 [b

ckets|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.

 

 

參數

參數說明

-f

Open source firewall port during the run.

 

-u

使用UDP ping(默認是TCP

-h

輸出直方圖(默認步長數量為20

-r

從服務器接收代替發送。

-i

指定ping包的間隔秒數,快ping則設置為0

-l

指定ping包大小,默認單位是byte。使用 k為單位代表kilobytes(KB),使用m為單位代表megabytes(MB)

-n

指定測試次數。還可以指定測試的時間長度,以秒為單位,使用時在數字后加上 s,例如“10s”

-q

測試過程中不輸出結果,結束后顯示統計結果;

-t

類似於 ICMP 的長 ping 測試,直到按下 Ctrl+C 停止測試,並顯示統計結果;

-w

熱身次數,默認為 5 次;

-4

強制使用 IPv4

-6

強制使用 IPv6

-s

服務器監聽地址和端口

 

 

 

 

 

C:\Users>psping -? b

 

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 outstan

ding] [-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.

 

帶寬測試多了-b-i兩個參數。如下所示:

 

-b 帶寬測試

-i 未完成的I/O數量

 

 

 

PsPing測試案例

 

 

 

例子1,例如我要檢查服務器的1433端口是否開放

 

clip_image005[4]

 

 

例子2:網絡時延測試

 

C:\Users>psping -n 6 -w 2 -h xxxxxx.database.chinacloudapi.cn:1433

 

PsPing v2.10 - PsPing - ping, latency, bandwidth measurement utility

Copyright (C) 2012-2016 Mark Russinovich

Sysinternals - www.sysinternals.com

 

TCP connect to 139.219.130.35:1433:

8 iterations (warmup 2) ping test:

Connecting to 139.xxx.130.xx:1433 (warmup): from 192.168.103.21:57851: 36.10ms

Connecting to 139.xxx.130.xx:1433 (warmup): from 192.168.103.21:57852: 36.32ms

Connecting to 139.xxx.130.xx:1433: from 192.168.103.21:57853: 40.33ms

Connecting to 139.xxx.130.xx:1433: from 192.168.103.21:57854: 34.71ms

Connecting to 139.xxx.130.xx:1433: from 192.168.103.21:57855: 35.60ms

Connecting to 139.xxx.130.xx:1433: from 192.168.103.21:57856: 35.74ms

Connecting to 139.xxx.130.xx:1433: from 192.168.103.21:57858: 40.21ms

Connecting to 139.xxx.130.xx:1433: from 192.168.103.21:57859: 39.50ms

 

TCP connect statistics for 139.xxx.130.xxx:1433:

  Sent = 6, Received = 6, Lost = 0 (0% loss),

  Minimum = 34.71ms, Maximum = 40.33ms, Average = 37.68ms

 

Latency Count

34.71   1

35.01   0

35.30   0

35.60   2

35.89   0

36.19   0

36.49   0

36.78   0

37.08   0

37.37   0

37.67   0

37.96   0

38.26   0

38.56   0

38.85   0

39.15   0

39.44   1

39.74   0

40.03   1

40.33   1

 

 

例子3:網絡帶寬測試

 

clip_image006[4]

 

 

 

paping安裝測試

 

 

 

paping的下載地址如下,它分WindowsLinux版本。

 

https://code.google.com/archive/p/paping/downloads

 

tar -xvf paping_1.5.5_x86-64_linux.tar.gz

 

解壓到任意目錄,就可以直接執行。另外paping命令對比psping命令,功能更簡單、單一。它只有簡單的4個參數。

 

 

 

-p, --port N    指定被測試服務的 TCP 端口(必須);

--nocolor   屏蔽彩色輸出;

-t, --timeout   指定超時時長,單位為毫秒,默認值為 1000

-c, --count N   指定測試次數。

 

[root@DB-Server tmp]# ./paping -?

paping v1.5.5 - Copyright (c) 2011 Mike Lovell

 

Syntax: paping [options] destination

 

Options:

 -?, --help     display usage

 -p, --port N   set TCP port N (required)

     --nocolor  Disable color output

 -t, --timeout  timeout in milliseconds (default 1000)

 -c, --count N  set number of checks to N

 

[root@DB-Server tmp]# ./paping --nocolor -p 80 -c 10 www.azure.cn

paping v1.5.5 - Copyright (c) 2011 Mike Lovell

 

Connecting to 1stcncloud.dtwscachev290.ourwebcdn.com [27.155.71.36] on TCP 80:

 

Connected to 27.155.71.36: time=0.39ms protocol=TCP port=80

Connected to 27.155.71.36: time=0.33ms protocol=TCP port=80

Connected to 27.155.71.36: time=0.73ms protocol=TCP port=80

Connected to 27.155.71.36: time=0.48ms protocol=TCP port=80

Connected to 27.155.71.36: time=0.49ms protocol=TCP port=80

Connected to 27.155.71.36: time=0.39ms protocol=TCP port=80

Connected to 27.155.71.36: time=0.37ms protocol=TCP port=80

Connected to 27.155.71.36: time=0.35ms protocol=TCP port=80

Connected to 27.155.71.36: time=0.47ms protocol=TCP port=80

Connected to 27.155.71.36: time=0.52ms protocol=TCP port=80

 

Connection statistics:

        Attempted = 10, Connected = 10, Failed = 0 (0.00%)

Approximate connection times:

        Minimum = 0.33ms, Maximum = 0.73ms, Average = 0.45ms

 

 

 

Hping介紹

 

Hping是一個命令行下使用的TCP/IP數據包組裝/分析工具,其命令模式很像Unix下的ping命令,但是它不僅能發送ICMP回應請求,它還可以支持TCPUDPICMPRAW-IP協議,它有一個路由跟蹤模式,能夠在兩個相互包含的通道之間傳送文件。Hping常被用於檢測網絡和主機,其功能非常強大,可在多種操作系統下運行,如LinuxFreeBSDNetBSDOpenBSDSolarisMacOs XWindows 目前最新的版本為hping3

 

Hping的主要功能有: 

  1、防火牆測試 

  2、高級端口掃描

  3、網絡檢測,可以用不同的協議、服務類型(TOS)、IP分片 

  4、手工探測MTU 最大傳輸單元) 路徑

  5、先進的路由跟蹤,支持所有的協議 

  6、遠程操作系統探測 

  7、遠程的運行時間探測 

  8TCP/IP堆棧審計 

 

Hping的官方網址為http://www.hping.org/,開發者為是Salvatore Sanfilippo,官方介紹資料如下:

 

   hping is a command-line oriented TCP/IP packet assembler/analyzer. The interface is inspired to the ping(8) unix command, but hping isn't only able to send ICMP echo requests. It supports TCP, UDP, ICMP and RAW-IP protocols, has a traceroute mode, the ability to send files between a covered channel, and many other features.

 

While hping was mainly used as a security tool in the past, it can be used in many ways by people that don't care about security to test networks and hosts. A subset of the stuff you can do using hping:

·         Firewall testing

·         Advanced port scanning

·         Network testing, using different protocols, TOS, fragmentation

·         Manual path MTU discovery

·         Advanced traceroute, under all the supported protocols

·         Remote OS fingerprinting

·         Remote uptime guessing

·         TCP/IP stacks auditing

·         hping can also be useful to students that are learning TCP/IP.

Hping works on the following unix-like systems: Linux, FreeBSD, NetBSD, OpenBSD, Solaris, MacOs X, Windows.

 

 

 

Hping安裝

 

Hping這個項目在GitHub上,https://github.com/antirez/hping,可以直接從這里下載安裝。另外如果yum源有安裝程序,使用yum安裝最方便、快捷。

 

yum install hping3

 

 

下面是官方文檔的源碼安裝,不過源碼安裝需要依賴一些組件,想必yum安裝麻煩很多:

 

Linux

-----

 

please, follows this steps:

 

$ ./configure (first try ./configure --help)

$ vi Makefile (optional)

$ make

$ su

# make install

 

FreeBSD, OpenBSD, NetBSD

------------------------

 

You will need the libpcap and the gmake utility installed on your system.

 

$ ./configure

$ gmake

$ su (or calife)

# gmake install

 

 

 

Hping測試

 

 

查看hping的幫助信息:

 

 

[root@DB-Server ~]# hping3 --help  #或者hping --help

 

 

下面表格整理了部分參數信息,更多參數信息可以參考幫助文檔或http://man.linuxde.net/hping 

 

 

 

參數

參數說明

-h  --help

顯示幫助信息

-v  --version

顯示版本信息

-c  --count

指定發送包的次數

-i  --interval

--fast

--faster

    --flood

發送間隔時間(單位是毫秒) 缺省時間是1,此功能在增加傳輸率上很重要,idle/spoofing掃描時此功能也會被用到,你可以參考hping-howto獲得更多信息

-fast 每秒發10數據包,與-i m100等同。表示間隔10毫秒發送一個數據包

--faster 每秒發送100個數據包

--flood  以最快的速度發送數據包。不顯示答復

-n  --numeric

指定以數字形式輸出

-q  --quiet

安靜模式 只輸出開始結束信息

-I  --interface

interface name 無非就是eth0之類的網卡參數

-V  --verbose

顯示更多信息

-D  --debug

進入DEBUG模式

-z  --bind

快捷鍵的使用 

-Z  --unbind

消除快捷鍵

…………….

…………………..

 

 

 

clip_image007[4]

 

 

 

 

#hping3  -S 192.168.27.57 -p 1433

HPING 192.168.27.57 (eth0 192.168.27.57): S set, 40 headers + 0 data bytes

len=44 ip=192.168.27.57 ttl=60 DF id=0 sport=1433 flags=SA seq=0 win=5840 rtt=31.4 ms

len=44 ip=192.168.27.57 ttl=60 DF id=0 sport=1433 flags=SA seq=1 win=5840 rtt=23.5 ms

len=44 ip=192.168.27.57 ttl=118 DF id=10907 sport=1433 flags=SA seq=2 win=8192 rtt=20.4 ms

len=44 ip=192.168.27.57 ttl=118 DF id=10908 sport=1433 flags=SA seq=3 win=8192 rtt=15.6 ms

len=44 ip=192.168.27.57 ttl=60 DF id=0 sport=1433 flags=SA seq=4 win=5840 rtt=15.5 ms

len=44 ip=192.168.27.57 ttl=60 DF id=0 sport=1433 flags=SA seq=5 win=5840 rtt=14.1 ms

len=44 ip=192.168.27.57 ttl=60 DF id=0 sport=1433 flags=SA seq=6 win=5840 rtt=14.4 ms

^C

--- 192.168.27.57 hping statistic ---

7 packets transmitted, 7 packets received, 0% packet loss

round-trip min/avg/max = 14.1/19.3/31.4 ms

 

 

個人感覺Hping是功能最強大的一款工具,可以測試防火牆功能、端口掃描、Idle掃描、拒絕服務攻擊、木馬功能,這篇hping3命令已經詳細介紹了,而且有些測試不方便展示在此。在此略過細節。另外,工具再好,也需要可以掌握、駕馭工具的人。

 

 

 

參考資料:

 

 

https://docs.azure.cn/zh-cn/articles/azure-operations-guide/virtual-network/aog-virtual-network-tcp-psping-paping-connectivity

https://docs.microsoft.com/en-us/sysinternals/downloads/psping

https://www.cmsky.com/tcping/

http://zhjwpku.com/2016/12/17/tcpping-hping-mtr.html

https://www.slashroot.in/what-tcp-ping-and-how-it-usedyouy

http://tookdes.org/geek/archives/tcping-intro.html

http://man.linuxde.net/hping3


免責聲明!

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



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