Я пытаюсь передать пакет для обнаружения окрестности, когда я запускаю симуляцию, я получил эту ошибку: handleMessage (): Неизвестный протокол: id = 47, name = udp - in module (inet :: MessageDispatcher)SaaS.host [0] .at (id = 77), во время инициализации сети
Мой код:
#ifndef MYAPP_H_
#define MYAPP_H_
#include "inet/common/INETDefs.h"
#include "inet/transportlayer/contract/udp/UdpSocket.h"
#include <omnetpp.h>
using namespace omnetpp;
using namespace inet;
class myApp : public cSimpleModule, public UdpSocket::ICallback
{
protected:
int localPort = -1, destPort = -1;
bool dontFragment = false;
const char *packetName = nullptr;
UdpSocket socket;
cMessage *selfMsg = nullptr;
protected:
void initialize() override;
void socketDataArrived(UdpSocket *socket, Packet *packet) override;
void socketErrorArrived(UdpSocket *socket, Indication *indication) override;
void socketClosed(UdpSocket *socket) override;
public:
myApp() {}
~myApp();
};
#endif /* MYAPP_H_ */
#include "myApp.h"
#include "inet/applications/base/ApplicationPacket_m.h"
#include "inet/applications/udpapp/UdpBasicApp.h"
#include "inet/common/ModuleAccess.h"
#include "inet/common/TagBase_m.h"
#include "inet/common/TimeTag_m.h"
#include "inet/common/lifecycle/ModuleOperations.h"
#include "inet/common/packet/Packet.h"
#include "inet/networklayer/common/FragmentationTag_m.h"
#include "inet/networklayer/common/L3AddressResolver.h"
#include "inet/transportlayer/contract/udp/UdpControlInfo_m.h"
Define_Module(myApp);
myApp::~myApp()
{
EV << "App destructor" << endl;
cancelAndDelete(selfMsg);
}
void myApp::initialize()
{
localPort = par("localPort");
destPort = par("destPort");
packetName = par("packetName");
socket.setOutputGate(gate("socketOut"));
socket.bind(localPort);
socket.setBroadcast(true);
socket.setCallback(this);
std::ostringstream str;
str << getId();
Packet *packet = new Packet(str.str().c_str());
if(dontFragment)
packet->addTagIfAbsent<FragmentationReq>()->setDontFragment(true);
const auto& payload = makeShared<ApplicationPacket>();
payload->setChunkLength(B(par("messageLength")));
payload->addTag<CreationTimeTag>()->setCreationTime(simTime());
packet->insertAtBack(payload);
L3Address address;
L3AddressResolver().tryResolve("255.255.255.255", address);
emit(packetSentSignal, packet);
socket.sendTo(packet, address, destPort);
}
void myApp::socketDataArrived(UdpSocket *socket, Packet *packet)
{
EV << "Data Arrived " << endl;
}
void myApp::socketErrorArrived(UdpSocket *socket, Indication *indication)
{
EV << "Error Arrived" << endl;
}
void myApp::socketClosed(UdpSocket *socket)
{
EV << "Close socket" << endl;
}
Я не знаю, как это сделать, мне нужно найти соседейа затем отправить разные пакеты каждому из них.