# ip – How do you calculate the prefix, community, subnet, and host numbers?

## IPv4 Math

With an IPv4 handle and the community masks, the community masks size, or host masks, you possibly can calculate the Community Tackle, Broadcast Tackle, Whole Addresses, Usable Addresses, First Usable Tackle, and Final Usable Tackle.

It can’t be confused sufficient that you just should do IPv4 math in binary. Each community engineer has tried to determine a approach to do all of it in decimal, as you’ll*. The issue is that `10` (decimal) just isn’t an influence of `2` (binary), so decimal and binary don’t simply convert between one another the best way that hexadecimal (base `16`) simply converts to and from binary as a result of `16` is an influence of `2`. Utilizing dotted-decimal notation for IPv4 was an early mistake that can’t now be corrected, however IPv6 adopted using hexadecimal from the very starting, and it’s straightforward to transform between hexadecimal and binary.

Should you wouldn’t have an IP calculator (disallowed in exams for community programs or certifications), make a chart of the values of the bits in an octet. In binary, every bit worth is `2` instances the identical digit worth within the subsequent less-significant digit. Every digit is the quantity base instances the identical digit worth within the subsequent less-significant digit. That is additionally true for all quantity bases, together with decimal, the place every digit worth is `10` instances the worth of the identical digit worth within the subsequent less-significant digit. The place decimal is powers of `10`, binary is powers of `2`. Discover that for every bit quantity within the desk, the corresponding worth is `2` to the ability of the bit quantity.

``````+-------------------------------------------------------+
¦ BIT # ¦  7  ¦  6  ¦  5  ¦  4  ¦  3  ¦  2  ¦  1  ¦  0  ¦
¦-------+-----+-----+-----+-----+-----+-----+-----+-----¦
¦ VALUE ¦ 128 ¦ 64  ¦ 32  ¦ 16  ¦  8  ¦  4  ¦  2  ¦  1  ¦
+-------------------------------------------------------+
``````

The dotted-decimal handle `198.51.100.223`

``````+------------------------------------------------------------------------+
¦ OCTET ¦ DEC ¦ 128 ¦ 64  ¦ 32  ¦ 16  ¦  8  ¦  4  ¦  2  ¦  1  ¦  BINARY  ¦
¦-------+-----+-----+-----+-----+-----+-----+-----+-----+-----+----------¦
¦   1   ¦ 198 ¦  1  ¦  1  ¦  0  ¦  0  ¦  0  ¦  1  ¦  1  ¦  0  ¦ 11000110 ¦
¦   2   ¦  51 ¦  0  ¦  0  ¦  1  ¦  1  ¦  0  ¦  0  ¦  1  ¦  1  ¦ 00110011 ¦
¦   3   ¦ 100 ¦  0  ¦  1  ¦  1  ¦  0  ¦  0  ¦  1  ¦  0  ¦  0  ¦ 01100100 ¦
¦   4   ¦ 223 ¦  1  ¦  1  ¦  0  ¦  1  ¦  1  ¦  1  ¦  1  ¦  1  ¦ 11011111 ¦
+------------------------------------------------------------------------+
``````

The binary handle `11000110001100110110010011011111`

``````+------------------------------------------------------------------------+
¦ OCTET ¦  BINARY  ¦   7 ¦   6 ¦   5 ¦   4 ¦   3 ¦   2 ¦   1 ¦   0 ¦ DEC ¦
¦-------+----------+-----+-----+-----+-----+-----+-----+-----+-----+-----¦
¦   1   ¦ 11000110 ¦ 128 ¦  64 ¦   0 ¦   0 ¦   0 ¦   4 ¦   2 ¦   0 ¦ 198 ¦
¦   2   ¦ 00110011 ¦   0 ¦   0 ¦  32 ¦  16 ¦   0 ¦   0 ¦   2 ¦   1 ¦  51 ¦
¦   3   ¦ 01100100 ¦   0 ¦  64 ¦  32 ¦   0 ¦   0 ¦   4 ¦   0 ¦   0 ¦ 100 ¦
¦   4   ¦ 11011111 ¦ 128 ¦  64 ¦   0 ¦  16 ¦   8 ¦   4 ¦   2 ¦   1 ¦ 223 ¦
+------------------------------------------------------------------------+
``````

Keep in mind the Fact Tables from faculty (in binary math, `0` is False, and `1` is True).

