IPv4 - Internet Protocol version 4

What is IPv4?

IPv4 stands for Internet Protocol version 4. It is the fourth version of the Internet Protocol and the most widely used protocol for identifying devices on a network using a 32-bit address. Each device on a network is assigned a unique IPv4 address to enable communication.

Why is IPv4 useful?

  • Identifying devices on a network

  • Routing data between devices across networks

  • Enabling internet communication

How it works?

  • Device gets an IP address – Either manually or via DHCP.

  • Data is sent with IP headers – Each packet includes source and destination IPv4 addresses.

  • Routers forward packets – Based on the destination IP, routers direct the packet toward its target.

  • Target device receives data – The device with the matching IP address processes the packet.

Where is IPv4 used?

  • Home networks – Routers assign IPv4 addresses to phones, laptops, TVs, etc.

  • Enterprise networks – Servers, workstations, and printers use IPv4 for communication.

  • Internet – Every website, server, and online service uses IPv4 (or IPv6) to identify and communicate with devices.

Which OSI Layer does IPv4 operate at?

  • IPv4 operates at the Network Layer (Layer 3) of the OSI model.

  • It handles logical addressing and routing between different networks.

  • It is responsible for packet forwarding, including routing through intermediate routers.

Is IPv4 windows specific?

  • No.

  • IPv4 is a universal Internet Protocol standard used across all major operating systems, including Windows, Linux, macOS, and others.

Is IPv4 linux specific?

  • No.

  • IPv4 is not specific to Linux; it is a fundamental protocol used globally on all platforms.

Which Transport Protocol is used by IPv4?

  • IPv4 itself is a Network Layer protocol (Layer 3).

  • It supports transport protocols like TCP, UDP, and ICMP over it, but IPv4 is not built on top of transport protocols.

Which Port is used by IPv4?

  • IPv4 does not use ports directly.

  • Ports are used by Transport Layer protocols (like TCP and UDP) which run over IPv4.

Is IPv4 using Client server model?

  • No.

  • IPv4 is a network layer protocol for addressing and routing; it does not implement a client-server model.

What is the address range of IPv4?

  • IPv4 addresses are 32 bits long, represented as four decimal numbers (octets) separated by periods.

  • The address range is from 0.0.0.0 to 255.255.255.255.

  • This gives a total of approximately 4.3 billion unique addresses.

What is an IPv4 subnet mask?

  • A subnet mask is used to divide an IPv4 network into smaller subnetworks.

  • It determines which portion of an IP address refers to the network and which part refers to the host.

What is the purpose of IPv4 CIDR notation?

  • Classless Inter-Domain Routing (CIDR) is used to allocate IP addresses more efficiently.

  • CIDR notation uses a slash (/) followed by a number to represent the number of bits used for the network portion of the address (e.g., 192.168.1.0/24).

What is the difference between public and private IPv4 addresses?

  • Public IP addresses are globally routable and can be used over the internet.

  • Private IP addresses are used within private networks and are not routable over the internet.

  • Private IP ranges include: - 10.0.0.0 to 10.255.255.255 - 172.16.0.0 to 172.31.255.255 - 192.168.0.0 to 192.168.255.255

What is an IPv4 gateway?

  • A gateway is a device that routes traffic between different networks.

  • In home and small office networks, the gateway is often the router that connects to the internet.

What is NAT (Network Address Translation)?

  • NAT allows multiple devices on a local network to share a single public IP address.

  • It translates private IP addresses to public ones when packets are sent out to the internet.

