zoukankan      html  css  js  c++  java
  • lldpd-0.7.7代码解读(send_pdu部分)

    此文档是经过逆序推到出的,可能有错误之处,敬请指教,谢谢。

    1)interfaces_update  

         更新一些接口信息

    2)levent_iface_subscribe

        该接口通过socket通信(非阻塞模式)来获取信息。增加了一个event,来接收信息。

    3)levent_iface_trigger  直接调用

         lldpd_update_localports

         更新本地接口信息。

    4)lldpd_reset_timer

        重启有信息变更的端口的timer。

    5)levent_schedule_pdu

        安排发送pdu。如果接口(端口)对应的timer不存在,则需添加。

    6)levent_send_pdu

        int tx_interval = hardware->h_cfg->g_config.c_tx_interval; // 发送间隔

        根据发送间隔,以及是否是快速帧(快速帧有自己的发送间隔,快于普通帧)来进行发送pdu。

    7)lldpd_send

         首先判断模式是否支持发送模式,以及接口是否正常运行状态,若否,则不发送。

         if (cfg->g_config.c_receiveonly || cfg->g_config.c_paused) return;
         if ((hardware->h_flags & IFF_RUNNING) == 0)  return;

         其次根据使用的协议还有协议是否enabeled来进行发送报文。

        for (i=0; cfg->g_protocols[i].mode != 0; i++) {
               if (!cfg->g_protocols[i].enabled)
                          continue;
               /* We send only if we have at least one remote system
            * speaking this protocol or if the protocol is forced */
           if (cfg->g_protocols[i].enabled > 1) {
           cfg->g_protocols[i].send(cfg, hardware);
           sent++;
           continue;
        }

    其中重要的结构体有:

    struct lldpd_config {  

    int c_paused;       /* lldpd is paused */  

    int c_tx_interval;   //lldppdu发送间隔  

    int c_smart;    /* Bitmask for smart configuration (see SMART_*) */  

    int c_receiveonly;   //只接受模式,有三种模式,只发送、只接收、同时支持发送和接收 

    int c_max_neighbors;  //支持的最大邻居数

    char *c_mgmt_pattern; /* Pattern to match a management address */  

    char *c_cid_pattern; /* Pattern to match interfaces to use for chassis ID */  

    char *c_iface_pattern; /* Pattern to match interfaces to use */

     char *c_platform; /* Override platform description (for CDP) */  

    char *c_description; /* Override chassis description */

    int c_advertise_version; /* Should the precise version be advertised? */  

    int c_set_ifdescr;  /* Set interface description */

    #ifdef ENABLE_LLDPMED

     int c_noinventory; /* Don't send inventory with LLDP-MED */

     int c_enable_fast_start; /* enable fast start */ //是否启动fast start模式,每秒钟发送报文个数快于平常  

     int c_tx_fast_init; //fast start的报文数量

     int c_tx_fast_interval;  // fast start报文发送间隔

    #endif

     int c_tx_hold;  /* Transmit hold */

     int c_bond_slave_src_mac_type; /* Src mac type in lldp frames over bond slaves */

    };

    如果一个“新邻居”被识别,将会启用快速发送机制,在很短的时间内连续发送指定数量(txFastInit,默认值为4)的LLDPDU,以确保“新邻居”能被快速更新。

     如果远端系统MIB信息库因为过载(tooManyNeighbors)而不能容纳新的邻居信息,则会为了避免过多的PDU传输而抑制快速发送行为。

    同时为了防止在有多个端口需要发送LLDPDU的系统中,所有的端口的定时器都在同一时间到期,因而标准建议将采用某种机制将多个发送实例的定时器到期时间给错开,以避免一个系统在同一时刻发送大量的LLDPDU

      

  • 相关阅读:
    rabbitmq发送消息的两种格式:发送json数据和直接发送对象以及对json与对象之间的相互转换
    rabbitmq 的hello world程序
    rabbitmq用户管理、角色、权限管理以及UI管理界面的使用
    redis设置密码以及安装到服务
    mybatis- generator自动生成代码
    COGS 有标号的二分图计数系列
    Codeforces183D T-shirt
    bzoj3473 字符串
    51Nod1782 圣诞树
    51Nod1601 完全图的最小生成树计数
  • 原文地址:https://www.cnblogs.com/rohens-hbg/p/4813839.html
Copyright © 2011-2022 走看看