1 簡介
1.1 OMNeT++ 簡介
OMNeT++ 是一個物件導向模組化的離散事件模擬平台,它具備一個通用的基礎架構因此可以被使用在(已經被使用在)很多不同的領域當中,這些領域包括:
- 有線及無線通訊網路模型建立
- 協定模型建立
- 排隊理論網路模型建立
- 多處理器以及其他分散式硬體系統模型建立
- 硬體架構驗證
- 複合式的軟體系統效能評估
- 一般情況下,適合用來對任何離散式事件系統的建模與模擬,同時也可以很方便的轉換使其應用到以訊息交換為基礎的元件通訊。
OMNeT++ 本身並非一個具體的模擬器,但是他提供撰寫一個模擬所需要的基礎設施以及工具。一個很重要的基本元素是OMNeT++具有一個以模擬模組元件為基礎的架 構,一些可以重複使用的元件(component)可以組合成模組(modules),這些經過良好程式撰寫的模組可以實現軟件重複使用的特性 (reusability),並且可以像樂高積木(LEGO)一樣的依照不同的需求組合應用。
Modules (註*1) 可以使用閘(gates)互相的連接(gate在其他的系統可能會被稱為埠(port)),也可以彼此組合成為複合模組(compound modules)。module可以使用巢狀組合的方式組成新的module,而巢狀的深度則沒有限制。Modules間的通訊是藉由一個稱為訊息 (message)的物件來傳遞,message可以攜帶任意型式的資料結構。modules間的message傳遞可以經過一個預先設計好的路線(路線 由gates和connections組成),或是直接傳遞給目的端模組。直接傳遞給模組這個方式很常被使用在無線網路模擬上面。舉例來說, Modules可能有一些參數用來調整模組的行為或是調整模型的拓樸(topology)(註*2)。最低階層的Module被稱為simple modules,它們封裝了模組的行為。Simple module使用C++語言以及模擬資料庫元件撰寫。
(譯註*1:我想這些專有名詞還是用英文來表示比較不容易被誤解,所以接下來的翻譯在容易混淆的地方都會直接使用英文名詞)
(譯註*2:這個舉例有點怪怪的,但可以認為是無線網路中access point和mobile station間的通訊是直接連接的型式)
OMNeT++可以在不同的使用者介面下執行,圖形及動畫使用者介面對於模擬程式的驗證以及除錯有很好的幫助,而命令列模式使用者介面則很適合用在需要快速取得模擬結果或是大批量模擬運行的場合。
這個模擬器、使用者介面以及其他工具都是可攜的,它們在各個主要的作業系統上被測試以確認可以正確執行,像是Linux、Mac OS/X、以及Windows。同時,雖然沒有經過詳細的測試,它們也可以在其他Unix衍生的作業系統上被編譯執行。
OMNeT++ 也支援平行分散式模擬。OMNeT++可以同時使用數個機器互相交換訊息分別完成平行分散式系統模擬中的一部分。舉例來說,MPI或是named pipes (註*3)。平行模擬演算法可以在此系統上很容易的改寫擴充或是很容易的外掛新的演算法。模型並不需要特別的指令就可以在平行系統上被執行,僅僅需要在系 統組態設定時指定是否使用平行模擬即可。OMNeT++甚至可以被用來在課堂上展現說明平行演算法,因為它可以將平行事件使用圖形介面以動畫的方式呈現, 對於事件的理解有很大的幫助。
(譯註*3:MPI, Message Passing Interface 一種為平行處理設計的訊息傳遞系統標準。named pipe 一種使用在 inter-process communication 的方法)
OMNEST是OMNeT++的商業版本,OMNeT++是一個自由軟體同時僅限於教育與非營利使用。如果是使用在商業上,你必須向Simulcraft公司購買OMNEST的使用版權。
1.2 使用手冊內容
這份使用手冊的組成如下:
- 第一章和第二章包含一些介紹性的文件
- 第三章、第四章、以及第七章為程式設計指南。包含NED語言,它描述了模擬組成的概念以及如何使用OMNeT++實作,也包含如何撰寫一個simple module和使用這些模組的類別資料庫
- 第十一章和十四章說明如何客製化網路圖、如何撰寫NED程式碼註解以便使用文件產生器生成說明文件
- 第八、九、十、和十二章說明如何建立和執行一個模擬,以及分析模擬的結果,同時說明OMNeT++提供那些工具來完成這些工作
- 第十六章說明分散式執行
- 第十七章和十八章說明OMNeT++內部的架構以及如何拓展或是嵌入OMNeT++進入大型系統
- 附錄收錄關於NED語言、組態選項、檔案格式、以及其他等參考資料
1 Introduction
1.1 What Is OMNeT++?
OMNeT++ is an object-oriented modular discrete event network simulation framework. It has a generic architecture, so it can be (and has been) used in various problem domains:
- modeling of wired and wireless communication networks
- protocol modeling
- modeling of queueing networks
- modeling of multiprocessors and other distributed hardware systems
- validating of hardware architectures
- evaluating performance aspects of complex software systems
- in general, modeling and simulation of any system where the discrete event approach is suitable, and can be conveniently mapped into entities communicating by exchanging messages.
OMNeT++ itself is not a simulator of anything concrete, but rather provides infrastructure and tools for writing simulations. One of the fundamental ingredients of this infrastructure is a component architecture for simulation models. Models are assembled from reusable components termed modules. Well-written modules are truly reusable, and can be combined in various ways like LEGO blocks.
Modules can be connected with each other via gates (other systems would call them ports), and combined to form compound modules. The depth of module nesting is not limited. Modules communicate through message passing, where messages may carry arbitrary data structures. Modules can pass messages along predefined paths via gates and connections, or directly to their destination; the latter is useful for wireless simulations, for example. Modules may have parameters that can be used to customize module behavior and/or to parameterize the model’s topology. Modules at the lowest level of the module hierarchy are called simple modules, and they encapsulate model behavior. Simple modules are programmed in C++, and make use of the simulation library.
OMNeT++ simulations can be run under various user interfaces. Graphical, animating user interfaces are highly useful for demonstration and debugging purposes, and command-line user interfaces are best for batch execution.
The simulator as well as user interfaces and tools are highly portable. They are tested on the most common operating systems (Linux, Mac OS/X, Windows), and they can be compiled out of the box or after trivial modifications on most Unix-like operating systems.
OMNeT++ also supports parallel distributed simulation. OMNeT++ can use several mechanisms for communication between partitions of a parallel distributed simulation, for example MPI or named pipes. The parallel simulation algorithm can easily be extended, or new ones can be plugged in. Models do not need any special instrumentation to be run in parallel — it is just a matter of configuration. OMNeT++ can even be used for classroom presentation of parallel simulation algorithms, because simulations can be run in parallel even under the GUI that provides detailed feedback on what is going on.
OMNEST is the commercially supported version of OMNeT++. OMNeT++ is free only for academic and non-profit use; for commercial purposes, one needs to obtain OMNEST licenses from Simulcraft Inc.
1.2 Organization of This Manual
The manual is organized as follows:
- The Chapters [1] and [2] contain introductory material
- The second group of chapters, [3], [4] and [7] are the programming guide. They present the NED language, describe the simulation concepts and their implementation in OMNeT++, explain how to write simple modules, and describe the class library.
- The chapters [11] and [14] explain how to customize the network graphics and how to write NED source code comments from which documentation can be generated.
- Chapters [8], [9], [10] and [12] deal with practical issues like building and running simulations and analyzing results, and describe the tools OMNeT++ provides to support these tasks.
- Chapter [16] is devoted to the support of distributed execution.
- Chapters [17] and [18] explain the architecture and internals of OMNeT++, as well as ways to extend it and embed it into larger applications.
- The appendices provide a reference on the NED language, configuration options, file formats, and other details.