Network Time Protocol (NTP)

nayr

IPCT Contributor
Joined
Jul 16, 2014
Messages
9,329
Reaction score
5,325
Location
Denver, CO
Embedded IP Cameras dont typically have a hardware Real Time Clock to help it track time, instead it uses processing cycles to calculate time and this can vary depending on voltages, temperatures, etc and quickly get out of sync with reality.. even if it does have a hardware RTC it will need a battery backup to keep time after a power loss and even a highly accurate one will drift off time a noticeable amount after a year.

To Combat this IPCameras sync time via the Network Time Protocol (NTP)

If you have one or two cameras, or your NVR is overlaying timestamps your best bet is to use a NTP Pool that is always available and nearby.. I would avoid using Microsoft or Apple's servers, many networks hijack there addresses and redirect them to an internal NTP server.. I do it so all machines sync time off my local NTP service without reconfiguring all the workstations.. you never know where you'll end up.


  • [*=1]north-america.pool.ntp.org
    [*=1]europe.pool.ntp.org
    [*=1]asia.pool.ntp.org
    [*=1]africa.pool.ntp.org
    [*=1]oceania.pool.ntp.org
    [*=1]south-america.pool.ntp.org
    [*=1]more info on NTP pools: http://www.pool.ntp.org/

If you have more than a few cameras you should choose a singular server for all of them, because the pool could give each camera a different server and this could result in some being slightly off from others... here is a nice list of individual US Based servers, I am lucky with alot of these being in Colorado I get a ping less than 10ms on many of these..


