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

How to access data packet details in rpl's objective function MRHOF in contikiRPL?

我想在 contikirpl 的 mrhrof objective 函数中实现 DAG Metric Container objective 类型,例如能量、吞吐量、延迟、跳数。我正在尝试获取数据包详细信息包,例如数据包的时间戳 send/receive、直接父节点接收的数据包等

实验设置: 一个接收器 (mote1) (udp-server.c),三个源 (mote2,3 & 4) (udp-slient.c ) (..../contiki-3.0/examples/ipv6/rpl-udp).

mote1<---->mote2<---->mote3<---->mote4

(1) 为了计算收到的数据包,我在neighbor_link_callback()中尝试了非常简单的代码,因为这个函数接收link层邻居信息。 (..contiki-3.0/core/net/rpl/rpl-mrhof.c)

#include "sys/node-id.h"(包含在访问node-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 mote wise 中获取 send/receiving 数据包时间戳,但我只能在 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;

里面“static void 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. 函数 clock_seconds() 提供以秒为单位的时间,但我需要以毫秒为单位的时间。
  2. 如何在rpl-mhrof.c
  3. 中获取sending/receiving个数据包的准确时间戳
  1. 您可以使用 RTIMER_NOW() 以获得更好的时间粒度,但是,请注意:对于大多数节点类型,时钟不同步!您唯一可靠的解决方案是将 time_send 值发送到节点,并要求节点对此进行回复。当您收到它时,您可以将 current_time 减去它们。 另一种绕过方法是在输出中使用 cooja 的时间(记录所有输出并使用此离线数据)。
  2. 对于详细数据包(data/icmp、send/received)使用以下内容: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"