当前位置:文档之家› Ubuntu安装ns-2.35及leach协议安装

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

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

powered by Hong Sheng , Jiangsu university ,Zhenjiang

583301743@https://www.doczj.com/doc/954135817.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,https://www.doczj.com/doc/954135817.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

Please put

/home/nan/ns-allinone-2.35/bin:/home/nan/ns-allinone-2.35/tcl8.5.10/unix:/home/nan/ns-allin one-2.35/tk8.5.10/unix

into your PATH environment; so that you'll be able to run itm/tclsh/wish/xgraph.

IMPORTANT NOTICES:

(1) You MUST put /home/nan/ns-allinone-2.35/otcl-1.14, /home/nan/ns-allinone-2.35/lib,

into your LD_LIBRARY_PATH environment variable.

If it complains about X libraries, add path to your X libraries

into LD_LIBRARY_PA TH.

If you are using csh, you can set it like:

setenv LD_LIBRARY_PA TH

If you are using sh, you can set it like:

export LD_LIBRARY_PA TH=

(2) You MUST put /home/nan/ns-allinone-2.35/tcl8.5.10/library into your TCL_LIBRARY

environmental

variable. Otherwise ns/nam will complain during startup.

After these steps, you can now run the ns validation suite with

cd ns-2.35; ./validate

step 6: 根据提示设置环境变量。

在Ubuntu 系统中有两种设置环境变量PA TH 的方法。第一种适用于为单一用户设置PATH,第二种是为全局设置PATH。

第一种方法:

在用户主目录下有一个.bashrc 文件,可以在此文件中加入PATH 的设置如下:export PATH=”$PATH:/your path1/:/your path2/…..”

注意:每一个path 之间要用“:“分隔,PA TH=之间不要有任何空格,否则会导入失败。

第二种方法:

在/etc/profile中增加。

PATH="$PATH:/ your path1"

export PATH

两者之间的区别在于,第一种方法只在当前用户下有效,而第二种方法对所有的用户都有效。两者是局部与全局的关系。执行

sudo gedit ~.bashrc //~等价于home/xx

本文根据环境变量设置的第一种方法,在.bashrc文件尾部加入相应的代码。如在我的机子上就是:

#PA TH

export

PATH="$PATH:/home/nan/ns-allinone-2.35/bin:/home/nan/ns-allinone-2.35/tcl8.5.10/unix:/h ome/nan/ns-allinone-2.35/tk8.5.10/unix"

#LD_LIBRARY_PATH

export

LD_LIBRARY_PA TH="$LD_LIBRARY_PATH:/home/nan/ns-allinone-2.35/otcl-1.14:/hom e/nan/ns-allinone-2.35/lib"

# TCL_LIBRARY

export TCL_LIBRARY="$TCL_LIBRARY:/home/nan/ns-allinone-2.35/tcl8.5.10/library "

2.leach协议安装

1.下载mit包https://www.doczj.com/doc/954135817.html,/s/1h8rj0#dir/path=%2FNS,解压,将解压之后的文件夹重新命名为leach。

2. 比较leach文件夹与ns-2.35文件夹(Note:不是ns-allinone-2.35),并做以下copy

?将leach目录下的test , leach_test , package_up 3个文件及mit文件夹复制到ns-2.35 ?将ns-2.35/tcl/ex/wireless.tcl的文件重命名为wireless1.tcl ,再将leach/tcl/ex/wieless.tcl 复制到 ns-2.35/tcl/中

?leach/mac目录下的https://www.doczj.com/doc/954135817.html, ,mac-sensor-timers.h ,https://www.doczj.com/doc/954135817.html, mac-sensor.h 4个文件复制到ns-2.35/mac目录下

?leach/tcl/mobility目录下的leach-c.tcl , leach.tcl , mte.tcl , stat-clus.tcl 4个文件复制到 ns-2.35/tcl/mobility目录下

3.将leach文件夹中的

(1) apps / https://www.doczj.com/doc/954135817.html, , app.h

(2) trace /https://www.doczj.com/doc/954135817.html, , cmu-trace.h

