0% found this document useful (0 votes)
9 views7 pages

IPv4 Addressing Overview and Calculations

Networking Tutorial

Uploaded by

mrtbsekati
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views7 pages

IPv4 Addressing Overview and Calculations

Networking Tutorial

Uploaded by

mrtbsekati
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

IP ADDRESSING TUTORIAL

Devices on networks have addresses: Internet Protocol (IP) version


4 addresses are expressed in dotted decimal and binary numbers,
whilst Media Access Control (MAC) addresses and IP version 6
addresses are expressed in hexadecimal.

Part 1: IP Addresses Recap


Recall the structure of an IPv4 address:
- 32 bits
- written in dotted decimal: divide 32 bits into 4 octets (groups
of 8 bits), each octet is converted into a decimal number
between 0 and 255; octets separated by a dot .
- accompanied by a subnet mask in dotted decimal, prefix
length (slash notation) or binary

On the other hand, an IPv6 address:


- 128 bits
- also written in hexadecimal: divided into eight hextets (16 bits),
each hextet is converted into four hex digits; hextets separated
by :
- accompanied by a subnet mask as prefix length

Each IP address has two parts: the network portion(prefix) and the
host portion. The subnet mask identifies which bits are the network
bits and which are the host bits. All devices in the same network will
have the same network portion, and the same subnet mask. Subnet
masks can be represented in binary, in dotted decimal (for IPv4 ) or
in prefix notation (slash notation), specifying the number of network
bits. Without its associated subnet mask, an IP Address is simply a set

IP Addressing Tutorial Page 1


of numbers. There is a direct relationship bit-for-bit between the IP
address and the subnet mask.

If a subnet mask bit is a one, the corresponding IP address bit


belongs to the network portion of the address.
If a subnet mask bit is a zero, the corresponding IP address bit
belongs to the host portion of the address.

Part 2: Types of IPv4 addresses


Given an IP address and a subnet mask, we can find:
- The network (first) address the IP address belongs to
- The range of addresses that belong to the same network (host
or useable addresses)
- The broadcast (last) address for the network

To find the network address


1. Convert the IPv4 address to binary
2. Convert the subnet mask to binary
3. Line the IP address and the subnet mask bit for bit
4. Apply the binary AND operation
The result is the network address – all host bits should be 0.

Example: Address [Link]/27

IP Address in binary 10100111 11000111 10101010 01010010


AND
Mask in binary 11111111 11111111 11111111 11100000
-----------------------------------------------------------------------------------
Network address 10100111 11000111 10101010 01000000
[Link] in dotted decimal

IP Addressing Tutorial Page 2


The network address identifies the network that the address belongs
to. It has all 0’s in the host portion. This address is used by routers to
route a packet to its destination network.
This address should not be allocated to devices.

The broadcast address


Every network has a broadcast address. This is a special address used
as the destination address of a packet if the device wants to send the
packet to all devices in the same network. All devices in the network
will receive the packet and process it. It is also the last address in the
network. This address has all 1’s in the host portion. Therefore, to find
the broadcast address, keep the network bits intact, change all host
bits to 1. Like the network address, this address should not be
allocated to devices.

Using the example above, the broadcast address for the network will
be
10100111 1100011 10101010 01011111
[Link] in dotted decimal

Useable Host addresses


These are the addresses that are in the same network. They are called
useable because they can be allocated to devices in the network. All
addresses between the network address and the broadcast address
are useable addresses. These addresses have a combination of 0’s and
1’s in the host portion. There is a total of 2n - 2 useable addresses in
a network, where n is the number of host bits.

To find the total number of addresses in a network, the formula is


2n , where n is the number of host bits. The network address and the

IP Addressing Tutorial Page 3


broadcast address can’t, and should not, be allocated to devices,
therefore have to be subtracted to get the useable hosts.

Using our example, the address has 5 host bits


This means that there are 2 5 - 2= 30 useable addresses in the
network
These addresses range from [Link] to [Link]
inclusive.

The first useable address is the network address +1. This can be
achieved by adding 1 to the last octet using the network address. This
address has all 0 on the host portion, except the last bit.
For our example, the first useable address is [Link]. The last
octet of the network address has 64, so 64+1 = 65.

The last useable address is the broadcast address – 1. Subtract 1 from


the last octet using the broadcast address. This address has all 1’s in
the host portion, except the last bit.
The last useable address for our example is therefore [Link].

Question 1

a) How many bits are in an IPv4 address? _______________________

b) How many bits does an IPv6 address have? ____________________

c) How large is an IPv4 address space in total? ____________________

d) How large is an IPv6 address space in total? ____________________

IP Addressing Tutorial Page 4


e) How is an IPv4 represented?

f) How is an IPv6 represented?

Question 2
Convert the following subnet masks into prefix length (slash notation)
a) [Link]

b) [Link]

Question 3
Convert the following prefixes into dotted decimal subnet masks. Hint:
First convert into binary notation, then into dotted decimal
a) /15

b) /22

IP Addressing Tutorial Page 5


Question 4
Given the following address, find the network address, the first useable
address, the last useable address, host addresses range and the
broadcast address Show all calculations.

a) [Link]/16

b) [Link]/23

c) [Link]/28

Question 1
What is wrong with the following IP addresses?
a. 1.2.3
b. [Link].
c. [Link].5
d. 1.255.255.2556

Question 5
Given address [Link]/19
a. Calculate the number of host bits.

b. Calculate the total number of hosts in the network.

c. Calculate the number of useable hosts in the network.

d. Find the network address in dotted decimal. Show your working.

IP Addressing Tutorial Page 6


e. What is the broadcast address of the network in dotted decimal?

f. What is the tenth useable address in the network?


g. Another device has an IP address [Link]/19. Is the device
in the same network? Show all your work.

IP Addressing Tutorial Page 7

Common questions

Powered by AI

To determine if two devices are on the same IPv4 network segment, check whether their network addresses, derived from their respective IP addresses and subnet masks, match. For each device, convert its IP address and subnet mask to binary, perform a binary AND operation between them to isolate the network address. If both resulting network addresses are identical, the devices share the same network segment. For example, given IPs 201.37.16.19/19 and 201.38.16.19/19, convert to binary, apply AND with respective subnet masks, and compare the network addresses .

To calculate the network address for IP 192.168.3.55/23, first convert IP and subnet to binary: 192.168.3.55 is 11000000.10101000.00000011.00110111 and /23 subnet is 11111111.11111111.11111110.00000000. Perform a binary AND between them: - IP: 11000000.10101000.00000011.00110111 - Subnet: 11111111.11111111.11111110.00000000 - Network: 11000000.10101000.00000010.00000000, which converts back to 192.168.2.0 in dotted decimal .

To calculate the network address of an IPv4 address using a subnet mask, follow these steps: 1) Convert the IPv4 address to binary; 2) Convert the subnet mask to binary; 3) Align the IP address and the subnet mask bit for bit; 4) Apply the binary AND operation to each pair of bits. The result is the network address, where all host bits are set to 0. For example, given the IP address 167.199.170.82/27: - IP Address in binary: 10100111 11000111 10101010 01010010 - Subnet Mask in binary: 11111111 11111111 11111111 11100000 - Apply AND operation: Network Address = 10100111 11000111 10101010 01000000 in binary, which equals 167.199.170.64 in dotted decimal. This indicates the network the address belongs to .

IPv4 addresses are 32-bit numbers expressed in dotted decimal format, divided into 4 octets, each converted into a decimal between 0 and 255. IPv6 addresses, on the other hand, are 128-bit numbers written in hexadecimal format, divided into eight hextets, each consisting of four hex digits separated by colons. IPv4 uses dotted decimal and often accompanies a subnet mask in dotted decimal or slash notation, while IPv6 uses prefix length for subnetting .

IPv6 utilizes hexadecimal representation because of its larger address space, consisting of 128 bits, which makes binary and dotted decimal representations cumbersome and complex to manage. Hexadecimal simplifies the expression of these extensive addresses by condensing the 128 bits into eight groups (hextets) of four hex digits each. This format reduces the size of the address string and makes it more human-readable while maintaining efficiency for computer processing .

To calculate the number of usable host addresses in a network, use the formula 2^n - 2, where n is the number of host bits. Host bits are determined by subtracting the subnet prefix length from 32 (for IPv4). For example, if an IPv4 address is 167.199.170.82/27, the subnet mask leaves 5 host bits (32 total bits - 27 prefix bits = 5 host bits). The total number of addresses is 2^5 = 32, and the number of usable addresses is 2^5 - 2 = 30. These exclude the network and broadcast addresses .

The broadcast address is used to send a packet to all devices within the same network and represents the last address in that network range. To find the broadcast address, keep the network bits intact and change all host bits to 1s. For example, using the IP address 167.199.170.82/27: the network portion remains the same, while the host portion becomes all 1s (e.g., 10100111 11000111 10101010 01011111 in binary), resulting in a broadcast address of 167.199.170.95 in dotted decimal .

IPv4 has a 32-bit address space, which equates to approximately 4.3 billion possible unique addresses (2^32). In contrast, IPv6 uses a 128-bit address space, allowing for about 3.4 x 10^38 possible addresses (2^128), vastly expanding the address capacity. This increase is necessary to accommodate the growing demand for IP addresses due to the expansion of internet-connected devices and networks .

To convert a subnet mask from dotted decimal notation to prefix length, convert each octet of the subnet mask to binary, count the number of consecutive 1s from the left, and this count is the prefix length. For example: - 255.255.255.252 converts to binary as 11111111.11111111.11111111.11111100, which has 30 consecutive 1s, thus the prefix length is /30. - 255.255.0.0 converts to binary as 11111111.11111111.00000000.00000000, with 16 consecutive 1s, resulting in a /16 prefix length .

Usable host addresses are derived by identifying the address range between the network and broadcast addresses. The network address marks the beginning (all 0's on the host bits) and the broadcast address is the end (all 1's on the host bits). The first usable address is one more than the network address, and the last usable address is one less than the broadcast address. For example, with a network address of 167.199.170.64 and a broadcast address of 167.199.170.95 (/27), usable addresses range from 167.199.170.65 to 167.199.170.94 .

You might also like