0% found this document useful (0 votes)
11 views61 pages

Understanding IPv4 Addressing and Structure

Uploaded by

rishiadik54
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views61 pages

Understanding IPv4 Addressing and Structure

Uploaded by

rishiadik54
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Network Layer –

●​ Version − Version no. of Internet Protocol used (e.g. IPv4).

●​ IHL − Internet Header Length; Length of entire IP header.

●​ DSCP − Differentiated Services Code Point; this is Type of Service.

●​ ECN − Explicit Congestion Notification; It carries information about the congestion


seen in the route.

●​ Total Length − Length of entire IP Packet (including IP header and IP Payload).

●​ Identification − If IP packet is fragmented during the transmission, all the


fragments contain same identification number. to identify original IP packet they
belong to.

●​ Flags − As required by the network resources, if IP Packet is too large to handle,


these flags tells if they can be fragmented or not. In this 3-bit flag, the MSB is always
set to 0.

●​ Fragment Offset − This offset tells the exact position of the fragment in the original
IP Packet.

●​ Time to Live − To avoid looping in the network, every packet is sent with some TTL
value set, which tells the network how many routers (hops) this packet can cross. At
each hop, its value is decremented by one and when the value reaches zero, the
packet is discarded.

●​ Protocol − Tells the Network layer at the destination host, to which Protocol this
packet belongs to, i.e. the next level Protocol. For example protocol number of ICMP
is 1, TCP is 6 and UDP is 17.
●​ Header Checksum − This field is used to keep checksum value of entire header
which is then used to check if the packet is received error-free.

●​ Source Address − 32-bit address of the Sender (or source) of the packet.

●​ Destination Address − 32-bit address of the Receiver (or destination) of the packet.

●​ Options − This is optional field, which is used if the value of IHL is greater than 5.
These options may contain values for options such as Security, Record Route, Time
Stamp, etc.

1. IPv4 Addressing

Size: 32-bit address (e.g., [Link])​


Structure: Network ID + Host ID​
Address Types:​
- Unicast: One-to-one communication​
- Broadcast: One-to-all (e.g., [Link])​
- Multicast: One-to-many ([Link] – [Link])​
Notation: Dotted decimal (e.g., [Link])
IPv4 Address Format

An IPv4 address consists of 32 bit (binary digit), grouped into four section of
known as octets or bytes. Each octet has 8 bits and this bits can be represented
only in 0 or 1 form, and when they grouped together, they form a binary
number. Since each octet has 8 bits, it can represent 256 numbers ranging from
o to 255. These four octets are represented as decimal numbers, separated by
periods known as dotted decimal notation. For example IPv4
address [Link] consists of four octets.

Binary Representation

IPv4 is basically converted into binary form by computer although these are
usually seen in decimal form for human readability. Each octet is converted into
8 bit binary number . For instance [Link] in binary looks like:

●​ 185: 10111001

●​ 107: 01101011

●​ 80: 01010000

●​ 231: 11100111

So [Link] in binary is: 10111001.01101011.01010000.11100111

IPv4 Address Format


Parts of IPv4

IPv4 addresses consist of three parts:

●​ Network Part: The network part indicates the distinctive variety that's
appointed to the network. The network part conjointly identifies the
category of the network that's assigned.

●​ Host Part: The host part uniquely identifies the machine on your
network. This part of the IPv4 address is assigned to every host. ​
For each host on the network, the network part is the same, however,
the host half must vary.

●​ Subnet Number: This is the non obligatory part of IPv4. Local networks
that have massive numbers of hosts are divided into subnets
and subnet numbers are appointed to that.

Types of IPv4 Addressing

IPv4 basically supports three different types of addressing modes:

Types of IPv4 addressing

●​ Unicast Addressing Mode: This addressing mode is used to specify single


sender and single receiver. Example: Accessing a website.
●​ Broadcast Addressing Mode: This addressing mode is used to send
messages to all devices in a network. Example: sending a message in
local network to all the devices.

●​ Multicast Addressing Mode: This addressing mode is typically used


within a local network or across networks and sends messages to a group
of devices. Example: Streaming audio to multiple devices at once.

IPv4 Datagram Header

These fields together ensure the proper delivery, routing, fragmentation, and
reassembly of IP packets across the network.

IPV4 Header

●​ VERSION: Version of the IP protocol (4 bits), which is 4 for IPv4

●​ HLEN: IP header length (4 bits), which is the number of 32 bit words in


the header. The minimum value for this field is 5 and the maximum is 15.

●​ Type of service: Low Delay, High Throughput, Reliability (8 bits)

●​ Total Length: Length of header + Data (16 bits), which has a minimum
value 20 bytes and the maximum is 65,535 bytes.

●​ Identification: Unique Packet Id for identifying the group of fragments of


a single IP datagram (16 bits)
●​ Flags: 3 flags of 1 bit each : reserved bit (must be zero), do not fragment
flag, more fragments flag (same order)

●​ Fragment Offset: Represents the number of Data Bytes ahead of the


particular fragment in the particular Datagram. Specified in terms of
number of 8 bytes, which has the maximum value of 65,528 bytes.

●​ Time to live: Datagram’s lifetime (8 bits), It prevents the datagram to loop


through the network by restricting the number of Hops taken by a Packet
before delivering to the Destination.

●​ Protocol: Name of the protocol to which the data is to be passed (8 bits)

●​ Header Checksum: 16 bits header checksum for checking errors in the


datagram header

●​ Source IP address: 32 bits IP address of the sender

●​ Destination IP address: 32 bits IP address of the receiver

●​ Option: Optional information such as source route, record route. Used by


the Network administrator to check whether a path is working or not.

Characteristics of IPv4

●​ IPv4 could be a 32-bit IP Address.

●​ IPv4 could be a numeric address, and its bits are separated by a dot.

●​ The number of header fields is twelve and the length of the header field
is twenty.

●​ It has Unicast, broadcast, and multicast-style addresses.

●​ IPv4 supports VLSM (Virtual Length Subnet Mask).

●​ IPv4 uses the Post Address Resolution Protocol to map to the MAC
address.

Advantages of IPv4

●​ IPv4 security permits encryption to keep up privacy and security.


●​ IPV4 network allocation is significant and presently has quite 85000
practical routers.

●​ It becomes easy to attach multiple devices across an outsized network


while not NAT.

●​ This is a model of communication so provides quality service also as


economical knowledge transfer.

●​ IPV4 addresses are redefined and permit flawless encoding.

Limitations of IPv4

●​ IP relies on network layer addresses to identify end-points on the


network, and each network has a unique IP address.

●​ The world's supply of unique IP addresses is dwindling, and they might


eventually run out theoretically.

●​ If there are multiple hosts, we need the IP addresses of the next class.

●​ Complex host and routing configuration, non-hierarchical addressing,


difficult to re-numbering addresses, large routing tables, non-trivial
implementations in providing security, QoS (Quality of Service), mobility,
and multi-homing, multicasting, etc. are the big limitations of IPv4 so
that's why IPv6 came into the picture.

Classes of IPv4 Address

There are around 4.3 billion IPv4 addresses and managing all those addresses
without any classification is next to impossible. For easier management and
assignment IP addresses are organized in numeric order and divided into the
following 5 classes:

IP Class Address Range Maximum number of networks


Class
1-126 126 (27-2)
A

Class B 128-191 16384

Class C 192-223 2097152

Class
224-239 Reserve for multitasking
D

Class E 240-254 Reserved for Research and development

●​ Class A ([Link] to [Link]): Used for very large networks (like


multinational companies). Supports up to 16 million hosts per network.

●​ Class B ([Link] to [Link]): Used for medium-sized networks,


such as large organizations. Supports up to 65,000 hosts per network.

●​ Class C ([Link] to [Link]): Used for smaller networks, like


small businesses or home networks. Supports up to 254 hosts per
network.

●​ Class D ([Link] to [Link]): Reserved for multicast groups


(used to send data to multiple devices at once). Not used for traditional
devices or networks.

●​ Class E ([Link] to [Link]): Reserved for experimental


purposes and future use.

2. IPv6 Addressing
Size: 128-bit address (e.g., 2001:0db8:85a3::8a2e:0370:7334)​
Notation: Hexadecimal, separated by colons​
Features: Larger address space, no NAT, auto-configuration, built-in security (IPSec)​
Address Types: Unicast, Multicast, Anycast

IPv6 Address Structure:

An IPv6 address consists of 128 bits, and it’s logically divided into two main parts, each
serving a distinct purpose in network communication:

●​ Prefix (Network Portion) – The first 64 bits identify the network or subnet.

●​ Interface Identifier (Interface ID) – The last 64 bits uniquely identify a device on
that network.

This standardized 64/64 split isn’t just for convenience — it plays a crucial role in scalable
routing, simplified network segmentation, and automatic address configuration (such
as SLAAC).

IPv6 Address Structure

Prefix (First 64 Bits): Understanding the Network Portion

In the IPv6 addressing scheme, the first 64 bits of the 128-bit address are known as
the prefix, which identifies the network segment to which a device belongs. If you imagine
an IP address as a complete mailing address, the prefix would be equivalent to the street
name and city — it tells the world where a device is located within the more extensive
global network.

Devices that share the same prefix are part of the same subnet and can communicate
directly with each other without the need for a router.
The 64-bit prefix is usually composed of two key parts:

Global Routing Prefix​


This is the portion of the address assigned by your Internet Service Provider (ISP) or
a regional Internet registry. It typically spans the first 48 bits and identifies your
organization or customer network globally.

Subnet ID​
The remaining 16 bits (from bits 49 to 64) are used internally by your organization to
divide the global prefix into multiple subnets. This allows network administrators to
segment the internal network for better performance, organization, and security, much like
splitting a city into neighborhoods.

Let’s take the following IPv6 address with CIDR notation:

1 2001:db8:abcd:1234::/64

●​ 2001:db8:abcd:1234 is the prefix

●​ /64 means the first 64 bits are reserved for network identification

This means all devices on this subnet will share the same 64-bit prefix but have unique
Interface Identifiers in the last 64 bits.

This separation allows for:

●​ Efficient hierarchical routing: ISPs can aggregate routes more easily

●​ Simplified address management: Organizations can predefine subnet structures

●​ Better scalability: You can have 2⁶⁴ addresses in each subnet — more than enough
for any use case

What is IPv6?

The next generation Internet Protocol (IP) address standard, known as IPv6, is meant to
work in cooperation with IPv4. To communicate with other devices, a computer,
smartphone, home automation component, Internet of Things sensor, or any other
Internet-connected device needs a numerical IP address.

Because so many connected devices are being used, the original IP address scheme, known
as IPv4, is running out of addresses. This new IP address version is being deployed to fulfil
the need for more Internet addresses. With 128-bit address space, it allows 340 undecillion
unique address space. IPv6 support a theoretical maximum of 340, 282, 366, 920, 938, 463,
463, 374, 607, 431, 768, 211, 456.
Representation of IPv6

An IPv6 address consists of eight groups of four hexadecimal digits separated by ' . ' and
each Hex digit representing four bits so the total length of IPv6 is 128 bits. Structure given
below.

IPV6-Representation

[Link]
The first 48 bits represent Global Routing Prefix. The next 16 bits represent the student ID
and the last 64 bits represent the host ID. The first 64 bits represent the network portion
and the last 64 bits represent the interface id.

●​ Global Routing Prefix: The Global Routing Prefix is the portion of an IPv6 address
that is used to identify a specific network or subnet within the larger IPv6 internet.
It is assigned by an ISP or a regional internet registry (RIR).

●​ Student Id: The portion of the address used within an organization to identify
subnets. This usually follows the Global Routing Prefix.

●​ Host Id: The last part of the address, is used to identify a specific host on a network.

Example: 3001:0da8:75a3:0000:0000:8a2e:0370:7334

Types of IPv6 Address

Now that we know about what is IPv6 address let’s take a look at its different types.

●​ Unicast Addresses : Only one interface is specified by the unicast address. A packet
moves from one host to the destination host when it is sent to a unicast address
destination.

●​ Multicast Addresses: It represents a group of IP devices and can only be used as the
destination of a datagram.

●​ Anycast Addresses: The multicast address and the anycast address are the same.
The way the anycast address varies from other addresses is that it can deliver the
same IP address to several servers or devices. Keep in mind that the hosts do not
receive the IP address. Stated differently, multiple interfaces or a collection of
interfaces are assigned an anycast address.

3. Subnetting
Concept: Dividing a large network into smaller subnetworks​
Purpose: Efficient IP use, better security, reduced broadcast traffic​
Subnet Mask Example: [Link] = /24​
Formulas:​
- Subnets = 2^n (n = borrowed bits)​
- Hosts per subnet = 2^h - 2 (h = host bits)

4. CIDR (Classless Inter-Domain Routing)


Format: IP/prefix (e.g., [Link]/24)​
Purpose: Efficient address allocation, removes class limits​
Allows: Route aggregation (supernetting)
Introduction To Subnetting

Subnetting is the process of dividing a large network into smaller networks called subnets.
Each subnet provides its own space for devices to communicate, improving network
performance, security, and management.

Example: In a company, different departments (Sales, HR, IT) can have their own subnets,
keeping their traffic separate and organized.

Subnetting

Why Subnetting is Important

Let's consider a company that follows classful addressing, it has a Class C network
([Link]/24) with 256 IP addresses. It has three departments:

Subnetting

Without subnetting, all departments share the same network, and all 256 IP addresses are
available to everyone, which leads to:
●​ IP Waste: Only 80 devices used out of 256 addresses i.e 176 wasted.

●​ Performance Issues: All traffic floods the same network, slowing communication.

●​ Security Risks: Devices from different departments can access each other freely.

With Subnetting, we split the network into three subnets, allocating just enough IP
addresses for each department:

Department Devices IPs Allocated (after subnetting)

Sales 20 32 ([Link]/27)

HR 10 16 ([Link]/28)

IT 50 64 ([Link]/26)

By subnetting, we:

●​ Efficient IP usage: Only 112 addresses used, leaving space for growth.

●​ Better performance: Traffic stays within each subnet.

●​ Improved security: Each department is isolated.

Key Concepts in Subnetting

IP Addressing

An IP address is made up of different parts, each serving a specific purpose in identifying a


device on a network. An IPv4 address consists of four parts called "octets," separated by dots
(e.g., [Link]). It has two main sections:

●​ Network Portion: Identifies the network the device belongs to.

●​ Host Portion: Uniquely identifies a device within the network.

IPv4 addresses are divided into classes based on the length of the network and host
portions:

●​ Class A: 8-bit network ID, 24-bit host ID.

●​ Class B: 16-bit network ID, 16-bit host ID.


●​ Class C: 24-bit network ID, 8-bit host ID.

Classful Addressing

What is a Subnet Mask?

A subnet mask is a 32-bit number used in IP addressing to separate the network portion of
an IP address from the host portion. It helps computers and devices determine which part of
an IP address refers to the network they are present, and which part refers to their specific
location or address within that network.

Subnet mask

CIDR Notation: A Simplified Approach to Subnetting


Instead of using a long subnet mask (e.g., [Link]), CIDR uses a simple format
like /24. The number after the slash (/n) represents the number of bits used for
the network portion of the IP address.

How Subnetting Works?

The working of subnets starts in such a way that firstly it divides the subnets into smaller
subnets. For communicating between subnets, routers are used. Each subnet allows its
linked devices to communicate with each other. Subnetting for a network should be done in
such a way that it does not affect the network bits.

In class C the first 3 octets are network bits so it remains as it is.

●​ For Subnet-1: The first bit which is chosen from the host id part is zero and the
range will be from (193.1.2.00000000 till you get all 1's in the host ID part i.e,
193.1.2.01111111) except for the first bit which is chosen zero for subnet id part.

Thus, the range of subnet 1 is: [Link] to [Link]

Subnet id of Subnet 1 is: [Link]​


The direct Broadcast id of Subnet-1 is: [Link]​
The total number of hosts possible is: 126 (Out of 128, 2 id's are used for Subnet id & Direct
Broadcast id)​
The subnet mask of Subnet- 1 is: [Link]

●​ For Subnet-2: The first bit chosen from the host id part is one and the range will be
from (193.1.2.100000000 till you get all 1's in the host ID part i.e,
193.1.2.11111111).

Thus, the range of subnet-2 is: [Link] to [Link]

Subnet id of Subnet 2 is : [Link]​


The direct Broadcast id of Subnet-2 is: [Link]​
The total number of hosts possible is: 126 (Out of 128, 2 id's are used for Subnet id & Direct
Broadcast id)​
The subnet mask of Subnet- 2 is: [Link]​
The best way to find out the subnet mask of a subnet is to set the fixed bit of host-id to 1 and
the rest to 0.

Finally, after using the subnetting the total number of usable hosts is reduced from 254 to
252.

Note:

1.​ To divide a network into four (2 2 ) parts you need to choose two bits from the host
id part for each subnet i.e, (00, 01, 10, 11).
2.​ To divide a network into eight (2 3 ) parts you need to choose three bits from the
host id part for each subnet i.e, (000, 001, 010, 011, 100, 101, 110, 111) and so on.

3.​ We can say that if the total number of subnets in a network increases the total
number of usable hosts decreases.

The network can be divided into two parts: To divide a network into two parts, you need
to choose one bit for each Subnet from the host ID part.

Subnet

In the above diagram, there are two Subnets.

Note: It is a class C IP so, there are 24 bits in the network id part and 8 bits in the host id
part.

Advantages of Subnetting

●​ Improved Security: Subnets isolate departments, preventing unauthorized access


(e.g., HR data hidden from Sales).

●​ Traffic Prioritization: Critical subnets (e.g., Sales hosting video conferences) can
get higher priority.

●​ Easier Maintenance: Smaller, segmented networks are simpler to manage.

Disadvantages of Subnetting

●​ Extra Overhead: Each subnet wastes 2 IP addresses (network ID and broadcast


address).

●​ Higher Cost: Subnetting often requires additional devices like routers and switches,
increasing expenses.
●​ More Complexity: Compared to a single flat network, subnetting adds extra steps in
communication and requires careful planning.

5. Routing Algorithms
Distance Vector: Routers share hop counts (e.g., RIP)​
Link State: Builds full topology (e.g., OSPF - Dijkstra)​
Shortest Path: Minimum cost path (Dijkstra, Bellman-Ford)​
Flooding: Packet sent to all neighbors​
Broadcast/Multicast: One-to-all / One-to-group​
Hierarchical Routing: Divides network into regions

5.1Distance Vector Routing (DVR) Protocol

Distance Vector Routing (DVR) is a protocol where each router keeps a table showing the
distance (in hops) to all other routers. Routers regularly share these tables with neighbors,
so they can update routes and always find the shortest, most efficient paths for data.

The Distance Vector Routing Algorithm is based on the Bellman-Ford Algorithm. It was first
used in the old ARPANET.

●​ Each router tells its neighbors about changes in the network topology (like new
links or failures).

●​ Each router uses this information to recalculate the shortest paths to every
destination.

Bellman-Ford Basics

Each router maintains a distance vector table that shows the shortest known distance to
every other router.

Information stored in a DV router includes:

●​ A unique Router ID

●​ Link cost for each connection (can be static or dynamic)

●​ Number of intermediate hops needed to reach other routers

Initialization:

●​ Distance to itself = 0

●​ Distance to all other routers = infinity

How Distance Vector Algorithm works?


1. Routers share information: Each router sends its distance vector to all its neighbors.

2. Routers update information:

●​ When a router receives a neighbor’s table, it saves it.

●​ If new information changes the shortest path, the router updates its own table.

●​ Updates also occur if a link goes down.

𝐷𝑥(𝑦) = 𝑚𝑖𝑛⁡{𝐶(𝑥, 𝑣) + 𝐷𝑣(𝑦)}

3. Distance calculation:​
The cost of reaching a destination is calculated using the Bellman-Ford equation:

Where:

●​ Dx​(y) = cost from router x to destination y

●​ C(x,v) = cost from router x to neighbor v

●​ Dv(y)= cost from neighbor v to destination y

Example: Consider 3-routers X, Y and Z as shown in figure. Each router have their routing
table. Every routing table will contain distance to the destination nodes.
Consider router X , X will share it routing table to neighbors and neighbors will share it
routing table to it to X and distance from node X to destination will be calculated using
bellmen- ford equation.

Dx(y) = min { C(x,v) + Dv(y)} for each node y ? N

As we can see that distance will be less going from X to Z when Y is intermediate node(hop)
so it will be update in routing table X.
Similarly for Z also:
Finally the routing table for all:
Applications of Distance Vector Routing Algorithm

The Distance Vector Routing Algorithm has several uses:

●​ Computer Networking : It helps route data packets in networks.

●​ Telephone Systems: It's used in some telephone switching systems.

●​ Military Applications: It has been used to route missiles.

Advantages

●​ Shortest Path: Finds the best route for data.

●​ Wide Usage: Works in LANs, MANs, and WANs.

●​ Easy to Implement: Simple setup with low resource requirements.

Disadvantages
●​ Slow Convergence: Takes time to adapt to changes.

●​ Count-to-Infinity Problem: Can keep increasing hop counts endlessly in some


failure cases.

●​ More Traffic: Routers share updates periodically, even if nothing changes, which
wastes bandwidth.

●​ Scalability Issues: Large networks mean larger routing tables, which can cause
congestion on WAN links.

5.2 Bellman–Ford Algorithm

Given a weighted graph with V vertices and E edges, along with a source vertex src, the task
is to compute the shortest distances from the source to all other vertices. If a vertex is
unreachable from the source, its distance should be marked as 108. In the presence of a
negative weight cycle, return -1 to signify that shortest path calculations are not feasible.

Examples:

Input: V = 5, edges = [[0, 1, 5], [1, 2, 1], [1, 3, 2], [2, 4, 1], [4, 3, -1]], src = 0

Output: [0, 5, 6, 6, 7]​


Explanation: Shortest Paths: ​
For 0 to 1 minimum distance will be 5. By following path 0 → 1​
For 0 to 2 minimum distance will be 6. By following path 0 → 1 → 2​
For 0 to 3 minimum distance will be 6. By following path 0 → 1 → 2 → 4 → 3 ​
For 0 to 4 minimum distance will be 7. By following path 0 → 1 → 2 → 4

Input: V = 4, edges = [[0, 1, 4], [1, 2, -6], [2, 3, 5], [3, 1, -2]], src = 0
Output: [-1]​
Explanation: The graph contains a negative weight cycle formed by the path 1 → 2 → 3 → 1,
where the total weight of the cycle is negative.
6. Routing Protocols
RIP - Distance Vector, hop count, max 15 hops​
OSPF - Link State, uses Dijkstra algorithm​
BGP - Path Vector, used between autonomous systems

Difference between RIP and OSPF

What is RIP?

RIP stands for Routing Information Protocol in which distance vector routing protocol is
used for data/packet transmission. In the Routing Information Protocol (RIP), the maximum
number of Hop is 15, because it prevents routing loops from source to destination.
Advantages of RIP

●​ Simplicity: RIP is very simple and can be used to configure and implement and is
thus suitable for use in a network that has less nodes.

●​ Low Resource Usage: RIP also low on complexity, and thus makes an excellent
protocol for environments with low processing power.

●​ Compatibility: RIP is supported by all most all the networking devices hence there
is the ability to fine tune work on different hardware.

Disadvantages of RIP

●​ Scalability Issues: RIP is not suitable for large network as it has only 15 hops limit
for routing the data within the network.
●​ Slow Convergence: RIP ‘convergence time’ can be long depending on the size of the
network and as a result, they can lead to temporary routing loops or sub-optimal
routing.

●​ Limited Features: However, basic services provided by RIP do not include such
facilities as hierarchical routing or load sharing that complicates the service usage in
the networks of a larger scale.

What is OSPF?

OSPF stands for Open Shortest Path First which uses a link-state routing algorithm. Using
the link state information which is available in routers, it constructs the topology in which
topology determines the routing table for routing decisions. It supports both variable-length
subnet masking and classless inter-domain routing addressing models. Since it uses
Dijkstra’s algorithm, it computes the shortest path tree for each route. The main advantage
of the OSPF (Open Shortest Path first) is that it handles the error detection by itself and it
uses multicast addressing for routing in a broadcast domain.

OSPF is an Interior Gateway Protocol (IGP), where routers connect networks using the
Internet Protocol (IP). It is a router protocol which is used to find the best path for packets
when they are passing through the set of connected networks simultaneously. The main
disadvantage of OSPF is that it is difficult than other protocols.
Advantages of OSPF

●​ Scalability: OSPF is designed for the large network with no restrictions placed upon
the hop count.

●​ Fast Convergence: The OSPF is faster to converge, meaning that it takes the least
time to restore the network in cases of a breakdown, making the network
performances to be even better.

●​ Hierarchical Design: OSPF supports the multi-area routing which assists in


minimizing the routing overhead in the networks.

●​ Load Balancing: routing – OSPF has the capability of supporting equal cost
multi-path or simply known as ECMP routing for load balancing.

Disadvantages of OSPF
●​ Complexity: OSPF is much more difficult to configure and to administer as
compared to RIP which may be time consuming and might even need the services of
a professional.

●​ Higher Resource Usage: OSPF however requires a lot of processing power and
memory which might be construed as limiting factors especially for small routers.

●​ Initial Configuration Effort: This is achieved at the cost of having greater initial
configuration efforts in the large or hierarchical OSPF networks.

Difference Between RIP and OSPF

RIP OSPF

RIP Stands for Routing Information


OSPF stands for Open Shortest Path First.
Protocol.

RIP works on the Bellman-Ford


OSPF works on Dijkstra algorithm.
algorithm.

It is a link-state protocol and it analyzes


It is a Distance Vector protocol and it
different sources like the speed, cost and
uses the distance or hops count to
path congestion while identifying the
determine the transmission path.
shortest path.

It is used for larger size organizations in the


It is used for smaller size organizations.
network.

There is no such restriction on the hop


It allows a maximum of 15 hops.
count.

It is not a more intelligent dynamic It is a more intelligent routing protocol than


routing protocol. RIP.
RIP OSPF

The networks are classified as areas,


The networks are classified as areas and
sub-areas, autonomous systems, and
tables here.
backbone areas here.

Its administrative distance is 120. Its administrative distance is 110.

RIP uses UDP(User Datagram OSPF works for IP(Internet


Protocol) Protocol. Protocol) Protocol.

It calculates the metric in terms of Hop It calculates the metric in terms of


Count. bandwidth.

In RIP, the whole routing table is to be


In OSPF, parts of the routing table are only
broadcasted to the neighbors every 30
sent when a change has been made to it.
seconds by the routers.

RIP utilizes less memory compared to OSPF device resource requirements are CPU
OSPF but is CPU intensive like OSPF. intensive and memory.

It consumes more bandwidth because of


It consumes less bandwidth as only part of
greater network resource requirements
the routing table is to send.
in sending the whole routing table.

OSPF's multicast addresses are [Link]


Its multicast address is [Link].
and [Link].
Dijkstra's Algorithm based Common Questions

Dijkstra’s Algorithm was introduced by Dutch computer scientist Edsger W. Dijkstra in


1956. It is one of the most popular algorithms in graph theory, used to find the shortest
path from a single source to all other vertices in a graph with non-negative edge weights.

The algorithm works by maintaining a set of visited and unvisited vertices. Starting from the
source it repeatedly picks the vertex with the smallest tentative distance, updates the
distances of its neighbours and continues until all vertices are processed or the destination
is reached.

Can Dijkstra's Algorithm work on both Directed and Undirected graphs?

Yes, Dijkstra's algorithm can work on both directed graphs and undirected graphs as this
algorithm is designed to work on any type of graph as long as it meets the requirements of
having non-negative edge weights and being connected.

●​ In a directed graph, each edge has a direction, indicating the direction of travel
between the vertices connected by the edge. In this case, the algorithm follows the
direction of the edges when searching for the shortest path.

●​ In an undirected graph, the edges have no direction, and the algorithm can
traverse both forward and backward along the edges when searching for the
shortest path.

Algorithm Steps

1.​ Mark the source node with a current distance of 0 and the rest with infinity.
2.​ Set the non-visited node with the smallest current distance as the current node.

3.​ For each neighbor, N of the current node adds the current distance of the adjacent
node with the weight of the edge connecting 0->1. If it is smaller than the current
distance of Node, set it as the new current distance of N.

4.​ Mark the current node 1 as visited.

5.​ Go to step 2 if there are any nodes are unvisited.

How does Dijkstra's Algorithm works?

Let's see how Dijkstra's Algorithm works with an example given below:

Dijkstra's Algorithm will generate the shortest path from Node 0 to all other Nodes in the
graph.

Consider the below graph:

Dijkstra's Algorithm

The algorithm will generate the shortest path from node 0 to all the other nodes in the
graph.

For this graph, we will assume that the weight of the edges represents the distance
between two nodes.

Initially we have:
●​ The Distance from the source node to itself is 0. In this example the source node is 0.

●​ The distance from the source node to all other node is unknown so we mark all of
them as infinity.

Example: 0 -> 0, 1-> ∞,2-> ∞,3-> ∞,4-> ∞,5-> ∞,6-> ∞.

●​ we'll also have an array of unvisited elements that will keep track of unvisited or
unmarked Nodes.

●​ Algorithm will complete when all the nodes marked as visited and the distance
between them added to the path. Unvisited Nodes:- 0 1 2 3 4 5 6.

Step 1: Start from Node 0 and mark Node as visited as you can check in below image visited
Node is marked red.

Dijkstra's Algorithm

Step 2: Check for adjacent Nodes, Now we have to choices (Either choose Node1 with
distance 2 or either choose Node 2 with distance 6 ) and choose Node with minimum
distance. In this step Node 1 is Minimum distance adjacent Node, so marked it as visited
and add up the distance.

Distance: Node 0 -> Node 1 = 2


Dijkstra's Algorithm

Step 3: Then Move Forward and check for adjacent Node which is Node 3, so marked it as
visited and add up the distance, Now the distance will be:

Distance: Node 0 -> Node 1 -> Node 3 = 2 + 5 = 7

Dijkstra's Algorithm

Step 4: Again we have two choices for adjacent Nodes (Either we can choose Node 4 with
distance 10 or either we can choose Node 5 with distance 15) so choose Node with
minimum distance. In this step Node 4 is Minimum distance adjacent Node, so marked it as
visited and add up the distance.

Distance: Node 0 -> Node 1 -> Node 3 -> Node 4 = 2 + 5 + 10 = 17


Dijkstra's Algorithm

Step 5: Again, Move Forward and check for adjacent Node which is Node 6, so marked it as
visited and add up the distance, Now the distance will be:

Distance: Node 0 -> Node 1 -> Node 3 -> Node 4 -> Node 6 = 2 + 5 + 10 + 2 = 19

Dijkstra's Algorithm

So, the Shortest Distance from the Source Vertex is 19 which is optimal one

For an implementation of Dijkstra's algorithm, refer to this article.

Why Dijkstra's Algorithms fails for the Graphs having Negative Edges ?
The problem with negative weights arises from the fact that Dijkstra's algorithm assumes that
once a node is added to the set of visited nodes, its distance is finalized and will not change.
However, in the presence of negative weights, this assumption can lead to incorrect results.

Consider the following graph for the example:

In the above graph, A is the source node, among the edges A to B and A to C , A to B is the
smaller weight and Dijkstra assigns the shortest distance of B as 2, but because of existence
of a negative edge from C to B , the actual shortest distance reduces to 1 which Dijkstra fails
to detect.

Note: We use Bellman Ford's Shortest path algorithm in case we have negative edges in the
graph.

Dijkstra's Algorithms vs Bellman-Ford Algorithm

Dijkstra's algorithm and Bellman-Ford algorithm are both used to find the shortest path in a
weighted graph, but they have some key differences. Here are the main differences between
Dijkstra's algorithm and Bellman-Ford algorithm:

Feature: Dijkstra's Bellman Ford

Bellman-Ford algorithm is
optimized for finding the
optimized for finding the
shortest path between a
shortest path between a
single source node and all
single source node and all
Optimization other nodes in a graph
other nodes in a graph
Feature: Dijkstra's Bellman Ford

with non-negative edge with negative edge


weights weights.

the Bellman-Ford
Dijkstra's algorithm uses a
algorithm relaxes all edges
greedy approach where it
in each iteration, updating
chooses the node with the
the distance of each node
smallest distance and
by considering all possible
updates its neighbors
Relaxation paths to that node

Dijkstra's algorithm has a


time complexity of O(V^2) Bellman-Ford algorithm
for a dense graph and O(E has a time complexity of
log V) for a sparse graph, O(VE), where V is the
where V is the number of number of vertices and E is
vertices and E is the the number of edges in the
number of edges in the graph.
Time Complexity graph.

Dijkstra's algorithm does


Bellman-Ford algorithm
not work with graphs that
can handle negative edge
have negative edge
weights and can detect
weights, as it assumes that
negative-weight cycles in
all edge weights are
the graph.
Negative Weights non-negative.
Bellman Ford's Algorithm Dijkstra's Algorithm

Dijkstra's Algorithm does not work when


Bellman Ford's Algorithm works when
there is negative weight edge. But will
there is negative weight edge, it also
definitely not work when there is a negative
detects the negative weight cycle.
weight cycle.

The result contains the vertices which The result contains the vertices containing
contains the information about the whole information about the network, not
other vertices they are connected to. only the vertices they are connected to.

It can easily be implemented in a It can not be implemented easily in a


distributed way. distributed way.

It is more time consuming than


It is less time consuming. The time complexity
Dijkstra's algorithm. Its time
is O(E logV).
complexity is O(VE).

Dynamic Programming approach is Greedy approach is taken to implement the


taken to implement the algorithm. algorithm.

Bellman Ford's Algorithm have more Dijkstra's Algorithm have less overheads than
overheads than Dijkstra's Algorithm. Bellman Ford's Algorithm.

Bellman Ford's Algorithm have less Dijkstra's Algorithm have more scalability
scalability than Dijkstra's Algorithm. than Bellman Ford's Algorithm. .
7. ICMP (Internet Control Message Protocol)
Used for error reporting and diagnostics (ping, traceroute)​
Examples: Destination Unreachable, Time Exceeded

Internet Control Message Protocol (ICMP) is a network layer protocol widely used by
network devices such as routers, gateways and hosts to send error messages and
operational information. Since the Internet Protocol (IP) itself does not have an inbuilt
error-reporting or correction mechanism, ICMP is a supporting protocol within the IP suite
that helps in reporting errors and sending diagnostic messages. It is primarily used for:

●​ Error reporting: When data packets cannot reach their destination due to issues
such as unreachable hosts, timeouts or fragmentation errors.

●​ Operational queries: For example, echo requests and replies used in tools like ping.

Uses of ICMP

Error Reporting

●​ If a message cannot be delivered, ICMP informs the source about the failure.

●​ Example: If a packet is too large and cannot be forwarded, the receiver drops the
packet and sends an ICMP error message to the sender.

Network Diagnostics

●​ Traceroute: Used to determine the path packets take across routers to reach the
destination.

●​ Ping: Sends echo-request and echo-reply messages to measure round-trip time and
test connectivity.

How ICMP Works

●​ ICMP is connectionless (unlike TCP) and does not require a handshake.

●​ Messages are encapsulated within IP datagrams, consisting of an IP header followed


by an ICMP header and payload.

●​ Devices send ICMP packets when encountering errors such as unreachable hosts,
expired time-to-live (TTL) or routing issues.

●​ ICMP Packet Format

●​ ICMP header comes after IPv4 and IPv6 packet header. In the ICMP packet format,
the first 32 bits of the packet contain three fields:
●​
ICMPv4 Packet Format

●​ Type (8-bit): The initial 8-bit of the packet is for message type, it provides a brief
description of the message so that receiving network would know what kind of
message it is receiving and how to respond to it. Some common message types are
as follows:

●​ Type 0 - Echo reply​


Type 3 - Destination unreachable​
Type 5 - Redirect Message​
Type 8 - Echo Request​
Type 11 - Time Exceeded​
Type 12 - Parameter problem

●​ Code (8-bit): Code is the next 8 bits of the ICMP packet format, this field carries
some additional information about the error message and type.

●​ Checksum (16-bit): Last 16 bits are for the checksum field in the ICMP packet
header. The checksum is used to check the number of bits of the complete message
and enable the ICMP tool to ensure that complete data is delivered.

●​ The next 32 bits of the ICMP Header are Extended Header which has the work of
pointing out the problem in IP Message. Byte locations are identified by the pointer
which causes the problem message and receiving device looks here for pointing to
the problem.

●​ The last part of the ICMP packet is Data or Payload of variable length. The bytes
included in IPv4 are 576 bytes and in IPv6, 1280 bytes.

●​
8. ARP (Address Resolution Protocol)
Maps IP address to MAC address within a LAN

How Address Resolution Protocol (ARP) Works?

When computer programs send or get messages, they usually use something called an IP
address, which is like a virtual address. But underneath, the real talk happens using another
type of address called a MAC address, which is like a device's actual home address.

So, our goal is to find out the MAC address of where we want to talk to. That's where ARP
comes in handy. It helps by turning the IP address into the physical MAC address, so we can
chat with other devices on the network

Most computer programs/applications use logical addresses (IP Addresses) to send/receive


messages. However, the actual communication happens over the Physical Address (MAC
Address) from layer 2 of the OSI model. So our mission is to get the destination MAC
Address which helps communicate with other devices. This is where ARP comes into the
picture; its functionality is to translate IP addresses into physical addresses.

ARP

What is Address Resolution Protocol (ARP)?

The acronym ARP stands for Address Resolution Protocol which is one of the most
important protocols of the Data link layer in the OSI model. It is responsible to find the
hardware address of a host from a known IP address. There are three basic ARP terms.

Note: ARP finds the hardware address, also known as the Media Access Control (MAC)
address, of a host from its known IP address.
Address Resolution Protocol

ARP is essential in mapping IP addresses to MAC addresses, making it a vital networking


concept. If you're studying for GATE or seeking to deepen your understanding of network
protocols like ARP, the GATE CS Self-Paced Course is designed to cover these concepts
thoroughly with both theory and practical examples.

Important Terms Associated with ARP

●​ Reverse ARP

●​ Proxy ARP

●​ Inverse ARP

Reverse ARP

Reverse Address Resolution Protocol is a protocol that is used in local area networks (LAN)
by client machines for requesting IP Address (IPv4) from Router's ARP Table. Whenever a
new machine comes, which requires an IP Address for its use. In that case, the machine
sends a RARP broadcast packet containing MAC Address in the sender and receiver
hardware field.

Proxy ARP

Proxy Address Resolution Protocol work to enable devices that are separated into network
segments connected through the router in the same IP to resolve IP Address to MAC
Address. Proxy ARP is enabled so that the 'proxy router' resides with its MAC address in a
local network as it is the desired router to which broadcast is addressed. In case, when the
sender receives the MAC Address of the Proxy Router, it is going to send the datagram to
Proxy Router, which will be sent to the destination device.

Inverse ARP
Inverse Address Resolution Protocol uses MAC Address to find the IP Address, it can be
simply illustrated as Inverse ARP is just the inverse of ARP. In ATM (Asynchronous Transfer
Mode) Networks, Inverse ARP is used by default. Inverse ARP helps in finding Layer-3
Addresses from Layer-2 Addresses.

How ARP Works?

Imagine a device that wants to communicate with others over the internet. What does ARP
do? It broadcast a packet to all the devices of the source network. The devices of the
network peel the header of the data link layer from the Protocol Data Unit (PDU) called
frame and transfer the packet to the network layer (layer 3 of OSI) where the network ID of
the packet is validated with the destination IP's network ID of the packet and if it's equal
then it responds to the source with the MAC address of the destination, else the packet
reaches the gateway of the network and broadcasts packet to the devices it is connected
with and validates their network ID. The above process continues till the second last
network device in the path reaches the destination where it gets validated and ARP, in turn,
responds with the destination MAC address.

ARP
1.​ ARP Cache: After resolving the MAC address, the ARP sends it to the source where it
is stored in a table for future reference. The subsequent communications can use the
MAC address from the table.

2.​ ARP Cache Timeout: It indicates the time for which the MAC address in the ARP
cache can reside.

3.​ ARP request: This is nothing but broadcasting a packet over the network to validate
whether we came across the destination MAC address or not.​

●​ The physical address of the sender.

●​ The IP address of the sender.

●​ The physical address of the receiver is FF:FF:FF:FF:FF: FF or 1’s.

●​ The IP address of the receiver.

4.​ ARP response/reply: It is the MAC address response that the source receives from
the destination which aids in further communication of the data.

●​ CASE-1:

o​ The sender wants to send a packet to another host on the same network.

o​ Use ARP to find another host’s physical address.

●​ CASE-2:

o​ The sender is a host and wants to send a packet to another host on another
network.

o​ The sender looks at its routing table.

o​ Find the IP address of the next hop (router) for this destination.

o​ Find the IP address of the next hop (router) for this destination.

●​ CASE-3:

o​ The sender is a router and received a datagram.

o​ The router checks its routing table.

o​ Calculate the IP of the next router.

o​ Use ARP to find the next router’s physical address.

●​ CASE-4:
o​ The sender is a router that has received a datagram destined for a host in the
same network.

o​ Use ARP to find this host’s physical address.

9. DHCP (Dynamic Host Configuration Protocol)


Assigns IP, subnet mask, gateway, DNS automatically​
Uses UDP ports 67 (server) and 68 (client)

Dynamic Host Configuration Protocol (DHCP)

Dynamic Host Configuration Protocol (DHCP) is a network protocol used to automate the
process of assigning IP addresses and other network configuration parameters to devices
such as computers, smartphones and printers. Instead of manually configuring each device,
DHCP enables devices to join a network and automatically receive:

●​ IP Address

●​ Subnet Mask

●​ Default Gateway

●​ DNS Server addresses

●​ Other TCP/IP configuration options

Note: This automation simplifies network administration, reduces errors and allows devices to
connect seamlessly.

Components of DHCP

●​ DHCP Server: Stores IP addresses and configuration details. Allocates addresses


dynamically to clients.

●​ DHCP Relay: Acts as a bridge between clients and servers when they are not on the
same subnet.

●​ DHCP Client: A device (PC, phone, printer, etc.) that requests and receives network
configuration from the DHCP server.

●​ IP Address Pool: A predefined range of IP addresses that the DHCP server can lease
to devices.
Components of DHCP

●​ Subnets: Logical partitions of an IP network to organize and manage IP allocation.

●​ Lease: The time period for which an IP address is assigned to a client. After expiry,
the client must renew or request a new lease.

●​ DNS Servers: DHCP can provide DNS server information to clients for resolving
domain names.

●​ Default Gateway: The gateway router information is provided to clients so they can
communicate outside their subnet.

●​ Options: Additional parameters like subnet mask, domain name and time servers.

DHCP Advanced Features

●​ Renewal: Clients can renew their lease before it expires to keep the same IP.

●​ Failover: Two DHCP servers can be configured for redundancy to prevent service
disruption.

●​ Dynamic Updates: DHCP can update DNS records with client IPs automatically.

●​ Audit Logging: Maintains logs of assigned leases for monitoring and


troubleshooting.

DHCP Packet Format

●​ Hardware Length (8 bits): Length of MAC address (e.g., 6 for Ethernet).

●​ Hop Count (8 bits): Maximum number of hops the packet can travel.
●​ Transaction ID (32 bits): Set by client, used to match requests and replies.

●​ Number of Seconds (16 bits): Time elapsed since the client started booting.

●​ Flags (16 bits): Leftmost bit indicates broadcast reply requirement.

●​ Client IP Address (4 bytes): Filled if the client already has an IP, else 0.

DHCP Packet Format

●​ Your IP Address (4 bytes): Client IP assigned by the server.

●​ Server IP Address (4 bytes): IP address of the responding DHCP server.

●​ Gateway IP Address (4 bytes): Router IP address (if applicable).

●​ Client Hardware Address: The device’s MAC address.

●​ Server Name (64 bytes): Optional server hostname.

●​ Boot Filename (128 bytes): Pathname of boot file (for diskless clients).

●​ Options (variable): Vendor-specific or additional configuration.


10. Datagram vs Virtual Circuit Switching
Datagram: Connectionless, each packet routed independently (e.g., IP)​
Virtual Circuit: Connection-oriented, path established first (e.g., ATM)

Difference between Datagram Switching and Virtual Circuit Switching

Datagram Switching Virtual Circuit Switching

Virtual circuits are connection-oriented, which


It is connection less service. There is
means that there is a reservation of resources
no need for reservation of resources
like buffers, bandwidth, etc. for the time
as there is no dedicated path for a
during which the new setup VC is going to be
connection session.
used by a data transfer session.

All packets are free to use any


The first sent packet reserves resources at
available path. As a result,
each server along the path. Subsequent
intermediate routers calculate routes
packets will follow the same path as the first
on the go due to dynamically changing
sent packet for the connection time.
routing tables on routers.

Data packets reach the destination in


random order, which means they need Packets reach in order to the destination as
not reach in the order in which they data follows the same path.
were sent out.

Every packet is free to choose any


All the packets follow the same path and hence
path, and hence all the packets must
a global header is required only for the first
be associated with a header
packet of connection and other packets will
containing information about the
not require it.
source and the upper layer data.

Datagram networks are not as reliable


Virtual Circuits are highly reliable.
as Virtual Circuits.

Efficiency high, delay more Efficiency low and delay less


Datagram Switching Virtual Circuit Switching

But it is always easy and cost-efficient


to implement datagram networks as Implementation of virtual circuits is costly as
there is no need of reserving each time a new connection has to be set up
resources and making a dedicated with reservation of resources and extra
path each time an application has to information handling at routers.
communicate.

A virtual circuit network uses a fixed path for a


A Datagram based network is a true
particular session, after which it breaks the
packet switched network. There is no
connection and another path has to be set up
fixed path for transmitting data.
for the next session.

Used in X.25, ATM(Asynchronous Transfer


Widely used in Internet
Mode)

11. NAT (Network Address Translation)


Translates private IPs to public IPs​
Used to conserve IPv4 addresses​
Types: Static, Dynamic, PAT (Port Address Translation)

Network Address Translation (NAT)

Network Address Translation (NAT) is a networking technique that allows multiple devices
within a private network to access external networks (like the Internet) using a single public
IP address. By translating private IP addresses into public IP addresses and vice versa, NAT
conserves the limited pool of IPv4 addresses and adds a layer of security by masking
internal addresses from the outside world.
Network Address Translation

Note: IPv4 provides only 2³² (about 4.3 billion) addresses, which is insufficient considering the
massive number of devices connected to the Internet. NAT prevents IP exhaustion by enabling
thousands of private devices to share a limited number of public IP addresses.

Working of NAT

When a device within a private network wants to communicate with the Internet, the
request first goes to the NAT - enabled router. The router replaces the private IP address
with its public IP address and assigns a unique port number. This mapping is recorded in the
NAT table.

Working of NAT

Note: When the response arrives from the external server, NAT uses the stored entry to identify
the correct internal device. It then replaces the public IP and port with the original private IP
and forwards the packet back to the device.

This mechanism ensures:


●​ Multiple devices can share a single public IP.

●​ Internal addresses remain hidden from external networks.

●​ Port numbers help differentiate traffic from different devices.

Examples of NAT Usage

●​ Connecting Private Networks to the Internet: A NAT - enabled router translates


all private IPs to a single public IP, allowing internal devices to access the Internet
securely.

●​ Linking Multiple Office Locations: Organizations use NAT to translate IPs between
branches, enabling communication across locations while maintaining private IP
schemes internally.

12. Fragmentation and Reassembly


Occurs when packet > MTU​
Fragmentation: Done at sender/router​
Reassembly: Done at destination

Fragmentation in Network Layer

In computer networks, data is sent in small units called packets or datagrams. Sometimes,
these datagrams are too large to pass through a network with a smaller size limit. To handle
this, the datagram is broken into smaller parts is called fragmentation.

●​ IPv4 datagram size can be up to 65,535 bytes.

●​ Networks have a Maximum Transmission Unit (MTU) limit.

●​ Fragmentation splits large datagrams into smaller fragments.

●​ Each fragment has its own header.

