You are on page 1of 85

Chapter 15

[Network Layer]

Logical Addressing

Dr. Niroj Kumar Pani


nirojpani@gmail.com

Department of Computer Science Engineering & Applications


Indira Gandhi Institute of Technology
Sarang, Odisha
Chapter Outline…
◼ Introduction to Network Layer

◼ Logical Addressing: Why & What?

◼ IPv4 Addressing
➢ IPv4 Addresses
➢ Addressing Architecture
➢ Classful Addressing
➢ Classless Addressing
➢ Network Address Translation (NAT)

◼ IPv6 Addressing
➢ Why IPv6 Addressing?
➢ IPv6 Addresses
➢ IPv6 Address Categories

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.2


Introduction to Network Layer
◼ As we have discussed in Chapter 2, the network layer is in between the transport
layer and the data link layer. It provides service to the transport layer and uses
the services of the data link layer.

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

➢ Services: In order to ensure source-to destination delivery, the network


layer provides the following services:
▪ Logical addressing / IP addressing: Refers to specifying an
addressing scheme that uniquely and universally identifies each
computer in a network.
Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.3
▪ Fragmentation & Reassembly: Refers to
- Dividing (fragmenting) the transport layer segment (at the
sender site and at each router), if its size exceeds the
allowed transmittable unit (the IP packet / datagram size).

[NOTE]: A packet can travel though different networks each of which


has its own data link layer frame formats (for example, the Ethernet
frame size is different from that of FDDI). If a packet is larger than
the maximum frame size, then the sender (as well as the routers) has
to reduce the packet size. It is done by fragmenting the data section
(transport layer segment) of the packet.

- Reversely, reassembling the fragments into one single


segment (at the receiver site), so that it could be delivered
to the transport layer.

[NOTE]: The reassembly of the packets is done only by the


destination host (not by the routers).

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.4


▪ Packetizing (Making Packets): Refers to
- Attaching a network layer header to each transport layer
segment (after fragmentation). The header contains the IP
addresses of sender & receiver, and other information (as
needed).

[NOTE]: The destination’s IP address is provided to the network


layer by DNS (application layer).

The data unit thus formed (by encapsulating transport layer


segment with network layer header) is called a packet. It is the
unit of data transmitted and processed by the network layer.

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

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.5


▪ Routing & Forwarding:
- Routing and forwarding are highly interlinked.
- Routing refers to the process of finding an optimal route
to the desired destination(s) (one source one destination -
unicast routing, or one source many destinations - multicast routing).
This information is stored in a “routing table”.
- Forwarding refers to placing a packet in its optimal route
to the destination(s) (i.e., placing the packet on the right interface
/ port). Forwarding requires routing.

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

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.7


◼ Protocols: The network layer defines / uses several protocols for different
specified services.
➢ IP (Internet Protocol): It is the main protocol of network layer that
performs source-to-destination delivery (one source to one destination
delivery - unicasting). It provides the following services (through which
source-to-destination delivery is achieved):
▪ Logical addressing
▪ Fragmentation & Reassembly
▪ Packetizing
[NOTE]: Currently we are using IPv4. We are migrating towards IPv6.

➢ IGMP (Internet Group Message Protocol): Provides multicasting (one


source to multiple destinations delivery).

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.8


➢ ARP (Address Resolution Protocol), RARP (Reverse Address Resolution
Protocol), and BOOTP (Bootstrap Protocol ): Provide address
resolution.

➢ ICMP (Internet Control Message Protocol): Provides error reporting.

➢ Different Routing Protocols (such as RIP, OSPF, BGP etc.): Provides


unicast / multicast routing.

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.9


What is Discussed Where?
✓ In this chapter, we will discuss
o Logical addressing, a service provided by IP. We will discuss both IPv4
and IPv6 addressing.
✓ In the next chapter , we will discuss three important network layer protocols
o The IP protocol (with its two services packetizing, and fragmentation &
reassembly)
o ARP
o ICMP
✓ In chapter 17, we will discuss Routing & forwarding.

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.10


Logical Addressing: Why & What?
◼ As we have discussed in Chapter 2, physical addresses are inadequate for
universal communication (a physical address can identify a computer within a
network only). For this, we need an addressing system that can identify a node
connected to the Internet, uniquely and universally. This address is called the
logical address or the IP address (as it is provided by the IP protocol).

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

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.11


IPv4 Addressing
IPv4 Addresses
◼ An IPv4 address is a 4-byte (octet) / 32-bit address that uniquely and
universally defines the connection of a node to the Internet.

◼ Address Space: The address space (total number of address) of IPv4 is 232
(4,294,967,296).

◼ Notations: Three notations are used to show an IPv4 address.


➢ Binary notation.
➢ Dotted-decimal notation (mostly used).
➢ Hexadecimal notation (rarely used).

[Fig. 15.1:
Notations in IPv4
Addressing]

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.13


Addressing Architecture
◼ An IPv4 address, just like a telephone or a postal network, is hierarchical in
structure.

◼ It is (normally, not always) is divided into two parts.


➢ The first part (leftmost n bits) defines the network. It is called the
network ID / netid / network prefix / prefix. (NOTE: The individual bits in this
part are called the network bits / net bits.)
➢ The second part (rightmost 32-n bits) defines the node / host (connection
of a node / host to the Internet). It is called the host ID / hostid / suffix.
(NOTE: The individual bits
in this part are called
the host bits.)

[Fig. 15.2: Hierarchy in


IPv4 Addressing]
Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.14
◼ Earlier (1981-1993), the IPv4 address was designed to have fixed length netids
(8, 16, and 24 bits). It is referred to as classful addressing. This scheme,
however had some limitations (discussed later) and is now obsolete.

◼ To overcome the limitations of classful addressing, a new scheme was


introduced in 1993 that uses variable length netids. It is called the classless
addressing. Currently this scheme is in use.

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.

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.15


Classful Addressing
◼ In classful addressing, the whole IPv4 address space is divided into 5 classes:
A, B, C, D, & E as shown in Fig. 15.3. Each class has its own purpose & property.

[Fig. 15.3:
IPv4 Classful
Addressing
Architecture]

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.16


◼ To clarify the concepts clearly, we discuss the classes under the following
heads.
➢ Design purpose
➢ Class identification
➢ Address space & range
➢ Networks & hosts

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.17


I. Design Purpose:

➢ Classes A, B and C: The classes A, B, and C were all designed to


provide unicast addresses. However, they were made for different
organizations (network groups).
▪ Class A addresses were made for large organizations (network
groups) having millions of hosts (nodes - computers or routers).
▪ Class B addresses target mid-sized organizations having
thousands of hosts.
▪ Class C addresses target small organizations where the number
of hosts are limited to few hundreds.

➢ Class D: Unlike the classes A, B, or C that are made for unicasting, class
D addresses were designed for multicast networking.

➢ Class E: Class E addresses were reserved for future and experimental


purposes.

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.18


II. Class Identification:

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.

➢ A class A address is identified by:


▪ The first bit to be 0 (reserved), in binary notation, or
▪ The value of the first octet to be 0-127 (00000000 - 01111111), in
dotted-decimal notation.
Any IPv4 address having the above property is a class A address.
For example, all these are class A addresses: 00000001 00001011
00100011 11011011, 123.4.46.0, 35.35.35.35.

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.19


➢ A class B address is identified by:
▪ The first two bits to be 10 (reserved), in binary notation, or
▪ The value of the first octet to be 128-191 (100000000 - 101111111),
in dotted-decimal notation.
Any IPv4 address having the above property is a class B address.
For example, all these are class B addresses: 10010001 00001011
00100011 11011011, 130.4.46.0, 191.35.35.35.

➢ A class C address is identified by:


▪ The first three bits to be 110 (reserved), in binary notation, or
▪ The value of the first octet to be 192-223 (110000000 - 110111111),
in dotted-decimal notation.
Any IPv4 address having the above property is a class C address.
For example, all these are class B addresses: 11010101 00101011
00100011 11011011, 192.4.46.0, 220.35.135.35.

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.20


➢ A class D address is identified by:
▪ The first four bits to be 1110 (reserved), in binary notation, or
▪ The value of the first octet to be 224-239 (111000000 - 111011111),
in dotted-decimal notation.
Any IPv4 address having the above property is a class D address.
For example, all these are class B addresses: 11100101 01101011
00100001 10011011, 230.4.66.20, 239.53.155.255.

➢ A class E address is identified by:


▪ The first four bits to be 1111 (reserved), in binary notation, or
▪ The value of the first octet to be 240-255 (111100000 - 111111111),
in dotted-decimal notation.
Any IPv4 address having the above property is a class E address.
For example, all these are class B addresses: 11110101 00101011
00000001 10011001, 241.40.61.30, 255.53.255.254.

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.21


III. Address Space & Range:

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

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.22


➢ Class C: In class C, since the first three bits, which are 110, are
reserved for class identification,
▪ The total number of class C addresses is: 232-3 = 229 = 536,870,912
(which is 12.5% of the IPv4 address space), and
▪ The address range is: 110000000 00000000 00000000 00000000 –
110111111 11111111 11111111 11111111
i.e., 192.0.0.0 - 223.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.

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.23


➢ Class E: In class C, since the first four bits, which are 1111, 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: 111100000 00000000 00000000 00000000 –
111111111 11111111 11111111 11111111
i.e., 240.0.0.0 - 255.255.255.255.

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.24


IV. Networks (also called Blocks) & Hosts:

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

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.25


▪ Number of Networks (Blocks): In the first byte that denotes the
network portion, since the first bit, which is 0, is reserved for
class identification, we can have only 7 bits as the network
identifier. So, the total number of class A networks (blocks)
possible is: 27 = 128 (from 0.X.X.X – 127.X.X.X).
But there are some exceptions. The first block 0.X.X.X and
the last block 127.X.X.X are not for normal use. The first block
0.X.X.X is kept with IANA (Internet Assign Number Authority – the
organization that allocates the IP addresses) as default network address
and the last block 127.X.X.X is used for network diagnosis and
loopback purpose.
So, in actual the total number of usable class A networks
(blocks) is: 27 - 2 = 126 (from 1.X.X.X – 126.X.X.X). It means there are
only 126 organizations in the world having a class A address.

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.26


▪ Number of Hosts in each Class A Network (Block): Since the last
three octets in a class A address denotes the host portion, the
total number of hosts (host addresses) possible in each class A
network (block) is: 224 = 16,277,216.
However, the first and the last IP addresses in a block (any
unicast block, e.g., A, B, or C) are not given to the individual hosts in
the network (the reason is given next). Therefore, in actual the total
number of usable hosts (host addresses) in each class A network
(block) is: 224 – 2 = 16,277,214.

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.27


[NOTE 1]: Network Address & Broadcast Addresses

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

[Fig. 15.4: Network


Structure of the
Organization XYZ]

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.29


This principle of address allocation is applicable to all unicast blocks (e.g., A, B, or C
in classful addressing). Therefore, in actual the total number of usable hosts (host addresses) in
any unicast block is always: 2number of host bits – 2.

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

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.30


➢ Class B:
▪ Since class B addresses were designed to provide unicast
addresses for mid-sized organizations having thousands of
hosts,
– the first two bytes / octets of the address were used to
represent the network portion (netid), and
– the last two bytes / octets of the address represent the
host portion (hostid).
This is fixed. The logic was that the number of organizations that have
thousands of hosts would also be in thousands.

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.31


▪ Number of Networks (Blocks): In the first two bytes that denote
the network portion, since the first two bits, which are 10, are
reserved for class identification, we can have only 14 bits as the
network identifier. So, the total number of class B networks
(blocks) is: 214 = 16,384 (from 128.0.X.X – 191.255.X.X). Here, all
blocks are usable, none is reserved. This means that there can
be 16,384 organizations in the world that can have a class B
address.

▪ Number of Hosts in each Class B Network (Block): Since the last


two octets in a class B address denotes the host portion, the total
number of hosts (host addresses) possible in each class B
network (block) is: 216 = 65,534.
However, since the first and the last IP address in a (unicast)
block are never given to individual hosts, in actual the total
number of usable hosts (host addresses) in each class B network
(block) is: 216 – 2 = 65,534.
Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.32
➢ Class C:
▪ Since class C addresses were designed to provide unicast
addresses for small organizations having only hundreds of hosts,
– the first three bytes / octets of the address were used to
represent the network portion (netid), and
– only the last byte / octet of the address represents the host
portion (hostid).
This is fixed. The logic was that the number of organizations having only
hundreds of hosts would also be in millions.

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.33


▪ Number of Networks (Blocks): In the first three bytes that denote
the network portion, since the first three bits, which are 110, are
reserved for class identification, we can have only 21 bits as the
network identifier. So, the total number of class C networks
(blocks) is: 221 = 2,097,152 (from 192.0.0.X – 223.255.255.X). Here, all
blocks are usable, none is reserved. This means that there can
be as much as 2,097,152 organizations in the world that can have
a class C address.

▪ Number of Hosts in each Class C Network (Block): Since the last


three octets in a class C address denotes the host portion, the
total number of hosts (host addresses) possible in each class C
network (block) is: 28 = 256.
However, since the first and the last IP address in a (unicast)
block are not allotted to individual hosts, in actual the total
number of usable hosts (host addresses) in each class C network
(block) is: 28 – 2 = 254.
Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.34
➢ Class D & E: Since the classes D & E addresses were not intended for
unicasting, they were not divided into netid or hostid.

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.35


Mask / Net Mask

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

[Fig. 15.5: Default


Masks in Classful
Addressing]

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.

◼ Use of a Mask: Given an IP address, a mask is used (mostly by routers) to find /


filter (that’s why it is called a mask) its the network address.

For Example, let us consider the


network in Fig. 15.6. Suppose the
router gets a packet through its
port #3. How will the router decide
where to send the packet: to
network X or Y? For this, the router
[Fig. 15.6: A Typical Network Scenario]
applies the masks of each network
(for X the mask is 255.255.0.0, and for Y the mask is 255.255.255.0) one-by-one to
the IP address of the packet to determine its network address. Once the router
gets the network address it forwards the packet to that network through
appropriate port.
Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.37
◼ How to find the network address of an IP address by using its mask?

The Rule: The network address of an IP address is found by bit-wise ANDing


the IP address with its mask.

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:

164.23.45.98 10100100 00010111 00101101 01100010


∧ 255.255.0.0 ∧ 11111111 11111111 00000000 00000000
164.23.0.0 10100100 00010111 00000000 00000000

[TRICK]: There is a trick for quick calculation.


Given an IP address, to find its network address, keep those many octets in the address
unchanged which is equal to the netid part (the number of 255s in the mask) of the class of the
address and make the remaining octets 0. It is because, when a AND operation is performed
between a number and 255 (11111111) the result is the number itself, and when a AND
operation is performed between a number and 0 (00000000) the result is always 0.
Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.38
In the given example, since 164.23.45.98 is a class B address, we keep the first two octets
unchanged (for a class B address the first two octets represent the netid) and make the remining
two octets 0 to get its network address as: 164.23.0.0.

◼ Example 1: Find the network address of the following IP addresses:


a) 193.168.4.5
b) 86.56.158.3.

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.

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.39


◼ Example 2: Given an IP address 164.23.45.86, find: (a) its network address, (b)
address of the third host in its network, (c) address of the last host in its
network, and (d) broadcast address of its network (the term “broadcast address” by
default mean “direct broadcast address”)

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:

164.23.0.0 ⟶ Network address (the first address)


164.23.0.1 ⟶ Address of the first host
164.23.0.2 ⟶ Address of the second host
164.23.0.3 ⟶ Address of the third host
……
164.23.255.254 ⟶ Address of the last host
164.23.255.255 ⟶ Broadcast address (the last address)

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.40


Subnetting in Classful Addressing

◼ Subnetting was introduced during the era of classful addressing.

◼ What is Subnetting?: It is a technique of dividing a large block of addresses


(e.g., a class A, or B block) granted to an organization into multiple contiguous
sub-groups, each of which is assigned to a smaller part of the network (called a
subnetwork / subnet).

◼ Why Subnetting?: Subnetting is done for better network management.


For example, suppose an organization is given a class A block. In such case,
managing 224 hosts addresses would be difficult. A better way of managing
such a large block of addresses is to divide it into smaller sub-groups, each of
which may be assigned to different departments of the organization.

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.41


◼ [NOTES]:
➢ Subnetting is completely internal to an organization, i.e., when an
organization is subnetted, the rest of the world still sees the organization as one entity,
though internally there are several subnets. All messages from outside the organization
are still sent to the same router that connects the organization to the rest of the
Internet; the router routes the message to the appropriate subnet.

➢ In subnetting, each subnet within an organization is treated as


independent piece of network. Each subnet must have its own subnet
address, subnet broadcast address, and subnet mask.
Therefore, subnetting establishes a three-level hierarchy in
addressing architecture. In subnetting, each IP address has a
▪ Network portion (netid) that derives network address, network
broadcast address, and network mask.
▪ Subnet portion (subnetid) that derives subnet address, subnet
broadcast address, and subnet mask.
▪ Host portion (hostid) that derives host address.
Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.42
This three-level hierarchy is achieved by borrowing some most
significant bits from the Host part to the Network part to form the
subnetid.

[Fig. 15.7: Three levels of


hierarchy in subnetting]

We shall see shortly, the exact number of host bits borrowed depends
upon the subnet size (number of hosts in the subnet).

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.43


◼ Types of Subnetting: There are two types of subnetting.
1. Fixed length subnetting / Fixed Length Subnet Mask (FLSM):
▪ In it, all the subnets in the network have equal number of hosts.
▪ Therefore, all the subnets use the same subnet mask (subnet mask
depends upon the number of hosts in a subnet).
2. Variable length subnetting / Variable Length Subnet Mask (VLSM):
▪ In it, the subnets in the network have variable number of hosts.
▪ Therefore, different the subnets use different subnet mask.

