Understanding IPv4 Network Codes
Understanding IPv4 Network Codes
IP stands for Internet Protocol version v4 stands for Version Four (IPv4), is
the most widely used system for identifying devices on a network. It uses a set
of four numbers, separated by periods (like [Link]), to give each device
a unique address. This address helps data find its way from one device to
another over the internet.
IPv4 was the primary version brought into action for production within the
ARPANET in 1983. IP version four addresses are 32-bit integers which will be
expressed in decimal notation. Example- [Link] could be an IPv4
address.
What is an IP Address?
An IP address (Internet Protocol address) is a unique identifier assigned to
each device connected to a network that uses the Internet Protocol for
communication. It serves two main purposes:
Identification: It uniquely identifies a device on a network.
Location Addressing: It indicates where a device is located within a
network, making data routing possible.
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:
Address Space
IPv4 has a certain address space. An address space is the total number of
addresses used by the protocol. If a protocol uses N bits to define an address, the
address space is 2N
IPv4 uses 32-bit address format, which means that the address space is 2 32 or
4,294,967,296
Notations
There are two notations to show an IPv4 address:
1. Binary notation
2. Dotted decimal notation
1. Binary Notation
In binary notation, the IPv4 address is displayed as 32 bits. Each octet is often
referred to as a byte. So it is common to hear an IPv4 address referred to a 4-
byte address. The following is an example of an IPv4 address in binary
notation: 01110111 10010101 00000001 00000011
2. Dotted-Decimal Notation
IPV4 addresses are usually written in decimal form with a decimal point (dot)
separating the bytes since it’s more compatible. The following is an
example: [Link] (above one and this one is same just different notation)
To resolve problems like the one mentioned above CIDR was introduced.
Classless Addressing
Classless Addressing or Classless Inter-Domain Routing was introduced
in 1993 to replace classful addressing. Classless Inter-Domain Routing (CIDR)
is a method for efficiently allocating IP addresses and routing Internet Protocol
(IP) packets. Unlike classful addressing, which divides IP addresses into fixed
classes (A, B, C, etc.), CIDR allows for variable-length subnet masks (VLSM).
This means that networks can be divided into smaller, more flexible subnets
according to their specific needs, rather than being constrained by predefined
class boundaries.
CIDR Notation
In CIDR subnet masks are denoted by /X. For example a subnet of
[Link] would be denoted by /24. To work a subnet mask in CIDR, we
have to first convert each octet into its respective binary value. For example,
if the subnet is of [Link]. then :
First Octet
255 has 8 binary 1's when converted to binary
Second Octet
255 has 8 binary 1's when converted to binary
Third Octet
255 has 8 binary 1's when converted to binary
Fourth Octet
0 has 0 binary 1's when converted to binary
Therefore, in total there are 24 binary 1's, so the subnet mask is /24.
While creating a network in CIDR, a person has to make sure that the masks
are contiguous, i.e. a subnet mask like 10111111.X.X.X can't exist. With CIDR,
we can create Variable Length Subnet Masks, leading to less wastage of IP
addresses. It is not necessary that the divider between the network and the
host portions is at an octet boundary. For example, in CIDR a subnet mask like
[Link] or 11111111.11100000.00000000.00000000 can exist.
Difference Between Classful Addressing and
Classless Addressing
Classless
Parameter Classful Addressing Addressing
Classless addressing
In Classful addressing IP
came to replace the
addresses are allocated
Basics classful addressing and
according to the classes- A to
to handle the issue of
E.
allocation of IP Address.
It supports Classless
It does not support Classless
CIDR Inter-Domain Routing
Inter-Domain Routing (CIDR).
(CIDR).
Division of Network
Host
Address Host
Subnet
Subnet
Network Address Translation (NAT) allows multiple devices to use the same
public IP address and access the Internet.
There can be a total of 232 (around 4.3 billion) different IPv4 addresses,
which is very few considering the number of IPv4 devices connected to the
Internet.
The idea of NAT saves from IP address exhaustion. Only one public IP
address is needed to access the Internet, while multiple private IP
addresses within a network can share that single public IP. To achieve this,
a private IP address must be translated into a public IP address.
Network Address Translation(NAT)
Network Address Translation (NAT) is a process in which one or more local
IP addresses are translated into one or more Global IP addresses and vice
versa to provide Internet access to the local hosts. It also does the translation
of port numbers, i.e., masks the port number of the host with another port
number in the packet that will be routed to the destination. It then makes the
corresponding entries of IP address and port number in the NAT table. NAT
generally operates on a router or firewall.
Working Of NAT
In this image, When PC0 sends a request to a web server, the packet reaches
the NAT-enabled router. NAT replaces PC0’s private IP with the router’s
public IP and assigns a unique public source port for tracking. This translated
packet is then sent to the web server over the internet. The NAT table stores
this mapping to ensure the reply reaches PC0 correctly.
The web server’s response arrives at the router’s public IP and assigned port.
NAT checks its translation table to identify the matching internal device,
replaces the public IP and port with PC0’s private IP and original port, and
then forwards the response to PC0.
PC0, PC1, and PC2 share the same public IP for internet access, and NAT
distinguishes their connections by assigning unique port mappings for each
device.
Types of Network Address Translation (NAT)
There are 3 ways to configure NAT:
Static NAT
In this, a single unregistered (private) IP address is mapped to a legally
registered (public) IP address, i.e., a one-to-one mapping between local and
global addresses. This is generally used for Web hosting. These are not used
in organizations as there are many devices that will need Internet access and
to provide Internet access, a public IP address is needed.
Suppose there are 3000 devices that need Internet access. The organization
would have to buy 3000 public addresses, which would be very costly.
Dynamic NAT
In this type of NAT, an unregistered IP address is translated into a registered
(Public) IP address from a pool of public IP addresses. If the IP address of the
pool is not free, then the packet will be dropped as only a fixed number of private
IP addresses can be translated to public addresses.
If there is a pool of 2 public IP addresses, then only 2 private IP addresses can
be translated at a given time. If 3rd private IP address wants to access the
Internet then the packet will be dropped therefore many private IP addresses
are mapped to a pool of public IP addresses. NAT is used when the number of
users who want to access the Internet is fixed. This is also very costly as the
organization has to buy many global IP addresses to make a pool.
Port Address Translation (PAT)
This is also known as NAT overload. In this, many local (private) IP
addresses can be translated to a single registered IP address. Port numbers
are used to distinguish the traffic i.e., which traffic belongs to which IP address.
This is the most frequently used method because it is cost-effective, allowing
thousands of users to connect to the Internet using only one real global (public)
IP address.
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.
IPV6
The wonder of IPv6 lies in its header. An IPv6 address is 4 times larger than IPv4,
but surprisingly, the header of an IPv6 address is only 2 times larger than that of
IPv4. IPv6 headers have one Fixed Header and zero or more Optional (Extension)
Headers. All the necessary information that is essential for a router is kept in the
Fixed Header. The Extension Header contains optional information that helps
routers to understand how to handle a packet/flow.
Fixed Header
[Image: IPv6
Fixed Header]
IPv6 fixed header is 40 bytes long and contains the following information.
1
Version (4-bits): It represents the version of Internet Protocol, i.e. 0110.
2
Traffic Class (8-bits): These 8 bits are divided into two parts. The most significant 6 bits are
used for Type of Service to let the Router Known what services should be provided to this
packet. The least significant 2 bits are used for Explicit Congestion Notification (ECN).
3
Flow Label (20-bits): This label is used to maintain the sequential flow of the packets
belonging to a communication. The source labels the sequence to help the router identify
that a particular packet belongs to a specific flow of information. This field helps avoid re-
ordering of data packets. It is designed for streaming/real-time media.
4
Payload Length (16-bits): This field is used to tell the routers how much information a
particular packet contains in its payload. Payload is composed of Extension Headers and
Upper Layer data. With 16 bits, up to 65535 bytes can be indicated; but if the Extension
Headers contain Hop-by-Hop Extension Header, then the payload may exceed 65535 bytes
and this field is set to 0.
5
Next Header (8-bits): This field is used to indicate either the type of Extension Header, or if
the Extension Header is not present then it indicates the Upper Layer PDU. The values for
the type of Upper Layer PDU are same as IPv4’s.
6
Hop Limit (8-bits): This field is used to stop packet to loop in the network infinitely. This is
same as TTL in IPv4. The value of Hop Limit field is decremented by 1 as it passes a link
(router/hop). When the field reaches 0 the packet is discarded.
7
Source Address (128-bits): This field indicates the address of originator of the packet.
8
Destination Address (128-bits): This field provides the address of intended recipient of the
packet.
Types of ARP
There are four types of Address Resolution Protocol, which is given
below:
o Proxy ARP
o Gratuitous ARP
o Reverse ARP (RARP)
o Inverse ARP
Proxy ARP - Proxy ARP is a method through which a Layer 3 devices
may respond to ARP requests for a target that is in a different network
from the sender. The Proxy ARP
configured router responds to the ARP and map the MAC address of the
router with the target IP
address and fool the sender that it is reached at its destination.
At the backend, the proxy router sends its packets to the appropriate
destination because the packets contain the necessary information.
There are some primary use cases of gratuitous ARP that are given
below:
o The gratuitous ARP is used to update the ARP table of other devices.
o It also checks whether the host is using the original IP address or a
duplicate one.
A special host configured inside the local area network, called as RARP-
server is responsible to reply for these kind of broadcast packets. Now the
RARP server attempt to find out the entry in IP to MAC address mapping
table. If any entry matches in table, RARP server send the response packet
to the requesting device along with IP address.
LAN technologies like Ethernet, Ethernet II, Token Ring and Fiber
Distributed Data Interface (FDDI) support the Address Resolution
Protocol.
RARP is not being used in today's networks. Because we have much
great featured protocols like BOOTP (Bootstrap Protocol) and DHCP(
Dynamic Host Configuration Protocol).
ICMP Protocol
The ICMP stands for Internet Control Message Protocol. It is a network layer protocol. It
is used for error handling in the network layer, and it is primarily used on network devices
such as routers. As different types of errors can exist in the network layer, so ICMP can be
used to report these errors and to debug those errors.
For example, some sender wants to send the message to some destination, but the router
couldn't send the message to the destination. In this case, the router sends the message
to the sender that I could not send the message to that destination.
The IP
protocol does not have any error-reporting or error-correcting mechanism, so it uses a message to
convey the information. For example, if someone sends the message to the destination, the
message is somehow stolen between the sender and the destination. If no one reports the error,
then the sender might think that the message has reached the destination. If someone in-between
reports the error, then the sender will resend the message very quickly.
o Error-reporting messages
The error-reporting message means that the router encounters a problem when it
processes an IP packet then it reports a message.
o Query messages
The query messages are those messages that help the host to get the specific information
of another host. For example, suppose there are a client and a server, and the client wants
to know whether the server is live or not, then it sends the ICMP message to the server.
o Type: It is an 8-bit field. It defines the ICMP message type. The values range from
0 to 127 are defined for ICMPv6, and the values from 128 to 255 are the
informational messages.
o Code: It is an 8-bit field that defines the subtype of the ICMP message
o Checksum: It is a 16-bit field to detect whether the error exists in the message or
not.
Note: The ICMP protocol always reports the error messages to the original source. For
example, when the sender sends the message, if any error occurs in the message then the
router reports to the sender rather than the receiver as the sender is sending the message.
o Destination unreachable
The destination unreachable error occurs when the packet does not reach the destination.
Suppose the sender sends the message, but the message does not reach the destination,
then the intermediate router reports to the sender that the destination is unreachable.
Source quench
There is no flow control or congestion control mechanism in the network layer or the IP
protocol. The sender is concerned with only sending the packets, and the sender does not
think whether the receiver is ready to receive those packets or is there any congestion
occurs in the network layer so that the sender can send a lesser number of packets, so
there is no flow control or congestion control mechanism. In this case, ICMP provides
feedback, i.e., source quench. Suppose the sender resends the packet at a higher rate, and
the router is not able to handle the high data rate. To overcome such a situation, the
router sends a source quench message to tell the sender to send the packet at a lower
rate.
Time exceeded
Sometimes the situation arises when there are many routers that exist between the sender
and the receiver. When the sender sends the packet, then it moves in a routing loop. The
time exceeded is based on the time-to-live value. When the packet traverses through the
router, then each router decreases the value of TTL by one. Whenever a router decreases
a datagram with a time-to-live value to zero, then the router discards a datagram and
sends the time exceeded message to the original source.
Parameter problems
The router and the destination host can send a parameter problem message. This
message conveys that some parameters are not properly set.
Redirection
When the packet is sent, then the routing table is gradually augmented and updated. The
tool used to achieve this is the redirection message. For example, A wants to send the
packet to B, and there are two routers exist between A and B. First, A sends the data to
the router 1. The router 1 sends the IP packet to router 2 and redirection message to A so
that A can update its routing table.
DHCP
Dynamic Host Configuration Protocol, or DHCP, is a network
management protocol that dynamically assigns IP addresses and other
network configuration settings to devices on a network.
DHCP uses a client-server model, where individual devices request for IP
address from a DHCP server when they join a network. DHCP reduces
the need for manual configurations for network admins, and DHCP
automatically manages the IP address and other network settings for a
device.
1. Discover
When a device (DHCP client) connects to a network, it broadcasts a
DHCP Discover message within the subnet to find available DHCP
servers. This message signals the client’s need for an IP address and
configuration details.
2. Offer
After receiving the discover message, DHCP servers respond with
a DHCP Offer message. This offer includes a proposed IP address from
the server's pool, along with critical parameters such as:
1. Subnet mask
2. Default gateway
3. DNS server addresses
4. Lease duration
3. Request
The client may receive multiple offers but selects one and broadcasts
a DHCP Request message back to the chosen server, confirming its
acceptance of the offered IP address and requesting the associated
configuration.
4. Acknowledgment (ACK)
The DHCP server that received the request sends a DHCP ACK
message to the client, confirming that it can use the offered IP address
and providing all necessary configuration details. The client then
configures its network interface based on this information.
Routing
Routing refers to the process of directing a data packet from one node to
another. It is an autonomous process handled by the network devices to direct
a data packet to its intended destination. Note that, the node here refers to
a network device called - 'Router'.
Routing is a crucial mechanism that transmits data from one location to another
across a network (Network type could be any like LAN, WAN, or MAN). The
process of routing involves making various routing decisions to ensure reliable
& efficient delivery of the data packet by finding the shortest path using various
routing metrics which we will be discussing in this article.
Routing of a data packet is done by analyzing the destination IP Address of the
packet. Look at the below image:
Routing of packets
The Source Node (Sender) sends the data packet on the network,
embedding the IP in the header of the data packet.
The nearest router receives the data packet, and based on some metrics,
further routes the data packet to other routers.
Step 2 occurs recursively till the data packet reaches its intended
destination.
Note: There are limits to how many hop counts a packet can do if it is
exceeded, the packet is considered to be lost.
1. Unicast Routing:
Definition:
Unicast routing is a one-to-one communication where data is
sent from one source to one specific destination.
How it works:
The router forwards packets to a single destination IP address
based on the routing table.
Example:
A user browsing a website. When you open [Link],
your computer sends a request directly to the web server’s IP
address, and the server responds only to your device.
Routing Protocols Used:
OSPF (Open Shortest Path First)
RIP (Routing Information Protocol)
BGP (Border Gateway Protocol)
2. Multicast Routing:
Definition:
Multicast routing is one-to-many communication where data is
sent from one source to multiple specific receivers who are part
of a multicast group.
How it works:
Routers forward packets only to networks where there are
members of the multicast group, reducing unnecessary traffic.
Example:
Live video streaming of a sports event to multiple subscribers.
The server sends one copy of the stream, and routers replicate it
only to those who subscribed (joined the multicast group).
Routing Protocols Used:
PIM (Protocol Independent Multicast)
DVMRP (Distance Vector Multicast Routing Protocol)
IGMP (Internet Group Management Protocol) – used by
hosts to join multicast groups