``````                      +--------+                +--------+
¦ RESULT ¦                ¦ RESULT ¦
+---------------------+--------¦  +-------------+--------¦
¦ False ¦ AND ¦ False ¦ FALSE  ¦  ¦ 0 ¦ AND ¦ 0 ¦ 0      ¦
¦ False ¦ AND ¦ True  ¦ FALSE  ¦  ¦ 0 ¦ AND ¦ 1 ¦ 0      ¦
¦ True  ¦ AND ¦ False ¦ FALSE  ¦  ¦ 1 ¦ AND ¦ 0 ¦ 0      ¦
¦ True  ¦ AND ¦ True  ¦ TRUE   ¦  ¦ 1 ¦ AND ¦ 1 ¦ 1      ¦
+------------------------------+  +----------------------+

+--------+                +--------+
¦ RESULT ¦                ¦ RESULT ¦
+---------------------+--------¦  +-------------+--------¦
¦ False ¦ OR  ¦ False ¦ FALSE  ¦  ¦ 0 ¦ OR  ¦ 0 ¦ 0      ¦
¦ False ¦ OR  ¦ True  ¦ TRUE   ¦  ¦ 0 ¦ OR  ¦ 1 ¦ 1      ¦
¦ True  ¦ OR  ¦ False ¦ TRUE   ¦  ¦ 1 ¦ OR  ¦ 0 ¦ 1      ¦
¦ True  ¦ OR  ¦ True  ¦ TRUE   ¦  ¦ 1 ¦ OR  ¦ 1 ¦ 1      ¦
+------------------------------+  +----------------------+

+--------+                +--------+
¦ RESULT ¦                ¦ RESULT ¦
+-------------+--------¦      +---------+--------¦
¦ NOT ¦ False ¦ TRUE   ¦      ¦ NOT ¦ 0 ¦ 1      ¦
¦ NOT ¦ True  ¦ FALSE  ¦      ¦ NOT ¦ 1 ¦ 0      ¦
+----------------------+      +------------------+
``````

*Should you carry out IPv4 math for a few years, it’s possible you’ll get to the purpose the place you possibly can carry out decimal/binary conversions in your head, and you may seem to have the ability to do IPv4 math in decimal. Even when you are able to do this in your head, all the time double-check with an IP calculator, or convert to binary and carry out the mathematics, earlier than committing a change to a manufacturing community.

## IPv4 Tackle

The IPv4 dotted-decimal notation, e.g., `198.51.100.223`, is solely to make it simpler for people to learn an handle. The 4 separate sections, referred to as octets, actually don’t have any that means to IPv4. Don’t make the widespread mistake of considering the octets have a particular that means. An handle is known as a 32-bit binary quantity, and that’s how community units see and use an IPv4 handle.

The instance dotted-decimal handle, `198.51.100.223`, is binary `11000110001100110110010011011111` to a tool on the community. You may see that the dotted-decimal illustration actually does make it simpler for people. Every octet is eight bits of the 32-bit handle (therefore the generally used time period, “octet”), so there are 4 octets (`32 handle bits / 8 bits per octet = 4 octets`). The instance 32-bit binary handle is separated into 4 octets, then every binary octet is transformed to a decimal quantity*.

Binary handle: `11000110001100110110010011011111`

``````+-----------------------------------------------------+
¦ OCTET   ¦        1 ¦        2 ¦        3 ¦        4 ¦
¦---------+----------+----------+----------+----------¦
¦ BINARY  ¦ 11000110 ¦ 00110011 ¦ 01100100 ¦ 11011111 ¦
¦ DECIMAL ¦      198 ¦       51 ¦      100 ¦      223 ¦
+-----------------------------------------------------+
``````

As a result of every octet is eight bits in size, every octet could have a price between `0` and `255` (any values higher than `255` are invalid). The reason being that `2``8`` = 256`: `2` (the binary quantity base) to the ability of `8` (eight bits per octet) equals `256`, the variety of totally different values that may be expressed by an eight-bit octet. Keep in mind that the primary worth is `0`, so the 256th worth will probably be one much less that the whole variety of values that may be expressed (`256 – 1 = 255`).

To accurately carry out IPv4 math, you should do it in binary, in any other case you will make errors that may trigger you issues and frustration. That implies that it’s essential to convert the dotted-decimal notation to binary earlier than attempting to govern it.

Dotted-decimal: `198.51.100.223`

