文档介绍:浙江工业大学计算机学院
实验报告
实验名称无线传感网络实验之丢包率检测
日期 2014年12月30日
实验内容
本次实验主要是通过代码的编写测试节点的发送功率和距离的远近对接收节点的丢包率的影响。。其中距离的远近的调节是容易实现的。而对丢包率的计算是由接收节点的主机B将收到的数据包打印到屏幕上,主机A烧写的节点则是实现每次发送100个数据包。
二、程序源代码
主机A(发送方)
#ifndef BLINKTORADIO_H
#define BLINKTORADIO_H
enum {
AM_BLINKTORADIO = 6,
TIMER_PERIOD_MILLI = 250
};
typedef nx_struct BlinkToRadioMsg {
nx_uint16_t nodeid;
nx_uint16_t counter;
} BlinkToRadioMsg;
#endif
#include <>
#include ""
configuration BlinkToRadioAppC {
}
implementation {
components MainC;
components LedsC;
components BlinkToRadioC as App;
components new TimerMilliC() as Timer0;
components ActiveMessageC;
components new AMSenderC(AM_BLINKTORADIO);
components new AMReceiverC(AM_BLINKTORADIO);
-> MainC;
-> LedsC;
-> Timer0;
-> AMSenderC;
-> AMSenderC;
-> ActiveMessageC;
-> AMSenderC;
-> AMReceiverC;
}
#include <>
#include ""
module BlinkToRadioC {
uses interface Boot;
uses interface Leds;
uses interface Timer<TMilli> as Timer0;
uses interface Packet;
uses interface AMPacket;
uses interface AMSend;
uses interface Receive;
uses interface SplitControl as AMControl;
}
implementation {
uint16_t counter;
messag