好文档就是一把金锄头!
欢迎来到金锄头文库![会员中心]
电子文档交易市场
安卓APP | ios版本
电子文档交易市场
安卓APP | ios版本

NS中的基本无线模型.ppt

63页
  • 卖家[上传人]:hs****ma
  • 文档编号:588299261
  • 上传时间:2024-09-07
  • 文档格式:PPT
  • 文档大小:343.50KB
  • / 63 举报 版权申诉 马上下载
  • 文本预览
  • 下载提示
  • 常见问题
    • NS Tutorial: mobile and wireless network simulationChuda LiuXJTUApril 10th, 2004 Outlinesn1. 引言: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 OFF 1.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 t0IP地址 ØSRNode不用 address demux or classifiers ;Ø节点接收到的所有包默认地 转发到DSR代理;ØDSR代理或者将pkt送到端口 dmux或者按源路路由转发pkt 1.2 创建MN的移动nMN被设计成在一个三维拓扑中移动,但Z轴未用(Z=0);nMN的坐标随MN的移动而改变;n有2种机制引入MN的移动: -指定MN的起始和终点位置 -随机移动模式n创建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中的网络组件nMN的网络栈有以下组件: -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 pmodellltype mactype qtype qlen iftype anttype } {$self instvar arptable_ nifs_$self instvar netif_ mac_ ifq_ ll_global ns_ MacTrace optset t $nifs_incr nifs_set netif_($t) [new $iftype] ;# net-interfaceset mac_($t) [new $mactype] ;# mac layerset ifq_($t) [new $qtype] ;# interface queueset ll_($t) [new $lltype] ;# link layerset ant_($t) [new $anttype]# Local Variablesset nullAgent_ [$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 arptable $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_ $qlenset 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(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# ===============================================# 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 to 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#$channel 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 sendtarget $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 nullAgent_]}# ===============================================$self addif $netif} add-interface(8/8) 1.3.1 Link Layer1.3.1 Link Layer((LLLL))n仿真数据链路层协议,实现分组的分段、重组等;nLL层负责设MAC目的地址在分组的MAC 头。

      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 baseStationNode 2.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 Node 2.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 encapsulation A 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 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} {$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_ run Wireless Scenario Generator(1)nMobile Movement Generatorsetdest -n -p pausetime -s -t -x -y See an examplenRandom movement$node startSource: See ns-2/indep-utils/cmu-scen-gen/setdest/ Wireless Scenario Generator(2)nGenerating traffic pattern filesuCBR trafficns [-type cbf|tcp] [-nn nodes] [-seed seed] [-mc connections] [-rate rate]uTCP trafficns [-nn nodes] [-seed seed]See an example Source: See ns-2/indep-utils/cmu-scen-gen/ Sensor Node extensionnNode is energy-awarenDefine node by adding new options:$ns_ node-config -energyModel EnergyModel -initialEnergy -txPower -rxPower Summary of the API changesOLD APIndsr/dsdv/tora-create-mobile-nodenstrong global variable dependencynno nam supportnno energy modelnneed global chan and propNew APIn$ns_ node-confign$ns nodenno global variable dependency nnamtrace-all-wirelessnEnergy model supportnNo global definition of chan and prop Visualize your simulationnUse nam to visualize:umobilenode positionumobilenode moving direction and speeducontrol the speed of playbacknSee an example: Feature summary(1)nAddress Resolution Protocol (ARP)nAd hoc routing protocols: DSDV, DSR,TORAnRadio Propagation ModeluFriss-space attenuation at near distancesuTwo ray ground at far distancesnAntenna: an omni-directional antenna having unity gain Feature summary (2)nScenario generator for traffic and node movementnBase station node to bridge wired domain and wireless domainnMobileIPnSymmetric architecture with wired LAN (IEEE 802.3) Feature summary(3)nVisualization of node movement and reachabilitynGridkeeper optimizer for some scenariosnEnergy consumption model for sensor networksnValidation test-suites for dsdv, dsr, tora, base station, mobileIP, gridkeeper Appendix A: Movement file$ns_ at 50.000000000000 "$node_(2) setdest$ns_ at 51.000000000000 "$node_(1) setdest 221.826585497093 80.855495003839 14.909259208114"$ns_ at 33.000000000000 "$node_(0) setdest Appendix B: Traffic Scenarioset udp_(0) [new Agent/UDP]$ns_ attach-agent $node_(0) $udp_(0)set null_(0) [new Agent/Null]$ns_ attach-agent $node_(2) $null_(0)set cbr_(0) [new Application/Traffic/CBR]$cbr_(0) set packetSize_ 512$cbr_(0) set random_ 1$cbr_(0) set maxpkts_ 10000$cbr_(0) attach-agent $udp_(0)$ns_ connect $udp_(0) $null_(0)$ns_ at 127.93667922166023 "$cbr_(0) start"……. Greedkeeper: an optimizer** optimization depends on your scenario 。

      点击阅读更多内容
      相关文档
      2025国开山东开大《土质学与土力学》形成性考核123答案+终结性考核答案.docx 中学综合素质知识点梳理【中学教师资格证】.docx 2025国开山东开大《特许经营概论》形成性考核123答案+终结性考核答案.doc 2025年高考英语全国一卷真题(含答案).docx 2025国开山东《农民专业合作社创建与管理》形成性考核123答案+终结性考核答案.docx 2025国开山东开大《自然现象探秘》形成性考核123答案+终结性考核答案.docx 2025国开山东《消费心理学》形成性考核123答案+终结性考核答案.doc 2025国开山东《小微企业管理》形成性考核123答案+终结性考核答案.doc 2025国开山东开大《资本经营》形成性考核123答案+终结性考试答案.docx 2025国开山东《小学生心理健康教育》形考123答案+终结性考试答案.docx 2025国开《视频策划与制作》形考任务1-4答案.docx 2025国开《亲子关系与亲子沟通》形考任务234答案+期末大作业答案.docx 2025国开电大《煤矿地质》形成性考核123答案.docx 2025国开电大《冶金原理》形考任务1234答案.docx 2025国开《在线学习项目运营与管理》形考任务1234答案.doc 2025国开电大《在线教育的理论与实践》阶段测验1-4答案.docx 2024 年注册环保工程师《专业基础考试》真题及答案解析【完整版】.docx 环保工程师---2023 年注册环保工程师《专业基础考试》真题及答案解析【完整版】.docx 2025国开《液压与气压传动》形考任务一参考答案.docx 2025年春江苏开放大学教育研究方法060616计分:形成性作业2、3答案.docx
      关于金锄头网 - 版权申诉 - 免责声明 - 诚邀英才 - 联系我们
      手机版 | 川公网安备 51140202000112号 | 经营许可证(蜀ICP备13022795号)
      ©2008-2016 by Sichuan Goldhoe Inc. All Rights Reserved.