ping & tracert over TCP
偶然发现还有这样的工具: 通过TCP协议实现ping和tracert. 之前一直苦恼无法通过ping的方式测试被q网站, 现在有了这两个工具后就方便了.
[Windows]
tcping: http://www.elifulkerson.com/projects/tcping.php
tracetcp: https://github.com/SimulatedSimian/tracetcp
[Linux]
tcpping: http://xmodulo.com/how-to-install-tcpping-on-linux.html
1. apt-get install tcptraceroute
2. vi tcpping.sh
#!/bin/sh
#
# tcpping: test response times using TCP SYN packets
# URL: http://www.vdberg.org/~richard/tcpping.html
#
# uses tcptraceroute from http://michael.toren.net/code/tcptraceroute/
#
# (c) - Richard van den Berg <richard@vdberg.org> under the GPL
# http://www.gnu.org/copyleft/gpl.html
#
# // v1. initial version
# // v1. added -c and -r options
# now accepting all other tcptraceroute options
# // v1. removed double quotes around backquotes
# // v1. added -x option, courtesy of Alvin Austin <alvin@crlogic.com>
# // v1. added -C option, courtesy of Norman Rasmussen <norman@rasmussen.org>
# // v1. catch bad destination addresses
# // v1. catch non-root tcptraceroute
# // v1. make -C work when reverse lookup fails, courtesy of Fabrice Le Dorze <Fabrice.LeDorze@apx.fr> ver="v1.7"
format="%Y%m%d%H%M%S"
d="no"
c="no"
C="no"
ttl=
seq=
q=
r=
w=
topts="" usage () {
name=`basename $`
echo "tcpping $ver Richard van den Berg <richard@vdberg.org>"
echo
echo "Usage: $name [-d] [-c] [-C] [-w sec] [-q num] [-x count] ipaddress [port]"
echo
echo " -d print timestamp before every result"
echo " -c print a columned result line"
echo " -C print in the same format as fping's -C option"
echo " -w wait time in seconds (defaults to 3)"
echo " -r repeat every n seconds (defaults to 1)"
echo " -x repeat n times (defaults to unlimited)"
echo
echo "See also: man tcptraceroute"
echo
} _checksite() {
ttr=`tcptraceroute -f ${ttl} -m ${ttl} -q ${q} -w ${w} $* >&`
if echo "${ttr}" | egrep -i "(bad destination|got roo)" >/dev/null >&; then
echo "${ttr}"
exit
fi
} _testsite() {
myseq="${1}"
shift
[ "${c}" = "yes" ] && nows=`date +${format}`
[ "${d}" = "yes" ] && nowd=`date`
ttr=`tcptraceroute -f ${ttl} -m ${ttl} -q ${q} -w ${w} $* >/dev/null`
host=`echo "${ttr}" | awk '{print $2 " " $3}'`
rtt=`echo "${ttr}" | sed 's/.*] //' | awk '{print $1}'`
not=`echo "${rtt}" | tr -d ".0123456789"`
[ "${d}" = "yes" ] && echo "$nowd"
if [ "${c}" = "yes" ]; then
if [ "x${rtt}" != "x" -a "x${not}" = "x" ]; then
echo "$myseq $nows $rtt $host"
else
echo "$myseq $nows $max $host"
fi
elif [ "${C}" = "yes" ]; then
if [ "$myseq" = "" ]; then
echo -n "$1 :"
fi
if [ "x${rtt}" != "x" -a "x${not}" = "x" ]; then
echo -n " $rtt"
else
echo -n " -"
fi
if [ "$x" = "" ]; then
echo
fi
else
echo "${ttr}" | sed -e "s/^.*\*.*$/seq $myseq: no response (timeout)/" -e "s/^$ttl /seq $myseq: tcp response from/"
fi
# echo "${ttr}"
} while getopts dhq:w:cr:nNFSAEi:f:l:m:p:s:x:C opt ; do
case "$opt" in
d|c|C) eval $opt="yes" ;;
q|w|r|x) eval $opt="$OPTARG" ;;
n|N|F|S|A|E) topt="$topt -$opt" ;;
i|l|p|s) topt="$topt -$opt $OPTARG" ;;
f|m) ttl="$OPTARG" ;;
?) usage; exit ;;
esac
done shift `expr $OPTIND - ` if [ "x$1" = "x" ]; then
usage
exit
fi max=`echo "${w} * 1000" | bc` if [ `date +%s` != "%s" ]; then
format="%s"
fi _checksite ${topt} $* if [ "$x" = "" ]; then
while [ ] ; do
_testsite ${seq} ${topt} $* &
pid=$!
if [ "${C}" = "yes" ]; then
wait $pid
fi
seq=`expr $seq + `
sleep ${r}
done
else
while [ "$x" -gt ] ; do
_testsite ${seq} ${topt} $* &
pid=$!
if [ "${C}" = "yes" ]; then
wait $pid
fi
seq=`expr $seq + `
x=`expr $x - `
if [ "$x" -gt ]; then
sleep ${r}
fi
done
fi exit
3. chmod 755 tcpping
ping & tracert over TCP的更多相关文章
- 网络测试常用的命令-比较ping,tracert和pathping等命令之间的关系
无论你是一个网络维护人员,还是正在学习TCP/IP协议,了解和掌握一些常用的网络测试命令将会有助于您更快地检测到网络故障所在,同时也会有助你您了解网络通信的内幕. 下面我们逐步介绍几个常用的命令: 1 ...
- 比较ping,tracert和pathping等命令之间的关系
无论你是一个网络维护人员,还是正在学习TCP/IP协议,了解和掌握一些常用的网络测试命令将会有助于您更快地检测到网络故障所在,同时也会有助你您了解网络通信的内幕. 下面我们逐步介绍几个常用的命令: 1 ...
- 数据包判断是否丢包 ping+tracert+mtr
1.用咱们最常用的Ping命令来查看是不是真的丢包了 这里可以看到数据包发送了4个,返回了4个,丢失=0 证明没有丢失 也有可能中间路由做了策略不给ICMP的回应 这样就ping没法判断了 正常情 ...
- Windows Ping | Tracert 's Bat 脚本并行测试
系统:windows 需求:测试多台PC输出三个网站并行ping.tracert结果,多台PC同时进行. 说明:以www.baidu.com.www.sina.com.cn.www.tencent.c ...
- TRACERT命令
这半个月 服务器从联通线路换到移动线路 导致基层用联通和电信线路的用户 上不去收费软件 tracert 120.194.42.142:8090 发现路由器 解析地址绕过很多条街后 出现丢包现象 联系 ...
- TCP/IP详解学习笔记
TCP/IP详解学习笔记(1)-基本概念 TCP/IP详解学习笔记(2)-数据链路层 TCP/IP详解学习笔记(3)-IP协议,ARP协议,RARP协议 TCP/IP详解学习笔记(4)-ICMP协议, ...
- HCIA SWITCHING&ROUTTING 笔记——第一章 TCP/IP基础知识(3)
4 ICMP协议 4.1 概念 ICMP即 Internet Contorl Message Protocol,即Internet控制消息协议,是网络层的一个重要协议.ICMP协议用来在网络设备间传递 ...
- Linux_09------Linux上系统扫描和安全策略
先谢慕课网/** * linux系统扫描技术 * * 主机扫描.路由扫描.批量服务扫描.系统安全策略(防SYN和ddos攻击) */ /** * 主机扫描 * ping fping hping * * ...
- Android 面试题总结
Android 面试题总结(不断更新) 1.INETNT几种有关Activit的启动方式FLAG_ACTIVITY_BROUGHT_TO_FRONT 将ACTIVITY带到最前面FLAG_ACTIVI ...
随机推荐
- 【Highcharts】 动态删除series
先绘制,后删除多余 var chart = new Highcharts.Chart(options); if (chart.series.length > result.dataList0.l ...
- iOS KVO 学习笔记
//// //// main.m //// TestBasis //// //// Created by ficow on 16/1/14. //// Copyright © 2016年 ficow. ...
- Hadoop2.0(HDFS2)以及YARN设计的亮点
YARN总体上仍然是Master/Slave结构,在整个资源管理框架中,ResourceManager为Master,NodeManager为Slave,ResouceManager负责对各个Node ...
- DrawingContext.Pop Method
The following example shows the effect of the Pop command. using System; using System.Windows; using ...
- 51nod p1175 区间中第K大的数
1175 区间中第K大的数 基准时间限制:1 秒 空间限制:131072 KB 分值: 160 难度:6级算法题 一个长度为N的整数序列,编号0 - N - 1.进行Q次查询,查询编号i至j的所有 ...
- ural 1251. Cemetery Manager
1251. Cemetery Manager Time limit: 1.0 secondMemory limit: 64 MB There is a tradition at the USU cha ...
- Mybatis Generator insert useGeneratedKeys keyProperty
Mybatis自动生成代码,需要用到mybatis Generator,详见http://mybatis.github.io/generator/configreference/generatedKe ...
- js函数中参数的传递
数据类型 在 javascript 中数据类型可以分为两类: 基本类型值 primitive type,比如Undefined,Null,Boolean,Number,String. 引用类型值,也就 ...
- BZOJ 1059 & 二分图匹配
题意: 判断一个黑白染色的棋盘能否通过交换行或列使对角线上都是黑色. SOL: 真是有点醉...这种问题要么很神要么很水...第一眼感觉很水但就是不造怎么做...想了10分钟怎么感觉就是判断个数够不够 ...
- ACM Registration system
Registration system 时间限制:1000 ms | 内存限制:65535 KB 难度:2 描述 A new e-mail service "Berlandesk&q ...