Skip to the page content area.




vsntp is an SNTP client daemon for machines without a sane system time. The word vsntp stands for SNTP for Virtual PC. It was originally designed for my GNU/Linux server running on Connectix Virtual PC. It runs according to RFC 1769 SNTP, connecting the NTP server on UDP port 123.

Without Virtual PC Additions, the system time on Virtual PC is completely insane. It’s RTC (Real Time Clock, or CMOS time, or hardware clock) is software emulated, which does not seems to be running. The GNU/Linux kernel hardly maintains a system time itself. With smooth run it goes 4 seconds ahead per minute, which is nearly 1.5 hours per day. That is insane. You can even tell it with your eyes.

David L. Mills’ ntp does not work here. It uses a method that learns the clock frequency drift first, and adjust the kerenl clock with adjtimex() so that time adjustment goes smoothly, from the point of view of system and applications. This assumes an existing fix-speed system clock. But this is not the case of Virtual PC. The system clock on Virtual PC is software emulated. It can be faster or slower now and then, depending on the load of the hosting machine. There is no fixed clock speed. The frequency drift does not exist, then. It dooms to fail to measure it.

There is an sntp client that comes with David L. Mills’ ntp package. It is suggested to be run from crontab. But crontab runs by minutes, and Virtual PC goes 4 seconds ahead per minute. Rolling back 4 seconds every minute is insane for most applications. It also increases system load heavily to run one instance per minute.

vsntp is a workaround on this. It runs as a daemon to eliminates the additional system load on every synchronization. It uses settimeofday() to synchronize the time. It synchronizes the time with an arbitrary interval, so that time can be accurate within a second.

There are some defects. Synchronizing the time too often introduces heavy network load. It introduces heavy load on the target NTP server, too. You should have a working NTP server nearby that is owned by you. Also, since settimeofday() is called so often, high-accurate time operations like timer, etc., may not run correctly.

vsntp uses sleep() as the synchronization scheduler. Reports show that on some systems sleep() may not function normally. If you find vsntp stops synchronization after running for some time, that the sleep() is not functioning normally on your system, you may want to switch to the alarm() scheduler with the -a switch.

If you ever encounter any problem, you may check your syslog. vsntp logs detailed debugging information to syslog in log level LOG_DEBUG with facility LOG_DAEMON. You may turn it on in your /etc/syslog.conf with the following line:

daemon.debug  /var/log/debug

and check the /var/log/debug file for the debugging message. Remember to remove this afterwards, for the amount of the debugging messages may be huge and may use up your harddisk in a very short time. To the least it may slow down your system for frequent harddisk I/O.

vsntp was originally written for GNU/Linux. It uses POSIX compatible system calls. It should work on any POSIX compatible system. But I have yet only tested it on Cygwin. Cygwin is known to work. I don’t have others to test and run on. Please let me know (and submit the patch if needed) if you can port it to other systems.

Please tell me if you have successfully running vsntp on other virtual machines, like VMWare.

Generally, please tell me if you are using vsntp. I would like to know that I am really doing some good for the world, *^_^* but not having fun myself. :p

This is my first daemon, my first socket program and my first public-released C program. Any comment or suggestion is welcome. ^_*'


vsntp’s official websites is at…

You can always download the newest version of vsntp from…

imacat’s PGP public key is at…

Compilation and Installation

vsntp uses standard GNU autoconf procedure to compile and install:

  1. Download, unzip and untar the vsntp package:
    % tar xzf vsntp-x.x.x.tar.gz
  2. Go into its directory:
    % cd vsntp-x.x.x
  3. Configure with ./configure:
    % ./configure
  4. Compile with make:
    % make
    The resulted executable will be named vsntp.
  5. You need to be root in order to install vsntp:
    % su
  6. You can simply copy vsntp to the appropriate directory:
    # cp vsntp /usr/local/sbin
    Or, you can run automatic install:
    # make install
    You can reduce the size of the installed executable by stripping off debug symbols inside:
    # make install-strip
    By default vsntp will be installed in /usr/local/sbin.

Running and Stopping

You need to be root to run vsntp. vsntp uses settimeofday() to set the system time. settimeofday() requires root privilege.

To start vsntp, just specify your NTP server:

# vsntp

vsntp writes its PID in /var/run/ To stop vsntp, kill it by its PID:

# kill `cat /var/run/`

The PID file location can be changed with the -p switch.


vsntp [-i n] [-p file] [-s|-a] server
vsntp [-h|-v]
The NTP server to synchronize with.
-i,--interval n
Set the synchronization interval to n seconds. Default is 900 seconds (15 minutes).
-p,--pidfile file
The PID file location. Default to /var/run/
-s, --sleep
Use sleep() to schedule synchronization. This is currently the default.
-a, --alarm
Use alarm() to schedule synchronization.
-h, --help
Display the help message and exit.
-v, --version
Output version information and exit.


vsntp is hosted on SourceForge and Tavern IMACAT’s. For the latest infomation, see:

There is a vsntp mailing list hosted at SourceForge. Please submit your questions, suggestions or bug reports there. It is a Mailman mailing list. For more information, see the vsntp mailing list page. Alternatively, you can send a mail to the e-mail command mailbox with the subject help for a list of available e-mail commands.





Copyright © 2003-2006 imacat. All rights reserved.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.