Anda di halaman 1dari 7

Shahin Ahmed Laskar

(CCIE R&S Preparation Notes) HOW OSPF ROUTERS CALCULATE BEST PATH FOR EACH DESTINATION USING SPF ALGORITHM:

Before start the SPF algorithm, lets take a look what is SPF?????? SPF Algorithm: OSPF uses the Shortest-Path-First (SPF) algorithm, also referred to as the Dijkstra algorithm, to determine the route to reach each destination. As we all know, OSPF is link state protocol. Now what is Link State Protocol. Lets take look Link State Protocol: Link State Protocol is one of the two main classes of routing protocol used in packet switched network which works based on building a map of connected links (also called graph) to all other nodes & share it with adjacent nodes. Each node then calculate the best path & best path will be installed into the routing table. Now we will look at our topology & will try to explore some of the concept we discussed here. Here we go. OSPF is enable on R1, R2 & R3. Once we enable the OSPF, each will start establishing NEIGHBOR relationship with directly connected Router (Must be OSPF enable Router). Once all the condition is match for NEIGHBOR relationship, router will transition through different OSPF neighbor state & subsequently they will exchange the database which is called LSDB (Link State Database). Once the LSDB exchange is done, each router will start SPF algorithm & will calculate the best path & best path will install in the Routing table as you can see in the pic.. Routing table of R1. Lets explore it by the use of LSDB info & IOS Commands: LETS CHECK HOW R1 CALCULATE THE BEST PATH TO REACH 30.1.1.1 (which is in Area 1).

First find out the longest match prefix for 30.1.1.1/8


R1#show ip route 30.1.1.1 Routing entry for 30.0.0.0/8 Known via "ospf 1", distance 110, metric 3, type inter area Last update from 10.1.12.2 on FastEthernet0/0, 00:03:21 ago

Routing Descriptor Blocks: * 10.1.12.2, from 2.2.2.2, 00:03:21 ago, via FastEthernet0/0 Route metric is 3, traffic share count is 1 NOTE: From the above output, we can see that LONGEST MATCH is 30.0.0.0/8 which is reachable via Next-hop address 10.1.12.2 & from 2.2.2.2 (Which is RID of R2) & Route type is INTER AREA. That means ABR (In our case R2) originating Network Summary LSA (LSA 3) from Area 1 into Area 0.

Find out from where Router R1 receiving LSA 3. This we can check by the use of OSPF DATABASE, here is it
R1#show ip ospf database summary 30.0.0.0

OSPF Router with ID (1.1.1.1) (Process ID 1) Summary Net Link States (Area 0) Routing Bit Set on this LSA LS age: 1702 Options: (No TOS-capability, DC, Upward) LS Type: Summary Links(Network) Link State ID: 30.0.0.0 (summary Network Number) Advertising Router: 2.2.2.2 LS Seq Number: 80000001 Checksum: 0xD93B Length: 28 Network Mask: /8 TOS: 0 Metric: 2 NOTE: From the above output, we can see that Advertising Router: 2.2.2.2 which is nothing but our R2 i.e. ABR is forwarding information to R1. One of the most important info is here in the last line of the above output is METRIC which is 2. DONT CONFUSED, THIS IS NOT THE END-TO-END COST calculated by the R1. IT IS THE COST CALCULATED BY ABR i.e. R2 TO THE DESTINATION NETWORK which is 30.0.00/8

Next Router R1 will run the SPF algorithm to find out the best path to reach the ABR which is nothing but our Router R2.

So lets see, R1 connectivity by the use of LSA 1 & we will col lect info from OSPF Database. Here it is . R1#show ip ospf database router 1.1.1.1 OSPF Router with ID (1.1.1.1) (Process ID 1) Router Link States (Area 0) LS age: 411 Options: (No TOS-capability, DC) LS Type: Router Links Link State ID: 1.1.1.1 Advertising Router: 1.1.1.1 LS Seq Number: 80000001 Checksum: 0x9366 Length: 36 Number of Links: 1 Link connected to: a Transit Network (Link ID) Designated Router address: 10.1.12.2 (Link Data) Router Interface address: 10.1.12.1 Number of TOS metrics: 0 TOS 0 Metrics: 1 NOTE: From the above output, we can see that R1 is connected on a BROADCAST network where DR/BDR election takes place. So DR on this segment is 10.1.12.2 (Which is R2s Fa0/0) & most important info is COST which 1 (as you can see in the last line of the above output).

For more verification, you can see the LSA 2 info from R1 & make sure that your router is also connected on this segment here it is.. R1#show ip ospf database network 10.1.12.2 OSPF Router with ID (1.1.1.1) (Process ID 1) Net Link States (Area 0) Routing Bit Set on this LSA LS age: 1358 Options: (No TOS-capability, DC)

