# Bit Requirements Analysis for IP Address Encoding
## Overview
This document analyzes the bit requirements for encoding all possible IP addresses with ports, and calculates how many words are needed with different dictionary sizes.
## IP Address Space Requirements
### IPv4 with Port
- **IPv4 Address**: 32 bits (4 octets × 8 bits)
- **Port Number**: 16 bits (0-65535)
- **Total**: 48 bits
### IPv6 with Port
- **IPv6 Address**: 128 bits (16 octets × 8 bits)
- **Port Number**: 16 bits (0-65535)
- **Total**: 144 bits
## Dictionary Sizes and Bits per Word
| 4,096 words | 12 bits | log₂(4,096) = 12 |
| 8,192 words | 13 bits | log₂(8,192) = 13 |
| 16,384 words | 14 bits | log₂(16,384) = 14 |
| 32,768 words | 15 bits | log₂(32,768) = 15 |
| 65,536 words | 16 bits | log₂(65,536) = 16 |
## Words Required for IPv4 + Port (48 bits)
### With 4,096-word dictionary (12 bits/word)
- **Calculation**: 48 ÷ 12 = 4 words exactly
- **Total combinations**: 4,096⁴ = 281,474,976,710,656 (281 trillion)
- **Verdict**: ✅ Perfect fit - exactly 4 words needed
### With 8,192-word dictionary (13 bits/word)
- **Calculation**: 48 ÷ 13 = 3.692... → 4 words needed
- **Bits provided**: 4 × 13 = 52 bits
- **Wasted bits**: 52 - 48 = 4 bits
- **Total combinations**: 8,192⁴ = 4,503,599,627,370,496 (4.5 quadrillion)
- **Verdict**: ✅ Works with 4 words, some overhead
### With 16,384-word dictionary (14 bits/word)
- **Calculation**: 48 ÷ 14 = 3.429... → 4 words needed
- **Bits provided**: 4 × 14 = 56 bits
- **Wasted bits**: 56 - 48 = 8 bits
- **Total combinations**: 16,384⁴ = 72,057,594,037,927,936 (72 quadrillion)
- **Verdict**: ✅ Works with 4 words, more overhead
### With 32,768-word dictionary (15 bits/word)
- **Calculation**: 48 ÷ 15 = 3.2 → 4 words needed
- **Bits provided**: 4 × 15 = 60 bits
- **Wasted bits**: 60 - 48 = 12 bits
- **Total combinations**: 32,768⁴ = 1,152,921,504,606,846,976 (1.15 quintillion)
- **Verdict**: ✅ Works with 4 words, significant overhead
### With 65,536-word dictionary (16 bits/word)
- **Calculation**: 48 ÷ 16 = 4 words exactly
- **Total combinations**: 65,536³ = 281,474,976,710,656 (281 trillion)
- **Verdict**: ✅ Perfect fit - exactly 4 words needed
## Words Required for IPv6 + Port (144 bits)
### With 4,096-word dictionary (12 bits/word)
- **Calculation**: 144 ÷ 12 = 12 words exactly
- **Total combinations**: 4,096¹² ≈ 1.84 × 10⁴³
- **Verdict**: ✅ Perfect fit - exactly 12 words needed
### With 8,192-word dictionary (13 bits/word)
- **Calculation**: 144 ÷ 13 = 11.077... → 12 words needed
- **Bits provided**: 12 × 13 = 156 bits
- **Wasted bits**: 156 - 144 = 12 bits
- **Total combinations**: 8,192¹² ≈ 4.72 × 10⁴⁶
- **Verdict**: ✅ Works with 12 words, some overhead
### With 16,384-word dictionary (14 bits/word)
- **Calculation**: 144 ÷ 14 = 10.286... → 11 words needed
- **Bits provided**: 11 × 14 = 154 bits
- **Wasted bits**: 154 - 144 = 10 bits
- **Total combinations**: 16,384¹¹ ≈ 3.77 × 10⁴⁶
- **Verdict**: ✅ Works with 11 words
### With 32,768-word dictionary (15 bits/word)
- **Calculation**: 144 ÷ 15 = 9.6 → 10 words needed
- **Bits provided**: 10 × 15 = 150 bits
- **Wasted bits**: 150 - 144 = 6 bits
- **Total combinations**: 32,768¹⁰ ≈ 1.42 × 10⁴⁵
- **Verdict**: ✅ Works with 10 words
### With 65,536-word dictionary (16 bits/word)
- **Calculation**: 144 ÷ 16 = 9 words exactly
- **Total combinations**: 65,536⁹ ≈ 1.84 × 10⁴³
- **Verdict**: ✅ Perfect fit - exactly 9 words needed
## Summary Table
| 4,096 (12-bit) | 4 words | 100% (perfect) | 12 words | 100% (perfect) |
| 8,192 (13-bit) | 4 words | 92.3% | 12 words | 92.3% |
| 16,384 (14-bit) | 4 words | 85.7% | 11 words | 93.5% |
| 32,768 (15-bit) | 4 words | 80.0% | 10 words | 96.0% |
| 65,536 (16-bit) | 4 words | 100% (perfect) | 9 words | 100% (perfect) |
## Key Findings
1. **Perfect Fits**:
- 4,096-word dictionary: 4 words for IPv4, 12 words for IPv6
- 65,536-word dictionary: 4 words for IPv4, 9 words for IPv6
2. **Most Practical for Human Use**:
- **IPv4**: 3-4 words is manageable for humans
- **IPv6**: 9-12 words is challenging for human memory
3. **Trade-offs**:
- Smaller dictionaries = more words needed but easier to curate quality words
- Larger dictionaries = fewer words needed but harder to find memorable words
4. **Recommendation for Four-Word System**:
- The current four-word system works only with a 65,536-word dictionary for IPv4
- For smaller dictionaries, a fourth word (or numeric suffix) is required
- IPv6 requires significantly more words regardless of dictionary size
## Additional Considerations
### Protocol and Additional Information
The above calculations assume only IP address and port. Real network addresses may include:
- Protocol type (UDP, TCP, QUIC, etc.)
- Additional layers (p2p, circuit relay, etc.)
These require additional bits, making the encoding requirements even higher.
### Human Factors
Research shows humans can reliably remember:
- 3-4 words: Easy
- 5-7 words: Moderate difficulty
- 8+ words: Very difficult
This suggests that for human-friendly addresses, we should optimize for IPv4 scenarios with 3-4 words maximum.