``````+-----------------------------------------------------+
¦ OCTET   ¦        1 ¦        2 ¦        3 ¦        4 ¦
¦---------+----------+----------+----------+----------¦
¦ DECIMAL ¦      198 ¦       51 ¦      100 ¦      223 ¦
¦ BINARY  ¦ 11000110 ¦ 00110011 ¦ 01100100 ¦ 11011111 ¦
+-----------------------------------------------------+
``````

*Main zeroes in a dotted-decimal IPv4 handle could also be interpreted by some functions and programming languages as octal (base `8`) fairly than decimal (base `10`), inflicting errors, and main zeros needs to be prevented for the dotted-decimal IPv4 illustration, however main zeroes are essential for the binary handle octets as a result of they symbolize bit positions within the full handle, and leaving out a bit place will shorten the handle and alter the binary worth.

A community masks is used to divide an handle into two components: Community and Host. As a result of IPv4 addresses are fastened 32-bits in size, a bigger Community means a smaller Host, and vice versa. The division might be at any bit quantity, so it might fall inside an octet, not on an octet boundary (as many individuals incorrectly assume it all the time does). A community masks is identical measurement as an handle (`32` bits), and it’s expressed in dotted-decimal notation the identical means you’ll categorical an handle in dotted-decimal notation (4 8-bit octets, separated by a interval). For instance, `255.255.248.0`.

A community masks consists of consecutive `1` bits (representing the Community), adopted by the variety of `0` bits (representing the Host) to complete `32` bits (the handle size). The variety of `1` bits plus the variety of `0` bits totals `32`, the variety of bits in an IPv4 handle or community masks. For instance, a community masks of `255.255.248.0`.

``````+--------------------------------------------------------+
¦ OCTET   ¦        1 ¦        2 ¦           3 ¦        4 ¦
¦---------+----------+----------+-------------+----------¦
¦ DECIMAL ¦      255 ¦      255 ¦         248 ¦        0 ¦
¦---------+----------+----------+-------------+----------¦
¦ BINARY  ¦ 11111111 ¦ 11111111 ¦ 11111 ¦ 000 ¦ 00000000 ¦
¦---------+-----------------------------+----------------¦
¦ # BITS  ¦         21 Community          ¦    11 Host     ¦
+--------------------------------------------------------+
``````

As you possibly can see, the division between Community and Host of the handle utilizing this masks falls inside an octet, not on an octet boundary.

A community masks is usually represented by the variety of consecutive `1` bits within the masks. That is variously referred to as the community masks size or prefix size, and it’s represented as a `/` adopted by the variety of consecutive `1` bits within the community masks. Counting the variety of consecutive `1` bits within the instance totals `21`, which might be represented as `/21`.

Given a masks size, you possibly can calculate the dotted-decimal illustration of the masks. Merely put down the variety of `1` bits for the masks size and add sufficient `0` bits on the top to complete `32` bits. Convert the ensuing binary quantity into the dotted-decimal illustration.

``````+--------------------------------------------------------+
¦ # BITS  ¦         21 Community          ¦    11 Host     ¦
¦---------+-----------------------------+----------------¦
¦ BINARY  ¦ 11111111 ¦ 11111111 ¦ 11111 ¦ 000 ¦ 00000000 ¦
¦---------+----------+----------+-------------+----------¦
¦ DECIMAL ¦      255 ¦      255 ¦         248 ¦        0 ¦
¦---------+----------+----------+-------------+----------¦
¦ OCTET   ¦        1 ¦        2 ¦           3 ¦        4 ¦
+--------------------------------------------------------+
``````

The instance `198.51.100.223` handle could also be represented historically with the instance community masks as `198.51.100.223` `255.255.248.0`, or it might be represented within the extra fashionable CIDR (Classless Inter-Area Routing) notation as `198.51.100.223/21`. Both illustration is legitimate, and you may simply convert between the masks and the masks size as required (OSes and functions would require a selected illustration).

## IPv4 Community Tackle

A community handle is an handle with all Host bits set to `0`. The community handle might be calculated by a bitwise `AND` of the respective bits within the binary illustration of the handle and the community masks. Align the bits, carry out a bitwise `AND` on every pair of the respective bits, then convert the person octets of the consequence again to decimal.

For instance, the IPv4 handle `198.51.100.223` and community masks `255.255.248.0`

