UCWords

Every now and then I find that I need to do something that seems remarkably obscure, and am surprised to learn that PHP has a function to do it. I found myself cleaning up a really sub-par Wikipedia article, where someone had entered a massive list of things in ALL CAPS.

It’s easy enough to upper-case everything, or to lower-case everything. But what I really wanted to was to capitalize the first letter of each word, because they’re all proper nouns. It turns out that PHP has a ucwords function to do precisely this.

And thus this page, which I suspect will never be useful to anyone, was born. Enter text, and it’ll covert it to lowercase, but upper-case the first letter of each word. And in this case, the time required to write the script was less than the time it’d have taken me to change it all by hand.

Counter-Vandalism

Today most of my tasks are in the “wait” phase, so I had some free time. Of course it’s a Sunday, so there wasn’t a lot to do. So I fell back on an old hobby: patrolling Wikipedia for vandalism. I’d say that 80% of edits are constructive, 10% are well-intentioned but misguided, and 10% are egregious vandalism. (Replacing a whole article with the word “poop,” for example.)

I’d like to point out that the deck is really stacked against vandals, though.

One of the most useful things is the Recent Changes page. Unsurprisingly, it shows the most recent changes to articles. Tweak the settings a bit, and I can view only changes by users who aren’t logged in, which probably accounts for 95% of vandalism. I can quickly click “diff” to view a summary of changes between the edit and the version before it, which makes vandalism quite evident. “hist” takes me to a history of all the changes, which is also useful. After that comes the change in length: (+1) indicates that the page was made one byte longer, for example. Huge differences are in bold; lengthy tirades inserted into the middle of an article, or outright “deletion” of articles, are super-easy to spot. (It’s worth remembering that all it shows is the net change of the edit: if you replace good text with obscene text of the exact same length, it’ll show a net change of “0,” so the size of the change shouldn’t be anything other than an occasional red flag that something’s up.) I get the user’s name (only IPs in the view I keep), followed by a link to their Talk page.

For example, I noticed a significant addition to the article on Jean Carne. Some guy kept inserting some sort of ramblings about her. Here’s a diff (obscene text). On the left is the “before,” and on the right is the “after.” The section in green is what got added, which clearly doesn’t belong.

Wikipedia allows logged-in users to include their own JavaScript, etc. into the pages they see, so I’ve got some mods to insert an “undo” option for me.

So it’s worth noticing that all of this took me maybe five seconds. That’s probably too high a number. I spotted a huge number of added content, saw the diff, noticed it was nonsense, and undid it.

But that’s only half the job. The next stage is to leave a note on the user’s talk page, explaining that you undid their edits. There’s a Wikipedia policy page on how to proceed, with a handful of useful templates. The basic premise is that they escalate from, “Your test worked and we undid it for you; next time please experiment in the Sandbox,” gradually growing in sternness until it gives a last warning: vandalize again and you’ll be banned. (Here’s an example, showing a guy who, frankly, got more warnings than he deserved.) You’ll note that, aside from vandalism earlier this month, it all happened in a short period–20:21 and he got his first warning, and by 20:39 he had been banned. What’s most awesome about this is that most of the time was him: we can’t warn someone again before they vandalize again.

However, I’m not an admin on Wikipedia, which means that I can’t actually ban anyone. But I don’t need to. There’s a handy page called Administrator Intervention against Vandalism, often referred to as WP:AIV for short. The use of a quick template allows me to identify a user or IP that’s actively vandalizing. My contributions rarely stay on the list for more than 30 seconds, after which time they’ve been acted on. I’ve never encountered a backlog, because there’s always an admin or twelve processing the list.

Another useful tool in our arsenal is the ability to view contributions by user. A fun bit of JavaScript allows me to simply hover over an IP / username and view their changes. So if I catch you vandalizing once, I’m going to go through your past edits. Most of the time your past vandalism was caught already, but periodically I’ll catch something.

There are two things worth noting:

  • It’s often under 30 seconds to go from a user vandalizing a page to their edits having been reverted and a warning left.
  • People patrol new edits pretty closely. I caught a guy today changing dates. They were subtle changes, but that doesn’t mean that no one caught it. Just as with people trying to trash pages, I had his edits undone in a matter of seconds.

