OMNeT++ ALOHA sample代码阅读

写在最前

前一篇博客谢了关于ALOHA的一些原理,现在看OMNeT++这个网络仿真软件的sample是如何实现ALOHA网络的。

代码

Server.ned

simple Server
{
    parameters:
        @display("i=device/antennatower_l");
        @signal[receiveBegin](type="long");  // increases with each new frame arriving to the server and drops to 0 if the channel becomes finally idle
        @signal[receive](type="long");  // for successful receptions (non-collisions): 1 at the start of the reception, 0 at the end of the reception
        @signal[collision](type="long"); // the number of collided frames at the beginning of the collision period
        @signal[collisionLength](type="simtime_t");  // the length of the last collision period at the end of the collision period
        @signal[channelState](type="long");

        //source 
        @statistic[serverChannelState](source="channelState";title="Channel state";enum="IDLE=0,TRANSMISSION=1,COLLISION=2";record=vector);
        @statistic[receiveBegin](source="receiveBegin"; record=vector?; interpolationmode=sample-hold; title="receive begin");
        @statistic[channelUtilization](source="timeavg(receive)"; record=last; interpolationmode=linear; title="channel utilization");
        @statistic[collisionMultiplicity](source=collision; record=vector?,histogram; title="collision multiplicity");
        @statistic[collisionLength](record=vector?,histogram,mean,sum,max; title="collision length");
        @statistic[receivedFrames](source="sum(receive)"; record=last; title="received frames");
        @statistic[collidedFrames](source="sum(collision)"; record=last; title="collided frames");
    gates:
        input in @directIn;
}

.ned文件一般是用于OMNeT中模块与仿真内核的配置,里面一般包含该模块的parameter,gates,connections等等。其中这里Server.ned文件中,开头定义了一些signal,主要是配合后面的statistic来使用,用于统计仿真过程中需要的统计指标(如时延,信道利用率等)。还定义了一个输入

  • 7
    点赞
  • 24
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
OMNeT++是一种基于C++语言开发的网络仿真框架,它的核心是一个模块化的、分层的仿真引擎。它被广泛应用于各种网络技术的研究和开发中。 OMNeT++的原代码包含了该框架的各个组成部分,包括模块库、仿真内核以及仿真实例等。其中,模块库是用于构建仿真模型的组件,提供了一系列已经实现好的网络协议和算法;仿真内核是框架的核心部分,负责处理事件驱动的仿真环境;仿真实例则是具体应用的实现,包括网络、节点、消息和事件等。 通过使用OMNeT++的原代码,用户可以自定义仿真模型,并根据实际需求编写自己的仿真代码。用户可以从模块库中选择合适的网络协议和算法,并将它们组合起来构建一个完整的仿真模型。用户可以对仿真模型中的节点、网络拓扑、消息传递和事件处理进行灵活的控制和定制。 同时,OMNeT++的原代码还提供了丰富的仿真功能,包括统计数据的收集与分析、仿真结果的可视化、调试工具的支持等。这些功能使得用户能够更加方便地进行网络仿真实验,并对仿真结果进行准确的评估和分析。 总之,OMNeT++的原代码提供了一个强大的网络仿真平台,用户可以根据自己的需求和兴趣进行网络仿真实验。通过使用OMNeT++,用户可以更好地理解和评估各种网络技术,为网络研究和开发提供有力的支持。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值