Picking A CRC

You send a file, but how do you know it arrived intact? In other words, how do you know that it didn’t get cut off, garbled, or changed somehow? Simplistically, you could just add up all the bytes in the file — a checksum — and send that along with the file. You compute the checksum when you know the file is good, and the receiver can compare the checksum to see if they match.

However, a simple addition doesn’t catch certain classes of errors, which is why there are better checksum algorithms that, for example, wrap the carry bit around or otherwise modify files with common errors so they produce different checksums. There are two problems with checksums. First, no matter how much you modify the algorithm, the chances that two files produce the same checksum are pretty high. Especially with common error patterns.

For example, assume a very simple algorithm that simply adds the bytes and discards any carry. If a file contains 0x80, 0x80, those numbers essentially cancel each other out. If you replace them with 0, 0, you’ll get the same checksum. To some degree, using anything other than a second copy of the entire file will have this problem — some corruption goes undetected — but you want to minimize the number of times that happens.

The other problem is that a checksum by itself doesn’t let you correct anything. You know the data is bad, but you don’t know why. If you think about it, the simplest checksum is a parity bit on a byte: odd parity is simply summing all the bits together. If the parity bit doesn’t match, you know the byte is bad, but you don’t know why. Any even number of errors goes undetected, but I am sure one-, three-, five-, or seven-bit errors will get caught.

People invent better error-checking codes by devising schemes that can promise they can detect a certain number of bit flips and, at least in some cases, correct them. One of these is the cyclic redundancy check (CRC). It is easy to think of the CRC as a “strong checksum,” but it actually works differently. What’s more, there isn’t just a single CRC algorithm. You have to select or design a particular algorithm based on your needs. Most people pick a “named” implementation like CCITT or Ethernet and assume it must be the best. It probably isn’t.

A CRC is a checksum in the broad sense: you feed it a message, and it gives you a small value that you append, store, or compare later. But unlike a simple additive checksum, a CRC is based on polynomial division over GF(2), which is a fancy way of saying “divide using XOR instead of carries.” That detail matters. It gives CRCs very strong guarantees against common classes of errors, provided you choose the right polynomial for the job. That’s the key. You must choose the right polynomial.

Continue reading “Picking A CRC”

Wooden Piano Keys Hold Your Less-Wooden, Not-Piano Keys

There are many ways to deal with keys: a bowl next to the entryway, a junk drawer, or you can just leave them in your pockets and hope you remember to check on Laundry Day. [Inventive Robin] has come up with his own, unique take on the key holder concept: he’s got piano keys to hold his car keys, CNC’d out of some nice hardwoods.

Of course, it’s not just a fake one-octave piano with hooks glued to it; that wouldn’t be quite enough to catch our fancy. There’s a mechanism hidden under the “white” keys– made of maple– that lowers the brass hooks when you press the, er, wooden actuator, so you can retrieve your, uh, lock-openers. Keys, that is. They’re both keys, of different sorts, because English is a wonderful language. In any case, pressing the maple key a second time lifts the brass hook, trapping the likely metal key hanging on it.

The mechanism was carved from acetyl sheet on the same Shapoko CNC machine that handled the wood, and was assembled with purchased metal rods, springs, and some plastic standoffs. It’s very satisfying to watch it work unenclosed, so check out the build video embedded below to see that in action– jump to 4:46 if you don’t want to get the whole design brief.

It’s not the most complex of hacks, but it’s beautifully done inside and out, and [Robin] is clearly happy with the result. It’s nice enough that visitors might want to photograph the key holder, but perhaps have them do it sans keys– those photos could potentially be a security risk.

Continue reading “Wooden Piano Keys Hold Your Less-Wooden, Not-Piano Keys”

The Y2K Bug In BSD 2.11 That Survived 2000

A year before the arrival of the brand-new 21st millennium, the Year 2000 Bug was predicted to grind modern society to a halt and ensure that at the dawn of the year 2001, there’d be nothing left but the smoldering wreck of once great societies. Thanks to the concerted efforts of countless engineers, software developers, and many others, we were left with mostly just silly glitches, with one of these surviving bugs apparently just discovered, as [Van Heusden] reported on an NTPd bug in BSD 2.11.

To be fair, it is a pretty obscure one, as the demonstration involves BSD 2.11 on a PDP-11/70 from 1975, so it’s probably not something that still sees much use outside retrocomputing enthusiast circles. In the blog post, the demonstration involves connecting a specific adapter by Traconex, capable of receiving WWV/WWVH time signals, and setting it up for use by the NTPd prior to running the ntpd -a any -d -d -d -d command.

Continue reading “The Y2K Bug In BSD 2.11 That Survived 2000”