This octect-checking will only work if you have subnet mask like 255.0.0.0, 255.255.0.0, and 255.255.255.0. If your subnet mask is different then you will need to check the IP address against the network ID and the subnet mask.

For example, a network 192.168.10.0 with subnet mask 255.255.255.192 includes IP addresses 192.168.10.1-192.168.10.63. This canot be checked for by just comparing octets.
_________________________
There are two types of vessels, submarines and targets.