Difference between IPv4 and IPv6

During the starting of the Internet, IPv4 was mainly used everywhere but nowadays due to an increase in the use of the Internet for almost every possibility, the address space has exhausted. Therefore, IPv6 was introduced which has almost infinite address capability with advanced features like auto-configuration of IP address and mobility, etc. and this address space will not be exhausted in the near future. In this blog, we will see the differences between IPv4 and IPv6 versions of IP addresses .

IPv4

IP version 4 is the older version. It uses 32 bits to create a single uniques address on the internet. IPv4 is limited to 4,294,967,296 addresses i.e. 2³² addresses. It consists of four numbers each of which can contain one to three digits ranging from 0 to 255 separated by a single dot(.). Here, each number is the decimal representation(base-10) for an 8 digit binary number(base-2). These IP addresses pretty much guarantee that our emails will come and go as expected, our google searches would take us to the website where we want and so many other things that we do on the internet.

Example of an IPv4 address: 63.171.234.171

IPv4 Packet Format

IPv4 datagram is a variable-length packet composed of the header(20 bytes) and data(up to 65,536 bytes).

  • Version: It defines the version number of IP which is 4 for this version. Its length is 4 bits.
  • Header length(HLEN): It shows the size of the header. Its length is 4 bits.
  • DSCP: It stands for a differentiated services code field. It determines how datagram should be handled. Its length is 8 bits.
  • Total length: It tells the entire length of IP datagram. Its length is 16 bits.
  • Identification: During transmission, if the data packet is fragmented then this field is used to allocate the same number to each fragment and so that it can be used for reconstructing the original packet. Its length is 16 bits.
  • Flags: It is used to handle fragmentation and it identifies the first, middle or last fragment. Its length is 3 bits.
  • Fragment offset: It represents the offset of data in the original data stream. Its length is 13 bits.
  • Time to leave(TTL): It tells the number of hops a datagram can travel before it is abandoned. At each hop, the value of TTL is decreased by 1 and when it reaches 0, the packet is abandoned. Its length is 8 bits.
  • Protocol: It tells which protocol is used for data transmitting i.e. TCP, UDP, etc. TCP has protocol number 6 and UDP has protocol number 17. Its length is 8 bits.
  • Header Checksum: This is used for error-detection. Its length is 16 bits.
  • Source IP address: It has the IP address of the source. The length is 32 bits.
  • Destination IP address: It has the address of the destination. The length is 32 bits.
  • Options: It provides more functionality to IP datagram. It contains information like routing, timing, management, etc.

IPv6

It is the replacement for IPv4. It uses 128 bits to create a uniques address. This means that there can be theoretically 2¹²⁸uniques address i.e. 340,282,366,920,938,463,463,374,607,431,768,211,456 and this number will never run out(at least in near future). It consists of eight groups of hexadecimal numbers separated by a colon(:). The IPV4 version used numerical values, so, IPv6 adopted the hexadecimal numbers to avoid any conflict. If any group contains all zeros then the notation can be shortened by using a colon to replace the zeroes.

Example of an IPv6 : adba:1925:0000:0000:0000:0000:8a2e:7334

In the above IP address, four groups contain only zeros. This zero can be replaced by a colon and can be re-written as adba:1925::8a2e:7334.

IPv6 Packet Format

IPv6 datagram is a packet composed of the base header ( 40 bytes) and payload (up to 65,536 bytes) Payload has extension header (optional) and data packet .

The base header consists of the following fields:

  • Version: It defines the version number of IP which is 6 here. Its length is 4 bits.
  • Priority: It defines the priority of the packet. Its length is 4 bits.
  • Flow label: It helps in controlling the flow of data. The source device labels to the data packets so that the router route the packet in sequence efficiently. Its length is 24 bits.
  • Payload length: It tells the entire length of the IP datagram except for the base header. Its length is 16 bits.
  • Next header: It denotes the presence of any extension headers or if is not present then it denotes the protocol such as TCP or UDP.
  • Hop limit: This works similarly as TTL as in IPv4. This is used to prohibit the data to go in an infinite loop in the system. At each hop, the value of TTL is decreased by 1 and when it reaches 0, the packet is abandoned. Its length is 8 bits.
  • Source address: It has the IP address of the source. The length is 128 bits.
  • Destination address: It has the IP address of the destination. The length is 128 bits.

Difference between IPv4 and IPv6

  1. Size of IP address: IPv4 is a 32 bits address and IPv6 is a 128 bits address.
  2. Addressing Method: IPv4 uses a numeric( decimal ) addressing method. The binary bits are separated by dots(.). It uses decimal representation. The IPv6 uses alphanumeric addressing(alphabets and numbers) method. The binary bits are separated by a colon(:). It uses hexadecimal representation.
  3. Address Space: IPv4 can generate 2³² address spaces. IPv6 can generate 2¹²⁸ address spaces.
  4. Address Configuration: IPv4 uses the DHCP server to allocate IP addresses to the host or it is done manually. In IPv6 this is done by IPv6 Stateless Address Autoconfiguration . The general idea is to have a device generate a temporary address until it can determine the characteristics of the network it is on, and then create a permanent address it can use based on that information.
  5. Mapping : IPV4 uses ARP to map IPv4 addresses to the MAC address. IPv6 uses NDP (Neighbour Discovery Protocol)map IPv6 addresses to MAC address.
  6. Security: IPv4 security is dependent on the application. IPSEC (Internet Protocol Security) is an inbuilt security feature of IPV6 protocol.
  7. Encryption: In IPv4 encryption and authentication are not provided. In IPv6 encryption and authentication are provided.
  8. Packet Fragmentation: In IPv4, fragmentation is done by sender and forwarding routers . In IPv6, fragmentation is done by only sender routers. We can also say that IPv6 uses end-to-sender fragmentation whereas the in IPv4 fragmentation can also be done by the intermediate routers if the packet is larger.
  9. Header Length: The header length of 20 bytes in IPv4 whereas the header length is 40 bytes in IPv6.
  10. Checksum Field: IPv4 uses the checksum field in the header format for handling errors whereas the IPv6 doesn't have this filed.
  11. Transmission of Packets : IPv4 uses broadcasting for transferring packets from source to destination whereas IPv6 uses multicasting and anycasting .

This is all about IPv4 and IPv6. Hope you learned something new today.

Do share this blog with your friends to spread the knowledge. Visit our YouTube channel for more content. You can read more blogs from here .

Keep Learning :)

Team AfterAcademy!!