The Student Room Group

how do you figure out bits needed for host, bits left for network, available hosts

i need to design a ipv4 addressing scheme where each subnet accommodates 2259 hosts. the only thing i have atm is class b address of 145.14.0.0
Firstly, make sure that you're confident with conversions between decimal/binary - there's a neat browser game to help with this https://studio.code.org/projects/applab/iukLbcDnzqgoxuu810unLw

Secondly, remember that computers use binary (base-2) to represent numbers. IP addresses are represented in 'decimal' as 4 sets of integers, each in the range 0..255 because 0.255 is the maximum possible range of numbers which can be stored in 8 bits.
(List of powers of 2 - https://en.wikipedia.org/wiki/Power_of_two )


8 bits is sometimes known as an "octet". So another way to think of an "IP Address" is that it's just 4 octets. (or, 32 bits)

For example - look at these IP addresses compared with their binary representations;
11000000.10100000.00000000.00000001 = 192.168.0.1
11111111.11111111.11111111.11111111 = 255.255.255.255


Given that an IP address has 32-bits, If you need a subnet mask which can accomodate 2259 hosts, then you need to figure out which power of 2 will have that many addresses, then subtract it from 32 to get the number of bits.

For example, a subnet mask for 256 IP addresses is going to need 32-8=24 bits because 256=2^8, so a /24 subnet mask would look like this:

11111111.11111111.11111111.0000000 = 255.255.255.0


A subnet mask for 512 IP addresses is going to need 32-9=23 bits because 512=2^9, so a /23 subnet mask would look like:
11111111.11111111.11111110.0000000 = 255.255.254.0


A subnet mask for 1024 IP addresses is going to need 32-10=22 bits because 1024=2^10, so a /22 subnet mask would look like:
11111111.11111111.11111100.0000000 = 255.255.252.0


etc.
(edited 4 years ago)
Reply 2
so how do i identify the addresses for the first 10 subnets and each accommodates the 2259 hosts?
Original post by geekz2
so how do i identify the addresses for the first 10 subnets and each accommodates the 2259 hosts?

Firstly you need the subnet mask which can subnet that many hosts - you can figure that out just by choosing the smallest power of 2 which fits 2259.

Then you need to use that subnet mask to divide up the Class B IP address you've been given (i.e. 145.14.0.0/16 ) - a class B address without subnetting would use a mask of 255.255.0.0, which means it has a range of 2^16=65,536 IP addresses.

So in binary it would look like this:
10010001.00001110.00000000.00000000
145 . 14 . 0 . 0

11111111.11111111.00000000.00000000
255 . 255 . 0 . 0

i.e. for the non-subnetted Class B IP range of 145.14.0.0/16:

The IP address range is 145.14.0.0/16

The first usable IP address in that range is 145.14.0.1 (because 145.14.0.0 is the subnet identity, so it's not usable - https://superuser.com/questions/1111437/why-cant-i-use-the-first-or-last-address-in-a-subnet )

The last usable IP address in that range is 145.14.255.254 (because 145.14.255.255 is the broadcast address)



So if you used a subnet mask of /17 (i.e. 255.255.128.0) instead of /16, you could have 2 ranges - i.e. subnetting like this
10010001.00001110.00000000.00000000 = 145.14.0.0 - network identity
11111111.11111111.10000000.00000000 = 255.255.128.0 - /17 Subnet Mask

Note the /17 subnet mask has 17 bits flipped to "1", meaning that a bitwise "AND" operation with the Network identity gives you the different combinations.

i.e. with 145.14.0.0/17, you can have two different network identities, using the first bit of the third octet:
11111111.11111111.10000000.00000000 = 255.255.128.0 - /17 Subnet Mask
10010001.00001110.00000000.00000000 = 145.14.0.0 - First network
10010001.00001110.10000000.00000000 = 145.14.128.0 - Second network


Note the difference between the first network identity and the second identity -- the only difference is that the first network has a "0" for the 17th bit and the second network has a "1" in the 17th bit. (the 17th bit is the first bit of the 3rd octet, so the two networks are 145.14.0.0/17 and 145.14.128.0/17.

Each of which each have 32,766 available (usable) addresses - i.e:

Range 1:
10010001.00001110.00000000.00000000 = 145.14.0.0 -- Network Identity
11111111.11111111.10000000.00000000 = 255.255.128.0 -- Subnet Mask
10010001.00001110.00000000.00000001 = 145.14.0.1 -- First usable address
10010001.00001110.01111111.11111110 = 145.14.127.254 -- Last usable address
10010001.00001110.01111111.11111111 = 145.14.127.255 -- Broadcast address

Network identity: 145.14.0.0/17

First usable address: 145.14.0.1

Last usable address: 145.14.127.254

Broadcast address: 145.14.127.255


Range 2:
10010001.00001110.10000000.00000000 = 145.14.128.0 -- Network Identity
11111111.11111111.10000000.00000000 = 255.255.128.0 -- Subnet Mask
10010001.00001110.10000000.00000001 = 145.14.128.1 -- First usable address
10010001.00001110.11111111.11111110 = 145.14.255.254 -- Last usable address
10010001.00001110.11111111.11111111 = 145.14.255.255 -- Broadcast address

Network identity: 145.14.128.0/17

First usable address: 145.14.128.1

Last usable address: 145.14.255.254

Broadcast address: 145.14.255.255

(edited 4 years ago)

Quick Reply

Latest

Trending

Trending