tcping port using detection means

We all know that detect network status is, whether it is a server / client most commonly used is the ping command, but can only detect ICMP protocol ping command, ping if the other party is prohibited agreement, naturally, will not be able to detect the ping command, this time, we can tcp / udp agreement to replace the ping command to check the status of network latency by tcping tool, the same time, we can also monitor what information the other open ports.

windos follows:

1, the installation tool tcping

Quguan network download tcping tool (32 according to their own system selection / 64) https://elifulkerson.com/projects/tcping.php

Note: download the corresponding 32-bit or 64-bit exe file, after the file into c: \ windows \ system32 \ directory (if the download is a 64-bit file name to take the time to use the other hand tcping.exe input tcping64) and then enter the command tcping If the document appears to help explain the installation command was successful.

Test: detecting an rsync server service port is unobstructed

tcping -d -t 192.168.43.117 873

windos - tcping parameters are as follows:

-------------------------------------------------- -------------------------------------------------- -------------------------------------------------- ------------------------------------------
-4, priority use IPv4

-6, priority use IPv6

-h, use http mode

-t, let the command run continuously until use ctrl + c to exit the command

-n figures, the number of sent commands, the default four times, tecping -n 6 www.baidu.com will tcping Baidu 6 times, which can be followed by other numbers.

-i 数字,发送ping命令的时间间隔,默认1s,可以为小数

-w 数字,等待响应的时间间隔,默认2s,可以为小数

-d 使输出的每一行显示时间和日期

-f 强制ping命令至少发送一个比特(byte)

-g 数字,失败指定次就放弃(注意默认是80端口,若其他端口没开也算失败)

-b 数字,开启蜂鸣器,参数4会一直响铃,tcping -b 4 www.baidu.com

-c 只显示改变的信息(ping时间很短一般不会改变)

-r 数字,每发送指定个数据包,就重新查找主机一次(通过DNS或路由查找)

-s ping通就立即退出

-u 与-h命令连用,每一行输出目标的url

-v 显示版本信息

-j 使用默认的方法,求ping的均值减小波动,网络有一定的不稳定性时,用此参数可以减小波动

-js 数字,用指定个实例求平均值减小波动,使用这个参数,系统会tcping 指定次,然后求出平均值作为一次结果显示,减小波动

–tee file_path,将结果输出到指定位置,tcping –tee /data/test.txt192.168.0.100,会把ping的结果保存在/data下的test文件中

–file 从文件中获得ping的来源;在/data下新建一个test.txt文件,并输入要tcping的所有ip或域名,一行一个,然后执行命令tcping –file /data/test.txt,就会依次tcping文件中指定的地址

destination 可以是DNS地址、IP地址、URL(需要使用-h,http模式)。使用http模式时,不要加https//或:port,例如:tcping http://www.jd.com:80l就会失败,使用tcping www.jd.com 8080就会成功

port 数字  指定tcp端口(1-65535),如果不指定,默认是80

–header  在头部显示时间和日期,与–tee显示的格式差不多

–block    tcping不通的等待时间,默认是20秒(很长)。–block可以把-w参数冲突掉 ,例如tcping --block www.baiu.com网址不正确,显然tcpping不通,默认会等待20s 。 tcping -w 0.5 –block www.baiu.com还是会等20s,而不是0.5s,因为–block选项会把-w选项冲突掉。

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

HTTP模式参数
–post    在http模式中,使用post方法

–head   在http模式中,使用head方法

–get      Shorthand to invoke “http” mode for consistency’s sake.

–proxy-server  指定代理服务

–proxy-port      指定代理服务端口

–proxy-credentials username:password   使用代理的安全验证,需要输入用户名和密码

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

返回值

如果所有的pings是成功的,返回0;如果所有ping都失败,返回1;混合结果,返回2

详情见官网: http://www.elifulkerson.com/projects/tcping.php

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

linux系统下tcping介绍:

  tcpping 工具工作在 TCP 层,通过发送伪造的 TCP SYN 包并侦听来自服务器或中间设备返回的 SYN/ACK 或 RST 。代码100多行,源代码在此链接http://www.vdberg.org/~richard/tcpping,tcpping需要调用tcptraceroute。打印与ping近乎相同测试结果,tcping的介

绍参考链接http://www.vdberg.org/~richard/tcpping.html,这个是Richard van den Berg在2002年编写的,作者当时需要测量TCP往返时间。所以写了这个脚本。tcpping只支持Linux。

语法:

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

参数:

-d   在每个结果输出前打印时间戳

-c   将结果输出在一列

-C  输出与fping的-C选项相同的打印格式

-w  Wait time in seconds (defaults to 3)

-r   -r n:每n秒重复一次(默认1)

-x   重复n次(默认无限)

安装:

wget https://sources.voidlinux.eu/tcping-1.3.5/tcping-1.3.5.tar.gz 
tar zxvf tcping-1.3.5.tar.gz
cd tcping-1.3.5/

#如果没有安装gcc,安装一下gcc

yum install gcc
gcc -o tcping tcping.c
cp tcping /usr/bin

#使用一下

tcping www.baidu.com 80

Guess you like

Origin www.cnblogs.com/su-root/p/10924758.html