Yes, you can. I suppose that you are using a cPacket and you will use bytes, and your parameter is the maximum fragment size.
packet MyPacket {
int destAddr = -1; // destination address
int srcAddr = -1; // source address
int seqNumber = -1;
int fagment = -1; // time to live
int totalFragments = -1;
}
I have included 3 parameters to check the fragmentation and to detect if some packet is lost, the seqNumber helps to detect duplicated
auto len = pkt->getByteLength();
int numFrag = ceil((double)len/(double)fragSize);
if (numFrag > 1) {
for (int i = 0; i < numFrag; i++) {
auto pktAux = pkt->dup();
if (i < numFrag -1)
pktAux -> setByteLength(fragSize);
else
pktAux -> setByteLength(len);
pktAux->setFragment(i);
pktAux->setTotalFragments(numFrag);
len -= fragSize;
send(pktAux, “out” );
}
delete pkt;
}
else {
// no frament
send(pkt, “out” );
}
Enviado desde Correo para Windows 10
--
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.
To view this discussion on the web visit
https://groups.google.com/d/msgid/omnetpp/3e9d4437-f382-4874-bc62-7ba96df46395n%40googlegroups.com.
Sender notified by Mailtrack 06/08/21, 09:33:41 AM |
To view this discussion on the web visit https://groups.google.com/d/msgid/omnetpp/AM6PR0602MB33834284A6FA0F792DFB0E5B8C399%40AM6PR0602MB3383.eurprd06.prod.outlook.com.