And the best option IMHO would be run your own NTP Server on your NVR or Router, or any machine on your network that is always on and reliable.. If your running DD/Open-WRT it should be easy to do on your router, google it.
The benefit of this is you can sync your cameras as quickly as they can (its abusive to do that to someone else's NTP server, if its not your server once every 20mins is more than enough) and the local network latency and throughput is much better than the internet's, if your internet has an outage you know everything is keeping correct time based off your NTPD running off a PC that has a more accurate RTC, with a battery to keep time when there is no power.. Of course your NTP Server needs to sync time with an upstream server or a radio signal every once and a while.


If your running NTPd by default your NTP server will deny requests from other machines on your local network, we want to change that and it requires adding a line such as this to the configuration: (if your running a software firewall you may need to open UDP Port 123)
Code:
[COLOR=#000000][FONT=monospace]restrict 192.168.0.0 mask 255.255.0.0 nomodify notrap[/FONT][/COLOR]
It will also use a default set of pool servers, feel free to change that but you want to keep several in there for it to compare latency with.

If your running a stand-alone IPCam network that is not hooked to the internet I would suggest running a NTPd and hooking up a cheap USB GPS Dongle in a nearby window.. this will give you an atomic time sync without requiring internet access.
A RasberyPI with a RTC Add-on and a GPS Receiver would make a pretty awesome lil personal NTP Server and could be considered more accurate than syncing from any internet server.: http://afterthoughtsoftware.com/products/rasclock

If your camera footage is ever required for a criminal investigation having all your timestamps as accurate as possible will help alot, if your times are unreliable then the timestamps are basically worthless and not trustworthy.

Dont forget to setup your DST Settings!
 
Last edited by a moderator:

bp2008

Staff member
Joined
Mar 10, 2014
Messages
12,673
Reaction score
14,017
Location
USA
I run Windows on almost all my computers, so getting them to keep accurate time has always been a struggle without the assistance of 3rd party software. Seriously, even with Windows 7 and 8, I'm always finding that the clock has drifted 20 seconds or more. Often a minute or longer. This is because the built-in NTP "Internet Time" feature is really terrible in Windows. It might as well not exist.

So I've been using NetTime from http://www.timesynctool.com/ on a few of my machines ever since Stickman at the cam-it.org forum posted about it. This program keeps a list of time servers (you can modify the list if desired) for the inevitable event when one or more of the servers fails to respond. Then it makes its best effort to synchronize the time at regular intervals (12 hours by default). The effect is that the time stays accurate. Now, by itself this would be unremarkable; there have been easy programs to do this since before Windows XP. What makes this app special is that it can run an NTP server for other things to sync from. All things considered I really prefer it to a Linux app, as you never have to muck about with configuration files or command lines. It is all GUI-driven.

So I have my cameras all point at this server, ever since I started using Direct to Disk recording in Blue Iris. The timestamps produced by the cameras all tend to stay within 1 second of each other now. Windows machines pointed at this server still manage to drift the same as they always have. Again, Windows' built-in NTP is really terrible.
 

nayr

IPCT Contributor
Joined
Jul 16, 2014
Messages
9,329
Reaction score
5,325
Location
Denver, CO
ah thank you @bp2008, I was trying to find something for you windows guys and settled on just the ntpd port.. I agree, you guys need GUI's.. most people cannot handle command lines and text configurations :D

I will change the guide slightly to urge windows users to that software instead..
 
Last edited by a moderator:

sprucecams

Getting the hang of it
Joined
Aug 4, 2014
Messages
142
Reaction score
11
Location
Chicagoland
Question to see if I understand how NetTime works. I download and install it on a Win7 PC. I start it and configure as needed. It's server is now running and I can point my IP cameras (Hikvision & Foscam) to that PC for the NTP source. Correct? (Can't be, that would too easy. :cool: )
 

bp2008

Staff member
Joined
Mar 10, 2014
Messages
12,673
Reaction score
14,017
Location
USA
Yeah, more or less. You will probably have to unblock port 123 for UDP in your firewall (Windows firewall and/or 3rd party software firewall).
 

sprucecams

Getting the hang of it
Joined
Aug 4, 2014
Messages
142
Reaction score
11
Location
Chicagoland
Many thanks, bp2008, and also many thanks for BI Tools. I am loving the weather data overlay! If you can consider a suggestion, maybe a NTP server function?
 

bp2008

Staff member
Joined
Mar 10, 2014
Messages
12,673
Reaction score
14,017
Location
USA
Well since Mike is the one who made BI Tools, that'd be his decision. But I wouldn't count on it. There is already a good tool for an NTP server.
 

iseeker

Getting the hang of it
Joined
Nov 16, 2018
Messages
229
Reaction score
90
Location
TEXAS
I've enabled the NTP Service in my synology rt2600ac router, and my router time itself is synced to pool.ntp.org. Then in IPCamera I checked NTP on System > General>Date&Time, put the server name as my router (192.168.1.1), port 123, interval 10 min. Did I miss anything?
 

bp2008

Staff member
Joined
Mar 10, 2014
Messages
12,673
Reaction score
14,017
Location
USA
I've enabled the NTP Service in my synology rt2600ac router, and my router time itself is synced to pool.ntp.org. Then in IPCamera I checked NTP on System > General>Date&Time, put the server name as my router (192.168.1.1), port 123, interval 10 min. Did I miss anything?
If you've got the time zone and daylight savings options all configured the way you want, then yeah, the IP, port, and interval are the only 3 NTP settings. Unless you count the checkbox for enabling or disabling NTP altogether. I guess then there are 4 settings.
 

pbc

Getting comfortable
Joined
Jul 11, 2014
Messages
1,024
Reaction score
156
I run Windows on almost all my computers, so getting them to keep accurate time has always been a struggle without the assistance of 3rd party software. Seriously, even with Windows 7 and 8, I'm always finding that the clock has drifted 20 seconds or more. Often a minute or longer. This is because the built-in NTP "Internet Time" feature is really terrible in Windows. It might as well not exist.

So I've been using NetTime from NetTime - Network Time Synchronization Tool on a few of my machines ever since Stickman at the cam-it.org forum posted about it. This program keeps a list of time servers (you can modify the list if desired) for the inevitable event when one or more of the servers fails to respond. Then it makes its best effort to synchronize the time at regular intervals (12 hours by default). The effect is that the time stays accurate. Now, by itself this would be unremarkable; there have been easy programs to do this since before Windows XP. What makes this app special is that it can run an NTP server for other things to sync from. All things considered I really prefer it to a Linux app, as you never have to muck about with configuration files or command lines. It is all GUI-driven.

So I have my cameras all point at this server, ever since I started using Direct to Disk recording in Blue Iris. The timestamps produced by the cameras all tend to stay within 1 second of each other now. Windows machines pointed at this server still manage to drift the same as they always have. Again, Windows' built-in NTP is really terrible.
Been having some issues with my cameras losing time, so came across this. Just want to make sure I have the steps right:

  • Run the nettimesetup.exe file
  • Go into Windows Defender Firewall, and set up a new inbound rule allowing port 123 via UDP to be open

Then do I insert nettime.pool.ntp.org and port 123 as the NTP server in my cameras? I keep getting a "Failed" when I test it. Is it because i've opened up the port as UDP when it should be SNTP?

1593608843959.png
 

pbc

Getting comfortable
Joined
Jul 11, 2014
Messages
1,024
Reaction score
156
So in the above screen shot, how does one setup a local time server?
 

bp2008

Staff member
Joined
Mar 10, 2014
Messages
12,673
Reaction score
14,017
Location
USA
Check the box "Allow other computers to sync to this computer". Then in the camera, for the time server address put in the LAN IP address of the computer you installed NetTime on. (and you also need the Windows Firewall rule you mentioned earlier to allow inbound UDP on port 123)
 

pbc

Getting comfortable
Joined
Jul 11, 2014
Messages
1,024
Reaction score
156
Ah, so this sort of thing (with the IP address being the local IP of my BI server where I installed the time service). Weird that the time was still one hour behind and I still had to click "sync PC" to get it to the right time.

1593616494181.png
 

alastairstevenson

Staff member
Joined
Oct 28, 2014
Messages
15,952
Reaction score
6,786
Location
Scotland
Weird that the time was still one hour behind and I still had to click "sync PC" to get it to the right time.
It looks like you do not have DST (Daylight Savings Time) enabled.
With the needed dates set for your location.
 

pbc

Getting comfortable
Joined
Jul 11, 2014
Messages
1,024
Reaction score
156
Ah, I thought having the time server matching the PC would adjust for that so I don't have to change the DST days each year?
 
Top