Skip to content

Releases: markrogoyski/ipv4-subnet-calculator-php

v4.4.0

15 Jan 01:04

Choose a tag to compare

New Features

  • CIDR aggregation and supernetting: New factory methods for combining multiple subnets into larger summary routes:

    • SubnetCalculatorFactory::aggregate(): Combine contiguous subnets into the minimal set of larger CIDR blocks
    • SubnetCalculatorFactory::summarize(): Find the smallest single supernet that contains all input subnets
    • Automatically handles overlapping subnets, duplicates, and proper CIDR alignment
    • Returns optimally-sized CIDR blocks for efficient route summarization
    • Useful for BGP route aggregation, reducing routing table size, OSPF area design, and network planning
  • Subnet exclusion and difference operations: New methods for calculating remaining address space after removing (excluding) subnets:

    • exclude(): Remove a single subnet from this subnet, returning the remaining address space as an array of optimally-sized CIDR blocks
    • excludeAll(): Remove multiple subnets from this subnet, applying exclusions sequentially
    • Returns minimal set of CIDR blocks covering the remaining space
    • Useful for IP address management (IPAM), reserving address ranges, carving out specific blocks from larger allocations, and network planning
  • Adjacent subnet navigation: New methods for navigating to neighboring subnets of the same size:

    • getNextSubnet(): Get the immediately following subnet in IP address space
    • getPreviousSubnet(): Get the immediately preceding subnet in IP address space
    • getAdjacentSubnets(): Get multiple adjacent subnets in either direction (positive count for forward, negative for backward)
  • Optimal prefix calculation: New utility method for calculating the smallest CIDR prefix that accommodates a given host count:

    • SubnetCalculatorFactory::optimalPrefixForHosts(): Calculate optimal prefix without creating a SubnetCalculator instance
    • Returns the smallest prefix (largest network) needed for the specified number of hosts
    • Useful for network planning and subnet sizing calculations
  • Network class information (legacy): New methods for obtaining classful network information (RFC 791):

    • getNetworkClass(): Get the legacy network class ('A', 'B', 'C', 'D', or 'E')
    • getDefaultClassMask(): Get the default classful mask (e.g., '255.0.0.0' for Class A)
    • getDefaultClassPrefix(): Get the default classful prefix (8, 16, or 24; null for D/E)
    • isClassful(): Check if the current subnet uses the classful default mask
    • While classful networking is obsolete (RFC 4632), it is useful for education, certifications, and legacy systems
  • Utilization statistics: New methods for analyzing subnet efficiency and capacity planning:

    • getUsableHostPercentage(): Calculate percentage of addresses that are usable hosts (accounts for network/broadcast overhead)
    • getUnusableAddressCount(): Get count of unusable addresses (network + broadcast, or 0 for /31 and /32)
    • getUtilizationForHosts($requiredHosts): Calculate utilization percentage for a given host requirement (values >100% indicate insufficient capacity)
    • getWastedAddresses($requiredHosts): Calculate wasted/unused addresses for a given host requirement (negative values indicate insufficient capacity)
    • Useful for capacity planning, choosing optimal subnet sizes, and minimizing IP address waste

Documentation

  • Comprehensive documentation reorganization: Restructured documentation for improved usability:
    • Simplified README with quick start, focused examples, and clear navigation
    • New docs/ directory with complete feature guides, API reference, real-world examples, and learning paths
    • Practical real-world examples including IPAM, firewall rules, BGP route optimization, DHCP, DNS, and network automation

v4.3.0

12 Jan 02:45

Choose a tag to compare

