Remember, IPv4 is not the only layer-3 protocol. Traffic on a LAN is delivered by a layer-2 protocol, so layer-2 protocols need a broadcast address to be able to deliver a broadcast to all hosts on a LAN. Layer-2 protocols can carry any number of layer-3 protocols.
An IPv4 host will drop layer-3 traffic delivered to it that is not destined to its IPv4 address, a subscribed IPv4 multicast address, or an IPv4 broadcast address, even if it is delivered via a layer-2 broadcast frame.
IPv4 has two different broadcasts: the limited broadcast (255.255.255.255
), and the network broadcast (highest IPv4 address in the network). The limited broadcast cannot leave the network on which it originated. The network broadcast used to be enabled on network equipment, e.g. routers, by default, but it is now disabled by default. It allows traffic from one network to be sent to a different network's broadcast address, in order to broadcast to all IPv4 hosts on the other network.
IPv6 has done away with broadcast altogether. You must use multicast.
For your example of 172.16.0.0/16
, the 172.16.0.0
is both the IPv4 network address and a host address, but not a usable host address. It could be the network address, and it may be a usable host address with a different mask length (for example, it is a usable host address with a /11
or shorter mask length). It could even be both a network address and a usable host address if the mask length is /31
. The /16
tells you the length of the mask (number of consecutive 1
bits), and I call it the mask length (can be called the prefix length, depending on the context).
An IPv4 address is a 32-bit unsigned integer (a binary cardinal number from 00000000000000000000000000000000
to 11111111111111111111111111111111
, or 0
to 4294967295
in decimal). Don't read anything into the fact that it is expressed as four decimal octets; that is simply to make it easier for humans to read; network devices deal with the binary number, not the text representation.
A network mask for IPv4 is also a 32-bit unsigned integer, but it consists of consecutive bits set to 1
, followed by any other bits set to 0
. The mask determines which part of the IP address is the network, and which part is the host number in the network.
If you do a bitwise AND
of the IP address and the mask, you will get the network address. You need to do IP math in binary; trying to use decimal will lead to stupid errors.
IPv4 address 172.16.0.0 -> 10101100000100000000000000000000
Mask length 16 -> 11111111111111110000000000000000
Bitwise AND -> ================================
IPv4 network address -> 10101100000100000000000000000000
If you have an address and mask, you have everything you need to calculate everything about the IPv4 address. See the question, How do you calculate the prefix, network, subnet, and host numbers? for how to do IP math.
IPv6 addressing works the same way, except that IPv6 addresses are 128 bits instead of the IPv4 32 bits, and all IPv6 addresses in a network are usable host addresses because IPv6 does not have broadcast.
Best Answer
A
/31
network actually has two usable hosts for a point-to-point link. See the Standards Track RFC 3021, Using 31-Bit Prefixes on IPv4 Point-to-Point Links (published in December 2000):-and-
Understand that not every vendor (Microsoft in particular) supports the standard, although many vendors, e.g. Cisco, fully support the standard.