我正在尝试修改UdpBasicApp中包含的模块INET Framework。我要做的是显示数据包的内容。我尝试使用EV
,EV_DEBUG
,EV_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++;
}