CCN - Lab - 05. & 06
CCN - Lab - 05. & 06
CCN - Lab - 05. & 06
Lab # 5& 6
IP Address
An Internet Protocol (IP) address is a numeric label consisting of a 32 bit number assigned to a network
capable device that uses IP for communication. The address fundamentally serves two purposes:
location addressing and computer host or network interface identification. The address indicates where
the connected device resides with the majority of hosts/devices still using the IPv4 (Internet Protocol
Version 4) form of addressing. A significant limitation of the legacy IPv4 addressing is that it supports
less than 4.3 billion total addresses. Based on the rapid growth of the Internet and related technologies,
the use of IPv4 is not sustainable for the long term. In the mid-1990’s, the new IPv6 technique was
developed which makes use of 128 bits for the IP address. IPv6 technology continues to be deployed,
albeit slowly. The Internet Assigned Numbers Authority (IANA) is responsible under the IETF for
management of the IP address space allocation globally. Beneath the IANA, there are five regional
Internet registries (RIRs) that are responsible for allocating IP address blocks to Internet service
providers (ISPs) and other trusted organizations.
IP Address Classes
There were five IP address classes in use before the majority of industry switched to classless routing.
There were A, B, C, D, and E. Class A addresses were used for networks with a very large number of total
hosts. Class B was designed for use on medium to large networks, and C for small local area networks
(LANs). Class D and E were set aside for multicast and experimental purposes. In the following table, the
four octets that make up an IP address (a, b, c, and d respectfully) are displayed in how they were
distributed in classes A, B, and C.
Classes A, B, and C.
A a.b.c.d a b.c.d
C a.b.c.d a.b.c d
Class A IP addresses were used for networks that had a large number of hosts on the network. The class
permitted up to 126 networks by using the first octet of the address for the network identification. The
first bit in this octet was always fixed or set to be zero. The following seven bits in the octet were then
set to one which would complete the network identification. The remaining octets (24 bits) represented
the hosts ID and would allow up to 126 networks with 17 million hosts per network. In a Class A address,
the network number values start at the number 1 and end at 127.
Class B IP Address
Class B IP address were assigned to medium to large networks. They allow 16,384 networks by using the
first two octets in the address for the network identification. The first two bits of the first octet are fixed
to 1 0. The next 6 bits along with the following octet then complete the network identification. The third
and fourth octet (16 bits) then represents the host ID. This allows approximately 65,000 hosts per
network. Class B network number values start at 128 and finish at 191.
Class C IP Address
Class C IP addresses were used in small LAN configurations. They allow for approximately 2 million
networks by using the first three octets of the address for the network identification. In a Class C
address, the first three bits are fixed to 1 1 0. In the following three octets, 21 bits make up the network
identification. The last octet then represents the host identification. This allows for 254 hosts per
network. A Class C network number value starts at 192 and ends at 223.
Class D IP Address
Class D IP addresses were reserved for multicasting purposes. These addresses begin with an octet in
the 224-239 range. They would have leading bits of 1 1 1 0 and includes addresses from 224.0.0.0 to
239.255.255.255.
Class E IP Address
Class E IP addresses are reserved for experimental use. The first octet of these addresses ranges
between 240 and 255. This range is reserved by the IETF and similar to Class D networks, should not be
assigned to a host device.
Private IP Addresses
While we are used to writing out streets and house numbers on envelopes, inside your computer IP
Addresses are usually represented in what is known as dotted-decimal format such as 124.62.112.7 as
this is the system that is understood by computers. As you can see, the address is split into 4 sections
known as "octets" and each of the four octets can be numbered from 0-255, providing a total of
4,294,967,296 potentially unique IP Addresses.
Now, while 4.2 Billion might seem like a lot, for many years large amounts of these have been allocated
and used by large network such as backbone providers, ISPs and large Universities that made up the
early Internet While other groups still have been reserved for special purposes and are not usable, so in
practice the real amount is far less than 4.2 billion. The problem that we face today is that with many
homes owning more than one computer and with cell phones, PDAs and even fridges being enabled for
Internet access these days, IP Addresses are running out.
When I mentioned above that some blocks of addresses had been reserved for special purposes, one of
these purposes was for private networking and it is these private addresses that help to relieve the
pressure on the remaining address space and make possible many of the cable and DSL routers that
people have at home today to share their Internet connection amongst many PCs.
10.0.0.0 - 10.255.255.255
Addresses: 16,777,216
172.16.0.0 - 172.31.255.255
Addresses: 1,048,576
192.168.0.0 - 192.168.255.255
Addresses: 65,536
Classless IP Addressing
After the invention of the Domain Name System (DNS), industry realized that the use of IP address
classes would limit the scalability of the Internet. As a result, the IETF published RC 1518 and 1519 in
1993 to define the classless method of routing IPv4 data packets. The most recent definition of the
standard occurred in 2006 under RFC 4632. Classless IP addressing was introduced as a more efficient
means to make use of the IP address space when compared to Classful addressing. In classless
addressing, the IP address is treated as a 32 bit stream where the boundary between the network
identification and host can be at any of the bit positions. The network portion of the address is
determined by the number of 1’s that are in the subnet mask being applied to the address. A subnet
mask is used locally on the hosts connected to the network and are never transmitted in an IPv4 data
packet or datagram. All of the hosts on the same network are configured to use the same subnet mask
with the host section of the IP address being unique to the host. The classless version of address is
referred to as Classless Inter-Domain Routing (CIDR) and allows networks to be divided into different-
sized subnets. The system avoids wasting IP addresses through the use of the subnet mask.
The network Class helps us determine how the 4 byte, or 32 Bit, IP Address is divided between network
and node portions.
The figure below shows you (in binary) how the Network ID and Node ID changes depending on the
Class:
Explanation:
The figure above might seem confusing at first but it's actually very simple. We will take Class A as an
example and analyze it so you can understand exactly what is happening here:
Now, even though we have 3 Classes of IP Addresses that we can use, there are some IP Addresses that
have been reserved for special use. This doesn't mean you can't assign them to a workstation but in the
case that you did, it would create serious problems within your network. For this reason it's best that
you avoid using these IP Addresses.
The following table shows the IP Addresses that you should avoid using:
IP Address Function
Network 0.0.0.0 Refers to the default route. This route is to simplify routing tables used by IP.
Reserved for Loopback. The Address 127.0.0.1 is often used to refer to the local host.
Network 127.0.0.0
Using this Address, applications can address a local host as if it were a remote host.
IP Address with all IP Addresses with all node bits set to "1" are local network broadcast addresses and
node bits set to "1" must NOT be used.
(Subnet / Network
Broadcast) e.g Some examples: 125.255.255.255 (Class A) , 190.30.255.255 (Class B), 203.31.218.255
192.168.255.255 (Class C). See "Multicasts" & "Broadcasts" for more info.
The IP Address with all bits set to "1" is a broadcast address and must NOT be used.
IP Address with all bits
These are destined for all nodes on a network, no matter what IP Address they might
set to "1" (Network
Broadcast) e.g have.
255.255.255.255
Subnet Masking
Applying a subnet mask to an IP address allows you to identify the network and node parts of the
address. The network bits are represented by the 1s in the mask, and the node bits are represented by
the 0s. Performing a bitwise logical AND operation between the IP address and the subnet mask results
in the Network Address or Number.
For example, using our test IP address and the default Class B subnet mask, we get:
--------------------------------------------------------
Additional bits can be added to the default subnet mask for a given Class to further subnet, or break
down, a network. When a bitwise logical AND operation is performed between the subnet mask and IP
address, the result defines the Subnet Address (also called the Network Address or Network Number).
There are some restrictions on the subnet address. Node addresses of all "0"s and all "1"s are reserved
for specifying the local network (when a host does not know its network address) and all hosts on the
network (broadcast address), respectively. This also applies to subnets. A subnet address cannot be all
"0"s or all "1"s. This also implies that a 1 bit subnet mask is not allowed. This restriction is required
because older standards enforced this restriction. Recent standards that allow use of these subnets have
superseded these standards, but many "legacy" devices do not support the newer standards. If you are
operating in a controlled environment, such as a lab, you can safely use these restricted subnets.
To calculate the number of subnets or nodes, use the formula (2n-2) where n = number of bits in either
field, and 2n represents 2 raised to the nth power. Multiplying the number of subnets by the number of
nodes available per subnet gives you the total number of nodes available for your class and subnet
mask. Also, note that although subnet masks with non-contiguous mask bits are allowed, they are not
recommended.
Example:
You can calculate the Subnet Address by performing a bitwise logical AND operation between the IP
address and the subnet mask, then setting all the host bits to 0s. Similarly, you can calculate the
Broadcast Address for a subnet by performing the same logical AND between the IP address and the
subnet mask, then setting all the host bits to 1s. That is how these numbers are derived in the example
above.
Subnetting always reduces the number of possible nodes for a given network. There are complete
subnet tables available here for Class A, Class B and Class C. These tables list all the possible subnet
masks for each class, along with calculations of the number of networks, nodes and total hosts for each
subnet.
Here is another, more detailed, example. Say you are assigned a Class C network number of
200.133.175.0 (apologies to anyone who may actually own this domain address). You want to utilize this
network across multiple small groups within an organization. You can do this by subnetting that network
with a subnet address.
We will break this network into 14 subnets of 14 nodes each. This will limit us to 196 nodes on the
network instead of the 254 we would have without subnetting, but gives us the advantages of traffic
isolation and security. To accomplish this, we need to use a subnet mask 4 bits long.
Recall that the default Class C subnet mask is
A address blocks, which contain over 16 Million host addresses! Only a tiny percentage of the allocated
Class A and Class B address space has ever been actually assigned to a host computer on the Internet.
People realized that addresses could be conserved if the class system was eliminated. By accurately
allocating only the amount of address space that was actually needed, the address space crisis could be
avoided for many years. This was first proposed in 1992 as a scheme called Supernetting. Under
supernetting, the classful subnet masks are extended so that a network address and subnet mask could,
for example, specify multiple Class C subnets with one address. For example, If I needed about 1000
addresses, I could supernet 4 Class C networks together:
In this example, the subnet 192.60.128.0 includes all the addresses from 192.60.128.0 to
192.60.131.255. As you can see in the binary representation of the subnet mask, the Network portion of
the address is 22 bits long, and the host portion is 10 bits long.
Under CIDR, the subnet mask notation is reduced to a simplified shorthand. Instead of spelling out the
bits of the subnet mask, it is simply listed as the number of 1s bits that start the mask. In the above
example, instead of writing the address and subnet mask as
192.60.128.0/22
which indicates starting address of the network, and number of 1s bits (22) in the network portion of
the address. If you look at the subnet mask in binary (11111111.11111111.11111100.00000000), you
can easily see how this notation works.
The use of a CIDR notated address is the same as for a Classful address. Classful addresses can easily be
written in CIDR notation (Class A = /8, Class B = /16, and Class C = /24)
It is currently almost impossible for an individual or company to be allocated their own IP address
blocks. You will simply be told to get them from your ISP. The reason for this is the ever-growing size of
the internet routing table. Just 10 years ago, there were less than 5000 network routes in the entire
Internet. Today, there are over 100,000. Using CIDR, the biggest ISPs are allocated large chunks of
address space (usually with a subnet mask of /19 or even smaller); the ISP's customers (often other,
smaller ISPs) are then allocated networks from the big ISP's pool. That way, all the big ISP's customers
(and their customers, and so on) are accessible via 1 network route on the Internet. But I digress.
It is expected that CIDR will keep the Internet happily in IP addresses for the next few years at least.
After that, IPv6, with 128 bit addresses, will be needed. Under IPv6, even sloppy address allocation
would comfortably allow a billion unique IP addresses for every person on earth! The complete and gory
details of CIDR are documented in RFC1519, which was released in September of 1993.
There are a wide range of techniques people use to work out their network, host and broadcast
addresses. I prefer to take the binary approach as I find it the quickest and easiest method, and is never
wrong.
Remember, the four most important things to know about a subnet is the following:
a. Network Address:
b. First Usable Address:
c. Last Usable Address:
d. Broadcast Address:
Let's say for example, we were given the IP address 195.70.16.159 and told that it is in a /30. This is how
I'd go about filling in the template above.
First of all, as IP addresses are 32 bits long, and each octet is 8 bits in length, we know that:
So, as this subnet address has 30 bits in it, we know we're dealing with the fourth octet.
Now, because know bits 25 to 30 are subnet bits (referred to as SN below), we also know that the
remaining two bits are host bits (referred to H below). Here is what it looks like when written down:
25 26 27 28 29 30 31 32
SN SN SN SN SN SN H H
x x x x x x x x
128 64 32 16 8 4 4 1
SN SN SN SN SN SN H H
x x x x x x x x
Now, let's replace the x's with the value of the fourth octet in the address, which in this case, is 159.
128 64 32 16 8 4 4 1
SN SN SN SN SN SN H H
1 0 0 1 1 1 1 1
Now to find out the network address all we do is add the SN bits that have a 1 underneath them,
together. (128 + 16 + 8 + 4 = 156).
When you add this 156 to the first three octets of the address, we're left with the Network Address
195.70.16.156.
Now, as we know that the first usable address is always the Network Address plus one, all we need to do
is perform the following calculation: (156 + 1 = 157).
Now let's skip the Last Usable Address for a moment and find the Broadcast Address. To find out what it
is, all we need to do is add all of the H bits together (regardless of whether they are a 1 or a 0) and then
add this number to the Network Address. (2 + 1 + 156 = 159).
And finally, let's work out the last usable address. This process is similar to finding the First Usable
Address, however, instead of adding one to the network address, we actually subtract one from the
Broadcast Address. (159 - 1 = 158).
An ISP is granted a block of addresses starting with 190.100.0.0/16 (65,536 addresses). The ISP needs to
distribute these addresses to three groups of customers as follows:
Design the sub blocks and find out how many addresses are still available after these allocations.
Solution:
Group 1
For this group, each customer needs 256 addresses. This means that 8 (log2 256) bits are needed to
define each host. The prefix length is then 32 − 8 = 24. The addresses are
Group 2
For this group, each customer needs 128 addresses. This means that 7 (log2 128) bits are needed to
define each host. The prefix length is then 32 − 7 = 25. The addresses are
Group 3
For this group, each customer needs 64 addresses. This means that 6 (log264) bits are needed to each
host. The prefix length is then 32 − 6 = 26. The addresses are
Tasks:
Q2. A block of addresses is granted to a small organization. We know that one of the addresses is
205.16.37.39/28.
Find
a. Network Address
b. The first usable address
c. The last usable address
d. The broadcast address
e. The number of addresses.
Q3. Your company would like to break the Class B private IP address range 172.16.0.0 into 60 different
subnets
Q4. A service provider has given you the Class C network range 209.50.1.0. Your company must
break the network into as many subnets as possible as long as there are at least 50 clients per
network.
Q5. An organization has a class C network: 200.1.1.0, and it wants to form subnets for 4 departments
with the number of hosts as follows:
a. Subnet A: 72 hosts
b. Subnet B: 35 hosts
c. Subnet C: 20 hosts
d. Subnet D: 18 hosts