IP Addressing Fundamentals
IP address is a numeric identifier that is assigned to a device for communicate with other devices on a network. IP address consists of four decimal numbers which are separated by dots or decimal points. Hence, we call dotted-decimal notation. For example, 192.168.0.1 is an IP address written in dotted-decimal notation, but the binary version is 11000000 10101000 00000000 00000001 (IP address is stored as binary numbers). You will see how to convert between binary and decimal numbers later.Each decimal numbers of an IP address represents 8-bit (or 1 byte), and is therefore called an octet. Hence, an IP address represents 32-bit (or 4 bytes). The range of each octet is between 0 and 255 inclusively.
Classes of Networks
On this diagram, there are 2 networks: 10.0.0.0 and 192.168.0.0 which is separated by a router. At this time, you may want to know how can I know that 192.168.0.101 and 192.168.0.102 are on the same network. Or if I want to add new PC on 10.0.0.0 network, what are valid IP addresses that I can choose? The answer is about classes of networks.
An IP address can be divided in 2 parts, network and host. RFC 790 defines IP protocol, including network classes which are Class A, Class B, and Class C. TCP/IP defines Class D and Class E as well. See the table below for details on each class.
*The valid network numbers shows actual network numbers. There are several reserved cases. For example, network 0.0.0.0, originally defined for use as a broadcast address, and 127.0.0.0, reserved for loopback address. Network 22.214.171.124, 126.96.36.199, 192.0.0.0 and 188.8.131.52 also are reserved.
**There are 2 reserved host addresses per network: its network address and network broadcast address.
Network mask or NetMask is a 32-bit binary number, usually written in dotted-decimal format. Network mask defines the size of the host part of an IP address, representing the host part of the IP address with binary 0s in the mask. For example, class A mask has its last 24 bits as binary 0, which means that the last three octets of the mask are 0s. You can see the default masks on the table below.
|Class||Size of network part, in bits||Size of host part, in bits||Default mask|
Network address or network number is a number that uses dotted-decimal notation like IP addresses, but the number itself represents all hosts in a single Class A, B, or C IP network. For example, given an IP address 192.168.0.1 with network mask 255.255.255.0, the network address will be 192.168.0.0.
To calculate network address, we use logical AND operation between one IP address (any) in the network and its network mask. For example, an IP address 192.168.0.1 with network mask 255.255.255.0.
- Convert the IP address 192.168.0.1 to binary format, we get 11000000 10101000 00000000 00000001.
- Convert its network mask 255.255.255.0 to binary format, we get 11111111 11111111 11111111 00000000
- Do logical AND operation on two binary numbers, we get 11000000 10101000 00000000 00000000.
Note: A logical AND operation compares 2 bits. In each pair, the result is 1 if the first bit is 1 and the second bit is 1. Otherwise, the result is 0.
- Convert the result back to decimal, we get 192.168.0.0.
Broadcast Address or Direct Broadcast Address is an IP address which refers to all nodes on a network or subnet instead of a single node. For example, a network address 192.168.0.0 with network mask 255.255.255.0, the broadcast address is 192.168.0.255 which refers to 192.168.0.1 to 192.168.0.254. If you send a packet to 192.168.0.255, all nodes on this network (192.168.0.1 to 192.168.0.254) will get the packet.
To calculate broadcast address, we first do bit inversion on network mask and use logical XOR operation between the inverted network mask and network address. For example, an IP address 192.168.0.1 with network mask 255.255.255.0
- Convert network mask 255.255.255.0 to binary format, we get 11111111 11111111 11111111 00000000.
- Do bit inversion on the network mask, we get 00000000 00000000 00000000 11111111.
- Convert network address 192.168.0.0 to binary format, we get 11000000 10101000 00000000 00000000.
- Do logical XOR operation on two binary numbers, we get 11000000 10101000 00000000 11111111.
Note: A logical XOR (exclusive or) is a type of logical disjunction on two operands that results in a value of true if exactly one of the operands has a value of true. A simple way to state this is “one or the other but not both.”
- Convert the result back to decimal, we get 192.168.0.255.
You can see the example on the figure below:
Loopback address is a special IP address, usually 127.0.0.1. It is designated for the software loopback interface of a machine. The loopback interface has no hardware associated with it, and it is not physically connected to a network.
The loopback interface allows IT professionals to test IP software
without worrying about broken or corrupted drivers or hardware.