OMNetpp学习笔记.docx

上传人:b****1 文档编号:2094382 上传时间:2022-10-26 格式:DOCX 页数:16 大小:20.70KB
下载 相关 举报
OMNetpp学习笔记.docx_第1页
第1页 / 共16页
OMNetpp学习笔记.docx_第2页
第2页 / 共16页
OMNetpp学习笔记.docx_第3页
第3页 / 共16页
OMNetpp学习笔记.docx_第4页
第4页 / 共16页
OMNetpp学习笔记.docx_第5页
第5页 / 共16页
点击查看更多>>
下载资源
资源描述

OMNetpp学习笔记.docx

《OMNetpp学习笔记.docx》由会员分享,可在线阅读,更多相关《OMNetpp学习笔记.docx(16页珍藏版)》请在冰豆网上搜索。

OMNetpp学习笔记.docx

OMNetpp学习笔记

OMnetpp作为一种仿真工具(与ns2,opnet并列),在P2P仿真方面具有很大的优势。

模块概念

模块

OMnetpp中功能被封装为一个个的模块。

简单模块(simplemodules)为基本模块,每个simplemodule完成一个基本功能。

Compoundmodule由多个simplemodule组成。

Messages,Gates,Links

massage是模块之间通信的媒介,可以包含复杂的结构体。

Gatesaretheinputandoutputinterfacesofmodules;messagesaresentoutthroughoutputgatesandarrivethroughinputgates.

Eachconnection(alsocalledlink)iscreatedwithinasinglelevelofthemodulehierarchy:

withinacompoundmodule,onecanconnectthecorrespondinggatesoftwosubmodules,oragateofonesubmoduleandagateofthecompoundmodule。

包传输模拟

connections可以使用物理链路模拟。

支持的参数有:

datarate,propagationdelay,biterrorrateandpacketerrorrate,andmaybedisabled.这些参数在channel对象中。

参数

Modules可以拥有参数。

ParameterscanbeassignedineithertheNEDfilesortheconfigurationfile.

TopologyDescriptionMethod

TheuserdefinesthestructureofthemodelinNEDlanguagedescriptions(NetworkDescription).

ProgrammingtheAlgorithms

Simulationobjects(messages,modules,queuesetc.)arerepresentedbyC++classes.Theyhavebeendesignedtoworktogetherefficiently,creatingapowerfulsimulationprogrammingframework.Thefollowingclassesarepartofthesimulationclasslibrary:

>>module,gate,parameter,channel

>>message,packet

>>containerclasses.queue,array)

>>datacollectionclasses

>>statisticanddistributionestimationclasses(histograms,P2algorithmforcalculatingquantilesetc.)

>>transientdetectionandresultaccuracydetectionclasses

使用OMNetpp

buildingandrunningsimulations

一个OMNetppmodel由以下几部分组成:

1.NED语言拓扑描述(.ned文件):

使用参数,gates等描述module结构。

NED文件可以用任意texteditor编辑,但OMNetppIDE提供了两种方式:

图形与文本。

2.消息定义(.msg文件)定义各种消息类型。

OMNetpp会将消息定义转换成C++类。

3.简单模块源文件(Simplemodulesources):

C++文件

仿真系统包括两部分:

1.仿真内核

2.用户接口

3.NED语言

NED概述

NED特点:

1)层次性:

复杂模块由简单模块组成

2)模块化

3)接口

4)继承性

5)包结构的管理:

如Java

6)内部类型:

(可以定义局部变量)

7)Metadataannotations(元数据注解?

NED开始

图1网络举例

这个网络描述如下:

.

connections:

++<-->{datarate=100Mbps;}<-->++;

++<-->{datarate=100Mbps;}<-->++;

++<-->{datarate=100Mbps;}<-->++;

...

}

channel类型

可以定义channel类型

.

connections:

++<-->C<-->++;

++<-->C<-->++;

++<-->C<-->++;

...

}