(3) common / packet.h , https://www.doczj.com/doc/954135817.html, , https://www.doczj.com/doc/954135817.html,

(4) mac / https://www.doczj.com/doc/954135817.html, , ll.h , https://www.doczj.com/doc/954135817.html, , phy.h , https://www.doczj.com/doc/954135817.html, mac / https://www.doczj.com/doc/954135817.html, , wireless-phy.h 文件中以 #ifdef MIT_uAMPS开始,以#endif结束的部分添加到ns-2.35文件夹中的对应的文件中。这个修改的工作量巨大,建议使用Beyond Compare软件协助修改。修改的时候特别注意,不要覆盖ns-2.35中原来的代码。

4.需要特别修改的部分

将wireless-phy.h中(约149行)MobileNode* node_; 前的注释取消掉。

将https://www.doczj.com/doc/954135817.html,中(约234行)node_ = (Node *)obj; 改为node_ = (MobileNode *)obj 将mac/https://www.doczj.com/doc/954135817.html,里的第133行,node_ =(Node *)obj; 同样改为node_ = (MobileNode *)obj;

将common/packet.h里添加的

#ifdef MIT_ MPS

PT_RCA,

#endif 修改为

#ifdef MIT_uAMPS

static const packet_t PT_RCA=73;

#endif

// insert new packet types here

static packet_t PT_NTYPE = 74; // This MUST be the LAST one 将mac/wireless-phy.h文件中(约143行)的private注释掉。

修改/ns-2.35/mit/uAMPS/ns-leach.tcl

将set dst_ $mac_dsc改为set dsc_addr $mac_dsc

5. 修改ns-2.35的makefile(可根据leach提供的makefile修改)

1).在DEFINE处添加宏定义:-DMIT_uAMPS

2).在INCLUDES处添加包含路径:-I./mit/rca -I./mit/uAMPS

3).在gaf/gaf.o前添加

mit/rca/energy.o mit/rca/rcagent.o \

mit/rca/rca-ll.o mit/rca/resource.o \

mac/mac-sensor-timers.o mac/mac-sensor.o mit/uAMPS/bsagent.o \

6.将test文件内容修改为

#!/bin/bash

cd tcl/ex

ns wireless-demo-csci694.tcl

sleep 2

cd ..

cd ..

./leach_test

7. 在mit\uAMPS\sims\uamps.tcl文件中$env(RCA_LIBRARY)修改为mit/tca

$env(uAMPS_LIBRARY) 修改为mit/uAMPS

8.修改test及leach_test的权限

sudo chmod 777 test

sudo chmod 777 leach_test // 不明白777 含义的,可以百度或者google自己找答案

9.运行./test

10.查看mit /leach_sims中的lech.out文件。

参考文献

[1] https://www.doczj.com/doc/954135817.html,/s/blog_b0992ce90101apqu.html#bsh-24-314759742

[2] https://www.doczj.com/doc/954135817.html,/chenkai619/article/details/7645272

[3] https://www.doczj.com/doc/954135817.html,/s/blog_4c44d3110101cl9h.html#bsh-24-315847529

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目录下的https://www.doczj.com/doc/954135817.html,, mac-sensor.h, https://www.doczj.com/doc/954135817.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/https://www.doczj.com/doc/954135817.html,,app.h ns-allinone-2.34/ns-2.34/trace/https://www.doczj.com/doc/954135817.html,,cmu-trace.h ns-allinone-2.34/ns-2.34/common/https://www.doczj.com/doc/954135817.html,,https://www.doczj.com/doc/954135817.html,,packet.h ns-allinone-2.34/ns-2.34/mac/https://www.doczj.com/doc/954135817.html,,ll.h,https://www.doczj.com/doc/954135817.html,,https://www.doczj.com/doc/954135817.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 在给定的时间间隔后,协议重新选举蔟首节点,以保证无线传感器网络获取同意的能量分布。

Ubuntu软件安装方法完全指南

Ubuntu软件安装方法完全指南 Ubuntu软件安装方法完全指南 刚开始使用Ubuntu的用户时常有这样的问题,我要安装新软件怎么办?.exe文件在哪里,怎么软件有这么多格式?RPM包,.tar.gz是什么?怎么就是安装不了啊?等等等等.的确,在Windows下安装文件只需要双击即可,所以很多人在Ubuntu下觉得很不习惯.事实上,使用Ubuntu平台下的新利得软件包管理器安装大部分软件比在Windows平台下更加简单,操作更加容易.当然,也有很多软件Ubuntu的储藏库里面没有,而这些软件有着各式各样的格式,因而安装方法也都不一样.下面我就Ubuntu下安装软件的方法做一个详细的总 一.使用新立得软件包管理器安装程序.新立得拥有一个友好的图形界面,你可以使用它安装大部分Ubuntu软件库里已有的程序.定位到系统-系统管理-新立得软件包管理器启动,基于安全考虑,系统会提示你输入管理员密码.在这里,你可以搜索你需要安装的程序,标记后应用即可. 3步安装:搜索,标记,应用 搜索你需要安装的程序.在新立得里面有成千上万种主题,应用程序,软件包,文档.所有的这些文件包都被存放在Ubuntu的服务器上供下载和升级.新立得相当于一个升级版的w indows升级工具,因为它除了可以升级系统文件之外,还可以通过它安装的非关键性程序.你可以在侧边栏的分类中查找软件.点击工具栏上的搜索图标进行搜索. 找到需要安装的文件包后,右键点击标记.系统很有可能会提示你一些依赖程序将会同时被安装,幸运的是这些系统会自动为你解决.记住:你可以使用同样的步骤卸载程序(右键 点击,选择卸载).你也可以一次标记多个安装包以节省时间. 标记完毕所有需要安装的文件之后,点击应用图标.新立得会自动下载安装. 常见问题: 1.如果找不到我需要的文件怎么办? 其实这是很正常的.大概说来有以下3个原因: 新立得软件包管理器里面的所有文件包都来自Ubuntu的主源,但是除了默认的源之外还有很多非官方软件源.在你放弃安装之前尝试一下激活额外的源.

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”。〃完成后,重宜右点的应用

Ubuntu 软件的安装与升级

第9章 Ubuntu 软件的安装与升级 教学提示:软件的安装与系统升级是使用操作系统基本任务,Ubuntu Linux操作系统采用APT管理软件,使Linux系统软件安装维护方面更加方便易用。本章涉及的内容主要有APT管理基础知识,命令或者图形环境软件的安装与升级。 教学要求:学习完本章后,将了解APT软件管理原理,能够使用命令与图形界面进行软件的安装与系统升级, 9.1 ATP简介 以往,使用过Windows而又转用Linux的用户一定为软件的安装与系统的安全升级烦恼,当对于有类似Red Hat那样的RMP包安装方式,linux是一大进步,但是对于RPM包安装一个很大的问题就是包的依赖性与安装后的软件维护问题,现在Ubuntu提供了APT (高级软件包工具,Advanced 软件包名Tool),在软件安装维护方面更加方便易用,使用起来比Windows的安装与维护甚至更为方便。 在Linux最初只有.tar.gz的打包文件,用户必须编译每个他想在Linux上运行的软件。对于用户,一方面,需要一个快速、实用、高效的方法来安装软件包;另一方面,当软件包更新时,这个工具应该能自动管理关联文件和维护已有配置文件。Debian率先解决了这个问题,这就是APT(Advanced Packaging Tool)。作为Debian的孪生兄弟Ubuntu自然就采用了这种高级的高级软件包管理工具。 9.2 命令环境软件的安装与升级 9.2.1常用apt类命令 1.apt-get—文本环境的软件的安装、升级与移除命令 apt-get 命令会检查软件包的完整性关系,如果即使完整性检查失败了仍然继续安装,

无线传感器网络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协议中,簇头的选举是随机产生的,这样的随机性可能会导致簇头

ubuntu用源码安装软件

在Ubuntu中附带了丰富的软件,这些软件一般使用图形化的自动方式(“添加/删除”或“新立得”)即可轻松安装,但是对于那些刚刚问世的新软件,Ubuntu的源中还未 收录其中,这时我们就需要用到一种更通用的安装方式:通过手工方式从源文件来安装这些 软件。下面就介绍这种手工安装方式的详细步骤。 一、安装编译程序 因为要编译源代码,所以第一步就是安装编译和构建之类的程序。如果你已经安装过了,可以跳过此步。在Ubuntu系统中非常简单,只要执行下面命令就行了: $ sudo apt-get install build-essential 该命令执行后,从源文件安装软件所需的工具,如gcc、make、g++及其他所需软件就 安装好了。 二、下载并编译软件的源代码 当我们下载源文件时,一定要弄清该软件所依赖的库文件和其他程序,并且首先将它们 装好。这些信息,通常都能在该开源项目的主页上查找到。做好这些准备工作后,我们就可 以进行下面的工作了。因为,软件的源代码通常以压缩文件形式发布,所以需要将其解压到 指定目录。命令如下所示: OwnLinux@ubuntu:~$ tar xvzf program.tar.gz OwnLinux@ubuntu:~$ cd program/ 如果你的对tar命令不熟悉请点击这里阅读《tar命令详解》 在Linux下从源文件安装程序时,有一个通用模式,即配置(。/configure)–>编译(make)–>安装(sudo make install)。但是,此前你最好还是阅读源文件中附带的安 装说明,因为对于每个程序,其开发者的指示才是最具权威性的。程序开发者通常将安装说 明存放在名为INSTALL或README.到哪里找这些文件呢?它们在项目主页或源代码主目录中 都能找到。 1.配置 构建应用的第一步就是执行configure脚本,该脚本位于程序源文件的主目录下: OwnLinux@ubuntu:~/program$ ./configure 该脚本将扫描系统,以确保程序所需的所有库文件业已存在,并做好文件路径及其他所 需的设置工作。如果程序所需的库文件不完全,该配置脚本就会退出,并告诉您还需要哪些 库文件或者是哪些版本太旧需要更新。如果遇到这种情况,仅弄到含有该库文件的软件包还 是不够的,同时还要找到具有该库文件所有头文件的开发包,在Ubuntu中,这样的包一般 以-dev作为文件名的结尾。安装好所有需要的库文件后,重新运行配置脚本,直到没有错 误提示为止,这说明需要的库文件已经全部安装妥当了即满足了依赖关系。 2.编译 当配置脚本成功退出后,接下来要做的就是编译代码了。具体操作为在源文件的主目录 中运行make命令: OwnLinux@ubuntu:~/program$ make 这时,您会看到一串编译输出数据迅速从屏幕上滚过,如果正常的话,系统会返回的提 示符状态。然而,如果编译过程中出现错误的话,排错的过程可就不像配置步骤那么简单了。因为,这通常要涉及到源代码的调试,可能源代码有语法错误,或其他错误等等。怎么办? 如果您是编程高手,那就自己调试吧!否则,检查该软件的邮件列表等支持渠道,看看是不 是已知的bug,如果是就看看别人是怎么解决的,不是就提交一份bug报告吧,也许不久就 会有解决办法。 3.安装

LEACH协议簇头

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

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

ubuntu软件安装卸载删除

说明:由于图形化界面方法(如Add/Remove...和Synaptic Package Manageer)比较简单,所以这里主要总结在终端通过命令行方式进行的软件包安装、卸载和删除的方法。 一、Ubuntu中软件安装方法 1、APT方式 (1)普通安装:apt-get install softname1softname2…; (2)修复安装:apt-get-f install softname1softname2...;(-f Atemp to correct broken dependencies) (3)重新安装:apt-get--reinstall install softname1softname2...; 2、Dpkg方式 (1)普通安装:dpkg-i package_name.deb 3、源码安装(.tar、tar.gz、tar.bz2、tar.Z) 首先解压缩源码压缩包然后通过tar命令来完成 a.解xx.tar.gz:tar zxf xx.tar.gz b.解xx.tar.Z:tar zxf xx.tar.Z c.解xx.tgz:tar zxf xx.tgz d.解xx.bz2:bunzip2xx.bz2 e.解xx.tar:tar xf xx.tar 然后进入到解压出的目录中,建议先读一下README之类的说明文件,因为此时不同源代码包或者预编译包可能存在差异,然后建议使用ls-F--color或者ls-F命令(实际上我的只需要l命令即可)查看一下可执行文件,可执行文件会以*号的尾部标志。一般依次执行./configure make sudo make install 即可完成安装。 二、Ubuntu中软件包的卸载方法 1、APT方式

