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 ...
随机推荐
- HTTP基础06--网络安全
HTTP 的缺点 通信使用明文可能会被窃听 HTTP 报文使用明文(指未经过加密的报文)方式发送. 通信的加密 用 SSL 建立安全通信线路之后,就可以在这条线路上进行 HTTP 通信了.与 SSL ...
- JSON 和 XML 优缺点的比较
JSON 和 XML 优缺点的比较 1.JSON定义(JavaScript Object Notation) 一种轻量级的数据交换格式,具有良好的可读和便于快速编写的特性.可在不同平台之间进行数据交换 ...
- js获取浏览器地址
<script type="text/javascript"> window.onload = function(){ var txt=""; va ...
- 遍历table指定name的td
$("td[name='rates']").each(function () { var temp = $(this).text().substr(0,$(this).text() ...
- 关于Ue4的深度模板
http://www.unrealchina.net/forum.php?mod=viewthread&tid=100234
- nginx实现ssl反向代理实战
登录认证account.free4lab.com需要提供ssl登录接口,ssl的原理看这篇博文,因为前面有反向代理nginx,所以这个需求就放在nginx实现了,否则可以放在web容器(jetty,t ...
- HDU5834 Magic boy Bi Luo with his excited tree(树形DP)
题目 Source http://acm.hdu.edu.cn/showproblem.php?pid=5834 Description Bi Luo is a magic boy, he also ...
- Codeforces 543D Road Improvement(树形DP + 乘法逆元)
题目大概说给一棵树,树的边一开始都是损坏的,要修复一些边,修复完后要满足各个点到根的路径上最多只有一条坏的边,现在以各个点为根分别求出修复边的方案数,其结果模1000000007. 不难联想到这题和H ...
- python 代码片段21
#coding=utf-8 @doco def foo(): pass ''' deco把foo函数拿过来,加上一些额外的功能再重新赋值给foo,如下 ''' foo=deco(foo) def lo ...
- node.js 实现一个简单的登录拦截器
拦截器在web开发中随处可见,比如站点的管理后台,不说所有人都能进入,所以就需要做一个拦截器并友好的跳转到提示页. 下面我们简单实现一种,判断用户是否登录成功,登录不成功的用户自动重定向到登录页面. ...