TCP/IP Concepts   «Prev  Next»

Lesson 8Netmask Structure and Usage
ObjectiveWhat is the Structure and use of a netmask?

Netmask Structure and Usage

As mentioned above, the first few bits of an IP address classify the address as
  1. Class A,
  2. Class B, or
  3. Class C.

This information is sufficient to decide what portion of the address refers to the host and which to the network.
However, this division is a convention and is not programmed into the TCP/IP networking software.
The netmask is a number telling the TCP/IP software which portion of the address is host and which is network.
The netmask itself is a 32-bit number with a one bit set in each position of the network address and a zero bit set in each position of the host address. It is usually written in dotted decimal form, like an IP address.
If an address is Class A, B, or C, the netmask is completely standard. For example, a Class A address has eight bits of network address, so the first eight bits of the netmask are 1; it has 24 bits of host, so the next 24 bits are 0. Converted to dotted decimal, this yields The other cases are illustrated in the table below.

Class Netmask

What is the Structure and use of a netmask?

A netmask is used to specify the size of a network in IP networking. It is used in conjunction with an IP address to identify which portion of the address represents the network and which portion represents the host. The structure of a netmask is a string of bits, where the number of set (1) bits represents the size of the network, and the number of unset (0) bits represents the size of the host.
For example, a netmask of is often used for a Class C network, which has 24 bits for the network portion of the IP address and 8 bits for the host portion. This netmask provides up to 256 possible hosts within the network.
Netmasks are used by routers and other network devices to determine which network a packet should be forwarded to, and by hosts to determine which IP addresses belong to the same network. They are also used to determine the subnet mask of a network and to calculate the broadcast address for a network.

More sophisticated netmasks are possible if subnetting is being used, but further discussion of the subject is beyond the scope of this course. The netmask is an important tool for subdividing IP networks and ensuring efficient and correct routing of IP packets.