Skip to content

Tool for measuring performance of NTP servers and PTP masters

License

Notifications You must be signed in to change notification settings

mlichvar/ntpperf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ntpperf

ntpperf is a tool for measuring performance of NTP servers and PTP masters. It simulates NTP clients or PTP slaves sending requests at an increasing rate and prints how many responses were received and lost. If the computer running ntpperf has an accurate clock and the network delay to the server/master is constant and known (e.g. there is a direct connection), it can also show how does the accuracy of the transmit timestamp change with increasing rate of requests.

ntpperf generates and processes raw Ethernet frames using libpcap. Requests from the simulated clients/slaves have source addresses from a specified private IPv4 network. The server/master and/or network needs to be configured to route the responses to the computer running ntpperf, which should drop them (ideally in the raw table of iptables to minimize the time wasted in the networking stack).

Network Time Security (NTS) support using the gnutls library can be enabled by setting the NTPPERF_NTS environment variable for the build.

Usage

Usage: ./ntpperf MODE NETWORK-OPTIONS [OTHER-OPTIONS]

Mode:
        -B              send NTP client requests in basic mode
        -I              send NTP client requests in interleaved mode
        -D DOMAIN       send PTP delay requests
        -N DOMAIN       send PTP NetSync Monitor (NSM) requests

Network options:
        -i INTERFACE    specify network interface
        -s NETWORK/BITS specify source IPv4 network
        -d IP-ADDRESS   specify destination IPv4 address
        -m MAC          specify destination MAC address

Other options:
        -M              send multicast PTP delay requests to 224.0.1.129
        -r RATE[-RATE]  specify minimum and maximum rate (1000-1000000)
        -p NUMBER       specify number of processes to send requests (1)
        -e              make transmit interval exponentially distributed
        -l              allow late transmissions
        -x MULT         specify rate multiplier (1.5)
        -t INTERVAL     specify sampling interval (2.0 seconds)
        -o CORRECTION   print offset between remote TX and local RX timestamp
                        with specified correction (e.g. network and RX delay)
        -O              with -o use remote (RX+TX)/2 instead of TX timestamp
        -H              enable HW timestamping for TX offset statistics
        -S C2S,COOKIE   authenticate NTP requests with NTS
        -h              print this help message

Example

In this example ntpperf runs on a computer with address 192.168.123.2. It is configured to drop all UDP packets sent to the network 172.18.0.0/16:

# iptables -t raw -A PREROUTING -p udp -m udp -d 172.18.0.0/16 -j DROP

An NTP server and PTP master is running on 192.168.123.1. The MAC address of its interface is AA:BB:CC:DD:EE:FF. It is configured to route the responses to 192.168.123.2:

# ip route add 172.18.0.0/16 via 192.168.123.2 dev eth0

The following test measures the throughput of the NTP server in the basic mode and accuracy of server’s transmit timestamps relative to the local hardware clock of eth0 assuming a network delay and RX+TX compensation of 1.45 microseconds:

# ./ntpperf -i eth0 -m AA:BB:CC:DD:EE:FF -d 192.168.123.1 -s 172.18.0.0/16 -B -o 1.95e-6 -H
               |          responses            |     TX timestamp offset (ns)
rate   clients |  lost invalid   basic  xleave |    min    mean     max stddev
1000       100   0.00%   0.00% 100.00%   0.00%    +5343  +12047  +23267   1090
1500       150   0.00%   0.00% 100.00%   0.00%    +6085  +12035  +23378    910
2250       225   0.00%   0.00% 100.00%   0.00%    +5382  +11585  +24165   1739
3375       337   0.00%   0.00% 100.00%   0.00%    +4656  +11442  +24104   1822
5062       506   0.00%   0.00% 100.00%   0.00%    +4455  +11066  +23308   2386
7593       759   0.00%   0.00% 100.00%   0.00%    +4408   +9283  +27831   3332
11389     1138   0.00%   0.00% 100.00%   0.00%    +3762   +7585  +31063   4742
17083     1708   0.00%   0.00% 100.00%   0.00%    +3650   +5034  +25045   1203
25624     2562   0.00%   0.00% 100.00%   0.00%    +3527   +4731  +24358    805
38436     3843   0.00%   0.00% 100.00%   0.00%    +3558   +4765  +35514   1041
57654     5765   0.00%   0.00% 100.00%   0.00%    +2675   +3302  +13421    460
86481     8648   0.00%   0.00% 100.00%   0.00%    +2519   +3046  +12824    413
129721   12972   0.00%   0.00% 100.00%   0.00%    +2524   +3062 +151362    610
194581   16384   0.00%   0.00% 100.00%   0.00%    +2511   +3082  +55417   1696
291871   16384   0.09%   0.00%  99.91%   0.00%    +2552   +3105  +47080   1884
437806   16384   5.58%   0.00%  94.42%   0.00%    +2562   +2975  +28727   1480
656709   16384  49.78%   0.00%  50.22%   0.00%    +2557   +3367 +230131   3570
Could not send requests at rate 985063

