Skip to content

Ntp Client Demo Application

Marcin Szamotulski edited this page Jan 13, 2021 · 1 revision

You can run demo-ntp-client with

cabal run demo-ntp-client

Every 10s it will connect to preconfigured list of ntp servers:

  • 0.de.pool.ntp.org
  • 0.europe.pool.ntp.org
  • 0.pool.ntp.org
  • 1.pool.ntp.org
  • 2.pool.ntp.org
  • 3.pool.ntp.org

and report the time drift of your system. An example output:

NtpTraceStartNtpClient
NtpTraceClientStartQuery
NtpTracePacketSendError [2001:6a0:0:31::2]:123 Network.Socket.ByteString.sendManyTo: does not exist (Network is unreachable)
NtpTracePacketReceived 159.253.242.123:123 (NtpPacket {ntpParams = 28, ntpPoll = 3, ntpOriginTime = Microsecond 1610526286199252, ntpReceivedTime = Microsecond 1610526286225527, 
ntpTransmitTime = Microsecond 1610526286225545})
NtpTracePacketReceived 193.70.94.182:123 (NtpPacket {ntpParams = 28, ntpPoll = 3, ntpOriginTime = Microsecond 1610526286299766, ntpReceivedTime = Microsecond 1610526286305976, nt
pTransmitTime = Microsecond 1610526286305994})
NtpTracePacketReceived 77.237.25.197:123 (NtpPacket {ntpParams = 28, ntpPoll = 6, ntpOriginTime = Microsecond 1610526286400093, ntpReceivedTime = Microsecond 1610526286428943, nt
pTransmitTime = Microsecond 1610526286428948})
NtpTracePacketReceived 193.70.94.182:123 (NtpPacket {ntpParams = 28, ntpPoll = 3, ntpOriginTime = Microsecond 1610526286500429, ntpReceivedTime = Microsecond 1610526286506172, nt
pTransmitTime = Microsecond 1610526286506183})
NtpTracePacketReceived 176.221.42.125:123 (NtpPacket {ntpParams = 28, ntpPoll = 3, ntpOriginTime = Microsecond 1610526286600745, ntpReceivedTime = Microsecond 1610526286634611, n
tpTransmitTime = Microsecond 1610526286634744})
NtpTracePacketReceived 85.10.240.253:123 (NtpPacket {ntpParams = 28, ntpPoll = 3, ntpOriginTime = Microsecond 1610526286701075, ntpReceivedTime = Microsecond 1610526286724084, nt
pTransmitTime = Microsecond 1610526286724106})
NtpTraceWaitingForRepliesTimeout IPv6
NtpTraceRunProtocolResults BothSucceded [NtpOffset {getNtpOffset = Microsecond (-9942)},NtpOffset {getNtpOffset = Microsecond (-706)},NtpOffset {getNtpOffset = Microsecond (-9922
)},NtpOffset {getNtpOffset = Microsecond 238},NtpOffset {getNtpOffset = Microsecond (-13260)},NtpOffset {getNtpOffset = Microsecond (-70)}]
NtpTraceResult (NtpDrift (NtpOffset {getNtpOffset = Microsecond (-13260)}))
...

Press Control-C to terminate it.