If a packet hits a pocket on a socket on a port,
And the bus is interrupted as a very last resort,
And the address of the memory makes your floppy disk abort,
Then the socket packet pocket has an error to report!
Rest can be found here. Below, we’ll go through how the internetz actually works, from switching on your computer to how to keep prying eyes out of your biznai with encryption and VPNs.
The internet is a series of tubes, as was famously remarked. More accurately it is a series of cables, buffers, timers and some really rather clever bits of engineering.
When stuff goes wrong on the internet you’ll see strange stuff like Timeout, Socket was Closed, Could not resolve host and so on. These are error messages that are bubbling up from the network and being reported in your browser. But how does the network work?
“The internet” is a shortening of TCP/IP which stands for Transport Control Protocol / Internet Protocol. It is part of the OSI seven layer networking stack , which is a way of turning the wires coming out of your computer into pictures of funny cats or rubber gimps on your screen, depending.
In days gone by you would have to have a modem in order to connect to the Internet, most people have broadband these days so I will write with this in mind. Even if you still have a modem, it still works the same, the main difference you’ll see is that a modem is not normally always on, as a broadband router normally is. Note that a modem only really provides one computer access to other computers; the box your ISP gives you is technically a modem/router so it is doing two jobs. The modem lets you talk to other computers outside your house, the router manages the network traffic so it gets to where it should go. I’ll just call this your router from here on.
Computers (or hosts as they are often called) don’t really talk in anything other than numbers. Strictly speaking, a computer can run several hosts at the same time but we don’t need to get into that here. There are lots of computers on the internet (and a lot of perverts too – headphones required for that link if you’re on a public or work machine) and they all need a way of uniquely identifying themselves. At each layer of the OSI stack there is a number that can be used to identify your internet connection, so as not to leak into other connections that may be happening at the same time.
This starts at the lowest level – the Network Interface Card, or NIC. These can be already installed inside your computer, or as USB dongles that you plug in. They can either be wired or wireless WiFi, which incidentally is not short for Wireless Fidelity, it is a trademarked term meaning IEEE 802.11x, where x is the subtype of the protocol. IEEE is the Institute of Electrical and Electronics Engineers and they set a lot of standards which affect the way the internet works.
The important thing at this point is that your NIC will have a number stamped into it called a Media Access Control address or MAC address for short. Every network capable device will have one of these and they will all be unique in the world. There are some clever bits of software out there that will allow you to edit this as it is transmitted (the original value is still burnt on to your circuit board though and can’t be changed) – this is known as a spoofed MAC.
For our purpose, we don’t need to worry about the different flavours of WiFi, but here is a good writeup if you’re interested. As WiFi is basically a radio signal it can be interfered with, eavesdropped and blocked.
Right now, we’ve got a means to connect to our router either through a cable or through a radio signal.
Given that there may be more than one computer connected to the router, we can’t just start blasting data down the connection as we’ll block other people trying to download cat pictures. So access to the network connection is rationed out into data packets – a little chunk of data. Each machine can send a packet at a time, which allows everyone to get a bit of their cat picture transferred at a time. The network stack will put these pieces back together before it can show you the kitty / gimp.
It all sounds pretty good so far: we have a cable to connect to the router, and we’re chunking our data up so we can share the connection. But at the minute, our packets are nameless and the router doesn’t really know us beyond our MAC address. We need another number to talk to other computers. What we will need is an Internet Protocol (IP) address.
An IP address is a series of numbers called a dotted quad. An example would be 188.8.131.52 – there are 4 dots separating numbers from 0 to 255.
Now, you could just get a random number and bung it in a dotted quad format but that’s pretty haphazard. This is where Dynamic Host Control Protocol comes in. A DHCP server is on your network, being run by your router. When it comes alive, your network device will send out a message asking for an Internet Protocol (IP) address. The DHCP server will assign one for you, out of a pool of special IP addresses that are used only for local traffic on the network.
Typically your local router will give you one beginning 10.x.x.x, 172.16.x.x, or 192.168.x.x. All internet machines know about these address ranges and will respect them. Your DHCP server in your router will keep a list of which MAC it has doled an IP address out to, and some routers will allow you to get dibs on a particular IP address – this is called a static IP address. An IP address is dotted like that as each part of the address has significance – it comprises a network address plus the actual address number by the computer itself (the host address). You can read a bit more about it herehttp://whatismyipaddress.com/ipv4-parts but you don’t really need to know the nitty gritty.
In recent years, we’ve actually started to run out of IPv4 addresses – each machine on the internet must have a unique address (excepting the internal IP addresses above, which are only for use on your local network) or the network will complain that someone else is using your IP address. To this end, IPv6 was created which supports a shitload more addresses and enables the Internet of Things – there’s enough spare capacity for your fridge to have an IPv6 address. We’re still going through a transition stage on the wider internet to enable this. Even the internet is getting in on transitioning!
This is all well and good, but so far you’re only talking to your own router. However, the initial chat that your network device has had with your router has already been replicated by your router with your internet provider’s routers – this is how your router gets on to the internet. Your ISP will provide a DHCP service to your router, which has its own MAC in turn, and the ISP router will manage your routers connection in much the same way as your router manages your network device’s connection. At this point you’re no longer on a local network, and you will now be assigned a “real” IP. Your ISP has dibs on a certain range of IP addresses, and it will dole one out to you – again this can be static or it can be dynamic. Some ISPs will charge you extra for having a static IP address as it’s a bit of a hassle making the reservation for you. Your router is on the internet on your behalf, and this IP address is what will be shown if you go to an IP address lookup website – this is also the IP address that websites will log, for the most part. It will be able to locate your approximate physical address as it knows which region the IP address your router belongs to, with varying degrees of accuracy depending on how the routers along the way are set up.
As this routing is being done, the network protocol has to start adding some routing information to the packet. The packet now has the originating local IP address (that you got from your router), plus the IP address it needs to be recognised on the wider network (that your router got from your ISP). You can imagine a packet being a bit like an onion – each layer of networking that the packet passes through, another skin is added to the outside of the packet so the internet knows where it came from. Right at the core is the actual data you want to send, outside is all of the guff that’s needed to get it moving.