Search code examples
network-programmingipipv4subnet

Network mask unlogical response


I'm quite new a network learning, and when I was connected to a public network I was trying to play with the stuff that I learned. So under mac OS X I tried the ifconfig command, and I looked closer to the eth0 response which returned at some point something like this "netmask 0xfffff000 broadcast 172.20.159.255".

My question is : if the mask is 0xfffff000 why the broadcast adress is not 172.20.15.255. Since the broadcast adress should be the one with only 1 in the part that is not associated to the mask (it should be 172.20.15.255). Furthermore if we calculate the total number of adresses in our network according to the mask we get 16*16*16 which is 4096 but if we look at the broadcast adress returned we get 160*256 = 40 960 which is ten time more.

Thank you in advance for the ones who can help me. Sorry if my english is not perfect I'm not a native english.


Solution

  • I just found my mistake after writing down the bits. The answer you be 172.20.(15).255 if the bits in parenthesis are (00001111), but the part with the 0 can change and this is why our broadcast adress is the the one I expected to be is is in fact (1001|1111) which is 159 OK!