{"id":57,"date":"2015-04-27T18:30:42","date_gmt":"2015-04-27T16:30:42","guid":{"rendered":"https:\/\/blog.unetresgrossebite.com\/?p=57"},"modified":"2015-05-31T01:23:45","modified_gmt":"2015-05-30T23:23:45","slug":"dcf77","status":"publish","type":"post","link":"https:\/\/blog.unetresgrossebite.com\/?p=57","title":{"rendered":"DCF77"},"content":{"rendered":"<p>This is no WMD, but a German radio station transmitting current date, for time synchronization purposes.<\/p>\n<p>I first stumbled upon DCF77 while working for <em>CamTrace<\/em>.<br \/>\nSome of our customers insisted on not connecting their video-surveillance network to the Internet.<\/p>\n<p>The first solution coming to mind is to set up some NTP server. Which would work, most of the time.<br \/>\nAlthough, you should know NTP uses a <em>stratum<\/em>, keeping track of how high you are in the food chain. Having a lower value is critical, to allow other devices to synchronize their clock against yours.<br \/>\nOur consumers may restart their server, not fully understanding those concepts. But a client configuring his camera right after booting his server is not wrong. Thus, a good way ensuring your stratum is low enough so that devices may always accept what your NTP server is answering, is to get your time from a reliable source. Such as some <a href=\"http:\/\/en.wikipedia.org\/wiki\/DCF77\">german-kalit\u00e4t radio clock<\/a>. Note this solution is only viable in the 2.000kms around Frankfurt though.<\/p>\n<p>I&#8217;m mostly familiar with Axis networks cameras, but assume the problem presents itself on anything not embedding some RTC (like Raspberry Pi on default configuration, module being sold separately) : setting the date installing the device is a mistake, knowing it would fluctuate relatively quickly (worst cases, we&#8217;re talking about a few minutes per day, quickly adding up to hours, &#8230;).<\/p>\n<p>Thus, I&#8217;ve combined some Raspberry Pi to a\u00a0<a href=\"http:\/\/wiki.gude.info\/FAQ_mouseCLOCK_USB_II\">MouseCLOCK USB<\/a>. NTP allows interfacing with such clock.\u00a0A minimalistic <em>\/etc\/ntpd.conf<\/em> would look like this:<\/p>\n<p><code>server 127.127.8.0 mode 19<br \/>\nfudge 127.127.8.0 stratum 0<br \/>\nfudge 127.127.8.0 time1 0.042<\/code><\/p>\n<p>Using <em>127.127.8.0<\/em>\u00a0as source tells ntp to look for <em>\/dev\/refclock-0<\/em>\u00a0device. Assuming FreeBSD, your clock device would show up as <em>\/dev\/cuaU$x<\/em>. Linux, <em>\/dev\/ttyUSB$x<\/em>. You may add to ntp startup the following lines:<\/p>\n<p><code>if \/usr\/local\/sbin\/lsusb | grep mouseCLOCK &gt;\/dev\/null; then<br \/>\nif test -c \/dev\/cuaU0; then<br \/>\ntest -h \/dev\/refclock-0 || ln -s \/dev\/cuaU0 \/dev\/refclock-0<br \/>\nfi<br \/>\nfi<\/code><\/p>\n<p>A cleaner way to create this link could be using <em>devfs<\/em>. In FreeBSD, add to <em>\/etc\/devfs.conf<\/em> the line <em>cuau0 refclock-0<\/em>.<br \/>\nOn Debian, use <em>udevd<\/em> creating a file in <em>\/dev\/udev\/rules.d<\/em>\u00a0matching your device, like <em>KERNEL==&#8221;ttyUSB*&#8221;, ATTRS{idProduct}==&#8221;e88a&#8221;, SYMLINK+=&#8221;refclock-%m&#8221;<\/em>.<\/p>\n<p>After a while, querying ntp should confirm proper synchronization:<\/p>\n<p><code>root@cronos:\/usr\/ports # ntpq -crv -pn<br \/>\nassID=0 status=0264 leap_none, sync_lf_clock, 6 events, event_peer\/strat_chg,<br \/>\nversion=\"ntpd 4.2.4p5-a (1)\", processor=\"arm\",<br \/>\nsystem=\"FreeBSD\/10.1-STABLE\", leap=00, stratum=1, precision=-19,<br \/>\nrootdelay=0.000, rootdispersion=1026.460, peer=25445, refid=DCFa,<br \/>\nreftime=d8e8e24f.1ec18939 Mon, Apr 27 2015 18:29:03.120, poll=6,<br \/>\nclock=d8e8e25d.bb054ad7 Mon, Apr 27 2015 18:29:17.730, state=4,<br \/>\noffset=-77.794, frequency=472.839, jitter=10.929, noise=27.504,<br \/>\nstability=0.197, tai=0<br \/>\nremote refid st t when poll reach delay offset jitter<br \/>\n==============================================================================<br \/>\n*127.127.8.0 .DCFa. 0 l 14 64 1 0.000 -77.794 10.929<br \/>\nroot@cronos:\/usr\/ports #<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is no WMD, but a German radio station transmitting current date, for time synchronization purposes. I first stumbled upon DCF77 while working for CamTrace. Some of our customers insisted on not connecting their video-surveillance network to the Internet. The first solution coming to mind is to set up some NTP server. Which would work, [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[8,2],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.unetresgrossebite.com\/index.php?rest_route=\/wp\/v2\/posts\/57"}],"collection":[{"href":"https:\/\/blog.unetresgrossebite.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.unetresgrossebite.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.unetresgrossebite.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.unetresgrossebite.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=57"}],"version-history":[{"count":6,"href":"https:\/\/blog.unetresgrossebite.com\/index.php?rest_route=\/wp\/v2\/posts\/57\/revisions"}],"predecessor-version":[{"id":108,"href":"https:\/\/blog.unetresgrossebite.com\/index.php?rest_route=\/wp\/v2\/posts\/57\/revisions\/108"}],"wp:attachment":[{"href":"https:\/\/blog.unetresgrossebite.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=57"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.unetresgrossebite.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=57"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.unetresgrossebite.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=57"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}