Random IPv6 Compression Exercise Generator
Generate expanded IPv6 prompts and canonical RFC 5952 compressed answer forms with configurable zero runs.
Description
Generate expanded IPv6 compression prompts with one controlled zero run and canonical answer strings.
IPv6 text can omit leading zeros and collapse a contiguous sequence of zero groups with ::. Canonical RFC 5952 formatting uses lowercase hex and collapses the longest qualifying run, choosing the leftmost run in a tie.1
This generator builds an eight-group address with one chosen zero run; every other group is nonzero. Each result.exercises item includes expanded as the full prompt and compressed as its answer. The full address value is unchanged by compression.
When to use Random IPv6 Compression Exercise Generator
Use it for zero-run compression practice or formatter fixtures with a guaranteed compressible run.
How to use Random IPv6 Compression Exercise Generator and understand its results
- Enter integer exerciseCount from 1 through 256 and ordered integer minimumZeroRun and maximumZeroRun from 2 through 8.
- Run and show expanded as the learner-facing prompt, keeping compressed separate.
- Remove unnecessary leading zeros and replace the zero run with ::, then compare with the canonical answer.
runLength = minimumZeroRun + floor(r1 × (maximumZeroRun − minimumZeroRun + 1)); start = floor(r2 × (9 − runLength)) The run and its feasible zero-based start position are drawn first.
The implementation writes zeros at that run’s positions and samples all remaining groups as inclusive integers 1–65,535. It formats eight padded lowercase hex groups and calls the IPv6 compressor for the canonical answer.
draw count per exercise = 2 + (8 − runLength) A length-eight run needs only its run and start draws; no random draw is needed for zero groups.
{
"input": {
"exerciseCount": 3,
"minimumZeroRun": 2,
"maximumZeroRun": 5
},
"randomDraw": 0.25,
"output": {
"result": {
"exercises": [
{
"compressed": "4000::4000:4000:4000:4000",
"expanded": "4000:0000:0000:0000:4000:4000:4000:4000"
},
{
"compressed": "4000::4000:4000:4000:4000",
"expanded": "4000:0000:0000:0000:4000:4000:4000:4000"
},
{
"compressed": "4000::4000:4000:4000:4000",
"expanded": "4000:0000:0000:0000:4000:4000:4000:4000"
}
]
}
}
} Run length eight gives 0000:0000:0000:0000:0000:0000:0000:0000 and answer ::. Runs can begin or end the address. A one-group run, reversed bounds, counts above 256, and invalid consumed draws fail.
Limitations and assumptions
The default source is Math.random; no seed input or cryptographic entropy guarantee is provided. Repeated runs may select the same result, and the distribution depends on the random source.
The construction excludes competing zero runs and isolated zero groups outside the selected run, so it does not exercise every canonicalization case. It produces no IPv4-embedded or zone-qualified text.
Both prompt and answer are returned; there is no automatic answer hiding, scoring, address assignment, or connectivity check.
Alternative or Complementary methods
Compress an explicit address to cover other zero-run patterns, or expand a compressed address to inspect its eight groups.
References
-
RFC 5952: A Recommendation for IPv6 Address Text Representation — IETF, RFC Editor
Similar or alternative tools
- IPv6 Address Compressor
Canonicalize a chosen IPv6 address, including competing zero runs.
- IPv6 Address Expander
Expand an explicit compressed address into full groups.