Skip to content

Commit

Permalink
+ Code made compatible with FlockLab 2
Browse files Browse the repository at this point in the history
+ Polished TTnet implementation
+ minor bug fixes
+ README clean-up
  • Loading branch information
romain-jacob committed Apr 10, 2020
1 parent 548b6ab commit 212dcde
Show file tree
Hide file tree
Showing 55 changed files with 319 additions and 1,806 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Baloo

> The Baloo code is archived on Zenodo
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.3510171.svg)](https://doi.org/10.5281/zenodo.3510171)

Baloo is a design framework for network stacks based on Synchronous Transmissions (i.e., using a flooding protocol like [Glossy](https://sourceforge.net/p/contikiprojects/code/HEAD/tree/ethz.ch/glossy/) as underlying communication primitive). Baloo is flexible enough to implement a wide variety of network layer protocols, while introducing only limited memory and energy overhead.

Using Baloo, one can relatively easily re-implement network layer protocols like the [Low-power Wireless Bus](https://github.com/ETHZ-TEC/LWB/blob/master/doc/papers/LWBSenSys12.pdf), [Crystal](http://disi.unitn.it/~picco/papers/ipsn18.pdf), and [Sleeping Beauty](http://www.chayansarkar.com/papers/chayan_mass16.pdf).
Expand All @@ -12,6 +15,14 @@ Proceedings of the 2019 International Conference on Embedded Wireless Systems an

Unless explicitly stated otherwise, all Baloo sources are distributed under the terms of the [3-clause BSD license](license). This license gives everyone the right to use and distribute the code, either in binary or source code format, as long as the copyright license is retained in the source code.

## How to cite Baloo

To cite Baloo, please use the paper listed above. If you want to cite specifically the code, please use the Zenodo archive corresponding to the version you want to cite.
> *Baloo*
Romain Jacob, Jonas Bächli, Reto Da Forno.
Version x.y. Zenodo.
http://doi.org/10.5281/zenodo.XXXXXXX

## Online presence
* GitHub repository [github.com/ETHZ-TEC/Baloo](https://github.com/ETHZ-TEC/Baloo)
* Documentation [github.com/ETHZ-TEC/Baloo/wiki](https://github.com/ETHZ-TEC/Baloo/wiki)
Expand Down
2 changes: 1 addition & 1 deletion arch/cpu/cc430/Makefile.cc430
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ ifndef CFLAGSNO
CFLAGSNO = -Wall -mmcu=$(CC_MCU) $(CFLAGSWERROR)
endif
CFLAGS += -Os
LDFLAGS = -mmcu=$(CC_MCU) -Wl,--gc-sections -ggdb -Wl,-Map=$(CONTIKI_NG_PROJECT_MAP)
LDFLAGS += -mmcu=$(CC_MCU) -Wl,--gc-sections -ggdb -Wl,-Map=$(CONTIKI_NG_PROJECT_MAP)

### These flags can reduce the code size and RAM usage with up to 10%
SMALL ?= 1
Expand Down
14 changes: 9 additions & 5 deletions arch/platform/dpp-cc430/Makefile.dpp-cc430
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,26 @@ CLEAN += $(HEXFILE) $(DISFILE)
CONTIKI_CPU=$(CONTIKI)/arch/cpu/cc430
include $(CONTIKI_CPU)/Makefile.cc430

#MODULES += os/net/glossy


files: $(CONTIKI_PROJECT).$(TARGET)
@$(OBJCOPY) $(CONTIKI_PROJECT).$(TARGET) -O ihex $(HEXFILE)
@$(OBJDUMP) -d $(CONTIKI_PROJECT).$(TARGET) > $(DISFILE)
$(info HEX and DIS file generated)

upload: $(CONTIKI_PROJECT).upload

%.upload:
@tos-set-symbols --objcopy msp430-objcopy --objdump msp430-objdump --target ihex $(CONTIKI_PROJECT).$(TARGET) $(HEXFILE) TOS_NODE_ID=$(NODE_ID)
@tos-set-symbols --objcopy msp430-objcopy --objdump msp430-objdump --target ihex $(CONTIKI_PROJECT).$(TARGET) $(HEXFILE) FLOCKLAB_NODE_ID=$(NODE_ID)
$(info node ID set to ${NODE_ID})
$(info file $(HEXFILE) generated from $(CONTIKI_PROJECT).$(TARGET))
@python ../../tools/dpp/program_cc430.py $(HEXFILE) $(PORT)

patch:
@tos-set-symbols --objcopy msp430-objcopy --objdump msp430-objdump --target ihex $(CONTIKI_PROJECT).$(TARGET) $(HEXFILE) FLOCKLAB_NODE_ID=$(NODE_ID)
$(info node ID set to ${NODE_ID})
$(info file $(HEXFILE) generated from $(CONTIKI_PROJECT).$(TARGET))
@python ../../tools/dpp/hexfilepatcher/patchHexFile.py $(HEXFILE)
@python ../../tools/dpp/program_cc430.py $(HEXFILE) $(PORT)

login:
@python ../../tools/dpp/login_cc430.py $(HEXFILE) $(PORT)

Expand Down
4 changes: 2 additions & 2 deletions arch/platform/dpp-cc430/node-id.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
#include "contiki.h"
#include "dev/xmem.h"

uint16_t TOS_NODE_ID = 0x1122; /* do NOT change this default value! */
unsigned short node_id;
uint16_t FLOCKLAB_NODE_ID = 0x1122; /* any value is ok, will be overwritten by FlockLab */
volatile unsigned short node_id; /* must be volative */

/*---------------------------------------------------------------------------*/
void
Expand Down
4 changes: 2 additions & 2 deletions arch/platform/dpp-cc430/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ static void init_gpio(void);
static void print_device_info(void);
/*---------------------------------------------------------------------------*/
static uint16_t rst_flag;
extern uint16_t TOS_NODE_ID;
extern uint16_t FLOCKLAB_NODE_ID;
/*---------------------------------------------------------------------------*/
void
platform_init_stage_one()
Expand Down Expand Up @@ -88,7 +88,7 @@ void
platform_init_stage_two()
{
#ifndef NODE_ID
node_id = TOS_NODE_ID;
node_id = FLOCKLAB_NODE_ID;
#else
node_id = NODE_ID;
#endif /* NODE_ID */
Expand Down
2 changes: 1 addition & 1 deletion arch/platform/sky/node-id.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
#include "contiki.h"
#include "dev/xmem.h"

unsigned short node_id = 0;
volatile unsigned short node_id = 0; /* must be volative */

/*---------------------------------------------------------------------------*/
void
Expand Down
16 changes: 8 additions & 8 deletions arch/platform/sky/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ extern int msp430_dco_required;
#include "experiment-setup.h"
#endif

uint16_t FLOCKLAB_NODE_ID = 0xbeef; /* any value is ok, will be overwritten by FlockLab */


void init_platform(void);
/*---------------------------------------------------------------------------*/
/* Log configuration */
Expand Down Expand Up @@ -119,10 +122,6 @@ set_lladdr(void)
linkaddr_set_node_addr(&addr);
}
/*---------------------------------------------------------------------------*/
#if WITH_TINYOS_AUTO_IDS
uint16_t TOS_NODE_ID = 0x1234; /* non-zero */
uint16_t TOS_LOCAL_ADDRESS = 0x1234; /* non-zero */
#endif /* WITH_TINYOS_AUTO_IDS */
void
platform_init_stage_one(void)
{
Expand Down Expand Up @@ -164,12 +163,13 @@ platform_init_stage_two(void)
* Hardware initialization done!
*/

#if WITH_TINYOS_AUTO_IDS
node_id = TOS_NODE_ID;
#else /* WITH_TINYOS_AUTO_IDS */
#if USE_FLOCKLAB_NODE_ID
/* Use FLOCKLAB_NODE_ID to enable patching by FlockLab */
node_id = FLOCKLAB_NODE_ID;
#else
/* Restore node id if such has been stored in external mem */
node_id_restore();
#endif /* WITH_TINYOS_AUTO_IDS */
#endif

/* for setting "hardcoded" IEEE 802.15.4 MAC addresses */
#ifdef IEEE_802154_MAC_ADDRESS
Expand Down
8 changes: 3 additions & 5 deletions examples/baloo-crystal/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
|Platform| Compilation command |
|:---|:---|
|TelosB
| make TARGET=sky |
|DPP-cc430
| make TARGET=dpp |
|TelosB | make TARGET=sky |
|DPP-cc430 | make TARGET=dpp |

This directory contains an re-implementation of the Crystal protocol, meant to be as similar as possible as the descritption from
> *Interference-resilient Ultra-low Power Aperiodic Data Collection*,
Expand All @@ -23,4 +21,4 @@ The protocol uses the interference detection feature
At each epoch, a fixed number of nodes generate and try to send a packet.
- Supported values: 0, 1 and 20
- Controlled by the `CRYSTAL_NB_CONCURRENT_SENDER` parameter
- The actual nodes sending in one epoch is defined by the `sndtbl` array, staticly defined are used for all Crystal test (see `sndtbl.c`).
- The actual nodes sending in one epoch is defined by the `sndtbl` array, staticly defined are used for all Crystal test (see `sndtbl.c`).
2 changes: 1 addition & 1 deletion examples/baloo-link-quality-test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ CFLAGS += -DPAYLOAD_LEN=8
# select the random seed
CFLAGS += -DRANDOM_SEED=123
# select the host
CFLAGS += -DHOST_ID_MAKEFILE=10
CFLAGS += -DHOST_ID_MAKEFILE=5

# Mark as a Baloo project
CFLAGS += -DBALOO
Expand Down
7 changes: 3 additions & 4 deletions examples/baloo-link-quality-test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ This can be modified after compilation by binary patching (see below)

The serial log is produced at the end of the test. They are formatted
as follows:
```
```c
Log:X:Y:Z[0].Z[1]. (...) .Z[n]
```
where
Expand Down Expand Up @@ -91,8 +91,8 @@ The user can patch
- the radio frequency channel, by patching `rf_channel`

The patching command is:
```
./tos-set-symbols --exe --objcopy msp430-objcopy --objdump msp430-objdump baloo-link-quality-test.TARGET baloo-link-quality-test.dpp-cc430
```bash
./tos-set-symbols --exe --objcopy msp430-objcopy --objdump msp430-objdump baloo-link-quality-test.TARGET baloo-link-quality-test.dpp-cc430
rf_channel=YOUR_CHANNEL payload_length=YOUR_PAYLOAD randomseed=YOUR_SEED host_id=YOUR_HOST
```

Expand All @@ -108,4 +108,3 @@ your testbed!
|:---|:---|
|TelosB | make TARGET=sky |
|DPP-cc430 | make TARGET=dpp |

8 changes: 3 additions & 5 deletions examples/baloo-lwb/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
|Platform| Compilation command |
|:---|:---|
|TelosB
| make TARGET=sky |
|DPP-cc430
| make TARGET=dpp |
|TelosB | make TARGET=sky |
|DPP-cc430 | make TARGET=dpp |

This directory contains an re-implementation of the LWB protocol, meant to be as similar as possible as the descritption from
> *Low-power Wireless Bus*,
F. Ferrari, M. Zimmerling, L. Mottola, and L. Thiele
Proceedings of the 10th ACM Conference on Embedded Network Sensor Systems (SenSys)
[Direct Link](doi.acm.org/10.1145/2426656.2426658)

All source nodes request one stream to the host at bootstrap. The stream inter-packet interval (IPI) is controlled by the `SOURCE_IPI` parameter in `project-conf.h`
All source nodes request one stream to the host at bootstrap. The stream inter-packet interval (IPI) is controlled by the `SOURCE_IPI` parameter in `project-conf.h`
8 changes: 3 additions & 5 deletions examples/baloo-minimal/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
|Platform| Compilation command |
|:---|:---|
|TelosB
| make TARGET=sky |
|DPP-cc430
| make TARGET=dpp |
|TelosB | make TARGET=sky |
|DPP-cc430 | make TARGET=dpp |

All nodes have a slot assigned (from the `static_nodes array`), where they each send 2 bytes, a counter value and a magic number. The round period is set to 2s.

All other paramters and settings are left to their default.
All other paramters and settings are left to their default.
8 changes: 3 additions & 5 deletions examples/baloo-sleeping-beauty/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
|Platform| Compilation command |
|:---|:---|
|TelosB
| make TARGET=sky |
|DPP-cc430
| make TARGET=dpp |
|TelosB | make TARGET=sky |
|DPP-cc430 | make TARGET=dpp |

This directory contains an re-implementation of the LWB protocol, meant to be as similar as possible as the descritption from
> C. Sarkar, R. V. Prasad, R. T. Rajan, and K. Langendoen
Expand All @@ -17,4 +15,4 @@ After 3 rounds without any new request, the host signals the end of the bootstra
The host then select a set of nodes that should remain active and send their data at every round. All other nodes go to sleep until the end of the scheduling period, which is 10-round long (ie 100s).

All others configuration parameters of Sleeping Beauty have been set according to [the original paper](https://ieeexplore.ieee.org/abstract/document/7815012/) description.
All values are in `project-conf.h` (`#define SB_xxx`).
All values are in `project-conf.h` (`#define SB_xxx`).
28 changes: 9 additions & 19 deletions examples/baloo-test-chaos/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
|Platform| Compilation command |
|:---|:---|
|TelosB
| make TARGET=sky |
|DPP-cc430
| _Not available for this platform_ |
|TelosB | make TARGET=sky |
|DPP-cc430 | _Not available for this platform_ |

This simple Baloo protocol illustrates the utilization of Chaos as communication primitive.

Expand All @@ -20,20 +18,12 @@ To use multiple communication primitives, the `#define GMW_CONF_USE_MULTI_PRIMIT
To use Choas as a primitive, the following defines must be configured
|#define| Rationale |
|:---|:---|
|CHAOS_CONF_NUM_NODES
| Number of nodes that contributes to the Chaos flood|
|CHAOS_CONF_NODE_ID_MAPPING
| Ordering of nodes to assign them a bit-mapping |
|CHAOS_CONF_SHARED_PAYLOAD
| When set to 1, the payload area of the Chaos
packet is shared among all participating nodes |
|CHAOS_CONF_PAYLOAD_LEN
| Size of the payload area of a Chaos packet.
|CHAOS_CONF_NUM_NODES | Number of nodes that contributes to the Chaos flood|
|CHAOS_CONF_NODE_ID_MAPPING | Ordering of nodes to assign them a bit-mapping |
|CHAOS_CONF_SHARED_PAYLOAD | When set to 1, the payload area of the Chaos packet is shared among all participating nodes |
|CHAOS_CONF_PAYLOAD_LEN | Size of the payload area of a Chaos packet.
If CHAOS_CONF_SHARED_PAYLOAD is set to 0 the available payload per node is CHAOS_CONF_PAYLOAD_LEN / CHAOS_CONF_NUM_NODES|
| CHAOS_CONF_SET_CUSTOM_PAYLOAD
| When set to 1, Chaos uses a custom agregation function: `chaos_set_payload_cb()`.
| CHAOS_CONF_SET_CUSTOM_PAYLOAD | When set to 1, Chaos uses a custom agregation function: `chaos_set_payload_cb()`.
When set to 0, Chaos simply copies each node's payload in the payload in their respective place (according to CHAOS_CONF_NODE_ID_MAPPING). |
|CHAOS_CONF_USE_TIMER_ISR
| Set to 0 enable the multiplexing of the timer ISR (`sky` platform only)|
|GLOSSY_CONF_USE_TIMER_ISR
| Set to 0 enable the multiplexing of the timer ISR (`sky` platform only)|
|CHAOS_CONF_USE_TIMER_ISR | Set to 0 enable the multiplexing of the timer ISR (`sky` platform only)|
|GLOSSY_CONF_USE_TIMER_ISR | Set to 0 enable the multiplexing of the timer ISR (`sky` platform only)|
8 changes: 3 additions & 5 deletions examples/baloo-test-corrupted/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
|Platform| Compilation command |
|:---|:---|
|TelosB
| make TARGET=sky |
|DPP-cc430
| make TARGET=dpp |
|TelosB | make TARGET=sky |
|DPP-cc430 | make TARGET=dpp |

This protocol illustrates the use of the interference detection feature. It is controlled (in `project-conf.h) by the following defines:

Expand All @@ -28,4 +26,4 @@ typedef enum {
} gmw_pkt_event_t;
```

To generate some contention, in this application, all data slots are contention slots. Every node decides with some probability wether it sends its own packet. Nodes that do not send receive a `GMW_EVT_PKT_CORRUPTED` or `GMW_EVT_PKT_CORRUPTED` event if the contention slot fails.
To generate some contention, in this application, all data slots are contention slots. Every node decides with some probability wether it sends its own packet. Nodes that do not send receive a `GMW_EVT_PKT_CORRUPTED` or `GMW_EVT_PKT_CORRUPTED` event if the contention slot fails.
8 changes: 3 additions & 5 deletions examples/baloo-test-static/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
|Platform| Compilation command |
|:---|:---|
|TelosB
| make TARGET=sky |
|DPP-cc430
| make TARGET=dpp |
|TelosB | make TARGET=sky |
|DPP-cc430 | make TARGET=dpp |

This simple Baloo protocol illustrates the utilization of the static control feature.

Expand All @@ -15,4 +13,4 @@ In this example, useful information is contained in `user_byte` section of the c

If either defines are unset, the middleware adapts: the control updates will be performed by the host as usual, using the `app_control_update` function in the `host_on_round_finished()` callback.

> **Note** When `GMW_CONF_USE_STATIC_CONFIG` is set to 1, neither the `gmw_config_t` nor the `gmw_slot_config_t` are included in the control packet, even if using the `GMW_CONTROL_SET_CONFIG(control)` and `GMW_CONTROL_SET_SLOT_CONFIG(control)`.
> **Note** When `GMW_CONF_USE_STATIC_CONFIG` is set to 1, neither the `gmw_config_t` nor the `gmw_slot_config_t` are included in the control packet, even if using the `GMW_CONTROL_SET_CONFIG(control)` and `GMW_CONTROL_SET_SLOT_CONFIG(control)`.
7 changes: 5 additions & 2 deletions examples/baloo-test-static/baloo-test-static.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,15 @@ static gmw_control_t control;
static uint8_t counter;

#ifdef FLOCKLAB
static const uint16_t static_nodes[] = { 1, 2, 3, 4, 6,
/*static const uint16_t static_nodes[GMW_CONF_MAX_SLOTS] =
{ 1, 2, 3, 4, 6,
7, 8,10,11,13,
14,15,16,17,18,
19,20,22,23,24,
25,26,27,28,32,
33};
33 };*/
static const uint16_t static_nodes[GMW_CONF_MAX_SLOTS] =
{ 11, 10, 9, 7, 6, 5, 4, 2 };
#else
static const uint16_t static_nodes[] = { 1, 1, 2, 2 };
#endif /* FLOCKLAB */
Expand Down
4 changes: 2 additions & 2 deletions examples/baloo-test-static/project-conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
* application specific config file to override default settings
*/

#define HOST_ID 1
#define HOST_ID 5

/* to compile for flocklab, pass FLOCKLAB=1 to the make command */
#ifdef FLOCKLAB
Expand Down Expand Up @@ -87,7 +87,7 @@

/* GMW configuration */
#define GMW_CONF_MAX_DATA_PKT_LEN 16
#define GMW_CONF_MAX_SLOTS 26
#define GMW_CONF_MAX_SLOTS 8
#define GMW_CONF_TX_CNT_DATA 2

#define GMW_CONF_PERIOD_TIME_BASE GMW_CONF_PERIOD_TIME_BASE_1ms
Expand Down
2 changes: 1 addition & 1 deletion examples/baloo-test-static_energy-model/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ ifeq ($(TARGET), dpp)
endif

# select the number of slots per round
CFLAGS += -DTTW_MAX_SLOTS_PER_ROUND=30
CFLAGS += -DTTW_MAX_SLOTS_PER_ROUND=5
# select the payload size
CFLAGS += -DTTW_MAX_PAYLOAD_LEN=8
# select the random seed
Expand Down
8 changes: 3 additions & 5 deletions examples/baloo-test-static_energy-model/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
|Platform| Compilation command |
|:---|:---|
|TelosB
| make TARGET=sky |
|DPP-cc430
| make TARGET=dpp |
|TelosB | _currently unavailable_ |
|DPP-cc430 | make TARGET=dpp |

This project evaluate the benefits of having communication rounds (vs no rounds), in a static framework (like TTW). The goal is to experimentally validate the latency and energy models for a Glossy-based NET layer protocol.

Written with the dpp in mind, but should also work on for the sky mote (the timing or some operations might be different though).
<!-- Written with the DPP-cc430 in mind, but should also work on for the sky mote (the timing or some operations might be different though). -->
4 changes: 4 additions & 0 deletions examples/baloo-test-static_energy-model/baloo-test-static.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ PROCESS_THREAD(app_process, ev, data)
{
PROCESS_BEGIN();

DEBUG_PRINT_MSG_NOW("GMW_CONF_T_DATA %lu", GMW_CONF_T_DATA);
DEBUG_PRINT_MSG_NOW("GMW_CONF_T_CONTROL %lu", GMW_CONF_T_CONTROL);
DEBUG_PRINT_MSG_NOW("GMW_CONF_MAX_DATA_PKT_LEN %u", GMW_CONF_MAX_DATA_PKT_LEN);


/* --- Application-specific initialization --- */

Expand Down
Loading

0 comments on commit 212dcde

Please sign in to comment.