NS中的基本无线模型_第1页
NS中的基本无线模型_第2页
NS中的基本无线模型_第3页
NS中的基本无线模型_第4页
NS中的基本无线模型_第5页
已阅读5页,还剩58页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、NS Tutorial: mobile and wireless network simulation,Chuda Liu XJTU April 10th, 2004,Outlines,1. 引言:NS中的基本无线模型 2. 对CMU的无线模型的扩展 3. 应用举例,1. 引言:NS中的基本无线模型,1.1 创建无线拓扑 1.2 创建MN的移动 1.3 MN中的网络组件 1.4 MAC协议 1.5 Ad hoc 路由协议 1.6 Trace支持 1.7 对无线Trance格式的修改 1.8 产生节点移动和业务连接的场景文件,1. 引言:NS中的基本无线模型,引言 无线模型MobileNode支

2、持Adhoc # 创建adhoc ragent -llType $opt(ll) -macType $opt(mac) -ifqType $opt(ifq) -ifqLen $opt(ifqlen) -antType $opt(ant) -propInstance new $opt(prop) -phyType $opt(netif) -channel new $opt(chan) -topoInstance $topo -wiredRouting OFF -agentTrace ON -routerTrace OFF -macTrace OFF,1.1 创建无线拓扑,创建MN: for se

3、t j 0 $j $opt(nn) incr j set node_($j) $ns_ node $node_($i) random-motion 0 ;# disable random motion,Node,ARP,Propagation and antenna models,MobileNode,LL,MAC,PHY,LL,CHANNEL,LL,MAC,PHY,protocol Agent /src/sink,routing agent,addr classifier,port classifier,255,IFQ,IFQ,defaulttarget_,Radio propagation

4、/ antenna models,Prop/ant,Mobilenode示意图,Node,ARP,Propagation and antenna models,MobileNode,LL,MAC,PHY,LL,CHANNEL,protocol agent,routing agent,addr classifier,port classifier,255,IFQ,defaulttarget_,Mobilenode示意图,物理层: 1.无线电波模型表示: 近处:Pant =1/r2 a free space prop. 远处:Pant =1/r4 two-ray ground 2.每个MN有一个或

5、多个网络接口,相同的类型的接口接到一个通道 Pkt - Chan Obj 计算延时-调度 包到达事件-通告接收接口pkt到达- 比较pkt的能量级别t0: 载波侦听阀值t1 和接收阀值t2: if t0t1 then discard pkt; else if t1t0t2 mark err; recv pkt并传至MAC层,Node,ARP,Propagation and antenna models,MobileNode,LL,MAC,PHY,LL,CHANNEL,protocol agent,routing agent,addr classifier,port classifier,255

6、,IFQ,defaulttarget_,Mobilenode示意图,MAC层: 实现了完整的IEEE 802.11 DCF,Node,ARP,Propagation and antenna models,MobileNode,LL,MAC,PHY,LL,CHANNEL,protocol agent,routing agent,addr classifier,port classifier,255,IFQ,defaulttarget_,Mobilenode示意图,ARP 地址解析协议 MAC地址IP地址,SRNode不用 address demux or classifiers ; 节点接收到的

7、所有包默认地 转发到DSR代理; DSR代理或者将pkt送到端口 dmux或者按源路路由转发pkt,1.2 创建MN的移动,MN被设计成在一个三维拓扑中移动,但Z轴未用(Z0); MN的坐标随MN的移动而改变; 有2种机制引入MN的移动: 指定MN的起始和终点位置 随机移动模式 创建MN前需要定义拓扑 set topo new Topography $topo load_flatgrid $opt(x) $opt(y,node set X_ $node set Y_ $node set Z_ $ns at time Snode setdest,1.3 MN中的网络组件,MN的网络栈有以下组件:

8、 LL ARP MAC IFQ netIF Channel 它们在MN中的add-interface()方法创建, The following setups up link layer, mac layer, network # interface , physical layer structures for the mobile node. Node/MobileNode instproc add-interface channel pmodel lltype mactype qtype qlen iftype anttype $self instvar arptable_ nifs_ $

9、self instvar netif_ mac_ ifq_ ll_ global ns_ MacTrace opt set t $nifs_ incr nifs_ set netif_($t) new $iftype ;# net-interface set mac_($t) new $mactype ;# mac layer set ifq_($t) new $qtype ;# interface queue set ll_($t) new $lltype ;# link layer set ant_($t) new $anttype # Local Variables set nullAg

10、ent_ $ns_ set nullAgent_ add-interface(1/8,set netif $netif_($t) set mac $mac_($t) set ifq $ifq_($t) set ll $ll_($t) # # Initialize ARP table only once. # if $arptable_ = set arptable_ new ARPTable $self $mac set drpT cmu-trace Drop IFQ $self $arptable_ drop-target $drpT # # Link Layer # $ll arptabl

11、e $arptable_ $ll mac $mac $ll up-target $self entry $ll down-target $ifq add-interface(2/8, # Interface Queue # $ifq target $mac $ifq set qlim_ $qlen set drpT cmu-trace Drop IFQ $self $ifq drop-target $drpT # # Mac Layer # $mac netif $netif $mac up-target $ll $mac down-target $netif $mac nodes $opt(

12、nn) add-interface(3/8, # Network Interface # $netif channel $channel $netif up-target $mac $netif propagation $pmodel ;# Propagation Model $netif node $self ;# Bind node interface $netif antenna $ant_($t) ;# attach antenna # # Physical Channel # $channel addif $netif ;# add to list of interfaces # =

13、 # Setting up trace objects add-interface(4/8, # Network Interface # $netif channel $channel $netif up-target $mac $netif propagation $pmodel ;# Propagation Model $netif node $self ;# Bind node interface $netif antenna $ant_($t) ;# attach antenna # # Physical Channel # $channel addif $netif ;# add t

14、o list of interfaces # = # Setting up trace objects add-interface(5/8, # Network Interface # $netif channel $channel $netif up-target $mac $netif propagation $pmodel ;# Propagation Model $netif node $self ;# Bind node interface $netif antenna $ant_($t) ;# attach antenna # # Physical Channel # $chann

15、el addif $netif ;# add to list of interfaces # = # Setting up trace objects add-interface(6/8,if $MacTrace = ON # # Trace RTS/CTS/ACK Packets # set rcvT cmu-trace Recv MAC $self $mac log-target $rcvT # # Trace Sent Packets # set sndT cmu-trace Send MAC $self $sndT target $mac sendtarget $mac sendtar

16、get $sndT # # Trace Received Packets # set rcvT cmu-trace Recv MAC $self $rcvT target $mac recvtarget $mac recvtarget $rcvT add-interface(7/8, # Trace Dropped Packets # set drpT cmu-trace Drop MAC $self $mac drop-target $drpT else $mac log-target $ns_ set nullAgent_ $mac drop-target $ns_ set nullAge

17、nt_ # = $self addif $netif add-interface(8/8,1.3.1 Link Layer(LL,仿真数据链路层协议,实现分组的分段、重组等; LL层负责设MAC目的地址在分组的MAC 头,1.3.2 ARP,Address Resolution Protocol 接收从LL来的查询 ,如果ARP目的地址的硬件地址, 它将其写入分组的MAC头; 否则广播一个ARP查询, 并临时缓存分组; 对每个未知目的地址的硬件地址, 有一个缓存为每个分组; 对有相同目的地址的分组若发送到ARP, 早先缓存的分组被丢弃; 一旦分组下一跳的硬件地址知道, 分组被插入到interf

18、ace queue(Ifq); The ARPTable./ns-2/arp.h 被实现在arp.cc,h和tcl/lib/ns-mobilenode.tcl,1.3.3 Interface Queue,优先队列PriQueue./ns-2/priqueue.h对路由分组给较高优先级, 将它们插入队列头; 对对列中的所有分组有过虑作用并移除那些特定目的地址的分组; 见priqueue.cc,h 为IFq 实现,1.3.4 MAC Layer,IEEE 802.11 distributed coordination function (DCF) Mac 协议由CMU实现; 对单播分组它使用RTS

19、/CTS/DATA/ACK 模式; 对广播分组只简单发送DATA; 实现物理和虚拟载波侦听; Mac802_11被实现在mac-802_11.cc,h,1.3.5 Network Interfaces,Network Interface layer作为用于MN访问 channel 的硬件接口; 无线共享媒体接口在Phy/WirelessPhy./ns-2/wireless-phy.h中实现,这种接口容易产生冲突并且由 radio propagation model 接收由其他节点接口发送到channel的分组; 接口给每个发送的分组分发时间戳 以及给出发送接口的meta-data,如发送功率、

20、 波长等参数; meta-data在pkt头,propagation model用来在接收netIF 确定是否分组有能被接收and/or captured and/or detected (carrier sense) by the receiving node的最小功率; 模型用近似DSSS radio interface (Lucent WaveLan direct-sequence spread-spectrum),netIF实现见phy.cc.h 和wireless-phy.cc,h,1.3.6 Radio Propagation Model,近距离使用 Friss-space att

21、enuation (); 远距离近似使用Two ray Ground () ; 近似假设频谱在一个平面中反射; 实现见tworayground.cc,h,1.3.7 Antenna,MN使用有统一增益的全向天线omni-directional antenna. 实现见antenna.cc,h,1.5 路由代理,DSDV DSR TORA AODV,1.5.1 Destination-Sequenced Distance Vector (DSDV,DSDV需要节点周期性的广播路由更新,采用逐跳路由,与传统的DV比,不会产生环路; 基本机制: 每个节点维护一个路由表,为每个可达目的地址列出下一跳;

22、 DSDV给每个路径一个序列标记,若路径R比R好:要么序列号高,要么测度 值低; 网络中的节点通告单调递增的序列号; 若节点B得知到目的D的路径断了,则以一个无穷大的测度和序列号比原来 值大1的通告到D的路径,1.5.1 Destination-Sequenced Distance Vector (DSDV,实现细节; 路由信息在MN间交换,当邻节点的路由信息在路由表中发生 变化,路由更新会被触发和转发; 若分组到目的地的路径未知时会被缓存,同时发送路由查询, 缓存至路径应答返回; 缓存分组数目到达分组最大时,后来的分组会被丢弃. 到MN的所有分组被地址dmux直接传至端口dmux. 端口dm

23、ux 传送分组到分别的目的代理,端口255用来连接路由代理。 MN也使用一个default-target 在分类器或地址demux中。 路由协议主要在C+中实现. DSDV实现的相关程序见dsdv 目录和tcl/mobility/dsdv.tcl,1.5.2 Dynamic Source Routing (DSR,DSR采用源路由而不是逐跳路由,其优点是中间节点不需要维护路由信息更新。 基本机制有2个: 路径发现 节点S需要发送一个分组到目的D以获得到目的D的源路径; *源节点S以泛洪方式广播一个ROUTE REQUEST到网络; *从目的节点或知道目的节点返回一个ROUTE REPLY到S。

24、 (为减少开销,每个节点维护一个它已经知道的源路径,以减少发送RREQ的频率和传输) 路径维护 当网络拓扑改变后,需要更新源路径; 实现细节: 见dsr 目录和 tcl/mobility/dsr.tcl,1.5.3 Temporally-Ordered Routing Algorithm (TORA,TORA是基于“反向链路”算法的分布式路由协议,按需发现路径,给一个目的提供多个路径,快速建立路径。 基本机制,1.5.4 Ad Hoc On-Demand Distance Vector (AODV,TORA是基于“反向链路”算法的分布式路由协议,按需发现路径,给一个目的提供多个路径,快速建立路

25、径。 基本机制,1.6 Trace Support,无线仿真的Trace支持仍然用cmu-trace对象。 cmu-trace对象有三类:CMUTrace/Drop, CMUTrace/Recv和CMUTrace/Send. 这些用来在应用层agent、网络层router和链路层MAC跟踪分组的丢弃、接收和发送事件。 用来实现无线跟踪支持的方法和程序可在trace.cc,h和tcl/lib/ns-cmutrace.tcl找到,1.7 Revised format for wireless traces,1.8 产生节点移动和业务连接场景,2 对cmu无线模型的扩展,原来的CMU无线模型仅允许仿

26、真 wireless LANs 和ad-hoc networks,为了用它仿真有线和无线节点必须对它扩展,称为wired-cum-wireless feature。SUN公司集成MIP到无线模型允许MN允许MIP 2.1 wired-cum-wireless 场景 2.2 MIP,2.1 wired-cum-wireless场景,当需要仿真一个由多个 WLAN通过有线节点相连的拓扑,或需要无线节点运行MIP 则需要扩展CMU模型; 面临的主要问题是路由,因为在NS中路由信息产生基于拓扑的联通性,如节点怎样经过Link和其他节点相连; 而MN无Link的概念,它们在无线拓扑范围内通过路由协议传送

27、分组到其他,因此这2类节点如何交换分组? BaseStationNode被引入作为优先和无线域的网关,本质上基站节点是一个层次节点(HierNode)和MobileNode的混合节点。基站节点负责转发分组到和出无线域,这协议层次路由来实现它。 每个无线域和基站应有一个唯一的域地址分配给他们,所有到无线节点的分组到达改无线节点域所属的基站,基站最终将其传到MN;MN发送分组到无线域外需先发送到基站,基站知道如何转分组到有线目的. 在wired-cum-wireless中MN需要支持层次寻址/路由,Figure 16.3: Schematic of a baseStationNode,2.1 Mo

28、bile IP,wired-cum-wireless 扩展无线模型为在NS中支持无线MIP奠定了基础MIP模型基于有线模型 (由节点和链路组成)并且不用CMU的移动模型; MIP由HA和FA组成, MH在HA和FAs间移动,HA和FA本质上为基站节点,而MHs为mobileNodes,MIP扩展的方法和程序在以下文件中:ns/mip.cc,h, ns/mip-reg.cc, ns/tcl/lib/ns-mip.tcl,ns/tcl/lib/ns-wireless-mip.tcl.。 HA和FA节点 被定义为MobileNode/MIPBS,有注册代理(regagent_) 发送信号到MN, 建

29、立了encapsulator和decapsulator。 MH节点 被定义为MobileNode/MIPMH,也有regagent_ 接收和相应 信号,并发送请求到HA或FAs.。 MobileNode/MIPMH与MobileNode/MIPBS相似,除了它没有封装和解封装器。 对 SRNode 版的MH, 没有层次分类器 和由RA代理组成节点实体,Figure 16.4: Schematic of a Wireless MobileIP BaseStation Node,2.1 Mobile IP,MobileNode/MIPBS节点广播信号或通告消息到MHs,一个来自MN的请求产生一个通

30、告,该通告直接发送到请求MH。 发送信号的基站的地址被MH听到,并用作 MH的COA (care-of-address). 因此当MH从家网移到外部域,其COA会改变. 当从MH接收到reg_request (as reply to ads),基站会检查是否是MH的HA,若不是,它建立解封装并转发reg_request到MH的HA. In case the base-station is the HA for the requesting MH but the COA doesnot match its own, it sets up an encapsulator and sends reg

31、-request-reply back to the COA (address of the FA) who has forwarded the reg_request to it. so now all packets destined to the MH reaching the HA would be tunneled through the encapsulator which encapsulates the IP pkthdr with a IPinIP hdr, now destined to the COA instead of MH. The FAs decapsulator

32、 recives this packet, removes the encapsulation,A simple wireless simulation(1,Scenario containing 3 mobile nodes moving within 670mX670m flat topology using DSDV ad hoc routing protocol Random Waypoint mobility model TCP and CBR traffic See: ns-2/tcl/ex/wireless-demo-csci694.tcl,A simple wireless s

33、imulation(2,set ns_ new Simulator ; create a ns simulator instance,Define Global Variables,set topo new Topography ; create a topology and $topo load_flatgrid 670 670 ; define it in 670 x670 area,A simple wireless simulation (3,Define standard ns/nam trace,set tracefd open 694demo.tr w $ns_ trace-al

34、l $tracefd,set namtrace open 694demo.nam w $ns_ namtrace-all-wireless $namtrace 670 670,A simple wireless simulation (4,Create “God,set god_ create-god 3 God is used to store an array of the shortest number of hops required to reach from one node to an other. For example: $ns_ at 899.00 “$god_ setdi

35、st 2 3 1,A simple wireless simulation (5,Define how a mobile node should be created,ns_ node-config -adhocRouting DSDV -llType LL -macType Mac/802_11 -ifqLen 50 -ifqType Queue/DropTail/PriQueue -antType Antenna/OmniAntenna -propType Propagation/TwoRayGround -phyType Phy/WirelessPhy -channelType Chan

36、nel/WirelessChannel -topoInstance $topo -agentTrace ON -routerTrace OFF -macTrace OFF,A simple wireless simulation (6,Create a mobile node and attach it to the channel,set node $ns_ node $node random-motion 0 ;# disable random motion,Use “for loop” to create 3 nodes: for set i 0 $i3 incr i set node_

37、($i) $ns_ node,A simple wireless example(7,A simple wireless example(8,Wireless Scenario Generator(1,Mobile Movement Generator setdest -n -p pausetime -s -t -x -y See an example Random movement $node start Source: See ns-2/indep-utils/cmu-scen-gen/setdest,Wireless Scenario Generator(2,Generating tra

38、ffic pattern files CBR traffic ns cbrgen.tcl -type cbf|tcp -nn nodes -seed seed -mc connections -rate rate TCP traffic ns tcpgen.tcl -nn nodes -seed seed See an example Source: See ns-2/indep-utils/cmu-scen-gen,Sensor Node extension,Node is energy-aware Define node by adding new options: $ns_ node-c

39、onfig -energyModel EnergyModel -initialEnergy100.0 -txPower0.6 -rxPower0.2,Summary of the API changes,OLD API dsr/dsdv/tora-create-mobile-node strong global variable dependency no nam support no energy model need global chan and prop,New API $ns_ node-config $ns node no global variable dependency na

40、mtrace-all-wireless Energy model support No global definition of chan and prop,Visualize your simulation,Use nam to visualize: mobilenode position mobilenode moving direction and speed control the speed of playback See an example,Feature summary(1,Mac Layer:IEEE 802.11 Address Resolution Protocol (A

41、RP) Ad hoc routing protocols: DSDV, DSR,TORA Radio Propagation Model Friss-space attenuation at near distances Two ray ground at far distances Antenna: an omni-directional antenna having unity gain,Feature summary (2,Scenario generator for traffic and node movement Base station node to bridge wired domain and wireles

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论