[Fig. 15.6:
FLSM Vs.
VLSM]

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.44


◼ Designing Subnets (How Subnetting - FLSM or VLSM - is Done?):

The Rules: While subnetting (either FLSM or VLSM) the following rules are
followed to guarantee proper network operation.

1. The number of addresses assigned to each subnet must be a power of 2


(1, 2, 4, 8, …). For instance, if a subnet has 50 hosts, we can’t give
exactly 50 address to the subnet (as 50 is not a power of 2), rather it is
given 64 addresses (14 addresses remain unused in the subnet).

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.

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.45


Let us see how subnetting (FLSM / VLSM) is done through an example:

➢ Suppose an organization XYZ is given a class C block 200.30.40.X (256


host addresses out of which 254 are usable). The organization has three
departments D1, D2, and D3.
▪ D1 has 100 hosts (computers / routers).
▪ D2 has 62 hosts (computers / routers).
▪ D3 has 30 hosts (computers / routers).
So, when subnetting is done three subnets, let's say, S1, S2, and S3
should be created respectively for D1, D2, and D3. The subnetting
structure of the organization is given next.

[NOTE]: It can be observed that this is a case of VLSM. The procedure for FLSM is
the same.

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.46


200.30.40.0 (200.30.40.00000000) ⟶ Network address of XYZ and subnet address of S1
Address range 200.30.40.1 (200.30.40.00000001) ⟶ Address of the 1 host of S1
st
100 used
of S1 ……
addresses
(Total 200.30.40.100 (200.30.40.01100100) ⟶ Address of the 100th host of S1
addresses: 128, 200.30.40.101 (200.30.40.01100101) ⟶
Usable …… 26 unused addresses
addresses: 126) 200.30.40.126 (200.30.40.01111110) ⟶
200.30.40.127 (200.30.40.01111111) ⟶ Direct broadcast address of S1

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

200.30.40.192 (200.30.40.11000000) ⟶ Subnet address of S3


Address range 200.30.40.193 (200.30.40.11000001) ⟶ Address of the 1st host of S3
30 used
of S3 ……
addresses
(Total 200.30.40.222 (200.30.40.11011110) ⟶ Address of the 30th host of S3
addresses: 64, 200.30.40.223 (200.30.40.11011111) ⟶
Usable …… 32 unused addresses
addresses: 62) 200.30.40.254 (200.30.40.11111110) ⟶
200.30.40.255 (200.30.40.11111111) ⟶ Direct broadcast address of XYZ and S3
Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.47
[Fig. 15.7: Subnetting Structure of XYZ - Classful Addressing]

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.48


➢ Observations:

1. The number of addresses assigned to each subnet is a power of 2.


For instance, though S1 has 100 hosts, it is given 128 addresses
(126 usable addresses; out of which 100 addresses are used and 26 addresses
remain unused).

2. The addresses are assigned from larger to smaller subnets and


they are assigned in contiguous fashion.
– S1 is given the first 128 addresses in the block from
200.30.40.0 - 200.30.40.127.
[NOTE]: Given the 1st address, one can calculate the last address easily
as: last address = 1st address + number of addresses required - 1,
e.g., 200.30.40.0 + 128 - 1 = 200.30.40.127).
– S2 is given the very next 64 addresses from 200.30.40.128 -
200.30.40.191.
– S3 is given the remaining 64 addresses from 200.30.40.192 -
200.30.40.255.
Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.49
3. The first address in the block 200.30.40.0 acts both as the network
address of XYZ and the subnet address of S1. Similarly, the last
address in the block 200.30.40.255. acts both as the direct
broadcast address of XYZ and the direct broadcast address of S3.
As we shall discuss soon, such allocation doesn’t create any
confusion in routing / forwarding.

4. Subnetting reduces the number of usable addresses in a block.


For instance, if the organization XYZ is not subnetted then the
number of usable address in the block 200.30.40.X would be 254
(256 - 2). However, with three subnets S, S2 and S3, the number of
usable address is 126 + 62 + 62 = 250 (or, 256 – 6).

[NOTE]: After subnetting, the total number of usable address can be


determined as: Total number of usable addresses = Total number of possible
address – (2 X number of subnets).

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.50


5. The network part and the host part in the subnet addresses is
determined by the subnet size (number of hosts in the subnet).

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:

▪ Net Mask: The net mask of the organization XYZ is 255.255.255.0


