96Appendix 6 – Addresses, masks and portsIP address, network masks and ports are all closely linked in the quest for onedevice to find another across disparate network links.IP addressesAs a rough analogy, consider how you use the telephone system. The phonenumber for Adder Technology in the UK is 0044 (0)1954 780044. This numberconsists of three distinct parts:• 0044 connects from another country to the UK• (0)1954 selects the main telephone exchange in the Bar Hill area ofCambridgeshire, and• 780044 is the unique code for Adder Technology within Bar Hill.The important parts of the whole number depend on where you are. If you werebased in the same local area as Adder Technology, there would be no pointin dialling out of the UK, or even out of the area. The only part of the wholenumber that you are interested in is the final part: 780044.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”. Considerthe following typical IP address:192.168.142.154192 is the most global part of the number (akin to the 0044 of the phonenumber) and 154 is the most local (similar to the 780044 unique local code ofthe phone number).When two network devices communicate with each other, they always “dial thewhole 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 thisis where the net mask comes into play.Net masksThe net mask (or sub-net mask) informs a device as to its own position within anetwork. From this it can determine whether any other device is within the samelocal network or is situated further afield.Taking the telephone number analogy given in the IP address section, in orderto use the telephone system efficiently, it is vital for you to know your locationrelative to the person you are calling. In this way you avoid dialling unnecessarynumbers.When one network device needs to talk to another, the first thing that it willdo is a quick calculation using its own IP address, the other device’s IP addressand its own net mask. Suppose a device with address 192.168.142.154 andnet mask 255.255.255.0 needed to communicate with a device at address192.168.142.22. The sending device would perform several calculations:The reason for doing this? It makes the network, as a whole, much moreefficient. If every message for every recipient was shoved straight out onto theInternet, the whole thing would grind to a halt within seconds. Net masks keeplocal traffic just that - local.Want to know more?1 The net mask is used to determine the local and global parts of the sender’s IPaddress. 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 - thissection 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’snet mask. Now the local parts of both addresses have been equalised to zero, becausetheir values are not important in determining whether they are both in the same localnetwork.4 The results of the two net mask operations are now compared, if they match, thedestination is local. If not, then the sender will still use the same full destination IPaddress but will also flag the message to go via the local network gateway and outinto the wider world.Sendingdevice IPaddressNet maskDestinationdevice IPaddress192.168.142.000 = 192.168.142.000 ? Answer: YESAddressis local12419219216816814214215400019219216816814214222000Result3