riebl / artery

OMNeT++ V2X simulation framework for ETSI ITS-G5
GNU General Public License v2.0
203 stars 129 forks source link

Creating new omnetpp::cObject #248

Closed lukne541 closed 2 years ago

lukne541 commented 2 years ago

Hi,

I'm trying to implement a new type of cObject, basically a copy of CaObject using CaObject, cam.hpp and CaService::sendCam(...) as templates and I get very close to successfully sending it.

However, It fails with this error message:

<!> Error: Unable to extract cPacket out of data indication -- in module (artery::Router) World.node[8].vanetza[0].router (id=650), at t=0.537385232682s, event #5430

And I can not figure out why. This is how I try to send the message:

using namespace vanetza;
btp::DataRequestB request;
request.destination_port = host_cast<uint16_t>(2345);
request.gn.its_aid = aid::MR;
request.gn.transport_type = geonet::TransportType::SHB;
request.gn.maximum_lifetime = geonet::Lifetime { geonet::Lifetime::Base::One_Second, 1 };
request.gn.traffic_class.tc_id(static_cast<unsigned>(dcc::Profile::DP2));
request.gn.communication_profile = geonet::CommunicationProfile::ITS_G5;

artery::NZKPObject obj(std::move(mrNZKP));
emit(scSignalNZKPSent, &obj);

using NZKPByteBuffer = convertible::byte_buffer_impl<asn1::Nzkp>;
std::unique_ptr<geonet::DownPacket> payload { new geonet::DownPacket() };
std::unique_ptr<convertible::byte_buffer> buffer { new NZKPByteBuffer(obj.shared_ptr()) };
payload->layer(OsiLayer::Application) = std::move(buffer);
this->request(request, std::move(payload));

Is there something I've missed when sending a new type of omnetpp:cObject? Does vanetza require me to define it somewhere? Thanks in advance.

riebl commented 2 years ago

Hi @lukne541,

sending your packet seems to work actually because the error message occurs when a receiving station tries to disassemble the received packet in ItsG5Service::indicate. Does your "NZKP" service inherit from ItsG5BaseService?

lukne541 commented 2 years ago

I inherited from ItsG5Service instead of ItsG5BaseService. Changing this solved it.