如何修复:check_and_cast():无法将 NULL 指针转换为类型 'IPv4ControlInfo *'

How to fix: check_and_cast(): cannot cast NULL pointer to type 'IPv4ControlInfo *'

这是我在 AODVRouting.cc 中实现的重放方法(已经在 inet 中)。当我启动模拟时,它运行了一会儿,但随后出现此错误:

check_and_cast(): cannot cast NULL pointer to type 'IPv4ControlInfo *'

这是我的方法:

void AODVRouting::Replay (cMessage *msg)
{
        std::cout<<"Mal Host Activity"<<endl;
        EV <<"Mal Host Activity \n";
        this->bubble("Replaying...");
        this->host->setDisplayString("i=misc/node,red");

            cMessage *ReplayMsg = msg->dup();
            std::cout<<"Done Duplicating MSG"<<endl;
            EV<<"Done Duplicating MSG \n";


            //we can add a delay before sending the copy of the message again (10 time units)
            //scheduleAt(simTime() + 1, ReplayMsg);
            send(ReplayMsg, "ipOut");
            //sendDelayed(ReplayMsg, 0.01,"ipOut");

            std::cout<<"Launched Replayed Packet!\n";
            EV<<"Launched Replayed Packet!\n";
            this->bubble("Attack");
}

有任何解决错误的想法吗?

似乎 ipv4address 指向一个空因素 - 数据包在到达我正在尝试的命令之前被销毁。 我通过引用索引而不是使用 IP 找到了修复: getIndex()