IP Addresses
IP addresses describe the whereabouts of anything in a computer network. It can be complex, but with the right metaphor it is quite easy to get a basic understanding.
Background
Just like in the real world, every host in a computer network requires a unique address in order to successfully receive and send data packages. Internet Protocol version 4 (IPv4) uses IP addresses with a length of 32 bits, written down in the CIDR annotation. Let's see how that works.
32 bits, essentially means a series of 32 times a 0 or a 1. That means that the first IP is:
0000 0000 0000 0000 0000 0000 0000 0000
The second IP is:
0000 0000 0000 0000 0000 0000 0000 0001
The third IP is:
0000 0000 0000 0000 0000 0000 0000 0010
And the fourth IP is:
0000 0000 0000 0000 0000 0000 0000 0011
etc, all the way to:
1111 1111 1111 1111 1111 1111 1111 1111
Because it is more convenient, IP addresses are not written down in binary, but is CIDR notation. This is how it works. First, the binary string is divided into 4 substrings of 8 bits (8 x a 0 or a 1), that are separated by a point.
00000000.00000000.00000000.00000000
Each of these substrings is converted to an integer. 00000000 would be a 0, 00000001 all the way up to 11111111 which is 255. This means that the first IPv4 address would be 0.0.0.0 and the last one is 255.255.255.255.
Subnet mask
In order to describe a subnet (or a range of IP addresses) the IPv4 standard uses a subnet mask. This basically 'freezes' the number of bits, counting from the beginning of the string. /32 for example, fixes all bits, /24 freezes just the first 24 bits, and /0 fixes no bits at all.
So if you write down 0.0.0.0/32 all bits are fixed, and your subnet consists of just 1 IP address. If you would write down 0.0.0.0/24 only the first 24 bits are frozen. Please see the binary notation below:
00000000 00000000 00000000 00000000
Since the first 24 bits are fixed, the biggest number we can make is 255, or in binary:
00000000 00000000 00000000 11111111
Translated back to CIDR, you are referring to:
0.0.0.0 - 0.0.0.255
Public IP address vs Private IP address
Generally speaking, there are two types of IP addresses; public and private IP addresses. Basically, it comes down to:
Is an IP used by a host on the internet: Public IP
Any other computer network: Private IP
But an important thing to note is that networks are connected to each other via gateways. Your WiFi network, for example, is a private network, that is connected to the internet. Your router has two IP addresses. One in the local WiFi network, and one for the internet and behaves as a gateway between these two networks.
Read more on public vs private IP addresses here.
Network Address Translation
Network address translation is the concept that an IP address in network A is translated by a gateway to another IP address in network B. It allows for internal network communication.
You could make a comparison to an apartment building. The street, number, ZIP, and city are globally unique, and the apartments have a number that is unique only to that building. The same goes for networks. If you would like to mail something to somebody across the street, you write down the public IP address of that building, after which it is sent to the correct apartment.
The same principle holds for computer networks. Your neighbor probably has a PC, that could have the same private IP address as your PC. However, your router and his router will have a unique public IP address.
If you were to send him a message, this will happen:
Your PC sends the message to the router
The router translates the sender's IP of the message to its own IP and forwards it to the neighbor's IP.
The neighbor's router will change the sender's IP to its own IP address and will forward it to the IP of your neighbor's PC.
Of course, it is a lot more complex, but it gives you an idea of how computer networks interact and how Network Address Translation (NAT) works.
Why is this important? Because on default, all SIM cards reside behind a NAT gateway. SIM cards are protected against any threats that the internet might hold. The NAT gateway only allows outbound traffic, to which servers on the internet are allowed to respond. But these servers can't initiate a data session themselves.
This is great for 99% of mobile use cases, but in IoT, you might want to contact, or configure your device remotely, so you want to be able to initiate a data session.
Read more on public vs private IP addresses here.
Further reading
Some great stuff can be found here:
Last updated