OSPF工作原理

send hello packet ===》建立邻接关系ajdency===》形成链路状态数据库===》SPF算法===》形成router table

neighbor : if two routers share a common data link agree on certain parameters specified in thier respective hello packets, they will become neighbor.

  • LSAs(send over all adjacentires); describle all of the router's links or interfaces ,and the state of the links.each router receiving an LSA from a neighbor records the LSA in its LSDB and send a copy of the LSA to all of its other neighbor.
  • by flooding the LSA through the area , all routers will build the identical LSDB.
  • when database completed , each router use SPF to calculate the shortest path.

hello protocol :

  • the means by which neighbors are discovered.

  • advertises serveral parameters on which two ruters must agree before they can become neighbors.

  • acts as keepalives between neighbors. (10s)

  • ensure bi-directional communication between neighbors.

  • elect DR and BDRs on broadcast and Nonbroadcast Multi-access(NBMA) networks.

hello 包 包含哪些成分:

router ID, area ID, hello interval, dead interval, router priority,DR,BDR, neighbor router ID

邻居(neighbor)和邻接(adjacency)的不同:

two OSPF routers are neighbors if they are connected to the same subnet and share a series of common configuration information:

  • Same Area ID
  • Same Area type
  • Same subnet mask
  • Same timers
  • Same authentication
  • They see their own OSPF RID in each other's Hello packet

two OSPF neighbors do not exchange any routing information- the only packets they exchange is Hello packets.

When 2 routers are connected via a link, they start to share hello's. And if their parameter's match, they become neighbors, i.e 2-way state.

OSPF adjacency is formed betwen selected neighbors and allows them to exchange routing information. So, two routers must first be neighbors, only then they can become adjacent. Two routers become adjacent if:

  • At least one of them is DR or BDR (on multiaccess type networks), or
  • They are interconnected by a point-to-point or point-to-multipoint network type

So, to sum it up, OSPF neighbors are simply routers that sit on the same segment and hear each other, but they do not engage in any closer cooperation. OSPF adjacent routers exchange routing information,exchange LSU,DD packet, exchange full LSDB.