一些简单模块( App,Routing,andQueue)

简单模块定义有关键字:

simple。

在这个例子中,我们定义了node为简单模块(trafficgeneration,routing,etc.其实也挺复杂的)。

应当定义一些简单模块,然后组合起来组成一个复合模块(compoundmodule)。

一个流量生成的简单模块,一个路由模块,一个队列模块。

(We'llhaveonesimplemodulefortrafficgeneration(App),oneforrouting(Routing),andoneforqueueinguppacketstobesentout(Queue))

simpleApp

{

parameters:

intdestAddress;

...

@display("i=block/browser");

gates:

inputin;

outputout;

}

simpleRouting

{

...

}

simpleQueue

{

...

}

这些放在 ,  和 文件中。

NOTE:

module 类型名称首字母大写,gate,parameter等用小写。

NED区分大小写。

@display()称作displaystring,在图形环境中显示。

"i=..."定义默认图标。

一般的,在NED中@-words如 @display 称作 properties 。

用来注释metadata,可以用于 files,modules,parameters,gates,connections,andotherobjects,andparametervalue

复合模块

moduleNode

{

parameters:

@display("i=misc/node_vs,gold");

gates:

inoutport[];

submodules:

app:

App;

routing:

Routing;

queue[sizeof(port)]:

Queue;

connections:

-->;

<--;

fori=0..sizeof(port)-1{

[i]-->queue[i].in;

[i]<--queue[i].out;

queue[i].line<-->port[i];

}

}

此为node的定义。

复合模块可以和简单模块一样,有parameter,gate。

简单模块

simpleQueue

{

parameters:

intcapacity;

@display("i=block/queue");

gates:

inputin;

outputout;

}

以上是一个Queue模块。

参数都是可选的。

动作不在NED语言中定义,而是在C++中定义。

默认情况下,OMNetpp会在与NED名字相同的C++类中寻找(如此例,Queue)。

也可以使用下面的方式指定:

simpleQueue

{

parameters:

intcapacity;

@class(mylib:

:

Queue);

@display("i=block/queue");

gates:

inputin;

outputout;

}

如果多个模块在同一名字空间中,则可以采用如下的方式

@namespace(mylib);

simpleApp{

...

}

simpleRouter{

...

}

simpleQueue{

...

}

这样C++类为mylib:

:

App, mylib:

:

Router and mylib:

:

Queue。

类似于C++中类的继承,简单模块之间也可以存在这样的关系:

simpleQueue

{

intcapacity;

...

}

simpleBoundedQueueextendsQueue

{

capacity=10;

}

该例BoundedQueue给capacity设置了初始值,这个模块使用的类与Queue相同,都是Queue。

若要使用不同的类,则需要用以下方式:

simplePriorityQueueextendsQueue

{

@class(PriorityQueue);

}

此时,PriorityQueue使用的类为PriorityQueue。

复合模块

moduleWirelessHostBase

{

gates:

inputradioIn;

submodules:

tcp:

TCP;

ip:

IP;

wlan:

Ieee80211;

connections:

-->;

<--;

++-->;

++<--;

<--radioIn;

}

moduleWirelessUserextendsWirelessHostBase

{

submodules:

webAgent:

WebAgent;

connections:

-->++;

<--++;

}

moduleDesktopUserextendsWirelessUser

{

gates:

inoutethg;

submodules:

eth:

EthernetNic;

connections:

++-->;

++<--;

<-->ethg;

}

Channels(通道)

Channel将parameters与behaviour封装并与connections相关联。

Channels像简单模块,在寻找C++类的处理方面与简单模块相同。

已提供的channel有,  and (ned是包名,可以使用importned.*导入这些包)。

IdealChannel没有参数,它允许messages无延时的到达对端。

一个connection不包含channel对象与包含IdealChannel对象相同。

DelayChannel有两个参数:

delay:

double类型,标明延迟。

disable

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 自然科学 > 数学

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1