The following test measures the performance of the NTP server in the interleaved mode:

# ./ntpperf -i eth0 -m AA:BB:CC:DD:EE:FF -d 192.168.123.1 -s 172.18.0.0/16 -I -o 1.95e-6 -H
               |          responses            |     TX timestamp offset (ns)
rate   clients |  lost invalid   basic  xleave |    min    mean     max stddev
1000       100   0.00%   0.00%   0.00% 100.00%      -23     +17     +53     14
1500       150   0.00%   0.00%   0.00% 100.00%      -21     +20     +57     14
2250       225   0.00%   0.00%   0.00% 100.00%      -43     +12     +55     17
3375       337   0.00%   0.00%   0.00% 100.00%      -54      -8     +41     15
5062       506   0.00%   0.00%   0.00% 100.00%      -15     +39     +80     16
7593       759   0.00%   0.00%   0.00% 100.00%      -26     +19     +73     15
11389     1138   0.00%   0.00%   0.00% 100.00%      +19     +70    +119     16
17083     1708   0.00%   0.00%   0.00% 100.00%       +8     +50     +98     15
25624     2562   0.00%   0.00%   0.00% 100.00%      -67      -1     +70     25
38436     3843   0.00%   0.00%   0.00% 100.00%      -70     -32      +9     14
57654     5765   0.00%   0.00%   0.00% 100.00%      -80     -36      +3     14
86481     8648  21.02%   0.00%   1.49%  77.49%      -92   +1173  +52305   3326
129721   12972  26.84%   0.00%   1.59%  71.57%      -43   +1226  +34199   1743
194581   16384  51.98%   0.00%   2.25%  45.77%      -77   +2179  +26984   2176

To test NTP performance with NTS authentication it is necessary to obtain a valid C2S key and cookie using a separate NTS-KE client. The AEAD algorithm is AEAD_AES_SIV_CMAC_256 (15). The key and cookie are specified as hexadecimal numbers with the -S option. Without the -o option the server response time (interval between remote RX and TX timestamps) is printed instead of the TX timestamp offset:

# ./ntpperf -i eth0 -m AA:BB:CC:DD:EE:FF -d 192.168.123.1 -s 172.18.0.0/16 -B -S 44508CC523BD3FF2334A3B73E70969BF69BC4753EB745FD8EC054FF083DF788C,2D1FF1538B637C3DDE7A1AE23D0A1B104A8F68C6E1E1BB54A3139955BACE08307C2C3210F6A039A956A72038A42FBF3489EBFB207EDB6CDBFFF2B4F25818787D78CD170637475394A8E597827CC06D78E9CD6CED3D8573D69AA7E1303CB79C0499D7BB21
               |          responses            |        response time (ns)