``````+-------------------------------------------------------------+
¦ OCTET           ¦        1 ¦        2 ¦        3 ¦        4 ¦
¦-----------------+----------+----------+----------+----------¦
¦ BINARY ADDRESS  ¦ 11000110 ¦ 00110011 ¦ 01100100 ¦ 11011111 ¦
¦ BINARY MASK     ¦ 11111111 ¦ 11111111 ¦ 11111000 ¦ 00000000 ¦
¦ BITWISE AND     ¦ 11000110 ¦ 00110011 ¦ 01100000 ¦ 00000000 ¦
¦-----------------+----------+----------+----------+----------¦
¦ DECIMAL NETWORK ¦      198 ¦       51 ¦       96 ¦        0 ¦
+-------------------------------------------------------------+
``````

The community handle of `198.51.100.223/21` is `198.51.96.0`. Discover that you just can not rely upon the octets to differentiate between Community and Host.

This methodology is used to find out if two addresses are on the identical or totally different networks*. For instance, if you wish to decide in case your instance handle is on the identical community with a goal handle, `198.51.102.57`, discover the instance community handle (as above). Subsequent, discover the goal community handle utilizing the identical community masks (addresses on the identical community use the identical community masks, and it’s possible you’ll not have the goal masks, solely the goal handle).

``````+-------------------------------------------------------------+
¦ OCTET           ¦        1 ¦        2 ¦        3 ¦        4 ¦
¦-----------------+----------+----------+----------+----------¦
¦ BINARY ADDRESS  ¦ 11000110 ¦ 00110011 ¦ 01100110 ¦ 00111001 ¦
¦ BINARY MASK     ¦ 11111111 ¦ 11111111 ¦ 11111000 ¦ 00000000 ¦
¦ BITWISE AND     ¦ 11000110 ¦ 00110011 ¦ 01100000 ¦ 00000000 ¦
¦-----------------+----------+----------+----------+----------¦
¦ DECIMAL NETWORK ¦      198 ¦       51 ¦       96 ¦        0 ¦
+-------------------------------------------------------------+
``````

Evaluate the goal community handle to the instance community handle, and spot that the community addresses are equal, that means the instance and goal addresses are on the identical community.

Now, take a look at if the instance handle is on the identical community because the `74.125.69.100` Google handle.

``````+-------------------------------------------------------------+
¦ OCTET           ¦        1 ¦        2 ¦        3 ¦        4 ¦
¦-----------------+----------+----------+----------+----------¦
¦ BINARY ADDRESS  ¦ 01001010 ¦ 01111101 ¦ 01000101 ¦ 01100100 ¦
¦ BINARY MASK     ¦ 11111111 ¦ 11111111 ¦ 11111000 ¦ 00000000 ¦
¦ BITWISE AND     ¦ 01001010 ¦ 01111101 ¦ 01000000 ¦ 00000000 ¦
¦-----------------+----------+----------+----------+----------¦
¦ DECIMAL NETWORK ¦       74 ¦      125 ¦       64 ¦        0 ¦
+-------------------------------------------------------------+
``````

Evaluate the goal community handle to the instance community handle, and spot that the community addresses are totally different, that means the instance and goal addresses usually are not on the identical community.

*That is the strategy a supply makes use of to find out if a vacation spot is on the identical community because the supply. Packets destined to a unique community should be despatched to a router for forwarding to a unique community.

One helpful, typically neglected, worth for IPv4 addressing is the host masks. A bunch masks is solely the inverse (bitwise `NOT`) of the community masks.

``````+-----------------------------------------------------------------+
¦ OCTET #             ¦        1 ¦        2 ¦        3 ¦        4 ¦
¦---------------------+----------+----------+----------+----------¦
¦ BINARY NETWORK MASK ¦ 11111111 ¦ 11111111 ¦ 11111000 ¦ 00000000 ¦
¦ BITWISE NOT         ¦ 00000000 ¦ 00000000 ¦ 00000111 ¦ 11111111 ¦
¦---------------------+----------+----------+----------+----------¦
¦ HOST MASK           ¦        0 ¦        0 ¦        7 ¦      255 ¦
+-----------------------------------------------------------------+
``````

``````+--------------------------------------------------------------+
¦ OCTET #          ¦        1 ¦        2 ¦        3 ¦        4 ¦
¦------------------+----------+----------+----------+----------¦
¦ BINARY HOST MASK ¦ 00000000 ¦ 00000000 ¦ 00000111 ¦ 11111111 ¦
¦ BITWISE NOT      ¦ 11111111 ¦ 11111111 ¦ 11111000 ¦ 00000000 ¦
¦------------------+----------+----------+----------+----------¦
¦ NETWORK MASK     ¦      255 ¦      255 ¦      248 ¦        0 ¦
+--------------------------------------------------------------+
``````

