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
For better understanding in IP addressing, let’s see a sample network diagram below.
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 220.127.116.11, 18.104.22.168, 192.0.0.0 and 22.214.171.124 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.
You can see the example on the figure below:
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.
thanks for this nice article.
I think there is a typo in the example figure about network address calculation. The binary representation of the subnet mask should be    
Thanks for pointing that, already fixed.
.A network mask or netmask .is used to divide an IP address.into a network address and a host address..When you set up a network .the network mask must be common to all.network interfaces on that network..The default network masks are 255.0.0.0 for class A .255.255.0.0 for class B .and 255.255.255.0 for class C networks as illustrated here ..Subnets are created.by extending the network ID portion of an address.by taking some bits from the host portion to create a subnet portion..The remaining bits can be used for host addresses within the subnet..The number of subnets that can be created from an m-bits long.subnet address is 2 m..The number of host addresses per subnet that are available.from an n-bits long host address is 2 n -2..Unlike the subnet portion of the network address .the host portion cannot consist of all 0s or 1s..See RFC 1812 and RFC 1878.for more information…The following figure illustrates the effect on a class B address.of extending a network mask from 255.255.0.0 to 255.255.255.0 . ..Subnetting a class B network.This scheme creates 256 2 8 possible subnet addresses. 0 through 255 with 254 2 8-2 host addresses 1 through 254 .per subnet.. .In this way you can create subnets for.class A and B networks by converting the.second and third octets respectively from host addresses to subnet.addresses.
Thanks for the information.