Ubuntu16.04环境上安装常用软件的方法

在Ubuntu16.04环境中安装常用软件的方法 1.在ubuntu16.04环境中修改IP,MAC和DNS: /*卡设备,进行修改 sudo gedit /etc/init.d/rc.local sudo ens33 dowm sudo ens33 hw ether xx:xx:xx:xx:xx:xx(mac地址) sudo ens33 up -----但是好像重启后就有字段修改了网卡地址*/----忽略这个这个吧 通过下面设置,可完成ip,mac,dns的修改 sudo gedit /etc/network/interfaces 修改如下: auto lo iface lo inet loopback auto ens33 iface ens33 inet static pre-up ifconfig ens33 hw ether xx:xx:xx:xx:xx:xx(mac地址) address x.x.x.x(ip地址) netmask 255.255.0.0 gateway x.x.x.x 保存后,需要PC再查看ifconfig 就发现ip和mac是更改了的 -----也可以单独设置DNS、MAC地址 sudo gedit /etc/resolv.conf nameserver xx.xx.xx.xx//设置的dns 2.使用Xftp往linux环境中上传文件,则buntu上必须先安装有ssh,安装和设 置SSH服务步骤如下: 最好是切换到root用户下sudo su 安装ssh-server

sudo apt-get install openssh-server ●安装ssh-client sudo apt-get install openssh-client ●确认sshserver是否安装 ps –e|grep ssh /etc/init.d/ssh start ●扩展配置 SSH默认服务端口为22,用户可以自已定义成其他端口,如222,需要修改的配置文件为: gedit /etc/ssh/sshd_config 把里面的Port参数修改成222即可 然后重启SSH服务: sudo/etc/init.d/ssh restart 3.在本机安装Xshell,连接Ubuntu中的linux ●确保Ubuntu可以联网 ●ssh服务启动了 ●打开xshell,新建连接 ●在【用户身份验证】下,输入自己linux操作系统下的普通用户名和密码, 之后【确认】-【连接】

iraf在ubuntu下的安装过程

IRAF安装之傻瓜篇 对于刚刚入手的人来说最头疼的莫过于安装,其实真正经历过后才知道,这种头疼多半来自于对IRAF植根的土壤Linux等操作系统的不熟悉和道听途说的前人经历,亲手安装过,就没有什么好头疼的了,10分钟搞定,完全不在话下。本文就简要介绍一下IRAF的安装过程。 本文中默认的操作系统是Linux/Ubuntu or Debian也是我在用的操作系统,如果你是其他的Linux甚至是MaxOS用户,安装过程也都是大同小异的,有出入的地方我也会尽量自己的说明。本文介绍的版本从IRAF到需要的一些包都是最新的版本,不过据IRAF的维护者介绍,下一阶段的开发目标中就包括了使得IRAF的安装过程更加简化,到了那时,可能这篇文章也就没什么必要了。 第一步,安装tcsh以及一些必要的包 sudo apt-get install tcsh wget https://www.doczj.com/doc/954135817.html,/~rubab/iraf/ldso_1.9.11-15_i386.deb sudo dpkg -i ldso_1.9.11-15_i386.deb wget https://www.doczj.com/doc/954135817.html,/~rubab/iraf/libc5_5.4.46-15_i386.deb sudo dpkg -i libc5_5.4.46-15_i386.deb wget https://www.doczj.com/doc/954135817.html,/~rubab/iraf/termcap-compat_1.2.3_i386.deb sudo dpkg -i termcap-compat_1.2.3_i386.deb **说明,这一步不是必须的,如果你不想用tcsh(推荐还是用吧)的话,下载的包是为了Ubuntu/Debian的deb包,当然也不难找到rpm包.sudo是为了用管理员权限操作,如果你已经拥有了管理员权限,可以不用;wget是一款很好用的命令行下载软件,现在的Ubuntu 和Fedora系统一般都是自带的吧,如果没有的话也没关系,到后面的网址下载就好了;包的安装这里用的是Ubuntu自带的包管理器dpkg,这个也没什么好说的了。 第二步:建立IRAF用户 这也是比较好玩的一步,对IRAF来说,一个单独的IRAF用户是必需的,不过以前有过需要安装两遍的说法(IRAF用户一遍,其他的再一篇),至少在现在是不必要的,只要改一下IRAF用户的权限就好了,这个用户只是IRAF软件的需要,并不一定真的要用。

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

Ubuntu 13.10下安装ns-2.35及leach协议安装 powered by Hong Sheng , Jiangsu university ,Zhenjiang 583301743@https://www.doczj.com/doc/954135817.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,https://www.doczj.com/doc/954135817.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

Ubuntu安装教程及设置

Ubuntu安装教程及设置 部门: xxx 时间: xxx 制作人:xxx 整理范文,仅供参考,可下载自行修改

Ubuntu 11.10 <手动分区:/、swap、/home) 2.4 所在地区和国家 2.5 键盘类型 2.6 使用者资料及密码

2.7 完成安装 2.8 初次开机 三.安装后系统设置 3.1 设置网络 3.1.1 有线网络 3.1.2 无线网络 3.1.3 拨号上网 3.4 输入法 3.5 修正时区及时间 3.6 硬件驱动 3.7 Unity 3D 3.8 Gnome3 3.9 窗口按钮改为右手<使用于Unity桌面) 四.安装软件 4.1 安装压缩工具 4.2 flash插件 4.3 Google Chrome浏览器 4.4 QQ

Ubuntu 10.10的安装图解过程

ubuntu 10.10在很多细节方面做了改变,采用了全新的主题,全新的菜单样式,全新的软件中心,全新的字体,全新的软件管理,以及全新面貌的Ubuntu One服务体系。一切的一切都是全新的,相信Ubuntu 10.10定能给那些关注它的用户带来全新的体验。 全新安装界面人性化做到极致 谈起Linux的安装,一直以来都给人一种非常死板和专业的感觉,即使是最注重人性化的Ubuntu,在早期版本中的安装程序也并不能做到绝对的“傻瓜化”。本次Ubuntu 10.10将安装程序重新制作,即使是计算机新手,也可以非常快速的部署自己的Ubuntu系统。 插入ubuntu 10.10光盘之后,默认启动程序不再是一个简陋的菜单,而是经过启动后的安装界面 界面详细的告知用户的可用选项,用户可自行选择“试用Ubuntu”还是“安装Ubuntu” 安装系统之前的选择 确定了安装意向之后,安装程序会对当前电脑状态进行一个评估,主要取决于以下三点: - 磁盘空间是否足够; - 是否有稳定电源; - 是否已经联网;

对于计算机的判定 如果有部分条件没有满足,Ubuntu会及时进行提醒,告知用户安装时可能出现的某些问题,让用户有备无患。 接下来是对硬盘空间的分配,用户可以选择全新安装,亦可以选择高级自定义。

分配磁盘空间 即使选择高级自定义磁盘分配,分配的过程也是比较简单的,选择磁盘,详细划归即可。 自定义空间划分 接下来就是值得夸赞的部分了,安装程序下侧已经出现了详细安装进度条,此时系统安装已经先行开始,而上方则是要求用户在对于登录用户名,系统时间和键盘布局等细节选项进行调整。

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@https://www.doczj.com/doc/954135817.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 https://www.doczj.com/doc/954135817.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.

相关主题
文本预览
相关文档 最新文档