How to create new messages of existing types

341 views
Skip to first unread message

Amr Abughazala

unread,
Nov 16, 2016, 12:57:28 PM11/16/16
to omn...@googlegroups.com
I wanted to create a new messages with different name using same type as EthernetIIFrame.

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);
}


123.png

Alfonso Ariza Quintana

unread,
Nov 17, 2016, 3:50:42 AM11/17/16
to omn...@googlegroups.com
The message is created but you need to include it inside the c++ code if you want to use it in the simulation


-----Mensaje original-----
De: omn...@googlegroups.com [mailto:omn...@googlegroups.com] En nombre de Amr Abughazala
Enviado el: miércoles, 16 de noviembre de 2016 18:57
Para: OMNeT++ Users <omn...@googlegroups.com>
Asunto: [Omnetpp-l] How to create new messages of existing

I wanted to create a new messages with different name using EtherFrameII.

I found from omnet++ manual is that by inheriting in .msg and then .h and .cc files are automatically created.

I did extended EtherFrameII but still the new message is not seen in the simulation

--
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.

Amr Abughazala

unread,
Nov 17, 2016, 4:23:13 AM11/17/16
to omn...@googlegroups.com, aari...@hotmail.com
By C++ code you mean the EtherIIFrame_m.cc or you mean the EtherTrafGen.cc for the Etherhost?

in EtherIIFrame_m.h, I can see that the frame is already created
class EthernetIIFrame1 : public ::inet::EthernetIIFrame
{
 
protected:
   
int etherType;
...

as well as in EtherIIFrame_m.cc
Register_Class(EthernetIIFrame1);
...


in EtherFrame.msg I am trying to have a different value for etherType so as to use it in Etherhost TraffGenerator
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;
}

Below is the value called in EtherTrafGen.h
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;

As shown in picture changing this value still doesn't change what I see in switch.
12.png
Message has been deleted

Amr Abughazala

unread,
Nov 18, 2016, 12:21:35 PM11/18/16
to OMNeT++ Users


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());


Amr Abughazala

I did and the frame now is changed still the EtherType is 0

also 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 EthernetIIFrame
    else {
       
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;


Alfonso Ariza Quintana

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.



Amr Abughazala

I dont want to replace I want all of them to be existing and the host choose what to send

I 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 = 2


Then in inet/linklayer/EtherEncap.ned
simple EtherEncap like IEtherEncap
{
    parameters
:
       
int  etherType = default(0); // Select type of message to be sent
       
bool useSNAP = default(false);  // create EtherFrameWithSNAP frames instead of EthernetIIFrame


​Then in inet/linlayer/EtherEncap.h
class 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: 139
by changing the inheritence

from
packet EthernetIIFrame5 extends EtherFrame
to
packet EthernetIIFrame5 extends EthernetIIFrame

again it works but still with the default value.

Alfonso Ariza Quintana

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

Amr Abughazala

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 :)
Reply all
Reply to author
Forward
0 new messages