简体   繁体   中英

What is the right way to measure server/client latency (TCP & UDP)

I am sending and recieving packets between two boards (a Jeston and a Pi). I tried using TCP then UDP, theoritically UDP is faster but I want to verify this with numbers. I want to be able to run my scripts, send and recieve my packets while also calculating the latency. I will later study the effect of using RF modules instead of direct cables between the two boards on the latency (this is another reason why I want the numbers).

What is the right way to tackle this?

I tried sending the timestamps to get the difference but their times are not synched. I read about NTP and Iperf but I am not sure how they can be run within my scripts. iperf measures the trafic but how can that be accurate if your real TCP or UDP application is not running with real packets being exchanged?

It is provably impossible to measure (with 100% accuracy) the latency, since there is no global clock. NTP estimates it by presuming the upstream and downstream delays are equal (but actually upstream buffer delay/jitter is often greater).

UDP is only "faster" because it does not use acks and has lower overhead. This "faster" is not latency. Datacam "speed" is a combo of latency, BW, serialization delay (time to "clock-out" data), buffer delay, pkt over-head, and sometimes processing delay, and/or protocol over-head.

While getting one-way latency can be rather difficult and depend on very well synchronized clocks, you could make a simplifying assumption that the latency in one direction is the same as in the other (and no, that isn't always the case) and measure round-trip-time and divide by two. Ping would be one way to do that, netperf and a "TCP_RR" test would be another.

Depending on the network/link speed and the packet size and the CPU "horsepower," much if not most of the latency is in the packet processing overhead on either side. You can get an idea of that with the service demand figures netperf will report if you have it include CPU utilization. (nb - netperf assumes it is the only thing meaningfully consuming CPU on either end at the time of the test)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM