Understanding IPv4 Addressing and Structure
Understanding IPv4 Addressing and Structure
● 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
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
● 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.
These fields together ensure the proper delivery, routing, fragmentation, and
reassembly of IP packets across the network.
IPV4 Header
● Total Length: Length of header + Data (16 bits), which has a minimum
value 20 bytes and the maximum is 65,535 bytes.
Characteristics of IPv4
● 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.
● IPv4 uses the Post Address Resolution Protocol to map to the MAC
address.
Advantages of IPv4
Limitations of IPv4
● If there are multiple hosts, we need the IP addresses of the next class.
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:
Class
224-239 Reserve for multitasking
D
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
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).
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:
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.
1 2001:db8:abcd:1234::/64
● /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.
● 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
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)
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
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:
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.
IP Addressing
IPv4 addresses are divided into classes based on the length of the network and host
portions:
Classful Addressing
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
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.
● 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.
● 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).
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
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
● Traffic Prioritization: Critical subnets (e.g., Sales hosting video conferences) can
get higher priority.
Disadvantages of Subnetting
● 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
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.
● A unique Router ID
Initialization:
● Distance to itself = 0
● If new information changes the shortest path, the router updates its own table.
3. Distance calculation:
The cost of reaching a destination is calculated using the Bellman-Ford equation:
Where:
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.
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
Advantages
Disadvantages
● Slow Convergence: Takes time to adapt to changes.
● 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.
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
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
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.
● 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.
RIP OSPF
RIP utilizes less memory compared to OSPF device resource requirements are CPU
OSPF but is CPU intensive like OSPF. intensive and memory.
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.
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.
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.
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.
● 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.
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:
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.
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
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.
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 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:
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
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
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.
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.
● Devices send ICMP packets when encountering errors such as unreachable hosts,
expired time-to-live (TTL) or routing issues.
● 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:
● 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
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
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
● 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.
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.
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.
● CASE-2:
o The sender is a host and wants to send a packet to another host on another
network.
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:
● CASE-4:
o The sender is a router that has received a datagram destined for a host in the
same network.
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
Note: This automation simplifies network administration, reduces errors and allows devices to
connect seamlessly.
Components of DHCP
● 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
● 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.
● 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.
● 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.
● Client IP Address (4 bytes): Filled if the client already has an IP, else 0.
● Boot Filename (128 bytes): Pathname of boot file (for diskless clients).
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.
● Linking Multiple Office Locations: Organizations use NAT to translate IPs between
branches, enabling communication across locations while maintaining private IP
schemes internally.
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.
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.
● Protocol & Hardware Limits: Some devices and protocols limit maximum packet
size.
● Transmission Efficiency: Large packets take longer in the network, delaying others
Header Format
The fields that are related to fragmentation and reassembly of an IPv4 datagram are:
Identification
● 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 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
● It tells the destination where to place this fragment when reassembling the full
datagram.
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.
First Fragment
● Explanation: This fragment starts at the beginning of the data. So its offset is 0.
Second Fragment
Third Fragment
● 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:
● 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.
● The source may not know the exact path or MTU of every network along the route.
● 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.
Efficiency:
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.
Reassembly of Fragments
● Extra Load on Routers: Routers must handle multiple fragments, slowing network
performance.
● Routing & Firewall Issues: Only the first fragment has full header info, which can
cause routing/firewall problems.
The below table shows the difference between the IPV4 and IPV6 addressing:
Field Structure 4 fields separated by dots (.) 8 fields separated by colons (:)