当前位置:文档之家› PELCOD协议

PELCOD协议

PELCO D、P通讯协议

一、PELCO协议介绍

1、PELCO主控与前端解码器是通过RS422\RS485通信格式传输。

2、除PELCO原装设备支持RS422和RS485兼容接口,国内大部分厂家主控和接收设备仅支持RS485接口,RS485接口是半双工通信模式,即发送端发过去的控制命令,只管发出去,不管你收不收得到,有的厂家连续发,有的间隔发,总类很多。停止命令往往发1、2条。如PELCO\PANASONIC、三星等大厂做的通信接口,主控发出去命令,接收端收到命令返回SCK 命令给主控,叫回答命令,告知发送端我已收到命令,不用再发了,这就是RS422通信模式的一种用途。

3、PELCO协议内容包括云台控制命令、摄像机控制命令、辅助控制命令、预置位设置和调用命令。注意:网上PELCO协议版本众多,建议看家选择英文版本,中文版本很多错误。

4、Pelco P protocol details are proprietary, non-public documents. In almost all cases, Pelco's publicly available ASCII, G, or D protocols can be used in place of Pelco P with the appropriate translator. Pelco Product Support technicians may be able to assist you in obtaining the use of these protocols for your application. ASCII, G, and D protocols can be obtained be filling out our online registration form located. For further assistance please contact Pelco Product Support at (800)298-9100 or (559)292-1981.

二、PELCO-D协议

数据格式:1位起始位、8位数据、1位停止位,无效验位。波特率:2400bps.

命令格式:

1.该协议中所有数值都为十六进制数

2.同步字节始终为FFH

3.地址码为摄像机的逻辑地址号,地址范围:00H–FFH

4.指令码表示不同的动作,在有关预制点的操作时,数据2表示预制点值

5.数据1、2分别表示水平、垂直方向速度(00-3FH),FFH表示“turbo”速度

6.校验码 = MOD[(字节2 + 字节3 + 字节4 + 字节5 + 字节6)/100H]

Sence码与Bit4和Bit3有关。在Bit4和Bit3为1的情况下,如果Sence码为1,则

命令就是自动扫描和和摄像机打开;如果Sence码为0,则命令就是手动扫描和摄像机关闭。当然如果Bit4或Bit3为0的话那命令就无效了。

常用命令列表:

关于云台自动功能如何实现,云台的自动功能是做到解码板电路,有多种硬件电路方法,也有软件检测限位开关或者光耦中断来控制左和右自动扫描。但上面协议表是没有自动命令,在P协议里AUTOPAN命令是CALL 99号预置位。在D协议里是没有定义,编程者可以定义CALL #NO来实现。

D协议特殊命令控制表:

以地址码0x01为例:

{0xff,0x01,0x00,0x08,0x00,0xff,0x08,}

协议中所有数值都为十六进制数

始终为A0H

3.地址码为摄像机的逻辑地址号,地址范围:00H–1FH

4.指令码表示不同的动作

5.数据码1、2分别表示水平、垂直方向速度(00-3FH),在有关预制点的操作时,数据码2表示预制点值

始终为AFH

7.校验码(XOR sum of Bytes 2-6) = 字节2 ^ 字节3 ^ 字节4 ^ 字节5 ^ 字节6

常用命令列表:

P协议特殊命令控制表:

以地址码0x01为例:

{0xa0,0x01,0x00,0x08,0x00,0x30,0xaf,0x39,} The protocol uses no parity, one start bit, eight data bits, and one stop bit. The recommended baud rate is 4800 (4800, 8, N, 1, 1).

MESSAGE FORMAT

Byte 1 is always $A0

Byte 2 is the receiver address, set by DIP switch in the receiver

Byte 3-6, see below

Byte 7 is always $AF

Byte 8 is an XOR sum of Bytes 1-7

The protocol is “zero indexed” so that the hexadecimal address sent in the protocol for the first receiver is $00 which corresponds to address 1.

The bits within the “Data bytes” are broken up into two main groups. For Pan and Tilt commands, the functions are determined as follows:

PAN AND TILT COMMANDS

EXTENDED COMMAND SET

The extended command set will have bit 0 of data byte 2 set and will follow the format in the following table:

The receiver will respond with an ACK.

To accommodate features of new systems and maintain compatibility with our old systems, some functions have been added through the use of some of the unused preset functions. These are:

Preset Number Function

99Begin Auto-scan

98Begin Frame Scan

97Begin Random Scan

96Stop Scan

95Enter Menu Mode

94Remote Reset

93Set Right Limit Stop

92Set Left Limit Stop

34Home (return to 0 pan position)

33Flip

Examples:

To SET PRESET 32 in the receiver with address 1, the command string (in Hexadecimal) would be:

A0 00 00 03 00 20 AF 2C (the last byte is the XOR sum of bytes 1 through 7)

To drive receiver with address 2 LEFT at half speed:

A0 01 00 04 00 1F AF 15

四种PELCOD协议与三种PELCOP协议区别

建议编程者在做控制串口软件时,每帧命令输出时间间隔最好定义200ms/ 帧。

Ns2.34上leach协议的完美移植

Ns2.34上leach协议的完美移植 经过几天的不断实验,以及网上各位前辈的帮助,终于成功将leach协议完美移植到ns2.34上,下面是我的安装笔记。 Step1 在ns-2.34的目录下新建一个leach文件夹,将leach.tar.gz放入这个文件夹 Step2 在终端中进入这个目录下,键入tar zxf leach.tar.gz Step3 ①将leach/mit整个目录复制到ns-allinone-2.34/ns-2.34中 ②将leach/mac目录下的http://biz.doczj.com/doc/27630493.html,, mac-sensor.h, http://biz.doczj.com/doc/27630493.html,, mac-sensor-timers.h四个文件复制到ns-allinone-2.34/ns-2.34/mac中 ③将leach/tcl/mobility目录下的四个文件复制到ns-allinone-2.34/ns-2.34/tcl/mobility中 ④将ns-allinone-2.34/ns-2.34/tcl/ex目录下的wireless.tcl重命名为wireless_1.tcl,再将leach/tcl/ex目录下的wireless.tcl复制到ns-allinone-2.34/ns-2.34/tcl/ex中⑤将leach目录下的test,leach_test,package_up三个文件复制到ns-allinone-2.34/ ns-2.34中 Step3 修改文件 ①需要修改的文件有: ns-allinone-2.34/ns-2.34/apps/http://biz.doczj.com/doc/27630493.html,,app.h ns-allinone-2.34/ns-2.34/trace/http://biz.doczj.com/doc/27630493.html,,cmu-trace.h ns-allinone-2.34/ns-2.34/common/http://biz.doczj.com/doc/27630493.html,,http://biz.doczj.com/doc/27630493.html,,packet.h ns-allinone-2.34/ns-2.34/mac/http://biz.doczj.com/doc/27630493.html,,ll.h,http://biz.doczj.com/doc/27630493.html,,http://biz.doczj.com/doc/27630493.html,,phy.h,wireless-phy.c c,wireless-phy.h ②修改方法: 对于leach目录下相应的文件(即刚才未复制的文件),将代码中以“#ifdef MIT_uAMPS”开始,并以“#endif”结束的部分复制到以上文件对应的位置 这个过此要小心核对修改,否则前功尽弃 ③特殊情况 <1> ns-allinone-2.34/ns-2.34/common/packet.h中大约185行,根据其他变量的格式将代码更改为 #ifdef MIT_uAMPS static const packet_t PT_RCA = 61; #endif 并将最后一个枚举值改为62 这个过程可以随情况改变,还要注意的是packet.h文件并不是只改这一部分,前面的修改依然要。 <2> ns-allinone-2.34/ns-2.34/mac/wireless-phy.h,给类WirelessPhy添加public变量,大约105行 #ifdef MIT_uAMPS MobileNode * node_;

LEACH协议的算法结构及最新研究进展

LEACH协议的算法结构及最新研究进展 1 LEACH协议算法结构 LEACH这个协议的解释是:低功耗自适应集簇分层型协议。通过名字,我们就能想到这个协议的大概作用了。那么在这之中,我们先来研究一下它的算法。 该算法基本思想是:以循环的方式随机选择蔟首节点,将整个网络的能量负载平均分配到每个传感器节点中,从而达到降低网络能源消耗、提高网络整体生存时间的目的。仿真表明,与一般的平面多跳路由协议和静态分层算法相比,LEACH协议可以将网络生命周期延长15%。LEACH在运行过程中不断的循环执行蔟的重构过程,每个蔟重构过程可以用回合的概念来描述。每个回合可以分成两个阶段:蔟的建立阶段和传输数据的稳定阶段。为了节省资源开销,稳定阶段的持续时间要大于建立阶段的持续时间。蔟的建立过程可分成4个阶段:蔟首节点的选择、蔟首节点的广播、蔟首节点的建立和调度机制的生成。 蔟首节点的选择依据网络中所需要的蔟首节点总数和迄今为止每个节点已成为蔟首节点的次数来决定。具体的选择办法是:每个传感器节点随机选择0-1之间的一个值。如果选定的值小于某一个阀值,那么这个节点成为蔟首节点。 选定蔟首节点后,通过广播告知整个网络。网络中的其他节点根据接收信息的信号强度决定从属的蔟,并通知相应的蔟首节点,完成蔟的建立。最后,蔟首节点采用TDMA方式为蔟中每个节点分配向其传递数据的时间点。 稳定阶段中,传感器节点将采集的数据传送到蔟首节点。蔟首节点对蔟中所有节点所采集的数据进行信息融合后再传送给汇聚节点,这是一种叫少通信业务量的合理工作模型。稳定阶段持续一段时间后,网络重新进入蔟的建立阶段,进行下一回合的蔟重构,不断循环,每个蔟采用不同的CDMA代码进行通信来减少其他蔟内节点的干扰。 LEACH协议主要分为两个阶段:即簇建立阶段(setup phase)和稳定运行阶段(ready phase)。簇建立阶段和稳定运行阶段所持续的时间总和为一轮(round)。为减少协议开销,稳定运行阶段的持续时间要长于簇建立阶段。 在簇建立阶段,传感器节点随机生成一个0,1之间的随机数,并且与阈值T(n)做比较,如果小于该阈值,则该节点就会当选为簇头。在稳定阶段,传感器节点将采集的数据传送到簇首节点。簇首节点对采集的数据进行数据融合后再将信息传送给汇聚中心,汇聚中心将数据传送给监控中心来进行数据的处理。稳定阶段持续一段时间后,网络重新进行簇的建立阶段,进行下一轮的簇重建,不断循环。 2 LEACH协议的特点 1 为了减少传送到汇聚节点的信息数量,蔟首节点负责融合来自蔟内不同源节点所产生的数据,并将融合后的数据发送到汇聚点。 2 LEACH采用基于TDMA/CDMA的MAC层机制来减少蔟内和蔟间的冲突。 3 由于数据采集是集中的和周期性的,因此该协议非常适合于要求连续监控的应用系统。 4 对于终端使用者来说,由于它并不需要立即得到所有的数据,因此协议不需要周期性的传输数据,这样可以达到限制传感器节点能量消耗的目的。 5 在给定的时间间隔后,协议重新选举蔟首节点,以保证无线传感器网络获取同意的能量分布。

WSN中LEACH协议源码分析报告

WSN中LEACH协议源码分析 分析(一) 首先对wireless.tcl进行分析,先对默认的脚本选项进行初始化: set opt(chan)Channel/\VirelessChannel set opt(prop) Propagatioii/TwoRayGround set opt(netif)PhyAVirelessPhy set opt(mac) Mac/802_l 1 set opt(ifq) Qucuc/DropTail/PriQueue set opt(ll) LL set opt(ant) Antenna/OmniAntenna set opt(x) 0 。# X dimension of the topography set opt(y) 0。# Y dimension of the topography set opt(cp),H, set opt(sc) N../mobility/scene/scen-670x670-50-600-20-2u。# scenario file set opt(ifqlen)50o # max packet in if set opt(nn) 51。# number of nodes set opt(secd) 0.0 set opt(stop) 10.0 o # simulation time set opt(tr) out.tr。# trace file set opt(rp) dsdv 。 # routing protocol script set opt(lm) M on H。# log movement 在这个wireless.tcl中设置了一些全局变呈:: # #Initialize Global Variables # set ns_ [new Simulator] set chan [new $opt(chan)] set prop [new $opt(prop)] set topo [newTopography] set tracefd [open Sopt(tr) w] Stopo Ioad_flatgrid $opt(x) $opt(y) Sprop topography Stopo 这些初始化将在后而的使用中用到,该文件最重要的是创建leach 17点:创建方法如下: } elseif { [string compare Sopt(rp) M leach,,]==0} { for {set i 0} {$i < $opt(nn) } {incr i} { leach-create-mobile-node $i } 如果路由协议是leach协议,则在Uamps.tcl中调用leach-create-mobile-node方法创建leach节点。将在第二小节讲如何创建leach节点。 for {set i 0} {$i < $opt(nn) } {incr i} { $ns_ at $opt(stop).000000001 M Snode_($i) reset”。〃完成后,重宜右点的应用

无线传感器网络LEACH协议研究

无线传感器网络LEACH协议的研究 摘要:无线传感器网络因其在军事、经济、民生等方面广阔的应用前景成为21世纪的前沿热点研究领域[1]。在传感器节点能量有限的情况下,提高路由效率,延长网络寿命成为无线传感器网络需考虑的问题。由于采取分簇,数据融合的思想,LEACH协议有着较高的路由效率,但在实际应用,尤其是大规模网络中,仍存在负载不均衡等问题。本文主要分析了LEACH协议的基本思想及优缺点,随后针对大规模的网络环境对其分簇算法进行改进。前人提出一种有效的方法计算最优簇首个数,本文推算出适合本文中网络环境的公式并加以应用。本文用NS2进行仿真,仿真后的结果表明,改进后的分簇算法更为有效,延长了网络寿命,增大了网络传送数据量。 关键词:无线传感器网络;路由协议;LEACH;分簇思想 Research on Routing Protocol of LEACH in WSN Shen Y uanyi Dept. of Information and Telecommunication,NUPT ABSTRACT:Nowadays, wireless sensor network has become a hot spot of 21st century because of its wide application on military, economy and human life. On the condition that the energy of a sensor node is limited, how to improve the routing efficiency and expand the network’s lifespan has been an important issue to consider. LEACH maintains quite high routing efficiency for its idea of clustering and data gathering. But in practical, it still has problems such as load unbalance especially in large scale network. The article mainly analyses the basic idea of LEACH, the benefits and drawbacks of it and later introduce an improvement on clustering algorithm according to large scale network. Key words:WSN;routing protocol; LEACH; clustering 1LEACH协议介绍与分析 1.1 LEACH算法思想 算法基本思想[2]是:以循环的方式随机选择簇头节点,将整个网络的能量负载平均分配到每个传感器节点中,从而达到降低网络能源消耗、提高网络整体生存时间的目的。LEACH在运行过程中不断的循环执行簇的重构过程,每个簇重构过程可以用回合的概念来描述[3]。每个回合可以分成两个阶段:簇的建立阶段和传输数据的稳定阶段。 1.2 LEACH算法的分析 LEACH协议的优点[4]有: (1)LEACH 通过减少参与路由计算的节点数目,减少了路由表尺寸。(2)LEACH协议是一种分簇路由协议,降低了非簇首节点的任务复杂度,不必对通信路由进行维护。(3)协议不需要周期性的传输数据。(4)在给定的时间间隔后,协议重新选举簇首节点,以保证无线传感器网络获取同意的能量分布。 由于LEACH算法是建立在一些假设上,所以在实际应用中LEACH协议存在一些问题:(1)在LEACH协议中,簇头的选举是随机产生的,这样的随机性可能会导致簇头

LEACH协议簇头

《单片机原理与接口技术》期中论文 论文题目 LEACH协议簇头 选择算法的改进 姓名 学号 学院电气工程学院 专业班级 2008级通信工程

目录 引言................................. 错误!未定义书签。 1 LEACH协议 .......................... 错误!未定义书签。 LEACH 协议介绍.................... 错误!未定义书签。 LEACH 协议的能量损耗模型.......... 错误!未定义书签。 LEACH 的不足在于:................ 错误!未定义书签。 LEACH 协议的优化.................. 错误!未定义书签。 基本思想....................... 错误!未定义书签。 改进细节........................ 错误!未定义书签。 2 簇头选择算法的改进LEACH-H ........... 错误!未定义书签。 簇头初选........................... 错误!未定义书签。 簇头调整过程....................... 错误!未定义书签。 3仿真结果 ............................ 错误!未定义书签。 4仿真分析 ............................ 错误!未定义书签。 5结束语 .............................. 错误!未定义书签。参考文献 ............................. 错误!未定义书签。

Ubuntu安装ns-2.35及leach协议安装

Ubuntu 13.10下安装ns-2.35及leach协议安装 powered by Hong Sheng , Jiangsu university ,Zhenjiang 583301743@http://biz.doczj.com/doc/27630493.html, Tue Nov 25 , 2013 之所以选择基于linux的操作系统ubuntu来安装ns2,是因为我个人特别讨厌Microsoft 开发的基于windows的cygwin软件,此软件安装的时候不仅有各种错误,UI也不够友好。而,有关ubuntu的安装,大家可以自行baidu或google之。下面只讲解ns-2.35和leach协议的安装过程。 1. Ubuntu 13.10下ns- 2.35安装 step 1:下载ns2.35,http://biz.doczj.com/doc/27630493.html,/s/1h8rj0#dir/path=%2FNS解压,放在home/xx下,xx是你的用户名 step 2:更新源包,终端输入:sudo apt-get update step 3:安装依赖包 sudo apt-get install tcl8.5-dev tk8.5-dev sudo apt-get install build-essential autoconf automake sudo apt-get install perl xgraph libxt-dev libx11-dev libxmu-dev step 4:修改ns-allinone-2.35中ls.h文件的代码 将void eraseAll() { erase(baseMap::begin(), baseMap::end()); } 改为: void eraseAll() { this->erase(baseMap::begin(), baseMap::end()); } step 5:sudo ls /usr/bin/gcc* //查看系统已经安装的gcc版本。Ubuntu 13.10默认安装了gcc-4.8 //和gcc-4.8版本的,如果是其他版本的linux操作系统且没有安装 //高于4.0版本的gcc/g++。则需要手动安装gcc/g++-4.8 sudo apt-get install gcc-4.8 g++-4.8 // 对于Ubuntu 13.10,此项是非必须的 sudo export CC=gcc-4.8 sudo export CXX=g++-4.8 //CC和CXX是全局变量,用来指定make将会用哪个版本的gcc/g++编译器生成 //makefile文件。如果没有这一步,保证你会makefile失败!!!因为,在ns-2.35文件夹//下的makefile.in 中要求配置全局变量。 echo $CC echo $CXX //查看全局变量导入成功了没有,如果成功,则执行 sudo ./install //开始进行安装,大概等5分钟左右。 ....... 出现以下的内容,每个人的/home/xx/不同,我的用户名是nan,所以,显示了以下信息。 Ns-allinone package has been installed successfully. Here are the installation places: tcl8.5.10: /home/nan/ns-allinone-2.35/{bin,include,lib} tk8.5.10: /home/nan/ns-allinone-2.35/{bin,include,lib} otcl: /home/nan/ns-allinone-2.35/otcl-1.14 tclcl: /home/nan/ns-allinone-2.35/tclcl-1.20 ns: /home/nan/ns-allinone-2.35/ns-2.35/ns nam:/home/nan/ns-allinone-2.35/nam-1.15/nam xgraph: /home/nan/ns-allinone-2.35/xgraph-12.2 gt-itm: /home/nan/ns-allinone-2.35/itm, edriver, sgb2alt, sgb2ns, sgb2comns, sgb2hierns

LEACH协议的MATLAIB仿真代码

Matlab Code for LEACH NodeNums = 100; % the num of node AreaR = 100 ; % the area of simulate NodeTranR=10; % the transit Radius Elec=50 * 10^(-9); % Eamp=100*10^(-12); Bx=50; % The Postion of Baseation By=175; MaxInteral =700; % the leach simulate time Pch=0.05; % the desired percentage of cluster heads InitEn=0.5; % the init energy of all node Tr=30; TDMA=100; Kbit=2000; % the bits of a node transmiting a packet every time BandWitch = 1*10.^(6); % Channel Bandwitch TOS_LOCAL_ADDRESS = 0; for i=1:(MaxInteral) AliveNode(i)=NodeNums; AmountData(i)=0; end sym alldata; alldata=0; LAECH = zeros(1,MaxInteral); LAENO = zeros(1,MaxInteral); for i=1:1:NodeNums EnNode(i)=InitEn; % the init energy of all node StateNode(i)=1; % the State of all node 1: alive 0:dead ClusterHeads(i)=0; % the Set of Cluster Head ,1: cluster head 0 :node Rounds=0; % the round end Threshold=0; % the threshold of node becoming a cluster-head Node.x=AreaR*rand(1,NodeNums); % the position of node Node.y=AreaR*rand(1,NodeNums); Node.c=zeros(1,NodeNums); Node.d=zeros(1,NodeNums); Node.l=zeros(1,NodeNums); Node.csize=zeros(1,NodeNums); Node.initclEn=zeros(1,NodeNums); % for i=1:NodeNums % Node.c(i)=0; % the Cluster head of node

SEP协议

1 SEP:A Stable Election Protocol for clustered heterogeneous wireless sensor networks G EORGIOS S MARAGDAKIS I BRAHIM M ATTA A ZER B ESTAVROS Computer Science Department Boston University gsmaragd,matta,best@http://biz.doczj.com/doc/27630493.html, Abstract—We study the impact of heterogeneity of nodes, in terms of their energy,in wireless sensor networks that are hierarchically clustered.In these networks some of the nodes become cluster heads,aggregate the data of their cluster members and transmit it to the sink.We assume that a percentage of the population of sensor nodes is equipped with additional energy resources—this is a source of heterogeneity which may result from the initial setting or as the operation of the network evolves. We also assume that the sensors are randomly(uniformly) distributed and are not mobile,the coordinates of the sink and the dimensions of the sensor?eld are known.We show that the behavior of such sensor networks becomes very unstable once the?rst node dies,especially in the presence of node heterogeneity.Classical clustering protocols assume that all the nodes are equipped with the same amount of energy and as a result,they can not take full advantage of the presence of node heterogeneity.We propose SEP,a heterogeneous-aware protocol to prolong the time interval before the death of the?rst node(we refer to as stability period),which is crucial for many applications where the feedback from the sensor network must be reliable. SEP is based on weighted election probabilities of each node to become cluster head according to the remaining energy in each node.We show by simulation that SEP always prolongs the stability period compared to(and that the average throughput is greater than)the one obtained using current clustering protocols. We conclude by studying the sensitivity of our SEP protocol to heterogeneity parameters capturing energy imbalance in the network.We found that SEP yields longer stability region for higher values of extra energy brought by more powerful nodes. I.I NTRODUCTION Motivation:Wireless Sensor Networks are networks of tiny, battery powered sensor nodes with limited on-board process-ing,storage and radio capabilities[1].Nodes sense and send their reports toward a processing center which is called“sink.”The design of protocols and applications for such networks has to be energy aware in order to prolong the lifetime of the network,because the replacement of the embedded batteries is a very dif?cult process once these nodes have been deployed.Classical approaches like Direct Transmission and Minimum Transmission Energy[2]do not guarantee well balanced distribution of the energy load among nodes of the sensor http://biz.doczj.com/doc/27630493.html,ing Direct Transmission(DT),sensor nodes transmit directly to the sink,as a result nodes that are far away from the sink would die?rst[3].On the other hand, using Minimum Transmission Energy(MTE),data is routed This work was supported in part by NSF grants ITR ANI-0205294,EIA-0202067,ANI-0095988,and ANI-9986397.over minimum-cost routes,where cost re?ects the transmission power expended.Under MTE,nodes that are near the sink act as relays with higher probability than nodes that are far from the sink.Thus nodes near the sink tend to die fast.Under both DT and MTE,a part of the?eld will not be monitored for a signi?cant part of the lifetime of the network,and as a result the sensing process of the?eld will be biased.A solution proposed in[4],called LEACH,guarantees that the energy load is well distributed by dynamically created clusters,using cluster heads dynamically elected according to a priori optimal probability.Cluster heads aggregate reports from their cluster members before forwarding them to the sink.By rotating the cluster-head role uniformly among all nodes,each node tends to expend the same energy over time. Most of the analytical results for LEACH-type schemes are obtained assuming that the nodes of the sensor network are equipped with the same amount of energy—this is the case of homogeneous sensor networks.In this paper we study the impact of heterogeneity in terms of node energy.We assume that a percentage of the node population is equipped with more energy than the rest of the nodes in the same network—this is the case of heterogeneous sensor networks.We are motivated by the fact that there are a lot of applications that would highly bene?t from understanding the impact of such heterogeneity.One of these applications could be the re-energization of sensor networks.As the lifetime of sensor networks is limited there is a need to re-energize the sensor network by adding more nodes.These nodes will be equipped with more energy than the nodes that are already in use,which creates heterogeneity in terms of node energy.Note that due to practical/cost constraints it is not always possible to satisfy the constraints for optimal distribution between different types of nodes as proposed in[5]. There are also applications where the spatial density of sen-sors is a constraint.Assuming that with the current technology the cost of a sensor is tens of times greater than the cost of embedded batteries,it will be valuable to examine whether the lifetime of the network could be increased by simply distribut-ing extra energy to some existing nodes without introducing new nodes.1 1We also study the case of uniformly distributing such extra energy over all nodes.In practice,however,it maybe dif?cult to achieve such uniform distribution because extra energy could be expressed only in terms of discrete battery units.Even if this is possible,we show in this paper that such fair distribution of extra energy is not always bene?cial.

Leach协议

目录 一、Leach协议与NS的关系 (2) 二、算法设计思想 (3) 三、簇头建立算法流程图 (4) 四、难点解决 (6) 五、算法运行结果分析 (9) 参考文献 (9)

一、Leach协议与NS的关系 为了实现leach 协议,对ns进行扩展。在ns中增加了一个事件驱动模拟器支持模拟无线传感器网络协议。这些扩展包括MAC协议,用于计算和交互的能量分配模型和leach协议的体系结构。 网络拓扑结构可以通过简单的Nodes, Links, Agents和Applications 描述。Nodes相当于网络中的终端主机, Links 是用于Nodes交互的连接器, Agent用来实现不同网络协议,是支持分组产生和丢弃的节点。Applications 用来产生数据和实现不同的应用函数。一旦网络拓扑结构建立起来后,模拟通过启动节点上的Applications运行。 为了在ns中支持无线传感器网络,在ns中增加了 mobile nodes, MAC 协议和信道传播模型Channel 。 Applications类的头文件用Tcl语言写的,节点中的其他函数功能用C++语言写成的。 数据包的发送过程: Applications创建数据包(data packets),然后发送给Agent. Agent执行协议栈中运输层和网络层的功能,将数据包发送给CMUTrace,。 CMUTrace将packets的统计数据写到trace 文件,然后将packets发至Connector。Connector将数据包传送给用于数据链路处理的链路层(LL).经过一小段时间的延迟后,数据包由LL发送给Queue缓冲队列。如果是还没有传送过的数据包,Queue将以队列进行存储。然后Queue将数据包出队列,发送到MAC层。然后开始运行MAC(媒体访问控制)协议。最终,packets被发送到网络接口层(Network Interface),网络接口层将packets加上正确的传输能量,然后将packets发送到Channel. Channel将packets进行拷贝,并发往连接信道的每一个节点。 发送过程可参考如下图1 数据包的接收过程: 数据包被节点的网络接口接收,并被向上传送至MAC层,Link-Layer, Connector, CMUTrace, 和Agent 函数. Agent 对数据包进行判定,并将数据包到达的信息通知给Application. 接收过程与发送过程传输的路径相反。

相关主题