




已閱讀5頁(yè),還剩10頁(yè)未讀, 繼續(xù)免費(fèi)閱讀
版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1.OMnetpp簡(jiǎn)介OMnetpp作為一種仿真工具(與ns2,opnet并列),在P2P仿真方面具有很大的優(yōu)勢(shì)。2.Overview2.1 模塊概念2.1.1 模塊OMnetpp中功能被封裝為一個(gè)個(gè)的模塊。簡(jiǎn)單模塊(simple modules)為基本模塊,每個(gè)simple module完成一個(gè)基本功能。Compound module由多個(gè)simple module組成。2.1.2 Messages, Gates, Linksmassage是模塊之間通信的媒介,可以包含復(fù)雜的結(jié)構(gòu)體。Gates are the input and output interfaces of modules; messages are sent out through output gates and arrive through input gates.Each connection (also called link) is created within a single level of the module hierarchy: within a compound module, one can connect the corresponding gates of two submodules, or a gate of one submodule and a gate of the compound module。2.1.3 包傳輸模擬connections可以使用物理鏈路模擬。支持的參數(shù)有:data rate, propagation delay, bit error rate and packet error rate, and may be disabled. 這些參數(shù)在channel對(duì)象中。2.1.4 參數(shù)Modules 可以擁有參數(shù)。Parameters can be assigned in either the NED files or the configuration file omnetpp.ini.2.1.5 Topology Description MethodThe user defines the structure of the model in NED language descriptions (Network Description).2.2 Programming the AlgorithmsSimulation objects (messages, modules, queues etc.) are represented by C+ classes. They have been designed to work together efficiently, creating a powerful simulation programming framework. The following classes are part of the simulation class library:module, gate, parameter, channelmessage, packetcontainer classes (e.g. queue, array)data collection classesstatistic and distribution estimation classes (histograms, P2 algorithm for calculating quantiles etc.)transient detection and result accuracy detection classes2.3 使用OMNetpp2.3.1 building and running simulations一個(gè)OMNetpp model 由以下幾部分組成:1. NED語(yǔ)言拓?fù)涿枋觯?ned 文件):使用參數(shù),gates等描述module結(jié)構(gòu)。NED文件可以用任意text editor編輯,但OMNetpp IDE提供了兩種方式:圖形與文本。2. 消息定義(.msg 文件)定義各種消息類型。 OMNetpp會(huì)將消息定義轉(zhuǎn)換成C+類。 3.簡(jiǎn)單模塊源文件(Simple module sources):C+文件仿真系統(tǒng)包括兩部分:1.仿真內(nèi)核2.用戶接口3. NED語(yǔ)言3.1 NED概述NED特點(diǎn):1)層次性:復(fù)雜模塊由簡(jiǎn)單模塊組成2)模塊化3)接口4)繼承性5)包結(jié)構(gòu)的管理:如Java6)內(nèi)部類型:(可以定義局部變量)7)Metadata annotations(元數(shù)據(jù)注解?)3.2 NED開(kāi)始圖1 網(wǎng)絡(luò)舉例這個(gè)網(wǎng)絡(luò)描述如下:/ A network/network Network submodules: node1: Node; node2: Node; node3: Node; . connections: node1.port+ datarate=100Mbps; node2.port+; node2.port+ datarate=100Mbps; node4.port+; node4.port+ datarate=100Mbps; node6.port+; .3.2.1 channel類型可以定義channel 類型/ A Network/network Network types: channel C extends ned.DatarateChannel datarate = 100Mbps; submodules: node1: Node; node2: Node; node3: Node; . connections: node1.port+ C node2.port+; node2.port+ C node4.port+; node4.port+ C node6.port+; .3.2.3 一些簡(jiǎn)單模塊(App, Routing, and Queue)簡(jiǎn)單模塊定義有關(guān)鍵字:simple。在這個(gè)例子中,我們定義了node為簡(jiǎn)單模塊(traffic generation, routing, etc. 其實(shí)也挺復(fù)雜的)。應(yīng)當(dāng)定義一些簡(jiǎn)單模塊,然后組合起來(lái)組成一個(gè)復(fù)合模塊(compound module)。一個(gè)流量生成的簡(jiǎn)單模塊,一個(gè)路由模塊,一個(gè)隊(duì)列模塊。(Well have one simple module for traffic generation (App), one for routing (Routing), and one for queueing up packets to be sent out (Queue))simple App parameters: int destAddress; . display(i=block/browser); gates: input in; output out;simple Routing .simple Queue .這些放在App.ned,Routing.ned和Queue.ned文件中。NOTE:module類型名稱首字母大寫,gate,parameter等用小寫。NED區(qū)分大小寫。display()稱作display string,在圖形環(huán)境中顯示。i=.定義默認(rèn)圖標(biāo)。一般的,在NED中-words如display稱作properties。用來(lái)注釋metadata,可以用于files, modules, parameters, gates, connections, and other objects, and parameter value3.2.4 復(fù)合模塊module Node parameters: display(i=misc/node_vs,gold); gates: inout port; submodules: app: App; routing: Routing; queuesizeof(port): Queue; connections: routing.localOut - app.in; routing.localIn queuei.in; routing.ini - queuei.out; queuei.line porti; 此為node的定義。復(fù)合模塊可以和簡(jiǎn)單模塊一樣,有parameter,gate。3.3 簡(jiǎn)單模塊simple Queue parameters: int capacity; display(i=block/queue); gates: input in; output out;以上是一個(gè)Queue模塊。參數(shù)都是可選的。動(dòng)作不在NED語(yǔ)言中定義,而是在C+中定義。默認(rèn)情況下,OMNetpp會(huì)在與NED名字相同的C+類中尋找(如此例,Queue)。也可以使用下面的方式指定:simple Queue parameters: int capacity; class(mylib:Queue); display(i=block/queue); gates: input in; output out;如果多個(gè)模塊在同一名字空間中,則可以采用如下的方式namespace(mylib);simple App .simple Router .simple Queue .這樣C+類為mylib:App,mylib:Routerandmylib:Queue。類似于C+中類的繼承,簡(jiǎn)單模塊之間也可以存在這樣的關(guān)系:simple Queue int capacity; .simple BoundedQueue extends Queue capacity = 10;該例BoundedQueue給capacity設(shè)置了初始值,這個(gè)模塊使用的類與Queue相同,都是Queue。若要使用不同的類,則需要用以下方式:simple PriorityQueue extends Queue class(PriorityQueue);此時(shí),PriorityQueue使用的類為PriorityQueue。3.4 復(fù)合模塊module WirelessHostBase gates: input radioIn; submodules: tcp: TCP; ip: IP; wlan: Ieee80211; connections: tcp.ipOut - ip.tcpIn; tcp.ipIn wlan.ipIn; ip.nicIn+ - wlan.ipOut; wlan.radioIn tcp.appIn+; webAgent.tcpIn eth.ipIn; ip.nicIn+ - eth.ipOut; eth.phy ethg;3.5 Channels(通道)Channel 將parameters與behaviour封裝并與connections相關(guān)聯(lián)。Channels像簡(jiǎn)單模塊,在尋找C+類的處理方面與簡(jiǎn)單模塊相同。已提供的channel有 ned.IdealChannel,ned.DelayChannelandned.DatarateChannel(ned是包名,可以使用import ned.* 導(dǎo)入這些包)。l IdealChannel沒(méi)有參數(shù),它允許messages無(wú)延時(shí)的到達(dá)對(duì)端。一個(gè)connection不包含channel對(duì)象與包含IdealChannel對(duì)象相同。l DelayChannel有兩個(gè)參數(shù): delay:double類型,標(biāo)明延遲。 disabled:boolean類型,默認(rèn)為false。如果為true,則channel對(duì)象丟棄所有包。l DatarateChannel相比于DelayChannel還有其它的參數(shù): datarate:double類型。表示data rate (bps,Kbps,Mbps,Gbps, etc.),默認(rèn)為0,表示無(wú)限帶寬。 ber 與 per 代表 Bit Error Rate 與Packet Error Rate。 0, 1范圍內(nèi)的double類型。當(dāng)channel決定一個(gè)包錯(cuò)誤是否發(fā)生(基于隨機(jī)數(shù)),會(huì)在包對(duì)象中設(shè)置error flag。接收模塊檢查flag,丟棄出錯(cuò)包。默認(rèn)值為0.一個(gè)channel例子:channel C extends ned.DatarateChannel datarate = 100Mbps; delay = 100us; ber = 1e-10;你可以通過(guò)subclassing的方式增加channel的參數(shù)和屬性。例如增加distance參數(shù):channel DatarateChannel2 extends ned.DatarateChannel double distance unit(m); delay = this.distance / 200000km * 1s;3.6 參數(shù)(parameter)參數(shù)的值可以NED code,configuration (omnetpp.ini), or even, interactively from the usermodule Node submodules: app : App sendIaTime = 3s; packetLength = 1024B; / B=byte .在模塊中直接定義,After the above definition, theappsubmodules parameters cannot be changed fromomnetpp.ini.(在模塊中定義的無(wú)法在ini文件中修改)值(value)在configuration中可以這樣定義:*.sendIaTime = 100ms*.sendIaTime = 2s + exponential(100ms)可以指定默認(rèn)或需要用戶給出:*.sendIaTime = default /在NED中用=default(.)給出*.sendIaTime = ask參數(shù)值放在模塊中還是放在配置文件中:在模塊中被認(rèn)為是模塊的一部分(模塊的性質(zhì)),一般是常數(shù)。在配置中則可以在每次試驗(yàn)中改變。表達(dá)式binary and logical XOR are#and#has been reassigned topower-of+可以代表字串連接volaile這個(gè)關(guān)鍵字標(biāo)明該參數(shù)在每次讀的過(guò)程中都要重新evaluate一次。而其他參數(shù)則在剛開(kāi)始的時(shí)候evaluate,之后再不會(huì)evaluate。對(duì)于讀取隨機(jī)數(shù)等在過(guò)程中變化的,則需要利用該參數(shù)。(是否就是在仿真過(guò)程中不斷變化的參數(shù)就需要利用該關(guān)鍵字?)Unitssimple App parameters: volatile double sendIaTime unit(s) = default(exponential(350ms); volatile int packetLength unit(byte) = default(4KB); .文檔意思好像是說(shuō)可以兼容單位:如unit(s)accepts milliseconds, nanoseconds, minutes, hours, etc.由OMNet+定義。XML 參數(shù)提供復(fù)雜輸入,可以將這些輸入寫在單獨(dú)的文件中。simple TrafGen parameters: xml profile; gates: output out;module Node submodules: trafGen1 : TrafGen profile = xmldoc(data.xml); .使用xml 類型與xmldoc()操作。也可以這樣:module Node submodules: trafGen1 : TrafGen profile = xmldoc(all.xml, profileid=gen1); trafGen2 : TrafGen profile = xmldoc(all.xml, profileid=gen2); 3 5 9 3.7 gates三種:input output inoutoutput是一個(gè)向量,由一組output,具體值取決于參數(shù)。simple Classifier parameters: int numCategories; gates: input in; output outnumCategories;可以動(dòng)態(tài)變化:simple Sink gates: input in;可以有些不被連接(例為定義grid上的節(jié)點(diǎn),在grid邊上的node會(huì)有少于四個(gè)的連接)simple GridNode gates: inout neighbour4 loose;WirelessNodebelow is expected to receive messages (radio transmissions) via direct sending, so itsradioIngate is marked withUnknown LaTeX commandfprop directIn.(不懂有什么用)simple WirelessNode gates: input radioIn directIn;首先定義了一個(gè)tree節(jié)點(diǎn),可以指向任意多個(gè)孩子節(jié)點(diǎn)。在此基礎(chǔ)上extend一個(gè)二叉樹(shù)節(jié)點(diǎn),指向兩個(gè)孩子。simple TreeNode gates: inout parent; inout children;simple BinaryTreeNode extends TreeNode gates: children2;3.8 子模塊module Node submodules: routing: Routing; / a submodule queuesizeof(port): Queue; / submodule vector 類似數(shù)組 .還能這么組合?!有點(diǎn)犀利module Host parameters: bool withTCP = default(true); submodules: tcpwithTCP ? 1 : 0: TCP; / conditional submodule . connections: tcp0.ipOut - ip.tcpIn if withTCP; tcp0.ipIn - ip.tcpOut if withTCP; .3.9 connection.就是用一個(gè)connection將兩個(gè)gates連接。Channel的說(shuō)明就寫在中間,如:. delay=10ms; . delay=10ms; ber=1e-8; . C . BBone cost=100; length=52km; ber=1e-8; . display(ls=red); . BBone display(ls=green,2); .3.10 multiple connectionsChainmodule Chain parameters: int count; submodules: nodecount : Node gates: port2; connections allowunconnected: for i = 0.count-2 nodei.port1 nodei+1.port0; Binary Treesimple BinaryTreeNode gates: inout left; inout right; inout parent;module BinaryTree parameters: int height; submodules: node2height-1: BinaryTreeNode; connections allowunconnected: for i=0.2(height-1)-2 nodei.left node2*i+1.parent; nodei.right node2*i+2.parent; 默認(rèn)每個(gè)gate必須要有連接,否則會(huì)出錯(cuò)。
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 計(jì)算機(jī)輸入輸出2025年考試試題及答案
- 2025年軟考備考的高效秘笈試題及答案
- 生活習(xí)慣養(yǎng)成小班教育計(jì)劃要點(diǎn)
- 現(xiàn)代化開(kāi)發(fā)流程的優(yōu)化策略試題及答案
- 2025年軟考服務(wù)導(dǎo)向架構(gòu)試題及答案
- 倉(cāng)庫(kù)應(yīng)對(duì)市場(chǎng)變化的靈活策略計(jì)劃
- 云計(jì)算平臺(tái)的服務(wù)模型解析試題及答案
- 河北省石家莊市八校聯(lián)考2025年七下數(shù)學(xué)期末經(jīng)典模擬試題含解析
- 保密資質(zhì)認(rèn)定管理辦法
- 2025屆合肥蜀山區(qū)五校聯(lián)考八年級(jí)數(shù)學(xué)第二學(xué)期期末考試模擬試題含解析
- 項(xiàng)目驗(yàn)收ppt目錄課件
- 兩器車間產(chǎn)能分析
- 機(jī)電廠房金屬壁板隔墻工程施工方案(71頁(yè))
- ASME第八卷第一冊(cè)2015培訓(xùn)資料
- 《石鐘山記》教案3
- 報(bào)聯(lián)商——有效溝通PPT課件
- 二年級(jí)口算題大全(可直接打印)
- 全國(guó)城市文明程度指數(shù)測(cè)評(píng)體系版圖文
- 低壓電工模擬考試題-急救
- 高速公路企業(yè)如何實(shí)現(xiàn)有效的精細(xì)化管理藝術(shù)
- 晉商成功之道PPT課件
評(píng)論
0/150
提交評(píng)論