New Features

  • SubnetCalculatorFactory: New factory class for creating SubnetCalculator instances from various input formats:

    • fromCidr(): Create from CIDR notation (e.g., "192.168.1.0/24")
    • fromMask(): Create from IP address and subnet mask (e.g., "192.168.1.0", "255.255.255.0")
    • fromRange(): Create from IP address range (e.g., "192.168.1.0", "192.168.1.255")
    • fromHostCount(): Create from IP address and required host count
  • Subnet overlap and conflict detection: New methods for network planning and conflict prevention:

    • overlaps(): Check if two subnets share any IP addresses
    • contains(): Check if this subnet fully contains another subnet
    • isContainedIn(): Check if this subnet is fully contained within another subnet
    • Useful for firewall rule validation, routing table conflict detection, and network planning
  • IP address range type detection: New methods for identifying special-purpose IPv4 address ranges (IANA registry compliance):

    • isPrivate(): Check if IP is in RFC 1918 private ranges (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16)
    • isPublic(): Check if IP is publicly routable (not in any special-purpose range)
    • isLoopback(): Check if IP is in loopback range (127.0.0.0/8)
    • isLinkLocal(): Check if IP is link-local/APIPA (169.254.0.0/16)
    • isMulticast(): Check if IP is multicast (224.0.0.0/4)
    • isCarrierGradeNat(): Check if IP is in CGN/Shared Address Space (100.64.0.0/10)
    • isDocumentation(): Check if IP is reserved for documentation (TEST-NET-1/2/3)
    • isBenchmarking(): Check if IP is reserved for benchmarking (198.18.0.0/15)
    • isReserved(): Check if IP is reserved for future use (240.0.0.0/4)
    • isLimitedBroadcast(): Check if IP is limited broadcast address (255.255.255.255)
    • isThisNetwork(): Check if IP is in "this" network range (0.0.0.0/8)
    • getAddressType(): Get address type classification as string
    • Useful for security validation, routing decisions, and network classification
  • Wildcard mask calculations: New methods for wildcard masks (inverse of subnet masks), commonly used in Cisco ACLs and OSPF configurations:

    • getWildcardMask(): Returns wildcard mask in dotted quad notation (e.g., "0.0.0.255")
    • getWildcardMaskQuads(): Returns wildcard mask as array of quads (e.g., ['0', '0', '0', '255'])
    • getWildcardMaskHex(): Returns wildcard mask in hexadecimal format (e.g., "000000FF")
    • getWildcardMaskBinary(): Returns wildcard mask in binary format (e.g., "00000000000000000000000011111111")
    • getWildcardMaskInteger(): Returns wildcard mask as integer value (e.g., 255)

Improvements

  • Test organization: Refactored test suite into smaller, focused test files grouped by functionality for better maintainability and clarity

v4.2.0

10 Jan 21:38

Choose a tag to compare

New Features

  • Added project logo

Fixed

  • RFC 3021 compliance for /31 networks: Fixed getMinHost(), getMaxHost(), and their variant methods (*Quads, *Hex, *Binary, *Integer) to correctly calculate host ranges for /31 point-to-point networks. Previously these methods returned the input IP for both min and max; they now correctly return the lower IP (network portion) as min host and higher IP (broadcast) as max host. This aligns with getNumberAddressableHosts() which already correctly reported 2 usable hosts for /31 networks.

v4.1.0

09 Feb 21:24

Choose a tag to compare

New Features

  • split: Split the network into smaller subnets
  • getCidrNotation: Get the network in CIDR notation

Improvements

  • Improvements for compatibility up to PHP 8.4

v4.0.0

29 Dec 00:07

Choose a tag to compare

New Features

  • IPv4 ARPA Domain for reverse DNS lookup (getIPv4ArpaDomain)
  • IP address as integer
    • getIPAddressInteger
    • getMinHostInteger
    • getMaxHostInteger
    • getSubnetMaskInteger
    • getNetworkPortionInteger
    • getHostPortionInteger

Improvements

  • IPv4 ARPA domain and IP as integer added to all reports
  • Internal improvements that come with upgrading PHP minimum versions

Backwards Incompatible Changes

  • Minimum PHP version supported is 7.2
    • For PHP 5.5–7.1, continue to use v3.1.0 release

v3.1.0

19 Dec 06:49

Choose a tag to compare

New Features

  • Is IP address in subnet

Improvements

  • General improvements

v3.0.0

27 Oct 23:35

Choose a tag to compare

New Features

  • Get all IP addresses
  • Get all host IP addresses
  • JsonSerializable interface
  • SubnetReport interface to allow optional custom subnet reports

Improvements

  • General improvements
  • Improvements in build/static analysis tools

v2.1.0

30 Apr 04:15

Choose a tag to compare

New Features

  • Min host
  • Max host
  • Addressable host range

Improvements

  • Improved unit testing
  • General refactoring improvements