来自UDPBasicApp的omnet ++中的派生应用程序未注册或链接

时间:2016-06-23 18:40:15

标签: omnet++ inet

我正在尝试从inet的UDPBasicApp实现我自己的UDP应用程序。我创建了一个如下所示的VoIPApp.cc:

#include <omnetpp.h>

class VoIPApp: public inet::UDPBasicApp {
public:

};

Register_Class(VoIPApp);

我在我的network.ned文件中声明了该应用程序:

import inet.networklayer.configurator.ipv4.FlatNetworkConfigurator;
import inet.node.inet.StandardHost;
import ned.DatarateChannel;
import inet.applications.udpapp.UDPBasicApp;

simple VoIPApp extends UDPBasicApp
{
    @class(VoIPApp);
}

network VoIPNetwork
{
    @display("bgb=561,272");
    types:
        channel standardChannel extends DatarateChannel
        {
            delay = default(10ms);
            datarate = default(10Mbps);
        }
    submodules:
        host1: StandardHost {
            @display("p=108,96");
        }
        host2: StandardHost {
            @display("p=431,96");
        }
        flatNetworkConfigurator: FlatNetworkConfigurator {
            @display("p=253,31");
        }
        host3: StandardHost {
            @display("p=250,221");
        }
    connections:
        host1.pppg++ <--> standardChannel <--> host2.pppg++;
        host1.pppg++ <--> standardChannel <--> host3.pppg++;
        host3.pppg++ <--> standardChannel <--> host2.pppg++;
}

我在omnetpp.ini中设置了三个StandardHost节点中的至少一个以使用此应用程序:

[General]
network = VoIPNetwork

repeat = 1
sim-time-limit = 100s
**.networkConfiguratorModule = ""

#Measure
**.ppp[*].numInputHooks = 1 
**.ppp[*].inputHook[0].typename = "ThruputMeter" 
**.vector-recording = false


# Client settings
**.host1.numUdpApps = 1 
**.host1.udpApp[0].typename = "VoIPApp"  
**.host1.udpApp[0].destAddresses = "host2 host3" 
**.host1.udpApp[0].destPort = 5000
**.host1.udpApp[0].localPort = 5000
**.host1.udpApp[0].messageLength = 32B + 40B #Data: 32B, Header: 40B = 20B(IP) + 8B(UDP) + 12B(RTP)
**.host1.udpApp[0].sendInterval = 20ms # 1000ms / 20ms = 50 packets per second.

**.host2.numUdpApps = 1 
**.host2.udpApp[0].typename = "UDPBasicApp"  
**.host2.udpApp[0].destAddresses = "host1 host3" 
**.host2.udpApp[0].destPort = 5000
**.host2.udpApp[0].localPort = 5000 
**.host2.udpApp[0].messageLength = 32B + 40B
**.host2.udpApp[0].sendInterval = 20ms

**.host3.numUdpApps = 1 
**.host3.udpApp[0].typename = "UDPBasicApp"  
**.host3.udpApp[0].destAddresses = "host1 host2" 
**.host3.udpApp[0].destPort = 5000
**.host3.udpApp[0].localPort = 5000 
**.host3.udpApp[0].messageLength = 32B + 40B
**.host3.udpApp[0].sendInterval = 20ms

当我运行时,我收到以下错误:

Error in module (omnetpp::cModule) VoIPNetwork.host1 (id=2) during network setup: Class "VoIPApp" not found -- perhaps its code was not linked in, or the class wasn't registered with Register_Class(), or in the case of modules and channels, with Define_Module()/Define_Channel().

我也尝试使用Define_Module()而不是Register_Class(),导致同样的错误。

我错过了什么?

1 个答案:

答案 0 :(得分:0)

我使用IDE创建了项目:New -> Project。这与New -> New OMNeT++ Project不同。

我猜它缺少一些必要的OMNeT ++东西。魔鬼在细节中。

创建适当的omnet项目后,VoIPApp.cc可以只包含<UDPBasicApp.h>

#include <UDPBasicApp.h>

class VoIPApp: public UDPBasicApp {
public:

};

Define_Module(VoIPApp);

此外,您应该将VoIPApp的声明放在标准的package.ned中,而不是放在自己的VoIPApp.ned中:

package voip;

import inet.applications.udpapp.UDPBasicApp;

simple VoIPApp extends UDPBasicApp {
    @class(VoIPApp);
}

请注意,我需要运行OMNeT ++ 4.6和inet 2.6而不是最新版本,因此NED文件的包含路径现在对应于这些版本的路径。