Categories
Gushing About Tech

The Basics of Home Networking (or: Why IPv6 is Awesome)

I was getting excited over on Fedi about finally having native IPv6 support on my home Internet connection, no tunnels necessary, and after someone asked, that led into an explanation of the basics of IP addressing, NAT, port forwarding, and routers generally. It was a bit long to dump onto people’s timelines, but that sort of long-form infodump is exactly what I put this site up for, so here we go.

I’m going to try to keep the assumed level of knowledge low so as not to exclude anyone, so if you already know some of the basics, feel free to skip ahead a bit. Seriously, I won’t mind. Or even notice. I’m not even tracking how many people load these pages up, never mind actually read them.

IP Addresses: v4 and v6

Oh, wow, did you see what happened to my voice there? That was cool. I bet it had a dramatic echo and everything. I sound Authoritative and Well-Read with all these fancy Section Headings.

So why is any of this IP address stuff and all those other acronyms even important? Well, it all comes down to knowing where to send things.

The Internet runs on the Internet Protocol, appropriately enough. Everything on the Internet has an IP address, and data tagged with an IP address will go to that thing, wherever it is. Hence, address.

Most of the Internet you know runs on IPv4 – version 4 of the Internet Protocol. No one talks about versions 1, 2, or 3, and even mentioning them can draw the ire of the Elders of the Internet, and you do not want that kind of attention. Version 5 is likewise verboten.

(More seriously, versions 1-3 and 5 were experimental and never made it into the real world. I don’t know much about them.)

An IPv4 address is a 32-bit number, and that means there are about 4 billion of them in total. That sounds like a lot, right? Nope. Not even close to enough. The way addresses were allocated in the early days was massively wasteful, and even if they were distributed fairly, there are 7.8 billion people in the world. It’s hard enough sharing a postal address with someone else, and at least letters have your name on them.

No, I haven’t been reading your mail. I’m offended that you’d even ask.

Anyway, not enough IPv4 addresses. Clearly what we need is a bigger number so we can have more of them! And that’s all IPv6 is: 128-bit addresses so we can have more of them. So many that each one of those 7.8 billion people could have a few zillion IPv4 Internets of their own and not even use a fraction of a percent of what’s available.

Overkill? Maybe. But better than running out again. And we did run out of IPv4 addresses. Luckily, IPv6 was finalized in 1998, and following that was swiftly adopted worldwide and effectively solved the problem— ahahaha, no. About three quarters of all Internet traffic is still IPv4.

NAT: Network Address Translation

So how did the world actually deal with there not being enough IP addresses? Well, they learned to share. That’s called NAT.

This is something that almost all IPv4 routers do, and that’s (mostly) a good thing.

In the early days, everyone on the Internet had their own block of addresses that they could assign as they liked, but that hasn’t been true since 1990 or so, due to the address shortage I spent the entire previous section going on about.

What this means is that your router gets one and only one IP address that can be reached from the Internet. Any time you connect to something else out there through the router, you appear to be connecting from that one address, and when replies come back to you, the router keeps track of which connections belong to whom and send them to the right place. Hence, “router”.

So how do you connect in, to a specific device, when there isn’t already a connection from that device out? Like running a server? Well, that’s the problem with NAT. You more or less can’t. The router doesn’t know what to do with an incoming request with no context behind it.

Unless you tell it. And that’s where port forwarding comes in.

Port Forwarding (you want me to do what to my router?)

Almost all traffic on the Internet is either TCP or UDP, and while the specifics are a bit beyond the scope of what I’m talking about here, those protocols have a port number associated with them. Think of it like an extra number on the end of the IP address.

It’s like having your name on the letter. Because computers can do more than one thing, that port number is intended for the receiving computer to know which program should handle the incoming data.

But we can also make use of this when working with a NAT router. When a connection comes in on a specific port, a router can be configured to always send that on to one specific address on the internal network.

For example, you can have the router send everything on TCP port 80 (HTTP) to whichever computer is running your web server. Others on your home network can still browse the web, but unprompted external connections can be sent to that one server box.

So, if you know the port number the program you’re working with listens to, and the internal IP address of the computer running it, you can configure the router to send all the traffic for that program to that computer.

Notably, you cannot have two servers for the same thing running on the same network without doing some complicated shenanigans with proxies that I won’t go into. As much as I love a good shenanigan, this post is way too long as it is.

DHCP: Why It’s Not That Simple

Now, if it’s just a temporary thing for a game, you can find out your machine’s local IP address, plug it in, and off you go. Unfortunately, the nature of private Local-Area Networks means there’s a bit of extra work if you want a permanent server, and that’s because of DHCP.

Dynamic Host Configuration Protocol is how computers on a network get their IP addresses. When they connect to the network, or their current address expires, they send out a DHCP request to anyone who’ll listen.

Your router is also a DHCP server, which means it is listening for such broadcasts. When it gets one, it’ll assign the computer an IP address, usually in the 192.168.x.x range (though there are others) which is reserved for LANs like this. Such assignments are temporary – after a set period, usually 24 hours, the computer has to ask for its assignment to be renewed.

Most DHCP servers will try to keep a computer’s address consistent, but it’s best-effort only, and there is no guarantee the address will remain stable over time.

So if you’re running a permanent server on a private network, you need to assign it a static IP address in the router. That *does* guarantee that that computer will always receive the same address, and that no one else will ever have that address.

It makes sense on small home networks, but for bigger setups it can be a problem to permanently take an address out of service, as there are only 250 or so to go around on a given network due to the way IPv4 was designed.

Big company networks with more computers than that? Actually composed of several sub-networks that talk to each other through routers, which all just works because that’s what the Internet Protocol was designed to do without NAT getting in the way.

