Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

CCN - Lab - 05. & 06

Download as pdf or txt
Download as pdf or txt
You are on page 1of 15

Lab Manual

Data Communication and


Networks

Lab # 5& 6

Lab Instructor :Engr. Mirza Ahsan Ullah


UNIVERSITY OF GUJRAT, FACULTY OF CS&IT
SOFTWARE ENGINEERING DEPARTMENT

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.

Class IP Address Network ID Host ID

A a.b.c.d a b.c.d

B a.b.c.d a.b c.d

C a.b.c.d a.b.c d

Data Communication and Networks Engr. Mirza Ahsan Ullah


UNIVERSITY OF GUJRAT, FACULTY OF CS&IT
SOFTWARE ENGINEERING DEPARTMENT

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

Data Communication and Networks Engr. Mirza Ahsan Ullah


UNIVERSITY OF GUJRAT, FACULTY OF CS&IT
SOFTWARE ENGINEERING DEPARTMENT

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.

Private IP address ranges


The ranges and the amount of usable IP's are as follows:

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

Data Communication and Networks Engr. Mirza Ahsan Ullah


UNIVERSITY OF GUJRAT, FACULTY OF CS&IT
SOFTWARE ENGINEERING DEPARTMENT

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.

How Does a Subnet Mask Work?


In classless IP address, a subnet mask is used on a network to define how many bits are used for the
network address and how many are used for the host address. The subnet mask is the same for all users
on a specific network. When overlay on a host address, it tells the host or device what part of the IP
address is the network address and which is used for the host. Subnet masks will typically start with
255.*.*.* with the remaining digits specific to the network. Every subnet address on a large network will
have its own subnet mask which in essence means the specific subnet has a subnet mask. This allows for
the current form of classless IP addressing that has been in use for IPv4 networks since the 1990s.

The Network and Node ID of each Class

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:

Data Communication and Networks Engr. Mirza Ahsan Ullah


UNIVERSITY OF GUJRAT, FACULTY OF CS&IT
SOFTWARE ENGINEERING DEPARTMENT

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:

Below you can see all this in pictures:

Data Communication and Networks Engr. Mirza Ahsan Ullah


UNIVERSITY OF GUJRAT, FACULTY OF CS&IT
SOFTWARE ENGINEERING DEPARTMENT

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 host


Refers to the actual network itself. For example, network 192.168.0.0 (Class C) can be
bits set to "0"
used to identify network 192.168.0.0 This type of notation is often used within routing
(Network Address) e.g
tables.
192.168.0.0

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.

Data Communication and Networks Engr. Mirza Ahsan Ullah


UNIVERSITY OF GUJRAT, FACULTY OF CS&IT
SOFTWARE ENGINEERING DEPARTMENT

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:

10001100.10110011.11110000.11001000 140.179.240.200 Class B IP Address

11111111.11111111.00000000.00000000255.255.000.000 Default Class B Subnet Mask

--------------------------------------------------------

10001100.10110011.00000000.00000000 140.179.000.000 Network Address

Default subnet masks:

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

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:

Data Communication and Networks Engr. Mirza Ahsan Ullah


UNIVERSITY OF GUJRAT, FACULTY OF CS&IT
SOFTWARE ENGINEERING DEPARTMENT

10001100.10110011.11011100.11001000 140.179.220.200 IP Address


11111111.11111111.11100000.00000000 255.255.224.000 Subnet Mask
--------------------------------------------------------
10001100.10110011.11000000.00000000 140.179.192.000 Subnet Address
10001100.10110011.11011111.11111111 140.179.223.255 Broadcast Address
In this example a 3 bit subnet mask was used. There are 6 (23-2) subnets available with this size mask
(remember that subnets with all 0's and all 1's are not allowed). Each subnet has 8190 (213-2) nodes.
Each subnet can have nodes assigned to any address between the Subnet address and the Broadcast
address. This gives a total of 49,140 nodes for the entire class B address subnetted this way. Notice that
this is less than the 65,534 nodes an unsubnetted class B address would have.

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

255.255.255.0 (11111111.11111111.11111111.00000000 binary)

Extending this by 4 bits yields a mask of

255.255.255.240 (11111111.11111111.11111111.11110000 binary)


This gives us 16 possible network numbers, 2 of which cannot be used:

Subnet bits Network Number Node Addresses Broadcast Address

0000 200.133.175.0 Reserved None

Data Communication and Networks Engr. Mirza Ahsan Ullah


UNIVERSITY OF GUJRAT, FACULTY OF CS&IT
SOFTWARE ENGINEERING DEPARTMENT

0001 200.133.175.16 .17 thru .30 200.133.175.31

0010 200.133.175.32 .33 thru .46 200.133.175.47

0011 200.133.175.48 .49 thru .62 200.133.175.63

0100 200.133.175.64 .65 thru .78 200.133.175.79

0101 200.133.175.80 .81 thru .94 200.133.175.95

0110 200.133.175.96 .97 thru .110 200.133.175.111

0111 200.133.175.112 .113 thru .126 200.133.175.127

1000 200.133.175.128 .129 thru .142 200.133.175.143

1001 200.133.175.144 .145 thru .158 200.133.175.159

1010 200.133.175.160 .161 thru .174 200.133.175.175

1011 200.133.175.176 .177 thru .190 200.133.175.191

1100 200.133.175.192 .193 thru .206 200.133.175.207

1101 200.133.175.208 .209 thru .222 200.133.175.223

1110 200.133.175.224 .225 thru .238 200.133.175.239

1111 200.133.175.240 Reserved None

Classless InterDomain Routing


Now that you understand "classful" IP Subnetting principals, you can forget them ;). The reason is CIDR -
- Classless InterDomain Routing. CIDR was invented several years ago to keep the internet from running
out of IP addresses. The "classful" system of allocating IP addresses can be very wasteful; anyone who
could reasonably show a need for more that 254 host addresses was given a Class B address block of
65533 host addresses. Even more wasteful were companies and organizations that were allocated Class

Data Communication and Networks Engr. Mirza Ahsan Ullah


UNIVERSITY OF GUJRAT, FACULTY OF CS&IT
SOFTWARE ENGINEERING DEPARTMENT

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:

192.60.128.0 (11000000.00111100.10000000.00000000) Class C subnet address


192.60.129.0 (11000000.00111100.10000001.00000000) Class C subnet address
192.60.130.0 (11000000.00111100.10000010.00000000) Class C subnet address
192.60.131.0 (11000000.00111100.10000011.00000000) Class C subnet address
--------------------------------------------------------
192.60.128.0 (11000000.00111100.10000000.00000000) Supernetted Subnet address
255.255.252.0 (11111111.11111111.11111100.00000000) Subnet Mask
192.60.131.255 (11000000.00111100.10000011.11111111) Broadcast address

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, Subnet Mask 255.255.252.0

the network address would be written simply 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,

Data Communication and Networks Engr. Mirza Ahsan Ullah


UNIVERSITY OF GUJRAT, FACULTY OF CS&IT
SOFTWARE ENGINEERING DEPARTMENT

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.

Detailed Example Of Subnetting

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:

Bits 0 to 8 are covered in the first octet.

Bits 9 to 16 are covered in the second octet.

Bits 17 to 24 are covered in the third octet.

Bits 25 to 32 are covered in the fourth octet.

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

Now let's replace the bit numbers with their values:

Data Communication and Networks Engr. Mirza Ahsan Ullah


UNIVERSITY OF GUJRAT, FACULTY OF CS&IT
SOFTWARE ENGINEERING DEPARTMENT

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).

This gives us a First Usable Address of 195.70.16.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).

This gives us a Broadcast Address of 195.70.16.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).

This gives us a Last Usable Address of 195.70.16.158.

Another Complex Scenario:

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:

a. The first group has 64 customers; each needs 256 addresses.


b. The second group has 128 customers; each needs 128 addresses.
c. The third group has 128 customers; each needs 64 addresses.

Data Communication and Networks Engr. Mirza Ahsan Ullah


UNIVERSITY OF GUJRAT, FACULTY OF CS&IT
SOFTWARE ENGINEERING DEPARTMENT

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

Number of granted addresses to the ISP: 65,536


Number of allocated addresses by the ISP: 40,960
Number of available addresses: 24,576

Data Communication and Networks Engr. Mirza Ahsan Ullah


UNIVERSITY OF GUJRAT, FACULTY OF CS&IT
SOFTWARE ENGINEERING DEPARTMENT

Tasks:

Q1. Find the class of each address.


a. 00000001 00001011 00001011 11101111
b. 11000001 10000011 00011011 11111111
c. 14.23.120.8
d. 252.5.15.111

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

There are 145 hosts in total.


Provide a possible arrangement of the network address space, together with the respective range of IP
addresses for each subnet. Explain your work!
Bounce Question(2 Extra Marks)
You are given the following IP address and subnet mask:
192.168.1.58
255.255.255.240
Identify the original range of addresses (the subnet) that this IP address belongs to

Data Communication and Networks Engr. Mirza Ahsan Ullah

You might also like