偶然发现还有这样的工具: 通过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的更多相关文章

  1. 网络测试常用的命令-比较ping,tracert和pathping等命令之间的关系

    无论你是一个网络维护人员,还是正在学习TCP/IP协议,了解和掌握一些常用的网络测试命令将会有助于您更快地检测到网络故障所在,同时也会有助你您了解网络通信的内幕. 下面我们逐步介绍几个常用的命令: 1 ...

  2. 比较ping,tracert和pathping等命令之间的关系

    无论你是一个网络维护人员,还是正在学习TCP/IP协议,了解和掌握一些常用的网络测试命令将会有助于您更快地检测到网络故障所在,同时也会有助你您了解网络通信的内幕. 下面我们逐步介绍几个常用的命令: 1 ...

  3. 数据包判断是否丢包 ping+tracert+mtr

    1.用咱们最常用的Ping命令来查看是不是真的丢包了 这里可以看到数据包发送了4个,返回了4个,丢失=0  证明没有丢失 也有可能中间路由做了策略不给ICMP的回应 这样就ping没法判断了  正常情 ...

  4. Windows Ping | Tracert 's Bat 脚本并行测试

    系统:windows 需求:测试多台PC输出三个网站并行ping.tracert结果,多台PC同时进行. 说明:以www.baidu.com.www.sina.com.cn.www.tencent.c ...

  5. TRACERT命令

    这半个月  服务器从联通线路换到移动线路 导致基层用联通和电信线路的用户 上不去收费软件 tracert 120.194.42.142:8090 发现路由器 解析地址绕过很多条街后 出现丢包现象 联系 ...

  6. TCP/IP详解学习笔记

    TCP/IP详解学习笔记(1)-基本概念 TCP/IP详解学习笔记(2)-数据链路层 TCP/IP详解学习笔记(3)-IP协议,ARP协议,RARP协议 TCP/IP详解学习笔记(4)-ICMP协议, ...

  7. HCIA SWITCHING&ROUTTING 笔记——第一章 TCP/IP基础知识(3)

    4 ICMP协议 4.1 概念 ICMP即 Internet Contorl Message Protocol,即Internet控制消息协议,是网络层的一个重要协议.ICMP协议用来在网络设备间传递 ...

  8. Linux_09------Linux上系统扫描和安全策略

    先谢慕课网/** * linux系统扫描技术 * * 主机扫描.路由扫描.批量服务扫描.系统安全策略(防SYN和ddos攻击) */ /** * 主机扫描 * ping fping hping * * ...

  9. Android 面试题总结

    Android 面试题总结(不断更新) 1.INETNT几种有关Activit的启动方式FLAG_ACTIVITY_BROUGHT_TO_FRONT 将ACTIVITY带到最前面FLAG_ACTIVI ...

随机推荐

  1. POJ 2002 统计正方形 HASH

    题目链接:http://poj.org/problem?id=2002 题意:给定n个点,问有多少种方法可以组成正方形. 思路:我们可以根据两个点求出对应正方形[有2个一个在两点左边,一个在两点右边] ...

  2. 浩瀚科技PDA移动开单|盘点机 数据采集器 条码扫描开单微POS软件 现场打印开单

    PDA移动开单,是我公司的一款便携式开单配套产品,PDA能通过蓝牙.无线局域网.互联网直接与主机连接,让公司业务人员能随时随地了解公司产品信息并且进行开单.入库.库存.盘点等一系列进销存操作.是现今企 ...

  3. 记一次Runtime的巧用

    背景 我们的视频直播是用的大华乐橙的解决方案,而他们近期出来个新的SDK,并且对老版SDK不兼容,而这周,终于把大华乐橙的新版SDK切换了,和这一周做的新的东西,一起提交审核了,并且今天也通过审核了. ...

  4. 关于ui修改的若干想法

    1.现在发现统一规划好各种xml资源.图片资源还是很重要的. 为什么?因为,很多一些ui设计,比如标题.文字大小.列表的宽高都是统一的, 据我个人理解,一个ui多个部分,如果很多部分都是设计上统一的, ...

  5. UVa 2197 & 拆点分环费用流

    题意: 给你一个带权有向图,选择一些边组成许多没有公共边的环,使每个点都在k个环上,要求代价最小. SOL: 现在已经养成了这种习惯,偏题怪题都往网络流上想... 怎么做这题呢... 对我们看到每个点 ...

  6. Codeforces Round #195 (Div. 2) A. Vasily the Bear and Triangle

    水题,注意数据范围即可 #include <iostream> #include <algorithm> #include <utility> using name ...

  7. [Leetcode|SQL] Combine Two Tables

    Table: Person +-------------+---------+ | Column Name | Type | +-------------+---------+ | PersonId ...

  8. 定期来一次“绩效谈话”(摘自易中)

    值得借鉴学习 管理者和下属直接的互动关系当中,需要有一个定期的反馈机制.员工在工作当中需要管理者给他持续地反馈.以下是一个绩效谈话的标准程序: 一:说明会谈的目的和时间:我们用10分钟对你上一阶段的工 ...

  9. JavaScript进阶篇

    组团,并给团取个名(如何创建数组) 使用数组之前首先要创建,而且需要把数组本身赋至一个变量.好比我们出游,要组团,并给团定个名字“云南之旅”. 创建数组语法: var myarray=new Arra ...

  10. BZOJ2322: [BeiJing2011]梦想封印

    Description 渐渐地,Magic Land上的人们对那座岛屿上的各种现象有了深入的了解. 为了分析一种奇特的称为梦想封印(Fantasy Seal)的特技,需要引入如下的概念: 每一位魔法的 ...