(Yes, I know CIDR with variable subnets is a thing, but that’s way above the level I’m going for in this post. Don’t worry about it.)

Wrapping It All Up

IPv6 was designed to make all of this unnecessary. There is no NAT in IPv6. There is no port forwarding in IPv6. There is a greatly reduced need for proxy shenanigans and subnetworks can be bigger than the entire IPv4 Internet.

So why aren’t we all using IPv6? Money.

IPv6 isn’t backwards-compatible with IPv4. What that means is that you need to run the two separate systems side by side until everyone’s on IPv6 and you can turn IPv4 off for good. You can run them on the same physical wires, but you need two completely different sets of software and, in some cases, switching hardware.

That’s more expensive than having a single IP system you can use for both, and NAT really doesn’t hurt most home users that much. I care because I’m running things on my home network that I want to be reachable from the Internet, but non-technical users don’t have any such need.

What that means is that people aren’t willing to pay for IPv6, so penny-pinching companies naturally don’t want to invest in setting them up.

What about companies that actually need lots of IP addresses to make things available on the Internet and would pay for IPv6? Well, aside from the fact that most of them already do support IPv6, they can also afford to buy blocks of IPv4 addresses at a premium.

Should You Care?

I can’t answer that. I do and I think I’m right to do so, but I’m not exactly your typical Internet user. I literally write blog posts about computer networking, as it turns out.

But if you’ve read this and decided that you should care, or at least want more information to decide if you do, the World IPv6 Launch site is a good place to start.

If not, don’t worry about it. There are more important things in this world to worry about than IP addresses. Look after yourself first.

Categories
Games Technical Difficulties

Heroes of Might and Magic 3 is a fine game that is far harder to get working than it should be

I’ve been playing Heroes of Might and Magic 2 recently. It’s one of the games I grew up with, and it holds many fond memories for me. It is also, as anyone following me on the Fediverse will know, how I discovered my lifelong fascination with griffins.

After a bit of that, today I decided to try and get Heroes of Might and Magic 3 running. While I strongly prefer Heroes 2’s aesthetic in most ways, Heroes 3 is mechanically the better game. If I could make Heroes 3 look like Heroes 2, I would be very happy indeed.

Now, getting Heroes 2 running was pretty easy, since it’s from 1996. Stick it into DOSBox and go. Heroes 3 was an entirely different matter. It came out in 1999, so it was Windows 9x native, and games of that era are often troublesome to get running on a modern system.

(As an aside, all these things are available on GOG and those folks already did all this work, but I’m not paying for these games again for the sake of a weekend’s nostalgia when I have my original CDs right here.)

First hurdle, the installer. It just didn’t work. Try running it and… nothing. Nothing at all. No window, no error message, not so much as a stray griffin feather. So out comes my first troubleshooting tool, Process Explorer, to see how far it gets.

Well. That’s not good. It’s just sitting there, not doing anything.

It turns out it’s an InstallShield installer, and those had a few quirks. For reasons I may go into another time, they use a 16-bit starter executable to bootstrap the main installer, and 16-bit support was dropped from 64-bit versions of Windows, which is all of them nowadays. The 32-bit launcher you can see there is trying to run the 16-bit one that’ll run the main 32-bit installer. But it failed, because my system can’t run 16-bit executables and it’s apparently just… sitting there, scratching its head.

After fruitlessly trying to unwrap and run the 32-bit installer I knew was buried in there, I eventually stumbled across a program called i5comp that some kind soul (thank you, fOSSiL, whoever you are!) wrote to access the InstallShield cab data format.

So, armed with this, I decompressed the game files and tried running it. To my great surprise, it actually started up first time, ran through the infuriatingly unskippable intro cinematic…

Good grief, what happened to your FACE? Oh, wait, it’s 1999 and that’s just what CG cutscenes looked like in those days.

…and dropped me to the main menu. Well, that was easier than I expected. That said, I like to play my games windowed these days, so I hit F4 (which was the standard key for this back then for some reason, except when it was alt-enter, ctrl-shift-f, or F11) and…

This game runs in 65536 color mode. You must switch the desktop to this mode before playing the game.

Oh. Well, that’s a problem. Does my current setup even support 16-bit colour mode on the desktop? It’s doing fine in full screen exclusive mode, but the other stuff I’m running might not take kindly to having the majority of its colour space taken away.

That was my immediate thought, anyway. Then I remembered that DxWnd exists. I haven’t had a lot of luck with it in the past, but it turns out that Heroes 3 is just undemanding enough that it wraps it up in a nice little window, no problem.

Then I scale the window up to 1200×900, disable the Windows cursor and off it goes!

Just look at that dragon. You only wish you looked this good.

That should have been it, but there was one more wrinkle. I load up a scenario, play my first turn, all goes well, but then it complains that it “can’t create save AUTOSAVE.CGM”. That’s not good. These games can run kind of long and I’m going to have problems if I can’t save.

This turned out to be because I hadn’t run the installer. Who could ever have thought that’d come back to bite me? Normally an installer does all sorts of nice things like creating the directory the save files will live in, and it’s unhappy because the place it wants to put its saves doesn’t exist.

So I go digging around to find out where saves are supposed to live. Fifteen minutes with DDG later, I find my way to a thread on the GOG forums in which someone else asked the same thing for a different reason. Seems it’s just a subdirectory inside the game’s main install directory (pretty common in 1999) called… “games”? I can sort of see it, but why games rather than saves?

Doesn’t matter. I create that and off we go, saves work just fine! Everything now works and I can get a game of Heroes 3 going!

…well, that was exhausting. I think I’m going to unwind with Minecraft a bit and come back to this later.

Categories
Meta

Hello world!

Wow, I have a blog? When did that happen? Who is responsible for this travesty?