riebl / artery

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

Getting packet_id or sequence number of ITS packets #270

Closed inesbj closed 5 months ago

inesbj commented 1 year ago

Hello,

I would like to know how can we get the unique packet id or sequence number of an ITS packet (CAM, DEN, CPM) in Artery.

Many thanks ! Ines

inesbj commented 1 year ago

Hello again,

I just added a sequence number which is increased per each sent ITS packet. So the packetId is not unique but the pair <nodeId, sequencenumber> should be unique.

Ines

riebl commented 1 year ago

Hi @inesbj,

I am sorry I had no time to reply earlier to your question. You can access the sequence number included in the GeoBroadcast header from Artery services; however, it is not straightforward as it violates layer isolation.

For example, one can add the following snippet do DenService::indicate:

    vanetza::ChunkPacket* chunk_packet = boost::get<vanetza::ChunkPacket>(packet.get());
    if (chunk_packet) {
        vanetza::geonet::Pdu* pdu = vanetza::geonet::pdu_cast(chunk_packet->layer(vanetza::OsiLayer::Network));
        if (pdu) {
            auto pdu_gbc = dynamic_cast<vanetza::geonet::GbcPdu*>(pdu);
            if (pdu_gbc) {
                const vanetza::geonet::GeoBroadcastHeader& gbc = pdu_gbc->extended();
                EV_INFO << "sequence number: " << vanetza::geonet::SequenceNumber::value_type(gbc.sequence_number);
            }
        }
    }

The used types and functions are declared by

#include <vanetza/geonet/pdu.hpp>
#include <vanetza/geonet/pdu_conversion.hpp>
#include <vanetza/geonet/pdu_variant.hpp>
#include <vanetza/net/osi_layer.hpp>

While my reply might come too late for you, this information might be useful for future reference.