cloverstd / tcping

ping over a tcp connection
MIT License
803 stars 163 forks source link

Seems every ping after the first one has the wrong timing data #23

Open iopq opened 2 years ago

iopq commented 2 years ago
Ping tcp://example.com:80(93.184.216.34:80) - Connected - time=233.248409ms
Ping tcp://example.com:80(93.184.216.34:80) - Connected - time=419.692µs
Ping tcp://example.com:80(93.184.216.34:80) - Connected - time=530.75µs
Ping tcp://example.com:80(93.184.216.34:80) - Connected - time=550.278µs

Ping statistics tcp://example.com:80
    4 probes sent.
    4 successful, 0 failed.
Approximate trip times:
    Minimum = 419.692µs, Maximum = 233.248409ms, Average = 58.687282ms

It should really be returning 200ish ms

I'm accessing the internet through a proxy, so it might have something to do with it

sidecut commented 1 year ago

Since the 2nd, 3rd, and 4th round trip times are in microseconds, not milliseconds, they barely contribute to the computation of the average, since the first round trip time is about 500x greater. Therefore, the simple average -- total/n -- is indeed about 58ms. (I think there should be an option to specify all roundtrip times in the same units. It's hard at a glance to notice the differences between the microseconds and the milliseconds.)

Perhaps outliers should be discarded before computing the average is computed, because the web server might be cold initially, throwing off the calculation of the average.

Alternatively, a median could be added to the statistics. Medians by their nature ignore outliers.

iopq commented 9 months ago

Alternatively, a median could be added to the statistics. Medians by their nature ignore outliers.

the problem is that I don't believe the actual latency is 400µs after the first one

that sounds like the latency to my localhost proxy