IP-Range
This Code-Kata consists in creating a library that calculates a range of IP addresses from an IP address and with a final IP address or a mask or a short mask.
An IP address is a way to identify a device in a network that uses the IP protocol. An IP address is formed by 4 groups of numbers from 0 to 255 and are separated by points (192.168.0.1)
- A final IP address is the same as an IP address, but that is greater or less than the IP address. Example: IP Address: 172.1.1.1 Final (Higher) 172.1.1.244 Final (Lesser) 172.1.0.1
- A mask has the same format as an IP address, but it indicates a network or range of IP addresses for an address. Example: IP Address: 192.168.0.1 MASK: 255.255.255.0 RANGE_FROM: 192.168.0.1 RANGE_TO: 192.168.0.255
- A short mask is a representation of the mask but counting the number of bits, it is between 1 and 32. Example: SHORT_MASK: 24 LONG_MASK: 255.255.255.0 In bits: 11111111.11111111.11111111.00000000 They are the same.
Note: There are already many libraries that do this and many programming languages have them included. If you decide to use one of these libraries, create your tests and when you see that you meet all the conditions, try to change the library to see how much it costs, if you have encapsulated the library correctly it should not take much effort to change it and your tests will remain green without changing them .
Range by final IP
Examples:
INPUT: ip_from: 192.168.1.1 ip_to: 192.168.1.255
OUTPUT from: 192.168.1.1 to: 192.168.1.255 ___
INPUT: ip_from: 192.168.1.1 ip_to: 192.168.0.1
OUTPUT from: 192.168.0.1 to: 192.168.1.1
Range by Netmask
Examples:
INPUT: ip_from: 192.168.1.1 mask: 255.255.255.0
OUTPUT from: 192.168.1.1 to: 192.168.1.255 ___
INPUT: ip_from: 192.168.1.1 mask: 255.255.0.0
OUTPUT from: 192.168.1.1 to: 192.168.255.255
Range by short Netmask
Example:
INPUT: ip_from: 192.168.1.1 short: 24
OUTPUT from: 192.168.1.1 to: 192.168.1.255 ___
INPUT: ip_from: 192.168.1.1 short: 16
OUTPUT from: 192.168.1.1 to: 192.168.255.255