(/24) (the default mask for class C).

▪ Subnet Mask: The subnet mask of each subnet can be found out by
using the following argument.

Since the network bits determine the mask,


Subnet mask (in /n notation) = 32 – host bits
= 32 – log2 (subnet size in power of 2).

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.

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.53


▪ CASE II (For Internal Packets, i.e., whenever the router gets a
packet through one of its port 1, 2, or 3): The router takes the
following actions:
– If the IP address of the packet is the direct broadcast
address of a subnet (200.30.40.127, 200.30.40.191, or
200.30.40.255), it is sent to appropriate subnet.
– If the IP address of the packet is not a direct broadcast
address, 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 destination of
the packet is within XYZ (in some other subnet). So, the
packet is further processed, else it is sent through port 4.
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. Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.54
Let’s consider some examples:
▪ The router gets a packet with IP address 200.30.40.255 at port 4:
It’s the direct broadcast address of XYZ. So, relayed through ports
1, 2, and 3.
▪ The router gets a packet with IP address 200.30.40.255 at port 1:
It’s the direct broadcast address S3. So, sent through ports 3.
▪ The router gets a packet with IP address 200.30.40.100 at port 4:
– 200.30.40.100 is ANDed with the net mask of XYZ “/24”
(255.255.25.0). The result is 200.30.40.0. So, further
processing is done.
– 200.30.40.100 is ANDed with the subnet mask of S1 “/25”
(255.255.25.128). The result is 200.30.40.0 (the subnet ID of
S1). So, the packet is sent through port 1.

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.55


▪ The router gets a packet with IP address 200.30.40.130 at port 4:
– 200.30.40.130 is ANDed with the net mask of XYZ “/24”
(255.255.25.0). The result is 200.30.40.0. So, further
processing is done.
– When 200.30.40.130 is ANDed with the subnet mask of S1
“/26” (255.255.25.192). The result is 200.30.40.128 (the subnet
ID of S2). So, the packet is sent through port 2.
▪ The router gets a packet with IP address 200.30.40.130 at port 1:
Same as above.

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.56


Limitations of Classful Addressing

1. Shortage (depletion) of address.


➢ The number of class A and B blocks are very less.
➢ A class C block is too small for most mid-sized organization.

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.

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.57


Classless Addressing
◼ Also called, CIDR (Classless Inter-Domain Routing).

◼ No concept of classes.

◼ Concept of blocks (addresses are granted in blocks of different sizes


depending on the need - discussed next).

◼ So, variable length netids.

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.58


Address Allocation Technique & Rules

◼ In classless addressing, addresses are allocated in blocks (of different sizes).

➢ Whenever an organization, large or small, requests a set of addresses,


it is granted a block (range) of addresses anywhere from the entire IPv4
address range 0.0.0.0 - 255.255.255.255 (except for the given exceptions)
depending upon the number of hosts in the organization.

➢ Exceptions: The following address ranges are not allocated to any


organizations as they are reserved for special purpose.

Address Range Total Purpose


0.0.0.0 - 10.255.255.255 224
172.16.0.0 - 172.31.255.255 220 Private Addresses
192.168.0.0 - 192.168.255.255 216
255.255.255.255 1 Limited broadcast address

[NOTE]: The concept of “Private addresses” is discussed later in “Network


Address Translation (NAT)”

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.59


◼ The Rules: To handle proper network operations, the Internet authorities
impose three restrictions on how a block should be allocated.

1. The number of addresses in a block must be a power of 2 (1, 2, 4, 8, …).


For instance, if an entity has 50 hosts, it can’t be given exactly 50
address (as 50 is not a power of 2), rather it is given 64 addresses (14
addresses remain unused in the organization).

2. The addresses in a block must be contiguous, one after another.

3. The first address in the block must be evenly divisible by the number of
addresses in the block.

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.60


An Example: Fig. 15.8 shows a block of addresses (in both binary and dotted-decimal
notations) granted to a small organization that needs 16 addresses.

[Fig. 15.8]

It can be observed that:


1. The number of addresses in the block is a power of 2 (16 = 24).
2. The address in the block are contiguous.
3. The first address in the block (205.16.37.32) is divisible by 16.

[TRICK - How to know whether an IP address “a.b.c.d” is divisible by a number “n”?]:


Let n = 2x. Then, “a.b.c.d” will be divisible by “n” if the “x” number of least significant bits
in “a.b.c.d” are all 0s (zeros), e.g., 205.16.37.32 is divisible by 16 (24) because the 4 LSB
of 205.16.37.32 (205.16.37.00100000) are all zeros.

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.61