●​ Fragmentation can occur at the source or routers.

●​ Reassembly happens only at the destination.

Need for Fragmentation

When a large datagram is created by the source computer, it may need to travel through
multiple networks to reach the destination. Each of these networks might support different
maximum packet sizes. This leads to the need for fragmentation.

Note: Although sending large datagrams is better for efficiency (because headers are not
repeated), it’s not always possible due to the reasons below:
Reasons for Fragmentation

●​ Different Network Limits: Each network has its own MTU. If a datagram is larger, it
must be split.

●​ Unknown Path MTU: Source doesn’t always know the smallest MTU along the
route.

●​ Error Handling: Smaller fragments reduce retransmission if a part is lost or


corrupted.

●​ Protocol & Hardware Limits: Some devices and protocols limit maximum packet
size.

●​ Transmission Efficiency: Large packets take longer in the network, delaying others

Header Format

Fields Related to Fragmentation

The fields that are related to fragmentation and reassembly of an IPv4 datagram are:

Identification

●​ This is a 16-bit field in the IPv4 header.

●​ It gives a unique number to each datagram sent from the source.

●​ The combination of the Identification field and source IP address helps to identify
each datagram uniquely.

●​ When a datagram is sent, the system copies a counter value into this field and then
increases the counter by 1 for the next datagram.
●​ If the datagram is broken into fragments, all fragments will have the same
Identification number.

●​ At the destination, this number helps to match and reassemble the fragments into
the original datagram.

Flags

●​ The Flags field in the IPv4 header is 3 bits long.

●​ The first bit is reserved and not used.

●​ The second bit is the Do Not Fragment (DF) bit. If set to 1, the datagram must not
be fragmented; if it cannot be sent due to size, it is discarded and an ICMP error
message is sent. If set to 0, fragmentation is allowed.

●​ The third bit is the More Fragments (MF) bit. If set to 1, more fragments are
coming. If set to 0, this is the last fragment or the datagram was not fragmented.

Fragment Offset

●​ This is a 13-bit field.

●​ It shows the position of the fragment in the original datagram.

●​ It tells the destination where to place this fragment when reassembling the full
datagram.

●​ The offset is measured in units of 8 bytes.

Example: Let’s say a large datagram has 4000 bytes of data. These bytes are numbered from
0 to 3999. Now, suppose this datagram is too large for the network and needs to be broken
into 3 fragments.

Here’s how the fragmentation will happen:

First Fragment

●​ Carries bytes: 0 to 1399

●​ Fragment Offset: 0/8 = 0

●​ Explanation: This fragment starts at the beginning of the data. So its offset is 0.

Second Fragment

●​ Carries bytes: 1400 to 2799

●​ Fragment Offset: 1400/8 = 175


●​ Explanation: This fragment starts from byte 1400. Dividing by 8 gives offset 175.

Third Fragment

●​ Carries bytes: 2800 to 3999

●​ Fragment Offset: 2800/8 = 350

●​ Explanation: This is the last part, starting from byte 2800. Offset becomes 350.

Fragmentation Example

Fragmentation of Datagram

When data travels through a network, it is placed into a unit called a datagram. Every
network, whether a Local Area Network (LAN) or a Wide Area Network (WAN), has a limit
on the maximum size of data it can handle at a time. This limit is known as the Maximum
Transmission Unit (MTU).

Fragmentation Process:

●​ Only the data part of the datagram is split into fragments.

●​ The header of the original datagram is copied into each fragment to allow
reassembly.

●​ Fragmentation can occur at the source computer or any router along the path.

At Each Router:
●​ The router removes the frame to access the datagram (decapsulation).

●​ It checks the MTU of the next network; if the datagram is too large, it fragments it.

●​ The datagram or fragments are encapsulated into a new frame suitable for the next
network.

Why Fragmentation May Happen Multiple Times:

●​ The source may not know the exact path or MTU of every network along the route.

●​ Routes can change in a connectionless network like the Internet.

●​ Routers may fragment the datagram again if it encounters a network with a smaller
MTU.

Reassembly of Fragments

It takes place only at the destination and not at routers since packets take an independent
path(datagram packet switching), so all may not meet at a router and hence a need of
fragmentation may arise again. The fragments may arrive out of order also.

Reassembly of Fragments

Algorithm:

1.​ Destination should identify that datagram is fragmented from MF, Fragment offset
field.

2.​ Destination should identify all fragments belonging to same datagram from
Identification field.

3.​ Identify the 1st fragment(offset = 0).


4.​ Identify subsequent fragments using header length, fragment offset.

5.​ Repeat until MF = 0.

Efficiency:

Efficiency (e) = useful/total = (Data without header)/(Data with header) ​


Throughput = e * B { where B is bottleneck bandwidth }

Example: An IP router with a Maximum Transmission Unit (MTU) of 200 bytes has received
an IP packet of size 520 bytes with an IP header of length 20 bytes. The values of the
relevant fields in the IP header. ​

Explanation: Since MTU is 200 bytes and 20 bytes is header size so, the maximum length of
data = 180 bytes but it can't be represented in fragment offset since it is not divisible by 8 so,
the maximum length of data feasible = 176 bytes.

●​ Number of fragments = (520/200) = 3.

●​ Header length = 5 (since scaling factor is 4 therefore, 20/4 = 5)

●​ Efficiency, e = (Data without header)/(Data with header) = 500/560 = 89.2 % ​

Reassembly of Fragments

Problems Caused by IP Fragmentation

●​ Extra Load on Routers: Routers must handle multiple fragments, slowing network
performance.

●​ Inefficient Transmission: Losing a fragment means resending the whole packet,


wasting bandwidth.
●​ Out-of-Order Arrival: Fragments may arrive in the wrong order, needing extra
processing to reorder.

●​ Routing & Firewall Issues: Only the first fragment has full header info, which can
cause routing/firewall problems.

●​ NAT Problems: Missing info in fragments can break IP address translation.

Difference Between IPv4 and IPv6

The below table shows the difference between the IPV4 and IPV6 addressing:

Feature IPv4 IPv6

Address Length 32-bit address 128-bit address

Decimal format (e.g., Hexadecimal format (e.g.,


Address Format [Link]) 2001:0db8::1)

Manual and DHCP Auto-configuration and


Configuration configuration renumbering supported

Connection End-to-end integrity is


End-to-end integrity is achievable
Integrity unachievable

No built-in security; external IPSec is built-in for encryption and


Security tools like IPSec needed authentication

Performed by sender and


Performed only by the sender
Fragmentation routers
Feature IPv4 IPv6

Flow Uses Flow Label field in header for


Not available
Identification packet flow identification

Checksum Field Present Not present

Transmission Uses multicast and anycast; no


Supports broadcast
Scheme broadcast

Header Size Variable: 20–60 bytes Fixed: 40 bytes

Not all IPv6 addresses can be


Can be converted to IPv6
Conversion converted to IPv4

Field Structure 4 fields separated by dots (.) 8 fields separated by colons (:)

Has address classes (A, B, C, D,


No concept of address classes
Address Classes E)

You might also like