Giter Club home page Giter Club logo

tcpping's Introduction

tcpping v2.x

Warning: With version 2.4, some defaults have changed:

  • Default timeout is now 1 second instead of 3
  • Interval between pings is now automatically calculated to fit timeout

These changes have been made to make Smokeping integration easier.

fork of elder tcpping v1.8 script running with newer traceroute binary

This script is a fork of Richard Van den Berg's tcpping script, original version found here, supporting newer traceroute binaries. Usage is the same and should work out of the box for smokeping.

It comes with various improvements like language agonstic functionality, better error detection, debug, and removed tcptraceroute dependancy, sub second pings and statistics.

So far, tests have been done with:

  • CentOS 7: v2.0-2.3 tested (with traceroute 2.0.22 and bash 4.2.46(2)-release)
  • CentOS 8: v2.3 tested (with traceroute 2.1.0 and bash 4.4.19(1)-release)
  • FreeBSD 11.2: v2.0-2.3 tested (with traceroute 1.4a12 and tcsh 6.20.00) Also, smokeping 2.7.2 and 2.7.3 have been tested.

Installation

sudo wget -O /usr/bin/tcpping https://raw.githubusercontent.com/deajan/tcpping/master/tcpping ; sudo chmod 755 /usr/bin/tcpping

Usage

Example command smokeping would use

tcpping -C -x 5 myhost 80

Example command for sub second tcp ping analysis on Linux

tcpping -x 10 -w .1 -o myhost 443

Keep in mind that the tcp / udp probe checks for a SYN flag, which does not mean that a service is listening on the target machine port.

Root privileges

By default, traceroute needs root privileges. You may launch script with sudo or with '-Z' in order to ask for root privileges during execution. By doing so, you may edit your sudoers file by allowing user 'bob' to run traceroute as root without password

bob ALL=(ALL) NOPASSWD: /usr/bin/traceroute

Licence and improvements

Altough there are probably better tools out there (hping, nmap, etc), this is still a quick and handy tool used by smokeping, so every improvement / fork / pull request is more than welcome.

Originally, Richard linked to the GPLv2 licence. Having talked with him, he did allow to update to GPLv3, so this script is GPLv3.

tcpping's People

Contributors

deajan avatar dmascord avatar notjames avatar ruiyuan-zhang avatar zahrun avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

tcpping's Issues

script gives error on debian buster sleep: invalid time interval 'auto'

Hi,

i'd like to use this script with smokeping, but it seems it doesn't work with debian buster (cat /etc/debian_version -> 10.9), if i run the script manually i get:

tcpping -x 10 -w .1 -o some.host 443

