Network Layer Addressing
Contents
• Network layer services
• IPv4 addressing and classes
• IPv6 overview
• Subnetting
Network layer services
1. Logical Addressing (IP Addressing)
The network layer assigns unique logical
addresses to devices so they can be identified
globally.
• Uses Internet Protocol (IP)
Example: [Link]
• This ensures every device on a network has a
unique identity.
2. Routing (Path Determination)
Routing is the process of selecting the best path
for data to travel from source to destination.
• Done by routers using routing algorithms
• Considers factors like distance, cost, and
congestion
• Think of it like choosing the fastest route on
Google Maps.
3. Packet Forwarding
Once a path is selected, routers forward
packets from one network to another.
• Each router checks the destination IP and
sends the packet to the next hop (host or
router)
• This is the actual movement of data across
networks.
4. Fragmentation and Reassembly
Different networks support different maximum
packet sizes.
• The network layer breaks large packets into
smaller fragments
• At the destination, fragments are
reassembled
• Ensures compatibility across different
network types.
5. Error Handling and Diagnostics
The network layer helps detect and report
errors.
• Uses protocols like Internet Control Message
Protocol (ICMP)
Example: “Destination unreachable” messages
• Helps troubleshoot network issues.
6. Congestion Control
The network layer may provide basic
mechanisms to avoid network congestion.
• Works alongside transport layer for better
control
• Prevents the network from becoming
overloaded.
7. Connectionless Service
The network layer (especially IP) provides
connectionless communication.
• Each packet is treated independently
• No guaranteed delivery or order
• This makes it fast but less reliable (reliability
handled at higher layers).
Summary
In short, the network layer:
• Identifies devices (IP addressing)
• Finds the best path (routing)
• Moves data (forwarding)
• Handles packet size differences
(fragmentation)
• Reports errors (ICMP)
The network layer
• The purpose of the physical layer is to provide a
physical mechanism for transmitting data as signals.
• The purpose of the data link layer is to ensure the
integrity of the data sent over a given physical link
(such as MAC or NIC addresses).
• The purpose of the network layer is to provide a
mechanism for data to be sent from one device to
another over a route that might span many different
physical links.
• Routing is the process by which data is directed across
multiple links from one host to another.
IP Addresses
• Each connection to the Internet is given an IP address of
some form or another.
• No two connections on the Internet can have the same IP
address at the same time.
• However, these are still logical addresses because a given
connection’s IP address can change, or it can be
reassigned to a new device if the first one is disconnected
from the Internet.
• If a given device has multiple connections to the internet
(such as a router), each connection needs its own IP
address.
Network Addresses
• An IP address has network address of which
we need to find the first and last address
for two reasons –
• first address is address of routing or hub
device and
• last address gives the total size of a block of
addresses.
Internet Protocol (IP)
• Switching at the network layer in the Internet
uses the datagram approach
• Communication at the network layer in the Internet is
connectionless
• Position of IPv4 in TCP/IP protocol suite
IPv4 Addresses
• An IPv4 address is 32 bit address that uniquely and
universally defines the connection of a device.
• Unique means no two devices can have same address at
the same time on Internet.
Address Space
• It is the total number of addresses used by IPv4
protocol.
• If N bit address is used, the total addresses in the
address space will be 2N.
• IPv4 uses 32 bit addresses then the total number of
addresses in the address space is
• 232 = 4,294,967,296
What is IPv4 ?
[Link] IP2v4 address has 32 bits. (Binary Notation)
10000000. 00001011. 00000011. 00011111
NOTE:-Above notation is representation of IPv4 address
in binary format.
2. Another notation is Dotted Decimal
Notation [Link]
NOTE:- Above notation is representation of IPv4
address in dotted decimal notation.
3. Each of the octet range 0 to 255.
4. IPv4 address are unique and universal.
Types of IP addressing
• Classful addressing
• Classless Addressing
Classful Addressing
• In classful addressing, the address space is divided in to 5
classes: A, B, C, D, and E.
• Binary Notation starting bits of first octet will tell the class.
• In decimal notation, range of first octet tells the class to which
the address belongs.
First Second Third Fourth
Class Class First Octet
Octet octet octet octet
A 0 Any Any Any A 0 -127
B 10 Any Any Any B 128 – 191
C 110 Any Any Any C 192 – 223
D 1110 Any Any any D 224 – 239
E 1111 Any Any any
E 240 – 255
Classful addressing cont..
• Finding the Class in Binary and Dotted
Decimal Notation
Classful addressing cont..
• In classless addressing every entity is granted a block of
addresses as per requirement.
• In class addesing the address block must be contiguous.
• The number of addresses in a block must be a power of 2
(1, 2, 4 ,8…………..)
Network ID & Host ID
IPv4 address is divided into two parts:
• Network ID
• Host ID
• The class of IP address is used to determine the
bits used for network ID and host ID and the
number of total networks and hosts possible in
that class.
Network ID & Host ID
Network ID & Host ID cont..
• In classful logical addressing, the address is divided into two
parts – Net-id and host-id
For example,
• Class A address, the first byte is network-id and the rest 3
bytes are Host-id.
Class Binary Dotted-Decimal CIDR
A 11111111. 00000000.00000000.00000000 [Link] /8
B 11111111. 11111111. 00000000.00000000 [Link] /16
C 11111111.11111111.11111111.00000000 [Link] /24
Default mask help us find the Net-id and hosted of an ip-address.
The class in the form /n is called CIDR (Classless Inter Domain
Routing) which is used for Classless logical addressing.
Classless Addressing
• Classless Addressing
• Due to depletion of addresses, Classless Logical Addressing
was introduced to connect more organizations to the Internet.
Address blocks and Restrictions
• In classless logical addressing, size of the address block
depends on size and nature of the entity.
• For example, ISP may get thousands of address; home user
may get 2 addresses. To manage IP address, three
restrictions were imposed
• Address in a block must be contagious
• Number of address in the block must be power of 2.
• The first address must be evenly divisible by the number of
addresses.
IPv6 addressing
• It is almost a certainty that we will run out of
IP addresses someday.
• IPv6 tries to address this by expanding
the address space available.
• IPv4 addresses were 32 bits.
• IPv6 addresses are 128 bits.
Need of IPv6
• IPv6 addresses are four times the size of IPv4 addresses.
• For IPv4, this space is 32-bits (2^32) in size and contains
4,294,967,296
IPv4 addresses.
The IPv6 address space is 128-bits (2^128) in size,
containing
340,282,366,920,938,463,463,374,607,431,768,211,456 IPv6
addresses.
What is IPv6 ?
• An IPv6 address has 128 bits.
0010 0000 0000 0001 0000 1101 1011 1000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0101 0010
0000 0000 0000 0000 0000 0000 0000 0001
• NOTE:- Above notation is representation of IPv6 address
in binary format.
• To convert the above binary notation into IPv6 format
2001:0db8:0000:0000:0000:0052:0000:0001.
• This is an entirely “legal” representation, a well-formed
address
Examples of IPv6 Addresses in the
Preferred Format
Preferred Format of IPv6 Addresses
0000:0000:0000:0000:0000:0000:0000:0000
0000:0000:0000:0000:0000:0000:0000:0001
2001:0410:0000:1234:FB00:1400:5000:45FF
3ffe:0000:0000:0000:1010:2a2a:0000:0001
3FFE:0B00:0C18:0001:0000:1234:AB34:0002
FE80:0000:0000:0000:0000:0000:0000:0009
FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF
Transition IPv4 to IPv6
Integration and Co-existence Strategy
• The transition from IPv4 to IPv6 does not require an
upgrade on all nodes at the same time.
• Many transition mechanisms enable smooth
integration of IPv4 to IPv6.
• There are mechanisms available that allow IPv4 nodes
to communicate with IPv6 nodes.
• All of these mechanisms can be applied to different
situations.
Integration Methods
1. Dual Stack (Dual IP)
• Complete support for both Internet protocols, IPv4
and IPv6, in hosts and routers.
• Most preferred mechanism.
2. Tunnelling Techniques
• The encapsulation of packets of one IP version
number within packets of a second IP version
number in order to traverse clouds of the second IP
version number.
3. Translation Techniques
• Enables IPv6-only devices to communicate with IPv4-
only devices and vice versa.
• Least desirable set of mechanisms.
Dual Stack
• Conceptually easiest ways of introducing IPv6 to a network is
called the “dual stack mechanism”.
• A host or a router is equipped with both IPv4 and IPv6
protocol stacks in the operating system (though this may
typically be implemented in a hybrid way).
• Each node, called an “IPv4/IPv6 node”, is configured with
both IPv4 and IPv6 addresses.
• It can both send and receive datagrams belonging to both
protocols and thus communicate with every node in the IPv4
and IPv6 network.
• Well known and has been applied in the past for other
protocol transitions.
Dual stack
Mapping
Address Mapping
• Internet protocol is designed to as a best effort delivery
protocol,
but it lacks some features such as flow control and error
control.
• We need a protocol to create a mapping between physical
and logical address.
• IP packets use logical address (host to host).
• But to the packets to travel from one node to another node
physical address is used.
• So we need to encapsulate the logical address with
physical address, we need set of protocols called
ARP(address Resolution Protocol).
• Similarly for reverse mapping : RARP, BOOTP and DHCP is used.
Address mapping
• Physical address and logical address are two
different identifiers.
• Mapping can be done in two ways
• Static mapping
• Dynamic mapping
Static mapping
• It involves the creation of routing tables that associates a
logical
address with physical address.
• It is stored in each machine on the network.
• It has some limitations because physical address may change
in the
following ways;
• A machine could change its NIC, resulting in a new physical
address.
• In some LAN, the physical address changes every
time when the computer turned on (Apple).
• A mobile computer can move from one physical network
to another,
resulting physical address changes.
Dynamic mapping
• Each time a machine knows one of the two address
(either logical or physical).
• It can use a protocol to find the other one
(either logical or physical).
ARP: Address Resolution Protocol
◼ Map a logical address to a physical address
RARP: Reverse Address Resolution Protocol
◼ Map a physical address to a logical address
ARP and RARP
Position of ARP and RARP
Notice that ARP and RARP are supplemental to IP.
ARP operation
Operation
The sender knows the target’s IP address
IP asks ARP to create an ARP request message
◼ The sender physical address
◼ The sender IP address
◼ The target physical address field is filled with 0s
◼ The target IP address
The message is passed to the data link layer to
encapsulate in a data link frame
◼ Physical destination address is broadcast address
Definition of RARP
• RARP (Reverse Address Resolution Protocol) is also a network layer
protocol
• RARP is adapted from the ARP protocol and it is just reverse of ARP.
• RARP perform following steps to obtain an IP address from the
server.
• The sender broadcast the RARP request to all the other host present
in the network.
• The RARP request packet contains the physical address of the sender.
• The authorized RARP server replies directly to requesting host with
the RARP response packet which contains IP address for the sender.
• RARP is not being used in today’s networks. Because we have much
great featured protocols like BOOTP (Bootstrap Protocol) and DHCP
(Dynamic Host Configuration Protocol).
RARP Operation
Encapsulation of RARP packet
Comparison Chart
BASIS FOR
ARP RARP
COMPARISON
Address Reverse Address
Full Form
Resolution Protocol. Resolution Protocol.
Retrieves the logical
Retrieves the physical
Basic address for a computer
address of the receiver.
from the server.
ARP maps 32-bit logical RARP maps 48-bit
Mapping (IP) address to 48-bit physical address to 32-bit
physical address. logical (IP) address.
ICMP
Why ICMP is needed?
• The IP protocol is a best-effort delivery service that delivers a
datagram from its original source to its final destination
• However, it has two deficiencies: lack of error control and lack of
assistance mechanisms
• What happens if something goes wrong? What happens if a router
must discard a datagram because it cannot find a router to the final
destination, or because the time-to-live field has a zero value?
• The Internet Control Message Protocol (ICMP) has been designed
to compensate for the two deficiencies
ICMP Encapsulation
• ICMP itself is a network layer protocol. However, its messages are not
passed directly to the data link layer as would be expected.
• Instead, the messages are first encapsulated inside IP datagrams before
going to the lower layer
• The value of the protocol field in the IP datagram is 1 to indicate that the
IP data is an ICMP message
Types of ICMP Messages
• ICMP message are divided into two broad
categories: error-reporting messages and query
messages
• The error-reporting messages report problems that a
router or a host (destination) may encounter when it
processes an IP packet
• The query messages help a host or a
network manager get specific information from
a router or another host
Types of ICMP Messages (cont.)
Message Format
• An ICMP message has an 8-byte header and a variable-size data section
• The first field, ICMP type defines the type of the message and the Code
field specifies the reason for the particular message type , checksum is
used for error detection and correction.
• The rest of the header is specific for each message type
• The data section in error messages carries information for finding the
original packet that had the error
• In query messages, the data section carries extra information based on the
type of the query
General format of ICMP messages
Error Reporting
• IP is not concerned with error checking and error control
• ICMP does not correct errors, it simply reports them
• Five types of errors are handled: destination unreachable,
source quench, time exceeded, parameter problems, and
redirection
Packet Delivery
• The network layer supervises the handling of
the packets by the underlying physical
networks.
• The delivery of a packet to its final
destination is accomplished using two
different methods of delivery: direct
and indirect.
• Direct Delivery
• Indirect Delivery
Direct vs. Indirect Delivery
• Direct delivery - transmit datagram
across a single physical network to
the destination.
• Indirect delivery - transmit datagram
across multiple physical networks
(with the support of routers) to the
destination.
• How does a machine know which method
of delivery to use?
Direct Delivery and Indirect Delivery
Direct Delivery
• Map the destination IP address to a
physical address.
• Encapsulate the datagram in a physical
frame.
• Send the frame over the
physical network to the destination.
Direct Delivery
Direct delivery
Direct delivery
Indirect Delivery
• Encapsulate the datagram in a frame.
• Choose a router on the physical network.
• Send the frame to that router.
• Router forwards the datagram on towards its final
destination.
Indirect Delivery
A B
Link Link Link
Indirect delivery Indirect delivery
Subnetting
What is Subnetting?
Subnetting is the process of dividing a large IP
network into smaller, manageable sub-networks
(subnets).
• It is based on the Internet Protocol and operates at
the network layer of the OSI Model.
•
Instead of one large network, you create smaller
networks for better control and efficiency.
Why Subnetting?
Subnetting solves real network problems:
• Efficient use of IP addresses (avoids wastage)
• Improves network performance (reduces broadcast
traffic)
• Enhances security (isolates departments/networks)
• Simplifies management and troubleshooting
Example: A university network can be divided into
Admin, Students, and Labs.
Basic Concepts You Must Know
a) IP Address Structure (IPV4, IPV6)
An IPv4 address has 32 bits, divided into:
• Network portion
• Host portion
• Example: [Link]
Basic Concepts You Must Know
b) Subnet Mask
A subnet mask defines which part of the IP address is
network and which is host.
Example: [Link] → /24
The “/24” is called CIDR notation
• CIDR(Classless Interdomain Routing)
Basic Concepts You Must Know
c) CIDR Notation
CIDR = Classless Inter-Domain Routing
Example:
[Link]/24 → 24 bits for network
Default Classes
Default
Class IP Range Hosts
Mask
[Link] –
A /8 ~16 million
[Link]
[Link] –
B /16 ~65,000
[Link]
[Link] –
C /24 254
[Link]
Subnetting allows you to go beyond these fixed classes.
Subnetting ….
Subnetting involves borrowing bits from the
host portion to create subnets.
• Subnet bits: borrowed bits
• Host bits: remaining bits
• Subnet mask: updated mask after borrowing
Subnetting Formulas
Number of Subnets:
Number of Subnets = 𝟐𝒏
Number of Hosts per Subnet:
Hosts per Subnet = 𝟐𝒉 − 𝟐
Where:
n = number of borrowed bits
h = number of remaining host bits
“−2” accounts for:
• Network address
• Broadcast address
Example
Given:
Network: [Link]/24
Required: 4 subnets
Example
Step 1: Determine borrowed bits
We need at least 4 subnets:
2² = 4 → borrow 2 bits
Step 2: New subnet mask
Original: /24
New: /26
Subnet mask: [Link]
Example
Step 3: Calculate hosts
Remaining bits = 6
Hosts per subnet: 2⁶ − 2 = 62 hosts
Example
Step 4: Subnet ranges
Subnet Network Valid Host Broadcast
Address Range Address
1 [Link] .1 – .62 .63
2 [Link] .65 – .126 .127
3 [Link] .129 – .190 .191
4 [Link] .193 – .254 .255
Key Subnetting Steps
1. Identify required subnets or hosts
2. Borrow bits accordingly
3. Calculate new subnet mask
4. Determine:
• Network address (first IP address)
• First host
Valid Host Range
• Last host
• Broadcast address (Last IP address)