It’s potential to make use of subtraction to create a bunch masks from the community masks, or the community masks from the host masks by subtracting the beginning masks from the longest masks (`/32` all-ones masks `255.255.255.255`).

``````+-----------------------------------------------------------------+
¦ OCTET #             ¦        1 ¦        2 ¦        3 ¦        4 ¦
¦---------------------+----------+----------+----------+----------¦
¦ BINARY /32 MASK     ¦ 11111111 ¦ 11111111 ¦ 11111111 ¦ 11111111 ¦
¦ BINARY NETWORK MASK ¦ 11111111 ¦ 11111111 ¦ 11111000 ¦ 00000000 ¦
¦ SUBTRACTION         ¦ 00000000 ¦ 00000000 ¦ 00000111 ¦ 11111111 ¦
¦---------------------+----------+----------+----------+----------¦
¦ HOST MASK           ¦        0 ¦        0 ¦        7 ¦      255 ¦
+-----------------------------------------------------------------+
``````

``````+--------------------------------------------------------------+
¦ OCTET #          ¦        1 ¦        2 ¦        3 ¦        4 ¦
¦------------------+----------+----------+----------+----------¦
¦ BINARY /32 MASK  ¦ 11111111 ¦ 11111111 ¦ 11111111 ¦ 11111111 ¦
¦ BINARY HOST MASK ¦ 00000000 ¦ 00000000 ¦ 00000111 ¦ 11111111 ¦
¦ SUBTRACTION      ¦ 11111111 ¦ 11111111 ¦ 11111000 ¦ 00000000 ¦
¦------------------+----------+----------+----------+----------¦
¦ NETWORK MASK     ¦      255 ¦      255 ¦      248 ¦        0 ¦
+--------------------------------------------------------------+
``````

``````+------------------------------------------+
¦ OCTET #          ¦   1 ¦   2 ¦   3 ¦   4 ¦
¦------------------+-----+-----+-----+-----¦
¦ DECIMAL /32 MASK ¦ 255 ¦ 255 ¦ 255 ¦ 255 ¦
¦ NETWORK MASK     ¦ 255 ¦ 255 ¦ 248 ¦   0 ¦
¦------------------+-----+-----+-----+-----¦
¦ HOST MASK        ¦   0 ¦   0 ¦   7 ¦ 255 ¦
+------------------------------------------+
``````

``````+------------------------------------------+
¦ OCTET #          ¦   1 ¦   2 ¦   3 ¦   4 ¦
¦------------------+-----+-----+-----+-----¦
¦ DECIMAL /32 MASK ¦ 255 ¦ 255 ¦ 255 ¦ 255 ¦
¦ HOST MASK        ¦   0 ¦   0 ¦   7 ¦ 255 ¦
¦------------------+-----+-----+-----+-----¦
¦ NETWORK MASK     ¦ 255 ¦ 255 ¦ 248 ¦   0 ¦
+------------------------------------------+
``````

A community broadcast handle is the community handle with all of the host bits set to `1`. There are a number of methods to calculate the community broadcast handle.

For instance, handle `198.51.100.223` and community masks `255.255.248.0`.

You may carry out a bitwise `OR` with the handle or community handle with the host masks.

``````+---------------------------------------------------------------+
¦ OCTET             ¦        1 ¦        2 ¦        3 ¦        4 ¦
¦-------------------+----------+----------+----------+----------¦
¦ BINARY ADDRESS    ¦ 11000110 ¦ 00110011 ¦ 01100100 ¦ 11011111 ¦
¦ BINARY HOST MASK  ¦ 00000000 ¦ 00000000 ¦ 00000111 ¦ 11111111 ¦
¦ BITWISE OR        ¦ 11000110 ¦ 00110011 ¦ 01100111 ¦ 11111111 ¦
¦-------------------+----------+----------+----------+----------¦
¦ BROADCAST ADDRESS ¦      198 ¦       51 ¦      103 ¦      255 ¦
+---------------------------------------------------------------+
``````

You may merely add the worth of the host masks to the worth of the community handle (not the host handle) and you are able to do this both in decimal or binary.

Decimal

