You are on page 1of 1

BlogHome|INEHome|Members|ContactUs

Submit a Question

View Archives

Training Products

17 ASimpleIPv4PrefixSummarizationProcedure
PostedbyPetrLapukhov,CCIE#16379inIGP,IPAddressing

CCIE Bloggers

SearchtheBlog

Mar

18Comments

Search
Submit

Overview
InthisshortblogpostwearegoingtopresentasimpleprocedureforIPv4prefixsummarization.The
procedureisbasedontheonefoundinOptimalRoutingDesignbookbyRussWhite,DonSliceandAlvaro
Retana,butdiffersinsomerespects.Theprocessisthreestep,andrequiretheuseofWindowscalculatorfor
easeofcomputation.Nobinarybreakdownsareinvolved,justsomebasicarithmetic.Forthesakeofsimplicity,we
skipallproofs,asthosearetrivial.ThesameapproachcouldbeadoptedforusewithIPv6prefixes,providedthat
decimalarithmeticisreplacedwithhexadecimal.

Scenario
Wearegoingtouseanexampletodemonstratethemethod.Hereisthetask:findtheoptimal(longestprefix
length)summaryprefixforthefollowingsetofsubnets:

192.168.100.0/22
192.168.101.0/24
192.168.99.0/24
192.168.102.0/24
192.168.105.0/24
192.168.98.0/23

Thisexampleistakenfromthewikipediaarticle:http://en.wikipedia.org/wiki/Supernetthatillustratestheuseof

Categories
SelectCategory

CurrentPoll
Iwouldplaceavalueof___
ontheabilitytotakeaway
PDF'sofallinstructor
whiteboardactivityduringa
LiveorOnlinecourse
deliveredbyINE.(1-lowest,
10-highestvalue)
1
2
3
4
5
6
7
8
9
10
Vote

binarybreakdownforthepurposeofaddresssummarization.

ViewResults
PollsArchive

Preparations
Itdoesnotmatterifthesubnetshavedifferentprefixlengthsyoumaysimplyignorethese,astheresulting
summarywilluseitsownprefixlength.Sorttheprefixesinascendingorder,startingwithlowestandtothehighest
32-bitnumber.Findtheoctetwheretheprefixesdiffer(wewouldcallitchangingoctetfromhereon).Inourcase

CCIEBloggers
BrianDennisCCIE#2210
Routing&Sw itching
ISPDial
Security
ServiceProvider
Voice

thisisthe3rdoctet(98,99etc):

192.168.98.0/23
192.168.99.0/24

ScottMorrisCCIE#4713

192.168.100.0/22

Routing&Sw itching
ISPDial
Security
ServiceProvider

192.168.101.0/24
192.168.102.0/24
192.168.105.0/24

BrianMcGahanCCIE#8593

Youonlyneedtosorttheprefixestofindthelowestandthehighestchangingoctetvalues.Thechangingoctet
positionalsogivesusthecorrespondingpositionalprefixlength.Ifthisoctetisthefirstintheprefix,thepositional
prefixlengthis8,ifitsthesecondthenthepositionalprefixlengthis16,next24forthirdand32forfourthposition
inthedotted-decimalform.

Routing&Sw itching
Security
ServiceProvider
PetrLapukhovCCIE#16379
Routing&Sw itching
Security
ServiceProvider
Voice

Step1:
TakethehighestandlowestchangingoctetsandperformXORoperationonthem.YoumayuseWindows
calculatororanyotherutilitythatallowsforlogicaloperationsondecimalnumbers:98XOR105=11.Next,take
thelowestpowerof2thatisstrictlygreaterthantheresultingnumber(eveniftheresultisapoweroftwoitself).
Inourcaseitis16.Letscallthisnumberasy.Afterthat,findthenumberz,sothat2^z=y(here^means
power,notXORlikeinC),i.e.takeLog2ofy:z=Log2(y)=Log2(16)=4.Youmayuseashorttableofpowers
of2rangingfrom2^0to2^8youdontneedmoreasyoudealwithjustasingleoctet.Itseasytomemorizethese
numberstoo.NoticethatdealingwithIPv6wouldrequirethetableof16elements(2^0through2^16).
NoteTheoriginalmethodfoundinOptimalRoutingDesignusessubtractionoperationinsteadofXORatthis
step.Itcouldbeshownthatsubtractiondoesnotworkinallcases.Forexample,itdoesnotrevealthecorrect
highestmismatchingbitpositioninthecaseof:10.1.66.0and10.1.69.0as69-66=3(incorrectlyapproximatedby
2^2)while69XOR66=7(correctlyapproximatedby2^3).Thereasonbeingarearithmeticunderflowsthat

