CTI Janus Programmable Automation Controller IOG
71
Using the Subnet Mask
For Class A, B, and C IP addresses, the IP Host uses the Subnet Mask to determine where to send an IP message.
After deriving the Network ID and Host ID portion of the IP Address using the Subnet Mask, the IP Host compares
the Network ID of the destination IP Address with the Network ID of the Host IP Address. If the Network IDs are
the same, the message is sent to another Host on the local network. If the Network IDs are different, the message
is sent to an IP Gateway, for routing to another network, if possible.
When you are configuring the IP Address of devices that must communicate on a local network, you must ensure
that:
•
The Subnet Mask of all devices is the same.
•
The Network ID of all hosts is the same.
•
The Host ID of each host is different.
If you are using Subnet Masks that are aligned with the IP Address octets, this can easily be done by examining the
dotted decimal values. The octets of the IP Address where the corresponding octet of the Subnet Mask is 255
belong to the Network ID and the octets of the IP Address where the corresponding octet of the Subnet Mask is 0
belong to the Host ID.
For example, where the IP Address is 127.18.40.3 with a Subnet Mask of 255.255.0.0, the Network ID is 127.18 and
the Host ID is 40.3.
IP Address
127
18
40
3
Subnet Mask
255
255
0
0
Network ID
127
18
Host ID
40
3
However, if you are using a Subnet Mask that does not align with the octet boundaries, this is more difficult. You
will need to perform a bitwise
“and”
calculation to arrive at the Network address. See the following illustration.
Assuming an IP Address of 127.18.40.3 and a Subnet Mask of 255.255.240.0, the following table illustrates the
bitwise “and” operation. In essence, wherever the
Subnet Mask bit is one, the corresponding IP Address bit is part
of the Network ID.
Item
Dotted
Decimal
Binary Equivalent
1
st
Octet
2
nd
Octet
3
rd
Octet
4
th
Octet
IP Address
127.18.40.3
01111111
00010010
0010
1000
00000011
Subnet Mask
255.255.240.0
11111111
11111111
1111
0000
00000000
Derived Network
Address
127.18.32.0
01111111
00010010
0010
0000
00000000
An easier way to determine this is to compare only non-aligned Subnet Mask octet with the corresponding octet of
the IP Address. For example, since the Subnet Mask of the first two octets is 255.255, the first two octets of the
Network ID are the same as the dotted decimal values (127.18) of the IP Address. However, since the third octet of
the subnet mask is not 255 or 0, you must perform a bitwise
“and”
calculation using the third octet of the IP
Address and Subnet Mask.