Tcping—-实用小工具tcping命令详解
一、tcping介绍
tcping:tcping命令基于tcp协议监控,可以从较低级别的协议获得简单的,可能不可靠的数据报服务。 原则上,TCP应该能够在从容硬线连接到分组交换或电路交换网络的各种通信系统之上操作。
二、tcping与ping的区别
(一).指代不同
① ping:是Windows、Unix和Linux系统下的一个命令。ping也属于一个通信协议,是TCP/IP协议的一部分。通过ICMP协议发送报文到对方主机上任意一个60000以上的端口,然后获取对方主机的回复。
② tcping:是一种面向连接的、可靠的、基于字节流的传输层通信协议。使用tcp协议尝试与某一个端口建立连接,然后获取与对方主机建立一次连接的回复。
(二).功能不同
① ping:利用“ping”命令可以检查网络是否连通,可以很好地帮助分析和判定网络故障。
② tcping:适知应支持多网络应用的分层协议层次结构。 连接到不同但互连的计算机通信网络的主计算机中的成道对进程之间依靠TCP提供可靠的通信内服务。有些网络环境禁ping,想要知道网络或端口连通性,tcping就是很好的方法。
(三).特点不同
① ping:Ping发送一个ICMP即因特网信报控制协议;回声请求消息给目的地并报告是否收到所希望的ICMPecho。
② tcping:可以从较低级别的协议获得简单的,可能不可靠的数据报服务。 原则上,TCP应该能够在从容硬线连接到分组交换或电路交换网络的各种通信系统之上操作。
三、下载与安装
官网地址:https://elifulkerson.com/projects/tcping.php
win32位下载地址:https://download.elifulkerson.com//files/tcping/0.39/tcping.exe
win64位下载地址:https://download.elifulkerson.com/files/tcping/0.39/x64/tcping64.exe

四、安装查看
① 可以设置windows环境变量,使得windows全局可以使用该命令。
② 可以将该执行文件放入windows的system32文件夹下即C:\Windows\System32也能使得全局windows可以使用该命令。
#查看命令版本信息
tcping -v

五、常用命令
-s 快速显示端口连通性,强烈推荐
-t 持续发送数据包,直到按ctrl+c停止
-n 5 指定发送5个包结束
-d 在每行前面附加日期时间,根据实际需求情况可以叠加使用
-r 3 每发送3个数据包,重新查找主机一次
-tee 输入结果到指定位置,比如:tcping –tee d:\test.txt 会将结果保存在D盘下的test.txt文件中
–file 顺序执行tcping文件中指定的目的地址,比如:tcping –file d:\ip.txt
六、常用实践
#1 默认发送4个数据包,默认测试80端口,也可以加指定端口,比如443
tcping


#2 快速测试端口连通性,强烈推荐!!!
tcping -s

#3 持续测试某个端口的连通性,按ctrl+c结束
tcping -t

#4 在每行前面附带日期时间
tcping -d

#5 每发送3个数据包,重新查找主机一次,根据DNS或者路由
tcping -r 3 -t

#6 文件输出,通常带上-d以及-n,比如测试发送5个数据包,并且输出信息带上具体日期,输入文件为D:\text.txt
tcping -d -n 5 –tee d:\test.txt

输出结果:

#7 顺序tcping执行文件目录中的地址
tcping –file d:\tcping.txt
将D盘tcping.txt中的地址,按顺序执行。

输出结果:

#8 也可以直接将结果输出到指定位置,但是–tee命令要在–file前面才行
tcping –tee d:\test.txt –file d:\tcping.txt

七、命令大全
# 以上内容只列举常用的一些,还有更多内容可以输入:tcping -help 或参考官网
Usage:
NAME
tcping - simulate "ping" over tcp by establishing a connection to network hosts.
Measures the time for your system to [SYN], receive the target's [SYN][ACK] and send [ACK]. Note that the travel time for
the last ACK is not included - only the time it takes to be put on the wire a tthe sending end.
SYNOPSIS
tcping [-tdsvf46] [-i interval] [-n times] [-w interval] [-b n] [-r times][-j depth] [--tee filename] [-f] destination [port]
DESCRIPTION
tcping measures the time it takes to perform a TCP 3-way handshake (SYN, SYN/ACK, ACK) between itself and a remote host.
The travel time of the outgoing final ACK is not included, only the (minimal) amount of time it has taken to drop it on
the wire at the near end. This allows the travel time of the (SYN, SYN/ACK) to approximate the travel time of the
ICMP (request, response) equivalent.
OPTIONS
-4 Prefer using IPv4
-6 Prefer using IPv6
-t ping continuously until stopped via control-c
-n count
send _count_ pings and then stop. Default 4.
-i interval
Wait _interval_ seconds between pings. Default 1. Decimals permitted.
-w interval
Wait _interval_ seconds for a response. Default 2. Decimals permitted.
-d include date and time on every output line
-f Force sending at least one byte in addition to making the connection.
-g count
Give up after _count_ failed pings.
-b type
Enable audible beeps.
'-b 1' will beep "on down". If a host was up, but now its not, beep.
'-b 2' will beep "on up". If a host was down, but now its up, beep.
'-b 3' will beep "on change". If a host was one way, but now its the other, beep.
'-b 4' will beep "always".
-c only show output on a changed state
-r count
Every _count_ pings, we will perform a new DNS lookup for the host in case it changed.
-s Exit immediately upon a success.
-v Print version and exit.
-j Calculate jitter. Jitter is defined as the difference between the last response time and the historical average.
-js depth
Calculate jitter, as with -j but with an optional _depth_ argument specified. If _depth_ is specified tcping will
use the prior _depth_ values to calculate a rolling average.
--tee _filename_
Duplicate output to the _filename_ specified. Windows can still not be depended upon to have a useful command line
environment. Don't tease me, *nix guys.
--append
When using --tee, append to rather than overwrite the output file.
--file
Treat the "destination" option as a filename. That file becomes a source of destinations, looped through on a
line by line basis. Some options don't work in this mode and statistics will not be kept.
destination
A DNS name, an IP address, or (in "http" mode) a URL.
Do not specify the protocol ("http://") in "http" mode. Also do not specify server port via ":port" syntax.
For instance: "tcping http://www.elifulkerson.com:8080/index.html" would fail
Use the style: "tcping www.elifulkerson.com/index.html 8080" instead.
port
A numeric TCP port, 1-65535. If not specified, defaults to 80.
--header
include a header with the command line arguments and timestamp. Header is implied if using --tee.
HTTP MODE OPTIONS
-h Use "http" mode. In http mode we will attempt to GET the specified document and return additional values including
the document's size, http response code, kbit/s.
-u In "http" mode, include the target URL on each output line.
--post Use POST instead of GET in http mode.
--head Use HEAD instead of GET in http mode.
--get Shorthand to invoke "http" mode for consistency's sake.
--proxy-server _proxyserver_
Connect to _proxyserver_ to request the url rather than the server indicated in the url itself.
--proxy-port _port_
Specify the numeric TCP port of the proxy server. Defaults to 3128.
--proxy-credentials username:password
Specify a username:password pair which is sent as a 'Proxy-Authorization: Basic' header.
RETURN VALUE
tcping returns 0 if all pings are successful, 1 if zero pings are successful and 2 for mixed outcome.
BUGS/REQUESTS
Please report bugs and feature requests to the author via contact information on http://www.elifulkerson.com
AVAILABILITY
tcping is available at http://www.elifulkerson.com/projects/tcping.php
本章结束~ifan