Teaching TCP/IP headers with legos

A Hal Pomeranz from 2010 suggests a great way to teach TCP/IP header structure to students: he builds header diagrams out of legos, then mixes them up and has the students reconstruct them.

The use of color here really highlights certain portions of the packet header. For example, the source and destination addresses and ports really jump out. But there are some other, more subtle color patterns that I worked in here. For example, if you look closely you’ll see that I matched the color of the ACK bit with the blue in the ACK number field. Similarly the colors of the SYN bit and the sequence number match, as do the URG bit and urgent pointer field.

Actually I wish I had a couple of more colors available. Yes, Lego comes in dozens of colors these days, but they only make 2×8 blocks (aka one “Lego Byte”) in six colors: White, Black, Red, Yellow, Blue, and Beige.

So while I tried to use Beige exclusively for size fields, Red for reserved bits, Yellow for checksums, and so on, I ultimately ended up having to use these colors for other fields as well– for example, the yellow sequence number fields in the TCP header. Maybe I should have just bought a bunch of “nibbles” (2×4 blocks) in other colors and not been so choosy about using full “Lego Bytes”.

Since 2010, the lego patent has expired and cheapish wire-extrusion 3D printing has become a reality -- and there's cool procedural models for generating arbitrary-sized bricks and labelling them with arbitrary type. Someone needs to make a printable TCP diagramming set on Thingiverse!

Practical, Visual, Three-Dimensional Pedagogy for Internet Protocol Packet Header Control Fields (via Hacker News)


  1. “Since 2010, the lego patent has expired and cheapish wire-extrusion 3D printing has become a reality — and there’s cool procedural models for generating arbitrary-sized bricks and labelling them with arbitrary type.”

    Wait wait what. Where’s the link?!? That’s more interesting than the actual story!

    1. It makes me a little sad.  This is one patent I wish wouldn’t expire.  If 3d printing really catches on and every kid can make his own legos, are the nice people in Denmark going out of business?

      1. Maybe, but probably not, for three reasons:

        1) Lego’s precision manufacturing tolerances are unbelievable. The difference between “too loose for a solid fit” and “too tight to easily snap on/off” can be as little as low as 10 micrometers. Competing products like Mega Blox just don’t fit as well, and they’re using the same steel mold technology as Lego. I’ve never heard of an affordable 3D printing technology that can get within two orders of magnitude of that. I thought from the article that Cory knew something I don’t, but if he’s talking about MakerBot-type filament extruders, I call bullshit. That particular technology will never be able to make Legos–you’d need a filament finer than spiderweb.

        2) Even if there were a home 3D printing system that could make Legos, it would probably be significantly more expensive (therefore not a real threat); even if it were significantly cheaper, Lego could simply switch to that manufacturing technology and cut their prices without losing profits.

        3) …Hang on, I’m not a patent guy, but Lego lost its court cases to stop Mega Bloks etc. decades ago. What does this patent expiration change? Anybody with the means was allowed to make custom “Lego” bricks already.

  2. The 8-bit scale seems worthy- if you’re not worried about pissing off the lego purists, glue together smaller more colorful bricks with ABS plumbing glue.

    -and if you *are* a lego purist, or care about not distracting them out of the lesson, put a 2×4 plate underneath your synthesized blocks.

    I may have to play along at home with this, I’ve got more bricks than I know what to do with.

    1. if you’re not worried about pissing off the lego purists

      He should be more worried about pissing off the TCP/IP purists. ☺

    1. my co-worker’s mother makes $87/hour on the laptop. She has been fired from work for ten months but last month her check was $19870 just working on the laptop for a few hours. Read more on  Zap22.c­om

    2. No. One Lego is a single block regardless of size. Multiple blocks (whether joined or not) are Legos. As for clay, it is infinitely divisible (at least down to the molecular level) and thus is always just “clay.”

          1. Because the Lego brand has more going for it than their legal IP. Their moulding process is still secret, and their toys are noticeably better than the competition. If Mega Blox or Best-Lock manage to create a toy with the same finish and *click*, then it’s all over for the Lego group.

    3. Po-tay-to, po-tah-to.

      (Yes, I know Lego doesn’t want me to say “Legos.” Lego does not in fact have any authority over English usage.)

        1. It’s a brand name. It’s questionable whether it’s in any language.

  3. This probably brands me as a huge nerd, but I would think that a 2×8 brick actually stores 16 bits of information, or two bytes. Each nub on a brick would be one bit.

    This is bad news because a TCP header only allows up to 60 bytes of information and this lego header is 80 bytes. The IEEE is going to run this guy over the coals.

  4. the 2 x 8 Lego bricks acome in much more colors than the ones mentioned , just look at Pick-A-Brick at the lego website

  5. Some MIT students were teaching Boston high school students chemistry with different colored Legos.

Comments are closed.