There’s really something pretty satisfying with someone working up some sort of elaborate vandalism, only to undo it with a single click.

Digital Radio

There are a few different technologies commonly used in two-way radio. One is digital voice, a la Motorola ASTRO / Project 25’s CAI (IMBE), which is a 9600bps (9.6kbps) digital stream. Another interesting technology is trunking: a city might have 12 talkgroups (think “virtual channels”), but only 4 frequencies. One frequency is designated as a “control channel,” which is a digital stream announcing system status. When you want to transmit, your radio will go out to the controller and get assigned one of the frequencies, and the system will then announce that you’re transmitting on one of them, and all radios in your group will switch over and listen. This allows much greater spectrum utilization: rather than needing a new frequency for every group that might want their own channel, you just need to license enough frequencies for however many simultaneous conversations you expect.

I’ve been thinking that it’d be interesting to merge the two technologies. Technologies like Speex will let you process audio at exceptionally low bitrates, seemingly as low as 3.4kbps. (And they have some neat technology, like variable bit-rate encoding and even further drops in data transfer in between words, dropping quite low for when it’s just background noise.) So I think it’d be neat to start a “data network” at 32 kbps, which could be done with relatively low bandwidth. You could keep one frequency, and yet fit as many as 7 or 8 simultaneous conversations on it. (And you can take its VBR support one step further, and have it scale to fit system capacity: on a system with minimal activity, allow 8-16 kbps, but when the system is starting to fill up, drop down to 4 kbps.) HE-AAC (also known as AACPlus) looks promising too, although it’s a proprietary technology.

And since it’s now a 100% data network, you can do what I’ve always thought mobile radio systems, especially those used by public safety agencies, ought to do: put a GPS unit in each radio, and have them embed GPS coordinates in each transmission, as well as periodically announcing their coordinates in the background.

The net result is insanely efficient (radio) bandwidth usage. For example, Boston PD has 16 frequencies licensed, but it’s rare for more than 2 or 3 to be in use at any given moment. They could get more efficient by switching to a trunking system, maybe with 5 frequencies (plus a control channel). Of course with an established system, there’s really no incentive to, but I digress. But if they could get entirely usable digital audio at 3-8 kbps, they could actually move to a single frequency and support multiple, simultaneous conversations.

Another neat side-effect is that linking the systems would get quite easy: the entire system, with multiple conversations, could even fit over a single dial-up modem link. And you can have better “emergency” support, although most trunking systems seem to do it anyway: public safety radios carry an “orange button,” which will signal an emergency to the radio system. Analog systems do this by basically making the radios “obnoxious”–they’ll just keep transmitting a distress signal over and over, increasing the odds that they get through. With an all-digital system, they can just send packets indicating an emergency, and have the network make way for them, going so far as to terminate existing conversations if needed.

Oh, and another novel benefit is power management. If I’m on a handheld radio and I’m standing twenty feet away from the tower, I can dial my power down as low as it goes and still make it in fine. But if I’m a few miles away, I need to be using the highest power I can to make sure I’m making it. Of course, no one in the field fiddles with power settings. (In fact, most radios don’t make this something the user can do.) But if you just exchange a bit of signal strength info in the data flowing between radios, you can make this automatic. As I talk to the tower, it’ll be periodically confirming that it’s hearing me. But when it does that, rather than just using a boolean, “Yup, got it,” it can send me signal strength data, and my radio can dial down power until it’s at a, “I’m still getting 100% of your packets but I wouldn’t go any lower in power…” point. The net result is longer battery life. (And potentially, less interference to distant users of the same frequency.) As a really obscure benefit, if you’re transmitting this information, and also embedding GPS coordinates in your transmissions, the system could silently log all of this and generate coverage maps, which would get more and more detailed over time.

Sheesh

Now that Comcast has vowed to quit arbitrarily blocking services on their Internet service, they’ve decided to shift the degraded quality to their HD offerings. This article talks a bit about how Comcast is running some heavy compression to fit more HD channels into finite bandwidth, but it has lots of words. So check out some pictures of screen captures of identical footage from FiOS versus Comcast. Slashdot has the story here.

XBox

One thing I find interesting about technology is that sometimes a trivial technological thing has huge differences to the end user.

I’ve been playing Grand Theft Auto a bit in my spare time, on the Xbox 360. After re-arranging some things, I’ve run into a strange problem where, when I power it up, it loads older game files, not the newest. I know exactly what’s wrong, but it’s kind of like the “roger tone” to “FRS” leap–intuitively understanding what’s wrong here borders on savantism.

When I rearranged things, I didn’t bother to plug the Xbox back into my switch. I think the cable it was using is out in another room right now. So the Xbox has no Ethernet connection. Are you seeing why my game loads really old saved data yet? Hint: the game doesn’t use the network in any way, shape, or form.

The Xbox, when it’s connected to the Internet, will grab the correct time via the web. (I’ve wondered about this, actually: is it using NTP? Is it syncing to time.windows.com? I’ve been tempted to try packet sniffing, but it would basically require ARP poisoning, which I’m reluctant to do right now, as both the Xbox and my laptop are essentially on the school’s network, so it wouldn’t be too easy to “safely” do it.)

For some reason, though, when shut down, the Xbox never runs a “systohw” call (or at least, that’s what it is under UNIX) — the system clock, which was just synchronized and is quite accurate, is never written to the hardware clock. So two weeks ago, when I booted my Xbox, it was March 14, 2008. I saved a game, shut down the console, and went to bed. And then I rearranged stuff and realized that there was no reason for my Xbox to be online, so I moved the cable to the common room.

So the Xbox, now booting with no Internet connection, thinks it’s November of 2006, since the software clock never got committed to hardware. And the game, not anticipating bizarre things like this, automatically loads the game with the newest timestamp. As far as it’s concerned, the game I saved two weeks ago is a year and a half “newer” than what I saved earlier today.

So there you have it — whether I have an Ethernet cable hooked up or not changes the year on my Xbox, which causes it to load old games. And it’s all because the Xbox, for reasons I can’t understand, never writes the time to the hardware clock. (To me, this is a bug, and one that would require adding one line of code.) And it shows something neat (or scary, depending on your perspective) about programming — trivial details (like whether you sync the hardware clock to the software clock when you shut down) manifest in entirely unexpected ways, like which save file my video game opens.

Stopping Blogger Spam

It’s very common for spammers to create blogs on Blogger (something.blogspot.com). There’s a survey out there that found that 74% of blogs on the site were spam.

It turns out that you can report spam blogs pretty easily on Blogger: they’ve got a form for it here. You won’t find it linked to on their site (or at least, I didn’t), but it’s available. Use it and make the Internet a better place!

Quick Photoshop Tutorial

As a photographer, and an obsessive-compulsive nut, I spend a lot of time working on tweaking photos in Photoshop. Inspired by a recent project, here’s my workflow for one image. Here’s what I started with:

It’s an aerial photograph, and certainly not a bad photograph. But it can be better!

The first thing I tend to address is how much detail is “lost” in the shadows and highlights. Often you’ll find a photo that looks washed out. (Less often, you’ll find one that’s excessively dark.) The good news is that, within reason, you can fix this up. The classic way is the Levels tool in Photoshop (Ctrl+L). But newer versions have a Shadows & Highlights wizard, something I’ve taken to using before I even get to Levels. The Shadows & Highlight tool (Image / Adjustments / Shadow & Highlight) gives you two sliders, one to bring out detail in the shadows (the dark regions), and one to bring out detail in the highlights (the exceedingly light regions). Here’s how it looks after a quick adjustment:

It’s definitely looking better. But it’s still not quite there. You have to be careful with the Shadows & Highlight tool, because applying too much results in an image that looks entirely artificial. You can adjust it so it starts to look like real life, but take it much further and you’re quickly at, “Wow, someone got carried away in Photoshop…” So I had to stop when the image was still slightly washed out. Take a look at the shadows cast by the buildings, which are the darkest part of the photo. The darkest part should be black, not gray. This is where Levels (Ctrl + L, or Image / Adjustments / Levels) comes in:

