You are on page 1of 4

What is the Structure of an IP Address?

An IP (Internet Protocol) address is based on the numbers 0 to 255. The IP number has four parts, called octets. For example, 154.37, 39,
210, is an IP number. Each octet, can only use the numbers from 0 to 255.

Another feature of the IP number is that there are five classes that define what type of network the IP number resides in. Those classes
are:

0 – 126: Class A
128 – 191: Class B
192 – 223: Class C
224 – 239: Class D
240 – 255: Class E

Notice that the number 127 is not included; that is because it is a self reflecting number called a loopback address. Another factor is that
only three classes are used by network administrators: A, B and C. The other two, D and E are reserved.

One more thing. The Class that was mentioned above only applies to the first octet. This is important because in order to go from one
network to another, The Router, will only look at the first octet to determine where to forward the data.

What is a Router?
Think of a traffic light at an intersection. It directs traffic. It has red, amber and green lights. It also has directional signals. You can turn
right, or left, or stop, or go.
But it only directs traffic. That is what a router does; it directs traffic, in this case network traffic. It could be LAN traffic, WAN traffic or
Internet traffic.
You cannot put applications on a router; it just has an operating system designed for only one job: control traffic.
In relation to the subnet mask and the IP address. The router will look at the IP number, and decide if it is class A, B, C, D or E. From that
information, the router can direct the traffic to the proper location, defined by the subnet mask.

What is the Structure of a Subnet Mask?


The subnet mask also has only four octets. However, unlike the IP number, there are only certain numbers that can be used in the mask.
The numbers it can use are: 255, 254, 252, 248, 240, 224, 192, 128 and 0.
Here are three examples: 255.0.0.0 or 255.255.128.0 or 255.255.255.224.
These masks are used to define how many networks are available to the IP address. That is because each IP address is part of a network of
addresses.

What Is the Purpose of the Subnet Mask?


Think of the following: there are four buildings, each with their own address. One building has 32 floors, one has 16 floors, the two others
have 64 and 128 floors.
The address on one is 10.128.32.0; another is 175.88.245.0; 9.9.9.0 is the third; and 220.22.156.0 the fourth.
Each IP can have the same subnet mask as the others; or it can have a separate subnet mask from the others. But the important point is
that subnet mask is used to specify what “floor” the IP address is on. It will also specify how many “desks” are in that “floor.” In other
words, an IP address does not exist independently of other IP addresses, it is part of a network of similar IP addresses. That is what makes
it a network.
The IP network address identifies the “building,” but the subnet mask identifies the “floor” in the building; it can also specify how many
“desks” are on that “floor.”
That is the relationship between the mask and the IP address. They are not independent of each other.

How Does the IP Address Work with the Subnet Mask?


Make no mistake, working with a subnet mask is among the most complicated concepts in networking. This will give you an example.
Take the IP address 192.168, 45.61 with a subnet mask of 255.255.255.240. The math is intricate but there are 16 "floors" and in each floor
there are 16 "desks."
In network speak, there are 16 networks, and 16 hosts (i.e., computers) in each network.
The location of the IP address is important; it is located on the 4th network, with a network ID of 192.148.45.48. There are 16 addresses
starting with 192.168.45.48 and ending with 192.168.45.63.
This is only one of 16 networks. The rest are:

192.168.45.0
192.168.45.16
192.168.45.32
192.168.45.48
192.168.45.64
192.168.45.80
192.168.45.96
192.168.45.112
192.168.45.128
192.168.45.144
192.168.45.160
192.168.45.176
192.168.45.192
192.168.45.208
192.168.45.224
192.168.45.240
Summary

In networking, the subnet mask helps define where an IP number will appear in a network. The relation between the mask and the IP
number is intricate. Each needs the other to create a network of numbers.

Subnet Masks

To decide whether the source and destination hosts are on the same network looks easy: just make a comparison between the two
network IDs of the two addresses. For example consider the following two addresses:

Source 200.100.55.101
Destination 200.100.66.72

