RPL children-list 关闭

RPL children-list Contiki

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

我看到 contiki 没有保留 children 的列表,只有 parents。因此,我不知道该怎么做?

伪代码:

if(senderOfDIO is child) {

   check the rank of the packet

}

谁能帮帮我?

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

这是在直接子级上循环的代码示例:

#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;
}

无论是在 RPL 存储模式还是非存储模式下,从 parent 节点到 child 节点的 DIO 将在两个场景中发送。 1 在形成 DODAG 之前 2 DODAG形成后定期发送DIO。

除了响应 Child 节点发送 DIS 外,每次 DIO 都会被多播。

测试child是否收到DIO报文,在COOJA虚拟仿真中可以看到

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