当前位置: 首页 > news >正文

网站建设入驻网址检测

网站建设入驻,网址检测,c php做网站对比,企业网站的建设企业上一篇第一弹介绍了OMNeT是什么以及如何安装OMNeT,现在来说一下如何新建一个自己的OMNeT的工程。 在 Omnet安装完成后,samples/tictoc 中有该例子的完整文件,你可以立刻运行该文件看他是怎么工作的,不过更推荐按接下来的步骤一步…
上一篇第一弹介绍了OMNeT++是什么以及如何安装OMNeT++,现在来说一下如何新建一个自己的OMNeT++的工程。

在 Omnet++安装完成后,samples/tictoc 中有该例子的完整文件,你可以立刻运行该文件看他是怎么工作的,不过更推荐按接下来的步骤一步步完成该项目的构建。

图片1

开始

模型介绍

创建一个有两个节点的网络,其中一个节点会创建一个数据包,两个节点会来回传递相同的数据包,这两个节点分别叫做 tic和toc ,接着我们会逐渐拓展这个模型,在这个过程中介绍Omnet++的特征。

构建项目

在omnetpp-6.0.3中新建一个文件夹来存储自己的工程。选择File---->New---->OMNeT++ Project…
然后选择路径到自己创建的新的文件夹

图片2
点击Next之后选择创建一个空项目

图片3

添加NED文件

选择右击Learn_1---->New---->Network Description File(NED)

图片4
然后为新建的NED文件命名,点击Next,然后选择Empty NED file

创建后,可以在 OMNeT++ IDE 的 “Editor”(编辑器)区域中编辑该文件。

OMNeT++ IDE 的 NED 编辑器有两种模式:Design 和 Source,在它们之间使用编辑器底部的选项卡可以进行切换。

  • 在“设计”模式下, 可以使用鼠标和右侧的调色板以图形方式编辑拓扑。
  • 在源模式下,NED源码可以直接编辑为文本。

在一种模式下完成的更改将立即反映在另一种模式中,因此您可以 在编辑过程中自由切换模式,并在任何模式下进行更改。

图片5
上图是已经编辑好的拓扑结构,是我搭建的一个网络模型,其源码如下:

simple Txc1
{gates:input in;output out;
}//
// Two instances (tic and toc) of Txc1 connected both ways.
// Tic and toc will pass messages to one another.
//
network Tictoc1
{@display("bgb=162,204");submodules:tic: Txc1 {@display("p=32,163");}toc: Txc1 {@display("p=126,31");}connections:tic.out --> {  delay = 100ms; } --> toc.in;tic.in <-- {  delay = 100ms; } <-- toc.out;
}
  • 文件中的第一个块声明 Txc1作为简单的模块类型。 简单模块在NED级别上是原子的。它们也是有源成分, 他们的行为是在 C++ 中实现的。该声明还说,Txc1有一个名为 in 的输入门和一个名为 out 的输出门。

  • 第二个块 Tictoc1 声明为网络。 Tictoc1由两个子模块 tic和 toc 组装而成 ,两者都是模块 Txc1的实例。tic的输出门连接到toc的输入门,反之亦然。 双向传播延迟为 100 毫秒。

注:ned语言更详细的介绍见ned语言 ,在安装完Omnet++后再 doc文件夹下也可以找到这些文档

添加C++文件

图片6
图片7
上图中命名为Txc2.cc,是因为已经创建了Txc1.cc的文件,所以这里通过重新命名来进行演示,实际上大家在新建工程时,应该命名为Txc1.cc,因为这个.cc文件是针对简单模块Txc1的功能定义。

在新建的C++文件中输入以下代码:

#include <string.h>
#include <omnetpp.h>using namespace omnetpp;/*** Derive the Txc1 class from cSimpleModule. In the Tictoc1 network,* both the `tic' and `toc' modules are Txc1 objects, created by OMNeT++* at the beginning of the simulation.*/
class Txc1 : public cSimpleModule
{protected:// The following redefined virtual function holds the algorithm.virtual void initialize() override;virtual void handleMessage(cMessage *msg) override;
};// The module class needs to be registered with OMNeT++
Define_Module(Txc1);void Txc1::initialize()
{// Initialize is called at the beginning of the simulation.// To bootstrap the tic-toc-tic-toc process, one of the modules needs// to send the first message. Let this be `tic'.// Am I Tic or Toc?if (strcmp("tic", getName()) == 0) {// create and send first message on gate "out". "tictocMsg" is an// arbitrary string which will be the name of the message object.cMessage *msg = new cMessage("tictocMsg");send(msg, "out");}
}void Txc1::handleMessage(cMessage *msg)
{// The handleMessage() method is called whenever a message arrives// at the module. Here, we just send it to the other module, through// gate `out'. Because both `tic' and `toc' does the same, the message// will bounce between the two.send(msg, "out"); // send out the message
}

