Why are IPv4 addresses 32-bit

ipv4memoryprotocol-theory

Many moons ago, when I was just a wee bairn commencing my career, I had a job interview for a low-level developer role. Having at that time just learned how CIDR was implemented, I was keen to show off my knowledge.

Sadly, that tactic didn't work out too well for me. I recall being completely floored by the very first question that was asked (and, then ruffled, it all went downhill). The question was:

Why are IPv4 addresses 32-bit?

I readily admitted that I didn't know the answer, but I did know that the original protocol design divided the address space into an 8-bit network number and a 24-bit host identifier—so I tried to rationalise it on the grounds that the protocol designers imagined an Internet of a few networks (after all, it was originally intended to link together a specific few) each comprising many hosts and, for simplicity of programming, kept everything aligned to byte boundaries.

I recall the interviewer being unsatisfied with my answer and suggesting to me that the real reason is that it's guaranteed to fit inside a long int in C, so simplifies implementation details. Being young and green at the time, I accepted that as a reasonable answer and (before today) hadn't thought any more of it.

For some reason that conversation has just returned to me and, now that I reflect upon it, it doesn't seem entirely plausible:

  1. Under the original addressing scheme comprising fixed-size network and host fields, it's unlikely that a developer would have wanted to assign the concatenation of the two fields to a single variable (I don't have access to any early IP implementations to verify what they actually did in practice); and

  2. At the time that works on TCP/IP began, C was neither standardized nor the de facto "lingua franca" of low-level software development that it has become today.

Was the interviewer's suggestion actually founded in fact? If not, what were the real reasons that the protocol designers chose 32-bit addressing?

Best Answer

Here's a link to a Hangout with Vint Cerf (Apr. 2014) where he explains how he thought that this internet was supposed to be an experiment only:

As we were thinking about the Internet (thinking well, this is going to be some arbitrary number of networks all interconnected — we don't know how many and we don't know how they'll be connected), but national scale networks we thought "well, maybe there'll be two per country" (because it was expensive: at this point Ethernet had been invented but it wasn't proliferating everywhere, as it did do a few years later).

Then we said "how many countries are there?" (two networks per country, how many networks?) and we didn't have Google to ask, so we guessed at 128 and that would be 2 times 128 is 256 networks (that's 8 bits) and then we said "how many computers will there be on each network?" and we said "how about 16 million?" (that's another 24 bits) so we had a 32-bit address which allowed 4.3 billion terminations — which I thought in 1974/3 was enough to do the experiment!

I had already posted this as a comment to Jens Link's answer, but I felt it shoud surface a bit more.