To measure latency and bandwidth, we use a simple echo test between two adjacent nodes. A receiving node simply echos back whatever it is sent, and the sending node measures round-trip time. Times are collected for some number of repetitions (100 to 1000) over various messages sizes (0 to 1,000,000 bytes). Times can be collected outside the repetition loop as illustrated in Figure 1. If the system has high resolution timers then a more detailed analyses can be made by timing each send-receive pair. The time for each send-receive is saved in a vector and printed at the end of the test. You can plot this vector of times, observing minimums and maximums. For small message sizes, clock resolution may not be adequate, and you will probably observe clock jitter from time-sharing interrupts in the underlying OS. The minimum send-receive time (divided by two) for zero-length messages is what we report for latency. Data rate, or bandwidth, is calculated from the number of bytes sent divided by half the round-trip time. A number of other similar tests have been reported in [6, 7].
Figure 1: Echo test pseudo-code.