如何在contikiRPL中的rpl目标函数MRHOF中访问数据包详细信息?

问题描述 投票:0回答:1

我想在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编写了相同类型的代码。

这里,我面临以下问题:

  1. [function clock_seconds()以秒为单位提供时间,但我需要以毫秒为单位。
  2. 如何在rpl-mhrof.c中获取发送/接收数据包的确切时间戳
iot contiki
1个回答
1
投票
  1. 您可以使用RTIMER_NOW()获得更好的时间粒度,但是请注意:对于大多数节点类型,时钟不同步!唯一可靠的解决方案是将time_send值发送到该节点,然后要求节点对此进行答复。收到时,您可以将current_time减去它们。另一个绕过的方法是在输出中使用cooja的时间(记录所有输出并使用此脱机数据)。
  2. 对于详细的数据包(数据/ icmp,发送/接收),请使用以下内容:uip_stat.udp.sent,uip_stat.udp.recv,uip_stat.icmp.sent,uip_stat.icmp.recv

使用

#include "net/ipv6/uip-ds6.h"
#include "net/ip/uip-udp-packet.h"
© www.soinside.com 2019 - 2024. All rights reserved.