Hochschule Augsburg
NTP Service - Realization
tickadj Calculation
#!/usr/bin/perl
#
# drift of 104.8576 -> +1 tick.
#
# 970306 HMS Deal with nanoseconds. Fix sign of adjustments.
# 980503 BE Call tickadj for base value.
$df="/etc/ntp.drift";
$base=`/usr/local/bin/tickadj`;
chomp $base;
$base =~ s/\D*//; # might be Linux-specific (BE)
$cvt = 2 ** 20 / $base;
$v1=0.;
$v2="";
if (open(DF, $df))
{
if ($_=)
{
($v1, $v2) = split;
}
while ($v1 < 0)
{
$v1 += $cvt;
$base--;
}
while ($v1 > $cvt)
{
$v1 -= $cvt;
$base++;
}
}
printf("%.3f (drift); ", $v1);
printf("%d usec; ", $base);
printf("%d nsec\n", ($base + ($v1/$cvt)) * 1000);
1998-05-19