A few things to note. The graph is called a histogram, and it’s basically a graph of how much of the photo is each shade of gray, ranging from pure black on the left to pure white on the right. Short of just hitting the ‘Auto’ button (which often produces results I don’t quite like), the easiest way to tweak the levels is to drag the sliders appropriately. Pull the black arrow (underneath the graph, above the “0” text box) until it points to where the graph is just starting to slope upwards. (Or, more accurately, to where the graph is non-zero.) You could do the same with the whites, although in this case, it’s properly-adjusted.

In this case, this is all we need. Press “OK” and you’re done. (A more advanced technique that’s sometimes called for involves using the eyedroppers above the “Preview” checkbox. Click the black eyedropper, and then click on the photo to select what you want to define as 100% black. Do the same with the white eyedropper, selecting what should be pure white in the photo. The gray one is more tricky, as you’re setting color balance, but you essentially want to find a “neutral gray,” something like pavement. You really just click around until you find something that looks good. But in this case, none of this is necessary.)

After clicking OK, here’s what you get:

The shadows are now black. More generally, and perhaps more importantly, the photo no longer looks washed out. It’s properly exposed.

In this case it’s not bad, but the next step is to look at the color cast of the image. It’s more pronounced in other photos, which often have various color tints that they shouldn’t.

Here’s the Variations menu (Image / Adjustments / Variations):

Make a habit of clicking on the photo under “Original,” which will reset it. When you first start otherwise, it’ll save whatever settings you have from last time. Unless things are insanely bad, I tend to slide the slider over from the center to where it’s shown in the photo. Do this mostly just “to taste.” My end result is subtle:

Now, we’re basically there. One last thing. I like really “sharp” images. It’s not blurry per se, but it doesn’t have that “tack sharp” status. Photoshop makes it very easy to sharpen images. I tend to use the “Smart Sharpen” available in newer Photoshop versions, though the older “Unsharp Mask” remains popular and effective. Here’s the Smart Sharpen (Filters / Sharpen / Smart Sharpen…) dialog:

You set two things: the amount of sharpening to apply, and the radius of the sharpening. Here, I used settled on an amount of 66%, and a radius of 0.5 pixels. This sort of blend is common. Another alternative is the “haze” sharpen, which is something like 20/20 (a low 20%, but over a huge 20 pixels). Applying the 66%, 0.5-pixel sharpening gives us this image:

So here we are. We’ve made lots of subtle changes, but all of them are quick. But then jump back to where we started:

One additional tip: I didn’t need it here, but adjusting Saturation can help with some more dull-looking photos. Ctrl+U is the shortcut to memorize, but Image / Adjustments / Hue & Saturation is the menu entry. Just don’t go too overboard.

More on Time

I’m worried you’ll all think I’ve snapped and become obsessed with time. It’s not quite that bad. But here’s another post about time.

A lot of Windows machines seem to sync to time.windows.com, and Apple has its own time.apple.com service. I come across this interesting (to me) post about Apple’s service, and started doing some looking. First, an important bit of terminology (for those who don’t follow my every post): the stratum of an NTP server is basically its place in a hierarchy of systems. Stratum 1 is the top, meaning that it’s directly connected to an accurate time source (e.g., a GPS or other hyper-accurate time source). Lots and lots of people sync their clocks to Stratum 1 servers, and thus become Stratum 2. And lots of the Stratum 2 servers join the pool, meaning that people who sync to them become stratum 3. With each step down the hierarchy, you increment the stratum by one. The impact of stratum varies: you become more and more removed with each step, which obviously introduces error. But the level of error varies: it’s conceivable that strata 1-3 would all be on the same LAN, but it’s also possible that my stratum 3 server I sync to is sitting on a 100 Mbps line in a data center in Boston, gets it time from a stratum 2 machine with a 128kbps satellite link in Zimbabwe, which gets it time from a stratum 1 on a 3600bps dialup line in Rhodesia. (Is that even a country anymore?) So the “loss” of being several strata down varies somewhere from maybe 1ms up through many seconds.

