How is the IP prefix passed to the router

ipv4prefix

First some background information on what I already know:

An IPv4 address is a 32 bit address that identifies a node in a network. An IP address will have an IP prefix which determines the "Network" part of the IP address and the rest will determine the "Host".

An example:

128.208.0.0/24 will tell me that the first 24 bits is the "Network" part of the IP address, and the remaining 8 bits will be for the host in the given Network. Also, 128.208.0.0. will be the lowest IP address that is available in the given network..

Now Tannenbaum states in his book:

Since the prefix length cannot be inferred from the IP address alone,
routing protocols must carry the prefixes to routers. Sometimes
prefixes are simply de- scribed by their length, as in a ‘‘/16’’ which
is pronounced ‘‘slash 16.’’ The length of the prefix corresponds to a
binary mask of 1s in the network portion. When written out this way,
it is called a subnet mask. It can be ANDed with the IP ad- dress to
extract only the network portion. For our example, the subnet mask is
255.255.255.0.

So my questions are:

1) How do routing protocols carry the prefixes? Where is the "slash" part stored?

2) What does this mean at all:

It can be ANDed with the IP address to
extract only the network portion. For our example, the subnet mask is
255.255.255.0.

Thanks.

Best Answer

  1. How do routing protocols carry the prefixes? Where is the "slash" part stored?

I'll answer this as direct as possible with OSPF. Below is a Type 1 Hello packet sent out all interfaces to form an adjacency.

    0                   1                   2                   3
    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |   Version #   |       1       |         Packet length         |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                          Router ID                            |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                           Area ID                             |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |           Checksum            |             AuType            |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                       Authentication                          |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                       Authentication                          |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                        Network Mask                           |    <------
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |         HelloInterval         |    Options    |    Rtr Pri    |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                     RouterDeadInterval                        |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                      Designated Router                        |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                   Backup Designated Router                    |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                          Neighbor                             |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                              ...                              |

RFC 2328, A.3.2 The Hello packet

The Network Mask field is populated with the subnet mask you're using with that interface.

CIDR Notation is nothing more than a shorter version of your subnet mask for the sake of brevity. And for that matter, subnet masks are just a condensed version of bit positions. Imagine having to write in decimal every time you wanted to configure a port.

11111111.11111111.11111111.00000000    <---- This would be painstaking
255.255.255.0                          <---- Better, but not optimal
0xffffff00                             <---- Shorter still, but still not optimal
/24                                    <---- Best-case scenario

Everything comes out to the same thing in the end. So having these shorthand ways of representing the same data just makes sense.

Related Topic