Hello Sarah and Giuseppe,
Giuseppe is of course right. However, if taking this purely technically, a similar method (although not so straightforward) can be used to compute networks and their multiples in IPv6 addresses.
Let say we have ipv6 prefix i.e 2001:0000::/23
our goal is to find valid ip address range, network number, next network number. Here i am stumped.
Okay but let's take a more appropriate example, say: 2001:4118:ABCD::/46.
So the /46 prefix means that the "mask" (which is not used in this format in IPv6) is 16+16+8+6 bits long, translating into FFFF:FFFF:FFFC. How did I calculate that? Well, it is worth memorizing the following table of translation from decimal to hexadecimal mask byte:
Number of bits (CIDR)
 Decimal value
 Hexadecimal value


/0  0  0x0 
/1  128  0x80 
/2  192  0xC0 
/3  224  0xE0 
/4  240  0xF0 
/5  248  0xF8 
/6  252  0xFC 
/7  254  0xFE 
/8  255  0xFF 
Now note that each hexadecimal digit (09, AF) is a direct expression of a 4bit value. In hexadecimal notation, we can perform the binary AND on individual hexadecimal digits. Also note that for sake of easiness, we can translate each nibble to a value between 0 and 15 and compute the AND in decimal, then reconvert the result back to hexadecimal if that suits you better. Let's call this one hexadecimal digit (a group of 4 bits) a nibble.
So, to compute the address of the network, we have:
2001:4118:ABCD::
&&
FFFF:FFFF:FFFC::
The only "interesting" nibble here is the last one where the mask nibble is set to C (all other nibbles are uninteresting because any nibble bitwise ANDed with 0xF yields the same value again, and all other nibbles ANDed with 0 yield 0). All we have to do now is compute the binary AND of 0xD in the address and of the 0xC in the mask. Let's do it in decimal and in the very similar way to how we compute it for IPv4 addresses but here, we are in the scope of a single nibble so instead of subtracting the mask from 256, now we subtract the mask from 16:
0xD = 14 (nibble in the address)
0xC = 12 (nibble in the mask)
16  0xC = 16  12 = 4  the networks are multiples of 4 on the interesting nibble
0xD = 14 rounded down to a multiple of 4 is 12 which is 0xC in hexadecimal
Thus, the network number in this case would be 2001:4118:ABCC::, and the next network would be 4 "steps" further at the interesting nibble and above: 2001:4118:ABC(C+4):: yielding 2001:4118:ABD0:: (note that 0xC + 4 = 0x10 so the predecessing nibble had to be incremented as well).
So the general process is:
 Translate the prefix length into a hexadecimal mask notation
 Find the (only) interesting nibble in mask whose value is neither 0x0 nor 0xF
 Convert the interesting nibble from hexadecimal to decimal.
 In decimal, subtract the value of this interesting nibble from 16, and call this resulting difference M.
 Convert the corresponding nibble in the IPv6 address from hexadecimal to decimal. Let us call this value A.
 Round down the decimal value A to the nearest integer multiple of M, and convert it back to hexadecimal.
I guess that after a longer practice the converting between decimal and hexadecimal will not be necessary anymore. This can be computed directly in hexadecimal, however, a care must be then taken to not to mix decimal and hexadecimal notations.
Please ask further if there is anything unclear!
Best regards,
Peter
Hello Sarah and Giuseppe,
Giuseppe is of course right. However, if taking this purely technically, a similar method (although not so straightforward) can be used to compute networks and their multiples in IPv6 addresses.
Okay but let's take a more appropriate example, say: 2001:4118:ABCD::/46.
So the /46 prefix means that the "mask" (which is not used in this format in IPv6) is 16+16+8+6 bits long, translating into FFFF:FFFF:FFFC. How did I calculate that? Well, it is worth memorizing the following table of translation from decimal to hexadecimal mask byte:
Now note that each hexadecimal digit (09, AF) is a direct expression of a 4bit value. In hexadecimal notation, we can perform the binary AND on individual hexadecimal digits. Also note that for sake of easiness, we can translate each nibble to a value between 0 and 15 and compute the AND in decimal, then reconvert the result back to hexadecimal if that suits you better. Let's call this one hexadecimal digit (a group of 4 bits) a nibble.
So, to compute the address of the network, we have:
The only "interesting" nibble here is the last one where the mask nibble is set to C (all other nibbles are uninteresting because any nibble bitwise ANDed with 0xF yields the same value again, and all other nibbles ANDed with 0 yield 0). All we have to do now is compute the binary AND of 0xD in the address and of the 0xC in the mask. Let's do it in decimal and in the very similar way to how we compute it for IPv4 addresses but here, we are in the scope of a single nibble so instead of subtracting the mask from 256, now we subtract the mask from 16:
Thus, the network number in this case would be 2001:4118:ABCC::, and the next network would be 4 "steps" further at the interesting nibble and above: 2001:4118:ABC(C+4):: yielding 2001:4118:ABD0:: (note that 0xC + 4 = 0x10 so the predecessing nibble had to be incremented as well).
So the general process is:
I guess that after a longer practice the converting between decimal and hexadecimal will not be necessary anymore. This can be computed directly in hexadecimal, however, a care must be then taken to not to mix decimal and hexadecimal notations.
Please ask further if there is anything unclear!
Best regards,
Peter