/usr/bin/tcpping: 341: [: auto: unexpected operator
255 some.host (12.34.56.78) 11.243 ms
sleep: invalid time interval 'auto'
Try 'sleep --help' for more information.

and i also don't get graphs in smokeping, which i relate to those errors.

Tcpping output out of order

Hi,

We are executing tcpping as synthetic tests continuously and the configuratons used to run the test is listed below. We are executing tcpping for 5 minutes, which internally runs tcpping test 300 times, 1 sequence per second.

The final output is generated from 300 sequences. We are processing the raw output generated for further processing.
For most part, we dont see any issue with the output file generated. But at times, the output seem to be not in order expected. Attached is one of the output for reference where line number 325 and 326 seem to be not in the order. Because of the order problem, we are facing issues in parsing the output generated.
tcpping_output_out_of_order.txt

Test Input Parameters:
"test_target_params": [{
"ParamName": "-d",
"ParamValue": ""
},
{
"ParamName": "-x",
"ParamValue": "300"
},
{
"ParamName": "-r",
"ParamValue": "1 server_ip 80"
}
]

Tcpping out of order:
image

unable to use with Docker (busybox) traceroute: unrecognized option: M

Trying to install TCPPing into a docker for Smokeping

I am testing it with this:
docker exec -i smokeping /usr/bin/tcpping -C -x 5 live-sjc05.twitch.tv 1935

I get this output:

Unable to run ' traceroute -M tcp -f 255 -m 255 -q 1 -w 1  -p 1935 live-sjc05.twitch.tv' command. Please submit an issue in 'https://github.com/deajan/tcpping/issues' with the output of the command.

Taking the command listed in the output and running it like this:
docker exec -i smokeping traceroute -M tcp -f 255 -m 255 -q 1 -w 1 -p 1935 live-sjc05.twitch.tv

yields this:

traceroute: unrecognized option: M
BusyBox v1.31.1 () multi-call binary.

Usage: traceroute [-46FIlnrv] [-f 1ST_TTL] [-m MAXTTL] [-q PROBES] [-p PORT]
        [-t TOS] [-w WAIT_SEC] [-s SRC_IP] [-i IFACE]
        [-z PAUSE_MSEC] HOST [BYTES]

Trace the route to HOST

        -4,-6   Force IP or IPv6 name resolution
        -F      Set don't fragment bit
        -I      Use ICMP ECHO instead of UDP datagrams
        -l      Display TTL value of the returned packet
        -n      Print numeric addresses
        -r      Bypass routing tables, send directly to HOST
        -v      Verbose
        -f N    First number of hops (default 1)
        -m N    Max number of hops
        -q N    Number of probes per hop (default 3)
        -p N    Base UDP port number used in probes
                (default 33434)
        -s IP   Source address
        -i IFACE Source interface
        -t N    Type-of-service in probe packets (default 0)
        -w SEC  Time to wait for a response (default 3)
        -g IP   Loose source route gateway (8 max)

Most importantly it shows: traceroute: unrecognized option: M

[: unexpected operator (patch attached)

If statements contain == instead of =, will fail using /bin/sh

user@host:/$ tcpping -x 1 google.com 443
/usr/local/bin/tcpping: 280: [: unexpected operator
/usr/local/bin/tcpping: 280: [: unexpected operator
/usr/local/bin/tcpping: 163: [: false: unexpected operator
user@host:/$ /usr/local/bin/tcpping: 201: [: false: unexpected operator
/usr/local/bin/tcpping: 206: [: unexpected operator
/usr/local/bin/tcpping: 206: [: unexpected operator

Patch supplied
tcpping.patch.gz

doesnt work without root or sudo

Morning,

Attempted to use this new script on an Ubuntu 16.04.5 LTS VM and it was producing zero output for smokeping. Debugged it down to the use of the -T switch with traceroute and the fact that the user smokeping runs as is just a normal user. User smokeping cant sudo and traceroute isnt setuid root by default.

Some more detailed notes:

  • running as normal user
ubuntu@jump00:~$ /usr/local/bin/tcpping.new -C -x 5 220.233.82.46 5060
220.233.82.46 : - - - - -
ubuntu@jump00:~$ /usr/local/bin/tcpping -C -x 5 220.233.82.46 5060
220.233.82.46 : 13.097 14.740 14.146 13.350 13.738
  • running with sudo
ubuntu@jump00:~$ sudo /usr/local/bin/tcpping.new -C -x 5 220.233.82.46 5060
220.233.82.46 : 13.349 12.796 13.697 13.730 13.162
ubuntu@jump00:~$ sudo /usr/local/bin/tcpping -C -x 5 220.233.82.46 5060
220.233.82.46 : 13.541 13.498 13.544 13.676 13.818
ubuntu@jump00:~$ /usr/local/bin/tcpping.new -z -C -x 5 220.233.82.46 5060
traceroute -T -f 255 -m 255 -q 1 -w 3  -p 5060 220.233.82.46
traceroute -T -f 255 -m 255 -q 1 -w 3  -p 5060 220.233.82.46
ubuntu@jump00:~$ traceroute -T -f 255 -m 255 -q 1 -w 3  -p 5060 220.233.82.46
You do not have enough privileges to use this traceroute method.
socket: Operation not permitted

Unable to run tcpping for a specific host

Hello there

First, thank you for providing me this awesome program!

Well nothing but I failed to run tcpping for a specific host.

I want to keep track of Euronet that we are using for our service but I can't see the graph with this message.

[Unable to run ' traceroute -M tcp -f 255 -m 255 -q 1 -w 3 -p 443 103.19.271.10' command. Please submit an issue in 'https://github.com/deajan/tcpping/issues']

Can you please check the issue?

Many thanks,
Sonia Lee

Illegal option error when running script

I get the following when trying to run tcpping, even after making the file executable:

# tcpping 
/usr/bin/tcpping: 74: set: Illegal option -o pipefail

Any ideas on how to fix this?

Script fails when run with `dash`

$ tcpping -C -x 5 localhost 80
/usr/bin/tcpping: 341: [: auto: unexpected operator

Working fixes:

  • Changing line 341 to use = instead of ==.
  • Changing line 1 to use /bin/bash.

checkbashisms reports possible issues on lines 75, 160, 165, 341.

Same subnet IPs will trigger bogus results

When using tcpping to query an IP in the same subnet, since there are no gateway jumps, traceroute will show initial sender timing, giving bogus results.
There should be a check if only one jump exists, don't show results.

Tcpping reporting "no response (timeout)" for extended time

Hi Team,

As per the below tcpping results output, the tcpping tool reported "no sequence timeout" errors from "Wed Jan 31 04:58:19 UTC 2024" till "Wed Jan 31 04:59:02 UTC 2024" between client and server VM for about 45 seconds.
The tcpping test is executed every second with parameter "-r 1".

When we checked with the cloud provider, there was a NIC update on the node hosting the tcpping server VM. However, the Nic update had completed in less than 10 seconds and was within the SLA.
From linux kernal logs we also see that the Vf registration of the NIC had completed in less than 10 seconds. However, the tcpping tool reported " no sequence timeouts" for close to 45 seconds.

**Ask: **

  1. Why did the tcpping tool report " no sequence timeout" for 45 seconds, though the underlying NIC had re-registered back in 10 seconds after NIC update? I was expecting the "no sequence timeouts" only for 10 seconds and not for 45 seconds? Why the tcpping tool is taking more time to recover after the NIC update? After 45 seconds, the tcpping stated to work fine reporting latency between client and server VM:
  2. Is there some caching in connection that's causing this problem? If yes, is there a way to reset the cache before executing the tcpping test that's executed every second?

Here is the tcpping output snippet which reported no sequence timeouts for 45 seconds:

Wed Jan 31 04:58:12 UTC 2024
traceroute to 10.10.1.23 (10.10.1.23), 255 hops max, 60 byte packets
seq 115: tcp response from 10.10.1.23 (10.10.1.23) <syn,ack> 1.417 ms
Wed Jan 31 04:58:13 UTC 2024
traceroute to 10.10.1.23 (10.10.1.23), 255 hops max, 60 byte packets
seq 116: tcp response from 10.10.1.23 (10.10.1.23) <syn,ack> 1.485 ms
Wed Jan 31 04:58:14 UTC 2024
traceroute to 10.10.1.23 (10.10.1.23), 255 hops max, 60 byte packets
seq 117: tcp response from 10.10.1.23 (10.10.1.23) <syn,ack> 1.109 ms
Wed Jan 31 04:58:15 UTC 2024
traceroute to 10.10.1.23 (10.10.1.23), 255 hops max, 60 byte packets
seq 118: tcp response from 10.10.1.23 (10.10.1.23) <syn,ack> 1.050 ms
Wed Jan 31 04:58:16 UTC 2024
traceroute to 10.10.1.23 (10.10.1.23), 255 hops max, 60 byte packets
seq 119: tcp response from 10.10.1.23 (10.10.1.23) <syn,ack> 1.118 ms
Wed Jan 31 04:58:17 UTC 2024
traceroute to 10.10.1.23 (10.10.1.23), 255 hops max, 60 byte packets
seq 120: tcp response from 10.10.1.23 (10.10.1.23) <syn,ack> 1.245 ms
Wed Jan 31 04:58:18 UTC 2024
traceroute to 10.10.1.23 (10.10.1.23), 255 hops max, 60 byte packets
seq 121: tcp response from 10.10.1.23 (10.10.1.23) <syn,ack> 0.989 ms
Wed Jan 31 04:58:19 UTC 2024
traceroute to 10.10.1.23 (10.10.1.23), 255 hops max, 60 byte packets
seq 122: no response (timeout)
Wed Jan 31 04:58:20 UTC 2024
traceroute to 10.10.1.23 (10.10.1.23), 255 hops max, 60 byte packets
seq 123: no response (timeout)
Wed Jan 31 04:58:21 UTC 2024
traceroute to 10.10.1.23 (10.10.1.23), 255 hops max, 60 byte packets
seq 124: no response (timeout)
Wed Jan 31 04:58:22 UTC 2024
traceroute to 10.10.1.23 (10.10.1.23), 255 hops max, 60 byte packets
seq 125: no response (timeout)
Wed Jan 31 04:58:23 UTC 2024
traceroute to 10.10.1.23 (10.10.1.23), 255 hops max, 60 byte packets
seq 126: no response (timeout)
Wed Jan 31 04:58:24 UTC 2024
traceroute to 10.10.1.23 (10.10.1.23), 255 hops max, 60 byte packets
seq 127: no response (timeout)
Wed Jan 31 04:58:25 UTC 2024
traceroute to 10.10.1.23 (10.10.1.23), 255 hops max, 60 byte packets
seq 128: no response (timeout)
Wed Jan 31 04:58:26 UTC 2024
traceroute to 10.10.1.23 (10.10.1.23), 255 hops max, 60 byte packets
seq 129: no response (timeout)
Wed Jan 31 04:58:27 UTC 2024
traceroute to 10.10.1.23 (10.10.1.23), 255 hops max, 60 byte packets
seq 130: no response (timeout)
Wed Jan 31 04:58:28 UTC 2024
traceroute to 10.10.1.23 (10.10.1.23), 255 hops max, 60 byte packets
seq 131: no response (timeout)
Wed Jan 31 04:58:29 UTC 2024
traceroute to 10.10.1.23 (10.10.1.23), 255 hops max, 60 byte packets
seq 132: no response (timeout)
Wed Jan 31 04:58:30 UTC 2024
traceroute to 10.10.1.23 (10.10.1.23), 255 hops max, 60 byte packets
seq 133: no response (timeout)
Wed Jan 31 04:58:31 UTC 2024
traceroute to 10.10.1.23 (10.10.1.23), 255 hops max, 60 byte packets
seq 134: no response (timeout)
Wed Jan 31 04:58:32 UTC 2024
traceroute to 10.10.1.23 (10.10.1.23), 255 hops max, 60 byte packets
seq 135: no response (timeout)
Wed Jan 31 04:58:33 UTC 2024
traceroute to 10.10.1.23 (10.10.1.23), 255 hops max, 60 byte packets
seq 136: no response (timeout)
Wed Jan 31 04:58:34 UTC 2024
traceroute to 10.10.1.23 (10.10.1.23), 255 hops max, 60 byte packets
seq 137: no response (timeout)
Wed Jan 31 04:58:35 UTC 2024
traceroute to 10.10.1.23 (10.10.1.23), 255 hops max, 60 byte packets
seq 138: no response (timeout)
Wed Jan 31 04:58:36 UTC 2024
traceroute to 10.10.1.23 (10.10.1.23), 255 hops max, 60 byte packets
seq 139: no response (timeout)
Wed Jan 31 04:58:37 UTC 2024
traceroute to 10.10.1.23 (10.10.1.23), 255 hops max, 60 byte packets
seq 140: no response (timeout)
Wed Jan 31 04:58:38 UTC 2024
traceroute to 10.10.1.23 (10.10.1.23), 255 hops max, 60 byte packets
seq 141: no response (timeout)
Wed Jan 31 04:58:39 UTC 2024
traceroute to 10.10.1.23 (10.10.1.23), 255 hops max, 60 byte packets
seq 142: no response (timeout)
Wed Jan 31 04:58:40 UTC 2024
traceroute to 10.10.1.23 (10.10.1.23), 255 hops max, 60 byte packets
seq 143: no response (timeout)
Wed Jan 31 04:58:41 UTC 2024
traceroute to 10.10.1.23 (10.10.1.23), 255 hops max, 60 byte packets
seq 144: no response (timeout)
Wed Jan 31 04:58:42 UTC 2024
traceroute to 10.10.1.23 (10.10.1.23), 255 hops max, 60 byte packets
seq 145: no response (timeout)
Wed Jan 31 04:58:43 UTC 2024
traceroute to 10.10.1.23 (10.10.1.23), 255 hops max, 60 byte packets
seq 146: no response (timeout)
Wed Jan 31 04:58:44 UTC 2024
traceroute to 10.10.1.23 (10.10.1.23), 255 hops max, 60 byte packets
seq 147: no response (timeout)
Wed Jan 31 04:58:45 UTC 2024
traceroute to 10.10.1.23 (10.10.1.23), 255 hops max, 60 byte packets
seq 148: no response (timeout)
Wed Jan 31 04:58:46 UTC 2024
traceroute to 10.10.1.23 (10.10.1.23), 255 hops max, 60 byte packets
seq 149: no response (timeout)
Wed Jan 31 04:58:47 UTC 2024
traceroute to 10.10.1.23 (10.10.1.23), 255 hops max, 60 byte packets
seq 150: no response (timeout)
Wed Jan 31 04:58:48 UTC 2024
traceroute to 10.10.1.23 (10.10.1.23), 255 hops max, 60 byte packets
seq 151: no response (timeout)
Wed Jan 31 04:58:49 UTC 2024
traceroute to 10.10.1.23 (10.10.1.23), 255 hops max, 60 byte packets
seq 152: no response (timeout)
Wed Jan 31 04:58:50 UTC 2024
traceroute to 10.10.1.23 (10.10.1.23), 255 hops max, 60 byte packets
seq 153: no response (timeout)
Wed Jan 31 04:58:51 UTC 2024
traceroute to 10.10.1.23 (10.10.1.23), 255 hops max, 60 byte packets
seq 154: no response (timeout)
Wed Jan 31 04:58:52 UTC 2024
traceroute to 10.10.1.23 (10.10.1.23), 255 hops max, 60 byte packets
seq 155: no response (timeout)
Wed Jan 31 04:58:53 UTC 2024
traceroute to 10.10.1.23 (10.10.1.23), 255 hops max, 60 byte packets
seq 156: no response (timeout)
Wed Jan 31 04:58:54 UTC 2024
traceroute to 10.10.1.23 (10.10.1.23), 255 hops max, 60 byte packets
seq 157: no response (timeout)
Wed Jan 31 04:58:55 UTC 2024
traceroute to 10.10.1.23 (10.10.1.23), 255 hops max, 60 byte packets
seq 158: no response (timeout)
Wed Jan 31 04:58:56 UTC 2024
traceroute to 10.10.1.23 (10.10.1.23), 255 hops max, 60 byte packets
seq 159: no response (timeout)
Wed Jan 31 04:58:57 UTC 2024
traceroute to 10.10.1.23 (10.10.1.23), 255 hops max, 60 byte packets
seq 160: no response (timeout)
Wed Jan 31 04:58:58 UTC 2024
traceroute to 10.10.1.23 (10.10.1.23), 255 hops max, 60 byte packets
seq 161: no response (timeout)
Wed Jan 31 04:58:59 UTC 2024
traceroute to 10.10.1.23 (10.10.1.23), 255 hops max, 60 byte packets
seq 162: no response (timeout)
Wed Jan 31 04:59:02 UTC 2024
traceroute to 10.10.1.23 (10.10.1.23), 255 hops max, 60 byte packets
seq 165: tcp response from 10.10.1.23 (10.10.1.23) <syn,ack> 0.862 ms
Wed Jan 31 04:59:00 UTC 2024
traceroute to 10.10.1.23 (10.10.1.23), 255 hops max, 60 byte packets
seq 163: no response (timeout)
Wed Jan 31 04:59:03 UTC 2024
traceroute to 10.10.1.23 (10.10.1.23), 255 hops max, 60 byte packets
seq 166: tcp response from 10.10.1.23 (10.10.1.23) <syn,ack> 0.916 ms
Wed Jan 31 04:59:01 UTC 2024
traceroute to 10.10.1.23 (10.10.1.23), 255 hops max, 60 byte packets
seq 164: no response (timeout)
Wed Jan 31 04:59:04 UTC 2024
traceroute to 10.10.1.23 (10.10.1.23), 255 hops max, 60 byte packets
seq 167: tcp response from 10.10.1.23 (10.10.1.23) <syn,ack> 1.102 ms
Wed Jan 31 04:59:05 UTC 2024
traceroute to 10.10.1.23 (10.10.1.23), 255 hops max, 60 byte packets
seq 168: tcp response from 10.10.1.23 (10.10.1.23) <syn,ack> 1.165 ms
Wed Jan 31 04:59:06 UTC 2024
traceroute to 10.10.1.23 (10.10.1.23), 255 hops max, 60 byte packets
seq 169: tcp response from 10.10.1.23 (10.10.1.23) <syn,ack> 0.893 ms

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.