【问题标题】:RPL children-list ContikiRPL 子列表 Contiki
【发布时间】:2017-05-02 19:11:01
【问题描述】:

我正在尝试测试文件 rpl-icmp6.c 中的 DIO 消息是否来自接收 DIO 的节点的子节点。谁能帮我?

我看到 contiki 不保留孩子的名单,只保留父母的名单。因此,我不知道该怎么做?

伪代码:

if(senderOfDIO is child) {

   check the rank of the packet

}

谁能帮帮我?

【问题讨论】:

    标签: c contiki


    【解决方案1】:

    如果您在存储模式下运行 RPL,您可以通过查看指向它们的路由并检查路由的 nexthop 是否与端点地址相同来判断哪些节点是直接连接的。

    这是一个循环直接子级的代码示例:

    #include "ipv6/uip-ds6-route.h"
    
    static void
    iterate_children(void)
    {
      uip_ds6_route_t *route;
    
      /* Loop over routing entries */
      route = uip_ds6_route_head();
      while(route != NULL) {
        const uip_ipaddr_t *address = &route->ipaddr;
        const uip_ipaddr_t *nexthop = uip_ds6_route_nexthop(route);
        if(uip_ipaddr_cmp(&address, &nexthop)) {
           /* direct child: do somehting */
        }
    
        route = uip_ds6_route_next(route);
      }
    }
    

    要专门解决您的问题,请使用以下内容:

    static uint8_t
    is_direct_child(uip_ipaddr_t *address)
    {
      uip_ds6_route_t *route;
    
      route = uip_ds6_route_lookup(address);
      if(route != NULL) {
        const uip_ipaddr_t *nexthop = uip_ds6_route_nexthop(route);
        if(uip_ipaddr_cmp(&address, &nexthop)) {
           /* nexthop and the address are the same */
           return 1;
        }
      }
      return 0;
    }
    

    【讨论】:

    • 非常感谢您的回答。很好的答案!一个快速的后续问题:在 is_direct_child 中,我应该发送孩子的 IP 地址还是主机的 IP 地址?
    • 地址argument是孩子的IP地址。
    • 我明白了!所以我像这样调用is_direct_childis_direct_child(&from),从哪里收到这样的:uip_ipaddr_copy(&from, &UIP_IP_BUF->srcipaddr);。但是,在uip_ds6_route_lookup(address) 根本找不到任何路线。它输出:uip-ds6-route: Looking up route for fe80::c40c:0:0:3 ,然后下一个输出是No route found。你能想到@kfx 的任何原因吗?
    • 如果我没记错的话,你不会在路由表中看到本地链接地址。您需要一个适当的、可路由的前缀,例如“fd00”,并且该路由必须已经被 RPL 发现,它才能显示在父路由表中(DIO 和 DAO 消息交换完成)。
    • 您能告诉我更多关于uip_ds6_route_lookup(address)uip_ds6_route_nexthop(route); 的工作原理吗?或者我在哪里可以找到有关它的一些信息?我已经查看了文档,但对返回的内容感到困惑。另外:为什么将孩子的IP地址与下一个希望进行比较?它不应该是父母的IP地址吗? @kfx
    【解决方案2】:

    在 RPL 存储模式或非存储模式下,从父节点到子节点的 DIO 将在两个场景中发送。 1 在组建 DODAG 之前 2 DODAG形成后定期发送DIO。

    每次DIO都会多播,除了响应子节点发出DIS。

    测试孩子是否收到DIO消息,可以在虚拟模拟COOJA中看到。

    在非存储模式下,除了路由器之外的所有节点都不会存储子地址。这里的数据包转发将由源路由头(SRH)完成,它承载了所有的地址。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-04-16
      相关资源
      最近更新 更多