Tuesday, March 23, 2010

Easy Route Summarization / Supernetting...

Some people get really confused when it comes to route summarization, probably more so with the different names given to it:
Route Summarization
Supernetting
Aggregate Address
Summary Address
Actually, I get more confused typing out this thing as being English I want to replace the z in "summarization" with an s, but as it's Cisco I best keep the z in. I also get this with "neighbor" versus "neighbour". Anyway, I digress. The above terms all mean the same thing.

What is summarization?
The process of taking a range of IP addresses and advertising them in one address block. The most well-known summarization/supernet is the RFC1918 Class B Range. More commonly we know the range to be 172.16.0.0 - 172.31.255.255, however the supernet is 172.16.0.0/12. You see what has happened there? We've taken a range of addresses and squashed it into one advertisement.

What are the benefits of summarization?
Quite clearly, if we have just one address instead of lots of individual addresses then the routing table is going to be smaller. This in turn means that memory requirements are reduced. The less obvious benefit is that summarization means you're tracking whether or not you're connected to some subnets of a summary, not the up/down state of every link. Thus when the link goes up or down, you don't have a flurry of traffic announcing the state change.

How to summarize/supernet?
This is what you really want to know isn't it? Well it's dead simple. The first method shows you the long way.
1. Starting from the left of the IP address, identify the first octet that has a change of address in it. For example, the Class B RFC1918 range, the IP address first changes in the second octet (i.e. 172.16.x.x - 172.31.x.x).
2. Write out the binary equivalent of the address up to and including the changing octet. So for example the range above is:
10101100.00010000 = 172.16
10101100.00010001 = 172.17
10101100.00010010 = 172.18
10101100.00010011 = 172.19
10101100.00010100 = 172.20
10101100.00010101 = 172.21
10101100.00010110 = 172.22
10101100.00010111 = 172.23
10101100.00011000 = 172.24
10101100.00011001 = 172.25
10101100.00011010 = 172.26
10101100.00011011 = 172.27
10101100.00011100 = 172.28
10101100.00011101 = 172.29
10101100.00011110 = 172.30
10101100.00011111 = 172.31

3. From this list, count from the left how many bits are the same in each address. If we look at it we see that the first 12 bits for each address is the same so that gives us our mask in slash notation. We therefore start at our first address 172.16.0.0 and append our mask so the summary address is 172.16.0.0/12.

Well that was quite simple. But can we be quicker? Yes we can is the good news, after all, you don't want to eat up time in the exam by writing out addresses in binary. So here goes:
1. How many subnets are in the range? The RFC1918 Class B range is 16 subnets.
2. What power of 2 equals our range? 16 subnets = 24 so the answer is four.
3. Subtract the figure from step 2 from the default mask of our address range. In this example our default mask is 16 so the mask after subtracting 4 is /12.
4. Add this mask to the first address in the range - 172.16.0.0/12 in this example
Quick, eh? This is how it works in my head, "mmmm, 16 addresses, 2 to the 4 is 16, mask is 16, minus 4 is 12, so summary address must be first address with /12 mask."

One last example:
Summarize the following:
192.168.0.0/24
192.168.1.0/24
192.168.2.0/24
192.168.3.0/24
There are 4 subnets. 2 to the power of 2 gives us 4 so default mask of 24, minus 2, gives us /22. Address is therefore 192.168.0.0/22.

More difficult supernetting question
There are, however, a few pitfalls with supernetting/summarization. Sometimes you may not be able to get all of the addresses into a supernet without wasting addresses. Experience with supernetting questions will help you to identify this. An example below shows you how this could happen:
You need to summarize the following range:
10.16.31.0/24
10.16.32.0/24
10.16.33.0/24
10.16.34.0/24
10.16.35.0/24
10.16.36.0/24
10.16.37.0/24
10.16.38.0/24
10.16.39.0/24
10.16.40.0/24
What summary address should you use? Well there's 10 subnets. 2 to the power of 3 only gives us 8 subnets which is too small so we need to look at 2 to the power of 4 which is 16. The problem is that if we count in 16s our addresses straddle two subnets: 10.16.16.0 to 10.16.31.255 and 10.16.32.0 to 10.16.47.255. We have the same problem if we use the power of 5 giving us a range of 32 addresses (10.16.31.0 is in a different subnet than the other addresses in the range). We therefore have to go out to 2 to the power of 6 = 64 in order to get all of our addresses in the
range (i.e. 10.16.0.0 to 10.16.63.255). What a waste of address space!! The best answer is the following:
Break the space down into three ranges. We can summarize 10.16.32.0 to 10.16.39.255 with 3 bits (i.e. there are 8 subnets and 2 to the power of 3 is 8). We simply leave the other two address as they are. We have therefore avoided any wasted address space.

Reference: Please also see the comments!
http://subnettingmadeeasy.blogspot.com/2007/11/router-summarization.html


More Examples:
Question:
"Given the addresses 10.1.138.0/27, 10.1.138.64/26, and 10.1.138.32/27, which of the following is the best summary?"

Answer:
10.1.138.0/27 covers 10.1.138.0 to 10.1.138.31
10.1.138.32/27 covers 10.1.138.32 to 10.1.138.63
10.1.138.64/26 covers 10.1.138.64 to 10.1.138.127
Therefore you have to find out which summary covers 10.1.138.0 to 10.128.38.127. This is 128 addresses (1 network address, 1 broadcast address, and 126 host addresses). We therefore need to reserve enough bits to cover 128 addresses. We know that 2^7 = 128 so we must not subnet the last 7 bits of the address. As there are 32 bits in an IP address we subtract 7 from 32 to give us 25. Our summary address is therefore 10.128.38.0/25

Question:
A router has a summary route to network 192.168.32.0/20 installed in its routing table. What range of networks are summarized by this route?

Answer:
You have a /20 which is a block size of 16 in the third octet (i.e. 2^(24-20) = 16). Count in block sizes of 16 in the third octet so you would have 192.168.0.0, 192.168.16.0, 192.168.32.0, 192.168.48.0 etc Your summary will therefore cover 192.168.32.0 to 192.168.47.255 To prove this you could always use binary. If we just concentrate on the third octet and pick 32 (the subnet address, in binary 00100000) and the mask for that octet is 11110000 (i.e. the full mask for a /20 is 111111111.11111111.11110000.00000000)
Perform an AND on that octet:
00100000
11110000
=
00100000
=
32
What if we use 47 in the 3rd octet (binary 00101111)?
Perform an AND:
00101111
11110000
=
00100000
=
32
They both resolve to the same value in the third octet so we know it is in the same summary.
Let's go to 48 in the third octet (binary 00110000) and perform the same AND with a /20 mask:
00110000
11110000
=
00110000
=
48
This value is different and therefore is not in the summary. The binary way is the longest method but can be useful for you to see what is happening with the bits.

Question:
Which address can be used to summarize networks 172.16.0.0/24 thru 172.16.7.0/24?

Answer:
In this case you still follow the same principals as in the tutorial but subtract the number of bits required to cover the subnet range from the mask given in the question. The question has 8 subnets in all. 3 bits will give us 8 subnets as 2 ^ 3 = 8. Subtract 3 from the mask in the question (24 - 3) which equals 21. Take the first address in your range and change the mask to the new mask and that gives you the summarized address (i.e. 172.16.0.0/21)