Classless Addressing Notation (CIDR Notation)

◼ In classless addressing, a block of address is represented by: a.b.c.d/n

Where, a.b.c.d is any one of the addresses in the block and /n is the netmask.

➢ This is called the CIDR notation

➢ 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

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.62


◼ Problem: Given an IP address in CIDR notation how to find out the first address,
the last address, and the number of addresses in the block?

Rules (Solution): Given an address block a.b.c.d/n


➢ The first address in the block can be found out by ANDing the mask “n”
with the address “a.b.c.d” (OR) by setting the 32 - n rightmost bits (in binary
notation of the address) to 0s.
➢ The last address in the block can be found out by ORing the mask “n”
with the address “a.b.c.d” (OR) by setting the 32 - n rightmost bits (in binary
notation of the address) to 1s.
➢ The number of address in the block can be found out by complementing
the mask “n”, converting it to its decimal equivalent, and then adding 1
to it (OR) by the formula 2(32 - n).

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

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.64


Network Address & Broadcast Addresses

◼ As already pointed out, like classful addressing, in classless addressing


➢ The first address in a block is reserved as the network address. It is
used to represent the network itself to the rest of the Internet.
➢ The last address in a block 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.
➢ The IP address 255.255.255.255 is reserved as the limited broadcast
address. It is used by a node present inside a network to broadcast a
packet to the remaining nodes present within the same network.

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.65


◼ For Example: In the address block 205.16.37.39/28
➢ The first address 205.16.37.32 is used as the network address.
➢ The last address 205.16.37.47 is used as the direct broadcast address.
➢ The remaining 14 numbers of addresses (205.16.37.33 - 205.16.37.46) can
be assigned to the hosts.
➢ The reserved address 255.255.255.255 is used as the limited broadcast
address.

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.66


Subnetting in Classless Addressing

◼ The entire concept, rules, and techniques of subnetting in classless addressing


is exactly same as that of the classful addressing. (So, they are not discussed again.)

◼ Let us see an example of subnetting in classless addressing:

➢ Suppose an organization XYZ is given a block 17.12.40.5/26 (first address


17.12.40.0, last address 17.12.40.63, number of host addresses 64 out of which 62
are usable). The organization has three departments D1, D2, and D3.
▪ D1 has 27 hosts (computers / routers).
▪ D2 has 14 hosts (computers / routers).
▪ D3 has 10 hosts (computers / routers).
So, when subnetting is done three subnets, let's say, S1, S2, and S3
should be created respectively for D1, D2, and D3. The subnetting
structure of the organization is given next.

[NOTE]: It can be observed that this is a case of VLSM. The procedure for FLSM is
the same.

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.67


17.12.40.0 (17.12.40.00000000) ⟶ Network address of XYZ and subnet address of S1
Address range 17.12.40.1 (17.12.40.00000001) ⟶ Address of the 1st host of S1
27 used
of S1 ……
addresses
(Total 17.12.40.27 (200.30.40.00011011) ⟶ Address of the 27th host of S1
addresses: 32, 17.12.40.28 (200.30.40.00011100) ⟶
Usable …… 3 unused addresses
addresses: 30) 17.12.40.30 (200.30.40.00011110) ⟶
17.12.40.31 (200.30.40.00011111) ⟶ Direct broadcast address of S1

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

17.12.40.48 (17.12.40.00110000) ⟶ Subnet address of S3


Address range 17.12.40.49 (17.12.40.00110001) ⟶ Address of the 1st host of S3
10 used
of S3 ……
addresses
(Total 17.12.40.58 (17.12.40. 00111010) ⟶ Address of the 10th host of S3
addresses: 16, 17.12.40.59 (17.12.40. 00111011) ⟶
Usable …… 4 unused addresses
addresses: 14) 17.12.40.62 (17.12.40.00111110) ⟶
17.12.40.63 (17.12.40. 00111111) ⟶ Direct broadcast address of XYZ and S3
Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.68
[Fig. 15.9: Subnetting Structure of XYZ - Classless Addressing]

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.69


➢ Observations: It can be observed that the subnetting process in
classless addressing is identical to that of the classful addressing.
1. The no. of addresses assigned to each subnet is a power of 2.
2. The addresses are assigned from larger to smaller subnets and
they are assigned in contiguous fashion.
3. The first address in the block (17.12.40.0) acts both as the network
address of XYZ and the subnet address of S1. Similarly, the last
address in the block (17.12.40.63) acts both as the direct
broadcast address of XYZ and the direct broadcast address of S3.
4. Subnetting reduces the number of usable addresses in a block.
For instance, if the organization XYZ is not subnetted then the
number of usable address in the block 17.12.40.5/26 would be 62
(64 - 2). However, with three subnets S, S2 and S3, the number of
usable address is 30 + 14 + 14 = 58 (or, 64 – 6).

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.70


