The video posted got me thinking on time again, though I’ve often pondered NTP and it’s reach in the modern world.

When I was a kid, we had a time and temperature phone number to call, on a fat, heavy, black dial-phone you could beat a man to death with (I made that gif for you ungrateful fuckers. Steal it.) That government source was our only way to synchronise our clocks and watches. Not that our timepieces were horribly inaccurate! But if you needed to be on the same page as your friends or homes or work clocks, call the number, get your shit right.

Now we take it for granted that all our clocks match within millionths of a second, across the entire planet. Hell, I’m frustrated when my Casio watch collection needs a couple of tweaks because they don’t have, or I didn’t set, the Daylight Savings Time option.

If you want to dig into NTP more, the wiki is a starting point, though far too technical for the uninitiated. Anyone have a more approachable source?

Discussed running my own NTP server with a friend. It’s way more complex than one would likely think. If you’ve never worked in software, bring up computer time to an engineer, get an earful, get yelled at. NTP is truly the unsung hero of the modern world.

  • SirEDCaLot@lemmy.today
    link
    fedilink
    arrow-up
    1
    ·
    9 hours ago

    Well first the question- do you need accuracy or precision? The two are not the same. See this image.

    Take for example your computer. In it are many different electronic components operating at GHz speed. When communicating, they have to stay in sync, because for example if one device is sending data on the bus at 100.001 MHz and the other device is trying to receive at 100.005 MHz, they will lose their connection.
    In this aspect you need precision, not accuracy- the computer doesn’t care what time it is, it needs all the internal devices to measure passing time at the same rate. They need to be precise, but accuracy doesn’t matter (the computer will work if the clock is set wrong).

    Or take for example SSL/TLS (how security works on the Internet). When you try to initiate a secure connection, the data you exchange with the server is time-stamped, to ensure the data isn’t being recaptured and replayed from an old session. Thus the server and the client have to have about the same time- it works within several minutes to account for badly set clocks. That needs to be accurate, not precise.

    One of the easiest ways to get time data that’s both accurate and precise is actually from GPS. GPS satellites each have an onboard atomic clock, and they continually broadcast the current time along with their position in space. A GPS receiver locks onto signals from several of those satellites, and by looking at the difference in received time from various satellites measured against each other, it can compute the differences in distance to each satellite. IE- we’ll start with satellite A, it says it’s at position X, and we’ve got the time signal from it. Satellite B says it’s at position Y, and its time signal is 10ms behind A’s, so it’s about 3000km farther from us than A. Satellite C says it’s at position Z and its time signal is 5ms ahead of A’s, so it’s about 1500km closer to us than A. Stack a few satellites like that and it’s easy to calculate the only position on earth where all the math would check out, so you have your own position. The key then is knowing your own position, you also know the distance to each satellite, so you can correct the time signal for its travel time through the air and end up with a time source that’s both very precise and very accurate- a good time-source-focused GPS receiver can be accurate to within 30-50 nanoseconds and similar precision.

    This can be useful for example in cellular networks. Older style TDMA networks divided each channel up into timeslots, where each phone would be assigned a time slot in which to transmit. Those timeslots had to be precisely coordinated, so the tower would have a GPS receiver (for accuracy) and would then broadcast the current time to all connected phones (for precision). Newer style CDMA technologies do the same type of thing.

    If you need accuracy/precision beyond what a GPS time source can give you, you get into very specialized hardware like running your own atomic clocks. That takes some doing, because once you unbox your shiny new atomic clock you then have to set it from something, which is usually the average of GPS signals received over several hours.

    There’s also specialty hardware like high precision oscillators, IE a device that produces a VERY steady 10 MHz or PPS (1 pulse per second) output with high precision but has no idea nor care what time it actually is. That’s designed to keep an existing clock that’s already set accurate.