Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Discussion: ntpd on a node #318

Closed
aanon4 opened this issue Mar 24, 2022 · 19 comments
Closed

Discussion: ntpd on a node #318

aanon4 opened this issue Mar 24, 2022 · 19 comments
Assignees
Labels
enhancement New feature or request

Comments

@aanon4
Copy link
Contributor

aanon4 commented Mar 24, 2022

(re: #221)

Rather than opening a PR with a possible solution, I thought I'd highlight some options for discussion first as there are several:

  1. By default, no ntp on a node. Given that running ntp at all takes resources, perhaps we just shouldn't run it at all on nodes by default. After all, day-to-day, most nodes don't need the time set particularly.

  2. Run ntp on startup. This is what we currently have. Ntpd runs on boot to set the initial time on the node and then assume the node will keep good-enough time afterwards.

  3. Run ntp periodically. A slightly improved version of (2) given that, actually, nodes probably don't keep great time over long periods. Perhaps reset the time every day.

  4. Run ntp. Here we run ntpd all the time, so a node will keep accurate time over long periods.

Orthogonal to the above is how a node chooses the time server to sync with. Currently we have a default set one on the main page which may, or may not, be reachable. It can be changed, although I have no idea how many people do that. An alternative to that is for a node to search out NTP server on the local mesh and use those for their time sync. Auto-configuration is nice, but it's not something we do anywhere else on the node at the moment. Also, it's a bit of a heuristic process as there's no well defined way to advertise ntp servers on the mesh (for now, it's basically looking for "ntp" in service names and then seeing if they're really ntp servers).

Thoughts?

@aanon4 aanon4 added the enhancement New feature or request label Mar 24, 2022
@K6AH
Copy link

K6AH commented Mar 24, 2022

I think I'm landing on #3 using the default NTP server in the config, and on failure search via auto config as described. I think so long as we have a report such as the SNR Chart, we should be accurate on the time axis. Perhaps randomize when it gets the time from the mesh so they all don't do so at the same time. The trade off of course is memory, and you don't say how much space this will consume, but I can't image it's much.

@aanon4
Copy link
Contributor Author

aanon4 commented Mar 24, 2022

@K6AH A running ntpd server uses about 1M (at least that's the footprint I see on my AR750)

@ab7pa
Copy link
Contributor

ab7pa commented Mar 24, 2022

The legacy ntpclient uses about the same amount of memory as ntpd (932kb).

@wu2s
Copy link
Contributor

wu2s commented Mar 24, 2022

I prefer #3. Just run periodically - my preference is about 4 times daily. That should be more than enough to keep reasonably in sync with correct time.

@K6AH
Copy link

K6AH commented Mar 24, 2022

Wow, that seams like a lot memory. So, between adding the tunnel and ntp features we've consumed all we saved by removing perl? Is there a smaller ntp client we could use?

@aanon4
Copy link
Contributor Author

aanon4 commented Mar 24, 2022

So for clarification, there's no change in the use of flash as ntpd (busybox) is already loaded onto the node. As for RAM, ntpclient and ntp use similar memory, and ntpclient is already running (and tends to hang around for some reason) using up RAM all the time. Option 3 would at least only use that RAM every few hours for a few moments; so all in all it would be a resource win.

@K6AH
Copy link

K6AH commented Mar 24, 2022

Then it's a no-brainer for me.... #3.

@ae6xe
Copy link
Contributor

ae6xe commented Mar 24, 2022

If the only dependency on a node knowing the time is meshchat, then we could consider making it an optional package like meshchat? Although I suspect a lot of admins like the node's time to be current regardless.

@ae6xe
Copy link
Contributor

ae6xe commented Mar 24, 2022

Busybox probably has an option to compile without ntp, to use a stand alone package.

@aanon4
Copy link
Contributor Author

aanon4 commented Mar 24, 2022

"I suspect a lot of admins like the node's time to be current" - this is really the question for me. Personally the moment I'm trying to debug something on a node is not the moment I like to discovery I can't trust the time on any file or in the log files. But I don't know if this is the usual case for most users.

@ab7pa
Copy link
Contributor

ab7pa commented Mar 24, 2022

My vote... try to keep the node clock reasonably accurate, if for nothing else then for ease of reading log files and logd. If there is a reachable time server, then at least update the clock upon reboot and once a day afterward if possible. If there is not a reachable time server then don't start ntpd, but maybe once a day try to check if a time server has become available and start it then.

@dman776
Copy link
Contributor

dman776 commented Mar 24, 2022 via email

@dman776
Copy link
Contributor

dman776 commented Mar 24, 2022 via email

@aanon4
Copy link
Contributor Author

aanon4 commented Mar 24, 2022

So I think this is the plan:
On boot and every 24 hours, sync the clock with an available time server, the one specific in the config or one found on the network. Don't run NTP otherwise.

@wck86
Copy link

wck86 commented Apr 2, 2022

At recent emergency preparedness fair in OC a small mesh was set up, with no access to the internet. Cameras were connected and the timestamps were off by about a day and a half. For smaller mesh networks, not having Internet access risks potentially substantial timing issues. After that experience, I put a stratum 1 NTP server onto a Raspberry Pi Zero W and it looks like it works pretty well.

The Pi Zero W is a bad platform for this for a few reasons- including, imo, only having 2ghz WiFi and no Ethernet port, but it works well enough in my kit for now.

Having something like this for smaller mesh networks could be pretty important. I understand the higher end Ubiquiti Rockets have GPS- could an optional package be made to utilize that for timing?

IMG_20220401_190223
image (2)

@dman776 dman776 closed this as completed Apr 27, 2022
@k6ccc
Copy link

k6ccc commented May 12, 2022

FYI, I put this NTP server on my network at my house a couple months ago and have all of my nodes using it for time sync. Working very well and not all that much money. https://centerclick.com/ntp/
I have the NTP200 model. It is reachable on the SoCal network at 10.9.60.82

@wck86
Copy link

wck86 commented Oct 11, 2022 via email

@wu2s
Copy link
Contributor

wu2s commented Oct 11, 2022 via email

@k6ccc
Copy link

k6ccc commented Oct 11, 2022

Good luck at getting a Pi zero for $35. Double that (or more). Then add the GPS module, Then get it all talking. Nice if what you want is a project. I wanted a box that I could power up and plug into my network and it would just work. I do like my CenterClick NTP...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

8 participants