大家好,又见面了,我是你们的朋友全栈君。
1.首先安装依赖包libpcap yum install -y libpcap 2.下载tcptraceroute rpm包,并安装 rpm -ivh tcptraceroute-1.5-0.beta7.el6.rf.x86_64.rpm tcptraceroute 121.46.29.115 5810 -n -q 1 traceroute to 121.46.9.135 (121.46.9.135), 30 hops max, 60 byte packets 1 10.0.12.254 1.296 ms 2 10.1.3.250 2.478 ms 3 * 4 180.76.225.253 0.369 ms 5 182.61.255.2 4.030 ms 6 182.61.253.121 3.815 ms 7 182.61.253.163 1.516 ms 8 103.216.40.75 3.131 ms 9 121.46.29.115 <syn,ack> 35.470 ms tcpping脚本 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) 2002-2005 Richard van den Berg <richard@vdberg.org> under the GPL # http://www.gnu.org/copyleft/gpl.html # # 2002/12/20 v1.0 initial version # 2003/01/25 v1.1 added -c and -r options # now accepting all other tcptraceroute options # 2003/01/30 v1.2 removed double quotes around backquotes # 2003/03/25 v1.3 added -x option, courtesy of Alvin Austin <alvin@crlogic.com> # 2005/03/31 v1.4 added -C option, courtesy of Norman Rasmussen <norman@rasmussen.org> # 2007/01/11 v1.5 catch bad destination addresses # 2007/01/19 v1.6 catch non-root tcptraceroute # 2008/02/10 v1.7 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=255 seq=0 q=1 r=1 w=3 topts="" usage () { name=`basename $0` 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} $* 2>&1` if echo "${ttr}" | egrep -i "(bad destination|got roo)" >/dev/null 2>&1; 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} $* 2>/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" = "0" ]; then echo -n "$1 :" fi if [ "x${rtt}" != "x" -a "x${not}" = "x" ]; then echo -n " $rtt" else echo -n " -" fi if [ "$x" = "1" ]; 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 - 1` 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 [ 1 ] ; do _testsite ${seq} ${topt} $* & pid=$! if [ "${C}" = "yes" ]; then wait $pid fi seq=`expr $seq + 1` sleep ${r} done else while [ "$x" -gt 0 ] ; do _testsite ${seq} ${topt} $* & pid=$! if [ "${C}" = "yes" ]; then wait $pid fi seq=`expr $seq + 1` x=`expr $x - 1` if [ "$x" -gt 0 ]; then sleep ${r} fi done fi exit :wq! chmod +x tcpping.sh [root@beijing012033 ~]# ./tcpping.sh 121.46.129.33 5810 traceroute to 121.46.129.33 (121.46.129.33), 255 hops max, 60 byte packets seq 0: tcp response from 121.46.129.33 (121.46.129.33) <syn,ack> 35.456 ms traceroute to 121.46.129.33 (121.46.129.33), 255 hops max, 60 byte packets seq 2: tcp response from 121.46.129.33 (121.46.129.33) <syn,ack> 35.456 ms traceroute to 121.46.129.33 (121.46.129.33), 255 hops max, 60 byte packets seq 1: tcp response from 121.46.129.33 (121.46.129.33) <syn,ack> 35.449 ms traceroute to 121.46.129.33 (121.46.129.33), 255 hops max, 60 byte packets seq 4: tcp response from 121.46.129.33 (121.46.129.33) <syn,ack> 35.519 ms traceroute to 121.46.129.33 (121.46.129.33), 255 hops max, 60 byte packets seq 5: tcp response from 121.46.129.33 (121.46.129.33) <syn,ack> 35.473 ms traceroute to 121.46.129.33 (121.46.129.33), 255 hops max, 60 byte packets seq 3: tcp response from 121.46.129.33 (121.46.129.33) <syn,ack> 35.470 ms traceroute to 121.46.129.33 (121.46.129.33), 255 hops max, 60 byte packets seq 7: tcp response from 121.46.129.33 (121.46.129.33) <syn,ack> 35.528 ms traceroute to 121.46.129.33 (121.46.129.33), 255 hops max, 60 byte packets seq 6: tcp response from 121.46.129.33 (121.46.129.33) <syn,ack> 35.479 ms traceroute to 121.46.129.33 (121.46.129.33), 255 hops max, 60 byte packets traceroute to 121.46.129.33 (121.46.129.33), 255 hops max, 60 byte packets seq 9: tcp response from 121.46.129.33 (121.46.129.33) <syn,ack> 35.478 ms seq 8: tcp response from 121.46.129.33 (121.46.129.33) <syn,ack> 35.516 ms traceroute to 121.46.129.33 (121.46.129.33), 255 hops max, 60 byte packets seq 10: tcp response from 121.46.129.33 (121.46.129.33) <syn,ack> 35.452 ms traceroute to 121.46.129.33 (121.46.129.33), 255 hops max, 60 byte packets seq 11: tcp response from 121.46.129.33 (121.46.129.33) <syn,ack> 35.529 ms traceroute to 121.46.129.33 (121.46.129.33), 255 hops max, 60 byte packets seq 12: tcp response from 121.46.129.33 (121.46.129.33) <syn,ack> 35.521 ms traceroute to 121.46.129.33 (121.46.129.33), 255 hops max, 60 byte packets seq 13: tcp response from 121.46.129.33 (121.46.129.33) <syn,ack> 35.404 ms traceroute to 121.46.129.33 (121.46.129.33), 255 hops max, 60 byte packets seq 14: tcp response from 121.46.129.33 (121.46.129.33) <syn,ack> 35.502 ms traceroute to 121.46.129.33 (121.46.129.33), 255 hops max, 60 byte packets seq 15: tcp response from 121.46.129.33 (121.46.129.33) <syn,ack> 35.514 ms traceroute to 121.46.129.33 (121.46.129.33), 255 hops max, 60 byte packets seq 17: tcp response from 121.46.129.33 (121.46.129.33) <syn,ack> 35.515 ms traceroute to 121.46.129.33 (121.46.129.33), 255 hops max, 60 byte packets seq 16: tcp response from 121.46.129.33 (121.46.129.33) <syn,ack> 35.462 ms traceroute to 121.46.129.33 (121.46.129.33), 255 hops max, 60 byte packets seq 18: tcp response from 121.46.129.33 (121.46.129.33) <syn,ack> 35.442 ms traceroute to 121.46.129.33 (121.46.129.33), 255 hops max, 60 byte packets seq 20: tcp response from 121.46.129.33 (121.46.129.33) <syn,ack> 35.518 ms traceroute to 121.46.129.33 (121.46.129.33), 255 hops max, 60 byte packets seq 19: tcp response from 121.46.129.33 (121.46.129.33) <syn,ack> 35.415 ms traceroute to 121.46.129.33 (121.46.129.33), 255 hops max, 60 byte packets seq 21: tcp response from 121.46.129.33 (121.46.129.33) <syn,ack> 35.453 ms traceroute to 121.46.129.33 (121.46.129.33), 255 hops max, 60 byte packets seq 22: tcp response from 121.46.129.33 (121.46.129.33) <syn,ack> 35.461 ms traceroute to 121.46.129.33 (121.46.129.33), 255 hops max, 60 byte packets seq 23: tcp response from 121.46.129.33 (121.46.129.33) <syn,ack> 35.462 ms traceroute to 121.46.129.33 (121.46.129.33), 255 hops max, 60 byte packets -d 打印本机每发出一个tcp包的当前时间戳 -c 打印一版纯数字的信息,可以用它来粘贴到excel表格 并制成延时抖动表 -C 另一种格式的纯数字制表信息 -w 设置等待时间(秒) 默认为3秒 -r 设置不管有无tcp包回复,本机间隔多少时间重复发送tcp握手包 这个那啥,可以用作ddos哦?! -x 设置本机发送多少次tcp包,默认为空 即无限制重复发送
转载于:https://www.cnblogs.com/vincent-liang/p/8528279.html
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/151485.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...