2. Network Layer Tasks
Logical Addressing: The network layer adds a header that includes the logical
addresses of the sender and receiver to the packet coming from the upper layer.
Routing: When independent networks or links are connected together to create
an internetwork, routers or switches route packets to their final destination.
The network layer is responsible for the delivery of individual packets from the
source host to the destination host
3. Number System
• Unary
• Binary
• Octal
• Decimal
• Hexadecimal
• Ex. Convert into decimal,
hexadecimal and binary
4. Binary Number
System
• If n bit space is divided into k
parts, then the
• Total possible numbers in k
parts = 2^k
• Size of each part = 2^n/2^k =
2^(n-k)
1 bit 2 bits 3 bits
0 00 000
1 01 001
10 010
11 011
100
101
110
111
k n-k
n bits
5. IP Addressing Schemes : Static Partitioning (ARPANET)
8 bits 24 bits
NID HID
32 bits IPv4
address
Total number of network addresses = 2^8 = 256
Total number of hosts with one network = 2^24 = 16 M (approx.)
6. IPv4 ADDRESSES
• An IPv4 address is a 32-bit address that uniquely and
universally defines the connection of a device (for
example, a computer or a router) to the Internet.
• The address space of IPv4 is 232
or
4,294,967,296.
Dotted-decimal notation and binary notation for
an IPv4 address
9. Q1. 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.
14. Classes in binary and
dotted-decimal
notation
• IPv4 addressing, at its inception, used the concept of classes. This architecture is called classful addressing.
• In classful addressing, the address space is divided into five classes: A, B, C, D, and E.
Classful addressing
• In classful addressing, an IP address in class A, B, or C is divided into netid and hostid.
• A mask (also called the default mask), a 32-bit number made of contiguous 1s followed by contiguous
0s.
19. A subnet mask is a 32-bit number used to divide an IP
address into network and host portions. It helps
determine which part of an IP address belongs to the
network and which part belongs to the hosts (devices like
PCs, routers, etc.).
22. Classless
Addressing
• In classful addressing, a large part of the
available addresses were wasted. It is
replaced with classless addressing.
• To overcome address depletion and give
more organizations access to the Internet,
classless addressing was designed and
implemented.
• In IPv4 addressing, a block of addresses can
be defined as x.y.z.t /n (Classless Inter-
Domain Routing(CIDR) notation)
Where x.y.z.t defines one of the
addresses and the /n defines the mask.
23. • To simplify the handling of addresses, the Internet authorities
impose, three restrictions on classless address blocks:
1. The addresses in a block must be contiguous, one after
another.
2. The number of addresses in a block must be a power of
2 (I, 2, 4, 8, ... ).
3. The first address must be evenly divisible by the
number of addresses.
• The first address in the block can be found by setting the
rightmost 32 − n bits to 0s
Classless Addressing
24. Q2
Solution:
The binary representation of the given address is
11001101 00010000 00100101 00100111
If we set 32−28 rightmost bits to 0, we get
11001101 00010000 00100101 0010000 or 205.16.37.32.
The binary representation of the given address is
11001101 00010000 00100101 00100111
If we set 32 − 28 rightmost bits to 1, we get
11001101 00010000 00100101 00101111 or 205.16.37.47
A block of addresses is granted to a small organization. We know
that one of the addresses is 205.16.37.39/28. What is the first and
last address in the block?
25. A network configuration for the block 205.16.37.32/28
• The first address in a block is normally not assigned to any device; it is used as the network
address that represents the organization to the rest of the world.
First address is: 205.16.37.32 (Network Address) Subnet Mask:255.255.255.240
Last address is: 205.16.37.47(Broadcast Address) Total Subnet Addresses: 2^4=16 But usable is
14.
usable ip: 205.16.37.33-205.16.37.46(total is 14)
• A block of 16 addresses granted to a small organization
•Total Addresses in Subnet: 2^(32-28) = 16
•Subnet Block Size: 256 - 240 = 16
28. First and Last Address: AND/OR Operations
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.
30. Two-Level Hierarchy:
No Subnetting
• Each address in the block can be considered as a two-
level hierarchical structure the leftmost n bits (prefix)
define the network; the rightmost 32 − n bits define the
host.
34. Three-level hierarchy in an IPv4 address
• If an organization was granted a large block in class A or B, it could divide the addresses
into several contiguous groups and assign each group to smaller networks (called
subnets)
Subnetting and Supernetting
• In supernetting, an organization can combine several class C blocks to create a larger
range of addresses.
• Supernetting decreases the number of 1s in the mask.
35. Subnetting
Types
• Fixed Length Subnet Mask
(FLSM)- This strategy allows
all subnet masks to be
the same size.
• Variable Length Subnet
Mask (VLSM)- This strategy
allows all subnet masks to
be variable sizes.
36. Que. There is a requirement in a university to setup five Computer Labs (Lab1- 7 PCs; Lab2- 14
PCs; Lab3- 28 PCs; Lab4- 14 PCs; Lab5- 11 PCs ) in different departments for a Class C IPV4
address - 200.15.5.0/24, using Fixed Length Subnet Mask (FLSM).
IP Address
Decimal- 200.15.5.0
Binary- 11001000.00001111.00000101.00000000
Subnet Mask- 255.255.255.0
For setting up five departments, We need five subnetworks to be setup
Therefore, 3 bits need to be borrowed from host bits
Using 3bits, 2^3 =8 subnets can be created
11001000.00001111.00000101.00000000
New Subnet Mask- 11111111. 11111111. 11111111.11100000 or 255.255.255.224
No. of Host in each subnet= 2^5= 32
Usable IP address in each subnet= 32-2=30
38. How Do You Get IPs?
• IP address ranges controlled by IANA
Internet Assigned Number Authority
Roots go back to 1972, ARPANET, UCLA
Today, part of ICANN
IANA grants IPs to regional authorities
ARIN (American Registry of Internet Numbers) may grant you a range of IPs
You may then advertise routes to your new IP range
There are now secondary markets, auctions, …
42. Classless Addressing Examples
1. In a classless addressing scheme, a network has a /20 CIDR block assigned to it. What is the maximum
number of useful addresses that can be assigned to a host?
a. 4096
b. 4094
c. 4098
d. 2048
43. Solution:
For a /20 CIDR block, the network portion occupies 20bits,
leaving 12bits for the host portion (32−20=12).
Therefore, the total number of addresses in this subnet is:
2^12=4096 (total addresses).
In a typical IPv4 subnet, you lose two addresses for the network and
broadcast addresses.
Hence, the number of useful (assignable) host addresses is:
4096−2=4094.
Thus, the correct answer is 4094.
44. Classless Addressing Example
Consider a class B network address 130.50.0.0. The last 7 bits of the host id are allotted for host
number and the remaining 9 bits are reserved for subnet number. How many usable subnets and
usable number of hosts in each subnet are possible with the above addressing scheme?
a. 128, 512
b. 512, 128
c. 126, 510
d. None of these
45. • Since a Class B network by default has 16 host bits, subdividing them
into 9 bits for subnetting and 7 bits for host numbering yields:
1.Subnets:
2^9=512 possible subnets (modern practice allows using them all).
2.Hosts per Subnet:
2^7=128 total addresses per subnet →
126 usable host addresses (subtracting network and broadcast).
• Hence, there are 512 usable subnets, each providing 126 host
addresses
46. Configuration and addresses in a subnetted network
suppose an organization is given the block
17.12.14.0/26, which contains 64 addresses.
The organization has three offices and needs to divide
the addresses into three subblocks of 32, 16, and 16
addresses.
• Suppose the mask for the first subnet is n1, then 2^32- n1 must be
32, which means that n1 =27.
• Suppose the mask for the second subnet is n2, then 2^32- n2 must
be 16, which means that n2 = 28.
• Suppose the mask for the third subnet is n3, then 2^32- n3 must be
16, which means that n3 =28.