微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Inet中的AdhocHost在接收消息或数据包时调用类似于handlemessage的函数怎么办?

如何解决Inet中的AdhocHost在接收消息或数据包时调用类似于handlemessage的函数怎么办?

我需要一种方法,每当以下 NED 场景中的一个主机节点接收到消息或数据包时,就会调用像 handlemessage 这样的函数。我想从 Inet 中的 AdhocHost 扩展一个简单或复合模块,例如,名为 Txc1 并具有所有 AdhocHost 属性。甚至可以将这个提到的简单模块扩展到 Inet 目录和子目录之外吗? 我怎样才能达到这个目标?如何在本模块的NED文件、h、cc文件中进行编码?

我的网络 NED 文件如下:

import inet.environment.common.PhysicalEnvironment;
import inet.networklayer.configurator.ipv4.Ipv4NetworkConfigurator;
import inet.node.inet.AdhocHost;
import inet.physicallayer.ieee80211.packetlevel.Ieee80211DimensionalRadioMedium;
import inet.visualizer.integrated.IntegratedVisualizer;

network Net80211
{
    parameters:
        int numHosts;
        @display("bgb=600,400;bgi=background/terrain");
        @signal[packetSent](type=inet::Packet);
        @signal[packetReceived](type=inet::Packet);
        @statistic[packetSent](title="packets sent"; source=packetSent; record=count,"sum(packetBytes)","vector(packetBytes)"; interpolationmode=none);
        @statistic[packetReceived](title="packets received"; source=packetReceived; record=count,"vector(packetBytes)"; interpolationmode=none);
        @statistic[throughput](title="throughput"; unit=bps; source="throughput(packetReceived)"; record=vector);
        @signal[reqStreamBytes](type=long);
        @statistic[reqStreamBytes](title="requested stream bytes"; record=count,sum,vector; interpolationmode=none);
        @statistic[rcvdPkLifetime](title="received packet lifetime"; source="dataAge(packetReceived)"; unit=s; record=stats,vector; interpolationmode=none);
        @statistic[rcvdPkSeqNo](title="received packet sequence number"; source="appPkSeqNo(packetReceived)"; record=vector; interpolationmode=none);
    submodules:
        visualizer: IntegratedVisualizer {
            parameters:
                @display("p=640,15;is=s");
        }
        configurator: Ipv4NetworkConfigurator {
            parameters:
                @display("p=640,112;is=s");
        }
        radioMedium: Ieee80211DimensionalRadioMedium {
            parameters:
                @display("p=638,56;is=s");
        }
        host[numHosts]: AdhocHost {
            parameters:
                @display("r=,#707070;p=300,200;is=s");
        }
        stModule: StModule {
            @display("p=639,169;i=block/cogwheel;is=s");
        }
        globalListener: GlobalListener {
            @display("p=67,128");
        }
}

注意事项:

  1. stModule 是一个简单的模块,用于在完成函数中写入结果。
  2. 作为一种方法,如果一个新模块从 AdhocHost 扩展并且它能够触发自己的 handlemessage 函数,则替换它而不是 AdhocHost。
  3. 按照我的规则,应该在网络层定义该函数。最好在数据链路层也有类似的功能
  4. A new module that inherit from AdhocHost in omnet++ 中有一个类似且简单的问题。虽然我测试了这种方法,但它有一个问题(不是调用 handlemessage)。

提前致谢

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。