ipv4 vs ipv6

In today’s technological age, we have witnessed a huge leap in the use of Internet and networked devices. Every home has a laptop, smartphone, digital watch, IoT devices, home automation components and other devices connected to the home network or the Internet. Devices communicate with each other over a variety of network protocols, of which TCP and IP are the most commonly used. Each device connected to the network must have an IP address that identifies the device on the network.

This article explains the Internet protocol and the difference between IPv6 and IPv4.

What is IP (Internet Protocol)?

As humans, we use our names to identify and communicate with each other. Similarly, in the computing world, devices use IP addresses to identify and interact with each other. The common language that all computing devices use to communicate with each other is called a protocol. Similar to human language, the protocol has a set of rules for formatting and processing data.

Internet Protocol

The Internet Protocol (IP) is a set of rules that specify the addressing and routing of data between computers. It is used primarily with network transport protocols, such as TCP and UDP.

This unique addressing model is what allows the Internet to exist today. IANA manages the range of IP addresses of networks/stations connected to the Internet. However, if we run an isolated local network infrastructure, we can assign IP addresses according to our preferences. Now, let’s dive into the essence of these two architectures and their comparative analysis.

IPv4

The first major release of the Internet Protocol (IP) was version 4 (IPv4). It uses a 32-bit network addressing architecture, which is further split into four 8-bit numbers called octets. For example, the IP address of google.com is 141.251.36.46. This format is called dotted-quad representation. These IP addresses can be configured manually or obtained automatically through a DHCP server.

To check the live status of a remote device, we can use the following ping command to perform an ICMP probe on that IP.

1
2
3
4
5
6
ping -c 1 google.com

PING google.com (142.251.36.46) 56(84) bytes of data.
64 bytes from ams17s12-in-f14.1e100.net (142.251.36.46): icmp_seq=1 ttl=116 time=247 ms

...

The IP address is divided into two parts, the network address and the host address, which are used to create subnets. The subnet number helps determine the network and host portions of the IP. In addition, the available IP space is divided into five different categories, as shown in the table below.

address class IP range subnet mask number of networks number of hosts per network
Class A 1.0.0.0 to 126.0.0.0 255.0.0.0 126 16,777,214
Level B 128.0.0.0 to 191.255.0.0 255.255.0.0 16,282 65,534
Class C 192.0.0.0 to 223.255.255.0 255.255.255.0 2,097,150 254
Level D 224.0.0.0 to 239.255.255.255 Multicast
Class E 240.0.0.0 to 255.255.255.255 Research/Reserve/Experimental

The calculation of subnets involves some mathematical gauges behind the scenes. To ease our calculations, we can use similar tools ipcalc or subnetcalc for IPv4 subnets. The following snippet shows how to use these tools.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
ipcalc 110.0.20.18/24

Address: 110.0.20.18 01101110.00000000.00010100. 00010010
Netmask: 255.255.255.0 = 24 11111111.11111111.11111111. 00000000
Wildcard: 0.0.0.255 00000000.00000000.00000000. 11111111
=>
Network: 110.0.20.0/24 01101110.00000000.00010100. 00000000
HostMin: 110.0.20.1 01101110.00000000.00010100. 00000001
HostMax: 110.0.20.254 01101110.00000000.00010100. 11111110
Broadcast: 110.0.20.255 01101110.00000000.00010100. 11111111
Hosts/Net: 254 Class A
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
subnetcalc 192.168.10.15/24

Address = 192.168.10.15
11000000 . 10101000 . 00001010 . 00001111
Network = 192.168.10.0 / 24
Netmask = 255.255.255.0
Broadcast = 192.168.10.255
Wildcard Mask = 0.0.0.255
Hosts Bits = 8
Max. Hosts = 254 (2^8 - 2)
Host Range = { 192.168.10.1 - 192.168.10.254 }
Properties =
- 192.168.10.15 is a HOST address in 192.168.10.0/24
- Class C
- Private
GeoIP Country = Unknown (??)
DNS Hostname = (Name or service not known)

Typically, IP addresses are assigned to end hosts and router gateway interfaces as shown in the figure below.

IP

Here, the traffic from Machine A (10.235.64.58) reaches the router gateway interface (10.235.64.57) on the left side of the Internet cloud. It is routed over the Internet to the Google Server gateway and finally to the destination server.

To identify the network interface IP, you can use commands such as ifconfig, hostname or the command ip.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
ifconfig ens160

