



下載本文檔
版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
1、1.OMnetpp簡介OMnetpp作為一種仿真工具(與ns2 , opnet并列),在P2P 仿真方面具有很大的優(yōu)勢。2.Overview2.1 模塊概念模塊OMnetpp中功能被封裝為一個個的模塊。簡單模塊( simple modules)為基本模塊, 每個simplemodule完成一個基本功能。Compound module由多個simple module組成。massage 是模塊之間通信的媒介,可以包含復雜的結構體。Gates aretheinputand outputinterfacesof modules;messages aresent outthroughoutputgat
2、es 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 ofone submodule and a gate of the compound module。包傳輸模擬connections可以使用物理鏈路模擬。a
3、nd packet error rate, and may be disabled.支持的參數有: data rate, propagation delay, bit error rate 這些參數在 channel 對象中。參數Modules 可以擁有參數。 Parameters can be assigned in either the NED files or the configuration file omnetpp.ini.The user defines the structure of the model in NED language descriptions (Networ
4、k Description).2.2 Programming the AlgorithmsSimulation objects (messages, modules, queues etc.) are represented by C+ classes. They havebeen designed to work together efficiently, creating a powerful simulation programming framework. The following classes are part of the simulation class library:&g
5、t;>module, gate, parameter, channel>>message, packet>>container classes (e.g. queue, array)>>data collection classes>>statistic and distribution estimation classes (histograms, P2 algorithm for calculating quantiles etc.)>>transient detection and result accuracy dete
6、ction classes2.3 使用OMNetpp一個OMNetpp model由以下幾部分組成:1. NED 語言拓撲描述( .ned 文件):使用參數, gates 等描述 module 結構。 NED 文件可以用任意 text editor 編輯,但 OMNetpp IDE 提供了兩種方式:圖形與文本。2.消息定義(.msg文件)定義各種消息類型。OMNetpp會將消息定義轉換成C+ 類。3. 簡單模塊源文件(Simple module sources):C+ 文件仿真系統(tǒng)包括兩部分:1. 仿真內核2. 用戶接口3. NED 語言3.1 NED 概述NED 特點:1)層次性:復雜模塊由
7、簡單模塊組成2)模塊化3)接口4)繼承性5)包結構的管理:如Java6)內部類型:(可以定義局部變量)7) Metadata annotations(元數據注解?)3.2 NED 開始圖 1網絡舉例這個網絡描述如下:/ A network/network Networksubmodules:node1: Node;node2: Node;node3: Node;.connections:node1.port+ <-> datarate=100Mbps; <-> node2.port+; node2.port+ <-> datarate=100Mbps; &l
8、t;-> node4.port+; node4.port+ <-> datarate=100Mbps; <-> node6.port+;.類型可以定義channel類型/ A Network/network Networktypes:channel C extends ned.DatarateChannel datarate = 100Mbps;submodules:node1: Node;node2: Node;node3: Node;.connections:node1.port+ <->node2.port+ <->node4.por
9、t+ <->.C <-> node2.port+;C <-> node4.port+;C <-> node6.port+;一些簡單模塊(App, Routing, and Queue)簡單模塊定義有關鍵字:simple 。在這個例子中,我們定義了node為簡單模塊(trafficgeneration, routing, etc.其實也挺復雜的)。應當定義一些簡單模塊,然后組合起來組成一個復合模塊(compound module)。一個流量生成的簡單模塊,一個路由模塊,一個隊列模塊。( We'll have one simple modul
10、e for traffic generation (App), one for routing (Routing), and onefor queueing up packets to be sent out (Queue))simple Appparameters:int destAddress;.display("i=block/browser");gates:input in;output out;simple Routing.simple Queue.這些放在App.ned, Routing.ned和 Queue.ned文件中。NOTE:module類型名稱首字母大
11、寫,display() 稱作display string一般的, 在 NED 中 -wordsgate , parameter等用小寫。NED 區(qū)分大小寫。,在圖形環(huán)境中顯示。"i=." 定義默認圖標。如 display 稱作properties。用來注釋metadata,可以用于files,modules, parameters, gates, connections, and other objects, and parameter value復合模塊module Nodeparameters:display("i=misc/node_vs,gold"
12、;);gates:inout port;submodules:app: App;routing: Routing;queuesizeof(port): Queue;connections:routing.localOut -> app.in;routing.localIn <- app.out;for i=0.sizeof(port)-1 routing.outi -> queuei.in;routing.ini <- queuei.out;queuei.line <-> porti;此為node的定義。復合模塊可以和簡單模塊一樣,有parameter, g
13、ate 。3.3簡單模塊simple Queueparameters:int capacity;display("i=block/queue");gates:input in;output out;以上是一個Queue模塊。參數都是可選的。動作不在NED語言中定義,而是在C+中定義。默認情況下,OMNetpp會在與NED名字相同的C+類中尋找(如此例,Queue)。也可以使用下面的方式指定:simple Queueparameters:int capacity;class(mylib:Queue);display("i=block/queue");gat
14、es:input in;output out;如果多個模塊在同一名字空間中,則可以采用如下的方式namespace(mylib);simple App .simple Router .simple Queue .這樣C+ 類為mylib:App, mylib:Routerand mylib:Queue。類似于C+ 中類的繼承,簡單模塊之間也可以存在這樣的關系:simple Queueint capacity;.simple BoundedQueue extends Queuecapacity = 10;該例 BoundedQueue 給 capacity設置了初始值,這個模塊使用的類與Queu
15、e相同,都是Queue 。若要使用不同的類,則需要用以下方式:simple PriorityQueue extends Queueclass(PriorityQueue);此時, PriorityQueue使用的類為PriorityQueue。3.4 復合模塊module WirelessHostBasegates:input radioIn;submodules:tcp: TCP;ip: IP;wlan: Ieee80211;connections:tcp.ipOut -> ip.tcpIn;tcp.ipIn <- ip.tcpOut;ip.nicOut+ -> wlan.
16、ipIn;ip.nicIn+ <- wlan.ipOut;wlan.radioIn <- radioIn;module WirelessUser extends WirelessHostBasesubmodules:webAgent: WebAgent;connections:webAgent.tcpOut -> tcp.appIn+;webAgent.tcpIn <- tcp.appOut+;module DesktopUser extends WirelessUsergates:inout ethg;submodules:eth: EthernetNic;conne
17、ctions:ip.nicOut+ -> eth.ipIn;ip.nicIn+ <- eth.ipOut;eth.phy <->ethg; 3.5 Channels(通道)Channel將在尋找C+parameters與 behaviour封裝并與類的處理方面與簡單模connections 塊 相 同相關聯(lián)。 已 提Channels供的像簡單模塊,channel有ned.IdealChannel, ned.DelayChanneland ned.DatarateChannel(ned 是包名,可以使用 import ned.*導入這些包)。IdealChannel 沒有
18、參數,它允許 messages 無延時的到達對端。 一個 connection 不包含 channel 對象與包含 IdealChannel 對象相同。DelayChannel有兩個參數:delay :double類型,標明延遲。disabled : boolean類型,默認為false 。如果為true ,則 channel對象丟棄所有包。DatarateChannel相比于DelayChannel還有其它的參數:datarate:double類型。表示data rate( bps,Kbps, Mbps ,Gbps , etc.),默認為0 ,表示無限帶寬。ber與per代表Bit Erro
19、r Rate與Packet Error Rate。0, 1范圍內的double類型。當channel決定一個包錯誤是否發(fā)生(基于隨機數),會在包對象中設置error flag。接收模塊檢查flag,丟棄出錯包。默認值為0.一個 channel例子:channel C extends ned.DatarateChanneldatarate = 100Mbps;delay = 100us;ber = 1e-10;你可以通過subclassing的方式增加channel的參數和屬性。例如增加distance參數:channel DatarateChannel2 extends ned.Datarat
20、eChanneldouble distance unit(m);delay = this.distance / 200000km * 1s;3.6 參數(parameter )參數的值可以NED code , configuration (omnetpp.ini), or even, interactively from the usermodule Nodesubmodules:app : App sendIaTime = 3s;packetLength = 1024B; / B=byte.在模塊中直接定義,Aftertheabovedefinition,theapp submodule
21、39;sparameterscannotbechanged fromomnetpp.ini. (在模塊中定義的無法在ini文件中修改)值( value )在 configuration 中可以這樣定義:*.sendIaTime = 100ms*.sendIaTime = 2s + exponential(100ms)可以指定默認或需要用戶給出:*.sendIaTime = default/在 NED 中用 =default(.)給出*.sendIaTime = ask參數值放在模塊中還是放在配置文件中:在模塊中被認為是模塊的一部分(模塊的性質),一般是常數。在配置中則可以在每次試驗中改變。表達
22、式binary and logical XOR are#and#has been reassigned topower-of+可以代表字串連接volaile這個關鍵字標明該參數在每次讀的過程中都要重新evaluate一次。而其他參數則在剛開始的時候 evaluate ,之后再不會 evaluate 。對于讀取隨機數等在過程中變化的,則需要利用該參數。(是否就是在仿真過程中不斷變化的參數就需要利用該關鍵字?)Unitssimple Appparameters:volatile double sendIaTimevolatile int packetLengthunit(s)unit(byte)=
23、 default(exponential(350ms);= default(4KB);.文檔意思好像是說可以兼容單位:如unit(s)acceptsmilliseconds,nanoseconds,minutes,hours, etc.由 OMNet+定義。XML參數提供復雜輸入,可以將這些輸入寫在單獨的文件中。simple TrafGen parameters:xml profile;gates:output out;module Node submodules:trafGen1 : TrafGen profile = xmldoc("data.xml");.使用xml類
24、型與xmldoc ()操作。也可以這樣:module Node submodules:trafGen1 : TrafGen profile = xmldoc("all.xml", "profileid='gen1'");trafGen2 : TrafGen profile = xmldoc("all.xml", "profileid='gen2'");<?xml><root><profile id="gen1"><para
25、m>3</param><param>5</param></profile><profile id="gen2"><param>9</param></profile></root>3.7 gates三種: input output inoutoutput是一個向量,由一組output ,具體值取決于參數。simple Classifier parameters:int numCategories;gates:input in;output outnumCatego
26、ries;可以動態(tài)變化:simple Sink gates:input in;可以有些不被連接(例為定義grid 上的節(jié)點,在grid 邊上的node 會有少于四個的連接)simple GridNode gates:inout neighbour4loose;WirelessNodebelow is expected to receive messages (radio transmissions) viadirect sending, so itsradioIngate is marked withUnknown LaTeX commandfpropdirectIn.(不懂有什么用)simp
27、le WirelessNode gates:input radioIndirectIn;首先定義了一個tree 節(jié)點,可以指向任意多個孩子節(jié)點。在此基礎上extend一個二叉樹節(jié)點,指向兩個孩子。simple TreeNode gates:inout parent;inout children;simple BinaryTreeNode extends TreeNode gates:children2;3.8 子模塊module Nodesubmodules:routing: Routing;/ a submodulequeuesizeof(port): Queue;/ submodule v
28、ector類似數組.還能這么組合?!有點犀利module Hostparameters:bool withTCP = default(true);submodules:tcpwithTCP ? 1 : 0: TCP;/ conditionalsubmodule .connections:tcp0.ipOut -> ip.tcpIn if withTCP;tcp0.ipIn <- ip.tcpOut if withTCP;.3.9 connection<-> ''.就是用一個connection將兩個gates連接。Channel的說明就寫在中間,如:.
29、<-> 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 connectionsC
30、hainmodule Chainparameters: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:
31、 BinaryTreeNode;connections allowunconnected:for i=0.2(height-1)-2 nodei.left <-> node2*i+1.parent;nodei.right <-> node2*i+2.parent;默認每個gate 必須要有連接,否則會出錯。使用allowunconnected參數,則可以忽略這個限制。Random Graphmodule RandomGraph parameters:int count;double connectedness; / 0.0<x<1.0submodules:nodecount: Node gates:incount;outcount;conne
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
- 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 汽車的介紹教學課件
- 汽車檢測技術課件
- 2025年制造業(yè)數字化轉型數據治理風險與應對策略報告
- 2025年城市供水廠自動化系統(tǒng)智能化升級項目環(huán)境效益評估報告
- 2025年金融租賃公司業(yè)務創(chuàng)新模式與風險控制能力提升路徑案例分析
- 新零售便利店O2O模式創(chuàng)新與案例分析報告
- 汽車技術課件教學
- 互聯(lián)網教育紅利:2025年在線教育平臺用戶增長策略與市場拓展研究
- 2025年金融行業(yè)數據治理與隱私保護技術市場趨勢與預測報告
- 2025年金融行業(yè)數據治理與數據資產化在金融行業(yè)金融科技風險管理組織中的應用報告
- DCMM數據管理師練習測試卷
- 血透室職業(yè)安全防護制度
- 設計總監(jiān)述職報告
- 求職委托代理協(xié)議書
- 遼寧省沈陽市(2024年-2025年小學四年級語文)人教版期末考試((上下)學期)試卷及答案
- TDSQL認證考試考題及答案-70分版
- 2025年日歷( 每2個月一張打印版)
- RB/T 228-2023食品微生物定量檢測的測量不確定度評估指南
- 2023年北京海淀社區(qū)工作者考試真題
- 2024年國開電大 高級財務會計 形考任務4答案
- 道路工程石材檢測報告及石材單軸抗壓強度檢測原始記錄
評論
0/150
提交評論