# IPv6 Address Types, Notation, and Structure Explained

This tutorial explains the format, notation, structure, types, and abbreviation methods of IPv6 address. Learn what IPv6 addresses are and how they are categorized in various types.

In computer networks, an interface connects the computer or the networking device to the network. An IP address provides a unique identity to the interface. If a device has multiple interfaces, you can access it through any interface from all available interfaces. For example, if a printer has two interfaces and both are configured with IP addresses, it can be reached on either interface.

There are two versions of IP addresses: IPv4 and IPv6. In this tutorial, we will discuss IPv6 address structure and types.

### IPv6 address structure and notation

IPv6 addresses are represented in hexadecimal notation. The IPv6 address consists of 128 binary bits. These bits are divided into eight 16-bit segments and each 16-bit segment is converted into a 4-digit hexadecimal number and separated by a colon. The term nibble is used to represent a group of four hex digits or 16 binary bits; thus, in an IPv6 address, we have eight nibbles values separated by colons.

The following image explains the basic structure of an IPv6 address in both binary and hexadecimal notation through an example IPv6 address.

Let's understand the above example address in detail. The following is the binary form of the address.

```0010000000000001000011011011100000000000000000000010111100111011
0000001010101010000000001111111111111110001010001001110001011010
```

To convert this binary address to hexadecimal format, add a space after every 16 bits. By doing this, we will get eight blocks where each block has 16 bits.

```0010000000000001 0000110110111000 0000000000000000 0010111100111011
0000001010101010 0000000011111111 1111111000101000 1001110001011010
```

Now take the first block, and add a space after every 4 bits.

```0010 0000 0000 0001
```

Four binary bits make a hexadecimal digit. The following table lists the corresponding binary value of each hex digit (0-F).

 Hex digit Binary value Hex digit Binary value Hex digit Binary value Hex digit Binary value 0 0000 4 0100 8 1000 C 1100 1 0001 5 0101 9 1001 D 1101 2 0010 6 0110 A 1010 E 1110 3 0011 7 0111 B 1011 F 1111

Write the corresponding hexadecimal digits in place of each 4-bit binary group.

 Binary value 0010 0000 0000 0001 Hexadecimal digit 2 0 0 1

After the conversion, remove the blanks added to the binary bits and write all four hexadecimal digits together as shown below.

2001

Now, follow the same steps and convert the remaining blocks to hexadecimal format.

2001 0DB8 0000 2F3B 02AA 00FF FE28 9C5A

Add a colon after each block and remove the blanks. The result will be the following.

2001:0DB8:0000:2F3B:02AA:00FF:FE28:9C5A

To simplify the address representation, IPv6 supports two types of abbreviations. Both abbreviations work with zeros. The first abbreviation allows us to skip leading zeros within a nibble while the second abbreviation allows us to drop the nibbles that contain only zeros. Since most IPv6 addresses contain long sequences of zeros, these two abbreviations can make writing IPv6 addresses a lot easier.

To understand how abbreviations work, let's take an example. The following is the IPv6 address.

```2001:0DB8:5002:AB41:0000:0000:0000:0801
```

The first form of abbreviation allows us to remove leading zeros within a nibble. After removing leading zeros from all nibbles, the above address could be abbreviated as the following.

```2001:DB8:5002:AB41:0:0:0:801
```

The second form of abbreviation allows us to use a double colon to represent one or more consecutive sets of zero nibbles. Using this form of abbreviation, the above address can be further abbreviated as the following.

```2001:DB8:5002:AB41::801
```

Two important rules must be followed when abbreviating an IPv6 address. First, you can't abbreviate a zero that is not leading in the nibble. For example, you can't abbreviate the address 2001:0DB8:5000:AB00:2300:0034:00A4:0801 as the 2001:0DB8:5:AB:23:34:A4:801. But, you can abbreviate this address as the 2001:DB8:5000:AB00:2300:34:A4:801 .

Second, you can use only one double colon within an address representation. For example, you can abbreviate the address 2001:AB3:0:45CA:0:0:0:F5 as either 2001:AB3::45CA:0:0:0:F5 or 2001:AB3:0:45CA::F5. But you can't abbreviate this address as the 2001:AB3::45CA::F5. If you will use two double colons in an address, the address will be considered as an ambiguous address.