5. The network part and the host part in the subnet addresses is
determined by the subnet size (number of hosts in the subnet).

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.

▪ Subnet Mask: The subnet mask of each subnet in classless


addressing can be found out in the same way as that of the
classful addressing.

Subnet mask (in /n notation) = 32 – host bits


= 32 – log2 (subnet size in power of 2).

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

➢ Routing / Forwarding: Identical to that of subnetting in classful


addressing.

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.72


Network Address Translation (NAT)
◼ Even with classless addressing, shortage of IPv4 address is still a problem.

◼ Network Address Translation (NAT) provides a partial solution to this problem.

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.73


◼ NAT - Concept:

➢ NAT enables a user / an organization to use a reserved set of addresses


(called, private addresses) internally and one or a small set of
addresses (from the remaining unreserved IPv4 addresses, called,
global / public addresses) externally. The traffic inside the organization
uses the private addresses & the traffic outside, the public addresses.

➢ Private Addresses: The following addresses are reserved as private


addresses by the Internet Authority.

Address Range Total


0.0.0.0 - 10.255.255.255 224
172.16.0.0 - 172.31.255.255 220
192.168.0.0 - 192.168.255.255 216

Any organization can use these addresses internally without the


permission from the Internet Authority. These addresses are unique
inside the organization, but not globally. No router will forward a packet
that has one of these addresses as the designation address.
Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.74
◼ NAT - Implementation: A typical NAT implementation is shown in Fig. 15.10.

[Fig. 15.10:
A NAT
Implementation]

➢ An organization that intends to implement NAT must be connected to


the Internet through a NAT enabled router (a router that runs NAT software).

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

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.75


[NOTE]: Why the NAT router generally uses a set of public address instead of just one
public address?

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.

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.76


➢ Address Translation: Since the rest of the Internet sees only the NAT
router with the public address, address translation (form private to public
address and vice versa) is required for all packets going and coming from
outside the organization. Address translation is done by the NAT router.

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

▪ For fault free address translation, the NAT router maintains a


NAT Translation Table. It normally has four entries: <Private IP,
Private Port, Public IP, Public Port>.
[NOTE] - Why these 4 entries?: Because the tuple <Private IP, Private Port>
uniquely identifies a computer within the organization and the tuple <Public
IP, Public Port> uniquely identifies a computer outside the organization.

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.77


[Fig. 15.11: NAT Address Translation]

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.78


IPv6 Addressing
Why IPv6 Addressing?
◼ Despite classless addressing, NAT, and DHCP (not discussed in this Chapter),
address depletion (shortage) is still a problem in IPv4.

◼ IPv4 also has other problems like,


➢ Lack of accommodation for real-time audio / video transmission.
➢ Lack of encryption and authentication mechanisms for some
applications.
◼ All these problems have been the motivation for IPv6.

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.80


IPv6 Addresses
◼ An IPv6 address is a 16-byte (octet) / 128-bit address.

◼ Address Space: The address space of IPv6 is 2128 (296 times the IPv4 address
space).

◼ Notations: Two notations are used.


➢ Binary notation.
➢ Hexadecimal Colon Notation (most common): In it, the 16 bytes are
grouped into 8 sections (2 bytes per section) separated by colons. The two
bytes in each section is represented as four hexadecimal digits.

[Fig. 15.12: IPv6


Addresses -
Binary and
Hexadecimal
Colon Notations]

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.81


➢ Abbreviation in Hexadecimal Colon Notation: In hexadecimal colon
notation, the leading zeros (not the trailing zeros) can be omitted.

[Fig. 15.13:
Abbreviated
IPv6
Addresses]

• Consecutive sections consisting of all zeros can be omitted.


• Note that this type of abbreviation is allowed only once per address, i.e., if there
are two runs of zero sections, only one of them can be abbreviated.

Problem: Expand the address 0:15::1:12:1213


Solution: 0 :15 : :1 :12 :1213
0000 :0015 :0000 :0000 :0000 :0001 :0012 :1213

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.82


IPv6 Address Categories
◼ The designers of IPv6 have divided the address space into 21 categories.

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

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.83


[Table 15.1: IPv6 Address Categories (Cont.)]

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 15.84


End of Chapter 15

You might also like