Tuesday, July 25, 2006

GeekSpeak: CRC's

Okay, here's part two of the introduction to checksums, as recently learned by this novice. The concept of a Cyclic Redundancy Check is derived from polynomial math. The idea is this: Take your file or a block of data in binary notation and convert it into a polynomial with coefficients of either one or zero. Ex, if your message was 1101:

1101 --> (1)x^3 + (1)x^2 + (0)x^1 + (1)x^0 --> x^3 + x^2 + 1
Do the same for some carefully chosen "key," Ex:
101 --> x^2 + 1
Multiply the message by x raised to the degree of the key polynomial (in this case, the degree of the key is 2). Ex:
(x^3 + x^2 + 1) * x^2 = x^5 + x^4 + x^2
Divide the result by the key. Ex:
(x^5 + x^4 + x^2) / (x^2 + 1) = x^3 + x^2 + x, R = x
The Remainder is the CRC. Convert this back into bits, Ex:
x --> (0)x^3 + (0)x^2 + (1)x + (0)x^0 --> 0010
Once you send the message, the computer at the receiving end can perform the same operation. If the CRC's are the same, then it is very likely your message was received without error.
All of this math is performed "modulo 2," which basically means that odd coefficients become 1, odd negative coefficients become -1, and even coefficients become 0. Ex:
4x^2 + 3x - 1 --> x + 1
Also, it is imperative that a "good" key is chosen. Really smart mathemeticians have figured out which keys work best. Generally speaking, the longer it is, the more error-proof it is. As an example, a very common CRC key is called "CRC-32". It's polynomial is:
x^31 + x^30 + x^26 + x^25 + x^24 + x^18 + x^15 + x^12 + x^11 + x^10 + x^8 + x^6 + x^5 + x^4 + x^3 + x + 1
As we would presume, computers can peform these operations in a more efficient manner than trying to do complicated polynomial math, but as other people have covered this well, I won't go into that here.

Anytime you use the internet, these kinds of operations are going on in the background without you even knowing it. Be thankful that people a lot smarter than you or I (well, at least I) have gone to the effort to figure all this stuff out for us!

Friday, July 21, 2006

GeekSpeak: Checksums

Here's something interesting to the techies. In my quest for learning new things, I did a little research about what a CRC (cyclic redundancy check) is. Since I found the subject interesting, I thought I would share a little about it here.

A CRC is a type of
checksum, and is a way of attempting to ensure that data (e.g., a computer file, or stream of data over a network) has not become corrupted since it was first created. (And data can easily become corrupted because computers often misunderstand the messages they're being sent.)

A simple checksum works like this: you (or, more realistically, a computer program) goes through the file (or a specific chunk of data) and adds up the values of each of the bytes. The total is the checksum. If part of the file was changed, the total would typically change as well. This is actually a very easy algorithm to implement. For example:

Say you wanted to send your friend the following word: hello

The computer translates each letter into the following values: 104 101 108 108 111

The checksum would, therefore, be: 104 + 101 + 108 + 108 + 111 = 532

But, what if an error caused the 'o' to get lost along the way? hell

The new checksum would be: 104 + 101 + 108 + 111 = 421

If your friend's computer did a checksum and compared it with yours, it would discover the error and ask your computer to re-transmit the word--and it is unlikely that this time it would have an error.

Piece of cake! The downside is that there is a good chance the checksum will not catch certain kinds of errors. (For example, if a byte of data with a value of 0 get inserted, it will not increase the value of the checksum, even though the file size has increased by one byte.) Thus, a more robust--and complicated--technique is usually employed. Next time I'll talk about the CRC method of error-checking.

Thursday, July 20, 2006

Orphans with Parents

Parents spend only 19 minutes a day looking after their children. This comes from yet another study (this one in the UK) which shows that parents are orphaning their children while they pursue their careers.

And yet, I thought the following quote was particularly interesting:

"Recent research showed that most mothers with young families would prefer to stay at home and look after their children."

So why don't these mums go home? Unquestionably, the middle-class life is expensive (probably even moreso in the UK than in the US), and the cost of living is continually on the rise. But the question that no one wants to ask is this: is the standard of living we demand for ourselves of greater importantance than spending more time raising our own children? Do we really need two Mercedes? Do we really need those gym memberships? The Tivo? The Satellite TV? All the latest techno-gadgets? The daily Starbucks venti, iced-blended, decaf, mocha frapuccino? Not that this will solve all of the problems. But I submit it would go a long way to reducing the number of orphaned children as our cost of living would often diminish to the point that mom could come home and pursue her dream of (and, dare I say, responsibility for) caring for the kids.

The above story reinforces what I have heard recently that American fathers, on average, spend only 4 minutes with their children each day! That is yet another problem. Does Dad always come home and plop himself in front of the TV, or does he spend this time rastling, snuggling, reading, worshiping, and praying with his kids?

Is there really any wonder that today's children have a different worldview than their parents, would rather spend time with their peers than their families, are promiscuous, get into drugs, and eventually grow up to be nasty, brutish adults?

Of course, what goes around comes around. You can just picture how the kids will respond:

"By the way, Mum. When you and Dad need care in your old age... Don't come asking me for help. I'm sure the government have a nice little hole carved out for you in some state-run nursing institution where you can waste away the remainder of your days while Sis and I are out looking after ourselves. Didn't you hear about the brilliant 103" plasma screen telie that's coming out soon? I've just gotta have one o' them! And, of course, the wife's gonna have to work to help us pay for it."

Scots Wha? Huh!?

So this is my first attempt at a blog. Okay, that's not quite true--I started a blog several years ago, just as they were coming around. But I ran out of time to keep it updated and eventually gave up. Now that blogging is "all the rage," I decided to try giving it another shot. (Of course, now I have even less free time, so we'll see...)

I always have lots to say--not that anyone really ought to listen. Then again, I figure that what millions of people post on their blogs is not really that interesting. And if they can do it, then why not me too?

So, what's with the name? I have to admit that I have an extremely hard time coming up with usernames and the like. But since a large part of my heritage is Scottish, and since one of my favorite interests is in all things Scottish, Irish, and English, I figured why not name my blog after the title of the poem by Scotland's bard, Robert Burns.

The title "Scots Wha Hae," which means "Scots who have," comprises the opening words of the poem. The poem is typical of the nationalistic poetry of Scotland, a land which struggled for independence from the English for centuries. I certainly don't know enough of the situation to make any sort of claim for Scottish autonomy today, but for historical (and literary) reasons, the poem is valueable.

Anyway, here's to high hopes.

Slainte Mhath!

/* ------ Google Analytics tracking code follows ------ */ /* ------ End of Google Analytics tracking code ------ */