freebsd-nq/contrib/ntp/scripts/calc_tickadj
1999-12-09 13:01:21 +00:00

39 lines
693 B
Perl

#! /usr/local/bin/perl
#
# drift of 104.8576 -> +1 tick. Base of 10000 ticks.
#
# 970306 HMS Deal with nanoseconds. Fix sign of adjustments.
$df="/etc/ntp.drift";
# Assumes a 100Hz box with "tick" of 10000
# Someday, we might call "tickadj" for better values...
$base=10000; # tick: 1,000,000 / HZ
$cvt=104.8576; # 2 ** 20 / $base
$v1=0.;
$v2="";
if (open(DF, $df))
{
if ($_=<DF>)
{
($v1, $v2) = split;
}
while ($v1 < 0)
{
$v1 += $cvt;
$base--;
}
while ($v1 > $cvt)
{
$v1 -= $cvt;
$base++;
}
}
printf("%.3f (drift)\n", $v1);
printf("%d usec; %d nsec\n", $base, ($base + ($v1/$cvt)) * 1000);