``````+-------------------------------------------+
¦ OCTET #           ¦   1 ¦   2 ¦   3 ¦   4 ¦
¦-------------------+-----+-----+-----+-----¦
¦ DECIMAL NETWORK   ¦ 198 ¦  51 ¦  96 ¦   0 ¦
¦ DECIMAL HOST MASK ¦   0 ¦   0 ¦   7 ¦ 255 ¦
¦-------------------+-----+-----+-----+-----¦
¦ BROADCAST ADDRESS ¦ 198 ¦  51 ¦ 103 ¦ 255 ¦
+-------------------------------------------+
``````

Binary

``````+--------------------------------------------------------------+
¦ OCTET #          ¦        1 ¦        2 ¦        3 ¦        4 ¦
¦------------------+----------+----------+----------+----------¦
¦ BINARY NETWORK   ¦ 11000110 ¦ 00110011 ¦ 01100000 ¦ 00000000 ¦
¦ BINARY HOST MASK ¦ 00000000 ¦ 00000000 ¦ 00000111 ¦ 11111111 ¦
¦ ADDITION         ¦ 11000110 ¦ 00110011 ¦ 01100111 ¦ 11111111 ¦
¦------------------+----------+----------+----------+----------¦
¦ NETWORK MASK     ¦      198 ¦       51 ¦      103 ¦      255 ¦
+--------------------------------------------------------------+
``````

## Whole IPv4 Community Host Addresses

The whole variety of host addresses for a community is `2` to the ability of the variety of host bits, which is `32` (IPv4 handle bits) minus the variety of community bits. For instance, for a `/21` (community masks `255.255.248.0`) community, there are `11` host bits (`32 handle bits – 21 community bits = 11 host bits`). Which means there are `2048` complete host addresses in a `/21` community (`2``11`` = 2048`).

## Whole Usable IPv4 Community Host Addresses

Apart from `/31` (`255.255.255.254`) and `/32` (`255.255.255.255`) networks, the variety of usable host addresses in a community is the whole variety of community host addresses minus `2` (as a result of the community and broadcast addresses are unusable for host addresses on the community, it’s essential to subtract them from the variety of usable host addresses). For instance, in a `/21` (`255.255.248.0`) community, there are `2046` usable host addresses (`2``11`` - 2 = 2046`).

## First Usable IPv4 Community Host Tackle

Apart from `/31` (`255.255.255.254`) and `/32` (`255.255.255.255`) networks, the primary usable community host handle is the community handle plus (both addition or bitwise `OR`) `1` (the community handle just isn’t usable for a community host handle). For instance, within the `198.51.96.0/21` community, the primary usable community host handle is `198.51.96.1` (`198.51.96.0 + 1 = 198.51.96.1` or `198.51.96.0 OR 1 = 198.51.96.1`). Set the low-order little bit of the binary community handle to `1`.

``````+------------------------------------------------------------------+
¦ OCTET                ¦        1 ¦        2 ¦        3 ¦        4 ¦
¦----------------------+----------+----------+----------+----------¦
¦ BINARY NETWORK       ¦ 11000110 ¦ 00110011 ¦ 01100000 ¦ 00000000 ¦
¦ 1                    ¦ 00000000 ¦ 00000000 ¦ 00000000 ¦ 00000001 ¦
¦ ADD (OR)             ¦ 11000110 ¦ 00110011 ¦ 01100000 ¦ 00000001 ¦
¦----------------------+----------+----------+----------+----------¦
¦ FIRST USABLE ADDRESS ¦      198 ¦       51 ¦       96 ¦        1 ¦
+------------------------------------------------------------------+
``````

## Final Usable IPv4 Community Host Tackle

Apart from `/31` (`255.255.255.254`) and `/32` (`255.255.255.255`) networks, the final usable community host handle is the community broadcast handle minus `1` (the community broadcast handle just isn’t usable for a community host handle). For instance, within the `198.61.96.0/21` community, the final usable community host handle is `198.51.103.254` (`198.51.103.255 - 1 = 198.51.103.254`). Set the low-order little bit of the binary IPv4 community broadcast handle to `0`.