One final note: the following commands are being run on a node that’s itself a stratum 2 NTP box, so pay attention to the “offset” field. (And note that it’s in seconds, not milliseconds, just to add a healthy dose of confusion.)

# ntpdate -q time.windows.com
server 207.46.197.32, stratum 3, offset 0.016801, delay 0.08435
 9 Mar 22:47:55 ntpdate[22072]: adjust time server 207.46.197.32 offset 0.016801 sec

First, it’s inexplicably a stratum 3 host. This isn’t necessarily bad as I discussed, so much as odd–you’d think that time.windows.com could at the very least be stratum 2, if not holding a GPS itself. (“time.windows.com” may actually be a number of machines sharing an IP, with GeoIP or whatnot.)

For comparison, the nodes I sync to:

#  ntpq -c peers
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
-time-C.timefreq .ACTS.           1 u  142 1024  377   18.854    4.204   0.025
-india.colorado. .ACTS.           1 u   93 1024  377   23.777   11.419   3.751
+rrcs-64-183-56- .GPS.            1 u  408 1024  377   55.427    0.217   1.047
*tick.UH.EDU     .GPS.            1 u  483 1024  377   25.108   -2.053   0.082
+clock.xmission. .GPS.            1 u  145 1024  377   38.306   -0.861   0.019

Pay attention to the “offset” column, which here is in milliseconds. The timeservers range from pulling be back 2 milliseconds to advancing me 11 milliseconds. (Although also note the “-” on the first line, indicating that the +11ms host is considered a fairly bad source. By comparison, the “*” indicates the current ‘best’ server, which set my clock back 2ms.)

Microsoft’s server is trying to pull me 0.016801 seconds, or 16.8ms. As shown above, this is even worse than the server that’s being rejected for being too far off. (Of course, it’s worth repeating that it’s less than 17 milliseconds, which is more than enough accuracy if your goal is to simply keep your clock accurate!)

How about Apple?

# ntpdate -q time.apple.com
server 17.254.0.28, stratum 2, offset 0.004297, delay 0.07193
server 17.254.0.31, stratum 2, offset 0.003697, delay 0.07074
server 17.254.0.26, stratum 2, offset 0.004346, delay 0.07195
server 17.254.0.27, stratum 3, offset 0.004369, delay 0.07195
 9 Mar 23:23:37 ntpdate[4321]: adjust time server 17.254.0.31 offset 0.003697 sec

This one looks different than the Microsoft one: there are four IPs for time.apple.com. All four are kept at stratum 2. The offset here is better: 0.003697 seconds, or 3.7ms. It’s still pulling me in the wrong direction (-2ms was ruled the best, whereas this wants to advance me +4ms), but it’s much closer to accurate.

This got me wondering: Apple has 4 A records for time.apple.com… What does the NTP pool look like?

# ntpdate -q pool.ntp.org
server 67.201.12.252, stratum 3, offset 0.002990, delay 0.05959
server 69.36.240.252, stratum 2, offset 0.003088, delay 0.06898
server 98.172.38.232, stratum 2, offset 0.022841, delay 0.08508
server 209.67.219.106, stratum 3, offset 0.019785, delay 0.02614
server 216.184.20.83, stratum 3, offset 0.012001, delay 0.10208
 9 Mar 23:31:21 ntpdate[7524]: adjust time server 69.36.240.252 offset 0.003088 sec

It returns five hosts. And a quick aside:

;; ANSWER SECTION:
pool.ntp.org.           948     IN      A       209.67.219.106
pool.ntp.org.           948     IN      A       67.201.12.252
pool.ntp.org.           948     IN      A       98.172.38.232
pool.ntp.org.           948     IN      A       69.36.240.252
pool.ntp.org.           948     IN      A       216.184.20.83

They have a long expiry: 948 seconds, or about 16 minutes. Sure enough, asking again gets me the same 5, but with a decremented TTL. They do run GeoIP, though, so my other server is getting a different list, even though both are in the US. (But it keeps the same list, too.) But anyway, back to the ntpdate output…