ens160: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.235.64.58 netmask 255.255.255.252 broadcast 10.235.64.59
inet6 fe80::fc7f:d8da:a969:1c1d prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:23:6f:30 txqueuelen 1000 (Ethernet)
RX packets 35607241 bytes 34540488400 (34.5 GB)
RX errors 0 dropped 12 overruns 0 frame 0
TX packets 24701952 bytes 15008379564 (15.0 GB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
ifconfig ens160

ens160: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.235.64.58 netmask 255.255.255.252 broadcast 10.235.64.59
inet6 fe80::fc7f:d8da:a969:1c1d prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:23:6f:30 txqueuelen 1000 (Ethernet)
RX packets 35607241 bytes 34540488400 (34.5 GB)
RX errors 0 dropped 12 overruns 0 frame 0
TX packets 24701952 bytes 15008379564 (15.0 GB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
1
2
3
hostname -I

10.235.64.58

A network IP address that has a special purpose, such as 0.0.0.0 or 127.0.0.1. The former is the default route or four-zero route, and the latter is called a loopback address.

In the following snippet, we will see the kernel IP routing table and the default route for this network. The flag ‘U’ indicates that the network route is UP, while G indicates that the network route is a network gateway.

1
2
3
4
5
6
netstat -rn | grep ens160

Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
0.0.0.0 10.235.64.57 0.0.0.0 UG 0 0 0 ens160
10.235.64.56 0.0.0.0 255.255.255.252 U 0 0 0 ens160

Typically, an IPv4 datagram consists of a 20-byte header field, an options field, and a variable-length data field. An example packet format is shown below.

IPv4

Below, Wireshark captures help decipher packet header information from live traffic.

IPv6

Internet Protocol version 6 is an updated version of the Internet Protocol (IP). Version 6 of the Internet Protocol is intended to replace the older version (IPv4), which carries 75% of total Internet traffic as of 2018 (source: Google IPv6 Stats).

IPv6 addresses are 128 bits (16 bytes) and use 32 hexadecimal digits, while these are further divided into eight groups of four digits each for ease of management. A brief description is shown below.

IPv6

There are very few basic steps involved in the IPv6 naming convention.

Rule 1: All letters are case-insensitive. For example, ‘ab41’ equals ‘AB41’ Rule 2: Consecutive fields with ‘0’ can be visualized as “::”, but can only appear once in the addressing rules Rule 3: Indicating leading zeros in a field is optional. For example, ‘001a’ is equivalent to ‘1a’

Take the IPv6 address as an example, 45ab:0000:a179:0000:0000:c1c0:abcd:0876

  • Application Rule 1 => 45ab:0000:a179:0000:0000:c1c0:abcd:0876
  • Application Rule 2 => 45ab:0:a179:0:0:c1c0:abcd:876
  • Application Rule 3 => 45ab:0:a179 ::c1c0:abcd:876

There are three types of IPv6 addresses: unicast, multicast, and anycast. A unicast address is a single network interface and the packets transmitted to that particular interface. In addition, unicast addresses have local (link-local) and global scope levels. Multicast addresses are the group interfaces to which packets are delivered. An anycast address is the group interface and the packet delivered to the nearest interface.

A few well known addresses are listed below.

]::1/128 loopback address
ff00::/8 multicast address
fe80::/10 link-local address
2001::/16 regular IPv6 unicast address
2002::/16 6to4 unicast address
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
subnetcalc 2001:4860:4860::8888/64

Address = 2001:4860:4860::8888
2001 = 00100000 00000001
4860 = 01001000 01100000
4860 = 01001000 01100000
0000 = 00000000 00000000
0000 = 00000000 00000000
0000 = 00000000 00000000
0000 = 00000000 00000000
8888 = 10001000 10001000
Network = 2001:4860:4860:: / 64
Netmask = ffff:ffff:ffff:ffff::
Wildcard Mask = ::ffff:ffff:ffff:ffff
Hosts Bits = 64
Max. Hosts = 18446744073709551616 (2^64 - 1)
Host Range = { 2001:4860:4860::1 - 2001:4860:4860:0:ffff:ffff:ffff:ffff }
Properties =
- 2001:4860:4860::8888 is a HOST address in 2001:4860:4860::/64
- Global Unicast Properties:
+ Interface ID = 0000:0000:0000:8888
+ Sol. Node MC = ff02::1:ff00:8888
GeoIP Country = United States (US)
DNS Hostname = dns.google

Similarly, IPv6 packets have both a header and a payload. The header size is fixed at 40 bytes, and the source and destination addresses occupy 32 bytes. An example packet format is shown below.

IPv6

IPv6, for all its benefits, cannot replace IPv4, and the two protocol versions must coexist for a period of time to migrate seamlessly. Therefore, service providers are providing dual-stack support systems that have network interfaces that can understand both IPv4 and IPv6 packets.

There are few intelligent transition mechanisms, i.e., IPv6 tunnels, IPv4 mapped IPv6 addresses, etc. The former encapsulates IPv6 packets in IPv4, while the latter maps IPv6 to IPv4 addresses in a dual-stack implementation.

IPv4 vs IPv6 - Quick Comparison Analysis

Features INTERNET Protocol - Version 4 [IPV4] Internet Protocol - Version 6 [IPV6]
deployment and allocation 1981 1999
length 32-bit 128-bit
address space 4.29 x 10^9 3.4 x 10^38
format dotted decimal / [10.235.64.56] hexadecimal / [2400::4]
number of octets 4 16
header size varies from 20 - 60 bytes 40 bytes
class five classes: Class A, Class B, Class C, Class D, Class E without any
security features/authentication and encryption unavailable available
Check amounts available unavailable
IPSec external and optional built-in features
hop count indicated by the TTL field indicated by the Hoplimit field
fragmentation performed by the sending and forwarding routers by the sender only
Option fields provided in IPv4 header no optional fields, but can use IPv6 extension header
Multicast IGMP manages multicast group members MLD replaces IGMP
Broadcast message available not available. Use multicast
IP to MAC Mapping Address Resolution Protocol Neighbor Discovery Protocol

Conclusion

We have explored the basics of the Internet protocol and its versions. In the process, this paper has clarified the addressing modes, packet formats, and functions of IPv4 and IPv6 through a comparative analysis. Although IPv4 carries most of the Internet traffic today, IPv6 is the future of the networked world.