IPv4 Subnet Calculator Multilang
One IPv4/CIDR specification, three implementations, one shared contract-test suite.
View repository · View CI · Read the full README · DataTideHH portfolio
Project purpose
This project compares how a clearly bounded networking calculation can be implemented and verified in Java 21, C++20 and Python 3.12.
The deliberately narrow scope makes the comparison credible:
- one accepted
IPv4/CIDRformat - explicit validation
- consistent terminal output
- interactive and direct modes
- correct
/0,/31and/32handling - no external runtime dependencies
- one shared set of expected domain results
- consistent oversized-number handling across fixed-width and arbitrary-precision integers
The project connects programming fundamentals, test design and practical IPv4 subnetting without presenting a small calculator as a production network platform.
Implementations
| Implementation | Structure | Verification | Status |
|---|---|---|---|
| Java 21 | Single application class with a record result | Plain Java CLI contract runner | Implemented and tested |
| C++20 | Header, calculation module and terminal entry point | CTest contract executable plus CLI smoke script | Implemented and tested |
| Python 3.12 | Single module with a frozen, slotted dataclass | Standard-library unittest plus subprocess checks |
Implemented and tested |
All three versions share the same input contract, output fields, validation categories, special-case behavior and exit rules.
Example
Input:
192.168.10.42/24
Output:
Input IP: 192.168.10.42
CIDR prefix: /24
Subnet mask: 255.255.255.0
Wildcard mask: 0.0.0.255
Network address: 192.168.10.0
Broadcast address: 192.168.10.255
Total addresses: 256
Usable hosts: 254
First usable host: 192.168.10.1
Last usable host: 192.168.10.254
Note: Standard subnet with network and broadcast addresses excluded.
The complete normative rules are documented in the behavior specification.
The /0 output is a mathematical calculation over the complete 32-bit IPv4 address space. It is not a claim that all reported addresses are globally assignable to hosts.
Shared verification
Every language-specific runner reads the same tab-separated contract file.
The current contract contains seven valid and sixteen invalid cases covering:
- standard
/24,/30and/16subnets - all IPv4 addresses through
/0 /31point-to-point semantics/32host-route semantics- surrounding-whitespace trimming
- malformed separators and octet counts
- empty and non-decimal values
- signs, range violations and leading zeros
- oversized numeric octets and prefixes
- whitespace inside the token
Valid cases verify every result field. Invalid cases verify the exact validation reason.
Every implementation also has CLI smoke coverage for:
- valid direct execution
- invalid direct execution
- help mode
- incorrect usage with too many arguments
Read Testing and CI for commands and design details.
GitHub Actions
The repository runs three independent checks on pull requests and pushes to main:
Java 21C++20Python 3.12
Separate jobs make failures easy to locate and provide stable status checks for protected-branch rules. The workflow uses read-only permissions, current official action major versions and per-job timeouts.
Run examples
Java
javac -d java/out java/src/SubnetCalculator.java
java -cp java/out SubnetCalculator 192.168.10.42/24
C++
cmake -S cpp -B cpp/build
cmake --build cpp/build --config Release
Python
python python/subnet_calculator.py 192.168.10.42/24
Standards and learning references
- RFC 3021: Using 31-Bit Prefixes on IPv4 Point-to-Point Links
- RFC 4632: Classless Inter-domain Routing (CIDR)
- Core Internet Standards and RFC Editor
- GitHub Actions Documentation
Related portfolio projects
- Cisco Switching Lab provides the physical switching and CCNA-oriented context behind IPv4 addressing and subnetting.
- Spring Boot Process API Basics shows the Java progression from a compact command-line implementation to a layered REST API.
Together, the projects show a controlled learning progression across networking fundamentals, multi-language implementation, automated verification and backend structure.
Scope limits
The project intentionally excludes IPv6, VLSM planning, subnet splitting, a GUI, a web frontend, persistence, exports and external CLI frameworks.
These limits keep the source understandable and the cross-language comparison direct.
Portfolio assessment
The strongest signal is not the calculator alone. It is the disciplined workflow around it:
- explicit behavioral specification
- three independently structured implementations
- shared domain test cases
- reproducible local commands
- GitHub Actions
- public project documentation
- honest scope boundaries
That makes the repository a credible supporting project for a Data/BI and process-analysis portfolio with additional networking and software-engineering foundations.