I’d actually run this earlier, and gotten all stratum 1’s and stratum 2’s, which I was going to post. Now it’s all 2’s and 3’s. The dork in me wants to run this every ttl seconds and keep logs.

This shows where the NTP clock selection algorithm shines. I know from belonging to the pool that we get “monitored” by a server that checks our time a few times an hour and pulls us out of the pool if our servers are off (I think a second is the tolerance). Here, the worst server is 0.022841 seconds (22.8ms) off, and one of the best is picked. (The “best,” the one closest to mine, is actually discounted because it’s a stratum 3, and the stratum 2 one is presumed to be more accurate. Closeness to your own clock is generally not a metric, unless you’re running these on a server that’s already kept to good time.) But the net result is an offset of about 3ms: a slight improvement over Apple, and a big improvement over Microsoft.

Aside: I just ran the Microsoft one again, and its offset had dropped to 2.3ms. So I ran it with Apple and Microsoft in one, letting the NTP algorithm do its magic… Suddenly Microsoft was suggesting a -1ms offset, with Apple pushing a 4ms increase. They’ve all converged a bit, although the time.windows.com one seems to jump around a bit more than the others?

The moral of the story? All of these timeservers are really good if you’re just looking to keep the clock in your system tray right. If you’re a total nut for the right time, the pool is best, followed by Apple, then Microsoft.

Addendum: Microsoft hosts one of NIST’s Stratum 1 servers, which makes it all the stranger that time.microsoft.com is all the way at stratum 3.

Sysadmin

I like to run a really good Windows machine. Firefox is my default browser (although IE’s come leaps and bounds since it’s “I’ll merrily install any program a webpage asks me to!” days), I keep a system free of viruses and spyware, I have a “background” disk defrag tool, I routinely run CCleaner, etc. to purge accumulated cruft, and so forth. In short, I’m a system administrator’s dream. (Actually, I think I’m their nightmare, since the only time I contact them is when I have a really hard question, and I never do anything they expect… But I digress. If I administered a set of desktop nodes, I’d want them to be setup like mine.)

If I ran a computer network, though, I really wouldn’t trust normal people with doing things. Virus definitions need to be updated, virus checks need to be run, recycle bins need to get emptied, stale caches need to get purged, clocks need to get synced, and disks need to be defragged. I do this naturally on my desktop machine, so I don’t think of it as taking a lot of time, but if you asked me to maintain a network of, say, 30 PCs, I’d want to cry.

There exist, of course, a bajillion different tools for administering clusters of PCs. But what I find interesting is that I can’t think of any that really do what I want. I want to make sure certain programs are installed, and run them unattended periodically. Most solutions still seem like they’re require me to go to each PC and do my work, or they’d limit things: an increasingly common thing to do is just reimage each computer when it reboots. In some cases, though, this is totally undesired: people might forget to use their network drive, losing all their work when they reboot. Or they might need to install a legitimate program for their work, and you’d end up losing a lot of productivity as they’re forced to reinstall every time they reboot. (Which means that they won’t reboot often, which complicates other things.)

Time

So I’ve mentioned before that I run an NTP server. Stratum 2, which means it gets its time from a “Stratum 1,” which is set directly to something reliable. The main goal of NTP is to keep clocks in sync, and it’s pretty accurate, down to a fraction of a second, which is more accuracy than most people need. All of my computers will now agree on the time down to a second.

The ultimate source, of course, is the atomic clock. But there isn’t an atomic clock, per se. There’s actually an array of them, each using cesium or hydrogen as an atomic reference. Collectively they form “the” atomic clock, which is used as a frequency standard.

It’s all well and good to keep your computer clock (and wristwatch, and microwave, and oven, and wall clock…) synced within a second, but some things need more accuracy. The USNO (US Naval Observatory, in charge of maintaining the atomic clock system) explains one common scenario well: systems for determining one’s location, such as GPS and LORAN “are based on the travel time of the electromagnetic signals: an accuracy of 10 nanoseconds (10 one-billionths of a second) corresponds to a position accuracy of 10 feet.” There are also lots of other scientific uses for extremely precise time, many of which I couldn’t even begin to understand the basic premise of. But suffice it to say that there are actually a lot of times when knowing the time down to the nanosecond is important.