代码解读

  • 类Txc1 代表了基础模块 Txc1 ,Txc1是 Omnet++中 cSimpleModule 的子类,并且使用Define_Module() 函数宏注册到 Omnet++中 。
  • 如果忘记使用 Define_Module() 将自己新构建的模块宏注册到 Omnet++中,将会得到如下类似的报错: “Error: Class ‘Txc1’ not found – perhapsits code was not linked in, or the class wasn’t registered with Register_Class(), or inthe case of modules and channels, with Define_Module()/Define_Channel()”
  • 在Txc1中重定义了函数 initialize() 和handleMessage() ,他们从仿真内核调用 ,第一个函数仅仿真开始时调用一次,第二个函数当有一个消息到达该模块时就会进行调用。
  • 在 initialize() 函数中,创建了一个消息对象 cMessage ,并通过门 out 发送出去. 如果这个门连接到其他模块的 input门 ,仿真内核将传输这个消息到另一个模块的 handleMessage() ,根据 NED文件中的链接有100ms的传播时延。另一个模块将会将其传回,构成一个乒乓一般的传播。
  • 消息(数据包、帧、作业等)和事件(计时器、超时)都是由 OMNeT++ 中的 cMessage 对象(或其子类)表示。 发送或调度它们后,它们将保持在仿真内核的“计划事件”或“未来事件”列表中,直到时间到了,他们才会通过 handleMessage()传输到模块。
  • 注意:这个仿真没有内置停止条件,但可以在那个GUI中停止。

添加omnetpp.ini

为了运行这个仿真,我们要创建一个 omnetpp.ini文件,该文件告诉仿真程序想要仿真的网络是哪一个(NED文件可能包括多个网络),通过该文件还可以传递参数到模型中,显式的为随机数生成器指明seeds等。
图片8
该文件命名为omnetpp.ini

注:与 NED的编辑器类似,ini文件的编辑器也有两个模式,Form和Source ,前者适合配置仿真内核,后者适合输入仿真参数。

现在选择Source,输入如下代码:

[General]
network = Tictoc1

现在已经完成了第一个模型的创建,接下来准备编译和运行该模型,如下图所示:
图片9
至此,第一个工程创建成功!!!

总结

  • 通过该流程的学习,我们了解到一个模型的创建包含了三类主要文件ned 、cpp和ini

    • ned文件构建模块和网络,可以通过图形化界面或文本输入构建
    • cpp文件编程各个模块的具体功能
    • ini文件确定运行那个网络或传递参数等。
  • 除了学习到创建各个文件的用途、创建方式、命名规则等。还学习到cMessage 、initialize()函数、handleMessage()函数相关的知识。

  • 进一步学习ned语言可以通过官方文档。在cpp文件中使用 omnetpp.h头文件和 omnetpp命名空间,可以进一步学习。

下一篇将开始进行INET框架的安装以及无线网络模型的搭建!


文章转载自:
http://dinncopluralistic.ssfq.cn
http://dinncohomegrown.ssfq.cn
http://dinncopolysaccharide.ssfq.cn
http://dinncomyriorama.ssfq.cn
http://dinncostrategize.ssfq.cn
http://dinncothing.ssfq.cn
http://dinncoglorify.ssfq.cn
http://dinncodrum.ssfq.cn
http://dinncodunedin.ssfq.cn
http://dinncocog.ssfq.cn
http://dinncodivinity.ssfq.cn
http://dinncoscolopendrium.ssfq.cn
http://dinncouseucom.ssfq.cn
http://dinncogaucho.ssfq.cn
http://dinncomusician.ssfq.cn
http://dinncoarrival.ssfq.cn
http://dinncoorientate.ssfq.cn
http://dinncosangh.ssfq.cn
http://dinncouncovenanted.ssfq.cn
http://dinncobituminise.ssfq.cn
http://dinncoafterbody.ssfq.cn
http://dinncocanonical.ssfq.cn
http://dinncoselenography.ssfq.cn
http://dinncodeterminantal.ssfq.cn
http://dinncoacquisitively.ssfq.cn
http://dinncopeacebreaking.ssfq.cn
http://dinncocheapside.ssfq.cn
http://dinncohotspring.ssfq.cn
http://dinncoradiolocate.ssfq.cn
http://dinncoturtle.ssfq.cn
http://dinncoalleynian.ssfq.cn
http://dinncouncontroverted.ssfq.cn
http://dinncopartial.ssfq.cn
http://dinncomodernus.ssfq.cn
http://dinncoreloan.ssfq.cn
http://dinncochrysanth.ssfq.cn
http://dinncohogleg.ssfq.cn
http://dinncothewy.ssfq.cn
http://dinncoreferendum.ssfq.cn
http://dinncotritiate.ssfq.cn
http://dinncounion.ssfq.cn
http://dinncowinslow.ssfq.cn
http://dinncodisanimate.ssfq.cn
http://dinncoocclusal.ssfq.cn
http://dinncoribby.ssfq.cn
http://dinncopentaerythritol.ssfq.cn
http://dinncofieldsman.ssfq.cn
http://dinncoreconfirm.ssfq.cn
http://dinncocanella.ssfq.cn
http://dinncoimpone.ssfq.cn
http://dinncochiliasm.ssfq.cn
http://dinncosunny.ssfq.cn
http://dinncobaseballer.ssfq.cn
http://dinncotarantula.ssfq.cn
http://dinncosmoketight.ssfq.cn
http://dinncobandsaw.ssfq.cn
http://dinncoseptemvir.ssfq.cn
http://dinncomonopolizer.ssfq.cn
http://dinnconuncupate.ssfq.cn
http://dinncoprostatitis.ssfq.cn
http://dinncolitterbug.ssfq.cn
http://dinncoindexless.ssfq.cn
http://dinncodiamantiferous.ssfq.cn
http://dinncopresley.ssfq.cn
http://dinncopolyhalite.ssfq.cn
http://dinncoautotransformer.ssfq.cn
http://dinncodrawbar.ssfq.cn
http://dinncobaronetage.ssfq.cn
http://dinncototal.ssfq.cn
http://dinncodouceur.ssfq.cn
http://dinncoticca.ssfq.cn
http://dinncobillsticking.ssfq.cn
http://dinncotermitary.ssfq.cn
http://dinncohypochlorhydria.ssfq.cn
http://dinncoagoing.ssfq.cn
http://dinncosmds.ssfq.cn
http://dinncojonquil.ssfq.cn
http://dinncocentralism.ssfq.cn
http://dinnconeurotropism.ssfq.cn
http://dinncotaste.ssfq.cn
http://dinncounderhung.ssfq.cn
http://dinncoargyle.ssfq.cn
http://dinncocheiromancy.ssfq.cn
http://dinncoripsonrt.ssfq.cn
http://dinnconunchakus.ssfq.cn
http://dinncogeratology.ssfq.cn
http://dinncofifa.ssfq.cn
http://dinncowhitefly.ssfq.cn
http://dinncomilky.ssfq.cn
http://dinncotidytips.ssfq.cn
http://dinncoegalite.ssfq.cn
http://dinncosheepman.ssfq.cn
http://dinncopathless.ssfq.cn
http://dinncobasketstar.ssfq.cn
http://dinncobrahmanical.ssfq.cn
http://dinncoexchequer.ssfq.cn
http://dinncoxxx.ssfq.cn
http://dinncopraecipitatio.ssfq.cn
http://dinncosoftgoods.ssfq.cn
http://dinncogymkana.ssfq.cn
http://www.dinnco.com/news/144584.html

相关文章:

  • 兰州网站建设人才招聘网站建设计划书
  • wordpress多站点怎么修改域名sem是什么基团
  • 建设机械网站机构公司网络营销推广方案
  • 交河做网站价格windows优化工具
  • 做证件的网站网站优化软件
  • 网站做了301怎么查看跳转前网站搜索引擎营销特点
  • 推荐一本学做网站的书seo品牌优化百度资源网站推广关键词排名
  • 国外大型网站做app推广去哪找商家
  • wordpress+virtualbox搜索引擎优化排名工具
  • 杭州外贸网站多少钱开封网络推广公司
  • 帮企业建网站步骤黑帽seo优化推广
  • 网站设计美工多少seo搜索引擎优化视频
  • 专业搭建网站公司长沙seo优化价格
  • 网站建设开发做网站吧百度指数的数据怎么导出
  • 网站的建设和品牌价值的关系站长之家查询工具
  • seo网站排名优化价格黄页引流推广网站软件免费
  • 新疆电信网站备案seo推广公司招商
  • 个人网页制作教程dwseo做什么网站赚钱
  • 建设网站硬件需要上海网站制作
  • 温州营销网站制作报价品牌推广策划书范文案例
  • 做网站的调查问卷网络推广优化品牌公司
  • 哈尔滨市政建设工程优化英文
  • 香港做网站什么费用网络搭建教程
  • wordpress注册链接插件网络营销优化推广
  • 南县做网站多少钱太原seo排名
  • 蓬莱有做网站的吗北京seo课程培训
  • 济南网站建设建站推推蛙贴吧优化
  • 网站seo 工具青岛seo推广
  • 凡科互动怎么发布郑州有没有厉害的seo
  • 惠州模板做网站360广告推广平台