October, 8th 2004
Copyright (c) 2002-2005 NMM work group, Computer Graphics Lab, Saarland University, Germany, http://www.networkmultimedia.org Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license can be found in the file COPYING.FDL. |
NMM can be used for locally running multimedia applications and for networked multimedia applications. For running networked multimedia applications, properly synchronized clocks of all participating systems are often required, e.g. if you want to achieve lip-synchronous audio and video rendering on different distributed systems. We are currently using NTP, the network time protocol, for establishing a global time within the network. This document describes how to set up NTP for NMM. We only discuss a simple setup, for further information, please see the official NTP documentation.
When synchronizing the clocks of two systems, one system acts as the 'master' (or server) the other as 'slave' (or client). The slave is synchronized to the master. First, you need to install the NTP packages provided for your GNU/Linux distribution. Sometimes, there is an additional package for the NTP master/server. For the master, the file /etc/ntp.conf needs configured like this:
logfile /var/log/xntpd
driftfile /var/lib/ntp/ntp.drift
statsdir /var/log/ntpstats/
statistics loopstats peerstats clockstats
filegen loopstats file loopstats type day enable
filegen peerstats file peerstats type day enable
filegen clockstats file clockstats type day enable
server 127.127.1.1
fudge 127.127.1.1
restrict default ignore
restrict 127.0.0.1
restrict 134.96.0.0 mask 255.255.0.0 nomodify notrap
|
Then, the NTP daemon, namely ntpd, needs to be restarted:
/etc/init.d/ntp restart
|
For the slave, the /etc/ntp.conf looks like this:
logfile /var/log/xntpd
driftfile /var/lib/ntp/ntp.drift
statsdir /var/log/ntpstats/
statistics loopstats peerstats clockstats
filegen loopstats file loopstats type day enable
filegen peerstats file peerstats type day enable
filegen clockstats file clockstats type day enable
server XXX.XXX.XXX.XXX prefer
server 127.127.1.1
fudge 127.127.1.1 stratum 8
|
Instead of XXX.XXX.XXX.XXX, use the IP of the master. Restart the ntpd for the slave. Then, you have to wait until the clocks of both hosts are synchronized. This can take some time. You can check this by using 'ntptrace' (or other tools) on the slave. The offset printed out is given in seconds and should be below 0.0010 seconds, i.e. less than 10 milliseconds. Offsets of 1 millisecond or less can be achieved. If not, please read further documentation on NTP or check the log files generated by NTP. For example, you can use 'gnuplot' to draw some statistics (you need to wait some hours before these statistics show you some meaningful values!):
> gnuplot
gnuplot> plot "/var/log/ntpstats/loopstats" using 2:3 with linespoints
gnuplot> q
|
For speeding up the initial synchronization of clocks, you can use 'ntpdate':
/etc/init.d/ntp stop
ntpdate
ntpdate
ntpdate
/etc/init.d/ntp start
|
Call 'ntpdate' at least once or twice until the shown offset it sufficiently small.