[ntp:questions] Clock and Network Simulator

Miroslav Lichvar mlichvar at redhat.com
Tue Jun 29 11:50:30 UTC 2010

On Mon, Jun 28, 2010 at 05:35:34PM +0000, David L. Mills wrote:
> How is your simulator different than the one included in the NTP
> software distribution?

If I read the code correctly, ntpdsim simulates inside ntpd a
minimalistic NTP server (or multiple servers) with configured wander
and network delay, and an ideal local clock.

clknetsim simulates clocks and a network to which are connected
unmodified ntpd daemons. The simulation is transparent for them. With
symbol preloading (dynamic linker's LD_PRELOAD variable) they don't
use the real system calls like sendto(), recvfrom(), select(),
gettimeofday(), ntp_adjtime(), but they use the symbols provided by
clknetsim instead. The system calls are passed to the clknetsim
server, which synchronizes all events, adjusts the clocks, forwards
NTP packets and monitors the real time and frequency offsets of the
virtual clocks.

So, for a simulation similar to ntpdsim, at least two ntpd daemons
have to be connected to clknetsim, one configured as a server with
LOCAL clock (adding a refclock source is on my todo list) and a client
which will be the subject of testing. 

The advantage of this approach is that it allows you to test pretty
much anything that can be tested in a real network, a chain of NTP
servers (few such tests are on the clknetsim webpage), server/peer
modes, broadcast modes, authentication, compatibility with older
versions or different NTP implementations, etc.

The disadvantage is that the simulation runs slower.

Miroslav Lichvar

More information about the questions mailing list