如何使用prepareWSM和sendWsm

时间:2019-03-13 13:22:55

标签: omnet++ veins

我使用OMNeT ++-5.3和Veins-4.7.1。 这就是我实现代码以计数器模式发送消息的方式(与泛洪相同)

    void Counter::sendMessage(std::string blockedRoadId)
{
    t_channel channel = dataOnSch ? type_SCH : type_CCH;
    WaveShortMessage* wsm = prepareWSM("data", dataLengthBits, channel, dataPriority, -1,2);
    wsm->setWsmData(blockedRoadId.c_str());
    sendWSM(wsm);

    sentMessage = true;
}
void Counter::handleSelfMsg(cMessage *msg)
{
 // for "data" and "beacon" self messages
 if ((!strcmp(msg->getName(), "data")) || (!strcmp(msg->getName(), "beacon"))) {
 BaseWaveApplLayer::handleSelfMsg(msg);
 return;
 }
 else { // for "rebroadcast" self messages
 // if the number of times a warning message is received exceeds the counterThreshold
 // configuration variable, do not rebroadcast.
 if (receivedMessages[atol(msg->getName())].size() >= (unsigned)counterThreshold)
 return;
 // if greater than threshold.. rebroadcast.
 sendWSM(receivedMessages[atol(msg->getName())][0]->dup());
 }
}

这些是我发现的错误:

'dataPriority’ was not declared in this scope

‘sendWSM’ was not declared in this scope

你能帮我吗?

这是代码Counter.h

typedef std::vector<WaveShortMessage*> WaveShortMessages;
class Counter : public BaseWaveApplLayer
{
    public:
        virtual void initialize(int stage);
        virtual void receiveSignal(cComponent *source, simsignal_t signalID, cObject *obj);
    protected:
        TraCIMobility* traci;
        vector<WaveShortMessage*> warningMessages;
        map<long,WaveShortMessages> receivedMessages; // treeId, WSM vector
    protected:
        virtual void onBeacon(WaveShortMessage *wsm);
        virtual void onData(WaveShortMessage *wsm);
        virtual void handlePositionUpdate(cObject *obj);
        virtual void sendMessage(std::string blockedRoadId);
        virtual void handleSelfMsg(cMessage *msg)

0 个答案:

没有答案