How to find public IP address on any machine?

  • Web Services: Visit websites like [whatismyipaddress.com](https://www.whatismyipaddress.com) or [ipinfo.io](https://ipinfo.io).

  • Command Line: - Linux/Mac: curl ifconfig.me or curl ipinfo.io/ip - Windows: nslookup myip.opendns.com resolver1.opendns.com

  • Router/Gateway Interface: Log into your router’s admin page (typically 192.168.1.1) and check the WAN/Internet section.

What is an IPv4 broadcast address?

  • The broadcast address is used to send data to all devices in a network.

  • In IPv4, the broadcast address for a subnet is determined by setting all the host bits to 1.

What is the ARP protocol in IPv4?

  • The Address Resolution Protocol (ARP) maps an IP address to a MAC address.

  • ARP is used by IPv4 devices to identify the hardware address of other devices on the same network.

What is an IPv4 routing table?

  • A routing table is used by routers to determine where to send packets based on the destination IP address. Use ip route on ubuntu to see routing table.

  • It contains entries for networks and associated next-hop addresses.

What is the role of DNS in IPv4?

  • The Domain Name System (DNS) translates human-readable domain names (like example.com) into IP addresses.

  • DNS ensures that users can access websites by using easy-to-remember names instead of IP addresses.

What is the difference between IPv4 and IPv6?

  • IPv4 uses a 32-bit address space, while IPv6 uses a 128-bit address space, allowing for a much larger number of unique addresses.

  • IPv6 also includes improvements in security, routing efficiency, and mobility.

What is the role of DHCP in IPv4?

  • The Dynamic Host Configuration Protocol (DHCP) assigns dynamic IP addresses to devices on a network.

  • DHCP helps reduce the need for manual configuration of IP addresses.

What is an IPv4 address conflict?

  • An address conflict occurs when two devices on the same network are assigned the same IP address.

  • This can cause network communication issues and prevent devices from accessing the network.

What is IPv4 packet structure?

  • IPv4 packets consist of a header and data. The header contains information such as the source and destination IP addresses, time-to-live (TTL), and protocol type.

  • The packet is used to encapsulate data for transmission across the network.

What is the Time-to-Live (TTL) field in IPv4?

  • The TTL field indicates the maximum number of hops a packet can make before being discarded.

  • It is used to prevent packets from circulating endlessly in case of routing loops.

What is IPv4 fragmentation?

  • Fragmentation allows large packets to be broken into smaller pieces to fit the MTU (Maximum Transmission Unit) of the network.

  • Each fragment is transmitted separately and reassembled at the destination.

What is the role of ICMP in IPv4?

  • The Internet Control Message Protocol (ICMP) is used for network diagnostics (e.g., ping) and error reporting.

  • It allows devices to report issues with packet delivery and network reachability.

What is IPv4 anycast?

  • Anycast is a communication method where a packet is delivered to the nearest device (or the device with the smallest number of hops) that shares the same IP address.

  • It is commonly used for load balancing and redundancy in network services.

  • In this section, you are going to learn

  • Terminology

  • Version Info

Version & RFC Details

IPv4 Version

RFC Version

Year

Core Idea / Contribution

IPv4

RFC 760

1980

First formal specification of IPv4; defined datagram format and addressing.

RFC 791

1981

Replaces RFC 760; defines the modern IPv4 protocol including header structure, addressing, fragmentation.

RFC 792

1981

Defines ICMP for error and control messaging.

RFC 919

1984

Defines broadcasting methods in IP networks.

RFC 922

1984

Defines broadcasting methods in IP networks.

RFC 950

1985

Introduces subnetting for efficient IP address allocation.

RFC 1122

1989

Host requirements for Internet protocols including IPv4.

RFC 1812

1995

Router requirements for IPv4.

RFC 1918

1996

Defines private IP address ranges.

RFC 2131

1997

Defines DHCP for dynamic IP address assignment.

RFC 3021

2000

Allows /31 subnets for point-to-point links.

RFC 4632

2006

Classless Inter-Domain Routing (CIDR) notation and address allocation.

Basic IPv4 Protocol Implementation

verify that two laptops with manually assigned IPv4 addresses can communicate using the ICMP protocol, and to observe the correct packet flow.

Test Setup

  • Laptop 1

    • Assign the IPv4 address 192.168.1.10 to the enp0s8 interface.

    test:~$ sudo ip addr add 192.168.1.10/24 dev enp0s8
    test:~$ sudo ip link set enp0s8 up
    
  • Laptop 2

    • Assign the static IPv4 address 192.168.1.100/24 to the network interface enp0s8.

    test:~$ sudo ip addr add 192.168.1.100/24 dev enp0s8
    test:~$ sudo ip link set enp0s8 up
    

Procedure

  • Step-1 : Test Connectivity

    • From Laptop 2, initiate a network ping to Laptop 1’s IP address (192.168.1.10).

    test:~$ ping 192.168.1.10
    PING 192.168.1.10 (192.168.1.10) 56(84) bytes of data.
    64 bytes from 192.168.1.10: icmp_seq=1 ttl=64 time=2.67 ms
    64 bytes from 192.168.1.10: icmp_seq=2 ttl=64 time=0.568 ms
    64 bytes from 192.168.1.10: icmp_seq=3 ttl=64 time=0.881 ms
    64 bytes from 192.168.1.10: icmp_seq=4 ttl=64 time=0.839 ms
    64 bytes from 192.168.1.10: icmp_seq=5 ttl=64 time=1.03 ms
    64 bytes from 192.168.1.10: icmp_seq=6 ttl=64 time=1.21 ms
    64 bytes from 192.168.1.10: icmp_seq=7 ttl=64 time=1.12 ms
    64 bytes from 192.168.1.10: icmp_seq=8 ttl=64 time=8.48 ms
    64 bytes from 192.168.1.10: icmp_seq=9 ttl=64 time=0.886 ms
    64 bytes from 192.168.1.10: icmp_seq=10 ttl=64 time=1.05 ms
    ^C
    --- 192.168.1.10 ping statistics ---
    10 packets transmitted, 10 received, 0% packet loss, time 9101ms
    rtt min/avg/max/mdev = 0.568/1.873/8.483/2.268 ms
    
  • Step-2 : Observe Packets with Wireshark

    • Simultaneously, use Wireshark to capture network traffic on either laptop

    • Apply a filter for ICMP packets to focus on the ping traffic.

Note

  • ICMP is the Internet Control Message Protocol, which is used by ping to send echo requests and receive replies.

Analysis of Packets

  • Request and Reply * The first packet will be an Echo (ping) request originating from 192.168.1.100 and destined for 192.168.1.10. * The second packet will be an Echo (ping) reply, originating from 192.168.1.10 and destined for 192.168.1.100. This pattern confirms successful two-way communication.

  • Packet Details * Frame : Shows information about the physical layer. * Ethernet : Displays the Source MAC Address (Laptop 2) and Destination MAC Address (Laptop 1). * Internet Protocol Version 4 (IPv4) : Shows the Source IP (192.168.1.100) and Destination IP (192.168.1.10). * ICMP : Contains the specific type and code that identify the packet as an Echo request or reply.

Note

  • The Time to Live (TTL) in the IPv4 header is a value that indicates the maximum number of hops a packet can take before it is discarded.

Wireshark Capture

IPv4 Packet

S.No

Protocol Packets

Description

Size(bytes)

1

IPv4

42

Header

Version

IP version (4 for IPv4)

1

Header Length (IHL)

length of the IP header in 32-bit words.

1

Type of Service (ToS)

specifying the priority of the packet.

1

Total Length

total length of the IP packet (header + data).

2

Identification

uniquely identifying the packet fragments.

2

Flags

controlling or identifying fragments.

1

Fragment Offset

offset of a fragment

2

Time to Live (TTL)

maximum time the packet is allowed to remain

1

in the network.

Protocol

specifying the next level protocol (e.g., 6=TCP,17= UDP).

1

Header Checksum

error-checking the header.

2

Source IP Address

IP address of the sender.

4

Destination IP Address

IP address of the receiver.

4

Options

variable-length field for optional settings.

variable

Data(Payload)

actual payload carried by the IP packet.

variable(20)

IPv4 - Use Cases

S.no

Use Case

Description

1

Internet Communication

IPv4 is the foundational protocol for routing data across the internet using unique 32-bit addresses.

2

Enterprise Networking

Used in LANs and WANs for assigning IP addresses to devices like computers, printers, and servers.

3

Web Hosting & DNS

Websites are hosted on servers with IPv4 addresses; DNS maps domain names to these addresses.

4

Network Address Translation (NAT)

Enables multiple devices on a private network to share a single public IPv4 address.

5

VPN and Remote Access

IPv4 is used in tunneling protocols to securely connect remote users to private networks.

6

IoT Device Connectivity

Many IoT devices still rely on IPv4 for communication due to its widespread support.

7

DHCP Address Assignment

IPv4 works with DHCP to dynamically assign IP addresses to devices on a network.

8

VoIP and Streaming Services

IPv4 supports real-time data transmission for voice and video over IP networks.

IPv4 - Basic Features

S.no

Features

Description

1

Addressing

IPv4 uses 32-bit addresses, allowing for unique identification of devices on a network.

2

Header Structure

IPv4 packets have a structured header with fields like source/destination IP, TTL, protocol, etc.

3

Packet Routing

Routers use IPv4 addresses to forward packets across networks toward their destination.

4

Fragmentation

IPv4 supports fragmentation when packets exceed the MTU of a network segment.

5

Connectionless Protocol

IPv4 does not establish a connection before sending data; each packet is independent.

6

Subnetting

Allows division of IP networks into smaller subnetworks for efficient IP management.

7

NAT Compatibility

IPv4 works with Network Address Translation to conserve public IP addresses.

8

Broadcast Support

IPv4 supports broadcasting to all devices in a subnet.

9

Protocol Identification

The header includes a field to identify the encapsulated protocol.

10

TTL (Time to Live)

Limits the lifespan of a packet to prevent infinite looping in the network.

11

Classful Addressing (Legacy)

Originally, IPv4 used fixed address classes (A, B, C, D, E), though now replaced by CIDR.

  • Reference links