{"id":166,"date":"2019-02-18T21:48:02","date_gmt":"2019-02-18T20:48:02","guid":{"rendered":"https:\/\/mokrane-assam.com\/?p=166"},"modified":"2026-11-29T21:50:06","modified_gmt":"2026-11-29T20:50:06","slug":"ospf-basics-from-neighbors-to-the-spf-tree","status":"publish","type":"post","link":"https:\/\/mokrane-assam.com\/index.php\/2019\/02\/18\/ospf-basics-from-neighbors-to-the-spf-tree\/","title":{"rendered":"OSPF Basics: From Neighbors to the SPF Tree"},"content":{"rendered":"<p class=\"wp-block-paragraph\"><strong>From zero to expert.<\/strong> OSPF (Open Shortest Path First) is the link-state IGP you meet on day one and keep meeting for the rest of your career. This guide starts with the absolute basics \u2014 what link-state means \u2014 and finishes on LSA types, area behaviour and the SPF algorithm itself. Almost every idea gets its own diagram.<\/p><h2 class=\"wp-block-heading\">1. What OSPF actually is: link-state<\/h2><p class=\"wp-block-paragraph\">A distance-vector protocol tells its neighbours <em>what it knows<\/em> (routes and distances). A link-state protocol tells its neighbours <em>what it sees<\/em> (its directly connected links). Every router floods these link descriptions, so all routers in an area build an <strong>identical map<\/strong> \u2014 the Link-State Database (LSDB) \u2014 and each one independently runs Dijkstra to find its own shortest paths.<\/p><figure class=\"mkz-diagram\" style=\"margin:24px auto;max-width:920px\"><svg style=\"width:100%;height:auto;display:block;margin:0 auto\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 920 260\" font-family=\"'Segoe UI',Roboto,Helvetica,Arial,sans-serif\" role=\"img\" aria-label=\"OSPF link-state model\"><defs><linearGradient id=\"hg\" x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\"><stop offset=\"0\" stop-color=\"#17263f\"\/><stop offset=\"1\" stop-color=\"#0f172a\"\/><\/linearGradient><marker id=\"ar\" viewBox=\"0 0 10 10\" refX=\"8\" refY=\"5\" markerWidth=\"7\" markerHeight=\"7\" orient=\"auto-start-reverse\"><path d=\"M0 0L10 5L0 10z\" fill=\"#0A66C2\"\/><\/marker><\/defs><rect x=\"0\" y=\"0\" width=\"920\" height=\"260\" rx=\"14\" fill=\"#f8fafc\" stroke=\"#e2e8f0\"\/><rect x=\"0\" y=\"0\" width=\"920\" height=\"60\" rx=\"14\" fill=\"url(#hg)\"\/><rect x=\"0\" y=\"40\" width=\"920\" height=\"20\" fill=\"#0f172a\"\/><text x=\"28\" y=\"37\" fill=\"#ffffff\" font-size=\"19\" font-weight=\"700\">OSPF link-state model<\/text><text x=\"892\" y=\"37\" text-anchor=\"end\" fill=\"#38bdf8\" font-size=\"13\" font-weight=\"600\" letter-spacing=\"1\">NET BY ME<\/text><text x=\"460\" y=\"92\" text-anchor=\"middle\" fill=\"#475569\" font-size=\"12\">Each router floods its links; all routers hold the SAME database, then compute paths independently<\/text><g><rect x=\"60\" y=\"120\" width=\"120\" height=\"56\" rx=\"10\" fill=\"#ffffff\" stroke=\"#0A66C2\" stroke-width=\"1.5\"\/><text x=\"120\" y=\"144\" text-anchor=\"middle\" fill=\"#0f172a\" font-size=\"12\" font-weight=\"700\">R1<\/text><text x=\"120\" y=\"163\" text-anchor=\"middle\" fill=\"#64748b\" font-size=\"10\">LSDB copy<\/text><\/g><g><rect x=\"280\" y=\"120\" width=\"120\" height=\"56\" rx=\"10\" fill=\"#ffffff\" stroke=\"#0A66C2\" stroke-width=\"1.5\"\/><text x=\"340\" y=\"144\" text-anchor=\"middle\" fill=\"#0f172a\" font-size=\"12\" font-weight=\"700\">R2<\/text><text x=\"340\" y=\"163\" text-anchor=\"middle\" fill=\"#64748b\" font-size=\"10\">LSDB copy<\/text><\/g><g><rect x=\"500\" y=\"120\" width=\"120\" height=\"56\" rx=\"10\" fill=\"#ffffff\" stroke=\"#0A66C2\" stroke-width=\"1.5\"\/><text x=\"560\" y=\"144\" text-anchor=\"middle\" fill=\"#0f172a\" font-size=\"12\" font-weight=\"700\">R3<\/text><text x=\"560\" y=\"163\" text-anchor=\"middle\" fill=\"#64748b\" font-size=\"10\">LSDB copy<\/text><\/g><g><rect x=\"720\" y=\"120\" width=\"120\" height=\"56\" rx=\"10\" fill=\"#ffffff\" stroke=\"#0A66C2\" stroke-width=\"1.5\"\/><text x=\"780\" y=\"144\" text-anchor=\"middle\" fill=\"#0f172a\" font-size=\"12\" font-weight=\"700\">R4<\/text><text x=\"780\" y=\"163\" text-anchor=\"middle\" fill=\"#64748b\" font-size=\"10\">LSDB copy<\/text><\/g><rect x=\"60\" y=\"200\" width=\"800\" height=\"40\" rx=\"9\" fill=\"#e0f2fe\" stroke=\"#0A66C2\"\/><text x=\"460\" y=\"225\" text-anchor=\"middle\" fill=\"#0369a1\" font-size=\"12\" font-weight=\"600\">Identical Link-State Database \u2192 each router runs SPF (Dijkstra) locally<\/text><line x1=\"120\" y1=\"176\" x2=\"120\" y2=\"200\" stroke=\"#0A66C2\" stroke-width=\"2\" marker-end=\"url(#ar)\"\/><line x1=\"340\" y1=\"176\" x2=\"340\" y2=\"200\" stroke=\"#0A66C2\" stroke-width=\"2\" marker-end=\"url(#ar)\"\/><line x1=\"560\" y1=\"176\" x2=\"560\" y2=\"200\" stroke=\"#0A66C2\" stroke-width=\"2\" marker-end=\"url(#ar)\"\/><line x1=\"780\" y1=\"176\" x2=\"780\" y2=\"200\" stroke=\"#0A66C2\" stroke-width=\"2\" marker-end=\"url(#ar)\"\/><\/svg><\/figure><h2 class=\"wp-block-heading\">2. Areas and the two-level hierarchy<\/h2><p class=\"wp-block-paragraph\">OSPF scales by splitting the domain into <strong>areas<\/strong>. Area 0 is the <strong>backbone<\/strong>; every other area must touch it. A router with interfaces in two areas is an <strong>ABR<\/strong> (Area Border Router) and summarises between them. A router that injects routes from outside OSPF is an <strong>ASBR<\/strong> (Autonomous System Boundary Router). Flooding is contained inside an area \u2014 a topology change in Area 1 never forces an SPF run in Area 2.<\/p><figure class=\"mkz-diagram\" style=\"margin:24px auto;max-width:920px\"><svg style=\"width:100%;height:auto;display:block;margin:0 auto\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 920 260\" font-family=\"'Segoe UI',Roboto,Helvetica,Arial,sans-serif\" role=\"img\" aria-label=\"OSPF area hierarchy\"><defs><linearGradient id=\"hg\" x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\"><stop offset=\"0\" stop-color=\"#17263f\"\/><stop offset=\"1\" stop-color=\"#0f172a\"\/><\/linearGradient><marker id=\"ar\" viewBox=\"0 0 10 10\" refX=\"8\" refY=\"5\" markerWidth=\"7\" markerHeight=\"7\" orient=\"auto-start-reverse\"><path d=\"M0 0L10 5L0 10z\" fill=\"#0A66C2\"\/><\/marker><\/defs><rect x=\"0\" y=\"0\" width=\"920\" height=\"260\" rx=\"14\" fill=\"#f8fafc\" stroke=\"#e2e8f0\"\/><rect x=\"0\" y=\"0\" width=\"920\" height=\"60\" rx=\"14\" fill=\"url(#hg)\"\/><rect x=\"0\" y=\"40\" width=\"920\" height=\"20\" fill=\"#0f172a\"\/><text x=\"28\" y=\"37\" fill=\"#ffffff\" font-size=\"19\" font-weight=\"700\">OSPF area hierarchy<\/text><text x=\"892\" y=\"37\" text-anchor=\"end\" fill=\"#38bdf8\" font-size=\"13\" font-weight=\"600\" letter-spacing=\"1\">NET BY ME<\/text><rect x=\"300\" y=\"86\" width=\"320\" height=\"52\" rx=\"10\" fill=\"#0f172a\"\/><text x=\"460\" y=\"110\" text-anchor=\"middle\" fill=\"#fff\" font-size=\"13\" font-weight=\"700\">Area 0 \u2014 Backbone<\/text><text x=\"460\" y=\"128\" text-anchor=\"middle\" fill=\"#94a3b8\" font-size=\"10\">all areas must connect here<\/text><rect x=\"40\" y=\"186\" width=\"240\" height=\"52\" rx=\"10\" fill=\"#e0f2fe\" stroke=\"#0A66C2\"\/><text x=\"160\" y=\"216\" text-anchor=\"middle\" fill=\"#0f172a\" font-size=\"12\" font-weight=\"600\">Area 1<\/text><rect x=\"640\" y=\"186\" width=\"240\" height=\"52\" rx=\"10\" fill=\"#e0f2fe\" stroke=\"#0A66C2\"\/><text x=\"760\" y=\"216\" text-anchor=\"middle\" fill=\"#0f172a\" font-size=\"12\" font-weight=\"600\">Area 2<\/text><circle cx=\"300\" cy=\"162\" r=\"15\" fill=\"#C8102E\"\/><text x=\"300\" y=\"166\" text-anchor=\"middle\" fill=\"#fff\" font-size=\"10\" font-weight=\"700\">ABR<\/text><circle cx=\"620\" cy=\"162\" r=\"15\" fill=\"#C8102E\"\/><text x=\"620\" y=\"166\" text-anchor=\"middle\" fill=\"#fff\" font-size=\"10\" font-weight=\"700\">ABR<\/text><line x1=\"300\" y1=\"177\" x2=\"220\" y2=\"186\" stroke=\"#0A66C2\" stroke-width=\"2\"\/><line x1=\"300\" y1=\"147\" x2=\"340\" y2=\"138\" stroke=\"#0A66C2\" stroke-width=\"2\"\/><line x1=\"620\" y1=\"177\" x2=\"700\" y2=\"186\" stroke=\"#0A66C2\" stroke-width=\"2\"\/><line x1=\"620\" y1=\"147\" x2=\"580\" y2=\"138\" stroke=\"#0A66C2\" stroke-width=\"2\"\/><text x=\"460\" y=\"232\" text-anchor=\"middle\" fill=\"#475569\" font-size=\"11\">ABR = interfaces in two areas \u00b7 ASBR = redistributes external routes into OSPF<\/text><\/svg><\/figure><h2 class=\"wp-block-heading\">3. How neighbours become adjacent<\/h2><p class=\"wp-block-paragraph\">Two routers do not exchange databases until they walk a <strong>state machine<\/strong>. They discover each other with Hellos (Down \u2192 Init \u2192 2-Way), elect a DR on multi-access links, then synchronise the LSDB (ExStart \u2192 Exchange \u2192 Loading \u2192 Full). <strong>Full<\/strong> is the only healthy end state for an adjacency that exchanges LSAs. Stuck in ExStart usually means an MTU mismatch; stuck in 2-Way between DROTHERs is normal.<\/p><figure class=\"mkz-diagram\" style=\"margin:24px auto;max-width:920px\"><svg style=\"width:100%;height:auto;display:block;margin:0 auto\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 920 180\" font-family=\"'Segoe UI',Roboto,Helvetica,Arial,sans-serif\" role=\"img\" aria-label=\"OSPF neighbor state machine\"><defs><linearGradient id=\"hg\" x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\"><stop offset=\"0\" stop-color=\"#17263f\"\/><stop offset=\"1\" stop-color=\"#0f172a\"\/><\/linearGradient><marker id=\"ar\" viewBox=\"0 0 10 10\" refX=\"8\" refY=\"5\" markerWidth=\"7\" markerHeight=\"7\" orient=\"auto-start-reverse\"><path d=\"M0 0L10 5L0 10z\" fill=\"#0A66C2\"\/><\/marker><\/defs><rect x=\"0\" y=\"0\" width=\"920\" height=\"180\" rx=\"14\" fill=\"#f8fafc\" stroke=\"#e2e8f0\"\/><rect x=\"0\" y=\"0\" width=\"920\" height=\"60\" rx=\"14\" fill=\"url(#hg)\"\/><rect x=\"0\" y=\"40\" width=\"920\" height=\"20\" fill=\"#0f172a\"\/><text x=\"28\" y=\"37\" fill=\"#ffffff\" font-size=\"19\" font-weight=\"700\">OSPF neighbor state machine<\/text><text x=\"892\" y=\"37\" text-anchor=\"end\" fill=\"#38bdf8\" font-size=\"13\" font-weight=\"600\" letter-spacing=\"1\">NET BY ME<\/text><g><rect x=\"30\" y=\"96\" width=\"100\" height=\"48\" rx=\"10\" fill=\"#ffffff\" stroke=\"#cbd5e1\" stroke-width=\"1.3\"\/><text x=\"80\" y=\"125\" text-anchor=\"middle\" fill=\"#0f172a\" font-size=\"12\" font-weight=\"600\">Down<\/text><\/g><g><rect x=\"150\" y=\"96\" width=\"100\" height=\"48\" rx=\"10\" fill=\"#ffffff\" stroke=\"#cbd5e1\" stroke-width=\"1.3\"\/><text x=\"200\" y=\"125\" text-anchor=\"middle\" fill=\"#0f172a\" font-size=\"12\" font-weight=\"600\">Init<\/text><\/g><g><rect x=\"270\" y=\"96\" width=\"100\" height=\"48\" rx=\"10\" fill=\"#ffffff\" stroke=\"#cbd5e1\" stroke-width=\"1.3\"\/><text x=\"320\" y=\"125\" text-anchor=\"middle\" fill=\"#0f172a\" font-size=\"12\" font-weight=\"600\">2-Way<\/text><\/g><g><rect x=\"390\" y=\"96\" width=\"100\" height=\"48\" rx=\"10\" fill=\"#ffffff\" stroke=\"#cbd5e1\" stroke-width=\"1.3\"\/><text x=\"440\" y=\"125\" text-anchor=\"middle\" fill=\"#0f172a\" font-size=\"12\" font-weight=\"600\">ExStart<\/text><\/g><g><rect x=\"510\" y=\"96\" width=\"100\" height=\"48\" rx=\"10\" fill=\"#ffffff\" stroke=\"#cbd5e1\" stroke-width=\"1.3\"\/><text x=\"560\" y=\"125\" text-anchor=\"middle\" fill=\"#0f172a\" font-size=\"12\" font-weight=\"600\">Exchange<\/text><\/g><g><rect x=\"640\" y=\"96\" width=\"100\" height=\"48\" rx=\"10\" fill=\"#ffffff\" stroke=\"#cbd5e1\" stroke-width=\"1.3\"\/><text x=\"690\" y=\"125\" text-anchor=\"middle\" fill=\"#0f172a\" font-size=\"12\" font-weight=\"600\">Loading<\/text><\/g><g><rect x=\"790\" y=\"96\" width=\"100\" height=\"48\" rx=\"10\" fill=\"#dcfce7\" stroke=\"#166534\" stroke-width=\"2\"\/><text x=\"840\" y=\"125\" text-anchor=\"middle\" fill=\"#0f172a\" font-size=\"12\" font-weight=\"700\">Full<\/text><\/g><line x1=\"130\" y1=\"120\" x2=\"150\" y2=\"120\" stroke=\"#0A66C2\" stroke-width=\"2\" marker-end=\"url(#ar)\"\/><line x1=\"250\" y1=\"120\" x2=\"270\" y2=\"120\" stroke=\"#0A66C2\" stroke-width=\"2\" marker-end=\"url(#ar)\"\/><line x1=\"370\" y1=\"120\" x2=\"390\" y2=\"120\" stroke=\"#0A66C2\" stroke-width=\"2\" marker-end=\"url(#ar)\"\/><line x1=\"490\" y1=\"120\" x2=\"510\" y2=\"120\" stroke=\"#0A66C2\" stroke-width=\"2\" marker-end=\"url(#ar)\"\/><line x1=\"610\" y1=\"120\" x2=\"640\" y2=\"120\" stroke=\"#0A66C2\" stroke-width=\"2\" marker-end=\"url(#ar)\"\/><line x1=\"740\" y1=\"120\" x2=\"790\" y2=\"120\" stroke=\"#0A66C2\" stroke-width=\"2\" marker-end=\"url(#ar)\"\/><text x=\"460\" y=\"166\" text-anchor=\"middle\" fill=\"#475569\" font-size=\"11\">Hellos build 2-Way \u00b7 DR elected \u00b7 then DBD\/LSR\/LSU sync to Full. Stuck in ExStart \u2192 check MTU.<\/text><\/svg><\/figure><h2 class=\"wp-block-heading\">4. DR and BDR on multi-access links<\/h2><p class=\"wp-block-paragraph\">On a broadcast segment, forming a full mesh of adjacencies would be O(n\u00b2) flooding. OSPF elects a <strong>Designated Router<\/strong> and <strong>Backup DR<\/strong>; everyone else (DROTHER) becomes <strong>Full with the DR\/BDR only<\/strong> and stays <strong>2-Way<\/strong> with each other. Election is highest <strong>priority<\/strong> (default 1), tiebreak highest <strong>Router-ID<\/strong>; priority 0 can never be DR. It is not pre-emptive \u2014 a higher-priority router joining later does not steal the role.<\/p><figure class=\"mkz-diagram\" style=\"margin:24px auto;max-width:920px\"><svg style=\"width:100%;height:auto;display:block;margin:0 auto\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 920 230\" font-family=\"'Segoe UI',Roboto,Helvetica,Arial,sans-serif\" role=\"img\" aria-label=\"OSPF DR\/BDR election\"><defs><linearGradient id=\"hg\" x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\"><stop offset=\"0\" stop-color=\"#17263f\"\/><stop offset=\"1\" stop-color=\"#0f172a\"\/><\/linearGradient><marker id=\"ar\" viewBox=\"0 0 10 10\" refX=\"8\" refY=\"5\" markerWidth=\"7\" markerHeight=\"7\" orient=\"auto-start-reverse\"><path d=\"M0 0L10 5L0 10z\" fill=\"#0A66C2\"\/><\/marker><\/defs><rect x=\"0\" y=\"0\" width=\"920\" height=\"230\" rx=\"14\" fill=\"#f8fafc\" stroke=\"#e2e8f0\"\/><rect x=\"0\" y=\"0\" width=\"920\" height=\"60\" rx=\"14\" fill=\"url(#hg)\"\/><rect x=\"0\" y=\"40\" width=\"920\" height=\"20\" fill=\"#0f172a\"\/><text x=\"28\" y=\"37\" fill=\"#ffffff\" font-size=\"19\" font-weight=\"700\">OSPF DR\/BDR election<\/text><text x=\"892\" y=\"37\" text-anchor=\"end\" fill=\"#38bdf8\" font-size=\"13\" font-weight=\"600\" letter-spacing=\"1\">NET BY ME<\/text><rect x=\"380\" y=\"86\" width=\"160\" height=\"46\" rx=\"10\" fill=\"#0f172a\"\/><text x=\"460\" y=\"106\" text-anchor=\"middle\" fill=\"#fff\" font-size=\"12\" font-weight=\"700\">DR<\/text><text x=\"460\" y=\"123\" text-anchor=\"middle\" fill=\"#94a3b8\" font-size=\"10\">highest prio \/ RID<\/text><rect x=\"40\" y=\"170\" width=\"150\" height=\"44\" rx=\"10\" fill=\"#fff7ed\" stroke=\"#f59e0b\"\/><text x=\"115\" y=\"197\" text-anchor=\"middle\" fill=\"#9a3412\" font-size=\"12\" font-weight=\"600\">BDR<\/text><rect x=\"250\" y=\"170\" width=\"150\" height=\"44\" rx=\"10\" fill=\"#ffffff\" stroke=\"#cbd5e1\"\/><text x=\"325\" y=\"197\" text-anchor=\"middle\" fill=\"#0f172a\" font-size=\"12\">DROTHER<\/text><rect x=\"460\" y=\"170\" width=\"150\" height=\"44\" rx=\"10\" fill=\"#ffffff\" stroke=\"#cbd5e1\"\/><text x=\"535\" y=\"197\" text-anchor=\"middle\" fill=\"#0f172a\" font-size=\"12\">DROTHER<\/text><rect x=\"670\" y=\"170\" width=\"150\" height=\"44\" rx=\"10\" fill=\"#ffffff\" stroke=\"#cbd5e1\"\/><text x=\"745\" y=\"197\" text-anchor=\"middle\" fill=\"#0f172a\" font-size=\"12\">DROTHER<\/text><line x1=\"115\" y1=\"170\" x2=\"460\" y2=\"132\" stroke=\"#166534\" stroke-width=\"2\" marker-end=\"url(#ar)\"\/><line x1=\"325\" y1=\"170\" x2=\"460\" y2=\"132\" stroke=\"#166534\" stroke-width=\"2\" marker-end=\"url(#ar)\"\/><line x1=\"535\" y1=\"170\" x2=\"460\" y2=\"132\" stroke=\"#166534\" stroke-width=\"2\" marker-end=\"url(#ar)\"\/><line x1=\"745\" y1=\"170\" x2=\"460\" y2=\"132\" stroke=\"#166534\" stroke-width=\"2\" marker-end=\"url(#ar)\"\/><text x=\"460\" y=\"226\" text-anchor=\"middle\" fill=\"#475569\" font-size=\"11\">DROTHERs go Full with DR &amp; BDR only; they stay 2-Way with each other. Election is non-pre-emptive.<\/text><\/svg><\/figure><h2 class=\"wp-block-heading\">5. Cost: the OSPF metric<\/h2><p class=\"wp-block-paragraph\">OSPF has no notion of bandwidth-as-metric the way EIGRP does; it uses a single additive <strong>cost<\/strong> per outgoing interface, <code>cost = reference-bandwidth \/ interface-bandwidth<\/code>, default reference 100 Mbps (10\u2078). So a 10 Mbps link costs 10, FastEthernet costs 1, and \u2014 by default \u2014 Gigabit and 10 Gig both round to <strong>1<\/strong>, which is the classic trap: raise <code>auto-cost reference-bandwidth<\/code> consistently everywhere or OSPF cannot tell a 1G link from a 100G one.<\/p><figure class=\"mkz-diagram\" style=\"margin:24px auto;max-width:920px\"><svg style=\"width:100%;height:auto;display:block;margin:0 auto\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 920 210\" font-family=\"'Segoe UI',Roboto,Helvetica,Arial,sans-serif\" role=\"img\" aria-label=\"OSPF cost formula\"><defs><linearGradient id=\"hg\" x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\"><stop offset=\"0\" stop-color=\"#17263f\"\/><stop offset=\"1\" stop-color=\"#0f172a\"\/><\/linearGradient><marker id=\"ar\" viewBox=\"0 0 10 10\" refX=\"8\" refY=\"5\" markerWidth=\"7\" markerHeight=\"7\" orient=\"auto-start-reverse\"><path d=\"M0 0L10 5L0 10z\" fill=\"#0A66C2\"\/><\/marker><\/defs><rect x=\"0\" y=\"0\" width=\"920\" height=\"210\" rx=\"14\" fill=\"#f8fafc\" stroke=\"#e2e8f0\"\/><rect x=\"0\" y=\"0\" width=\"920\" height=\"60\" rx=\"14\" fill=\"url(#hg)\"\/><rect x=\"0\" y=\"40\" width=\"920\" height=\"20\" fill=\"#0f172a\"\/><text x=\"28\" y=\"37\" fill=\"#ffffff\" font-size=\"19\" font-weight=\"700\">OSPF cost formula<\/text><text x=\"892\" y=\"37\" text-anchor=\"end\" fill=\"#38bdf8\" font-size=\"13\" font-weight=\"600\" letter-spacing=\"1\">NET BY ME<\/text><rect x=\"60\" y=\"86\" width=\"800\" height=\"40\" rx=\"9\" fill=\"#eef2ff\" stroke=\"#c7d2fe\"\/><text x=\"460\" y=\"111\" text-anchor=\"middle\" fill=\"#3730a3\" font-size=\"13\" font-weight=\"700\">cost = reference_bw (default 100 Mbps) \u00f7 interface_bw<\/text><rect x=\"40\" y=\"146\" width=\"180\" height=\"48\" rx=\"9\" fill=\"#ffffff\" stroke=\"#cbd5e1\"\/><text x=\"130\" y=\"168\" text-anchor=\"middle\" fill=\"#0f172a\" font-size=\"12\" font-weight=\"600\">10 Mbps<\/text><text x=\"130\" y=\"186\" text-anchor=\"middle\" fill=\"#C8102E\" font-size=\"12\" font-weight=\"700\">cost 10<\/text><rect x=\"250\" y=\"146\" width=\"180\" height=\"48\" rx=\"9\" fill=\"#ffffff\" stroke=\"#cbd5e1\"\/><text x=\"340\" y=\"168\" text-anchor=\"middle\" fill=\"#0f172a\" font-size=\"12\" font-weight=\"600\">FastEthernet<\/text><text x=\"340\" y=\"186\" text-anchor=\"middle\" fill=\"#C8102E\" font-size=\"12\" font-weight=\"700\">cost 1<\/text><rect x=\"460\" y=\"146\" width=\"180\" height=\"48\" rx=\"9\" fill=\"#ffffff\" stroke=\"#cbd5e1\"\/><text x=\"550\" y=\"168\" text-anchor=\"middle\" fill=\"#0f172a\" font-size=\"12\" font-weight=\"600\">Gigabit<\/text><text x=\"550\" y=\"186\" text-anchor=\"middle\" fill=\"#C8102E\" font-size=\"12\" font-weight=\"700\">cost 1 \u26a0<\/text><rect x=\"670\" y=\"146\" width=\"180\" height=\"48\" rx=\"9\" fill=\"#ffffff\" stroke=\"#cbd5e1\"\/><text x=\"760\" y=\"168\" text-anchor=\"middle\" fill=\"#0f172a\" font-size=\"12\" font-weight=\"600\">10 Gig<\/text><text x=\"760\" y=\"186\" text-anchor=\"middle\" fill=\"#C8102E\" font-size=\"12\" font-weight=\"700\">cost 1 \u26a0<\/text><\/svg><\/figure><p class=\"wp-block-paragraph\"><strong>\u26a0 Expertise:<\/strong> because cost is additive and per-interface, OSPF picks the path with the lowest <em>sum<\/em> of egress costs \u2014 it never load-balances unequally the way EIGRP can. Equal-cost paths (default up to 4) are used; everything else is ignored.<\/p><h2 class=\"wp-block-heading\">6. LSA types \u2014 reading the database like an expert<\/h2><p class=\"wp-block-paragraph\">The LSDB is built from Link-State Advertisements. Knowing the six you meet daily is what separates &#8220;OSPF works&#8221; from &#8220;I can troubleshoot OSPF&#8221;:<\/p><figure class=\"mkz-diagram\" style=\"margin:24px auto;max-width:920px\"><svg style=\"width:100%;height:auto;display:block;margin:0 auto\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 920 370\" font-family=\"'Segoe UI',Roboto,Helvetica,Arial,sans-serif\" role=\"img\" aria-label=\"OSPF LSA types\"><defs><linearGradient id=\"hg\" x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\"><stop offset=\"0\" stop-color=\"#17263f\"\/><stop offset=\"1\" stop-color=\"#0f172a\"\/><\/linearGradient><marker id=\"ar\" viewBox=\"0 0 10 10\" refX=\"8\" refY=\"5\" markerWidth=\"7\" markerHeight=\"7\" orient=\"auto-start-reverse\"><path d=\"M0 0L10 5L0 10z\" fill=\"#0A66C2\"\/><\/marker><\/defs><rect x=\"0\" y=\"0\" width=\"920\" height=\"370\" rx=\"14\" fill=\"#f8fafc\" stroke=\"#e2e8f0\"\/><rect x=\"0\" y=\"0\" width=\"920\" height=\"60\" rx=\"14\" fill=\"url(#hg)\"\/><rect x=\"0\" y=\"40\" width=\"920\" height=\"20\" fill=\"#0f172a\"\/><text x=\"28\" y=\"37\" fill=\"#ffffff\" font-size=\"19\" font-weight=\"700\">OSPF LSA types<\/text><text x=\"892\" y=\"37\" text-anchor=\"end\" fill=\"#38bdf8\" font-size=\"13\" font-weight=\"600\" letter-spacing=\"1\">NET BY ME<\/text><rect x=\"30\" y=\"80\" width=\"860\" height=\"30\" rx=\"6\" fill=\"#0f172a\"\/><rect x=\"30\" y=\"110\" width=\"860\" height=\"40\" fill=\"#f1f5f9\" stroke=\"#e2e8f0\"\/><text x=\"60\" y=\"135\" text-anchor=\"middle\" fill=\"#C8102E\" font-size=\"13\" font-weight=\"700\">1<\/text><text x=\"110\" y=\"135\" fill=\"#0f172a\" font-size=\"12\" font-weight=\"600\">Router<\/text><text x=\"320\" y=\"135\" fill=\"#475569\" font-size=\"11.5\">every router<\/text><text x=\"520\" y=\"135\" fill=\"#334155\" font-size=\"11.5\">intra-area links and cost<\/text><rect x=\"30\" y=\"150\" width=\"860\" height=\"40\" fill=\"#ffffff\" stroke=\"#e2e8f0\"\/><text x=\"60\" y=\"175\" text-anchor=\"middle\" fill=\"#C8102E\" font-size=\"13\" font-weight=\"700\">2<\/text><text x=\"110\" y=\"175\" fill=\"#0f172a\" font-size=\"12\" font-weight=\"600\">Network<\/text><text x=\"320\" y=\"175\" fill=\"#475569\" font-size=\"11.5\">DR only<\/text><text x=\"520\" y=\"175\" fill=\"#334155\" font-size=\"11.5\">the multi-access segment and its routers<\/text><rect x=\"30\" y=\"190\" width=\"860\" height=\"40\" fill=\"#f1f5f9\" stroke=\"#e2e8f0\"\/><text x=\"60\" y=\"215\" text-anchor=\"middle\" fill=\"#C8102E\" font-size=\"13\" font-weight=\"700\">3<\/text><text x=\"110\" y=\"215\" fill=\"#0f172a\" font-size=\"12\" font-weight=\"600\">Summary<\/text><text x=\"320\" y=\"215\" fill=\"#475569\" font-size=\"11.5\">ABR<\/text><text x=\"520\" y=\"215\" fill=\"#334155\" font-size=\"11.5\">inter-area prefixes (area \u2192 area)<\/text><rect x=\"30\" y=\"230\" width=\"860\" height=\"40\" fill=\"#ffffff\" stroke=\"#e2e8f0\"\/><text x=\"60\" y=\"255\" text-anchor=\"middle\" fill=\"#C8102E\" font-size=\"13\" font-weight=\"700\">4<\/text><text x=\"110\" y=\"255\" fill=\"#0f172a\" font-size=\"12\" font-weight=\"600\">ASBR-Summary<\/text><text x=\"320\" y=\"255\" fill=\"#475569\" font-size=\"11.5\">ABR<\/text><text x=\"520\" y=\"255\" fill=\"#334155\" font-size=\"11.5\">how to reach the ASBR<\/text><rect x=\"30\" y=\"270\" width=\"860\" height=\"40\" fill=\"#f1f5f9\" stroke=\"#e2e8f0\"\/><text x=\"60\" y=\"295\" text-anchor=\"middle\" fill=\"#C8102E\" font-size=\"13\" font-weight=\"700\">5<\/text><text x=\"110\" y=\"295\" fill=\"#0f172a\" font-size=\"12\" font-weight=\"600\">External<\/text><text x=\"320\" y=\"295\" fill=\"#475569\" font-size=\"11.5\">ASBR<\/text><text x=\"520\" y=\"295\" fill=\"#334155\" font-size=\"11.5\">redistributed routes, flooded domain-wide<\/text><rect x=\"30\" y=\"310\" width=\"860\" height=\"40\" fill=\"#ffffff\" stroke=\"#e2e8f0\"\/><text x=\"60\" y=\"335\" text-anchor=\"middle\" fill=\"#C8102E\" font-size=\"13\" font-weight=\"700\">7<\/text><text x=\"110\" y=\"335\" fill=\"#0f172a\" font-size=\"12\" font-weight=\"600\">NSSA External<\/text><text x=\"320\" y=\"335\" fill=\"#475569\" font-size=\"11.5\">ASBR in NSSA<\/text><text x=\"520\" y=\"335\" fill=\"#334155\" font-size=\"11.5\">external routes inside an NSSA<\/text><text x=\"60\" y=\"100\" fill=\"#fff\" font-size=\"11\" font-weight=\"700\">Type<\/text><text x=\"110\" y=\"100\" fill=\"#fff\" font-size=\"11\" font-weight=\"700\">LSA<\/text><text x=\"320\" y=\"100\" fill=\"#fff\" font-size=\"11\" font-weight=\"700\">Originated by<\/text><text x=\"520\" y=\"100\" fill=\"#fff\" font-size=\"11\" font-weight=\"700\">Describes<\/text><\/svg><\/figure><h2 class=\"wp-block-heading\">7. Area types \u2014 controlling what floods where<\/h2><p class=\"wp-block-paragraph\">Stub-area flavours trade visibility for a smaller database. The rule to memorise: stub areas block <strong>Type 5 externals<\/strong> and inject a default; totally-stubby also blocks <strong>Type 3 inter-area<\/strong>; NSSA re-allows externals but carries them as <strong>Type 7<\/strong>, which the ABR translates back to Type 5 on the way to the backbone.<\/p><figure class=\"mkz-diagram\" style=\"margin:24px auto;max-width:920px\"><svg style=\"width:100%;height:auto;display:block;margin:0 auto\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 920 260\" font-family=\"'Segoe UI',Roboto,Helvetica,Arial,sans-serif\" role=\"img\" aria-label=\"OSPF area types\"><defs><linearGradient id=\"hg\" x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\"><stop offset=\"0\" stop-color=\"#17263f\"\/><stop offset=\"1\" stop-color=\"#0f172a\"\/><\/linearGradient><marker id=\"ar\" viewBox=\"0 0 10 10\" refX=\"8\" refY=\"5\" markerWidth=\"7\" markerHeight=\"7\" orient=\"auto-start-reverse\"><path d=\"M0 0L10 5L0 10z\" fill=\"#0A66C2\"\/><\/marker><\/defs><rect x=\"0\" y=\"0\" width=\"920\" height=\"260\" rx=\"14\" fill=\"#f8fafc\" stroke=\"#e2e8f0\"\/><rect x=\"0\" y=\"0\" width=\"920\" height=\"60\" rx=\"14\" fill=\"url(#hg)\"\/><rect x=\"0\" y=\"40\" width=\"920\" height=\"20\" fill=\"#0f172a\"\/><text x=\"28\" y=\"37\" fill=\"#ffffff\" font-size=\"19\" font-weight=\"700\">OSPF area types<\/text><text x=\"892\" y=\"37\" text-anchor=\"end\" fill=\"#38bdf8\" font-size=\"13\" font-weight=\"600\" letter-spacing=\"1\">NET BY ME<\/text><rect x=\"30\" y=\"86\" width=\"200\" height=\"150\" rx=\"11\" fill=\"#ffffff\" stroke=\"#0A66C2\" stroke-width=\"1.4\"\/><rect x=\"30\" y=\"86\" width=\"200\" height=\"34\" rx=\"11\" fill=\"#e0f2fe\"\/><text x=\"130\" y=\"108\" text-anchor=\"middle\" fill=\"#0f172a\" font-size=\"12.5\" font-weight=\"700\">Standard<\/text><text x=\"130\" y=\"150\" text-anchor=\"middle\" fill=\"#334155\" font-size=\"11\">LSAs allowed<\/text><text x=\"130\" y=\"172\" text-anchor=\"middle\" fill=\"#C8102E\" font-size=\"12\" font-weight=\"700\">1,2,3,4,5<\/text><text x=\"130\" y=\"212\" text-anchor=\"middle\" fill=\"#64748b\" font-size=\"10.5\">full visibility<\/text><rect x=\"250\" y=\"86\" width=\"200\" height=\"150\" rx=\"11\" fill=\"#ffffff\" stroke=\"#0A66C2\" stroke-width=\"1.4\"\/><rect x=\"250\" y=\"86\" width=\"200\" height=\"34\" rx=\"11\" fill=\"#e0f2fe\"\/><text x=\"350\" y=\"108\" text-anchor=\"middle\" fill=\"#0f172a\" font-size=\"12.5\" font-weight=\"700\">Stub<\/text><text x=\"350\" y=\"150\" text-anchor=\"middle\" fill=\"#334155\" font-size=\"11\">LSAs allowed<\/text><text x=\"350\" y=\"172\" text-anchor=\"middle\" fill=\"#C8102E\" font-size=\"12\" font-weight=\"700\">1,2,3 + default<\/text><text x=\"350\" y=\"212\" text-anchor=\"middle\" fill=\"#64748b\" font-size=\"10.5\">no Type 5<\/text><rect x=\"470\" y=\"86\" width=\"200\" height=\"150\" rx=\"11\" fill=\"#ffffff\" stroke=\"#0A66C2\" stroke-width=\"1.4\"\/><rect x=\"470\" y=\"86\" width=\"200\" height=\"34\" rx=\"11\" fill=\"#e0f2fe\"\/><text x=\"570\" y=\"108\" text-anchor=\"middle\" fill=\"#0f172a\" font-size=\"12.5\" font-weight=\"700\">Totally Stubby<\/text><text x=\"570\" y=\"150\" text-anchor=\"middle\" fill=\"#334155\" font-size=\"11\">LSAs allowed<\/text><text x=\"570\" y=\"172\" text-anchor=\"middle\" fill=\"#C8102E\" font-size=\"12\" font-weight=\"700\">1,2 + default<\/text><text x=\"570\" y=\"212\" text-anchor=\"middle\" fill=\"#64748b\" font-size=\"10.5\">no 3,4,5<\/text><rect x=\"690\" y=\"86\" width=\"200\" height=\"150\" rx=\"11\" fill=\"#ffffff\" stroke=\"#0A66C2\" stroke-width=\"1.4\"\/><rect x=\"690\" y=\"86\" width=\"200\" height=\"34\" rx=\"11\" fill=\"#e0f2fe\"\/><text x=\"790\" y=\"108\" text-anchor=\"middle\" fill=\"#0f172a\" font-size=\"12.5\" font-weight=\"700\">NSSA<\/text><text x=\"790\" y=\"150\" text-anchor=\"middle\" fill=\"#334155\" font-size=\"11\">LSAs allowed<\/text><text x=\"790\" y=\"172\" text-anchor=\"middle\" fill=\"#C8102E\" font-size=\"12\" font-weight=\"700\">1,2,3,7 + default<\/text><text x=\"790\" y=\"212\" text-anchor=\"middle\" fill=\"#64748b\" font-size=\"10.5\">Type 7 instead of 5<\/text><\/svg><\/figure><h2 class=\"wp-block-heading\">8. The SPF algorithm itself<\/h2><p class=\"wp-block-paragraph\">Finally, the engine. Each router puts itself at the root and runs <strong>Dijkstra<\/strong>: it repeatedly moves the lowest-cost candidate from the tentative list onto the shortest-path tree, relaxing its neighbours. The result is a loop-free tree of lowest-cost paths to every prefix. Because every router in an area shares the same LSDB, their trees are consistent \u2014 which is <em>why<\/em> link-state does not form routing loops inside an area.<\/p><figure class=\"mkz-diagram\" style=\"margin:24px auto;max-width:920px\"><svg style=\"width:100%;height:auto;display:block;margin:0 auto\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 920 240\" font-family=\"'Segoe UI',Roboto,Helvetica,Arial,sans-serif\" role=\"img\" aria-label=\"OSPF SPF shortest-path tree\"><defs><linearGradient id=\"hg\" x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\"><stop offset=\"0\" stop-color=\"#17263f\"\/><stop offset=\"1\" stop-color=\"#0f172a\"\/><\/linearGradient><marker id=\"ar\" viewBox=\"0 0 10 10\" refX=\"8\" refY=\"5\" markerWidth=\"7\" markerHeight=\"7\" orient=\"auto-start-reverse\"><path d=\"M0 0L10 5L0 10z\" fill=\"#0A66C2\"\/><\/marker><\/defs><rect x=\"0\" y=\"0\" width=\"920\" height=\"240\" rx=\"14\" fill=\"#f8fafc\" stroke=\"#e2e8f0\"\/><rect x=\"0\" y=\"0\" width=\"920\" height=\"60\" rx=\"14\" fill=\"url(#hg)\"\/><rect x=\"0\" y=\"40\" width=\"920\" height=\"20\" fill=\"#0f172a\"\/><text x=\"28\" y=\"37\" fill=\"#ffffff\" font-size=\"19\" font-weight=\"700\">OSPF SPF shortest-path tree<\/text><text x=\"892\" y=\"37\" text-anchor=\"end\" fill=\"#38bdf8\" font-size=\"13\" font-weight=\"600\" letter-spacing=\"1\">NET BY ME<\/text><circle cx=\"110\" cy=\"150\" r=\"26\" fill=\"#0f172a\"\/><text x=\"110\" y=\"155\" text-anchor=\"middle\" fill=\"#fff\" font-size=\"12\" font-weight=\"700\">ROOT<\/text><circle cx=\"320\" cy=\"100\" r=\"22\" fill=\"#e0f2fe\" stroke=\"#0A66C2\"\/><text x=\"320\" y=\"105\" text-anchor=\"middle\" fill=\"#0f172a\" font-size=\"12\" font-weight=\"600\">A<\/text><circle cx=\"320\" cy=\"200\" r=\"22\" fill=\"#e0f2fe\" stroke=\"#0A66C2\"\/><text x=\"320\" y=\"205\" text-anchor=\"middle\" fill=\"#0f172a\" font-size=\"12\" font-weight=\"600\">B<\/text><circle cx=\"540\" cy=\"100\" r=\"22\" fill=\"#e0f2fe\" stroke=\"#0A66C2\"\/><text x=\"540\" y=\"105\" text-anchor=\"middle\" fill=\"#0f172a\" font-size=\"12\" font-weight=\"600\">C<\/text><circle cx=\"540\" cy=\"200\" r=\"22\" fill=\"#e0f2fe\" stroke=\"#0A66C2\"\/><text x=\"540\" y=\"205\" text-anchor=\"middle\" fill=\"#0f172a\" font-size=\"12\" font-weight=\"600\">D<\/text><circle cx=\"760\" cy=\"150\" r=\"22\" fill=\"#dcfce7\" stroke=\"#166534\"\/><text x=\"760\" y=\"155\" text-anchor=\"middle\" fill=\"#0f172a\" font-size=\"12\" font-weight=\"600\">E<\/text><line x1=\"136\" y1=\"138\" x2=\"298\" y2=\"108\" stroke=\"#0A66C2\" stroke-width=\"2.5\"\/><text x=\"210\" y=\"112\" fill=\"#C8102E\" font-size=\"11\" font-weight=\"700\">1<\/text><line x1=\"136\" y1=\"162\" x2=\"298\" y2=\"192\" stroke=\"#0A66C2\" stroke-width=\"2.5\"\/><text x=\"210\" y=\"192\" fill=\"#C8102E\" font-size=\"11\" font-weight=\"700\">1<\/text><line x1=\"342\" y1=\"100\" x2=\"518\" y2=\"100\" stroke=\"#0A66C2\" stroke-width=\"2.5\"\/><text x=\"430\" y=\"92\" fill=\"#C8102E\" font-size=\"11\" font-weight=\"700\">1<\/text><line x1=\"342\" y1=\"200\" x2=\"518\" y2=\"200\" stroke=\"#0A66C2\" stroke-width=\"2.5\"\/><text x=\"430\" y=\"220\" fill=\"#C8102E\" font-size=\"11\" font-weight=\"700\">1<\/text><line x1=\"562\" y1=\"108\" x2=\"740\" y2=\"142\" stroke=\"#0A66C2\" stroke-width=\"2.5\"\/><line x1=\"562\" y1=\"192\" x2=\"740\" y2=\"158\" stroke=\"#cbd5e1\" stroke-width=\"2\" stroke-dasharray=\"5 3\"\/><text x=\"460\" y=\"232\" text-anchor=\"middle\" fill=\"#475569\" font-size=\"11\">Shortest-path tree from ROOT; dashed = higher-cost path pruned by SPF<\/text><\/svg><\/figure><h2 class=\"wp-block-heading\">Takeaway<\/h2><p class=\"wp-block-paragraph\">OSPF is simple to say and deep to master: flood identical link-state, build one database per area, run Dijkstra. Everything advanced \u2014 areas, LSA types, stub flavours, cost tuning \u2014 is just <em>controlling what enters that database and how far it floods<\/em>. Get that mental model and the CLI stops surprising you.<\/p><p class=\"wp-block-paragraph\"><em>Generic, vendor-neutral fundamentals from my own study and labs. No client- or employer-specific configuration.<\/em><\/p>","protected":false},"excerpt":{"rendered":"<p>From zero to expert. OSPF (Open Shortest Path First) is the link-state IGP you meet on day one and keep meeting for the rest of your career. This guide starts with the absolute basics \u2014 what link-state means \u2014 and finishes on LSA types, area behaviour and the SPF algorithm itself. Almost every idea gets<\/p><\/div>\n<div class=\"blog-btn\"><a href=\"https:\/\/mokrane-assam.com\/index.php\/2019\/02\/18\/ospf-basics-from-neighbors-to-the-spf-tree\/\" class=\"home-blog-btn\">Read More<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[24],"tags":[],"class_list":["post-166","post","type-post","status-publish","format-standard","hentry","category-basic"],"_links":{"self":[{"href":"https:\/\/mokrane-assam.com\/index.php\/wp-json\/wp\/v2\/posts\/166","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mokrane-assam.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mokrane-assam.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mokrane-assam.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mokrane-assam.com\/index.php\/wp-json\/wp\/v2\/comments?post=166"}],"version-history":[{"count":1,"href":"https:\/\/mokrane-assam.com\/index.php\/wp-json\/wp\/v2\/posts\/166\/revisions"}],"predecessor-version":[{"id":167,"href":"https:\/\/mokrane-assam.com\/index.php\/wp-json\/wp\/v2\/posts\/166\/revisions\/167"}],"wp:attachment":[{"href":"https:\/\/mokrane-assam.com\/index.php\/wp-json\/wp\/v2\/media?parent=166"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mokrane-assam.com\/index.php\/wp-json\/wp\/v2\/categories?post=166"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mokrane-assam.com\/index.php\/wp-json\/wp\/v2\/tags?post=166"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}