Quantcast
Channel: Personal Archives - Stephen Foskett, Pack Rat
Viewing all articles
Browse latest Browse all 130

GPS Time Rollover Failures Keep Happening (But They’re Almost Done)

$
0
0

On Sunday, April 7, every GPS device on the planet will “roll over” the date. This shouldn’t affect most devices, but it’s likely that quite a few will no longer show the correct date. We know this because it already happened back in 1999 and similar GPS date issues have been cropping up for the last few years. The good news is that all this trouble will soon be at an end, with all remaining GPS date issues a few decades off.

This is week “1111111111” in the GPS system. Tomorrow morning it will roll over to week “0000000000”. How well will various systems handle this change? Not well, judging by what we’ve seen so far!

Epochs, Weeks, and Seconds: How GPS Time Works

The GPS system consists of constellation of satellites orbiting in known positions, each with an ultra-precise atomic clock inside. Each constantly broadcasts the exact time, and a receiver on the ground compares the time code with the position of the satellite to triangulate location. The rest of this blog post has very little to do with any of this, however.

Because the time is a key component of the GPS system, most receivers synchronize their date and time display to the received signal. Most of us don’t use standalone GPS devices anymore, but clocks synchronized to GPS are integrated into just about everything these days from cars to Internet servers. This is the same reason the clock on your iPhone is so accurate: The mobile phone network receives GPS signals and sends the precise time and location in a very similar way.

So-called GPS time is counted very differently from how people tell the time. The GPS network uses a 10-bit counter adding up the number of weeks since a known date (the “epoch”) and has another 19-bit counter for the number of seconds-and-a-half since midnight at the start of Sunday.

That’s right, GPS tells “time” and “date” with Week Number and second-and-a-half increments into the week. Week Number makes more sense than you would think, proceeding regularly with no leap days or odd lengths. But why 1.5 seconds? I guess to save one bit. There is no concept of seconds, minutes, hours, days, months, or even years to GPS time. It’s all just Epoch, Week Number, and Time of Week. In 29 bits, GPS can encode the time with sufficient precision to locate you in almost two decades and that’s good enough.


Each counter “rolls over” differently. The Week Number will naturally reset to 0 after 1,023 increments, as all the bits are flipped. But the Time of Week counter is forced to reset after 403,199 increments, even though 19 bits gives some headroom past that. The reason is that a week is 604,800 seconds, or 403,199 seconds-and-a-half, long. So there you have it.

Humans Count Date and Time Strangely

If this sounds weird and unwieldy to you, congratulations you are human. But to a computer, this is a straightforward and useful way to count the time. Computers don’t care about the number of times the earth has revolved around the sun since an arbitrary point in human history. They also don’t care that their count doesn’t exactly line up with the precise moment a certain spot on earth faces the sun, one twenty-fourth the time the earth takes to reach that spot again, one sixtieth of that increment, or one sixtieth of that. But you might, so it has to translate for you.

This is where the trouble starts.

The first GPS epoch began the Sunday before the start of a new decade, and midnight on Sunday, January 6, 1980 was the first time the Week Number incremented. This was a usefully-old yet reasonably-recent date to pick for “everything” to begin.

A 10-bit binary counter will “roll over” after 1,023 increments (in our familiar decimal system), which gives the Week Number almost 20 years before we have to worry about the date. But the first Week Number rollover has already happened: On Sunday, August 22, 1999, the Week Number reset to 0 (or “0000000000” to be precise). And this will happen a second time tomorrow morning, April 7, 2019.

The Epoch is manually set in each GPS clock, and the clock needs to know the rough date to within 9 years, 10 months in order to display the correct year, month, and date. But the useful life of these systems means that a user must enter this information if the system loses power or the wrong date will be displayed. If you tell your GPS (or car dashboard or clock or whatever) that it’s more than 10 years off, the Epoch will be interpreted incorrectly and the date and time will be shifted by 19 years, 8 months, and some odd number of days, hours, minutes, and seconds.

This can be hilarious, weird, or it can cause problems. Is today April 6, 2019 or August 21, 1999? GPS doesn’t know. And whether that matters is entirely up to the application.

“Interesting” GPS Dates: Conversion, Rollover, and I-Don’t-Know-What

Even a properly-programmed GPS device can show a wildly-wrong date. But not all devices are programmed correctly.

A serious failure of GPS time actually happened 168 days ago. On October 21, 2018, the decimal representation of the GPS Week Number reached 1,000, exceeding three digits for the first time since most modern devices were created. Most systems use the binary number internally, so this isn’t an issue. But some programmers converted to decimal before doing their Epoch lookup. Such was the case for the car I bought a few months back, which I’ll discuss below.

