private void SplitSubnets() { if (Mask == null || Ip == null) { return; } var buffer = new StringBuilder(); int requiredbits = GetBits(NetworkCount); int maskbits = SubnetMask.GetBitLength(Mask); int outmaskbits = requiredbits + maskbits; if (outmaskbits > 32) { buffer.AppendLine("IPv4 is too small for this"); Output = buffer.ToString(); OnPropertyChanged(() => Output); return; } buffer.AppendFormat("Required additional subnet bits for {0} networks: {1}\r\n", NetworkCount, requiredbits); buffer.AppendFormat("New netmask: {0}/{1}\r\n", SubnetMask.CreateByNetBitLength(outmaskbits), outmaskbits); buffer.AppendLine("--------------------------------------------------------------------------------------"); buffer.AppendLine(); uint tmp = Ip.GetUint(); int shift = 32 - outmaskbits; for (uint i = 0; i < NetworkCount; i++) { uint sh = i << shift; uint val = tmp + sh; var addr = new IPAddress(0); addr = addr.SetUint(val); buffer.AppendFormat("Subnet {0,-4} Network adress: {1,-15} Broadcast Adress: {2,-15}\r\n", i, addr, addr.GetBroadcastAddress(SubnetMask.CreateByNetBitLength(outmaskbits))); } Output = buffer.ToString(); OnPropertyChanged(() => Output); }