Parts of an IP address
An IP address is split into a network identifier part and a host identifier part. The more bits that are used for the network identifier, the less host bits are available and vice versa. There are 2 reserved host identifiers
on a network all 0s and all 1s which mean the formula to calculate the number of hosts available is 2n - 2 where n is the number of bits used for the host.
Classful v classless addressing
Classful addressing had various classes, each of which had a set number of bits for the network ID and host ID. Classless addressing includes the number of bits for the network after a slash e.g. 124.34.67.213/16 which would
indicate that 16 bits were being used for the network ID.
Subnet Masks
A subnet mask is used to identify the network identifier part of the IP address. A subnet mask is a 32 bit number with as many 1s as the number of bits used for the network ID followed by 0s. A logical AND is performed between
the IP address of a sender and the subnet mask and again between the IP address of the recipient and the subnet mask to see if they are on the same network.
Subnets
Networks can be divided into subnets. A further subnet ID is added to divide a large network into smaller subnets. To establish if two devices are on the same subnetwork we and both IP addresses with a mask of the length of
the Network ID and Subnet ID together. This is still referred to as a subnet mask.
Using subnets can increase efficiency on a large network. Two computers on one subnet can communicate at the same time as two computers on
another subnet without risk of collisions. It also increases security on bus networks by limiting the number of devices a message is broadcast to.
IPV4 & IPV6
IPV4
Although generally represented as four decimal numbers between 0 and 255 e.g. 10.165.204.34, IPV4 numbers are really 32 bit binary numbers. This means there are 232 or 4,294,967,296 possible addresses. It seems
like a lot. But with the increasing popularity of the internet of things i.e. devices connected to the internet, we were starting to run out of IPV4 addresses and a solution needed to be found.
IPV6
Although generally represented as 32 hexadecimal digits e.g. 2001:0ab8:85a2:0000:0000:8a3e:0370:7334, IPV6 numbers are really 128 bit binary numbers. This means there are 2128 possible addresses. This is a very large
number. There would be 3 digits in the number of addresses we can create with IPV6. This is unlikely to run out any time in the forseeable future.
Public and private IP addresses
All devices connected directly to the internet need a unique public IP address. Devices on an internal network can be given a private IP address that only needs to be unique on that network. The router for a network can make
external requests on behalf of internal devices and return them to the appropriate device using network address translation.
If you look at the subnet diagram above you will notice that the external router has both a public and
private IP address. Devices on the network have just private IP addresses. Devices still need to check if they are on the same network as another device they wish to communicate with. It is therefore imortant that private IP ranges
do not match public ones. For this reason most private networks start 10. or 172. or 192.
DHCP
Dynamic host configuration protocol is used to allocate a temporary IP address from a pool of available addresses when a client wants to access a network. This IP address is then returned to the pool and available for another
device when the first device disconnects. This is useful for public wireless access points.
Network address translation (NAT)
The router which connects the internal network with the internet is responsible for network address translation. When a client on the internal network requests a web page it is sent to the router. The router makes note of the
IP address and port number and swaps these for its own IP address and a unique port number. When a response is received to that unique port number, the router checks it's tables to see which IP address and port on the internal
network to send it to and forwards it on to the correct recipient.