Chapter 15 - Logical Addressing
Chapter 15 - Logical Addressing
[Network Layer]
Logical Addressing
◼ IPv4 Addressing
➢ IPv4 Addresses
➢ Addressing Architecture
➢ Classful Addressing
➢ Classless Addressing
➢ Network Address Translation (NAT)
◼ IPv6 Addressing
➢ Why IPv6 Addressing?
➢ IPv6 Addresses
➢ IPv6 Address Categories
◼ Functionalities / Duties:
➢ Prime Responsibility:
▪ Source-to-destination (host-to-host) delivery of the transport
layer data unit (segment or user datagram).
[NOTE]: Since source-to-destination delivery normally involves delivering a
packet across (outside) networks, it is also referred to as internetworking.
[NOTE]: The network layer protocols, in general, use two types of packets.
Data packets (packets that carry transport layer data along with some control
information) and control packets (carry control information only).
[NOTE]: Normally, for efficiency, routing & forwarding are NOT done by
hosts. They are done by routers. The hosts usually use a “static routing table”
(information is entered manually) having an entry for only one router called
the “default router” (the host usually knows only this router). The host sends
all its IP packets to the default router. The default router, depending upon the
destination address of a packet, finds an optimal route for it (does the routing)
and forwards the packet on that route (through one of its interfaces).
Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.6
▪ Address resolution: Refers to converting the logical address to
physical address and vice versa.
▪ Error reporting: Refers to reporting any error that occurs during
packet transmission to the source.
◼ The current version of IP address is IPv4 that uses a 4-byte address. Slowly we
are migrating to IPv6 addresses (the reasons will be discussed later) which uses a
16-byte address.
◼ [NOTE 1]: Two devices on the Internet can never have the same IP addresses
at the same time.
◼ [NOTE 2]: If a device (for example, a router) operating at the network layer has
‘n’ connections/ports to the Internet, it needs to have ‘n’ different IP addresses
each for one connection/port.
◼ Address Space: The address space (total number of address) of IPv4 is 232
(4,294,967,296).
[Fig. 15.1:
Notations in IPv4
Addressing]
Though the classful addressing scheme has become obsolete, many concepts used in it put a
foundation to the classless addressing. We, therefore, discuss the classful addressing first; then
we explore the classless addressing.
[Fig. 15.3:
IPv4 Classful
Addressing
Architecture]
➢ Class D: Unlike the classes A, B, or C that are made for unicasting, class
D addresses were designed for multicast networking.
In classful addressing, the first few bits of the IP address are exclusively
reserved for class identification purpose only.
So, if an IPv4 address is given in binary notation, these first few reserved bits
identify the class of the address. Alternatively, if the address is given in dotted-
decimal notation, the value of the first byte / octet (decimal equivalent of the
first byte / octet) determines the class of the address.
➢ Class A: In class A, since the first bit, which is 0, is reserved for class
identification,
▪ The total number of class A addresses is: 232-1 = 231 =
2,147,483,648 (which is 50% of the IPv4 address space), and
▪ The address range is: 00000000 00000000 00000000 00000000 –
01111111 11111111 11111111 11111111
i.e., 0.0.0.0 - 127.255.255.255.
➢ Class B: In class B, since the first two bits, which are 10, are reserved
for class identification,
▪ The total number of class B addresses is: 232-2 = 230 =
1,073,741,824 (which is 25% of the IPv4 address space), and
▪ The address range is: 100000000 00000000 00000000 00000000 –
101111111 11111111 11111111 11111111
i.e., 128.0.0.0 - 191.255.255.255.
➢ Class D: In class D, since the first four bits, which are 1110, are reserved
for class identification,
▪ The total number of class D addresses is: 232-4 = 228 = 268,435,456
(which is 6.25% of the IPv4 address space), and
▪ The address range is: 111000000 00000000 00000000 00000000 –
111011111 11111111 11111111 11111111
i.e., 224.0.0.0 - 239.255.255.255.
➢ Class A:
▪ Since class A addresses were intended to provide unicast
addresses for large organizations with millions of hosts,
– only the first byte / octet of the address is used to
represent the network portion (netid), and
– the last three bytes / octets of the address represent the
host portion (hostid).
This is fixed. The logic was that the number of organizations having millions
of hosts would be very few.
When an organization is given a block of addresses (any unicast block, e.g., a class A, B, or C
block in classful addressing), the first and the last IP address in the block are considered
special addresses. They are not allotted to individual hosts present in the network.
The first address is used as the network address. It is used to represent the network itself
to the rest of the Internet. The last address is reserved as the direct broadcast address. It is used
by a node present outside the network to broadcast to all the nodes present within the network.
(Actually, there are two types of broadcasting: direct and limited. In direct broadcasting, a
node present outside a network broadcasts a packet to all the nodes present within the network.
The last IP address in the network is used for this purpose. In limited broadcasting, a node
inside a network broadcasts a packet to the remaining nodes present within the same network.
The IP address 255.255.255.255 is reserved as the limited broadcast address.)
Let us consider an example. Suppose an organization XYZ is granted a class A block
64.X.X.X, i.e., addresses from 64.0.0.0 to 64.255.255.255 (a set of 224 addresses). In this
block, the first address 64.0.0.0 is used as the network address of XYZ. It represents the
organization XYZ to the rest of the Internet.
Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.28
At the same time, the last address 64.255.255.255 is used as the direct broadcast address. It is
used by some node outside XYZ to broadcast to all the nodes present within XYZ (note that, if
a node within XYZ wants to broadcast a packet to the remaining nodes within XYZ it uses the
limited broadcast address: 255.255.255.255). Therefore, the first and the last addresses in the
block (64.0.0.0 and 64.255.255.255) are not given to any individual host present within
XYZ. The hosts are allotted IP addresses from 64.0.0.1 to 64.255.255.254 (the 1st host
64.0.0.1, the 2nd host 64.0.0.2,…., and the last host 64.255.255.254).
[NOTE 2]: In some texts / questions the term “network ID” or “netid” is used in the place of
(to mean) “network address”. In such cases, interpretation is important.
◼ What is a Mask?:
➢ A mask is a 32-bit number consisting of consecutive 1s followed by
consecutive 0s.
➢ It distinguishes the netid and the hostid in an IP address.
➢ A mask for an IP address is created by setting the network bits all to 1s
and the host bits all to 0s in the address.
◼ Masks in Classful Addressing: The masks for different classes (unicast classes -
masking is applicable to unicast classes only) in classful addressing are shown below.
In classful addressing, since the netid in each (unicast) class is fixed (first 1, 2,
and 3 bytes in classes A, B, and C respectively), the mask for each class is also fixed.
Therefore, in classful addressing a mask is also called the default mask.
Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.36
[NOTE]: In Fig. 15.5, the last column shows the masks in slash notation or Classless
Interdomain Routing (CIDR) notation. The notation is particularly used in classless addressing.
We have shown it here because it can also be applied to classful addressing.
For Example, let’s find the network address of the IP address 164.23.45.98.
Solution: 164.23.45.98 is a class B address (value of the first octet 128-191). So,
its mask is 255.255.0.0. Therefore, its network address is:
Solution:
a) 193.168.4.5 is a class C address (value of the first octet 192-223). So, we
keep the first three octets unchanged (for a class C address the first
three octets represent the netid) and make the remining octet 0 to get
its network address as: 193.168.4.0.
b) 86.56.158.3 is a class A address (value of the first octet 0-127). So, we
keep the first octet unchanged (for a class A address the first octet
represents the netid) and make the remining three octets 0 to get its
network address as: 86.0.0.0.
Solution: 164.23.45.86 is a class B address (value of the first octet 128-191). So, we
keep the first two octets unchanged and make the remining two octets 0 to get
its network address as: 164.23.0.0. The network structure for the network
address 164.23.0.0 would be:
We shall see shortly, the exact number of host bits borrowed depends
upon the subnet size (number of hosts in the subnet).
[Fig. 15.6:
FLSM Vs.
VLSM]
The Rules: While subnetting (either FLSM or VLSM) the following rules are
followed to guarantee proper network operation.
2. The addresses are assigned from larger to smaller subnets and they are
assigned in contiguous fashion.
For example, if an organization has 3 departments D1, D2, and D3
having 1000, 500, and 200 hosts respectively, then D1 is given the first
1024 addresses in the address block granted to the organization, D2 is
assigned the very next 512 addresses and D3 the very next 256
addresses.
[NOTE]: It can be observed that this is a case of VLSM. The procedure for FLSM is
the same.
Address range
200.30.40.128 (200.30.40.10000000) ⟶ Subnet address of S2
of S2
200.30.40.129 (200.30.40.10000001) ⟶ Address of the 1st host of S2
(Total 62 used
addresses: 64, ……
addresses
Usable 200.30.40.190 (200.30.40.10111110) ⟶ Address of the 62nd host of S2
addresses: 62) 200.30.40.191 (200.30.40.10111111) ⟶ Direct broadcast address of S2
For Example: The size of S2 is 62. So, 64 addresses are given to it.
Now, in order to represent 64 hosts the number of host bits
required is 6. Therefore, the number of network bits for S2
becomes 32-6 = 26.
i.e., 2 most significant bits are borrowed from the Host part to the
Network part to form the subnetid (for a class C address last 8 bits
represents the host part).
Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.51
➢ Masks:
▪ Subnet Mask: The subnet mask of each subnet can be found out by
using the following argument.
So,
– The subnet mask of S1 = 32 – log2 (128) = /25
i.e., 11111111 11111111 11111111 10000000 (255.255.255.128)
– The subnet mask of S2 = 32 – log2 (64) = /26
i.e., 11111111 11111111 11111111 11000000 (255.255.255.192)
– The subnet mask of S1 = 32 – log2 (64) = /26
i.e., 11111111 11111111 11111111 11000000 (255.255.255.192)
Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.52
➢ Routing / Forwarding:
▪ CASE I (For External Packets, i.e., whenever the router gets a
packet through its port 4): The router takes the following actions:
– If the IP address of the packet is the direct broadcast
address of XYZ (200.30.40.255), the packet is relayed to all
the subnets through ports 1, 2 and 3.
– If the IP address of the packet is not the direct broadcast
address of XYZ, the router first ANDs the IP address of the
packet with the net mask of XYZ (/24). If the result is the
netid of XYZ (200.30.40.0), the router knows that the packet
is for XYZ, hence it is further processed, else it is dropped.
The router then ANDs the IP address of the packet with
each subnet mask (/25 and /26) one by one. The result is
one of the subnet IDs (200.30.40.0, 200.30.40.128, or
200.30.40.192). The router now forwards the packet through
appropriate port.
2. Wastage of addresses.
➢ If a mid-sized organization is provided a class A or B block (because a
class C block would be too small) it will result in a wastage of many
addresses.
3. Difficult to manage.
➢ If a mid-sized organization is provided multiple class C blocks (because
one class C block would be insufficient) it will result in too many
networks to handle.
◼ No concept of classes.
3. The first address in the block must be evenly divisible by the number of
addresses in the block.
[Fig. 15.8]
Where, a.b.c.d is any one of the addresses in the block and /n is the netmask.
➢ This notation completely defines the whole block of addresses (the first
address, the last address, and the number of addresses).
➢ For Example: the address block given in Fig. 15.8 can be represented by
any one of the following (each one represents the same address block)
▪ 205.16.37.33/28 or,
▪ 205.16.37. 39/28 or,
▪ 205.16.37.45/28
[NOTE]: Like classful addressing, in classless addressing, the first and the last
addresses in a block are reserved as the network address and the direct broadcast
addresses, respectively. Therefore, the number of usable addresses (addresses those
can be assigned to the hosts) in a block is: 2(32 - n)-2.
Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.63
An Example: Find the first address, the last address, and the number of
addresses in the address block 205.16.37.39/28.
Solution:
➢ The address 205.16.37.39 in binary (converting the last octet only) is:
205.16.37.00100111.
➢ We find the first address in the block by setting the rightmost 32-28 = 4
bits to 0s. So, the first address in the block is: 205.16.37.00100000, which
is 205.16.37.32.
➢ We find the last address in the block by setting the rightmost 32-28 = 4
bits to 1s. So, the first address in the block is: 205.16.37.00101111, which
is 205.16.37.47.
➢ The number of address in the block is: 2(32-28) = 16.
➢ The number of usable address in the block is: 16 - 2 = 14.
[NOTE]: It can be observed that this is a case of VLSM. The procedure for FLSM is
the same.
Address range
17.12.40.32 (17.12.40. 00100000) ⟶ Subnet address of S2
of S2
17.12.40.33 (17.12.40.00100001) ⟶ Address of the 1st host of S2
(Total 14 used
addresses: 16, ……
addresses
Usable 17.12.40.46 (17.12.40. 00101110) ⟶ Address of the 14th host of S2
addresses: 14) 200.30.40.47 (17.12.40.00101111) ⟶ Direct broadcast address of S2
For Example: The size of S2 is 14. So, 16 addresses are given to it.
Now, in order to represent 16 hosts the number of host bits
required is 4. Therefore, the number of network bits for S2
becomes 32-4 = 28.
i.e., 2 most significant bits are borrowed from the Host part to the
Network part to form the subnetid (for the address block
17.12.40.5/26 last 6 bits represents the host part).
Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.71
➢ Masks:
▪ Net Mask: The net mask of the organization XYZ is already given
as /26.
So,
– The subnet mask of S1 = 32 – log2 (32) = /27
– The subnet mask of S2 = 32 – log2 (16) = /28
– The subnet mask of S1 = 32 – log2 (16) = /28
[Fig. 15.10:
A NAT
Implementation]
➢ The organization uses the private addresses internally (e.g., here the
organization is using the private addresses 172.18.3.1 - 172.18.3.30).
➢ The NAT router uses one or a small set of public addressees (e.g., here
the NAT router is using the address set 200.24.5.8 - 200.24.5.11).
➢ The rest of the Internet sees the organization through the public
addresses (the address of the NAT router).
The reason is that, if the NAT router uses just one public address, then only one
private network host, at a time, can access the same external host (e.g., google.com)
because each pair of IP addresses defines a connection.
To remove this restriction, the NAT router uses a pool of global addresses,
for example, in our case, the NAT router use four global addresses (200.24.5.8 -
200.24.5.11). Therefore, four private network host, at the same time, can communicate
with the same external host.
▪ For all outgoing packets, the NAT router replaces the source
address (a private address) with one of its public NAT addresses.
▪ Similarly, for all incoming packets, the NAT router replaces the
destination addresses (one of its public NAT address) with the
appropriate private address.
◼ Address Space: The address space of IPv6 is 2128 (296 times the IPv4 address
space).
[Fig. 15.13:
Abbreviated
IPv6
Addresses]
◼ A few leftmost bits (of variable length), called the type prefix, in an address
defines its category. No type prefix are identical.
Fraction of each type of
address w.r.to the total
[Table 15.1: IPv6 Address Categories] address space.