AnthonySequeriaCCIE#15626
Routing&Sw itching
MarvinGreenleeCCIE#12237
Routing&Sw itching
Security
ServiceProvider
KeithBarkerCCIE#6783
Routing&Sw itching
Security
MarkSnow CCIE#14073
Voice
Security
JoshFinkeCCIE#25707
Voice

happenwithsubtraction.

PopularTags

Step2:

35503560announcementasa

Taketheanychangingoctetvalue,e.g.thelowestone,anddivideitbyythendroptheremainder:98/16=
6.125roundedto6(floorfunction).Nowmultiply6byyagaintoyield96thisisthebaseoctetofthe
summaryaddress.Thesummaryprefixnowlookslike:192.168.96.0.Effectively,thesetwooperationsrepresent
logicalbinaryshiftrightandlefttomaskthechangingbits.Yes,youmaytakeANYoctectfromthesetofprefixes
theresultwillbethesame.

ccie

betablueprintCCENT

ccie2.0CCIEVoiceCCNA

ciscocorecustomer-

CCNP

exam

focus eigrp
filtering
firew alliewbiew b-rs ios

knowledgelabMPLS

Step3:

multicastnews ospfpix

practicesampleSecurity

Thefinalstepisfindingthesummaryprefixlength.Takethepositionalprefixlengthcorrespondingtothechanging
octet,asdescribedpreviously.Inourcaseitsthethirdoctet,andthusthepositionalprefixlengthis24.Now
subtractzfromthisnumbertogetxthesummaryprefixlength:x=24-z=24-4=20.Thesummaryprefixis:
192.168.y.0/x=192.168.96.0/20

strategystudy

shapingstp

tipstrainingtroubleshooting
updateupdates v5vol1vol2
written

Step4(Optional):
Convertprefixlengthintonetworkmask,ifneeded.Toaccomplishthis,take256andsubtracty:256-16=240.
Thisisthenetmaskcomponentthatcorrespondstothesummarybaseoctet:192.168.96.0255.255.240.0

Example1
Takethefollowingsubnets:

10.1.57.0/24
10.1.59.0/24
10.1.61.0/24

Changingoctet3rd,positionalprefixlength=24.Nextstep:61XOR57=4thusy=8,z=3;57/y=57/8=
7.125andthebaseoctetis7*8=56.Theprefixlengthis24-3=21.Summaryprefixis:10.1.56.0/21or10.1.56.0
255.255.248.0

Example2
Takethefollowingsubnets:

192.168.97.0/23
192.168.100.0/22

Changingoctet3rd,positionalprefixlength=24.Nextstep:100XOR97=5,y=8,z=397/8=12.125,base
=12*8=96.Theprefixlength=24-3=21.SummaryPrefix:192.168.96.0/21or192.168.96.0255.255.248.0

Example3
Takethefollowingsubnets:

172.16.14.0/24
172.16.17.0/24
172.16.25.0/24

ChangingOctet3rd,positionalprefixlength=24.NextStep:25XOR14=23,y=32,z=5;14/32=0.43,base
octet=0.Summarylength:24-5=19.Summaryprefix:172.16.0.0/19or172.16.0.0255.255.224.0.Noticethat
thissummaryaddresscouldbetooexhaustiveintermsofoverlappedaddressspace.Youmaywanttosummarize
justtwoprefixes:172.16.17.0and172.16.25.0andleak172.16.14.0:summaryof172.16.17.0and172.16.25.0=
172.16.16.0/20and172.16.14.0/24isleftun-summarized.

Conclusions
Theprocedurepresentedinthisarticlecouldbeusefulwhendealingwithlarge-scalenetworksandconfiguring
manualIPv4prefixsummarization.Youmayavoidcomplicatedbinaryconversionsandsimplyusethecalculatorto
findtheresultingprefix.

Tags:addresssummarization,ipv4summarization,supernets
DownloadthispageasaPDF
AboutPetrLapukhov,CCIE#16379:
PetrLapukhov'scareerinITbegainin1988w ithafocusoncomputerprogramming,andprogressedintonetw orking
w ithhisfirstexposuretoNovellNetWarein1991.Initiallyinvolvedw ithKazanStateUniversity'scampusnetw ork
supportandUNIXsystemadministration,hew entthroughthepathofbecominganetw orkingconsultant,takingpartin
manynetw orkdeploymentprojects.Petrcurrentlyhasover12yearsofexperiencew orkingintheCisconetw orking
field,andistheonlypersoninthew orldtohaveobtainedfourCCIEsinundertw oyears,passingeachonhisfirst
attempt.Petrisanexceptionalcaseinthathehasbeenw orkingw ithallofthetechnologiescoveredinhisfourCCIE
tracks(R&S,Security,SP,andVoice)onadailybasisformanyyears.Whennotactivelyteachingclasses,developing
self-pacedproducts,studyingfortheCCDEPractical&theCCIEStorageLabExam,andcompletinghisPhDinApplied
Mathematics.
Findallpostsbypetr|VisitWebsite

Youcanleavearesponse,ortrackbackfromyourownsite.

18ResponsestoASimpleIPv4PrefixSummarizationProcedure

Marc h17,2010at10:09am

JohnZhang
Greatshortcut.Thanks

OTCCIER&SandSecurityBootcampinNigeria-SoDoYouWanttobeaCCIE?-2bccie.com
Marc h17,2010at1:39pm

[...]CoreKnowledgeIsPricelessTestYoursToday:Q:Whatisthetheoptimal(longestprefixlength)summaryforthefollowingset
ofsubnets192.168.100.0/22;192.168.101.0/24;192.168.99.0/24;192.168.102.0/24;192.168.105.0/24;192.168.98.0/23?A:
192.168.96.0/20MoreInfo:http://blog.ine.com/2010/03/17/a-simple-ipv4-prefix-summarization-procedure/[...]

Marc h17,2010at2:47pm

Dana
Ilovethewaythiswasexplained.Aniceresourceformany.GreatworkPetr!

OTCCIER&SandSecurityBootcampinNigeria-SoDoYouWanttobeaCCIE?-2bccie.com
Marc h17,2010at3:11pm

[...]192.168.105.0/24;192.168.98.0/23?>A:192.168.96.0/20>MoreInfo:>>http://blog.ine.com/2010/03/17/a-simple-ipv4-prefixsummarization-procedure/>>OnMar17,2010,at4:27PM,MarkAnthonywrote:>>>HelloGS,>>>[...]

OTCCIER&SandSecurityBootcampinNigeria-SoDoYouWanttobeaCCIE?-2bccie.com
Marc h17,2010at10:04pm

[...]192.168.98.0/23?>>A:192.168.96.0/20>>MoreInfo:>>>>>http://blog.ine.com/2010/03/17/a-simple-ipv4-prefixsummarization-procedure/>>>>OnMar17,2010,at4:27PM,MarkAnthonywrote:>>>>>Hello[...]

Marc h18,2010at4:36am

CarlosFarinha
HiPetr,
Thanksforyourpost,asusualreallywellexplainedandveryuseful.
Pleasejustcorrectthetypoonexample3,justtoavoidconfusinganyonereadingthepost,itshouldbe14/32(y)not14/23.
Thanksonceagain!
Carlos

Marc h18,2010at8:39am

