5

I have a project that wishes to force the times of a set of private NTP servers to demonstrate how NTP (and our software) reacts to various time changes and differences, network lag, etc.

Normally, we'd set up a virtual network of VMs to demonstrate our software, but I can't seem to find one that will allow NTP to run independently in each VM. For this we'd need a software clock.

So far, I've looked at:

  • Docker - ties their clock to the hardware clock of the host, privileges are one issue, but the main issue is that if the clock is changed all clocks running in all VMs on that host are changed.

  • VirtualBox - This answer suggests that even with guest-additions, the lack of a high-resolution clock would make this impossible.

Is there any software that can virtualize a hardware clock for NTP, or otherwise run independent clocks on the same machine at the same time?

3 Answers3

3

It is not clear if you are interested in

  • how ntp behaves under some set of circumstances.

  • how your software behaves due to time changes and you have decided the best way to introduce these time changes is fiddling with ntp.

If you are simply interested in the former check out ntpdsim. It is part of the ntp reference implementation:

The ntpdsim program is used to simulate and study the behavior of an NTP daemon that derives its time from a number of different simulated time sources (servers). Each simulated server can be configured to have a different time offset, frequency offset, propagation delay, processing delay, network jitter and oscillator wander.

If you are interested in the later, use ntpdsim to see how your ntp servers will react to the changes. Then take this information and use a cronjob or something similar to modify the clocks on your vms according to the information you learned from the ntpdsim runs...

https://www.eecis.udel.edu/~mills/ntp/html/ntpdsim_new.html

dfc
  • 757
  • 6
  • 11
2

Red Hat's documentation suggests that at least one of the libvirt hypervisors support configurable clock sources (or at least custom offsets): https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Virtualization_Administration_Guide/sect-Virtualization-Tips_and_tricks-Libvirt_Managed_Timers.html

KVM is one of the libvirt hypervisors, and at least one person describes accidental desynchronisation: https://unix.stackexchange.com/q/83934/63149

(Apologies for formatting -- I'm on mobile and originally intended to just drop this as a comment!)

RJHunter
  • 198
0

As RJHunter stated, it is entirely possible to get NTP working on multiple KVM instances, however it will probably not be extremely accurate.

This link goes into details about KVM.

davidgo
  • 73,366