Reading Notes on NS2(3)

NS作为一款离散事件模拟器,采用分裂对象模型结合C++与OTcl,支持多种网络类型及路由方式,具备开放源代码特性,适用于网络系统研究。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

NS原理

 

[1] 离散事件模拟器
NS是一个离散事件模拟器。
注意:
(1)事件规定了系统状态的改变,状态的修改仅在事件发生时进行;
(2)在一个网络模拟器中,典型的事件包括分组到达、时钟超时等;
(3)模拟时钟的推进由事件发生的时间量确定;
(4)模拟处理过程的速率不直接对应着实际时间;
(5)一个事件的处理可能又会产生后续的事件;(例如对一个接收到的分组的处理触发了更多的分组的发送)
(6)模拟器所做的就是不停地处理一个个事件,直到所有的事件都被处理完或者某一特定的事件发生为止;
(7)NS的核心部分是一个离散事件模拟引擎;(NS中有一个“调度器”(Scheduler)类)

[2] 丰富的构件库
NS对网络系统中一些通用的实体已经进行了建模。例如链路、队列、分组、节点等,并用对象来实现了这些实体的特性和功能,这就是NS的构 件库。(这大大减轻了进行网络模拟研究的工作量,提高了效率)
(1)网络类型
NS的构件库所支持的网络类型包括广域网、局域网、移动通信网、卫星通信网等;
(2)路由方式
所支持的路由方式包括层次路由、动态路由、多播路由等;
(3)跟踪和检测对象
NS还提供跟踪和检测对象,可以把网络系统中的状态和事件记录下来以便分析;
(4)数学支持
NS还提供了大量的数学方面的支持,包括随机数产生、随机变量、积分等;

[3] 分裂对象模型
NS的构件库是用两种面向对象的语言编写的:C++和OTcl。
OTcl是MIT开发的ObjectTcl,即Tcl的面向对象的扩展。
注意:
(1)Tcl的全称是Toolkit command language,它是一种灵活的、交互式的脚本语言。OTcl则是在Tcl中加入了类、实例、继承等面向对象的概念 。
(2)NS中的构件通常都作为一个C++类来实现,同时有一个OTcl类与之对应(用户通过编写OTcl脚本来对这些对象进行配置、组合,描述模拟过程 ,最后调用NS完成模拟)。这种方式被称为分裂对象模型。构件的主要功能通常在C++中实现,OTcl中的类则主要提供C++对象面向用户的接口。 用户可以通过OTcl来访问对应的C++对象的成员变量和函数。
(3)C++对象和OTcl对象之间是通过叫做TclCL的机制关联起来的。
(4)NS使用这种分裂对象模型,是出于兼顾模拟性能和灵活性两方面的考虑。一方面,C++是高效的编译执行语言,使用C++实现功能的模拟,可 使模拟过程的执行获得较好的性能。另一方面,OTcl是解释执行的,用OTcl进行模拟配置,可以在不必重新编译的情况下随意修改模拟参数和 模拟过程,提高了模拟的效率。
(5)同时,这种分裂对象模型增强了构件库的可扩展性和可组合性,用户通常只需要编写OTcl脚本就可以把一些构件组合起来,成为一个“宏对 象”。(例如,节点对象就是由一些分类器、复用器、链路等对象组合而成的)
(6)分裂对象模型也起到了抽象的作用,它对用户屏蔽了功能实现的细节。用户通过OTcl进行模拟配置,很多情况下只需要了解构件的使用和配 置接口就可以了,而不需要了解这些构件的功能是如何实现的。
(7)实践证明,较好地掌握OTcl语言对于深入学习NS,阅读其他研究者公布的脚本代码以及在自己使用NS过程中减少bug,缩短调试周期等方面 都是大有裨益的。

[4] 开放的源代码
NS是免费的,开放源代码的。(这是一个好的网络模拟器的生命力之所在)

The Network Simulator, Version 3 -------------------------------- Table of Contents: ------------------ 1) An overview 2) Building ns-3 3) Running ns-3 4) Getting access to the ns-3 documentation 5) Working with the development version of ns-3 Note: Much more substantial information about ns-3 can be found at http://www.nsnam.org 1) An Open Source project ------------------------- ns-3 is a free open source project aiming to build a discrete-event network simulator targeted for simulation research and education. This is a collaborative project; we hope that the missing pieces of the models we have not yet implemented will be contributed by the community in an open collaboration process. The process of contributing to the ns-3 project varies with the people involved, the amount of time they can invest and the type of model they want to work on, but the current process that the project tries to follow is described here: http://www.nsnam.org/developers/contributing-code/ This README excerpts some details from a more extensive tutorial that is maintained at: http://www.nsnam.org/documentation/latest/ 2) Building ns-3 ---------------- The code for the framework and the default models provided by ns-3 is built as a set of libraries. User simulations are expected to be written as simple programs that make use of these ns-3 libraries. To build the set of default libraries and the example programs included in this package, you need to use the tool 'waf'. Detailed information on how use waf is included in the file doc/build.txt However, the real quick and dirty way to get started is to type the command ./waf configure --enable-examples followed by ./waf in the the directory which contains this README file. The files built will be copied in the build/ directory. The current codebase is expected to build and run on the set of platforms listed in the RELEASE_NOTES file. Other platforms may or may not work: we welcome patches to improve the portability of the code to these other platforms. 3) Running ns-3 --------------- On recent Linux systems, once you have built ns-3 (with examples enabled), it should be easy to run the sample programs with the following command, such as: ./waf --run simple-global-routing That program should generate a simple-global-routing.tr text trace file and a set of simple-global-routing-xx-xx.pcap binary pcap trace files, which can be read by tcpdump -tt -r filename.pcap The program source can be found in the examples/routing directory. 4) Getting access to the ns-3 documentation ------------------------------------------- Once you have verified that your build of ns-3 works by running the simple-point-to-point example as outlined in 4) above, it is quite likely that you will want to get started on reading some ns-3 documentation. All of that documentation should always be available from the ns-3 website: http:://www.nsnam.org/documentation/. This documentation includes: - a tutorial - a reference manual - models in the ns-3 model library - a wiki for user-contributed tips: http://www.nsnam.org/wiki/ - API documentation generated using doxygen: this is a reference manual, most likely not very well suited as introductory text: http://www.nsnam.org/doxygen/index.html 5) Working with the development version of ns-3 ----------------------------------------------- If you want to download and use the development version of ns-3, you need to use the tool 'mercurial'. A quick and dirty cheat sheet is included in doc/mercurial.txt but reading through the mercurial tutorials included on the mercurial website is usually a good idea if you are not familiar with it. If you have successfully installed mercurial, you can get a copy of the development version with the following command: "hg clone http://code.nsnam.org/ns-3-dev"
最新发布
03-08
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值