There is considerable confusion with regards to the way that IP addresses, network masks, broadcast addresses and network numbers are related. Even the standard reference on TCP/IP networking does not discuss the topic with reference to the commands which can be issued in UNIX to see the results of configuration changes. This treatise will attempt to eliminate the confusion.
An important basis for the discussion is the representation of numbers in different bases. The binary system uses a base of 2, the octal system uses 8, decimal uses 10, and hexadecimal uses 16. The base of the numbering systems specifies the number of unique symbols which are used to represent numbers. The octal system, for example, uses a base of 8 and the 8 symbols used to represet octal numbers are: 0, 1, 2, 3, 4, 5, 6, and 7.
The digits of a number using any base are multiplied by the the base of the system raised to the power of the digit number, starting at 0 and increasing from right to left. As an example, the number 12310 (base 10) is equal to ( 1 x 102 ) + ( 2 x 101 ) + ( 3 x 100 ), or ( 1 x 100 ) + ( 2 x 10 ) + ( 3 x 1 ), or 123 decimal.
Similarly, the number 12348 (base 8, or octal) is equal to ( 1 x 83 ) + ( 2 x 82 ) + ( 3 x 81 ) + ( 4 x 80 ), or ( 1 x 512 ) + ( 2 x 64 ) + ( 3 x 8 ) + ( 4 x 1 ), or 668 decimal. The number 110102 (base 2, or binary) is equal to ( 1 x 24 ) + ( 1 x 23 ) + ( 0 x 22 ) + ( 1 x 21 ) + ( 0 x 20 ), or ( 1 x 16 ) + ( 1 x 8 ) + ( 0 x 4 ) + ( 1 x 2 ) + ( 0 x 1 ), or 26 decimal. Note that any number raised to the power of 0 is 1 and any number raised to the power of 1 is itself, i.e. 160 = 1, 161 = 16.
The IP address consists of a 32 bit quantity which consists of two parts: the network number and the host number. IP addresses are usually written in the "dotted-decimal" format consisting of four decimal numbers separated by periods. In this format, each decimal number represents 8 bits of the address. Thus, an IP address of 188.8.131.52 would correspond to the binary number 10011111111110010111100100111100.
The netmask is simply a bit-mask which specifies which part of an IP address is used for the network number and which part is used for the node number. When the normal version of the netmask is AND'ed with an address, what remains is the network number. When the inverse of the netmask is AND'ed with the address, what remains is the node number. Here is an example:
IP address: 184.108.40.206 Netmask: 255.255.255.0 IP address: 10011111111110010111100100111100 Netmask: 11111111111111111111111100000000 Network #: 10011111111110010111100100000000 IP address: 10011111111110010111100100111100 ~Netmask: 00000000000000000000000011111111 Node #: 00000000000000000000000000111100
In this example we have used the C-language notation of ~ to indicate the inverse (or logical NOT) function. Converting the network number back to dotted-decimal format gives 220.127.116.11. The most important function of the subnet mask is to determine if an IP address is "local" to a network or "foreign". Local addresses can be reached directly on the local network while packets destined for a foreign addresses will have to be forwarded through an intermediate address.
To demonstrate this mechanism, imagine a host with a network address of 18.104.22.168 and a netmask of 255.255.0.0 (standard for a class B address, as we'll see later.) Now imagine a local application sending two packets; one to 22.214.171.124 and another to 126.96.36.199. We will and the local address and the detination address of the two packets and show the results.
IP address: 10010001010011100001011100000010 (188.8.131.52) Netmask: 11111111111111110000000000000000 (255.255.0.0) Network #: 10010001010011100000000000000000 (184.108.40.206) IP address: 10010001010011100001011100001010 (220.127.116.11) Netmask: 11111111111111110000000000000000 (255.255.0.0) Network #: 10010001010011100000000000000000 (18.104.22.168) IP address: 10011111111110010111100101000110 (22.214.171.124) Netmask: 11111111111111110000000000000000 (255.255.0.0) Network #: 10011111111110010000000000000000 (126.96.36.199)
Since the network number of the 188.8.131.52 address does not match the network number of the local address, we know that this is destined for a foreign network. Various routing protocols specify how routing information can be exchanged among hosts on the internet. Open Shortest Path First (OSPF) and Border Gateway Protocol (BGP) are two common examples. Some TCP/IP implementations do not support any routing protocol and only permit the specification of a default address to send foreign packet through.
One of the base concepts of IP addressing is the use of address classes. The original network classes were designed to permit a flexible mechanism for building networks with differing numbers of hosts. Some sites with connection to the internet would have a small number of hosts while others would have a much larger host population. Associated with each class of address is a standard netmask. The following diagram shows the standard IP address classes.
|Address Class||First bits of address||Netmask|
Assignment of IP addresses for organizations wishing to connect to the internet is performed by the Network Information Centre. Organizations can request which address class they require, with consideration being given to the total expected number of hosts expected to exist on the network. While a large organization such as IBM might be assigned a class A address class, mid-sized organizations will typically request and be assigned a class B address.
Internet access providers, such as UUNET, typically specify the addresses which will be used by their customers. An organization administering their own address domain can specify the addresses used by each sub-network connected to the corporate backbone. In order to break an address range into smaller groups, we use a mechanism known as sub-netting.
While we previously mentioned the "typical" values of the network mask based on address class, it is perfectly acceptable to use additional bits of the address to indicate the host and network portions of the IP address. It is important to remember that we are sub-netting the address assigned by the NIC and must use a netmask of at least the value shown in the table.
Since the bits in the netmask which indicate the network portion of an address must be contiguous, we allocate additional bits to be used as the netmask from left to right. The following table shows the number of bits used for the submask, the binary representation, and the dotted-decimal representation.
|Number of bits||Binary netmask||Dotted-decimal netmask|
The dotted decimal values for other configurations can be determined through use of the mathematical concepts discussed earlier. It is significant that a network can be variably subnetted. We could for example have one network with a network address of 184.108.40.206 and a subnet mask of 255.255.255.128 and two networks, 220.127.116.11 and 18.104.22.168, with a netmask of 255.255.224.0.
IP address: 10011111111110010000000000000000 (22.214.171.124) Netmask: 11111111111111111000000000000000 (255.255.255.128) Network #: 10011111111110010000000000000000 (126.96.36.199) IP address: 10011111111110001000000000000000 (188.8.131.52) Netmask: 11111111111111111100000000000000 (255.255.255.224) Network #: 10011111111110001000000000000000 (184.108.40.206) IP address: 10011111111110000100000000000000 (220.127.116.11) Netmask: 11111111111111111100000000000000 (255.255.255.224) Network #: 10011111111110000100000000000000 (18.104.22.168)Let's take a look at each of these networks and see how they handle packets destined for the other subnets. We’ll start with the 22.214.171.124 network and send packets to 126.96.36.199 and 188.8.131.52.
IP address: 10011111111110000010000000000001 (184.108.40.206) Netmask: 11111111111111111000000000000000 (255.255.255.128) Network #: 10011111111110000000000000000000 (220.127.116.11) IP address: 10011111111110000010000000000010 (18.104.22.168) Netmask: 11111111111111111000000000000000 (255.255.255.128) Network #: 10011111111110000000000000000000 (22.214.171.124)
In both cases we can see that the resulting network number is not the local network number and so the packets would have to be forwarded to another network. Here is the example for the 126.96.36.199 network with netmask 255.255.255.224 and destination addresses of 188.8.131.52 and 184.108.40.206
IP address: 10011111111110001000000000000011 (220.127.116.11) Netmask: 11111111111111111110000000000000 (255.255.255.224) Network #: 10011111111110001000000000000000 (18.104.22.168) IP address: 10011111111110000010000000000010 (22.214.171.124) Netmask: 11111111111111111110000000000000 (255.255.255.224) Network #: 10011111111110000010000000000000 (126.96.36.199)
Once again, we can determine that the destination IP addresses are non-local. Finally, please refer to the document NOC IP AND IPX ROUTING for additional information regarding the configuration of Proteon and Cisco IP interfaces.
Copyright © 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 by Phil Selby