Subject: [Ntp] Minimal implementation of client/server interleaved mode

From: Miroslav Lichvar <[email-masked]>
Date: Tue, 11 Sep 2018 15:57:28 +0200

On the previous meeting there was a discussion about NAT breaking the
client/server interleaved mode. That may be a limitation of a
particular implementation, but I don't think it is an issue of the
protocol in general.

I've written a minimal server and client implementation in Python that
tries to follow all recommendations from the draft. It should be
useful for experimenting with the protocol.

https://raw.githubusercontent.com/mlichvar/draft-ntp-interleaved-modes/master/example-server.py
https://raw.githubusercontent.com/mlichvar/draft-ntp-interleaved-modes/master/example-client.py

You can run multiple clients on the same host (even localhost) and see
that the server is still able to respond in the interleaved mode. It
doesn't matter from which port or address the client request comes
from. The only thing that matters is the origin timestamp.

# python3 example-client.py 127.0.0.1 > /dev/null &
# python3 example-client.py 127.0.0.1 > /dev/null &
# python3 example-server.py
Request from 127.0.0.1:52313       : org=0000000000000000 rx=0000000000000000 tx=41dd79da962db249
Response in basic mode             : org=41dd79da962db249 rx=df423dff410c3b6c tx=df423dff410d5a9d
Request from 127.0.0.1:36135       : org=0000000000000000 rx=0000000000000000 tx=06c5e75185f3de08
Response in basic mode             : org=06c5e75185f3de08 rx=df423e00927370fe tx=df423e0092748d54
Request from 127.0.0.1:52313       : org=df423dff410c3b6c rx=84134b4b3cf9972d tx=931225c4a2fae73c
Response in interleaved mode       : org=84134b4b3cf9972d rx=df423e03422770bc tx=df423dff41127e32
Request from 127.0.0.1:36135       : org=df423e00927370fe rx=7a06a8d28e325c55 tx=7d56589108c95250
Response in interleaved mode       : org=7a06a8d28e325c55 rx=df423e049390b0ba tx=df423e009278d1b1
Request from 127.0.0.1:52313       : org=df423e03422770bc rx=a19333754b0c69b3 tx=2f19912a017c3484
Response in interleaved mode       : org=a19333754b0c69b3 rx=df423e074342055b tx=df423e03422ab0d5
Request from 127.0.0.1:36135       : org=df423e049390b0ba rx=73a5128a94758c67 tx=452c6027969510dd
Response in interleaved mode       : org=73a5128a94758c67 rx=df423e0894ad1308 tx=df423e0493949e42

You can test it also with clients running chronyd or ntpd using the
xleave option.

Comments and suggestions are welcome.

-- 
Miroslav Lichvar