Hi,

I am a bit confused, I have been given an address 132.132.0.0/16 and i have to devise a scheme allowing for at least 396 subnets. I think i have to extend the subnet mask to do this, I have worked through the different possible masks and the mask /25 gives me a possible 512 subnets this fits into the criteria i was to use. As there is 9 bits left, to find the number of hosts per subnet mask I use the formula 2^9 = 126 hosts, so the first address for the subnet mask 0 is

Subnet 0 - 132.132.0.1, address range is 132.132.0.1 - 132.132.0.126 and the broadcast is 132.132.0.127

Subnet 1 - 132.132.0.128, address range is 132.132.0.129 - 132.132.0.254 and the broadcast is 132.132.0.255

Subnet 2 - 132.132.1.0, address range is 132.132.1.1 - 132.132.1.126 and the broadcast is 132.132.1.127

How would i work out for the subnet 350 and 396?

Thanks

Sorry i should say its 128 hosts - 2, 1 for broadcast and 1 for id

Right my working out is if i can fit in 2 subnet masks before i reach 255 in the last octet and have to increase the 3rd octet, I would divide 349 (not 350 as we are using subnet 0) by 2 this gives me 174.5 which i believe the subnet 350 id would be 132.132.174.128

I don't understand the nature of these questions -- is this academic? Why are you wanting to create so many subnets? Each subnet (usually) burns up 2 usable IP address for the router and broadcast addresses. There are other ways of isolating network segments aside from subnetting (routing) the traffic. Are you wanting to isolate network groups or just to mathematically figure out a way to have 396+ subnets?

If you want the most subnets use the smallest routable mask (I think 255.255.255.252/30 would be your best bet here). You have 256 addresses per class-C IP block and /30 uses 4 addresses so 256/4=64. Assuming 64 subnets per class C and that you have 256 class-C blocks, 256*64=16,384.

I think that satisfies your original post of having "at least 396 subnets".

You should review CIDR notation:
http://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing

For calculatins this may help:

public static bool BelongsToSubnet(this IPAddress @this, IPAddress subnetAddress, IPAddress subnetMask)
    {
      if (subnetAddress == null) throw new ArgumentNullException("subnetAddress");
      if (subnetMask == null) throw new ArgumentNullException("subnetMask");
      if (@this.AddressFamily != AddressFamily.InterNetwork) throw new NotImplementedException(@this.AddressFamily.ToString());
      if (subnetAddress.AddressFamily != AddressFamily.InterNetwork) throw new NotImplementedException(subnetAddress.AddressFamily.ToString());
      if (subnetMask.AddressFamily != AddressFamily.InterNetwork) throw new NotImplementedException(subnetMask.AddressFamily.ToString());
      uint uMatch = BitConverter.ToUInt32(@this.GetAddressBytes(), 0);
      uint uSubnetAddress = BitConverter.ToUInt32(subnetAddress.GetAddressBytes(), 0);
      uint uSubnetMask = BitConverter.ToUInt32(subnetMask.GetAddressBytes(), 0);
      return ((uSubnetAddress & uSubnetMask) == (uMatch & uSubnetMask));
    }
    public static IPAddress CalculateBroadcastAddress(this IPAddress @this, IPAddress subnetMask)
    {
      if (@this == null) throw new ArgumentNullException("this");
      if (subnetMask == null) throw new ArgumentNullException("subnetMask");
      if (@this.AddressFamily != AddressFamily.InterNetwork) throw new NotImplementedException(@this.AddressFamily.ToString());
      if (subnetMask.AddressFamily != AddressFamily.InterNetwork) throw new NotImplementedException(subnetMask.AddressFamily.ToString());

      uint uAddr = BitConverter.ToUInt32(@this.GetAddressBytes(), 0);
      uint uSubnet = BitConverter.ToUInt32(subnetMask.GetAddressBytes(), 0);
      uint uBroadcast = uAddr | ~uSubnet;
      return new IPAddress(BitConverter.GetBytes(uBroadcast));
    }
    public static bool BelongsToLocalSubnet(this IPAddress @this)
    {
      try
      {
        if (@this.AddressFamily != AddressFamily.InterNetwork)
          throw new NotImplementedException();
        uint match = BitConverter.ToUInt32(@this.GetAddressBytes(), 0);
        UnicastIPAddressInformation[] localBindings = GetLocalIPv4Bindings().ToArray();
        for (int i1 = 0; i1 < localBindings.Length; i1++)
        {
          UnicastIPAddressInformation uni = localBindings[i1];
          if ((uni.Address == null) || (uni.IPv4Mask == null)) continue;
          if (@this.BelongsToSubnet(uni.Address, uni.IPv4Mask))
            return true;
        }
      }
      catch { }
      return false;
    }

yeah its a practise exam question and thank you for your advice

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.