Error about adding tag twice without adding any tag at all

45 views
Skip to first unread message

omidimaru

unread,
Jul 28, 2022, 6:25:39 PM7/28/22
to ns-3-users
Hi,

I'm getting the following error without ever having added a packet tag at all.

assert failed. cond="cur->tid != tag.GetInstanceTypeId ()", msg="Error: cannot add the same kind of tag twice.", +1.000000000s -1 file=../src/network/model/packet-tag-list.cc, line=266
terminate called without an active exception
Command ['/home/ben/ns-allinone-3.35/ns-3.35/build/scratch/project/project'] terminated with signal SIGIOT. Run it under a debugger to get more information (./waf --run <program> --gdb").


This is the code from running it with --gdb

__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
50    ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x00007ffff2e16859 in __GI_abort () at abort.c:79
#2  0x00007ffff3213911 in ?? () from /lib/x86_64-linux-gnu/libstdc++.so.6
#3  0x00007ffff321f38c in ?? () from /lib/x86_64-linux-gnu/libstdc++.so.6
#4  0x00007ffff321f3f7 in std::terminate() ()
   from /lib/x86_64-linux-gnu/libstdc++.so.6
#5  0x00007ffff3bfb5ad in ns3::PacketTagList::Add (this=0x5555558ff7f0, tag=
    ...) at ../src/network/model/packet-tag-list.cc:266
#6  0x00007ffff3be8cb0 in ns3::Packet::AddPacketTag (this=0x5555558ff7b0,
    tag=...) at ../src/network/model/packet.cc:959
#7  0x00007ffff78dda3c in ns3::WaveNetDevice::SendX (this=0x5555558fe4e0,
    packet=..., dest=..., protocol=35036, txInfo=...)
    at ../src/wave/model/wave-net-device.cc:416
#8  0x0000555555582631 in ns3::MakeEvent<bool (ns3::WaveNetDevice::*)(ns3::Ptr<ns3::Packet>, ns3::Address const&, unsigned int, ns3::TxInfo const&), ns3::Ptr<ns3::WaveNetDevice>, ns3::Ptr<ns3::Packet>, ns3::Mac48Address, int, ns3::TxInfo>(bool (ns3::WaveNetDevice::*)(ns3::Ptr<ns3::Packet>, ns3::Address const&, unsigned int, ns3::TxInfo const&), ns3::Ptr<ns3::WaveNetDevice>, ns3::Ptr<ns3::Packet>, ns3::Mac48Address, int, ns3::TxInfo)::EventMemberImpl4::Notify() (
    this=0x5555557b72d0) at ./ns3/make-event.h:504
#9  0x00007ffff37bab51 in ns3::EventImpl::Invoke (this=0x5555557b72d0)
    at ../src/core/model/event-impl.cc:51
#10 0x00007ffff37c0215 in ns3::DefaultSimulatorImpl::ProcessOneEvent (
--Type <RET> for more, q to quit, c to continue without paging--
    555744190) at ../src/core/model/default-simulator-impl.cc:151
#11 0x00007ffff37c0632 in ns3::DefaultSimulatorImpl::Run (this=0x555555744190)
    at ../src/core/model/default-simulator-impl.cc:204
#12 0x00007ffff37bb947 in ns3::Simulator::Run ()
    at ../src/core/model/simulator.cc:176
#13 0x00005555555b4575 in main (argc=1, argv=0x7fffffffe418)
    at ../scratch/project/attempt.cc:449


This is the code from where the DosApp is created:

//DoS packet rate in milliseconds - translates to 50 packet/s
double dosInterval = 20;

//sets up the malicious nodes with their DoS application - spams packets at 20 packets/s
        std::ifstream malFile ("scratch/project/maliciousSerials.txt");
        for(uint16_t i = 0; i < maliciousNum; i++){
            uint32_t malSerial;
            malFile >> malSerial;

            Ptr<WaveNetDevice> device = DynamicCast<WaveNetDevice>(malNodes.Get(i)->GetDevice(0));
            Ptr<DosApp> dosApp = CreateObject<DosApp>(device, malSerial);





            dosApp->SetStartTime(Seconds(0));
            dosApp->SetStopTime(Seconds(simTime - 5));
            malNodes.Get(i)->AddApplication(dosApp);

            Ptr<Packet> malPacket = Create <Packet>(200);
            SignatureHeader malSig = SignatureHeader(uint32_t(554329379), uint32_t(999999), uint16_t(1));
            malPacket->AddHeader(malSig);

            Simulator::ScheduleNow(&WaveNetDevice::SendX, device, malPacket, Mac48Address::GetBroadcast(), 0x88dc, tx);

            //the RSUs need to broadcast in a staggered fashion, otherwise a combative deadzone appears between the two RSUs and effectively
            //reduces their broadcast range
            Simulator::Schedule(Seconds(1), &DosApp::spam, dosApp, malPacket, dosInterval);
        }
        malFile.close();

And finally, the spam function within DosApp itself:

void DosApp::spam(Ptr<Packet> packetSend, double broadcastRate){

        TxInfo tx;
        tx.channelNumber = CCH;
        tx.preamble = WIFI_PREAMBLE_LONG;
        tx.priority = 7; //DoS would probably take place on the highest prority to affect the network more
        tx.txPowerLevel = 7;
        tx.dataRate = WifiMode("OfdmRate6MbpsBW10MHz");

        Simulator::ScheduleNow(&WaveNetDevice::SendX, m_device, packetSend, Mac48Address::GetBroadcast(), 0x88dc, tx);
        Simulator::Schedule(MilliSeconds(broadcastRate), &DosApp::spam, this, packetSend, broadcastRate);
    }



I cannot for the life of me figure out why this is happening, and it's driving me crazy.
Please, if anyone can offer some help or suggestions, I'm all ears.
Thanks.

omidimaru

unread,
Jul 28, 2022, 6:49:54 PM7/28/22
to ns-3-users
Right, I don't know why but for some reason creating the packet within the main program and sending it to the DosApp like I did was the cause.

I fixed it by moving the packet creation into the DosApp::spam function and doing it all there.

I hope this proves useful to anyone else that might have this problem or in the future if people go google searching. Hi future people.

Tom Henderson

unread,
Jul 28, 2022, 6:50:52 PM7/28/22
to ns-3-...@googlegroups.com, omidimaru

> I cannot for the life of me figure out why this is happening, and it's
> driving me crazy.
> Please, if anyone can offer some help or suggestions, I'm all ears.
> Thanks.

My guess is that the DosApp is recycling Packet objects that have
already traversed the WaveNetDevice. Try calling RemoveAllPacketTags()
and RemoveAllByteTags() on any Packet that is reused (i.e., if the code
is reusing a received packet rather than creating a new one via
Create<Packet> ()).
Reply all
Reply to author
Forward
0 new messages