Appendix 6 – Addresses, masks and ports
IP address, network masks and ports are all closely linked in the quest for one device to find another across disparate network links.
IP addresses
As a rough analogy, consider how you use the telephone system. The phone number for Black Box in the US is
•1 connects from another country to the US,
•724 connects into Pennsylvania,
•746 selects the telephone exchange in Lawrence, and
•5500 is the unique code for Black Box within Lawrence.
The important parts of the whole number depend on where you are. If you were based in the same local area as Black Box in the US, there would be no point
in dialling out of the US, or even out of the area. The only part of the whole number that you are interested in is the final part: 5500.
In a similar way to the various parts of the telephone number, the four sections (or Octets) of every IP address have different meanings or “weights”. Consider the following typical IP address:
192.168.142.154
192 is the most global part of the number (akin to the 1 of the phone number) and 154 is the most local (similar to the 5500 unique local code of the phone number).
When two network devices communicate with each other, they always “dial the whole number” regardless of their respective locations in a network. However, they still need to know whether the other device is local to them or not, and this is where the net mask comes into play.
Net masks
The net mask (or
Taking the telephone number analogy given in the IP address section, in order to use the telephone system efficiently, it is vital for you to know your location relative to the person you are calling. In this way you avoid dialling unnecessary numbers.
When one network device needs to talk to another, the first thing that it will do is a quick calculation using its own IP address, the other device’s IP address and its own net mask. Suppose a device with address 192.168.142.154 and net mask 255.255.255.0 needed to communicate with a device at address 192.168.142.22. The sending device would perform several calculations:
1 | Sending | Destination |
|
|
192 168 142 154 | device IP | device IP | 192 168 142 22 | |
| address | address |
|
|
| Net mask |
|
| |
|
| 3 |
|
|
192 168 142 000 | Result |
| 192 168 142 000 | |
| 2 |
|
|
|
192.168.142.000 | = 192.168.142.000 ? | Answer: YES | ||
|
|
| 4 | Address |
|
|
|
| is local |
1 The net mask is used to determine the local and global parts of the sender’s IP address. Where there is 255 in the mask, the corresponding address slips through, where there is a 0, it is blocked.
2 Where the net mask was 0, the corresponding part of the result is also zero - this section is now known to be the local part of the IP address.
3 The same process is carried out for the destination address, again using the sender’s net mask. Now the local parts of both addresses have been equalized to zero, because their values are not important in determining whether they are both in the same local network.
4 The results of the two net mask operations are now compared, if they match, the destination is local. If not, then the sender will still use the same full destination IP address but will also flag the message to go via the local network gateway and out into the wider world.
The reason for doing this? It makes the network, as a whole, much more efficient. If every message for every recipient was shoved straight out onto the Internet, the whole thing would grind to a halt within seconds. Net masks keep local traffic just that - local.
Want to know more?
®
79