SPF algorithm Calculation Process--Example Network

Source: Internet
Author: User
http://golehuang.blog.51cto.com/7499/920865

When the link state routing algorithm constructs the LSDB, the next verse calls the SPF algorithm, processes the LSA in the LSDB, and calculates all the paths. The SPF algorithm is described in the OSPF section of the Routing TCP/IP volmun I.

The SPF algorithm is described briefly as follows (Lsdb has converged):

First, select the root node;/----Regardless of which node is the root node, the resulting spanning tree should be the same (i.e., the weights of each node to the other node will not change)

Second, traverse all direct-attached nodes of the selected node. During traversal, the Jogen and the branch of a node are

L New Branch, then add the branch to the branch list, and record the branch weight, the root of the next jump;

L already exists in the branch list, it is better than the weight value of the branch that already exists in the branch list, and the superior value is updated to the branch list;

L already exist in the weight list, then ignore;

The best branch of the branch list is moved out to the weight list, and the node of the branch is selected;

If the branch list is not empty, proceed to step three, otherwise the algorithm ends.

After the algorithm is finished, the weight list is the shortest path tree, which is used to generate the routing table or other follow-up work.

Here is a simple example, the arrow direction for the node configuration link weight (metric), pay attention to the weight is one-way, modify the weight in general to ensure that both ends consistent. A for the node running the SPF algorithm, LSDB has converged:

* The following display meaning is the node (next hop) weight

First, the SPF put A, B, C, D, E, F, G, h to not traverse the state, and the node (R1) as the root. Add a (a) to the weight list with a weight of 0 and the next hop to a. It then iterates through a's direct-link node B, c, D, and adds B (b) 50,c (c) 85,d (d) 20 to the branch list. The weight of D (d) is the best, and is 20. Add d (d) to the weight list, with a weight of 20, the next jump to D, and select D;

Second, traverse D all connected nodes. Here D-b 20,d-c 20,d-g 20,d-h 20. In the branch list, B (b) is changed from 50 to 40, the next hop to D;c (c) from 85 to 40, and the next to D; add g (d) 40,h (d) 40. The branch list includes: B (d) 40,c (d) 40,g (d) 40,h (d) 40. Add B (d) to the weight list, the weight is 40, the next jump to D, and select B;

Third, traverse b all connected nodes. This branch is B-E 80,b-d 20, because D has been added to the weight list and is no longer considered. Add e (d) 120 to the branch list. The branch list contains: C (d) 40,g (d) 40,h (d) 40,e (d) 120. Add C (d) to the weight list, the weight is 40, the next jump to D, and selected C;

Four, traverse C. This branch is C-f 20,c-d 20, since D has been added to the weight list and is no longer considered. The branch list adds F (d) 60. The branch list contains: g (d) 40,h (d) 40,e (d) 120,f (d) 60. Add g (d) to the weight list, the weight is 40, the next jump to D, and select G;

V. Traversal of G. G Branch for G-e 20,g-h 50. Branch List Modify E (d) 60. The branch list contains: h (d) 40,e (d) 60,f (d) 60. Add h (d) to the weight list, the weight is 40, the next jump to D, and select H;

Six, traverse H. H Branch for H-g 50,h-f 20. G has been added to the weight list, not considered; while A-d-c-f and A-d-h-f are 60 and the next hop is D, there is no difference between the new branch and the branch in the branch list. The branch list contains: E (d) 60,f (d) 60. Add e (d) to the weight list, the weight is 60, the next jump to D, and select E;

Seven, traverse E. Branch for E-b 80,e-g 20, because B, G has been in the weight list, the branch list does not need to change, for F (d) 60. Add F (d) to the weight list with a weight of 60 and the next hop to D.

Because the list of branches is empty, the SPF algorithm ends. Then the weight list is:

Node

A

D

B

C

G

E

F

Weight

A

D

D

D

D

D

D

Next jump

0

20

40

40

40

60

60

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.