Skip to content

Latest commit

 

History

History
389 lines (272 loc) · 9.16 KB

05-time_and_clocks.md

File metadata and controls

389 lines (272 loc) · 9.16 KB
SPDX-FileCopyrightText SPDX-License-Identifier title author footer description keywords color class style
© 2024 Menacit AB <[email protected]>
CC-BY-SA-4.0
Logging course: Time and clocks
Joel Rangsmo <[email protected]>
© Course authors (CC BY-SA 4.0)
Introduction to time and clock challenges in logging course
logging
siem
course
#ffffff
invert
section.center { text-align: center; } table strong { color: #d63030; } table em { color: #2ce172; }

Time and clocks

A not so scary introduction

bg right:30%


IT systems rely on time and clocks for a wide variety of important tasks.

Authentication protocols, banking applications, industrial control systems...

Allows us to correlate events/activity in different computers and the real world.

bg right:30%


What kind of time?

Wall time / Real time.

bg right:30%


Keeping it simple

Most computers count number of seconds elapsed since the first of January 1970 (UTC).

Commonly called "UNIX time"/"Epoch".

Converted into local time/calendar date by OS/applications.

Await the horrors of 2038!

bg right:30%


What is a second anyway?

Something something the sun and moon.

In the late 1800s, physicists tried to properly define a second.

Atomic clocks measure the resonant frequency of atoms very precisely.

Since 1968, BIPM defines it as ~9 billion frequency transitions of Cesium 133 at -273 Celsius.

bg right:30%


Sounds quite straightforward, doesn't it?

You're not getting away that easily.

Let's talk about time zones and dates...

bg right:30%


Time zones

You wanna eat lunch around 12, right?

Not straight lines, quite a lot of politics involved.

Important to keep track of if we're operating internationally.

bg right:30%


Daylight savings

Everyone Many of us love a bit of sun, but hates being confused.

Not everyone changes at the same time.

Many plan to get rid of it, few have succeeded.

bg right:30%


Let's make it more exciting!

Some time zones differ by 30 or 45 minutes.

Some places don't even want 24 hour days.

bg right:30%


Why not throw in leap years and leap seconds?

bg right:30%


These are not static things and can change (back and forth) over time.

Not just the Gregorian calendar.

Must be remembered when performing time calculations.

bg right:30%


Is all hope lost?

Are we doomed to live in a confusing time warp?

Could any somewhat sane person wrap their head around this?

bg right:30%


Let's meet Arthur David Olson and Paul Eggert.

bg right:30%


tz database

Dataset and reference code for working with international calendar time.

Continuously updated to match an ever-changing world.

Maintained by ICANN since 2011.

bg right:30%


Time/Date representation

Many different formats exist for dates and timestamps.

Which part is the year, month and day? What time zone are we talking about?

Some are more/less readable by humans and machines alike.

bg right:30%


Okay okay - Time is messy but important, we get it!

bg right:30%


The two challenges

  1. All clocks show the same time
  2. All clocks show the right time

bg right:30%


In theory, if we solve the second we should automatically solve the first.

In practice, this is tricky - just trust me for now.

Let's start with the first problem...

bg right:30%


NTP

Network Time Protocol.

Standard for clock synchronization. Actively developed since 1980s.

Replicates time over UDP port 123. Uses bag of tricks to calculate and adjust for network delay.

Mitigates clock drift/skew.

bg right:30%


Example clients/servers

  • ntpd
  • NTPsec
  • OpenNTPD
  • chrony
  • systemd-timesyncd

Some only implement SNTP.

bg right:30%


Weaknesses

Plain-text protocol* vulnerable to Man-In-The-Middle attacks.

Precision typically limited to milliseconds.

bg right:30%


NTS

Network Time Security.

Uses TLS and PKI to exchange key for symmetric authenticated encryption.

Extension to NTP, like HTTPS for HTTP.

Limited software support and a bit more resource intensive than plain NTP.

bg right:30%


PTP

Precision Time Protocol.

Version 2 can synchronize clocks with ~nanosecond precision.

Enabled by special handling in Network Interface Cards and Operating Systems.

bg right:30%


Our clocks are in sync!

Let's focus on the second problem...

bg right:30%


What's the correct time?

In the basement of BIPM, atomic clocks tick to define...

Universal Time Coordinated.

bg right:30%


How does my time server know what the correct time is?

Ask another one perhaps?

bg right:30%


Getting reference time

  • Dedicated signaling cable
  • Radio broadcast
  • Satellite navigation system (GNSS)
  • Locally connected atomic clock

bg right:30%


Clocks break, radio communication can be spoofed/jammed and NTP peers may lie.

What's the solution?

bg right:30%


Use multiple sources and calculate an average!

bg right:30%


Kool - let's grab some time!

bg right:30%


Using pool.ntp.org

Used as default by many operating systems and IoT appliances.

Run by volunteers, anyone* can join and contribute!

Region specific aliases, like "se.pool.ntp.org", can be used in attempts to find servers nearby.

bg right:30%


Cloudflare and NIST provide good alternatives/complements.

bg right:30%


Using ntp.se

Also known as the Swedish Distributed Time Service.

Funded by PTS and operated by Netnod.

Provides highly accurate time via Anycast from several redundant sites spread over Sweden.

Relies on an open-source FPGA-based for NTP and NTS. Offers PTP.

bg right:30%


Wanna geek out on time?

Join the annual Netnod Tech Meeting!

bg right:30%