There have been other “interesting” GPS time errors over the last few years. It’s hard to know exactly what mistakes the programmers made, but devices have rolled over or failed when the Week Number reached 800 (in December 2014), 860 (February 2016), 886 (August 2016), and 987 (July 2018).

How will your favorite GPS-based clock or device handle the rollover? It’s hard to say. The fact that so many have failed in such unusual ways gives cause for serious concern. I think we might be hearing about a lot of odd issues for the next few months.

Happily, none of this will occur again for a very long time after tomorrow morning. GPS is being modernized to use a 13-bit Week Number, which will certainly help as well.

A Real-World Example: Mercedes-Benz COMMAND NTG3

My car insists that it’s 2003, 5 years before it was even built!

I recently bought a 2008 Mercedes-Benz S-Class with just such a system. Around October 21, 2018, all models with Mercedes’ COMMAND NTG3 infotainment system decided it was actually June, 2003. And the incorrectly-converted GPS signal continues to reset the date accordingly at every opportunity. As of today, my car thinks it’s August 21, 2003.

Why 2003? It’s hard to say exactly. If the system simply “rolled off” the third decimal digit, it should be showing the date as February 5, 2000. This would be week 23 (instead of 1,023) of the current GPS Epoch. Instead, it seems to think it’s week 228. If I had to guess, I would say the Mercedes (née Daimler) Benz programmers picked another date as their Epoch and are basing the date off of that. The fact that the failure first occurred all over the world just as the Week Number passed 999 definitively shows this to be a GPS error, however.

There’s another issue happening here too, but it’s a little harder to see: August 21, 2003 was Thursday, not Saturday like today. This means that the car is using the wrong start of the week when calculating the time of day. And since GPS Time simply counts up from Sunday, this shows that something else is seriously wrong with the time software. It’s a miracle it’s showing anything close to the correct time.

What does it matter? Apart from the inconvenience of the date being incorrect in the display, this incredibly over-engineered car has another perplexing issue. See that nice analog clock between the vents? It’s set automatically by the COMMAND system. Since the GPS date was incorrect, and the time is calculated based on Sunday, the clock is wrong in thousands of cars all around the world. And it’s doubly wrong since it thinks it’s summer, so daylight savings time isn’t in effect! Most clocks were showing a little over 2 hours off.

The IWC-branded clock in most AMG S- and CL-Class cars shows the wrong time. At least the clock is showing the right time, even though it’s set by the COMMAND system too.

I can’t say why my clock is showing the correct time even though most others are not. I believe it has to do with the fact that my GPS navigation system was broken when I bought the car, and had been broken since well before October. Although I fixed it (replacing the original 2.5-inch hard disk drive with an SSD) it still shows the right time. Thank goodness!

Who knows how the Mercedes-Benz COMMAND system will handle the GPS Epoch reset at midnight. Mercedes-Benz refuses to accept responsibility for this bug and will not fix it, even though it affects top-of-the-line cars less than 10 years old. And one would think that IWC, a renowned maker of high-end Swiss clocks, wouldn’t like their name associated with a clock that refuses to show the correct time.

References:

https://www.dhs.gov/cisa/gps-week-number-roll-over

https://ics-cert.us-cert.gov/sites/default/files/documents/Memorandum_on_GPS_2019.pdf

Stephen’s Stance

The GPS Time bug is part of a whole category of time formatting and storage bugs, from the familiar (Y2K) to the perilous (2038) to the obscure (Reiwa). The fact that a simple system like GPS time can fail in so many interesting ways and places shows just how much our world is reliant on the assumptions of programmers and the ability of companies to properly quality-test their products. And the fact that world-renowned companies like Mercedes-Benz (and by extension IWC) refuse to fix their own bugs does not set my mind at ease.

Update: What Happened and Why It Matters

It’s April 7, 2019 and GPS Week Number is now 0. The world did not end, but some failures have been noted. And some things that were broken remain broken.

The Trimble Thunderbolt is definitely not handling the GPS Week Number rollover correctly.
Twitter users say the navigation systems in some aircraft (possibly China Airlines Boeing 787s) is showing today as August 22, 1999. So the Epoch shift simply did not work.
The same is happening with some Garmin eTrex GPS receivers.

As for my Mercedes, the date is still wrong. So much for that.

Why does it matter? Some systems aren’t so trivial as a dashboard clock or date display. What if they divide by week number and crash? What if they’re calculating the time offset from a previous date and now read negative? What if something is supposed to happen on a certain date and now it won’t for another 20 years?

Most importantly, this shows that programmers don’t always make valid assumptions about infrequent issues and QA doesn’t catch them. And they didn’t catch this. This is an issue beyond GPS time.


© Stephen Foskett for Stephen Foskett, Pack Rat: GPS Time Rollover Failures Keep Happening (But They’re Almost Done)


Viewing all articles
Browse latest Browse all 130

Latest Images

Trending Articles





Latest Images