You are on page 1of 2

IP address and Subnet mask validator

1. The address must consist of four decimal numbers separated by periods (dots).
2. Each number must be between 0 and 255, inclusive.
3. Convert each octet into binary and print the output followed by a valid or invalid
message
4. Validate each of the decimal values input to ensure they are in the range 0-255
inclusive. Provide appropriate user feedback if invalid data are input and handle the
input data appropriately until valid data is received. ie. No processing or calculations
should be done/attempted on invalid data.
5. In any cell that displays binary data, the cell should always display exactly 8 bits
(which includes leading zeros) eg. 00010111.
6. Validate the entries in the SUBNET MASK to ensure it produces a valid mask ie. a
single run of 1's followed by a single run of 0's
7. 255.255.255.0 is 11111111.11111111.11111111.00000000 not 255.0.240.5 which
would be 11111111.00000000.11110000.00000101
8. The subnet mask address binary has to have a single run of 1s and 0s otherwise it is
invalid. For example 255.255.255.254 the result should be
11111111.11111111.11111111.1111110 which is valid. But 255.254.255.255 result
would be 11111111.11111110. 11111111. 11111111 INVALID, because it cannot go
back to 1 after you get a 0 in the converted binary address. This limits the possible
numbers to:
00000000 | 0
10000000 | 128
11000000 | 192
11100000 | 224
11110000 | 240
11111000 | 248
11111100 | 252
11111110 | 254
11111111 | 255
9. Do the project both in interactive and batch mode.
10. Interactive mode should take one IP and subnet mask as input and should print the
results directly in the console
11. Batch mode of IP should take a text file constituting all possible valid invalid Ips in
one file as input and produce the corresponding validation messages as output into
an output file formed.
12. Batch mode of subnet mask should take a text file constituting all possible valid
invalid subnet masks in one file as input and produce the corresponding validation
messages as output into an output file formed.

You might also like