Wednesday, August 26, 2009


I consider myself a fairly well-rounded engineer. My specialty is control systems but that's in name only. It doesn't say embedded systems on my MS diploma because I had already taken all of the embedded classes for non-grad credit. It says communications on there because I sat through all of the comm classes (and got A's in them) but even though I know a lot I wouldn't consider that my bag. It doesn't say 'math minor' on my BS degree because I was two classes short (I decided to get a head start on my MS instead of the math minor). I've been programming since I was 6 in BASIC, C, Perl, Python, etc. That doesn't make me a CS major, but the years after that of learning to use source control, taking OOP classes, using unit tests and documenting with Doxygen makes me at least a friend (you guys will be my friend, right?). I built robots when I was a teenager and learned the basics of electromechanical systems as a controls engineer, so I'm claiming some mechanical experience as well. And I can speak German.

But I find as I grow older that some areas I just don't know about. Worse, I think I've built them up so that they seem so difficult that it's not worth it to even try to learn about them. TCP/IP, networking, ethernet - all that is something I've been interested in but thought the barrier to entry was too high. I've fussed about around the edges - I can tell you that the ethernet physical layer uses differential signal and (I believe) a 350MHz signal. I've done web programming and that introduced me to ports and such, but I don't take the time to go and just learn the stuff. I would start and I'd see the 7-layer OSI model and my eyes would just glaze over. Who the hell needs 7 layers (unless it's lasagna)? What are they cramming in there that it NEEDS 7 layers. Is it really this complicated to send data across the internet? I deal with microcontrollers and RS-232. I can send data that way, but for some reason people see the need to make twittering power meters out of the same microcontrollers. Other than being just a foolish idea it seems way too complicated if you have to interpret every layer of this 7-layer monstrosity just to do something as asinine as say 'Your refrigerator is now using 78 watts of power!'

So I figured I wouldn't deal with it. Who needs internet connectivity? I'll get along just fine. But still, it vexes me. It's something I don't know. I have a friend who does all this sort of stuff, makes routers in his free time. So I ask him 'What do you DO? What do you know that I don't know?' And he replies 'I can tell you exactly how a machine responds to a ping request. Where the message goes, where it comes from, what happens. It's complicated but I know it.' Basically, he knows how the OSI model works, what each level does, what happens. And the trick is it's mostly programming after a point. But not straightforward programming: complicated CS-type programming. Layers of abstraction built upon layers of abstraction so in the end you don't know that you're dealing with bits and voltages. You see, software people are TERRIFIED of bits and voltages and they will do anything they can to abstract those away. They have sacrificial programmers that write drivers to interface the bits and voltages to sane, reasonable things like floats and strings. They'd have a minor episode if they saw a character instead of a string. They NEED the 7-layers of the OSI model to be able to effectively ignore the basic truth of what's happening: bits are being represented by voltages. By the time you get to the 5th layer you're dealing with all kinds of structs, connection IDs, sessions and voltagephobia so that you don't know what's going on. If you're me that is.

If he tried to explain it all I think I wouldn't have understood. He could have explained it in Elvish and it would have made as much sense. So I ignore it again BUT IT STILL BOTHERS ME. Especially since I designed what I thought was a very complicated, nice and worthwhile messaging system for microcontrollers built on top of RS-485. It had circular buffers, message queues, priority, timeliness, guaranteed message delivery and all that jazz. It was complicated but I just started at the bottom and worked up. Pretty soon *I* had a few layers just to implement serial communication between a couple of devices. You had to have addresses and ACKs and collision sensing and much more to handle all this. It gets complicated quickly. Even when you start simple you always have the edge case. "Oops, what about this? Better add an address field. Oops, better add parity. Gotta ACK that for sure.."

It adds up. So I thought I might take another crack at TCP/IP and you know what? It turns out it's a bunch of things I already know. Just more queues and buffers and ACKs. When a ping happens (I think this is how it goes...) it's sent to the right computer (as determined by its IP address) where the network layer reads the message, finds it's an ICMP ping packet and puts the information in a special struct then pushes it into a queue for the ICMP handling process to take care of. When it gets around to it, it creates a response packet, tells the network layer where to send it (what IP address) and puts all that data into another struct and pushes it onto a queue for the network layer. That's it. Not too complicated - just data structures, processes and lots of teamwork. I learned something about TCP/IP.

TCP/IP is a complicated system, there's no question. But it does a LOT. It can reliably send data halfway around the world to a computer you didn't know existed in a few seconds. That sort of success is built up on layers and layers of success - each layer being tested and battle-hardened until it has so many special cases that it looks like an insane asylum. But once again - IT WORKS. Simpler systems would not. I don't begrudge the creators of the magical internet their seven layers anymore. It's not simple but it's not incomprehensible. It uses tools and methods that I was aware of - I just wasnt' aware of how they pieced them together. Now I am. The moral of the story is that if there's something you want to learn or need to learn don't think that it's impossible just because it's complicated, and don't condemn the creators of the system just because it's complicated. Just take it slow, re-read a lot and eventually it will make sense. Eventually.

No comments: