A New Addiction?

I don’t normally watch TV. If I have time to waste, I find it much more satisfying to waste it on the computer. But yesterday my brother was watching TV. I ended up watching a bit of TV with him, and then he left. So I started flipping through the channels, and came across National Geographic in HD.

Whatever you might have thought National Geographic TV would be about, you’re probably wrong. I tuned in halfway through a show about mobsters controlling Las Vegas in the 80s (or maybe 70s), and the FBI work to bring them down. It was kind of a fascinating show, actually, but when it ended, I looked forward to quitting this “TV” thing and getting back to the computer.

But then the next show was about the Mafia working with biker gangs to sell cocaine in Canada, which got me hooked. After that, I finally escaped.

But then last night was another one of those “I finished the Internet” moments, and I really didn’t have the motivation to go do anything actually productive. So I tried another hit of TV.

National Geographic (which they call “Nat Geo,” a name which for some reason comes across as pretentious and irksome to me) had a program on “police technology,” the latest high-tech they’re using. They talked about the “Shot Spotter,” a neat system of microphones throughout a “bad neighborhood” in LA as a pilot program. They fired a test shot to demonstrate the system (they apparently test it often). About a minute later a cruiser showed up. Apparently it works by calculating the (miniscule) difference in arrival of the gunshot sound to various listening posts, and then triangulates the location with awfully good accuracy. He also modeled some newer non-lethal weapons. They modeled tasers, which, despite the whole “Don’t tase me bro” bad reputation they’re getting, actually strike me as a good thing. (They’re basically there for times when an officer’s only other choice is to pull out his gun, and I’d certainly rather get tasered than shot in the face.) The new ones come with embedeed video and audio cameras for accountability purposes. They also had what’s basically a paintball gun, firing something like 10 rounds a second. They have a few different “balls” they can fire, including hard rubber balls intended to inflict a bit of injury for crowd control, and traditional paintballs for marking suspects. But the neat one was the one they apparently use the most: “paintballs” filled with something like mace in powered form. They can fire a couple at a suspect and stop him pretty much instantly, or, for crowd control, fire a stream of them at the ground in a distance to keep people back.

That finished up at 11. Finally, I could escape the TV. Except, darn them, the next program was about past CIA programs, including some insane attempts at brainwashing people / feeding them LSD, and the pretty blatant murder of one of their operatives who’d expressed to his superiors that he was very uncomfortable with them testing serin on people, particularly after one died. So he “committed suicide” by jumping out a 13th-story window. The CIA insisted on a closed-casket funeral (for the family’s protection, of course!), and apparently discreetly had a few CIA agents at the funeral. The family later caught on that someone wasn’t right and exhumed the body, finding that he suffered blunt trauma to the head (which entirely contradicted the medical reports), and that the CIA the next year released a “manual” for their agents, including a recommendation that, to kill people, you should whack them in the head to knock them out, and then hurl them out a window to make it look like suicide.

Right now I’m just tuning into “Seconds from Disaster,” a show about a volcano in the Caribbean.

At 3pm there’s a show on the Green Berets, but I’m gone then. 4pm is a show about “hired guns” in Iraq, 7pm is about the shooting of Ronald Reagan, 8pm on Kent State, and 9pm is a program they’ve been hyping on the Oklahoma City bombing, with suggestions that the people convicted for it didn’t act alone. 10pm is about Columbine. I can skip 11pm, because it’s a repeat of Kent State. In fact, it’s repeats until 3am, when it’s about an old al Queda attempt at blowing up a plane. 4am is another plane crash, and 5am is another al Queda attack. Then 10am is “Military technology inspired by nature.”

I don’t think I can sleep anymore.

Seriously, this is an amazing TV network.

Clarity

I saw a reference to RAID 6 and didn’t recognize it, so I did what anyone would do–I Wikipediad (I’m going to make that a verb) it:

RAID 6 extends RAID 5 by adding an additional parity block, thus it uses block-level striping with two parity blocks distributed across all member disks. It was not one of the original RAID levels.

So that’s why I hadn’t heard of it–it’s not an “original” RAID level. (I don’t subscribe to RAID trade publications, so I wasn’t aware of it.) The description is a good one-liner, but there’s more text that follows. Surely, it will give me a good insight into exactly what this means and how it works in an applied setting.

RAID 5 can be seen as special case of a Reed-Solomon code.[5] RAID 5, being a degenerate case, requires only addition in the Galois field. Since we are operating on bits, the field used is a binary galois field GF(2). In cyclic representations of binary galois fields, addition is computed by a simple XOR.

After understanding RAID 5 as a special case of a Reed-Solomon code, it is easy to see that it is possible to extend the approach to produce redundancy simply by producing another syndrome; typically a polynomial in GF(28) (8 means we are operating on bytes). By adding additional syndromes it is possible to achieve any number of redundant disks, and recover from the failure of that many drives anywhere in the array, but RAID 6 refers to the specific case of two syndromes.

Wait, what? Reed-Solomon? Degenerate cases? Galois fields? Binary galois fields in cyclic representations? Special cases of the Reed-Solomon code? Polynomial notation of the Reed-Solomon field? I’m lost. Very lost, in fact. Here I was hoping for an expansion over a one-liner that I pretty much understood but that was somewhat vague. And instead I get… I’m not even sure what I got.

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.

I Told You…

Texas has problems.

Apparently, in the counties that got around to holding caucuses and primaries, no one was quite sure what they were doing. People waited hours to cast their ballot (wait, you cast ballots in a caucus? How is that diferent from a primary? Why do they hold them on the same day?), which apparently also confused a lot of people by, for some reason, asking them to select their sexual orientation?

The results (of candidates, not Texans’ sexuality) are still coming in….

Ohio

The weather in Ohio has apparently turned absolutely miserable, which many predict (for obvious reasons) will hurt the turnout. But, as the photo shows, Obama fans like Arya Kamangar won’t let the weather stop them. I wonder if bad weather is almost in Obama’s favor? Although at this point, Hillary fans are probably pushing really hard for turnout, too.

Yes They Can

There’s a women’s rights movement going on in South Africa.

One thing I think is interesting is that people tend to view this as backwards–they’re just now having a women’s rights movement? But I view it differently. They became a Republic in 1961. It took us centuries from being founded on supposedly-democratic principles before we truly recognized that every person was equal. Forty-five years and they’re already doing it.

And just the other day, Kenyans agreed to a power-sharing deal putting an end to a brutal conflict that had developed there.