void UDPMasterSvr::processStreamRequest(CMessage *msg)
{
if (pk->getIsInterest()) {
EV_INFO << "It's an interest packet" << pk->getName() << "\n";
}
else {
EV_INFO << "It's a data packet " << pk->getName() << "\n";
}
}
It is cMessage, not CMessage
pk is undefined, and it is possible to receive a packet that it isn’t of type CNNPacket
you should do
CNNPacket *pk = dynamic_cast<CNNPacket *> (msg);
if (pk) {
…..
}
Also, you have an error here
socket.setOutputGate(gate("udpOut"));
socket.bind(localPort);
This lines should be in requestStream() you only need to bind the port one time or if you change the port, if the port number doesn’t change, the bind of the port and the select of the output gate should be in the initialize method.
--
You received this message because you are subscribed to the Google Groups "OMNeT++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to omnetpp+u...@googlegroups.com.
Visit this group at https://groups.google.com/group/omnetpp.
For more options, visit https://groups.google.com/d/optout.
socket.setOutputGate(gate("udpOut"));
socket.bind(localPort);
Check_and_cast does a dynamic_cast and if the result is null it throws an exception
CCNPacket *data = new CCNPacket();
data->setName(cache[i].getName().c_str());
data->setPart(cache[i].getPart());
data->setContent(cache[i].getContent().c_str());
socket.sendTo(data, CCNPk->getSrcAddress(), clientPort);
L3Address srcAddr = L3AddressResolver().resolve(getParentModule()->getFullName());
std::ostringstream str;
str << rand() % 10;
name = "CCNPacket-" + str.str();
CCNPacket *CCNPk = new CCNPacket();
CCNPk->setName(name.c_str());
CCNPk->setPart(1);
CCNPk->setSrcAddress(srcAddr);
**.vod_trace_file="Terse_Simpsons16.dat"
**.traceType="SVC"
UDPDataIndication *ctrl = check_and_cast<UDPDataIndication *>(CCNPk->removeControlInfo());
L3Address srcAddress = ctrl->getSrcAddr();
int srcPort = ctrl->getSrcPort();
delete ctrl;
// send back
socket.sendTo(data, srcAddress, srcPort);
If you are using UDP the sender port is in the controlInfo, if you are working in the network layer, you need to “open” the received packet.