Code to extract a subnet from a network