Lecture02 Network Layer Addressing
Lecture02 Network Layer Addressing
Chapter 05
Network Layer
Addressing
Shawqi Kharbash
1
Outline
• Introduction
• Network Layer Duties
• IP4 Addressing
– Classful addressing
– Classless addressing
2
Introduction
• The network layer in the TCP/IP protocol suite is
responsible for the host-to-host delivery of datagrams.
• It provides services to the transport layer and receives
services from the data-link layer.
3
Network Layer Duties
• Packetizing
– encapsulating the payload (data received from upper layer) in a
network-layer packet at the source and decapsulating the payload
from the network-layer packet at the destination.
• Fragmenting:
– datagram fragmentation is breaking it into smaller pieces, so that
packets may be formed that can pass through a link with a
smaller maximum transmission unit (MTU) than the original
datagram size.
• Routing
– determining optimal route for sending a packet from one host to
another
• Addressing
– identifying each device uniquely to allow global communication
4
Packetizing
5
Packetizing
• The destination host receives the network-layer packet from its data-
link layer, decapsulates the packet, and delivers the payload to the
corresponding upper-layer protocol.
6
Packetizing
7
Routing and Forwarding
• Routing
– The network layer is responsible for routing the packet from its
source to the destination.
– A physical network is a combination of networks (LANs and
WANs) and routers that connect them.
– There is more than one route from the source to the destination.
– The network layer is responsible for finding the best one among
these possible routes.
– The network layer needs to have some
specific strategies (routing protocols)
for defining the best route.
– Routing is applying strategies and
running some routing protocols
to create the decision-making
tables for each router
8
Routing and Forwarding
• Forwarding
– forwarding can be defined as the action applied by each router
when a packet arrives at one of its interfaces.
– The decision-making table a router normally uses for applying
this action is sometimes called the forwarding table and
sometimes the routing table.
– To make a decision,the router uses a piece of information in the
packet header, which can be the destination address or a label,
to find the corresponding output interface number in the
forwarding table.
9
IPV4 Addresses
• An IPv4 address is a 32-bit address that uniquely and
universally defines the connection of a device of (a host or
a router) to the Internet.
• The IP address is the address of the connection, not the
host or the router, because if the device is moved to
another network, the IP address may be changed.
• If a device has two connections to the Internet, via two
networks, it has two IPv4 addresses and so on.
10
Address Space & Notations
• An address space is the total number of addresses used
by the protocol. If a protocol uses b bits to define an
address, the address space is 2b because each bit can
have two different values (0 or 1).
• IPv4 uses 32-bit addresses, which means that the
address space is 232 or 4,294,967,296 .
• There are three common notations to show an IPv4
address: binary notation (base 2), dotted-decimal notation
(base 256), and hexadecimal notation (base 16).
11
Address Notation Conversion
Change the following IPv4 addresses from binary notation
to dotted-decimal notation.
Solution
We replace each group of 8 bits with its equivalent decimal
number and add dots for separation.
a) 129.11.11.239
b) 193.131.27.255
12
Address Notation Conversion
Change the following IPv4 addresses from dotted-decimal
notation to binary notation.
a) 111.56.45.78
b) 221.34.7.82
Solution
We replace each decimal number with its binary equivalent.
13
Address Notation
Solution
a. There must be no leading zero (045).
b. There can be no more than four numbers.
c. Each number needs to be less than or equal to 255.
d. A mixture of binary notation and dotted-decimal
notation is not allowed.
14
Hierarchy in Addressing
• A 32-bit IPv4 address is also hierarchical, but divided
only into two parts. The first part of the address, called
the prefix, defines the network; the second part of the
address, called the suffix, defines the node (connection
of a device to the Internet).
• A prefix can be fixed length or variable length (Classful
Addressing vs Classless Addressing)
15
Classful Addressing
• IPv4 address was designed with a fixed-length prefix, but
to accommodate both small and large networks, three
fixed-length prefixes were designed instead of one (n =
8, n = 16, and n = 24).
• The whole address space was divided into five classes
(class A, B, C, D, and E).
16
Classful Addressing
• Address Depletion:
– The addresses were not distributed properly, the Internet was
faced with the problem of the addresses being rapidly used up,
resulting in no more addresses available for organizations and
individuals that needed to be connected to the Internet.
17
Classless Addressing
• In classless addressing, the whole address space is
divided into variable length blocks. The prefix in an
address defines the block (network); the suffix defines
the node (device).
• Theoretically, we can have a block of 20, 21, 22, . . . , 232
addresses. One of the restrictions is that the number of
addresses in a block needs to be a power of 2.
18
Prefix Length: Slash Notation
• The prefix length, n, is added to the address, separated
by a slash. The notation is informally referred to as slash
notation and formally as classless interdomain routing or
CIDR (pronounced cider) strategy.
19
Address Mask
• A network mask or a default mask in classful addressing
is a 32-bit number with n leftmost bits all set to 1s and
(32 − n) rightmost bits all set to 0s. Since n is different for
each class in classful addressing, we have three default
masks in classful addressing
Lecture 17 20
Finding a Network Address Using
address Mask
21
Extracting Information from an
Classeless Address
• Given any address in the block, we normally like to know
three pieces of information about the block to which the
address belongs: the number of addresses, the first
address in the block, and the last address. Since the
value of prefix length, n, is given, we can easily find
these three pieces of information:
1. The number of addresses in the block is found as N = 2 32−n.
2. To find the first address, we keep the n leftmost bits and set the
(32 − n) rightmost bits all to 0s.
3. To find the last address, we keep the n leftmost bits and set the
(32 − n) rightmost bits all to 1s.
22
Example
A classless address is given as 167.199.170.82/27. We can find the
number of addresses, first and last addresses as follows.
n=27 then the number of addresses in the network is
232 − n = 25 = 32 addresses.
23
Address Mask
• An address mask is used to find the first and last
addresses in the block.
• The address mask is a 32-bit number in which the n
leftmost bits are set to 1s and the rest of the bits (32 − n)
are set to 0s.
– The first address can be found by ANDing the given addresses
with the mask.
– The last address can be found by ORing the given addresses
with the complement of the mask. The complement of a number
is found by changing each 1 to 0 and each 0 to 1.
– The number of addresses can be found by complementing the
mask, interpreting it as a decimal number, and adding 1 to it.
24
Example (using Network mask)
A classless address is given as 167.199.170.82/27. We can find the
number of addresses, first and last addresses as follows.
n=27 then the number of addresses in the network is
232 − n = 25 = 32 addresses.
25
Network Addresses
• The first address, the network address, is particularly
important because it is used in routing a packet to its
destination network.
26
Example
A classless address is given as 167.199.170.82/27. We can find the
number of addresses, first and last addresses as follows.
Mask of : 167.199.170.82/27 → 11111111 11111111 11111111 11100000
167.199.170.82/27 → 1 0 1 0 0 1 1 1 1 1 0 0 0 1 1 1 1 0 1 0 1 0 1 0 0 1 0 1 0 0 1 0
AND 11111111 11111111 11111111 111 0 0 0 0 0
First Address 1 0 1 0 0 111 11 0 0 0 111 1 0 1 0 1 0 1 0 0 1 0 0 0 0 0 0
167.199.170.82/27 → 1 0 1 0 0 1 1 1 1 1 0 0 0 1 1 1 1 0 1 0 1 0 1 0 0 1 0 1 0 0 1 0
OR 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 11111
Last Address 1 0 1 0 0 111 11 0 0 0 111 1 0 1 0 1 0 1 0 0 1 0 11111
27
Classful Addressing
• Subnetting and Supernetting
– To alleviate address depletion, two strategies were proposed
and, to some extent, implemented: subnetting.
– In subnetting, a class A or class B block is divided into several
subnets. Each subnet has a larger prefix length than the original
network.
• Advantage of Classful Addressing
– the prefix length in classful addressing is inherent in the address;
no extra information is needed to extract the prefix and the
suffix.
28
Subnetting
• Three levels of hierarchy can be created using subnetting.
An organization (or an ISP) that is granted a range of
addresses may divide the range into several subranges
and assign each subrange to a subnetwork (or subnet).
• Note that nothing stops the organization from creating
more levels. A subnetwork can be divided into several
sub-subnetworks. A sub-subnetwork can be divided into
several sub-sub-subnetworks. And so on.
Lecture 17 29
Designing Subnets
• Assume the total number of addresses granted to the organization
is N, the prefix length is n, the assigned number of addresses to
each subnetwork is Nsub, the prefix length for each subnetwork is
nsub, and the total number of subnetworks is s. Then, the following
steps need to be carefully followed to guarantee the proper
operation of the subnetworks.
1. The number of addresses in each subnetwork should be a power of 2.
2. The prefix length for each subnetwork should be found using the following
Lecture 17 30
Subnetting Example
An organization is granted the block 130.34.12.64/26. The organization
needs four subnetworks, each with an equal number of hosts. Design the
subnetworks and find the information about each network.
Lecture 17 31
Subnetting Example
Solution
Lecture 17 32
Subnetting Example
Lecture 17 33
Example
An organization is granted a block of addresses with the beginning
address 14.24.74.0/24. The organization needs to have 3 subblocks of
addresses to use in its three subnets as shown below:
– One subblock of 120 addresses.
– One subblock of 60 addresses.
– One subblock of 10 addresses.
Solution
34
Special Addresses
• All-Zeros Address
– The block 0.0.0.0/32, which contains only one single address, is
reserved for communication when a host needs to send an IPv4 packet
but it does not know its own address.
• All-Ones Address: Limited Broadcast Address
– The block 255.255.255.255/32, which contains one single address, is
reserved for limited broadcast address in the current network. A host
that wants to send a message to every other host can use this address
as a destination address in an IPv4 packet.
• Loopback Addresses
– The block 127.0.0.0/8 is used for the loopback address, which is an
address used to test the software on a machine. When this address is
used, a packet never leaves themachine; it simply returns to the
protocol software. It can be used to test the IPv4 software.
35
Summary
• We discussed:
– Introduction
– Network Layer Duties
– IP4 Addressing
– subnetting
36