These are class C networks, so the source address has a network ID of 200.100.55.101, and the destination has network ID of
200.100.66.72. Thus they are on different networks. Or are they? One of the consequences of having no more class A and class B address
blocks is that many large corporations can handle their addressing needs only by obtaining multiple blocks of class C address. So it's
entirely possible that the 200.100.55.101 and 200.100.66.72 networks IDs belong to the same company and could therefore be part of the
same network! If so, IP should look at only the first two quads (200.100) to determine whether the address on the same network.

So how does IP know to compare the first one, two, or three quads? by using a subnet mask. A subnet is a subsection of a network that
uses related IP addressees. On a class C network, for example, you could define the first 127 addresses to be on one subnet and the second
127 addresses to be on another subnet. On a larger scale, from the point of view of the internet - which you think of as being the network-
each class A, B and C networks is a subnet.

The subnet mask is a 32-bit value that usually expressed in the same dotted-decimal notation used by IP addresses. The purpose of the
subnet mask is to let IP separate the network ID (or, as you saw in preceding example, part of the network ID) from the full IP address and
thus determine whether source and destination are on the same network

This table spells out the default subnet masks for each type of network class.

Network Subnet Mask Bit Value

Class A 255.0.0.0 11111111 00000000 00000000 00000000


Class B 255.255.0.0 11111111 11111111 00000000 00000000
Class C 255.255.255.0 11111111 11111111 11111111 00000000

When IP applies the subnet mask to an IP address, the part of that mask is all 0's strips off the corresponding section of the address.
consider the following example:

IP Address Mask Results


Source 205.208.113.2 255.255.255.0 205.208.113.0
Destination 205.208.113.50 205.208.113.50 205.208.113.0

The mask produces the same result, so these two addresses are on the same network. Now consider the example we used earlier. In this
case we need to use a nonstandard mask of 255.255.0.0:

IP address Mask Result


Source 200.100.55.101 255.255.0.0 200.100.0.0
Destination 200.100.66.72 255.255.0.0 200.100.0.0

How subnet Mask works ?


The operation of the subnet is a bit more complex. than we have let on. It's actually a two step processes. In the first step, the IP addresses
are both compared bit by bit with the subnet mask using a Boolean AND operation- if both are 1, a 1 returned; otherwise, a 0 is returned:

Source
205.208.113.2 11001101 11010000 01110001 00000010
255.255.255.0 11111111 11111111 11111111 00000000
Result of AND 11001101 11010000 01110001 00000000

Destination
205.208.113.50 11001101 11010000 01110001 00110010
255.255.255.0 11111111 11111111 11111111 00000000
Result of AND 11001101 11010000 01110001 00000000

Now the two results are compared bit by bit a Boolean Exclusive or (xoR) operation if the both bits are 0 or 1 , a 0 is returned; otherwise; a
1 is returned:

Source Result 11001101 11010000 01110001 00000000


Destination Result 11001101 11010000 01110001 00000000
Result of XOR 00000000 00000000 00000000 00000000

If the results of the xoR operation is all 0's, the source and destination are on the same network.
What is subnetting?

There is a scarcity of network addresses today. A viable solution to creating new network addresses is to divide the 32-bit address in a
process called subnetting. The process entails modifying the IP address by using the host (or client portion) address bits as network
address bits. A more technical evaluation is that a subnet mask is applied to filter the bits not used in the network address.

Subnetting is used when a company has more computers than can be connected to its network; it is also used as a traffic reduction
mechanism. However, all devices on the subnet must be programmed with the correct mask value in order for the network to function
properly.
To subnet an IP network, you use a subnet mask, which splits IP networks into subgroups of networks or subnetworks by filtering
unwanted bits so that only usable bits remain. Before using subnet masks, you must perform a decimal-to-binary conversion of the IP
address. A subnet mask identifies how the bits of an IP address are used. In binary terms, 0 and 1 are the only functional digits. In binary
notation, a 0 (zero) indicates that the bit is a host bit. A 1 (one) indicates that the bit is a network bit. A subnet mask defines the network,
the subnet, and the host.
The table below provides the default masks for IP address classes A to C.

