/
Sub-net masks

Sub-net masks

The Subnet mask reflects the network portion in an IP address

If you recall this previous diagram

Class A networks have a range of 27-2 = 126 networks (0.0.0.0, and 127.x.y.z are special addresses, and the MSB is the class identifier).

So if you apply a mask of 255.0.0.0 (0xff000000) you will be left with the Network ID

int ipAddress = 0x90A80502; // 121.168.5.2 int subClass = ipAddress & 0xFF000000; System.out.println( Integer.toBinaryString(subClass));

 

Class B networks have a range of 214 = 16384 networks (the first two MSB are the class identifier).

So if you apply a mask of 255.255.0.0 (0xff000000) you will be left with the Network ID

int ipAddress = 0x79A80502; // 185.168.5.2 int subClass = ipAddress & 0xFFFF0000; System.out.println( Integer.toBinaryString(subClass));

 

Related content