Internet Protocol (IP)
IP address gives you the ability to reach nodes on a network
IPv4 is a 32-bit (232) unique address.
IPv6 is a 1280bit (2128) unique address.
Addresses are written in dot notation (most popular) or hexadecimal notation.
192.168.5.2
IP Address Classes
IP addresses are divided into 5 groups
Class A
Class B
Class C
Class D
Class E
Classes D and E are reserved for multicast and experimental purposes. Each class has a valid range of IP addresses.
IPv4 addresses are divided into two parts
Network ID
Host ID
The class of an IP address is used to determine the number of bits used for the Network ID, and the Host ID, which ultimately determines the number of hosts on a network. It is the job of the network administrator to assign host IP addresses within a network. Network IP address ranges are assigned through IANA (Internet Assigned Numbers Authority).
Network classes binary encoding
The first octet of the entire 32-bit value is used to determine the class of network
You can use binary masking to determine the network class
This piece of code would show the conversion taking place
int ipAddress = 0xC0A80502; // 192.168.5.2
int subClass = ipAddress & 0xF0000000;
System.out.println( Integer.toBinaryString(subClass));
The classification systems allow us to partition networks into domains
Combining these two models together we get
So using the table able Class B network would provide 214 networks (16384), with 216-2 hosts (65534)