rate   clients |  lost invalid   basic  xleave |    min    mean     max stddev
1000       100   0.00%   0.00% 100.00%   0.00%   +19172  +55881  +91692  10729
1500       150   0.00%   0.00% 100.00%   0.00%   +20906  +55601  +92014  10875
2250       225   0.00%   0.00% 100.00%   0.00%   +19151  +54690 +224118  11974
3375       337   0.00%   0.00% 100.00%   0.00%   +16020  +53464  +75994  12282
5062       506   0.00%   0.00% 100.00%   0.00%   +14089  +49891 +168482  15643
7593       759   0.00%   0.00% 100.00%   0.00%   +13429  +38142 +184297  18957
11389     1138   0.00%   0.00% 100.00%   0.00%   +11065  +28241 +156426  16472
17083     1708   0.00%   0.00% 100.00%   0.00%    +9592  +18460 +154719   6312
25624     2562   0.00%   0.00% 100.00%   0.00%    +8077  +19027 +164717   3842
38436     3843   0.00%   0.00% 100.00%   0.00%    +4782  +12554 +237316   3736
57654     5765   0.00%   0.00% 100.00%   0.00%    +3951  +11393 +122890   3255
86481     8648   0.00%   0.00% 100.00%   0.00%    +3762  +44640 +428393  47749
129721   12972   0.00%   0.00% 100.00%   0.00%    +3696  +23200 +280790  15876
194581   16384   0.00%   0.00% 100.00%   0.00%    +3950  +35853 +412163  21372
291871   16384  31.54%   0.00%  68.46%   0.00%  +256319 +417028 +855913  32953
437806   16384  60.92%   0.00%  39.08%   0.00%  +284758 +503148 +933666  88104

The following test measures the throughput of the PTP master using delay requests:

# ./ntpperf -i eth0 -m AA:BB:CC:DD:EE:FF -d 192.168.123.1 -s 172.18.0.0/16 -D 0
               |          responses            |
rate   clients |  lost invalid   delay sync/fw |
1000       100   0.00%   0.00% 100.00%   0.00%
1500       150   0.00%   0.00% 100.00%   0.00%
2250       225   0.00%   0.00% 100.00%   0.00%
3375       337   0.00%   0.00% 100.00%   0.00%
5062       506   0.00%   0.00% 100.00%   0.00%
7593       759   0.00%   0.00% 100.00%   0.00%
11389     1138   0.00%   0.00% 100.00%   0.00%
17083     1708   0.00%   0.00% 100.00%   0.00%
25624     2562   0.00%   0.00% 100.00%   0.00%
38436     3843   0.00%   0.00% 100.00%   0.00%
57654     5765   0.01%   0.00%  99.99%   0.00%
86481     8648   0.04%   0.00%  99.96%   0.00%
129721   12972   0.00%   0.00% 100.00%   0.00%
194581   16384   0.08%   0.00%  99.92%   0.00%
291871   16384   0.09%   0.00%  99.91%   0.00%
437806   16384  80.90%   0.00%  19.10%   0.00%

And this test measures the performance of the PTP master using NetSync Monitor requests:

# ./ntpperf -i eth0 -m AA:BB:CC:DD:EE:FF -d 192.168.123.1 -s 172.18.0.0/16 -N 0 -o 1.95e-6 -H
               |          responses            |     TX timestamp offset (ns)
rate   clients |  lost invalid   delay sync/fw |    min    mean     max stddev
1000       100   0.00%   0.00% 100.00% 100.00%      +13     +27     +38      7
1500       150   0.00%   0.00% 100.00% 100.00%      -22     +21     +47     18
2250       225   0.00%   0.00% 100.00% 100.00%      -52     -41     -22      7
3375       337   0.00%   0.00% 100.00% 100.00%      -48     -34     -25      7
5062       506   0.00%   0.00% 100.00% 100.00%      -65     -46     -27      9
7593       759   0.00%   0.00% 100.00% 100.00%      -29      +6     +19     12
11389     1138   0.00%   0.00% 100.00% 100.00%       -7     +12     +24      8
17083     1708   0.00%   0.00% 100.00% 100.00%       -3      +7     +26      4
25624     2562   0.00%   0.00% 100.00% 100.00%      -35     -22     +15     12
38436     3843   0.00%   0.00% 100.00% 100.00%      -39     +56    +136     70
57654     5765   0.00%   0.00% 100.00% 100.00%      -56     -18     +61     32
86481     8648 168.41%   0.00%  15.96%  15.63%      -49    +246    +634    235

Author

Miroslav Lichvar <[email protected]>

License

GPLv2+

About

Tool for measuring performance of NTP servers and PTP masters

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published