``````+----------------------------------------------------------------------+
¦ OCTET                    ¦        1 ¦        2 ¦        3 ¦        4 ¦
¦--------------------------+----------+----------+----------+----------¦
¦ BINARY BROADCAST ADDRESS ¦ 11000110 ¦ 00110011 ¦ 01100111 ¦ 11111111 ¦
¦ 1                        ¦ 00000000 ¦ 00000000 ¦ 00000000 ¦ 00000001 ¦
¦ SUBTRACT                 ¦ 11000110 ¦ 00110011 ¦ 01100111 ¦ 11111110 ¦
¦--------------------------+----------+----------+----------+----------¦
¦ LAST  USABLE ADDRESS     ¦      198 ¦       51 ¦      103 ¦      254 ¦
+----------------------------------------------------------------------+
``````

## IPv4 `/31` (`255.255.255.254`) Networks

Initially, `/31` (`255.255.255.254`) networks have been unusable as a result of there is just one host bit, supplying you with two complete community host addresses, however the variety of usable community host addresses is the whole variety of community host addresses minus `2` (`2 complete host addresses - 2 = 0 usable host addresses`).

Level-to-point hyperlinks solely want two host addresses (one for every finish of the hyperlink). The standard means of assigning IPv4 networks required using `/30` (`255.255.255.252`) networks for point-to-point hyperlinks, however that wastes half the community host addresses as a result of a `/30` community has 4 complete community host addresses, however solely two are usable community host addresses (`2``2`` – 2 = 2`).

With the vital IPv4 handle scarcity, an ordinary was created (RFC 3021, Utilizing 31-Bit Prefixes on IPv4 Level-to-Level Hyperlinks) to permit using `/31` networks for point-to-point hyperlinks. That is smart as a result of there isn’t any want for broadcast on such networks: any packets despatched by a bunch on the community are destined for the one different host on the community, successfully broadcasting. In a `/31` community, the community handle is the primary usable host handle, and the published handle is the final usable host handle.

Sadly, not all distributors (Microsoft specifically) help the usual for utilizing `/31` networks on point-to-point hyperlinks, and you’ll most frequently see point-to-point hyperlinks utilizing `/30` networks.

## IPv4 `/32` (`255.255.255.255`) Networks

A `/32` (`255.255.255.255`) community is each a community with no host addresses, and a bunch handle, itself. There is just one handle within the community, and that’s the community handle. As a result of there aren’t any different hosts are on the community, site visitors should be routed to and from the community handle.

These addresses are sometimes used on digital community interfaces outlined inside a tool that may route packets between its digital and bodily interfaces. An instance of that is to create a digital interface in a community machine for use because the supply or vacation spot for the machine itself. A digital interface can not drop due to a bodily downside, e.g., cable unplugged, and if the machine has a number of paths into it, different units can nonetheless talk with the machine utilizing the digital interface handle when a bodily interface of the machine is inoperable for some purpose.

## Placing IPv4 Community Addressing All Collectively

For instance, the community handle `198.51.100.223` and masks `255.255.248.0` (or `198.51.100.223/21`), we will calculate the community data.*

``````+--------------------------------------------+
¦ HOST ADDRESS              ¦ 198.51.100.223 ¦
¦ NETWORK MASK              ¦  255.255.248.0 ¦
¦ NETWORK MASK LENGTH       ¦             21 ¦
¦ HOST MASK                 ¦      0.0.7.255 ¦
¦ HOST MASK LENGTH          ¦             11 ¦
¦ NETWORK ADDRESS           ¦    198.51.96.0 ¦
¦ FIRST USABLE HOST ADDRESS ¦    198.51.96.1 ¦
¦ LAST USABLE HOST ADDRESS  ¦ 198.51.103.254 ¦
¦ TOTAL HOST ADDRESSES      ¦           2048 ¦
¦ USABLE HOST ADDRESSES     ¦           2046 ¦
+--------------------------------------------+
``````

*Community training class exams and certification checks will ask you to have the ability to rapidly calculate these values, given a bunch handle and masks (or masks size). You need to use the hints under for a fast test of your solutions:

• Community Tackle (trace: an excellent quantity)
• First Usable Host Tackle (trace: Community Tackle plus `1`, an odd quantity)
• Final Usable Host Tackle (trace: Broadcast Tackle minus `1`, an excellent quantity)
• Broadcast Tackle (trace: Community Tackle plus Host Masks, an odd quantity)

The above hints don’t apply to `/31` (`255.255.255.254`) or `/32` (`255.255.255.255`) networks.

Given sufficient time in your examination, and an issue that has a number of strategies to reach at a solution, you must use the a number of strategies to double-check the reply.

Continued in Half 2