Computer Networking Basics
Which correctly shortens the IPv6 address 2001:0db8:0000:0000:0000:0000:0000:0001 according to the abbreviation rules?
- A2001:db8:1
- B2001:db8::1
- C2001:db8::0::1
Show answer and explanation
Answer: B. 2001:db8::1
An IPv6 address is 128 bits long (IPv4 is 32 bits), divided into eight 16-bit groups, each written as four hexadecimal digits. There are two abbreviation rules: leading zeros in each group can be dropped (0db8→db8, 0001→1), and one run of consecutive all-zero groups can be replaced with "::" once. Here the five zero groups from the third to the seventh collapse to give 2001:db8::1. Using "::" twice is not allowed because it would be ambiguous how many zero groups each one stands for. "2001:db8:1" has only three groups and lacks the "::" that marks omitted zero groups, so it is not a valid form of this address.
- A. Omitted zero groups must be marked with "::"; this has only three groups and is invalid.
- B. Correct. Drop leading zeros and collapse the run of zero groups into one "::".
- C. "::" may be used only once.