LS Type: Network Links Link State ID: 10.1.12.2 (address of Designated Router) Advertising Router: 2.2.2.2 LS Seq Number: 80000001 Checksum: 0xB25A Length: 32 Network Mask: /24 Attached Router: 2.2.2.2 Attached Router: 1.1.1.1 NOTE: From the above output, we can see that 1.1.1.1 (i.e. R1) is attached with DR which is none other than our beloved R2 hahahahaha CONCLUSION: R1 CAN REACH THE R2 (WHICH IS ABR & ADVERTISING THE NETWORK 30.0.0.0/8 INTO AREA 0) & ASSOCIATED COST IS 1 (ONE).

(R1 ====== R2) ========== COST 1 (as seen from the above out)
Now we reach up to ABR i.e. R2. Now R2 is responsible for calculating the best path to reach the network 30.0.0.0/8. That means R1 is depending on R2s best path selection which is SORT O F DISTANCE VECTOR PROTOCOL CHARACTERISTICS. Thats why OSPF is sometime called as Partial DISTANCE VECTOR & partial LINK STATE.

Now lets take a look on R2s OSPF database & see the LSA 1 info.
R2#show ip ospf database router 2.2.2.2 self-originate OSPF Router with ID (2.2.2.2) (Process ID 1) Router Link States (Area 0) LS age: 1602 Options: (No TOS-capability, DC) LS Type: Router Links Link State ID: 2.2.2.2 Advertising Router: 2.2.2.2 LS Seq Number: 80000003 Checksum: 0x5499 Length: 36 Area Border Router

Number of Links: 1 Link connected to: a Transit Network (Link ID) Designated Router address: 10.1.12.2 (Link Data) Router Interface address: 10.1.12.2 Number of TOS metrics: 0 TOS 0 Metrics: 1 Router Link States (Area 1) LS age: 1571 Options: (No TOS-capability, DC) LS Type: Router Links Link State ID: 2.2.2.2 Advertising Router: 2.2.2.2 LS Seq Number: 80000002 Checksum: 0x5384 Length: 36 Area Border Router Number of Links: 1 Link connected to: a Transit Network (Link ID) Designated Router address: 10.1.23.3 (Link Data) Router Interface address: 10.1.23.2 Number of TOS metrics: 0 TOS 0 Metrics: 1 NOTE: From the above output, we can see that R2 (Router Interface address: 10.1.23.2) is connect with R 3 which is DR (Designated Router address: 10.1.23.3) & associated metric is 1 (one). CONCLUSION: R2 CAN REACH THE R3 (WHICH IS ON AREA 1 & ADVERTISING THE NETWORK 30.0.0.0/8 INTO AREA 1) & ASSOCIATED COST IS 1 (ONE).

(R2 ====== R3) ========== COST 2 (as seen from the above out). WHAT IS TOTAL COST SO FAR: (R1 R2) + (R2 R3) i.e. (1+1) = 2. Total cost is 2.

Now check the LSA 1 info in R3 & Check the Cost to reach 30.0.0.0/8. Here it is (You can check it from R2 or R3):

R2# show ip ospf database router 3.3.3.3 OSPF Router with ID (2.2.2.2) (Process ID 1) Router Link States (Area 1) LS age: 76 Options: (No TOS-capability, DC) LS Type: Router Links Link State ID: 3.3.3.3 Advertising Router: 3.3.3.3 LS Seq Number: 80000004 Checksum: 0xDDC0 Length: 48 Number of Links: 2 Link connected to: a Stub Network (Link ID) Network/subnet number: 30.0.0.0 (Link Data) Network Mask: 255.0.0.0 Number of TOS metrics: 0 TOS 0 Metrics: 1 Link connected to: a Transit Network (Link ID) Designated Router address: 10.1.23.3 (Link Data) Router Interface address: 10.1.23.3 Number of TOS metrics: 0 TOS 0 Metrics: 1

From the Above output, we can see that COST TO REACH 30.0.0.0/8 network is 1 (one).

WHAT IS TOTAL COST: (R1 R2) + (R2 R3) + (R3 to 30.0.0.0/8) i.e. (1+1+1) = 3. Total cost is 3.

Here I wanna mention one thing, for INTER AREA Routes cost is calculated like this Total Cost for Destination = (Least Cost to reach ABR) + (ABR to Destination) So if we apply the same then Total Cost for Destination = (Least Cost to reach ABR) + (ABR to Destination) =1 +2 = 3.
Lets verify the Routing table of R1: R1#show ip route ospf | include 30.0 O IA 30.0.0.0/8 [110/3] via 10.1.12.2, 00:26:02, FastEthernet0/0

Anda mungkin juga menyukai