'Contiki-NG Z1 Nullnet CSMA CC2420 accidently receives all messages in range
Via the observation of PowerTracker in Cooja, it seems that my Z1 nodes in the Cooja emulator receive all the packets they could get (in range). I am using nullnet with CSMA. How could I let my Z1 nodes reject the messages (frames) not for them?
Cooja Emulation Configuration Screenshots - DGRM radio environment
Here, I lined up the four Z1 nodes: node 1, node 2, node 3, and node 4, whose link-layer addresses are 0100.0000.0000.0000, 0200.0000.0000.0000, 0300.0000.0000.0000, 0400.0000.0000.0000, respectively. Only two adjacent nodes can communicate with each other (As you can see in the figure above, these configurations are achieved by the DGRM link setting).
After the initialization, all the nodes will broadcast a message respectively to acknowledge their existence; Then, node 1 will not send any messages anymore, nodes 2, 3, and 4 periodically unicast their messages to an address 0600.0000.0000.0000, which does not exist.
Then, a desperate scenario happens, CC2420 has an address filter, when the Z1 node finds the message incoming is not the one for it, it should not receive the left part of the message any longer. However, in our cases, the Radio RX time from the PowerTracker are as follow:
Z1_1 MONITORED 719915550 us
Z1_1 ON 718993610 us 99.87 %
Z1_1 TX 768 us 0.00 %
Z1_1 RX 552061 us 0.08 %
Z1_1 INT 0 us 0.00 %
Z1_2 MONITORED 719915582 us
Z1_2 ON 719009242 us 99.87 %
Z1_2 TX 552829 us 0.08 %
Z1_2 RX 483012 us 0.07 %
Z1_2 INT 11 us 0.00 %
Z1_3 MONITORED 719938987 us
Z1_3 ON 719032647 us 99.87 %
Z1_3 TX 552864 us 0.08 %
Z1_3 RX 851568 us 0.12 %
Z1_3 INT 54522 us 0.01 %
Z1_4 MONITORED 719939019 us
Z1_4 ON 719043863 us 99.88 %
Z1_4 TX 552843 us 0.08 %
Z1_4 RX 479181 us 0.07 %
Z1_4 INT 4 us 0.00 %
The CC2420's filtering seems dead in Cooja, or do I make huge mistakes? How could I let my Z1 nodes reject the messages (frames) not for them?
Here comes my experiment source code, it is generated based on the `Nullnet unicast example. These examples all are masterpieces, and I'm just making superficial changes on it:
#include "contiki.h"
#include "net/netstack.h"
#include "net/nullnet/nullnet.h"
#include <string.h>
#include <stdio.h>
#include "sys/log.h"
#define LOG_MODULE "App"
#define LOG_LEVEL LOG_LEVEL_INFO
/* Configuration */
#define SEND_INTERVAL (1 * CLOCK_SECOND)
/**
* For node 1 the dest_addr is 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00;
* Nodes 2, 3, and 4's are 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00;
*/
static linkaddr_t dest_addr = {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}};
/*---------------------------------------------------------------------------*/
PROCESS(nullnet_example_process, "NullNet unicast example");
AUTOSTART_PROCESSES(&nullnet_example_process);
/*---------------------------------------------------------------------------*/
void input_callback(const void *data, uint16_t len, const linkaddr_t *src, const linkaddr_t *dest)
{
if (len == sizeof(unsigned))
{
unsigned count;
memcpy(&count, data, sizeof(count));
LOG_INFO("Received %u from ", count);
LOG_INFO_LLADDR(src);
LOG_INFO_("\n");
}
}
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(nullnet_example_process, ev, data)
{
static struct etimer periodic_timer;
static unsigned count = 0;
nullnet_set_input_callback(input_callback);
PROCESS_BEGIN();
/* Activate Address Filtering */
NETSTACK_RADIO.set_value(RADIO_PARAM_RX_MODE,RADIO_RX_MODE_ADDRESS_FILTER | RADIO_RX_MODE_AUTOACK);
/* Initialize NullNet */
nullnet_buf = (uint8_t *)&count;
nullnet_len = sizeof(count);
/* Acknowledgement of existence */
NETSTACK_NETWORK.output(NULL);
// Main loop
if (!linkaddr_cmp(&dest_addr, &linkaddr_node_addr))
{
/* Node 1 will not perform the following part. */
etimer_set(&periodic_timer, SEND_INTERVAL);
while (1)
{
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&periodic_timer));
LOG_INFO("Sending %u to ", count);
LOG_INFO_LLADDR(&dest_addr);
LOG_INFO_("\n");
// NETSTACK_NETWORK.output(NULL);
NETSTACK_NETWORK.output(&dest_addr);
count++;
etimer_reset(&periodic_timer);
}
}
PROCESS_END();
}
/*---------------------------------------------------------------------------*/
The configuration file:
/************** system configuration ***************/
#ifndef PROJECT_CONF_H_
#define PROJECT_CONF_H_
/* Configuration of ACK */
#define CSMA_CONF_SEND_SOFT_ACK 0 /* Disable software ACK */
#define CC2420_CONF_AUTOACK 1 /* Using AUTO_ACK from CC2420 */
#define CSMA_CONF_ACK_WAIT_TIME RTIMER_SECOND / 2500 /* Default */
#define CSMA_CONF_AFTER_ACK_DETECTED_WAIT_TIME RTIMER_SECOND / 1500 /* Default */
/* Configuration of Energest - Waring !Do not use it when using TSCH MAC! */
#define ENERGEST_CONF_ON 1 /* Activation */
#define SIMPLE_ENERGEST_CONF_PERIOD (CLOCK_SECOND * 2400) /* 2400 second */
// #define LOG_CONF_LEVEL_RPL LOG_LEVEL_WARN
// #define LOG_CONF_LEVEL_TCPIP LOG_LEVEL_WARN
// #define LOG_CONF_LEVEL_IPV6 LOG_LEVEL_WARN
// #define LOG_CONF_LEVEL_6LOWPAN LOG_LEVEL_WARN
// #define LOG_CONF_LEVEL_MAC LOG_LEVEL_WARN
// #define LOG_CONF_LEVEL_FRAMER LOG_LEVEL_WARN
#endif
Moreover, if my memory is correct, if AUTO_ACK is activated, the CC2420's Address_filtering should be activated as well.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