What is Subnet Mask?


An IP address has two components, the network address and the host address. A subnet mask
separates the IP address into the network and host addresses (<network><host>). Subnetting
further divides the host part of an IP address into a subnet and host address
(<network><subnet><host>). It is called a subnet mask because it is used to identify network
address of an IP address by perfoming bitwise AND operation on the netmask.
A Subnet mask is a 32-bit number that masks an IP address, and divides the IP address into
network address and host address. Subnet Mask is made by setting network bits to all "1"s and
setting host bits to all "0"s. Within a given network, two host addresses are reserved for special purpose. The "0" address is assigned a
network address and "255" is assigned to a broadcast address, and they cannot be assigned to a host.
Examples of commonly used netmasks for classed networks are 8-bits (Class A), 16-bits (Class B) and 24-bits (Class C), and classless
networks are as follows:

Class Address # of Hosts Netmask (Binary) Netmask (Decimal)


CIDR /4 240,435,456 11110000 00000000 00000000 00000000 240.0.0.0
CIDR /5 134,217,728 11111000 00000000 00000000 00000000 248.0.0.0
CIDR /6 67,108,864 11111100 00000000 00000000 00000000 252.0.0.0
CIDR /7 33,554,432 11111110 00000000 00000000 00000000 254.0.0.0
A /8 16,777,216 11111111 00000000 00000000 00000000 255.0.0.0
CIDR /9 8,388,608 11111111 10000000 00000000 00000000 255.128.0.0
CIDR /10 4,194,304 11111111 11000000 00000000 00000000 255.192.0.0
CIDR /11 2,097,152 11111111 11100000 00000000 00000000 255.224.0.0
CIDR /12 1,048,576 11111111 11110000 00000000 00000000 255.240.0.0
CIDR /13 524,288 11111111 11111000 00000000 00000000 255.248.0.0
CIDR /14 262,144 11111111 11111100 00000000 00000000 255.252.0.0
CIDR /15 131,072 11111111 11111110 00000000 00000000 255.254.0.0
B /16 65,534 11111111 11111111 00000000 00000000 255.255.0.0
CIDR /17 32,768 11111111 11111111 10000000 00000000 255.255.128.0
CIDR /18 16,384 11111111 11111111 11000000 00000000 255.255.192.0
CIDR /19 8,192 11111111 11111111 11100000 00000000 255.255.224.0
CIDR /20 4,096 11111111 11111111 11110000 00000000 255.255.240.0
CIDR /21 2,048 11111111 11111111 11111000 00000000 255.255.248.0
CIDR /22 1,024 11111111 11111111 11111100 00000000 255.255.252.0
CIDR /23 512 11111111 11111111 11111110 00000000 255.255.254.0
C /24 256 11111111 11111111 11111111 00000000 255.255.255.0
CIDR /25 128 11111111 11111111 11111111 10000000 255.255.255.128
CIDR /26 64 11111111 11111111 11111111 11000000 255.255.255.192
CIDR /27 32 11111111 11111111 11111111 11100000 255.255.255.224
CIDR /28 16 11111111 11111111 11111111 11110000 255.255.255.240
CIDR /29 8 11111111 11111111 11111111 11111000 255.255.255.248
CIDR /30 4 11111111 11111111 11111111 11111100 255.255.255.252

Subnetting an IP network is to separate a big network into smaller multiple networks for reorganization and security purposes. All nodes
(hosts) in a subnetwork see all packets transmitted by any node in a network. Performance of a network is adversely affected under heavy
traffic load due to collisions and retransmissions.