To calculate the full address from an abbreviate address, first, check whether the address has a double colon. If it has a double colon, determine how many 0 blocks are represented by the double colon. For this, count the number of blocks in the abbreviated address and subtract this number from 8. For example, in the address FF01::1, there are two blocks: FF01 and 1. The number of blocks expressed by the double colon (::) is 6 (8 blocks - 2 two blocks).

Once all 8 blocks are determined, count the number of hexadecimal digits in each block. Each block must contain 4 Hexadecimal digits. If any block contains less than 4 hexadecimal digits, add an equal number of zeros on the left side or in the leading position of the block.

```FF01::1
```

The address after removing abbreviated double-colon

```FF01:0:0:0:0:0:0:1
```

```FF01:0000:0000:0000:0000:0000:0000:0001
```

So the full address of the abbreviated address FF01::1 is the FF01:0000:0000:0000:0000:0000:0000:0001.

### IPv6 prefixes

IPv6 addresses are categorized into several types. To identify every type, a unique prefix is assigned to each type. The prefix is the part of the address where bits have fixed values. Prefix bits define a route or subnet. An IPv6 prefix is written in address/prefix-length notation. For example, in the address 2001:AACD:3B:23::/64, the length of the prefix is 64.

The following table lists the common IPv6 prefixes and their allocations.

 IPv6 Prefix Binary Form Allocation 0000::/3 000 Reserved by IETF. Two addresses from this block are assigned. These addresses are the unspecified address (::) and the loopback address (::1). 2000::/3 001 Global unicast address space 4000::/3 010 Reserved by IETF 6000::/3 011 Reserved by IETF 8000::/3 100 Reserved by IETF A000::/3 101 Reserved by IETF C000::/3 110 Reserved by IETF E000::/4 1110 Reserved by IETF F000::/5 1111 0 Reserved by IETF F800::/6 1111 10 Reserved by IETF FC00::/7 1111 110 Unique local unicast FF00::/8 1111 1111 Multicast FE00::/9 1111 1110 0 Reserved by IETF FE80::/10 1111 1110 10 Link local unicast FEC0::/10 1111 1110 11 Reserved by IETF

There are three types of IPv6 addresses: Unicast, Anycast, and Multicast. Let's understand these address types in detail through an example.

A unicast address represents a single interface in the network. It is used in end-to-end communication between two devices. Data packets addressed to a unicast address are received and processed by only one device.

The following image shows a unicast communication between two PCs. In this example, packets sent by PC0 are received only by PC6.

There are mainly three types of unicast addresses: link-local, site-local or unique local, and global. A link-local unicast address identifies the interface in the local network. A site-local address represents the interface in the network. A global unicast address provides a unique identity to the interface in the global IPv6 Internet network.

There are mainly three types of unicast addresses: link-local, site-local or unique-local, and global. A link-local unicast address identifies the interface in the local network. A site-local address identifies the interface in the network. A global unicast address identifies the interface in the global IPv6 Internet network.

These unicast addresses are explained along with other unicast addresses in the following tutorial.

An anycast address identifies a single interface in the group of interfaces. The concept of anycast addresses is introduced in IPv6. In this concept, a group of interfaces is created by assigning the same anycast address on all interfaces.

Once the group is created, any interface from the group can receive IP packets on the behalf of the group. IP packets sent to an anycast address are received by only one interface of the group, not by all interfaces. To identify the interface that will receive IP packets, routers use routing table metrics.

In simple words, when a router receives an IP packet for an anycast address, it forwards the packet to the interface that is nearest to the router and belongs to the destination anycast group. Anycast addresses are used to optimize the network.

The following image shows a sample implementation of an anycast address. In this implementation, five interfaces are grouped by specifying the same anycast address. From these interfaces, any interface that is near to the sender device can receive IP packets sent to this anycast address. For example, when PC-A and PC-C send IP packets to this anycast address, they are respectively received by the In1 and In3 interfaces, as both interfaces are near to their respective sender devices.