I found from omnet++ manual is that by inheriting in .msg and then .h and .cc files are automatically created as shown in picture.
I did extended EthernetIIFrame but still the new message is not seen in the simulation
I also did clean and rebuild inet by make
in inet/linklayer/ethernet/EtherFrame.msg
packet EthernetIIFrame extends EtherFrame
{
byteLength = ETHER_MAC_FRAME_BYTES;
int etherType @enum(EtherType);
}
packet EthernetIIFrame1 extends EtherFrame
{
byteLength = ETHER_MAC_FRAME_BYTES;
int etherType @enum(EtherType);
}class EthernetIIFrame1 : public ::inet::EthernetIIFrame
{
protected:
int etherType;
...
Register_Class(EthernetIIFrame1);
...
packet EthernetIIFrame extends EtherFrame
{
byteLength = ETHER_MAC_FRAME_BYTES;
int etherType @enum(EtherType);
}
packet EthernetIIFrame1 extends EthernetIIFrame
{
byteLength = ETHER_MAC_FRAME_BYTES;
int etherType @enum(EtherType);
etherType = 1;
}class INET_API EtherTrafGen : public cSimpleModule, public ILifecycle
{
protected:
enum Kinds { START = 100, NEXT };
long seqNum = 0;
// send parameters
cPar *sendInterval = nullptr;
cPar *numPacketsPerBurst = nullptr;
cPar *packetLength = nullptr;
int etherType = 0; // I changed this value to 1 but still in the simulation I can see what is received at the switch is EtherFrameII only
MACAddress destMACAddress;
NodeStatus *nodeStatus = nullptr;
Alfonso Ariza Quintana
In
void EtherEncap::processPacketFromHigherLayer(cPacket *msg)
Replace
EthernetIIFrame *eth2Frame = new EthernetIIFrame(msg->getName());
For your class
EthernetIIFrame1 *eth2Frame = new EthernetIIFrame1(msg->getName());
I did and the frame now is changed still the EtherType is 0also I am actually going to make 7 messages of these and I want each host to send one of them. So is it possible to have a variable from the omnetpp.ini to this condition replacing EthernetIIFrameelse {
EthernetIIFrame1 *eth2Frame = new EthernetIIFrame1(msg->getName());
eth2Frame->setSrc(controlInfo->getSourceAddress()); // if blank, will be filled in by MAC
eth2Frame->setDest(controlInfo->getDestinationAddress());
if (etherctrl)
eth2Frame->setEtherType(etherctrl->getEtherType());
frame = eth2Frame;
The EthernetIIFrame is created in the files EtherEncap, Ieee80211MgmtAPBase and Ieee8021dRelay, if you want to replace the type EthernetIIFrame for EthernetIIFrame1 you need to modify these files.
I dont want to replace I want all of them to be existing and the host choose what to sendI did this trial
omnetpp.ini**.Host1.app.destAddress = "RCV"
**.Host1.app.packetLength = 64B
**.Host1.app.sendInterval = 10us
**.Host1.encap.etherType = 1
**.Host2.app.destAddress = "RCV"
**.Host2.app.packetLength = 1500B
**.Host2.app.sendInterval = 10us
**.Host2.encap.etherType = 2Then in inet/linklayer/EtherEncap.nedsimple EtherEncap like IEtherEncap
{
parameters:
int etherType = default(0); // Select type of message to be sent
bool useSNAP = default(false); // create EtherFrameWithSNAP frames instead of EthernetIIFrameThen in inet/linlayer/EtherEncap.hclass INET_API EtherEncap : public cSimpleModule
{...
bool useSNAP; // true: generate EtherFrameWithSNAP, false: generate EthernetIIFrame
int etherType; // integer(1..7) that decides which one of 7 EtherIIFrame messages to be sent...
}then in inet/linklayer/EtherEncap.cc (the one you showed me)else if (etherType == 0){
EthernetIIFrame *eth2Frame = new EthernetIIFrame(msg->getName());
eth2Frame->setSrc(controlInfo->getSourceAddress()); // if blank, will be filled in by MAC
eth2Frame->setDest(controlInfo->getDestinationAddress());
if (etherctrl)
eth2Frame->setEtherType(etherctrl->getEtherType());
frame = eth2Frame;
}
else if (etherType == 1){
EthernetIIFrame1 *eth2Frame = new EthernetIIFrame1(msg->getName());
eth2Frame->setSrc(controlInfo->getSourceAddress()); // if blank, will be filled in by MAC
eth2Frame->setDest(controlInfo->getDestinationAddress());
if (etherctrl)
eth2Frame->setEtherType(etherctrl->getEtherType());
frame = eth2Frame;
}
else if (etherType == 2){
EthernetIIFrame2 *eth2Frame = new EthernetIIFrame2(msg->getName());
eth2Frame->setSrc(controlInfo->getSourceAddress()); // if blank, will be filled in by MAC
eth2Frame->setDest(controlInfo->getDestinationAddress());
if (etherctrl)
eth2Frame->setEtherType(etherctrl->getEtherType());
frame = eth2Frame;
}Still both are taking the default value host1 and host2
INFO (EtherTrafGen)Mysimulation.Host1.app: Send packet `pk-12-9' dest=0A-AA-00-00-00-06 length=64B type=0
INFO (EtherTrafGen)Mysimulation.Host2.app: Send packet `pk-15-13' dest=0A-AA-00-00-00-06 length=1500B type=0
What I am missing?I tried to change etherType to different name as I created that variable and it might take zero from etherType that was already existing.I receive an error Simulation terminated with exit code: 139by changing the inheritencefrompacket EthernetIIFrame5 extends EtherFrametopacket EthernetIIFrame5 extends EthernetIIFrameagain it works but still with the default value.
You should check if the Ieee80211Ctrl that is filled by the source is correct, the ethertype is carried out from the source to the mac by this control info, with the debug is easy to check this
solved it, instead of creating new message I just created new field types in enum and I can use it to send different types of frames. I appreciate your time and assistance :)