NS-2下的zigbee

这些日子,为了使论文更加完善,再对Zigbee网络进行网络仿真。选择的工具是ns-2 ,开始上手时,真是有点不太熟悉,现在搞了几天算是有点头绪了。

为了对Zigbee网络进行认真,找了好长时间,终于找到一个高人的网站 , 从名字上看,像是一个中国人,但它只提供了802.15.4的PHY层和MAC层的代码,路由方式只有AODV方式,并没有zigbee所使用的 Cluster-Tree方式的路由,据网站作者说是因为,他看到了最新的zigbee协议规格书,发现Cluster-Tree的路由方式较以前有所改 变,所以怕引起别人的误解,所以就将他称的"ZBR"路由方式统一换成了AODV方式,这样一来就给我造成了极大的困难,我是两眼一片黑啊!

没办法,只能硬着头皮找啊!最后发现,在使用ns-2进行Zigbee仿真,并将源代码公开的,就只有这位高人了,并且我发现很多人的文章里也在使用他的 源代码。(可能是因为我找的还不够认真吧,因为我用“zigbee simulation ns 2”作为关键词在google上找,至少打开前20页是毫无斩获!后面还有好多页,我是没有心情再去打开了!)

我是费尽了20%以上的脑细胞了,终于在网上找到了一个救命的稻草---(No ad-hoc routing agent)NOAH ,我大致看了一下,觉得至少只要我建立好路由表,它的通信方式Cluster-tree路由方式有些类似,而路由表的建立方式就是笨办法了,基本靠手了,在TCL脚本里使用:

eval "[$node_(13) set ragent_] routing 1 0 5"---eval 就不用讲了,1 0 5的意思是建立"1"个路由,目标地址为"0",而下一跳的地址为"5";当然了这样的语句是可以向后加的,一次可以加这个节点的到多个节点的路由。

用这种笨的方法,我手动的建立了所有节点到中心节点的路由信息后,一试,果然是按我指定的路由传送数据,心中一片狂喜,然后又看了一下tr文件,里 面的显示与我所理解的路由方式是一样的(可能我接触这个东西还是太短的时间,不到1周的时间,所以有好多东西理解的还不够深入,所以要是有高人可以看到这 个东西的话,觉得不妥,请批评指正!)

网络仿真当然要有一些关于能量,通信距离的参数设置问题,所以我又到网上找了一下,根据这个网页 ,我对我的系统情况进行了设置:

首先搞明白:dBm是以dB表示的毫瓦的数量。例如,250mW等于10* log10(250)= +24dBm

1dB压缩点 (P1dB )是输出功率的性能参数。压缩点越高意味着输出功率越高。P1dB 是指与在很低的功率时相比增益减少1dB时的输入(或输出)功率点。参见图2 ,增益随输入功率变化的曲线。注意当输入功率升高时增益是如何下降的。这是因为在其最大输出功率时器件达到饱和于是功率不能继续上升。1dB压缩点可以在输入或输出定义。例如,如果输出P1dB 规范是+20dBm,则这个元件的输出功率约为+20dBm。减小输出功率使之低于P1dB 将减小失真。
这两个概念我以前有些模糊,这次借这个机会又在这个网站 上学习了一下。

我使用的射频芯片是CC2420,它的输出功率为0dBm,Receiver sensitivity 是-95dBm。而使用的功放芯片,1dB压缩点是23dBm,也就相当于它的输出功率了。

ns-2提供了三种传播模式:
Free-Space Model : The free space model is the simplest of the three models with a direct line of sight path between the transmitter and the receiver. If the devices are arounf the transmitter within its operating space, along a circle around it, then it would receive all the packets. Otherwise, it loses all the packets.
Two-Ray Ground Model : This is a slightly improved version of the Free-Space model. In this model other than the direct line-of-sight link, a ground reflection is also considered. When the distance between the transmitter and the receiver is long, the Two-Ray Ground model would provide much more accurate results than the Free-Space Model.
Shadowing Model : The two propagation models described so far, are mostly suitable for short range communications where a line-of-sight or a near line-of-sight is possible. However, when the distance between the transmitter and the receiver is considerable, as in mobile communications, the transmitted signal would undergo, fading effects, due to multipath propagation. The first two models do not take this into account. Hence this model is widely used in simulating diverse wireless networks.
所以我选择了第二种传播方式。
天线使用:Omni directional Antenna

----------各参数设置-----------------
Pr = −97dBm = 3.1623× 10−13 W             //接受阈值
Pt_= 0.197526W           //l输出功率 
Gt = 1.0              
//传输增益  
Gr = 1.0             
   //接收增
L = 1.0               //Path loss  
ht = 0.02m
                                            //发送天级高度
hr = 0.02m             //接收天线高度

Pr(d) = PtGrGthr2 ht2/ d4 L                                            

                             3.1623 × 10−13 =( 0.197526 × 1.0 × 1.0 × (0.02)2 × (0.02)2    ) / ( d4 × 1.0 )

                 =>         d =(0.000000031660416 / (3.1623 × 10−13 ) ) ¼

                 =>         d = 17.78@   18m                             

---------------------------------------

原文网址:http://hi.baidu.com/kuns/blog/item/b6a9f2de9ed2d45595ee3732.html


你可能感兴趣的:(网络,Google,脚本,mobile,Path,Signal)