A network subnet mask is needed in a network to tell the computer what part of the network address is network address and what part is host address. Network address is common to all the computers on a network, but host address is unique to each computer. It’s like a street address where every house on a street uses the same street name when addressing mail, but unique house numbers for each house.
Typical class C subnet mask is 32 bits where the first 24 bits are set to ones (or high) and the last 8 bits are set to zeros (or low). The last 8 bits are the host address part and are set to zero so the computer knows that these bits are unique to each computer. Without the subnet mask the computer would not know how to handle the IP address or how to route data.
Routers are the network devices that route data packets from network to network until the data is received by the computer that it was addressed to. The router examines the data packet using the network subnet mask to determine the destination network address. It then makes a decision on which port the send the data. The last router is the gateway router for the destination network where the host portion of the address is used to deliver the packet to the appropriate computer.
A typical network class C IP address might look like 192.168.1.0 in decimal or 1100 1010 0001 0000 in binary. The IP address when represented as a decimal number in divided in four 8-bit blocks separated by a dot. This is a type of shorthand convenience and allows us to easily convert 32 bit binary numbers as decimal 8-bit numbers. This way we only need to know 8 bit binary to decimal conversion. Otherwise a 32-bit number would be very large and cumbersome to convert.
The Computer Network Training website has additional information you might find useful.
