如何显示文本以查看UdpBasicApp中某些变量的内容?

时间:2019-05-06 07:17:00

标签: c++ omnet++ inet

我正在尝试修改UdpBasicApp中包含的模块INET Framework。我要做的是显示数据包的内容。我尝试使用EVEV_DEBUGEV_INFO,但看不到显示的任何内容。这是我正在使用的部分代码:

void UdpBasicApp::sendPacket()
{
    cModule *host = getContainingNode(this);
    int id = host->getId();
    IMobility *mobility = check_and_cast<IMobility *>(host->getSubmodule("mobility"));
    char *position = mobility->getCurrentPosition().str();

    std::ostringstream str;
    char msg[20];

    xed data = generateXedData();
    str << packetName << "-" << numSent << "-" << data.address << "-" << data.random;

    sprintf(msg, "NodeID-%d-NodePosition-%s-RandomNumber-%d", id, position, data.random);
    EV << msg << endl;

    Packet *packet = new Packet(str.str().c_str());

    packet->content = str;

    EV_INFO << str << endl;
    EV_INFO << data.address << "-" << data.random << endl;

    if (dontFragment)
        packet->addTagIfAbsent<FragmentationReq>()->setDontFragment(true);

    const auto& payload = makeShared<ApplicationPacket>();
    payload->setChunkLength(B(par("messageLength")));
    payload->setSequenceNumber(numSent);
    payload->addTag<CreationTimeTag>()->setCreationTime(simTime());
    packet->insertAtBack(payload);

    emit(packetSentSignal, packet);
    socket.sendTo(packet, data.address, destPort);
    numSent++;
}

0 个答案:

没有答案