我想在contikirpl的mrhrof目标函数中实现DAG度量容器目标类型,例如能量,吞吐量,延迟,跳数。我正在尝试获取数据包详细信息包,例如包发送/接收的时间戳,直接父节点收到的包等。
实验设置:一个接收器(mote1)(udp-server.c),三个接收器(mote2,3&4)(udp-slient.c)(../ contiki-3.0 /示例/ ipv6 / rpl-udp)。
mote1 mote2 mote3 mote4
(1)为了对接收到的数据包进行计数,我在neighbor_link_callback()中尝试了非常简单的代码,因为此函数接收链路层邻居信息。(..contiki-3.0 / core / net / rpl / rpl-mrhof.c)
#include "sys/node-id.h"
(包含在文件中以访问节点ID)
static uint16_t pkt1=0,pkt2=0,pkt3=0; /* pkt1,2 and 3 store incoming packets for mote2,3 and 4 respectively */
if(status == MAC_TX_OK) // pkts transmission successfully
{
switch (node_id) {
case 2:
pkt1++;
break;
case 3:
pkt2++;
break;
case 4:
pkt3++;
break;
default:
PRINTF("Other::error outside of three mote \n");
break;
}
}
此代码的问题是我在这些变量中获取了更多的数据包。我认为因为它存储所有类型的数据包(控制和数据包)。如何仅获取这些变量(pkt1,pkt2,pkt3)中的数据包。
((2)为了计算延迟,我想在mrhrof.c中获取发送/接收数据包的时间戳,但是我只能在udp-server.c和udp-client.c中获取时间。(.... / contiki-3.0 / examples / ipv6 / rpl-udp)
为此,我编写了以下代码:udp-client.c
静态uint16_t pkt1_s = 0,pkt2_s = 0,pkt3_s = 0;
[内部“静态无效send_packet(void * ptr)“
pkt_send_time = clock_seconds();
switch (node_id) {
case 2:
PRINTF("::No of pkt_send:: %u by \t mote %d at \t pkt_send_time:: %u \n",++pkt1_s,node_id,pkt_send_time);
break;
case 3:
PRINTF("::#pkt_send:: %u \t by mote %d at \t pkt_send_time:: %u \n",++pkt2_s,node_id,pkt_send_time);
break;
case 4:
PRINTF("::#pkt_send:: %u \t by mote %d at \t pkt_send_time:: %u \n",++pkt3_s,node_id,pkt_send_time);
break;
default:
PRINTF("::error send pkt outside range \n");
break;
}
我为udp-server.c编写了相同类型的代码。
这里,我面临以下问题:
使用
#include "net/ipv6/uip-ds6.h"
#include "net/ip/uip-udp-packet.h"