
NS中的基本无线模型.ppt
63页NS Tutorial: mobile and wireless network simulationChuda LiuXJTUApril 10th, 2004Outlinesn1. 引言:NS中的基本无线模型 n2. 对CMU的无线模型的扩展n3. 应用举例1. 引言:NS中的基本无线模型n1.1 创建无线拓扑 n1.2 创建MN的移动n1.3 MN中的网络组件n1.4 MAC协议n1.5 Ad hoc 路由协议n1.6 Trace支持n1.7 对无线Trance格式的修改n1.8 产生节点移动和业务连接的场景文件1. 引言:NS中的基本无线模型n引言无线模型=MobileNode+支持Adhoc & WLAN特征基本节点无线/移动功能ü在给定拓扑中移动;ü能从无线通道(Channel )接收发送信号üMN不再通过链路相连1.1 创建无线拓扑 nMN从Node派生,其移动特征包括: -节点移动 -周期性位置更新 -维护拓扑边缘nMN中的网络组件 -分类器 -dmux -LL -MAC -Channel在C++实现mobilenode.{cc,h}在OTcl实现ns-1.1 创建无线拓扑 n创建创建MNMN前先要配置节点,经过以下前先要配置节点,经过以下APIAPI::# Define how a mobile node is configured$ns_ node-config -adhocRouting $opt(adhocRouting) ;# 创建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 OFF1.1 创建无线拓扑 n创建创建MNMN::for { set j 0 } { $j \< $opt(nn)} {incr j} { set node_($j) [ $ns_ node ] $node_($i) random-motion 0 ;# disable random motion } NodeARPPropagation and antenna models MobileNodeLLMACPHYLLCHANNELLLMACPHY::Classifier: ForwardingAgent: Protocol EntityNode EntryLL: Link layer objectIFQ: Interface queueMAC: Mac objectPHY: Net interfaceprotocolAgent/src/sinkroutingagentaddrclassifierportclassifier255IFQIFQdefaulttarget_Radio propagation/antenna modelsProp/antMobilenode示意图NodeARPPropagation and antenna models MobileNodeLLMACPHYLLCHANNELprotocolagentroutingagentaddrclassifierportclassifier255IFQdefaulttarget_Mobilenode示意图Ø物理层:1.无线电波模型表示: -近处:Pant =1/r2 a free space prop. -远处:Pant =1/r4 two-ray ground2.每个MN有一个或多个网络接口,相同的类型的接口接到一个通道 Pkt -> Chan Obj 计算延时->调度 包到达事件->通告接收接口pkt到达-> 比较pkt的能量级别t0: 载波侦听阀值t1 和接收阀值t2: if t0
1.3.2 ARP1.3.2 ARPnAddress Resolution Protocol 接收从LL来的查询 ,如果ARP目的地址的硬件地址, 它将其写入分组的MAC头;n否则广播一个ARP查询, 并临时缓存分组;n对每个未知目的地址的硬件地址, 有一个缓存为每个分组;n对有相同目的地址的分组若发送到ARP, 早先缓存的分组被丢弃;n一旦分组下一跳的硬件地址知道, 分组被插入到interface queue(Ifq);nThe ARPTable../ns-2/arp.h 被实现在arp.{cc,h}和. 1.3.3 Interface Queue1.3.3 Interface Queuen优先队列对路由分组给较高优先级, 将它们插入队列头;n对对列中的所有分组有过虑作用并移除那些特定目的地址的分组;n见priqueue.{cc,h} 为IFq 实现. 1.3.4 MAC Layer1.3.4 MAC LayernIEEE 802.11 distributed coordination function (DCF) Mac 协议由CMU实现;n对单播分组它使用RTS/CTS/DATA/ACK 模式;n对广播分组只简单发送DATA;n实现物理和虚拟载波侦听;nMac802_11被实现在mac-802_11.{cc,h}. 1.3.5 1.3.5 Network Interfaces Network Interfaces nNetwork Interface layer作为用于MN访问 channel 的硬件接口;n无线共享媒体接口在中实现,这种接口容易产生冲突并且由 radio propagation model 接收由其他节点接口发送到channel的分组;n接口给每个发送的分组分发时间戳 以及给出发送接口的meta-data,如发送功率、 波长等参数;nmeta-data在pkt头,propagation model用来在接收netIF 确定是否分组有能被接收and/or captured and/or detected (carrier sense) by the receiving node的最小功率;n模型用近似DSSS radio interface (Lucent WaveLan direct-sequence spread-spectrum),netIF实现见} 和wireless-phy.{cc,h}1.3.6 1.3.6 Radio Propagation Model Radio Propagation Model n近距离使用 Friss-space attenuation ();n远距离近似使用Two ray Ground () ;n近似假设频谱在一个平面中反射;n实现见tworayground.{cc,h} 1.3.7 Antenna1.3.7 Antenna nMN使用有统一增益的全向天线omni-directional antenna. 实现见antenna.{cc,h} 。
1.5 1.5 路由代理路由代理nDSDV nDSR nTORA nAODV 1.5.1 Destination-Sequenced1.5.1 Destination-Sequenced Distance Vector (DSDV) Distance Vector (DSDV)nDSDV需要节点周期性的广播路由更新,采用逐跳路由,与传统的DV比,不会产生环路;n基本机制: -每个节点维护一个路由表,为每个可达目的地址列出下一跳; -DSDV给每个路径一个序列标记,若路径R比R’好:要么序列号高,要么测度 值低; -网络中的节点通告单调递增的序列号; -若节点B得知到目的D的路径断了,则以一个无穷大的测度和序列号比原来 值大1的通告到D的路径1.5.1 Destination-Sequenced1.5.1 Destination-Sequenced Distance Vector (DSDV) Distance Vector (DSDV)n实现细节; -路由信息在MN间交换,当邻节点的路由信息在路由表中发生 变化,路由更新会被触发和转发; -若分组到目的地的路径未知时会被缓存,同时发送路由查询, 缓存至路径应答返回; -缓存分组数目到达分组最大时,后来的分组会被丢弃. -到MN的所有分组被地址dmux直接传至端口dmux. 端口dmux 传送分组到分别的目的代理,端口255用来连接路由代理。
-MN也使用一个default-target 在分类器或地址demux中 -路由协议主要在C++中实现. DSDV实现的相关程序见dsdv 目录和 1.5.2 Dynamic Source Routing (DSR)1.5.2 Dynamic Source Routing (DSR)nDSR采用源路由而不是逐跳路由,其优点是中间节点不需要维护路由信息更新n基本机制有2个: -路径发现 节点S需要发送一个分组到目的D以获得到目的D的源路径; *源节点S以泛洪方式广播一个ROUTE REQUEST到网络; *从目的节点或知道目的节点返回一个ROUTE REPLY到S (为减少开销,每个节点维护一个它已经知道的源路径,以减少发送RREQ的频率和传输) -路径维护 当网络拓扑改变后,需要更新源路径;n实现细节: -见dsr 目录和 1.5.3 Temporally-Ordered Routing 1.5.3 Temporally-Ordered Routing Algorithm (TORA) Algorithm (TORA)nTORA是基于“反向链路”算法的分布式路由协议,按需发现路径,给一个目的提供多个路径,快速建立路径。
n基本机制: 1.5.4 Ad Hoc On-Demand 1.5.4 Ad Hoc On-Demand Distance Vector (AODV) Distance Vector (AODV) nTORA是基于“反向链路”算法的分布式路由协议,按需发现路径,给一个目的提供多个路径,快速建立路径n基本机制: 1.6 Trace Support 1.6 Trace Support n无线仿真的Trace支持仍然用cmu-trace对象ncmu-trace对象有三类:CMUTrace/Drop, CMUTrace/Recv和CMUTrace/Send. 这些用来在应用层agent、网络层router和链路层MAC跟踪分组的丢弃、接收和发送事件n用来实现无线跟踪支持的方法和程序可在trace.{cc,h}和找到 1.7 Revised format for 1.7 Revised format for wireless traces wireless traces n 1.8 1.8 产生节点移动和业务连接场景产生节点移动和业务连接场景 n 2 2 对对cmucmu无线模型的扩展无线模型的扩展 n原来的CMU无线模型仅允许仿真 wireless LANs 和ad-hoc networks,为了用它仿真有线和无线节点必须对它扩展,称为wired-cum-wireless feature。
SUN公司集成MIP到无线模型允许MN允许MIPn2.1 wired-cum-wireless 场景 n2.2 MIP 2.1 wired-cum-wireless2.1 wired-cum-wireless场景场景 n当需要仿真一个由多个 WLAN通过有线节点相连的拓扑,或需要无线节点运行MIP 则需要扩展CMU模型;n面临的主要问题是路由,因为在NS中路由信息产生基于拓扑的联通性,如节点怎样经过Link和其他节点相连; 而MN无Link的概念,它们在无线拓扑范围内通过路由协议传送分组到其他,因此这2类节点如何交换分组?nBaseStationNode被引入作为优先和无线域的网关,本质上基站节点是一个层次节点(HierNode)和MobileNode的混合节点基站节点负责转发分组到和出无线域,这协议层次路由来实现它n每个无线域和基站应有一个唯一的域地址分配给他们,所有到无线节点的分组到达改无线节点域所属的基站,基站最终将其传到MN;MN发送分组到无线域外需先发送到基站,基站知道如何转分组到有线目的.n在wired-cum-wireless中MN需要支持层次寻址/路由. Figure 16.3: Schematic of a baseStationNode2.1 2.1 Mobile IPMobile IP nwired-cum-wireless 扩展无线模型为在NS中支持无线MIP奠定了基础MIP模型基于有线模型 (由节点和链路组成)并且不用CMU的移动模型;nMIP由HA和FA组成, MH在HA和FAs间移动,HA和FA本质上为基站节点,而MHs为mobileNodes,MIP扩展的方法和程序在以下文件中:~ns/mip.{cc,h}, ~, ~,~.。
nHA和FA节点 被定义为MobileNode/MIPBS,有注册代理(regagent_) 发送信号到MN, 建立了encapsulator和decapsulatornMH节点 被定义为MobileNode/MIPMH,也有regagent_ 接收和相应 信号,并发送请求到HA或FAs.nMobileNode/MIPMH与MobileNode/MIPBS相似,除了它没有封装和解封装器n对 SRNode 版的MH, 没有层次分类器 和由RA代理组成节点实体 Figure 16.4: Schematic of a Wireless MobileIP BaseStation Node2.1 2.1 Mobile IPMobile IP nMobileNode/MIPBS节点广播信号或通告消息到MHs,一个来自MN的请求产生一个通告,该通告直接发送到请求MH n发送信号的基站的地址被MH听到,并用作 MH的COA (care-of-address). 因此当MH从家网移到外部域,其COA会改变. n当从MH接收到reg_request (as reply to ads),基站会检查是否是MH的HA,若不是,它建立解封装并转发reg_request到MH的HA.nIn case the base-station is the HA for the requesting MH but the COA doesnot match its own, it sets up an encapsulator andnsends reg-request-reply back to the COA (address of the FA) who has forwarded the reg_request to it. so now all packetsndestined to the MH reaching the HA would be tunneled through the encapsulator which encapsulates the IP pkthdr with anIPinIP hdr, now destined to the COA instead of MH. The FA’s decapsulator recives this packet, removes the encapsulationA simple wireless simulation(1)nScenarioucontaining 3 mobile nodesumoving within 670mX670m flat topologyuusing DSDV ad hoc routing protocoluRandom Waypoint mobility modeluTCP and CBR trafficuSee: n A simple wireless simulation(2)set ns_ [new Simulator] ; create a ns simulator instance#Define Global Variablesset topo [new Topography] ; create a topology and $topo load_flatgrid 670 670 ; define it in 670x670 area A simple wireless simulation (3)#Define standard ns/nam traceset tracefd [open w] $ns_ trace-all $tracefdset namtrace [open 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_ setdist 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 Channel/WirelessChannel \ -topoInstance $topo -agentTrace ON \ -routerTrace OFF \ -macTrace OFFA 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} {$i<3} {incr i} { set node_($i) [$ns_ node]}A simple wireless example(7)#Define traffic modelsource traffic-scenario-files#Define node movement model source movement-scenario-files A simple wireless example(8)#Define node initial position in namfor {set i 0} {$i < 3 } { incr i} {$ns_ initial_node_position $node_($i) 20}#Tell ns/nam the simulation stop time $ns_ at 200.0 “$ns_ nam-end-wireless 200.00”$ns_ at 200.00 “$ns_ halt”#Start your simulation $ns_ runWireless Scenario Generator(1)nMobile Movement Generatorsetdest -n
