omnet4.0ned語言看完中文手冊后再_第1頁
omnet4.0ned語言看完中文手冊后再_第2頁
omnet4.0ned語言看完中文手冊后再_第3頁
omnet4.0ned語言看完中文手冊后再_第4頁
omnet4.0ned語言看完中文手冊后再_第5頁
已閱讀5頁,還剩21頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)

文檔簡介

NED

第三章NED結(jié)構(gòu)、網(wǎng)絡(luò)組成、模塊(簡單與復(fù)合模塊兩種)及模塊的內(nèi)部結(jié)構(gòu)等。NED語言子類也可以添加新的成員變量和函數(shù)。這里與C++類似。由參數(shù)決定。實體模塊類型則取決于他們可替代的接口。例如,給定一個復(fù)合模塊類型名Host,其包含一個移動子模塊類型IMobility(該IMobility是模塊接口),該移動子模塊IMobility是選擇的。(RandomWalkMobility,TurtleMobility等等小。例如,可以把某一參數(shù)設(shè)置成確定值來建立一個GenericTCPApp類模塊或者繼承一個FTPApp類。也可以通過添加一個WebApp類子模塊而從BasHost復(fù)合模塊繼承WebHost類復(fù)合模塊,并將之與可繼承的TCP子模塊連接起來??煞庋b性NED語言采用類似于Java包結(jié)構(gòu)的特性來降低2個不同模塊之間命名的危害性??臻g污染(namespacepollution)。 NED這里列出,由.cppNEDcpp//Anetwork{node1:Node;node2:Node;node3:node1.port++<-->{datarate=100Mbps;}<-->node2.port++;node2.port++<-->{datarate=100Mbps;}<-->node4.port++;node4.port++<-->{datarate=100Mbps;}<-->node6.port++;}NetworkNED語言用熟悉的大括號“{}”來標記語法部分和“//NEDNodenode1,node2等幾是哪個。通常的方式是采用network選項(默認在omnetpp.ini文件里)來進行設(shè)置。network=//Anetwork{channelCextends{datarate=}node1:Node;node2:Node;node3:node1.port++<-->C<-->node2.port++<-->C<-->node4.port++;node4.port++<-->C<-->}簡單模塊-App,Routing模塊。行為由C++類所定義。NED文件僅僅只在模塊中外部可見的接口(門,參數(shù)等)。后simple{intinputoutput}simple{}simple{}看看第一個簡單模塊的申明。AppdestAddress參數(shù)(其他略),2outin的Figure3.2:TheNodeCompoundmodule{inoutapp:App;queue[sizeof(port)]:Queue;routing.localOut-->app.in;routing.localIn<--app.out;fori=0..sizeof(port)-1{routing.out[i]-->routing.in[i]<--queue[i].line<-->}}向連接的port[]的類型是inout。simple{intcapacity;inputoutput}parameters和gates是可選的,也就是說,如果沒有參數(shù)或門,可以省略不填。另外,使用@classC++mylib::Queue類一樣,類simple{intcapacity;inputoutput}如果你在普通名空間中已經(jīng)創(chuàng)建了幾個模塊,那么最好是用@namespace來替代@class屬性。用@namespace名將被預(yù)先加入標準的C++類名。在下面的例子中,mylib::App,mylib::Routerandmylib::Queue都是C++類simpleApp}simpleRouter}simpleQueue}packagened,命名空間將應(yīng)用在同一個 simple{int}simpleBoundedQueueextends{capacity=}simplePriorityQueueextendsQueue//wrong!stillusestheQueueC++{}++simplePriorityQueueextends{}module{}module{inputip:IP;wlan:tcp.ipIn<--ipnicOut++-->wlan.ipIn;ipnicIn++<--wlan.ipOut;wlan.radioIn<--radioIn;}moduleWirelessUserextends{webAgent:webAgent.tcpIn<--}moduleDesktopUserextends{eth:ipnicOut++-->eth.ipIn;ipnicIn++<--eth.ipOut;eth.phy<-->ethg;}channelCustomChannel//needsaCustomChannelC++{}channelCextends{delay=100us;ber=1e-}{doublelengthdelay=this.length/200000km*}參數(shù)的作用首先就是輸入到基本的+類中,但是即使你重新使用內(nèi)置信道類型的基本+類,分算channelBackboneextends{doublecost=}simple{intaddress;//localnodestringdestAddresses;//destinationvolatiledoublesendIaTime@unit(s)=//timebetweengeneratingvolatileintpacketLength@unit(byte);//lengthofone}module{app:{sendIaTime=packetLength=1024B;//}}**.sendIaTime=以用的特定模式來替代**,這樣的話得到的可選擇得值得分配.配置文件中的參數(shù)**.sendIaTime=2s+**.sendIaTime=Finally,onecanexplicitlyaskthesimulatortoprompttheuserin ctivelyforthevalue(again,providedthatin ctivityisenabled,otherwisethiswillresultinanerror):**.sendIaTime=binary和logicalXOR是#和##,^代替了power。+操作進行字符串連接和數(shù)字加法一樣方便。表達erlangk(),等等.)表達式可以和模塊參數(shù)、門矢量和模塊矢量大小(使用sizeof)、以及在當前模為了更好的理解volatile,我們定義了有一個ActiveQueue的簡單模塊,有一個volatiledoublesimple{volatiledoublesendIaTime@unit(s)=volatileintpacketLength@unit(byte)=}·MsimpleTrafGenxmloutput}moduleNodetrafGen1:TrafGenprofile=}}moduleNodetrafGen1:TrafGenprofile=xmldoc("all.xml",}trafGen2:TrafGenprofile=xmldoc("all.xml",}}<profile<profile門出門起來的。不管是輸入還是輸出門,一個門不能連接到兩個或多于2個以上的門(對于復(fù)合模塊門來說,則意味著著“outside”著“inside”)。但是不建議把一個inout門分別連接到單獨的input和output門上。simpleClassifierintinputoutput}simpleSinkinput}simpleGridNodeinoutneighbour[4]}simpleWirelessNodeinputradioIn}Inthefollowingexample,wedefineTreeNodeashavinggatestoconnectanynumberofchildren,thensubclassittogetaBinaryTreeNodetosetthegatesizetotwo:simpleTreeNodeinoutinout}simpleBinaryTreeNodeextendsTreeNode}moduleBinaryTreenodes[31]:TreeNode}}module{routing:Routing;//asubmodulequeue[sizeof(port)]:Queue;//submodulevector}module{tcp[withTCP?1:0]:TCP;//conditionaltcp[0].ipOut-->ip.tcpInifwithTCP;tcp[0].ipIn<--ip.tcpOutif}顯示字符串合并(將在chapter10中講述):module{inoutrouting:Routingparameters://thiskeywordisoptionalroutingTable="routingtable.txt";//assignparameterin[sizeof(port)];//setgatevectorsize}@disy("t=queueid$id");//modifydisyid=1000+index;//different"id"parameterforeach}}Anemptybodymaybeomitted,thatqueue:Queue;isthesameas}連接Achannelspecification(-->channelspec-->insideaconnection)aresimilartosubmodulesinmanyrespect.<-->C<--但是沒有明確的指定信道類型,這會導(dǎo)致出錯(提示“ned.DelayChannelhasnosuchparameter”·moduleintnode[count]:Node}fori=0..count-2node[i].port[1]<-->}}·BaysimpleBinaryTreeNodeinoutleft;inoutright;inout}moduleBinaryTreeintfori=0..2^(height-1)-2node[i].left<-->node[2*i+1].parent;}}intdoubleconnectedness;//node[count]:Node}{node[i].out[j]-->ifi!=j&&}}·“gahofaFullGraph”全網(wǎng)互聯(lián)(密集連接fori=0..N-1,j=0..N-1node[i].out[...]-->node[j].in[...]if}當?shù)腸ondition(i;j)可以用明確表達出來。例如,當生成一個樹形結(jié)構(gòu)時,該條件返回一個值fori=0..Nnodes,j=0..Nconns(i)-{node[i].out[j]-->}·}=)=i1network{stringnode[6]:<nodeType>like{address=}}{intinout}moduleSensorNodelike{intinout}@prop;//filemodule{@prop;//moduleinta@prop=default(1);//parameteroutputoutsrc:Source@prop;//submodulecount@prop;//addingapropertytoaout[]@prop;//addingapropertytoa}src.out++-->{@prop;}-->sink1.in;src.out++-->Channel{@prop;}-->sink2.in;}@coords(x=10.31;y=30.2;一樣處理后面的所有形式:@host(),@host(true),@host(anything-but-false),@host(a=1;b=2);注意:@host(false)應(yīng)該被解釋成缺乏@host標記。Somebase@propnew@prop(a)new@prop(,-)result@prop(a,,c)basenew@prop(foo=A,,c;bar=1,2)simpleApp//declaretwostatisticscollectedbytheC++code@statistic[packetsReceived](type=integer;label="Numberofpacketsreceived");}simpleHttpAppextendsApp//tailorthelabelofthe"packetsReceived"statistic:@statistic[packetsReceived](label="NumberofHTTPrequestsreceived");}在NED中,一個類型僅僅只能派生(extends)一個同樣類型的元素:如簡單模塊值包小規(guī)模仿真方案在單一下存放所有的NED文件。然而當方案逐步完善時,遲早不可避免的引入一個結(jié)構(gòu)并把NED文件分類放入中。NED本來就支持NED文件的樹,這稱作包。包對減少命名很有用處,因為名字可以用包的名來限制。當仿真運行時,你必須告訴仿真你的包樹的根,我們稱為NED源文件夾。仿真心將會穿越整個樹,從每個里加載所有的NED文件。你可以有幾個NED樹,但是它們的根(NED源文件夾)應(yīng)該通過NEDPATH變量指定給仿真。NEDPATH用幾種不同的NED源樹中的樹和包一致。如果你在a<root> 中有ED文件(<root>所得的在NEDPATH中

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論