Applying a subnet mask to an IP address separates network address from host address. The network bits are represented by the 1's in the
mask, and the host bits are represented by 0's. Performing a bitwise logical AND operation on the IP address with the subnet mask
produces the network address. For example, applying the Class C subnet mask to our IP address 216.3.128.12 produces the following
network address:
IP: 1101 1000 . 0000 0011 . 1000 0000 . 0000 1100 (216.003.128.012)
Mask: 1111 1111 . 1111 1111 . 1111 1111 . 0000 0000 (255.255.255.000)
---------------------------------------------
1101 1000 . 0000 0011 . 1000 0000 . 0000 0000 (216.003.128.000)

Subnetting Network
Here is another scenario where subnetting is needed. Pretend that a web host with a Class C network needs to divide the network so that
parts of the network can be leased to its customers. Let's assume that a host has a network address of 216.3.128.0 (as shown in the
example above). Let's say that we're going to divide the network into 2 and dedicate the first half to itself, and the other half to its
customers.
216 . 3 . 128 . (0000 0000) (1st half assigned to the web host)
216 . 3 . 128 . (1000 0000) (2nd half assigned to the customers)
The web host will have the subnet mask of 216.3.128.128 (/25). Now, we'll further divide the 2nd half into eight block of 16 IP addresses.

216 . 3 . 128 . (1000 0000) Customer 1 -- Gets 16 IPs (14 usable)


216 . 3 . 128 . (1001 0000) Customer 2 -- Gets 16 IPs (14 usable)
216 . 3 . 128 . (1010 0000) Customer 3 -- Gets 16 IPs (14 usable)
216 . 3 . 128 . (1011 0000) Customer 4 -- Gets 16 IPs (14 usable)
216 . 3 . 128 . (1100 0000) Customer 5 -- Gets 16 IPs (14 usable)
216 . 3 . 128 . (1101 0000) Customer 6 -- Gets 16 IPs (14 usable)
216 . 3 . 128 . (1110 0000) Customer 7 -- Gets 16 IPs (14 usable)
216 . 3 . 128 . (1111 0000) Customer 8 -- Gets 16 IPs (14 usable)
-----------------------------
255 . 255 . 255 . (1111 0000) (Subnet mask of 255.255.255.240)

CIDR - Classless Inter Domain Routing


Classless InterDomain Routing (CIDR) was invented to keep the Internet from running out of IP Addresses. The IPv4, a 32-bit, addresses
have a limit of 4,294,967,296 (232) unique IP addresses. The classful address scheme (Class A, B and C) of allocating IP addresses in 8-bit
increments can be very wasteful. With classful addressing scheme, a minimum number of IP addresses allocated to an organization is 256
(Class C). Giving 256 IP addresses to an organization only requiring 15 IP addresses is wasteful. Also, an organization requiring more than
256 IP addresses (let's say 1,000 IP addresses) is assigned a Class B, which allocates 65,536 IP addresses. Similarly, an organization
requiring more than 65,636 (65,634 usable IPs) is assigned a Class A network, which allocates 16,777,216 (16.7 Million) IP addresses. This
type of address allocation is very wasteful.

With CIDR, a network of IP addresses is allocated in 1-bit increments as opposed to 8-bits in classful network. The use of a CIDR notated
address can easily represent classful addresses (Class A = /8, Class B = /16, and Class C = /24). The number next to the slash (i.e. /8)
represents the number of bits assigned to the network address. The example shown above can be illustrated with CIDR as follows:

216.3.128.12, with subnet mask of 255.255.255.128 is written as


216.3.128.12/25

Similarly, the 8 customers with the block of 16 IP addresses can be


written as:

216.3.128.129/28, 216.3.128.130/28, and etc.

With an introduction of CIDR addressing scheme, IP addresses are more efficiently allocated to ISPs and customers; and hence there is
less risk of IP addresses running out anytime soon. For detailed specification on CIDR, please review RFC 1519. With introduction of
additional gaming, medical, applicance and telecom devices requiring static IP addresses in addition to more than 6.5 billion (July 2006
est.) world population, the IPv4 addresses with CIDR addressing scheme will eventually run out. To solve shortage of IPv4 addresses, the
IPv6 (128-bit) address scheme was introduced in 1993.

You might also like