【发布时间】:2017-05-02 19:11:01
【问题描述】:
我正在尝试测试文件 rpl-icmp6.c 中的 DIO 消息是否来自接收 DIO 的节点的子节点。谁能帮我?
我看到 contiki 不保留孩子的名单,只保留父母的名单。因此,我不知道该怎么做?
伪代码:
if(senderOfDIO is child) {
check the rank of the packet
}
谁能帮帮我?
【问题讨论】:
我正在尝试测试文件 rpl-icmp6.c 中的 DIO 消息是否来自接收 DIO 的节点的子节点。谁能帮我?
我看到 contiki 不保留孩子的名单,只保留父母的名单。因此,我不知道该怎么做?
伪代码:
if(senderOfDIO is child) {
check the rank of the packet
}
谁能帮帮我?
【问题讨论】:
如果您在存储模式下运行 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;
}
【讨论】:
argument是孩子的IP地址。
is_direct_child:is_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 的任何原因吗?
uip_ds6_route_lookup(address) 和uip_ds6_route_nexthop(route); 的工作原理吗?或者我在哪里可以找到有关它的一些信息?我已经查看了文档,但对返回的内容感到困惑。另外:为什么将孩子的IP地址与下一个希望进行比较?它不应该是父母的IP地址吗? @kfx
在 RPL 存储模式或非存储模式下,从父节点到子节点的 DIO 将在两个场景中发送。 1 在组建 DODAG 之前 2 DODAG形成后定期发送DIO。
每次DIO都会多播,除了响应子节点发出DIS。
测试孩子是否收到DIO消息,可以在虚拟模拟COOJA中看到。
在非存储模式下,除了路由器之外的所有节点都不会存储子地址。这里的数据包转发将由源路由头(SRH)完成,它承载了所有的地址。
【讨论】: