public NetworkBuilder(NetworkInfo Info)
        {
            //// Get the nessecary data to build the subnetting information

            //int NumberOfHostsNeeded = Info.NumberOfHosts;

            //// The nessecary address class for the number of subnets and the required hosts per subnet
            //AddressClass InetClass = DetermineNessecaryAddressClass(NumberOfHostsNeeded);

            //// Uses 2^x to determine how many bits need to be borrowed
            //int BitsToBorrow = DetermineBitsToBorrow(NumberOfHostsNeeded, InetClass);

            //int BitsForAddressSpace = DetermineBitsForAddressSpace(BitsToBorrow, InetClass);

            //int RequiredSubnets = DetermineNumberOfSubnets(BitsToBorrow, InetClass);

            int BitsToBorrow = DetermineBitsToBorrow(Info.RequiredSubnets);

            AddressClass InetClass = DetermineNessecaryAddressClass(Info.NumberOfHosts);

            int AddressSpaceBits = DetermineBitsForAddressSpace(BitsToBorrow, InetClass);

            int RequiredSubnets = IntPow(2, BitsToBorrow);

            // Gets the subnet mask using data resources basedo n the required bits to borrow
            SubnetMask NetMask = GetSubnetAddress(InetClass, BitsToBorrow, AddressSpaceBits);
            IpAddress SampleAddress = new IpAddress(Info.SampleAddress);

            // The program has different functionallity based on different address class
            // For Class C it will be able to build the entire subnet out
            // For the other classes it will display generic subnetting information but not build a subnet
            switch (InetClass)
            {
                case AddressClass.A:
                    BuiltNetwork = new FullNetwork();
                    // Gather network information for Class A
                    //ClassAandBBuilder ClassABuilder = new ClassAandBBuilder();
                    //ClassABuilder.NetMask = NetMask;
                    //ClassABuilder.HostsPerSubnet = IntPow(2, (AddressSpaceBits - 2) );
                    //ClassABuilder.NumberOfSubents = IntPow(2, BitsToBorrow);
                    //BuiltNetwork.ClassAorBBuilder = ClassABuilder;
                    BuiltNetwork = new FullNetwork();
                    BuiltNetwork.BitsBorrowed = BitsToBorrow;
                    BuiltNetwork.Class = InetClass;
                    BuiltNetwork.NetMask = NetMask;
                    BuiltNetwork.NumberOfSubnets = IntPow(2, BitsToBorrow);
                    BuiltNetwork.AddressSpace = IntPow(2, AddressSpaceBits);
                    BuiltNetwork.UsableHosts = IntPow(2, AddressSpaceBits) - 2;
                    break;
                case AddressClass.B:
                    //BuiltNetwork = new FullNetwork();
                    //ClassAandBBuilder ClassBBuilder = new ClassAandBBuilder();
                    //ClassBBuilder.NetMask = NetMask;
                    //ClassBBuilder.HostsPerSubnet = IntPow(2, AddressSpaceBits);
                    //ClassBBuilder.NumberOfSubents = IntPow(2, BitsToBorrow);
                    //BuiltNetwork.ClassAorBBuilder = ClassBBuilder;
                    BuiltNetwork = new FullNetwork();
                    BuiltNetwork.BitsBorrowed = BitsToBorrow;
                    BuiltNetwork.Class = InetClass;
                    BuiltNetwork.NetMask = NetMask;
                    BuiltNetwork.NumberOfSubnets = IntPow(2, BitsToBorrow);
                    BuiltNetwork.AddressSpace = IntPow(2, AddressSpaceBits);
                    BuiltNetwork.UsableHosts = IntPow(2, AddressSpaceBits) - 2;
                    break;
                case AddressClass.C:
                    // Gather network information for Class C
                    int SubnetCount = 0;
                    BuiltNetwork = new FullNetwork();
                    // Begin the subnet building process
                    ClassCSubnetBuilder ClassCBuilder = new ClassCSubnetBuilder(NetMask, SampleAddress);
                    // Subtraction by one because it is a based of zero
                    while (SubnetCount < RequiredSubnets)
                    {
                        SubnetCount += 1;
                        Subnetwork Subnet = ClassCBuilder.NextSubnet();
                        BuiltNetwork.Subnets.Enqueue(Subnet);
                    }

                    BuiltNetwork.BitsBorrowed = BitsToBorrow;
                    BuiltNetwork.Class = InetClass;
                    BuiltNetwork.NetMask = NetMask;
                    BuiltNetwork.NumberOfSubnets = IntPow(2, BitsToBorrow);
                    BuiltNetwork.AddressSpace = (IntPow(2, AddressSpaceBits) * BuiltNetwork.NumberOfSubnets);
                    BuiltNetwork.UsableHosts = IntPow(2, AddressSpaceBits) - 2;

                    break;
                default:
                    break;
            }
        }
예제 #2
0
        public NetworkBuilder(NetworkInfo Info)
        {
            //// Get the nessecary data to build the subnetting information

            //int NumberOfHostsNeeded = Info.NumberOfHosts;

            //// The nessecary address class for the number of subnets and the required hosts per subnet
            //AddressClass InetClass = DetermineNessecaryAddressClass(NumberOfHostsNeeded);

            //// Uses 2^x to determine how many bits need to be borrowed
            //int BitsToBorrow = DetermineBitsToBorrow(NumberOfHostsNeeded, InetClass);

            //int BitsForAddressSpace = DetermineBitsForAddressSpace(BitsToBorrow, InetClass);

            //int RequiredSubnets = DetermineNumberOfSubnets(BitsToBorrow, InetClass);

            int BitsToBorrow = DetermineBitsToBorrow(Info.RequiredSubnets);

            AddressClass InetClass = DetermineNessecaryAddressClass(Info.NumberOfHosts);

            int AddressSpaceBits = DetermineBitsForAddressSpace(BitsToBorrow, InetClass);

            int RequiredSubnets = IntPow(2, BitsToBorrow);

            // Gets the subnet mask using data resources basedo n the required bits to borrow
            SubnetMask NetMask       = GetSubnetAddress(InetClass, BitsToBorrow, AddressSpaceBits);
            IpAddress  SampleAddress = new IpAddress(Info.SampleAddress);


            // The program has different functionallity based on different address class
            // For Class C it will be able to build the entire subnet out
            // For the other classes it will display generic subnetting information but not build a subnet
            switch (InetClass)
            {
            case AddressClass.A:
                BuiltNetwork = new FullNetwork();
                // Gather network information for Class A
                //ClassAandBBuilder ClassABuilder = new ClassAandBBuilder();
                //ClassABuilder.NetMask = NetMask;
                //ClassABuilder.HostsPerSubnet = IntPow(2, (AddressSpaceBits - 2) );
                //ClassABuilder.NumberOfSubents = IntPow(2, BitsToBorrow);
                //BuiltNetwork.ClassAorBBuilder = ClassABuilder;
                BuiltNetwork = new FullNetwork();
                BuiltNetwork.BitsBorrowed    = BitsToBorrow;
                BuiltNetwork.Class           = InetClass;
                BuiltNetwork.NetMask         = NetMask;
                BuiltNetwork.NumberOfSubnets = IntPow(2, BitsToBorrow);
                BuiltNetwork.AddressSpace    = IntPow(2, AddressSpaceBits);
                BuiltNetwork.UsableHosts     = IntPow(2, AddressSpaceBits) - 2;
                break;

            case AddressClass.B:
                //BuiltNetwork = new FullNetwork();
                //ClassAandBBuilder ClassBBuilder = new ClassAandBBuilder();
                //ClassBBuilder.NetMask = NetMask;
                //ClassBBuilder.HostsPerSubnet = IntPow(2, AddressSpaceBits);
                //ClassBBuilder.NumberOfSubents = IntPow(2, BitsToBorrow);
                //BuiltNetwork.ClassAorBBuilder = ClassBBuilder;
                BuiltNetwork = new FullNetwork();
                BuiltNetwork.BitsBorrowed    = BitsToBorrow;
                BuiltNetwork.Class           = InetClass;
                BuiltNetwork.NetMask         = NetMask;
                BuiltNetwork.NumberOfSubnets = IntPow(2, BitsToBorrow);
                BuiltNetwork.AddressSpace    = IntPow(2, AddressSpaceBits);
                BuiltNetwork.UsableHosts     = IntPow(2, AddressSpaceBits) - 2;
                break;

            case AddressClass.C:
                // Gather network information for Class C
                int SubnetCount = 0;
                BuiltNetwork = new FullNetwork();
                // Begin the subnet building process
                ClassCSubnetBuilder ClassCBuilder = new ClassCSubnetBuilder(NetMask, SampleAddress);
                // Subtraction by one because it is a based of zero
                while (SubnetCount < RequiredSubnets)
                {
                    SubnetCount += 1;
                    Subnetwork Subnet = ClassCBuilder.NextSubnet();
                    BuiltNetwork.Subnets.Enqueue(Subnet);
                }

                BuiltNetwork.BitsBorrowed    = BitsToBorrow;
                BuiltNetwork.Class           = InetClass;
                BuiltNetwork.NetMask         = NetMask;
                BuiltNetwork.NumberOfSubnets = IntPow(2, BitsToBorrow);
                BuiltNetwork.AddressSpace    = (IntPow(2, AddressSpaceBits) * BuiltNetwork.NumberOfSubnets);
                BuiltNetwork.UsableHosts     = IntPow(2, AddressSpaceBits) - 2;

                break;

            default:
                break;
            }
        }