lr-wpan: State clash between LrWpanPhy (ns3::IEEE_802_15_4_PHY_BUSY_RX) and LrWpanMac (ns3::MAC_SENDING)
My simulation exits with an assertion:
assert failed. cond="m_lrWpanMacState == MAC_IDLE || m_lrWpanMacState == MAC_ACK_PENDING || m_lrWpanMacState == MAC_CSMA", +11263.384148797s 9 file=../src/lr-wpan/model/lr-wpan-mac.cc, line=1022
terminate called without an active exception
After some debugging time I now found out that the Phy is receiving and the Mac is in sending state:
(gdb) bt
#0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1 0x00007ffff35e8535 in __GI_abort () at abort.c:79
#2 0x00007ffff39d3983 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#3 0x00007ffff39d98c6 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#4 0x00007ffff39d9901 in std::terminate() () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#5 0x00007ffff6e27f14 in ns3::LrWpanMac::PdDataIndication (this=0x5555556f2170, psduLength=5, p=..., lqi=216 '\330') at ../src/lr-wpan/model/lr-wpan-mac.cc:1022
#6 0x00007ffff6e5d079 in ns3::MemPtrCallbackImpl<ns3::Ptr<ns3::LrWpanMac>, void (ns3::LrWpanMac::*)(unsigned int, ns3::Ptr<ns3::Packet>, unsigned char), void, unsigned int, ns3::Ptr<ns3::Packet>, unsigned char, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty>::operator() (this=0x5555556f39e0, a1=5, a2=..., a3=216 '\330') at ./ns3/callback.h:646
#7 0x00007ffff6e0ee88 in ns3::Callback<void, unsigned int, ns3::Ptr<ns3::Packet>, unsigned char, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty>::operator() (this=0x5555556f2d00, a1=5, a2=..., a3=216 '\330') at ./ns3/callback.h:1430
#8 0x00007ffff6e013b8 in ns3::LrWpanPhy::EndRx (this=0x5555556f2b20, par=...) at ../src/lr-wpan/model/lr-wpan-phy.cc:488
#9 0x00007ffff6e11924 in ns3::MakeEvent<void (ns3::LrWpanPhy::*)(ns3::Ptr<ns3::SpectrumSignalParameters>), ns3::LrWpanPhy*, ns3::Ptr<ns3::SpectrumSignalParameters> >(void (ns3::LrWpanPhy::*)(ns3::Ptr<ns3::SpectrumSignalParameters>), ns3::LrWpanPhy*, ns3::Ptr<ns3::SpectrumSignalParameters>)::EventMemberImpl1::Notify() (this=0x5555556cd930) at ./ns3/make-event.h:405
#10 0x00007ffff3c1fc14 in ns3::EventImpl::Invoke (this=0x5555556cd930) at ../src/core/model/event-impl.cc:51
#11 0x00007ffff3c249b9 in ns3::DefaultSimulatorImpl::ProcessOneEvent (this=0x55555563e4b0) at ../src/core/model/default-simulator-impl.cc:151
#12 0x00007ffff3c24d76 in ns3::DefaultSimulatorImpl::Run (this=0x55555563e4b0) at ../src/core/model/default-simulator-impl.cc:204
#13 0x00007ffff3c208e5 in ns3::Simulator::Run () at ../src/core/model/simulator.cc:176
#14 0x000055555556c4e3 in main (argc=5, argv=0x7fffffffe1d8) at ../scratch/sixlowpan.cc:398
(gdb) f 5
#5 0x00007ffff6e27f14 in ns3::LrWpanMac::PdDataIndication (this=0x5555556f2170, psduLength=5, p=..., lqi=216 '\330') at ../src/lr-wpan/model/lr-wpan-mac.cc:1022
1022 NS_ASSERT (m_lrWpanMacState == MAC_IDLE || m_lrWpanMacState == MAC_ACK_PENDING || m_lrWpanMacState == MAC_CSMA);
(gdb) p m_lrWpanMacState
$1 = {m_v = ns3::MAC_SENDING, m_cb = {m_callbackList = empty std::__cxx11::list}}
(gdb) f 8
#8 0x00007ffff6e013b8 in ns3::LrWpanPhy::EndRx (this=0x5555556f2b20, par=...) at ../src/lr-wpan/model/lr-wpan-phy.cc:488
488 m_pdDataIndicationCallback (currentPacket->GetSize (), currentPacket, tag.Get ());
(gdb) p m_trxState
$2 = {m_v = ns3::IEEE_802_15_4_PHY_BUSY_RX, m_cb = {m_callbackList = empty std::__cxx11::list}}
As you can see, the states seem to have gone out of sync. I wonder if this is a problem with my changes, or if this can actually happen and additional synchronisation is needed, i.e. the phy Telling the Mac it is in RX state, or the MacLayer implementation that needs to check PHY layer?
In addition, the received Packet
is an ACK.
Edited by Robert Hartung