예제 #1
0
        public static IPv4Address GetIPv4AddressWithinSubnet(this Random random, IPv4SubnetMask mask, IPv4Address networkAddress)
        {
            Int32 maxAddressInSubnet = mask.GetAmountOfPossibleAddresses();

            IPv4Address result = networkAddress + random.Next(1, maxAddressInSubnet);

            return(result);
        }
예제 #2
0
        public static IPv4Address GetIPv4AddressOutWithSubnet(this Random random, IPv4SubnetMask mask, IPv4Address networkAddress)
        {
            Boolean upperBoundaries = random.NextDouble() > 0.5;

            if (upperBoundaries == true)
            {
                Int32 maxAddressInSubnet = mask.GetAmountOfPossibleAddresses();
                return(networkAddress + maxAddressInSubnet + random.Next(10, 300));
            }
            else
            {
                return(networkAddress - random.Next(10, 300));
            }
        }