DeepakArora
HeyPetrcanyouwritesomegooddetailedarticleonPrefixListsfrombinaryprospective.Iknowmostpeoplefeelthatitsveryeasy
though.Buttherearemanyouttherelikemewhostillwantto
understanditfrombinarypointofviewspeciallywhensomeoneaskssomethinglike:Constructaprefixlistthatdeniesanyprefixfor
whichthemost-significantfourbitsare0110,andpermitseverythingelse.
Thanks!
DeepakArora

OTCCIER&SandSecurityBootcampinNigeria-SoDoYouWanttobeaCCIE?-2bccie.com
Marc h18,2010at12:12pm

[...]192.168.98.0/23?>>A:192.168.96.0/20>>MoreInfo:>>>>http://blog.ine.com/2010/03/17/a-simple-ipv4-prefixsummarization-procedure/>>>>OnMar17,2010,at4:27PM,MarkAnthonywrote:>>>>>Hello[...]

Marc h18,2010at7:51pm

BilalHansrod
HiPetr,
Howdidyouderivey?Istillcantgetmyheadaround:)
Regards,
Bilal

Marc h19,2010at3:28am

NishVamadevan
Bilal,
AXorB=C
2^D=E
Eisapowerof2whichisgreaterthanC,whereDisthepoweryouareusing.
Inhiscase,
A=98
B=105
HenceC=11(98Xor105)
So
2^D>11andthatisE
2^4=16=E(IntheExampleitisY)

Marc h20,2010at7:41am

shivlujain
ThanksbydoingIgetridfromthebinaryanditsaveslotoftime.

Marc h22,2010at9:02pm

BilalHansrod
ThanksNishItlookslikeEOrYisalwaysgreaterthanCvalue.soifXorvalueis32thanitwouldbe2^6andEorYbecomes64.
AmIright?

Marc h24,2010at3:28am

NishVamadevan
Bilal,thatiscorrect.
TheValueofYneedstobe
lowestpowerof2thatisstrictlygreaterthantheresultingnumber
2^5=32isthesamevaluesoyouneedtogooneonemorepowerwhichis2^6=64,whichiscorrect.

Marc h28,2010at8:58pm

BilalHansrod
ThanksNish

May4,2010at6:18am

Dev13
Guys,
Incaseof
222.222.221.1/24
222.222.222.1/24
222.222.223.1/24
WhatwillbethesummaryaddressIcanuse?

May4,2010at8:01am

PetrLapukhov,CCIE#16379
@Dev13
thesummaryis222.222.220/22

May4,2010at8:18am

Dev13
soPetrinmycasey=4as221XOR223=2soIhavetotakeYstrictlygreaterthantheXORresultright?soitwillbe4.ThenIwilldo
Log2(4)whichwillgivemeresultof2andthatis24-2=22andthatwillbemymask.andfor3rdoctet221/4=55.25andIwilltake55
byleavingreminderandagain554=220,sothatway222.222.220.0/22istheresultright?
SoforYithastobegreaterthan,itisnotequaltotheXORresult.

May4,2010at9:48am

PetrLapukhov,CCIE#16379
@Devin13:
Quotefromtheblogpost:
TakethehighestandlowestchangingoctetsandperformXORoperationonthem.YoumayuseWindowscalculatororanyother
utilitythatallowsforlogicaloperationsondecimalnumbers:98XOR105=11.Next,takethelowestpowerof2thatisstrictly
greaterthantheresultingnumber(eveniftheresultisapoweroftwoitself)

LeaveaReply
Name(required)

Mail(willnotbepublished)(required)

Website

SubmitComment

twitter.com/inetraining

Aninvestmentinknow ledgealw ays


paysthebestinterest-Benjamin
Franklinhttp://bit.ly/cVdRKd(Mark
Snow ,CCIE#14073)

2010InternetworkExpert,Inc.,AllRightsReserved

Apologiesfortheshortdow ntimeon
http://ine.com.Weransomequick
maintenance,buteverythingshould
bew orkingagain:)

AskINE#3http://bit.ly/9Eib70.Your
#cciequestionsansw ered!

You might also like