guide you changing RDC and MAC protocols for a contiki project(如何在contiki工程中修改默认的rdc,mac协议))
来源:互联网 发布:home软件下载 编辑:程序博客网 时间:2024/05/16 06:30
In low-power networks, the radio transceiver must be switched off as much as possible to save energy. In Contiki, this is done by the Radio Duty Cycling (RDC) layer. Contiki provides a set of RDC mechanisms, with various properties. The default mechanism is ContikiMAC.
The MAC (Medium Access Control) layer sits on top of the RDC layer. The MAC layer is responsible for avoiding collisions at the radio medium and retransmitting packets if there were a collision. Contiki provides two MAC layers: a CSMA (Carrier Sense Multiple Access) mechanism and a NullMAC mechanism, that does not do any MAC-level processing.
This guide shows how to change RDC and MAC layer in Contiki. We assume you have your Contiki project already set up. If not, see theDevelop your first application guide.
Table of Contents
- About MAC Drivers
- About RDC drivers
- Step 1: Add a project-conf.h file to the Makefile
- Step 2: Create the project-conf.h file
- Step 3a: Specify a new RDC channel check rate
- Step 3b: Specify a new RDC driver
- Step 3c: Specify a new MAC driver
- Step 4: Recompile
- Conclusions
About MAC Drivers
Contiki provides two MAC drivers, CSMA and NullMAC. CSMA is the default mechanism. The MAC layer receives incoming packets from the RDC layer and uses the RDC layer to transmit packets. If the RDC layer or the radio layer detects a radio collision, the MAC layer may retransmit the packet at a later point in time. The CSMA mechanism is currently the only MAC layer that retransmits packets if a collision is detected.
About RDC drivers
Contiki has several RDC drivers. The most commonly used are ContikiMAC, X-MAC, CX-MAC, LPP, and NullRDC. ContikiMAC is the default mechanism that provides a very good power efficiency but is somewhat tailored for the 802.15.4 radio and the CC2420 radio transceiver. X-MAC is an older mechanism that does not provide the same power-efficiency as ContikiMAC but has less stringent timing requirements. CX-MAC (Compatibility X-MAC) is an implementation of X-MAC that has more relaxed timing than the default X-MAC and therefore works on a broader set of radios. LPP (Low-Power Probing) as a receiver-initiated RDC protocol. NullRDC is a "null" RDC layer that never switches the radio off and that therefore can be used for testing or for comparison with the other RDC drivers.
RDC drivers keep the radio off as much as possible and periodically check the radio medium for radio activity. When activity is detected, the radio is kept on to receive the packet. The channel check rate is given in Hz, specifying the number of channel checks per second, and the default channel check rate is 8 Hz. Channel check rates are given in powers of two and typical settings are 2, 4, 8, and 16 Hz.
The transmitted packet must generally be repeated or "strobed" until the receiver turns on to detect it. This increases the power usage of the transmitting node as well as adding radio traffic which will interfere with the communication among other nodes. Some RDCs allow for "phase optimization" to delay strobing the tx packet until just before the receiver is expected to wake. This requires a good time sync between the two nodes; if the clocks differ by 1% the rx wake time will shift through the entire tx phase window every 100 cycles, e.g. 12 seconds at 8 Hz. This would make phase optimization useless when there are more than a few seconds between packets, as the transmitter would have to start sending well in advance of the predicted receiver wake. A clock drift correction might fix this. See RDC Phase Optimization for more details.
The Contiki RDC drivers are called:
contikimac_driver xmac_driver cxmac_driver lpp_driver nullrdc_driver
Step 1: Add a project-conf.h file to the Makefile
A Contiki project can have an optional per-project configuration file, called 'project-conf.h'. This file is, however, not enabled by default. To enable it, we need to add the following line to the project's Makefile:
CFLAGS += -DPROJECT_CONF_H=\"project-conf.h\"
The full Makefile may now look something like this:
CONTIKI = /home/user/contiki CFLAGS += -DPROJECT_CONF_H=\"project-conf.h\" include $(CONTIKI)/Makefile.include
Step 2: Create the project-conf.h file
We now need to create the project-conf.h file. This file should be called project-conf.h and reside in the project's directory.
The project-conf.h file may override a number of Contiki configuration options. In this example, we will override the radio duty cycle layer driver.
Step 3a: Specify a new RDC channel check rate
We first change the RDC channel check rate. This is done by adding a #define to the project-conf.h file that specifies the channel check rate, in Hz:
#define NETSTACK_CONF_RDC_CHANNEL_CHECK_RATE 16
Step 3b: Specify a new RDC driver
To specify what RDC driver Contiki should use, add another #define to the project-conf.h file:
#define NETSTACK_CONF_RDC nullrdc_driver
Step 3c: Specify a new MAC driver
To specify what MAC driver Contiki should use, add another #define to the project-conf.h file:
#define NETSTACK_CONF_MAC nullmac_driver
Step 4: Recompile
After having specified the project-conf.h file in the Makefile, it is necessary to clean up existing dependencies with the make clean command:
make TARGET=sky clean
This is only needed the first time, however. Next, just compile as usual:
make TARGET=sky
Conclusions
Radio Duty Cycling (RDC) and Medium Access Control (MAC) protocols are an important part of the Contiki netstack as they ultimately determine the power consumption of the nodes and their behavior when the network is congested. This guide demonstrates how to change RDC and MAC protocols for a Contiki project by adding a project-conf.h file and adding the necessary configuration statements to it.
(详细参见: https://github.com/contiki-os/contiki/wiki/Change-mac-or-radio-duty-cycling-protocols)
- guide you changing RDC and MAC protocols for a contiki project(如何在contiki工程中修改默认的rdc,mac协议))
- Contiki中MAC层与RDC层
- Contiki:关于MAC和RDC层的关系、作用及其实现
- Contiki:RDC &CoAP
- Contiki:RDC &CoAP
- Rdc for mac 不能全屏的问题
- [Contiki系列论文之4]ContikiMAC RDC协议
- contiki MAC
- contiki MAC
- 使用Microsoft RDC for Mac在Mac和Windows间传文件
- 使用 Microsoft RDC for Mac 在 Mac 和 Windows 间传文件
- Contiki之MAC协议:MAC协议架构
- 如何在研发项目中提高RDC的研发能力
- MAC微软远程桌面RDC不能全屏的的解决方法
- 在RDC的日子(一)————学习如何定义接口
- Contiki之MAC协议:802.15.4帧frame
- Contiki
- 云效(原RDC)如何构建一个基于Maven的Java项目
- MySQL不插入重复记录
- 动态图片切换
- 第六周项目1-深复制体验
- swipeListView 和 PullToRefreshView 合体!
- Python 将毫秒转换成日期
- guide you changing RDC and MAC protocols for a contiki project(如何在contiki工程中修改默认的rdc,mac协议))
- static class 静态类(Java)
- 十道海量数据处理面试题
- HashMap和HashSet的区别
- Java内存与垃圾回收调优
- 物联网开源软件
- 数据结构学习笔记
- 剖析cmd >file 2>&1 和 cmd >file 2>file 的差别
- javascript常用对象的源码--Array用法