CS计算机代考程序代写 scheme M.Sc. Computer Science

M.Sc. Computer Science
Computer Systems

Topic – IP Addressing and Subnets

What is an IP Address?

An IP address is an address used in order to uniquely identify a device on an IP network. The address is
made up of 32 binary bits, which can be divisible into a network portion and host portion with the help
of a subnet mask. The 32 binary bits are broken into four octets (1 octet = 8 bits). Each octet is
converted to decimal and separated by a period (dot). For this reason, an IP address is said to be
expressed in dotted decimal format (for example, 172.16.81.100). The value in each octet ranges from
0 to 255 decimal, or 00000000 – 11111111 binary.

Classful IP Addressing

These octets are broken down to provide an addressing scheme that can accommodate large and small
networks. There are five different classes of networks, A, B, C, D & E. We focus on classes A to C,
since classes D and E are reserved and discussion of them is beyond our scope. Also note that the terms
“Class A, Class B” and so on are used in this document in order to help facilitate the understanding of
IP addressing and subnetting. These terms are rarely used in the industry anymore because of the
introduction of Classless Interdomain Routing (CIDR).

Given an IP address, its class can be determined from the four high-order bits (the four left-most bits in
the first octet). The following table shows the significance of these high order bits and the range of
addresses that fall into each class.

Network/Host Parts Class Classful Mask Addresses Range

0nnnnnnn.hhhhhhhh.hhhhhhhh.hhhhhhhh Class A 255.0.0.0 1.0.0.0 – 127.255.255.255

10nnnnnn.nnnnnnnn.hhhhhhhh.hhhhhhhh Class B 255.255.0.0 128.0.0.0 – 191.255.255.255

110nnnnn.nnnnnnnn.nnnnnnnn.hhhhhhhh Class C 255.255.255.0 192.0.0.0 – 223.255.255.255

1110hhhh.hhhhhhhh.hhhhhhhh.hhhhhhhh Class D 224.0.0.0 – 239.255.255.255

1111hhhh.hhhhhhhh.hhhhhhhh.hhhhhhhh Class E Experimental 240.0.0.0 – 255.255.255.255

In a Class A address, the first octet is the network portion, so the Class A has a major network address
of 1.0.0.0 – 127.255.255.255. Octets 2, 3, and 4 (the next 24 bits) are for the network manager to divide
into subnets and hosts as he/she sees fit. Class A addresses are used for networks that have more than
65,536 hosts (actually, up to 16777214 hosts!).

In a Class B address, the first two octets are the network portion, so the Class has a major network
address of 128.0.0.0 – 191.255.255.255. Octets 3 and 4 (16 bits) are for local subnets and hosts. Class B
addresses are used for networks that have between 256 and 65534 hosts.

In a Class C address, the first three octets are the network portion. The Class has a major network
address of 192.0.0.0 – 223.255.255.255. Octet 4 (8 bits) is for local subnets and hosts – perfect for
networks with less than 254 hosts.

Network Masks

A network mask helps you know which portion of the address identifies the network and which portion
of the address identifies the node. Class A, B, and C networks have default masks, also known as
natural masks, as shown here:

Class A: 255.0.0.0
Class B: 255.255.0.0
Class C: 255.255.255.0

An IP address on a Class A network that has not been subnetted would have an address/mask pair
similar to: 8.20.15.1 255.0.0.0. In order to see how the mask helps you identify the network and node
parts of the address, convert the address and mask to binary numbers.

8.20.15.1 = 00001000.00010100.00001111.00000001
255.0.0.0 = 11111111.00000000.00000000.00000000
———————————–
net id | host id
netid = 00001000 = 8
hostid = 00010100.00001111.00000001 = 20.15.1

Once you have the address and the mask represented in binary, then identification of the network and
host ID is easier. Any address bits which have corresponding mask bits set to 1 represent the network
ID. Any address bits that have corresponding mask bits set to 0 represent the node ID.

Understanding Subnetting

Subnetting allows you to create multiple logical networks that exist within a single Class A, B, or C
network. If you do not subnet, you are only able to use one network from your Class A, B, or C
network, which is unrealistic.

Each data link on a network must have a unique network ID, with every node on that link being a
member of the same network. If you break a major network (Class A, B, or C) into smaller
subnetworks, it allows you to create a network of interconnecting subnetworks. Each data link on this
network would then have a unique network/subnetwork ID. Any device, or gateway, that connects n
networks/subnetworks has n distinct IP addresses, one for each network / subnetwork that it
interconnects.

In order to subnet a network, extend the natural mask with some of the bits from the host ID portion of
the address in order to create a subnetwork ID. For example, given a Class C network of 204.17.5.0
which has a natural mask of 255.255.255.0, you can create subnets in this manner:

204.17.5.0 – 11001100.00010001.00000101.00000000
255.255.255.224 – 11111111.11111111.11111111.11100000

————————–|sub|—-

By extending the mask to be 255.255.255.224, you have taken three bits (indicated by “sub”) from the
original host portion of the address and used them to make subnets. With these three bits, it is possible
to create eight subnets. With the remaining five host ID bits, each subnet can have up to 32 host
addresses, 30 of which can actually be assigned to a device since host ids of all zeros or all ones are
not allowed (it is very important to remember this). So, with this in mind, these subnets have been
created.

Subnet # Subnet Address Subnet Mask Host IP Address Range

1 204.17.5.0 255.255.255.224 204.17.5.1 – 204.17.5.30

2 204.17.5.32 255.255.255.224 204.17.5.33 – 204.17.5.62

3 204.17.5.64 255.255.255.224 204.17.5.65 – 204.17.5.94

4 204.17.5.96 255.255.255.224 204.17.5.97 – 204.17.5.126

5 204.17.5.128 255.255.255.224 204.17.5.129 – 204.17.5.158

6 204.17.5.160 255.255.255.224 204.17.5.161 – 204.17.5.190

7 204.17.5.192 255.255.255.224 204.17.5.193 – 204.17.5.222

8 204.17.5.224 255.255.255.224 204.17.5.225 – 204.17.5.254

Here are two ways to denote these masks. First, since you use three bits more than the “natural” Class
C mask, you can denote these addresses as having a 3-bit subnet mask. Or, secondly, the mask of
255.255.255.224 can also be denoted as /27 as there are 27 bits that are set in the mask. This second

method is used with CIDR. With this method, one of these networks can be described with the notation
prefix/length. For example, 204.17.5.32/27 denotes the network 204.17.5.32 255.255.255.224.

The following figure shows the No of Hosts, prefix/length Masks, and Binary Representation of these
masks as used in CIDR.

And lastly, remember the following table by heart, it will help you a lot!

Question #1
You are given two address / mask combinations, written with the prefix/length notation, which have
been assigned to two devices. Your task is to determine if these devices are on the same subnet or
different subnets. You can use the address and mask of each device in order to determine to which
subnet each address belongs.

Device A: 172.16.17.30/20
Device B: 172.16.28.15/20

Determine the Subnet for Device A:

172.16.17.30 – 10101100.00010000.00010001.00011110
255.255.240.0 – 11111111.11111111.11110000.00000000

—————–| sub|————
subnet = 10101100.00010000.00010000.00000000 = 172.16.16.0

Looking at the address bits that have a corresponding mask bit set to one, and setting all the other
address bits to zero (this is equivalent to performing a logical “AND” between the mask and address),
shows you to which subnet this address belongs. In this case, Device A belongs to subnet 172.16.16.0.

Determine the Subnet for Device B:

172.16.28.15 – 10101100.00010000.00011100.00001111
255.255.240.0 – 11111111.11111111.11110000.00000000

—————–| sub|————
subnet = 10101100.00010000.00010000.00000000 = 172.16.16.0

From these determinations, DeviceA and DeviceB have addresses that are part of the same subnet.

Question #2: You are working in a company and have been asked to design a network where each
subnet would contain around 50 hosts. How many subnets can you create using the Network Address of
200.100.50.0? What are the range of IP addresses for each subnet?

We can see that 200.100.50.0 is a Class C address with a default subnet mask of 255.255.255.0 or /24
The subnet mask in Binary looks like: 11111111.11111111.11111111.00000000
As we need around 50 hosts per subnet, we will dedicate need at-least 6 bits for the host part i.e. 26 = 64
So the subnet mask can be extended up to /26 bits i.e. 11111111.11111111.11111111.11000000
Therefore, we will have four subnets in our network, as shown in the table below:

Subnet # Subnet Address Subnet Mask Host IP Address Range

1 200.100.50.0 255.255.255.192 200.100.50.1 – 200.100.50.62

2 200.100.50.64 255.255.255.192 200.100.50.65 – 200.100.50.126

3 200.100.50.128 255.255.255.192 200.100.50.129 – 200.100.50.190

4 200.100.50.192 255.255.255.192 200.100.50.193 – 200.100.50.254