add TSCH channel selection example
This commit is contained in:
parent
bc9967dbb0
commit
df733e409a
|
@ -0,0 +1,34 @@
|
|||
CONTIKI_PROJECT = node
|
||||
all: $(CONTIKI_PROJECT)
|
||||
|
||||
CONTIKI=../../..
|
||||
|
||||
PLATFORMS_EXCLUDE = sky nrf52dk native
|
||||
BOARDS_EXCLUDE = srf06/cc13xx launchpad/cc1310 launchpad/cc1350 sensortag/cc2650 sensortag/cc1350
|
||||
|
||||
# The channel selection library
|
||||
MODULES += os/services/tsch-cs
|
||||
|
||||
# force Orchestra from command line
|
||||
MAKE_WITH_ORCHESTRA ?= 0
|
||||
# force Security from command line
|
||||
MAKE_WITH_SECURITY ?= 0
|
||||
# print #routes periodically, used for regression tests
|
||||
MAKE_WITH_PERIODIC_ROUTES_PRINT ?= 0
|
||||
|
||||
MAKE_MAC = MAKE_MAC_TSCH
|
||||
MODULES += os/services/shell
|
||||
|
||||
ifeq ($(MAKE_WITH_ORCHESTRA),1)
|
||||
MODULES += os/services/orchestra
|
||||
endif
|
||||
|
||||
ifeq ($(MAKE_WITH_SECURITY),1)
|
||||
CFLAGS += -DWITH_SECURITY=1
|
||||
endif
|
||||
|
||||
ifeq ($(MAKE_WITH_PERIODIC_ROUTES_PRINT),1)
|
||||
CFLAGS += -DWITH_PERIODIC_ROUTES_PRINT=1
|
||||
endif
|
||||
|
||||
include $(CONTIKI)/Makefile.include
|
|
@ -0,0 +1,8 @@
|
|||
Demonstration of TSCH adaptive channel selection based on background noise RSSI metric.
|
||||
TSCH stats must be enabled for the adaptive selection functionality to compile and work.
|
||||
|
||||
This code relies on the `os/services/channel-selection` library that implements
|
||||
the "RSSI upstream" adaptative channel selection strategy, described in the following paper:
|
||||
|
||||
A. Elsts, X. Fafoutis, G. Oikonomou and R. Piechocki. Adaptive Channel Selection in IEEE 802.15.4 TSCH Networks, 1st Global Internet of Things Summit, 2017.
|
||||
http://ieeexplore.ieee.org/document/8016246/
|
|
@ -0,0 +1,94 @@
|
|||
/*
|
||||
* Copyright (c) 2015, SICS Swedish ICT.
|
||||
* Copyright (c) 2018, University of Bristol - http://www.bristol.ac.uk
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* \file
|
||||
* A RPL+TSCH node.
|
||||
*
|
||||
* \author Simon Duquennoy <simonduq@sics.se>
|
||||
* Atis Elsts <atis.elsts@bristol.ac.uk>
|
||||
*/
|
||||
|
||||
#include "contiki.h"
|
||||
#include "sys/node-id.h"
|
||||
#include "sys/log.h"
|
||||
#include "net/ipv6/uip-ds6-route.h"
|
||||
#include "net/ipv6/uip-sr.h"
|
||||
#include "net/mac/tsch/tsch.h"
|
||||
#include "net/routing/routing.h"
|
||||
#include "tsch-cs.h"
|
||||
|
||||
#define DEBUG DEBUG_PRINT
|
||||
#include "net/ipv6/uip-debug.h"
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS(node_process, "RPL Node");
|
||||
AUTOSTART_PROCESSES(&node_process);
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS_THREAD(node_process, ev, data)
|
||||
{
|
||||
int is_coordinator;
|
||||
|
||||
PROCESS_BEGIN();
|
||||
|
||||
is_coordinator = 0;
|
||||
|
||||
#if CONTIKI_TARGET_COOJA
|
||||
is_coordinator = (node_id == 1);
|
||||
#endif
|
||||
|
||||
if(is_coordinator) {
|
||||
NETSTACK_ROUTING.root_start();
|
||||
}
|
||||
NETSTACK_MAC.on();
|
||||
|
||||
#if WITH_PERIODIC_ROUTES_PRINT
|
||||
{
|
||||
static struct etimer et;
|
||||
/* Print out routing tables every minute */
|
||||
etimer_set(&et, CLOCK_SECOND * 60);
|
||||
while(1) {
|
||||
/* Used for non-regression testing */
|
||||
#if (UIP_MAX_ROUTES != 0)
|
||||
PRINTF("Routing entries: %u\n", uip_ds6_route_num_routes());
|
||||
#endif
|
||||
#if (UIP_SR_LINK_NUM != 0)
|
||||
PRINTF("Routing links: %u\n", uip_sr_num_nodes());
|
||||
#endif
|
||||
PROCESS_YIELD_UNTIL(etimer_expired(&et));
|
||||
etimer_reset(&et);
|
||||
}
|
||||
}
|
||||
#endif /* WITH_PERIODIC_ROUTES_PRINT */
|
||||
|
||||
PROCESS_END();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
|
@ -0,0 +1,109 @@
|
|||
/*
|
||||
* Copyright (c) 2015, SICS Swedish ICT.
|
||||
* Copyright (c) 2017, University of Bristol - http://www.bristol.ac.uk
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* \author Simon Duquennoy <simonduq@sics.se>
|
||||
* Atis Elsts <atis.elsts@bristol.ac.uk>
|
||||
*/
|
||||
|
||||
#ifndef __PROJECT_CONF_H__
|
||||
#define __PROJECT_CONF_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
/* Set to enable TSCH security */
|
||||
#ifndef WITH_SECURITY
|
||||
#define WITH_SECURITY 0
|
||||
#endif /* WITH_SECURITY */
|
||||
|
||||
/* USB serial takes space, free more space elsewhere */
|
||||
#define SICSLOWPAN_CONF_FRAG 0
|
||||
#define UIP_CONF_BUFFER_SIZE 160
|
||||
|
||||
/*******************************************************/
|
||||
/******************* Configure TSCH ********************/
|
||||
/*******************************************************/
|
||||
|
||||
/* IEEE802.15.4 PANID */
|
||||
#define IEEE802154_CONF_PANID 0x81a5
|
||||
|
||||
/* Do not start TSCH at init, wait for NETSTACK_MAC.on() */
|
||||
#define TSCH_CONF_AUTOSTART 0
|
||||
|
||||
/* 6TiSCH minimal schedule length.
|
||||
* Larger values result in less frequent active slots: reduces capacity and saves energy. */
|
||||
#define TSCH_SCHEDULE_CONF_DEFAULT_LENGTH 3
|
||||
|
||||
#if WITH_SECURITY
|
||||
|
||||
/* Enable security */
|
||||
#define LLSEC802154_CONF_ENABLED 1
|
||||
|
||||
#endif /* WITH_SECURITY */
|
||||
|
||||
/* Enable TSCH statistics: must be on for channel selection to work */
|
||||
#define TSCH_STATS_CONF_ON 1
|
||||
|
||||
/* Enable periodic RSSI sampling for TSCH statistics */
|
||||
#define TSCH_STATS_CONF_SAMPLE_NOISE_RSSI 1
|
||||
|
||||
/* Reduce the TSCH stat "decay to normal" period to get printouts more often */
|
||||
#define TSCH_STATS_CONF_DECAY_INTERVAL (60 * CLOCK_SECOND)
|
||||
|
||||
/* For adaptive channel selection */
|
||||
extern void tsch_cs_channel_stats_updated(uint8_t updated_channel, uint16_t old_busyness_metric);
|
||||
extern bool tsch_cs_process(void);
|
||||
/* These will be called from the core TSCH code */
|
||||
#define TSCH_CALLBACK_CHANNEL_STATS_UPDATED tsch_cs_channel_stats_updated
|
||||
#define TSCH_CALLBACK_SELECT_CHANNELS tsch_cs_process
|
||||
|
||||
/* The coordinator will update the network nodes with new hopping sequences */
|
||||
#define TSCH_PACKET_CONF_EB_WITH_HOPPING_SEQUENCE 1
|
||||
|
||||
/* Reduce the EB period in order to update the network nodes with more agility */
|
||||
#define TSCH_CONF_EB_PERIOD (4 * CLOCK_SECOND)
|
||||
#define TSCH_CONF_MAX_EB_PERIOD (4 * CLOCK_SECOND)
|
||||
|
||||
/*******************************************************/
|
||||
/************* Other system configuration **************/
|
||||
/*******************************************************/
|
||||
|
||||
/* Logging */
|
||||
#define LOG_CONF_LEVEL_RPL LOG_LEVEL_INFO
|
||||
#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_DBG
|
||||
#define LOG_CONF_LEVEL_FRAMER LOG_LEVEL_INFO
|
||||
#define TSCH_LOG_CONF_PER_SLOT 1
|
||||
|
||||
#endif /* __PROJECT_CONF_H__ */
|
Loading…
Reference in New Issue