📄 neighbor_table.c
字号:
olsr_delete_neighbor_table(neighbor_tmp); /* This flag is set to UP to recalculate the MPR set and the routing table*/ changed = 1; } else { /* check if links is asym */ if (olsr_timed_out (&neighbor->neighbor_link_asym_timer)) { if (debug_level>2) { } if (neighbor->neighbor_status != LOST_LINK) { if (debug_level>1) { printf ("\n\n.................neighbor %s -- Asym_timer expires!................\n", convert_address_to_string(&neighbor->neighbor_addr)); printf ("neighbor_link_asym_timer: %d %d\n", neighbor->neighbor_link_asym_timer.tv_sec, neighbor->neighbor_link_asym_timer.tv_usec); printf ("neighbor_link_sym_timer: %d %d\n", neighbor->neighbor_link_sym_timer.tv_sec, neighbor->neighbor_link_sym_timer.tv_usec); printf("now: %d %d\n ",now.tv_sec,now.tv_usec); printf ("CHANGE LINK STATUS TO LOST_LINK!\n"); fprintf (y_file,"\n\n.................neighbor %s -- Asym_timer expires!................\n", convert_address_to_string(&neighbor->neighbor_addr)); fprintf (y_file,"neighbor_link_asym_timer: %d %d\n", neighbor->neighbor_link_asym_timer.tv_sec, neighbor->neighbor_link_asym_timer.tv_usec); fprintf (y_file,"neighbor_link_sym_timer: %d %d\n", neighbor->neighbor_link_sym_timer.tv_sec, neighbor->neighbor_link_sym_timer.tv_usec); fprintf(y_file,"now: %d %d\n ",now.tv_sec,now.tv_usec); fprintf (y_file,"CHANGE LINK STATUS TO LOST_LINK!\n"); } neighbor->neighbor_status = LOST_LINK; changed = 1; } } else { /* check if link is still sym */ if (olsr_timed_out (&neighbor->neighbor_link_sym_timer)) { if (neighbor->neighbor_status == SYM_LINK) { changed = 1; if (debug_level>1) { printf ("\n\n.............neighbor %s, sym_timer expires!................\n", convert_address_to_string(&neighbor->neighbor_addr)); printf ("neighbor_link_asym_timer: %d %d\n", neighbor->neighbor_link_asym_timer.tv_sec, neighbor->neighbor_link_asym_timer.tv_usec); printf ("neighbor_link_sym_timer: %d %d\n", neighbor->neighbor_link_sym_timer.tv_sec, neighbor->neighbor_link_sym_timer.tv_usec); printf("now: %d %d\n ",now.tv_sec,now.tv_usec); printf ("CHANGE LINK STATUS TO ASYM_LINK!\n"); fprintf (y_file,"\n\n.............neighbor %s, sym_timer expires!................\n", convert_address_to_string(&neighbor->neighbor_addr)); fprintf (y_file,"neighbor_link_asym_timer: %d %d\n", neighbor->neighbor_link_asym_timer.tv_sec, neighbor->neighbor_link_asym_timer.tv_usec); fprintf (y_file,"neighbor_link_sym_timer: %d %d\n", neighbor->neighbor_link_sym_timer.tv_sec, neighbor->neighbor_link_sym_timer.tv_usec); fprintf(y_file,"now: %d %d\n ",now.tv_sec,now.tv_usec); fprintf (y_file,"CHANGE LINK STATUS TO ASYM_LINK!\n"); } } if (neighbor->neighbor_status != LOST_LINK) neighbor->neighbor_status = ASYM_LINK; } } olsr_time_out_two_hop_neighbors(neighbor); } if (changed) { changes_neighborhood = 1; changes_topology = 1; } neighbor=neighbor->neighbor_forw; } } //also should update main_addr_neighbor_status based on the link status if (changed) { olsr_update_main_addr_neigh_table_status (); if (debug_level > 1) { printf ("XXXXXXXXXX after time out neighbor table, the neighbor table is:XXXXXXXXXXXX\n"); olsr_print_neighbor_table(); olsr_print_main_addr_neigh_table(); fprintf (y_file,"XXXXXXXXXX after time out neighbor table, the neighbor table is:XXXXXXXXX\n"); olsr_print_trace_neighbor_table(); olsr_print_trace_main_addr_neigh_table(); } }}/*------------------------------------------------------------------------*//************** commented by Y.Ge ************//*voidolsr_print_neighbor_table(){ olsr_u8_t index; struct neighbor_entry *neighbor; struct neighborhash *hash_neighbor; struct neighbor_2_list_entry *list_2; char str[46]; printf("neighbor list: %02d:%02d:%02d.%06lu\n",nowtm->tm_hour, nowtm->tm_min, nowtm->tm_sec, now.tv_usec); for(index=0;index<HASHSIZE;index++) { hash_neighbor=&neighbortable.neighborhash[index]; for(neighbor=hash_neighbor->neighbor_forw;neighbor!=(struct neighbor_entry *)hash_neighbor;neighbor=neighbor->neighbor_forw) { //printf("%s:%d:%1.2f[2hlist:",convert_address_to_string(&neighbor->neighbor_addr),neighbor->neighbor_status,neighbor->neighbor_hysavg); printf("%s;%d;%1.2f[2hlist;",inet_ntop(AF_INET6,(&neighbor->neighbor_addr),str,46),neighbor->neighbor_status,neighbor->neighbor_hysavg); list_2=neighbor->neighbor_2_list; while(list_2!=NULL) { //printf("%s:",convert_address_to_string(&list_2->neighbor_2->neighbor_2_addr)); printf("%s;",inet_ntop(AF_INET6,&list_2->neighbor_2->neighbor_2_addr,str,46)); list_2=list_2->neighbor_2_next; } printf("]\n"); } }}*//*------------------------------------------------------------------------*//************** added by Y.Ge ************/voidolsr_print_neighbor_table(){ olsr_u8_t index; struct neighbor_entry *neighbor; struct neighborhash *hash_neighbor; struct neighbor_2_list_entry *list_2; char str[46]; int i; printf("\n\nneighbor list: %02d:%02d:%02d.%06lu\n",nowtm->tm_hour, nowtm->tm_min, nowtm->tm_sec, now.tv_usec); for(index=0;index<HASHSIZE;index++) { hash_neighbor=&neighbortable.neighborhash[index]; for(neighbor=hash_neighbor->neighbor_forw;neighbor!=(struct neighbor_entry *)hash_neighbor;neighbor=neighbor->neighbor_forw) { //printf("%s:%d:%1.2f[2hlist:",convert_address_to_string(&neighbor->neighbor_addr),neighbor->neighbor_status,neighbor->neighbor_hysavg); printf ("---from my iface address (%d): %s\n",neighbor->my_iface_index, inet_ntop(AF_INET6,(&neighbor->my_iface_addr),str,46)); printf(" neighbor:%s;%d;%1.2f[2hlist;",inet_ntop(AF_INET6,(&neighbor->neighbor_addr),str,46),neighbor->neighbor_status,neighbor->neighbor_hysavg); list_2=neighbor->neighbor_2_list; while(list_2!=NULL) { //printf("%s:",convert_address_to_string(&list_2->neighbor_2->neighbor_2_addr)); printf("%s;",inet_ntop(AF_INET6,&list_2->neighbor_2->neighbor_2_addr,str,46)); list_2=list_2->neighbor_2_next; } printf("]\n"); /*** hyst ***/ if (use_hyst) { printf("***** link pending: %d\n", neighbor->link_pending); } /* timers */ printf (" neighbor timers:\n"); printf (" neighbor_timer: %d %d\n ",neighbor->neighbor_timer.tv_sec,neighbor->neighbor_timer.tv_usec); printf (" neighbor_link_sym_timer: %d %d\n", neighbor->neighbor_link_sym_timer.tv_sec, neighbor->neighbor_link_sym_timer.tv_usec); printf (" neighbor_link_asym_timer: %d %d\n", neighbor->neighbor_link_asym_timer.tv_sec, neighbor->neighbor_link_asym_timer.tv_usec); if (use_hyst) { printf (" neighbor_link_lost_timer: %d %d\n", neighbor->neighbor_link_lost_timer.tv_sec, neighbor->neighbor_link_lost_timer.tv_usec); printf (" neighbor_next_hello_timer: %d %d\n", neighbor->next_hello_timer.tv_sec, neighbor->next_hello_timer.tv_usec); } printf(" now: %d %d\n ",now.tv_sec,now.tv_usec); /* qos OLSR */ if (use_qos) { printf ("++++++ neighbor's busy time: %d\n", neighbor->neighbor_busy_time); } printf (" --> this neighbor's main address info-address:%s, willingness: %d, status: %d\n", inet_ntop(AF_INET6, (&neighbor->neighbor_main_info->main_neighbor->main_addr_neigh_addr),str,46), neighbor->neighbor_main_info->main_neighbor->main_addr_neigh_willingness, neighbor->neighbor_main_info->main_neighbor->main_addr_neigh_status); } }}/*------------------------------------------------------------------------*/voidolsr_print_trace_neighbor_table(){ olsr_u8_t index; struct neighbor_entry *neighbor; struct neighborhash *hash_neighbor; struct neighbor_2_list_entry *list_2; char str[46]; int i; fprintf(y_file,"\n\nneighbor list: %02d:%02d:%02d.%06lu\n",nowtm->tm_hour, nowtm->tm_min, nowtm->tm_sec, now.tv_usec); for(index=0;index<HASHSIZE;index++) { hash_neighbor=&neighbortable.neighborhash[index]; for(neighbor=hash_neighbor->neighbor_forw;neighbor!=(struct neighbor_entry *)hash_neighbor;neighbor=neighbor->neighbor_forw) { //printf("%s:%d:%1.2f[2hlist:",convert_address_to_string(&neighbor->neighbor_addr),neighbor->neighbor_status,neighbor->neighbor_hysavg); fprintf (y_file,"---from my iface address (%d): %s\n",neighbor->my_iface_index, inet_ntop(AF_INET6,(&neighbor->my_iface_addr),str,46)); fprintf(y_file," neighbor:%s;%d;%1.2f[2hlist;",inet_ntop(AF_INET6,(&neighbor->neighbor_addr),str,46),neighbor->neighbor_status,neighbor->neighbor_hysavg); list_2=neighbor->neighbor_2_list; while(list_2!=NULL) { //printf("%s:",convert_address_to_string(&list_2->neighbor_2->neighbor_2_addr)); fprintf(y_file,"%s;",inet_ntop(AF_INET6,&list_2->neighbor_2->neighbor_2_addr,str,46)); list_2=list_2->neighbor_2_next; } fprintf(y_file,"]\n"); /*** hyst ***/ if (use_hyst) { fprintf(y_file,"***** link pending: %d\n", neighbor->link_pending); } /*** timer ***/ fprintf (y_file," neighbor timers:\n"); fprintf (y_file," neighbor_timer: %d %d\n ",neighbor->neighbor_timer.tv_sec,neighbor->neighbor_timer.tv_usec); fprintf (y_file," neighbor_link_sym_timer: %d %d\n", neighbor->neighbor_link_sym_timer.tv_sec, neighbor->neighbor_link_sym_timer.tv_usec); fprintf (y_file," neighbor_link_asym_timer: %d %d\n", neighbor->neighbor_link_asym_timer.tv_sec, neighbor->neighbor_link_asym_timer.tv_usec); if (use_hyst) { fprintf (y_file," neighbor_link_lost_timer: %d %d\n", neighbor->neighbor_link_lost_timer.tv_sec, neighbor->neighbor_link_lost_timer.tv_usec); fprintf (y_file," neighbor_next_hello_timer: %d %d\n", neighbor->next_hello_timer.tv_sec, neighbor->next_hello_timer.tv_usec); } fprintf(y_file," now: %d %d\n ",now.tv_sec,now.tv_usec); /* qos OLSR */ if (use_qos) { fprintf (y_file,"++++++ neighbor's busy time: %d\n", neighbor->neighbor_busy_time); } fprintf (y_file," --> this neighbor's main address info-address:%s, willingness: %d, status: %d\n", inet_ntop(AF_INET6, (&neighbor->neighbor_main_info->main_neighbor->main_addr_neigh_addr),str,46), neighbor->neighbor_main_info->main_neighbor->main_addr_neigh_willingness, neighbor->neighbor_main_info->main_neighbor->main_addr_neigh_status); } }}/*------------------------------------------------------------------------*/struct neighbor_entry*olsr_find_sym_neighbor(struct main_addr_neigh_entry *main_neighbor){ struct iface_addr_list_entry *list_of_iface; list_of_iface = main_neighbor->neigh_iface_list; while(list_of_iface != NULL) { if (list_of_iface->neighbor_iface->neighbor_status == SYM_LINK) return (list_of_iface->neighbor_iface); list_of_iface = list_of_iface->iface_addr_next; } return NULL; }/*------------------------------------------------------------------------*/struct neighbor_entry*olsr_find_highest_bw_neighbor(struct main_addr_neigh_entry *main_neighbor){ struct iface_addr_list_entry *list_of_iface; struct neighbor_entry *highest_bw_neighbor = NULL; int current_busy_time = -1; list_of_iface = main_neighbor->neigh_iface_list; while(list_of_iface != NULL) { if (list_of_iface->neighbor_iface->neighbor_status == SYM_LINK && list_of_iface->neighbor_iface->neighbor_busy_time < current_busy_time) { current_busy_time = list_of_iface->neighbor_iface->neighbor_busy_time; highest_bw_neighbor = list_of_iface->neighbor_iface; } list_of_iface = list_of_iface->iface_addr_next; } return (highest_bw_neighbor);}/********************************** end of revision *****************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -