zebra/qugga ospf implemention 1

类别:软件工程 点击:0 评论:0 推荐:

1. start an ospf process
a. data structure
ospf_master{}
  |--ospf--ospf{}
 
b. main routines
router_ospf
  |--ospf_get
       |--ospf_new
            |--ospf_lsa_maxage_walker
            |--ospf_lsa_refresh_walker
            |--ospf_sock_init
            |--ospf_read
              
c.notes            
-there is only one router ospf process, but cisco can have many ospf process.

2. set a network area
a. data structure
ospf{}                                         <--|       <--|
  |--networks--ospf_network{}    |            |
  |--areas--ospf_area{}            ---|            |
              |--oiflist--ospf_interface{}       ---|
                            |--nbrs--ospf_neighbor{}
                            |--nbr_self--ospf_neighbor{}               
b. main routines                              
ospf_network_area
  |--ospf_network_set
       |--ospf_if_new
       |--ospf_nbr_add_self
       |--ospf_network_run
            |--ospf_if_up
                 |--OSPF_ISM_EVENT_SCHEDULE (ISM_InterfaceUp)
                      |--ospf_ism_event(ISM_Down-->ISM_Waiting)

ospf_if_new: construct an ospf_interface and a pseudo self ospf_neighbor (its state is always NSM_TwoWay)
ospf_nbr_add_self: add self ospf_neighbor to ospf_interface{}--nbrs
                     
ospf_ism_event (ISM_Down-->ISM_Waiting)
  |--ism_interface_up
  |--ism_change_state
       |--ospf_check_abr_status
       |--ospf_router_lsa_timer_add
  |--ism_timer_set (ISM_Waiting)
       |--OSPF_ISM_TIMER_ON (ospf_hello_timer)
       |--OSPF_ISM_TIMER_ON (ospf_wait_timer)
      
ospf_wait_timer
  |--OSPF_ISM_EVENT_SCHEDULE (ISM_WaitTimer)
       |--ospf_ism_event (ISM_Waiting-->ISM_DR)
            |--ism_wait_timer
                 |--ospf_dr_election
            |--ism_change_state
                 |--ospf_network_lsa_timer_add
            |--ism_timer_set (ISM_DR)    
                 |--OSPF_ISM_TIMER_ON (ospf_hello_timer)
                 |--OSPF_ISM_TIMER_ON (ospf_ls_ack_timer);
                
                
3. interact with a neighbor

situation: after the router become DR, start the other router

a. data structure

b. main routines

ospf_hello
  |--ospf_nbr_get
       |--ospf_nbr_add
            |--ospf_nbr_new
            |--nbr->state = NSM_Down
  |--OSPF_NSM_EVENT_EXECUTE (NSM_HelloReceived)  
       |--ospf_nsm_event (NSM_Down-->NSM_Init)     
            |--nsm_hello_received
            |--nsm_change_state
                 |--OSPF_ISM_TIMER_ON (oi->t_hello, ospf_hello_timer, 1)
                
  if the router can see itself in the neighbor hello packet then
 
    |--OSPF_NSM_EVENT_EXECUTE (NSM_TwoWayReceived)
         |--ospf_nsm_event 
              |--nsm_twoway_received (NSM_Init-->NSM_ExStart) 
              |--nsm_change_state
                   |--ospf_db_desc_send ()
                   |--OSPF_ISM_EVENT_EXECUTE (ISM_NeighborChange)
                        |--ospf_ism_event (ISM_DR)
                             |--ospf_dr_election
                            
  if the router can not see itself in the neighbor hello packet then
 
    |--OSPF_NSM_EVENT_EXECUTE (NSM_OneWayReceived)
         |--ospf_nsm_event (NSM_Init-->NSM_Init) 
        
    after the router receive db desc packet from the neighbor.      
   
    ospf_db_desc                   
      |--OSPF_NSM_EVENT_EXECUTE (NSM_TwoWayReceived)    
  
    
          

本文地址:http://com.8s8s.com/it/it31819.htm