DR(based on interfces , not the enire router,BDR选举过程(why need to select DR,BDR):

reduce the unnessary LSAs, prevent creating many copies of the same LSA on the same network.

router priority : 8-bit interger range from 0~255,default is 1 ,higher is better , if the value is 0 , it is ineligible to become DR or BDR.

  1. 在和邻居建立双向通信(two-way)之后,检查邻居的Hello包中Priority,DR和BDR字段,列出所有可以参与DR/BDR选举的邻居( priority larger than 0 and state at least two way) .所有的路由器声明它们自己就是DR/BDR(Hello包中DR字段的值就是它们自己的接口地址;BDR字段的值就是它们自己的接口地址)

  2. 从这个有参与选举DR/BDR权的列表中,创建一组没有声明自己就是DR的路由器的子集(声明自己是DR的路由器将不会被选举为BDR)

  3. 如果在这个子集里,不管有没有宣称自己就是BDR,只要在Hello包中BDR字段就等于自己接口的地址,优先级最高的就被选举为BDR;如果优先级都一样,RID最高的选举为BDR

  4. 如果在Hello包中DR字段就等于自己接口的地址,优先级最高的就被选举为DR;如果优先级都一样,RID最高的选举为DR;如果没有路由器宣称自己就是DR,那么新选举的BDR就成为DR

  5. 要注意的是,当网络中已经选举了DR/BDR后,又出现了1台新的优先级更高的路由器,DR/BDR是不会重新选举的

  6. DR/BDR选举完成后,其他Rother只和DR/BDR形成邻接关系.所有的路由器将组播Hello包到224.0.0.5,以便它们能跟踪其他邻居的信息.其他Rother只组播update packet到224.0.0.6,只有DR/BDR监听这个地址 .一旦出问题,反过来,DR将使用224.0.0.5泛洪更新到其他路由器

when an ospf router becomes active and discovers its neighbors, it check for an active DR and BDR , if a DR and BDR exist, the router accepts them, if there is no BDR ,an election is held in which the router with the highest priority becomes the BDR, if more than one routers has the same priority , the one with the highest router ID wins, if there is no active DR , the BDR will promoted to DR and a new election id held for BDR.

note : a router with higher priority will not take over the DR or BDR once the DR has been elected.

all routers multicast hello to the AllSPFRouters address 224.0.0.5 to track the neighbors.

Dothers multicast the update packet to address 224.0.0.6 which only DR and BDR ca nreceive.

DR will flood the update to the DRothers on 224.0.0.5.

Master and Slave election process(exstart) :

The Database Description packet is of particular importance to the adjacency-building process. As the name implies, the packets carry a summary description of each LSA in the originating router’s link-state database. Three flags in the DD packet are used to manage the adjacency building process:

  1. The I-bit, or Initial bit, which when set indicates the first DD packet sent
  2. The M-bit, or More bit, which when set indicates that this is not the last DD packet to be sent
  3. The MS-bit, or Master/Slave bit, which is set in the DD packets originated by the master

When the master/slave negotiation begins in the ExStart state, both neighbors will claim to be the master by sending an empty DD packet with the MS-bit set to one. The DD sequence number in these two packets will be set to the originating router’s idea of what the sequence number should be. The neighbor with the lower Router ID will become the slave and will reply with a DD packet in which the MS-bit is zero and the DD sequence number is set to the master’s sequence number. When the master/slave negotiation is completed, the neighbor state transitions to Exchange.

ospf state:

Down: no hello have been heard from the neighbor in the last dead interval

Attempt: only applied on NBMA betwork ,where neoghbors are manually configured.

Init:

two way : if a router receives a valid hello(parameter matches) in which it finds its own router ID listed, the router knows that two-way has been established.

exstart: router and the neighbor establish a master(highest interface address )/slave relationship and determine the initial DD sequence number in prepariation for the exchange of DBD packets. master/slave negociate completed.

exchange : send DBD packets (listed LSA headers) describing its entire link state satabase t oneighbors that are in the exchange state.the route may also send LSR to request more recent LSAs to neighbors.

If a router sees that its neighbor has a LSA that is not in its databases it will place the LSA on the Link State Request list. It then sends a Link State Request packet asking for a complete copy of theLSA in question.

All LSAs sent in Update packets must be individually acknowledged.

Loading : router will send LSR to neighbor that are in the laoding state, requesting more recent LSAs that have been discovered in the exchange state but have not yest been received.

Full: fully adjacent, and the adjacencies will appear in router LSA and network LSAs

RT1 becomes active and sends a Hello. At this point, RT1 hasn’t seen any neighbors, so it reports such and sets its DR and BDR fields to 0.0.0.0.

  1. Upon receipt by RT2, RT2 will build a data structure for RT1 and set RT1’s state to Init RT2 will then send a Hello packet reporting that it has seen RT1, and will report itself as the DR.
  2. RT1 now sees its own RID in the received Hello packet from RT2, so RT1 will now create a data structure for RT2 and set its state to ExStart RT1 then begins Master/Slave negotiation with a DD packet with a sequence number of “x”, the Init bit set to indicate that it is the start of an exchange, the More bit set to indicate that it is not the last DD packet to be sent, and lastly with the MS-bit set to indicate that RT1 wants to be the Master. No LSA summaries are provided just yet – this is purely for Master/Slave negotiation.
  3. Upon receipt of RT1’s DD packet, RT2 sets RT1’s state to ExStart. RT2 then sends a DD with a sequence number of “y”, and the MS-bit set since RT2 has a higher RID in this example.
  4. RT1 agrees that RT2 is the Master and sets its state to Exchange. RT1 informs RT2 of its agreement by sending a DD packet with a sequence number “y” that matches what was sent from RT2 in step 4. The MS-bit will now be set to 0, and here is where we’ll start to see LSA summaries provided by RT1.
  5. RT2 now sets RT1’s state to Exchange as well and sends a DD packet containing LSA headers from its Link State Summary list and increments the DD sequence number to “y+1”.
  6. RT1 acknowledges this by sending an acknowledgement with the same sequence number that it received in the DD packet from RT2. It also begins taking the LSA summaries it received and building a Link State Request list. This process repeats until RT2 sends the last of its LSA summaries and sets the More bit to 0.
  7. Once RT1 receives the last of RT2s LSA summaries and acknowledges it knowing that it has sent the last of its own LSA summaries, the Exchange state process is complete. Now RT1 will begin processing the LSA summaries it has added to its Link State Request list and transition to the Loading state.
  8. Once RT2 receives RT1’s last DD packet, RT2 then sets RT1s’s state to Full because RT2 has no entries in its own Link State Request list.
  9. RT1 will send Link State Requests for all entries in its Link State Request list and RT2 will send Link Sate Update packets until RT1’s list is empty. At that point, it sets RT2 to Full, and the adjacency is complete. each LSU and LSAck may have multiple LSAs. LSAs are sent across adjacenties within link state update packets.

results matching ""

    No results matching ""