Things like NTP don’t cut it here. You can get down to the millisecond, but you need to be about a million times more accurate. (A millisecond is a thousand microseconds, which is a thousand nanoseconds.) So how do you keep the exact time? It turns out that there are actually several ways. One way (decreasingly common) was to keep an atomic clock of your own. You can buy a “small” (the size of a computer…ish) device that has cesium or hydrogen or rubidium inside of it, which keeps pretty accurate time. Over time it’ll wander, but at least short-term, it’s quite accurate.

One of the first ways is WWV, a shortwave radio station. (And it’s Hawaiian sister station, WWVH.) They run continuously, disseminating the exact time via radio as observed from the atomic clock system. In the past I’ve synced my watch to this source. More notable, in a behind-the-scenes type of way, is WWVB, a low-frequency (60 kHz) radio broadcast. This is what all your “atomic wall clocks” sync to. (Incidentally, I’ve read that most of them are fairly cheaply built, meaning that their time is really not accurate to more than a second.) Another interesting sidenote is the deal with their antennas: a quarter-wavelength antenna at such a low frequency is 1,250 meters tall, or about 4,100 feet (nearly a mile). But with some wacky designs they can overcome this (although pouring 50,000 Watts into it also helps).

The problem with “straight” receivers for WWVB, though, is that you have to figure in the time it takes for the signal to reach you, which is rarely done all that well (if at all). Instead, a more common technology is used: GPS.

It turns out that GPS carries insanely accurate time. Wikipedia has a really good article on it. Each GPS satellite carries an atomic clock onboard, and people on the ground keep it synced (with nanosecond accuracy) to the atomic system. There’s some funky correction going on to keep things perfectly accurate. GPS has a claimed accuracy of 100 nanoseconds, although people have found that it’s actually about ten times better, down to 10 nanoseconds or so.

As an aside, GPS in general is an interesting read. There’s a lot more going on than meets the eye. I recently dug up an old GPS and wondered if it needed an “update” to get new satellite positions: with ham satellites, we get periodic updates for our tracking software to account for changes in their path. GPS has a neat solution, though: the satellites broadcast this data. Actually, more accurately, they broadcast all the data for all the satellites, so that seeing one satellite will fill you in on the whole setup. There used to be Selective Availability, basically a deliberate introduction of error into the signal. The premise was that we didn’t want enemy forces using it: imagine a GPS-guided rocket, for example. So we introduced error of about 30 meters for a while. Ironically, it was ended because our own troops (before Iraq) couldn’t get the military units, so they were just buying off-the-shelf civilian units and incurring the decreased accuracy. So Selective Availability has been turned off, and there are indications that it was permanent. A third interesting tidbit is that the GPS satellites carry much more than might meet the eye, including equipment monitoring for nuclear detonations.

The timekeeping problem is what to do when you get the time at the GPS, though. High-end GPS units will provide a pulse-per-second signal, which you cna hook up to a computer via serial, and achieve great accuracy. But there are all sorts of considerations I never thought of. Between the time it actually charges the pin and the time the operating system has processed it takes a little bit of time, os there are special kernel modifications available for Linux and BSD to basically get the kernel directly monitoring the serial port, to greatly speed up its processing. I also discovered the Precision Time Protocol (commonly known by its technical name, IEEE 1588), which is designed to keep extremely accurate time over Ethernet, but apparently requires special NICs to truly work well.

I’ve also learned another interesting tidbit of information. CDMA (which is a general standard, not just the cell phone technology that Verizon uses) apparently requires time down to the microsecond to keep everything in sync, such as your multiple towers and all the units (e.g., phones) in sync and transmitting at the right times. So the easiest way to keep all of their towers in sync to a common standard was to put a GPS receiver at each tower and sync the system to that. Thus CDMA carries extremely accurate time derived from GPS, which has led to some interesting uses. It’s hard to get a GPS signal indoors, so they now make CDMA time units–they sit on a CDMA network in receive-only mode, getting the time but never taking the “next step” of actually affiliating with the network. This lets people get GPS-level accuracy inside buildings.