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: 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, 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

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


  • Can the downvoter please clarify why this question is downvoted? Feb 19, 2014 at 14:28
  • I suspect the community is expressing some down voting because your question is introductory-level, and this site is aimed at professionals. On the upside though, people are not close-voting you. Feb 19, 2014 at 16:27
  • Sorry, English is not my native language. What does this mean: "On the upside though, people are close-voting you." Feb 19, 2014 at 17:50
  • I meant to say: people are not voting to close your question. So some people don't like it (down voters), but it's not so bad that people are voting to close it. Feb 19, 2014 at 18:15
  • @CraigConstantine Got it thanks.. Yes you are right.. Feb 19, 2014 at 19:54

2 Answers 2

  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                          <---- 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.

  • The whole network mask is sent? Wouldn't it be more efficient to use 5 bits(only 1 to 31 is needed) indicating how many bits are network? Is there really any advantage to being able to define a mask?
    – Cruncher
    Feb 19, 2014 at 16:54
  • @Cruncher isn't a possibility. Only wildcard masks can work with discontiguous bits like this. The RFC doesn't outline why it sends the entire network mask with the OSPF packets.
    – Ryan Foley
    Feb 19, 2014 at 18:01
  • Is this a DHCP packet? Feb 19, 2014 at 19:54
  • No, the example above is an OSPF Type 1 Hello packet.
    – Ryan Foley
    Feb 19, 2014 at 20:05
  • @Cruncher wild card mask are only used for access-list and NATing, it is practically an inverted subnet mask.
    – chris
    Feb 20, 2014 at 12:15

It depends on the routing protocol. Old protocols like RIP v1 assume a classful mask and do not advertise a mask, but newer ones like RIP v2, OSPF, ISIS, BGP, etc do.

The answer to the second part of your question: To determine the network part of the address, or to test if a given address is part of a particular network, you perform a bitwise logical AND with the subnet mask.

For example, to get the network address of, you AND each bit of the 32 bit address and the Mask, like this:

10101100 00010000 00011000 00000101 <-

11111111 11111111 11111111 00000000 <-

10101100 00010000 00011000 00000000 <- Result:

The result is the network portion of the IP address (also called the network number). This is exactly what your router and PC do to determine which network to use to transmit the packet.

  • Thanks for the answer but what is so special about ? Feb 19, 2014 at 14:29
  • 1
    Nothing really, other than because the division between the network and host mask fall on the "dot" boundary, it is easy to use (the last decimal digit is always 0). So it is very commonly used.
    – Ron Trunk
    Feb 19, 2014 at 14:34
  • Does it assume the IP has a 24 bit prefix? Feb 19, 2014 at 14:42
  • What I do not understand is, you have given an example: and you already know the prefix length. But how does the Router know the prefix? If it does not know the prefix, how will it know it should use ? Feb 19, 2014 at 14:48
  • The router advertisements for each route carry the prefix (for modern protocols).
    – Ron Trunk
    Feb 19, 2014 at 15:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.