Network
Layer
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
Number System
• Unary
• Binary
• Octal
• Decimal
• Hexadecimal
• Ex. Convert into decimal,
hexadecimal and binary
Binary 1 bit 2 bits 3 bits
Number 0 00 000
System 1 01 001
• If n bit space is divided into k
parts, then the 10 010
• Total possible numbers in k
parts = 2^k
11 011
• Size of each part = 2^n/2^k = 100
2^(n-k)
n bits 101
k n-k 110
111
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.)
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
Q1. Change the following IPv4addresses
Solution from binary notation to
dotted-decimal notation. We replace each group of 8 bits with its equivalent
decimal number and add dots for separation.
Classful addressing
• 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.
Classes in binary and
dotted-decimal
notation
• 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.
Number of blocks and block size in classful IPv4
addressing
Default masks for classful 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 classless addressing was designed and
implemented.
Addressing • 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.
Classless
Addressing
• 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
Q2
A block of addresses is granted to a small organization. We know
that one of the addresses is [Link]/28. What is the first and
last address in the block?
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 [Link].
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 [Link]
A network configuration for the block [Link]/28
• A block of 16 addresses granted to a small organization
• 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 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.
Two-Level • Each address in the block can be considered as a two-
level hierarchical structure the leftmost n bits (prefix)
Hierarchy: No define the network; the rightmost 32 − n bits define the
Subnetting host.
What is Subnetting is the process of dividing a
Subnettin network into multiple logical sub-
networks.
g?
1 1 2
1
1 2 2 4 3
Subnetting and Supernetting
• 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)
Three-level hierarchy in an IPv4 address
• 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.
• Fixed Length Subnet Mask
(FLSM)- This strategy allows
all subnet masks to be
Subnettin the same size.
• Variable Length Subnet
g Types Mask (VLSM)- This strategy
allows all subnet masks to
be variable sizes.
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 - [Link]/24, using Fixed Length Subnet Mask (FLSM).
IP Address
Decimal- [Link]
Binary- 11001000.00001111.00000101.00000000
Subnet Mask- [Link]
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 [Link]
No. of Host in each subnet= 2^5= 32
Usable IP address in each subnet= 32-2=30
IP Address
Decimal- [Link]
Binary- 11001000.00001111.00000101.00000000
Subnet 1- 11001000.00001111.00000101.00000000
Subnet 2- 11001000.00001111.00000101.00100000
Subnet 3- 11001000.00001111.00000101.01000000
Subnet 4- 11001000.00001111.00000101.01100000
Subnet 5- 11001000.00001111.00000101.10000000
Subnet 8- 11001000.00001111.00000101.11100000
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, …
Classless Addressing: The Two Level
Hierarchy
Classless Addressing: Class Sizes
and Issues
Classless
Addressing
: N-Level
Subnet
Hierarchy
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
Classless Addressing Example
Consider a class B network address [Link]. 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
Configuration and addresses in a subnetted network
suppose an organization is given the block
[Link]/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.