Dynamic creation of gates and connections

562 views
Skip to first unread message

Vladimir Vesely

unread,
Aug 4, 2014, 7:22:09 AM8/4/14
to omn...@googlegroups.com
Dear OMNeT++ elders!

I have a question regarding dynamic creation of connections between compound modules and simple module. First let me brief you a little bit about my use case.

I am using OMNeT 4.5. I am referring to the attachment picture (omnetppgates.png) describing modules topology. 



A is compound module within which is compound module B. Module B dynamically creates simple module C. There have to be gates between A <--> B <--> C to pass messages which are also dynamically created. After C is created, I am executing C's method that should establish connections between A, B and C. This method: 1) dynamically creates INOUT gates in all three modules (using addGate() method); 2) interconnects them (using gateHalf() method to retrieve pointer for a certain gate followed by connectTo() method )

void C::createBindings() {

    this->addGate("bcCon", cGate::INOUT, false);
    cGate* g1i = this->gateHalf("bcCon", cGate::INPUT);
    cGate* g1o = this->gateHalf("bcCon", cGate::OUTPUT);

    cModule* B = this->getParentModule();
    B->addGate("aCon", cGate::INOUT, false);
    cGate* g2i = B->gateHalf("aCon", cGate::INPUT);
    cGate* g2o = B->gateHalf("aCon", cGate::OUTPUT);

    cModule* C = B->getParentModule();
    C->addGate("aCon", cGate::INOUT, false);
    cGate* g3i = C->gateHalf("aCon", cGate::INPUT);
    cGate* g3o = C->gateHalf("aCon", cGate::OUTPUT);

    /* 
     * ATTEMPT 1
     * g2o->connectTo(g1i) failed because gate g2o is already connected
     */
    //Connecting C <-> B
    g3o->connectTo(g2i);
    g2o->connectTo(g3i);
    //Connecting B <-> A    
    g2o->connectTo(g1i);
    g1o->connectTo(g2i);


    /* 
     * ATTEMPT 2
     * g1o->connectTo(g2i) failed because gate g2i is already connected
     */
    //Connecting C -> B -> A
    g3o->connectTo(g2i);
    g2o->connectTo(g1i);
    //Connecting A -> B -> C
    g1o->connectTo(g2i);
    g2o->connectTo(g3i);
}

My question is simple. How should I correctly create chains of dynamically created connections between simple-compound and compound-compound modules? 

Also I am definitely not sure whether I am using the most effective way how to retrieve and connect INOUT gates. However, from cGate (http://www.omnetpp.org/doc/omnetpp/api/classcGate.html) and cModule (http://www.omnetpp.org/doc/omnetpp/api/classcModule.html) documentation pages I could not find anything better for INOUT gate types.

Thank you very much for any help and kind regards,


Vladimir



omnetppgates.png

Zarrar Yousaf

unread,
Aug 4, 2014, 3:03:31 PM8/4/14
to omn...@googlegroups.com

Hi,

I want to investigate a topic that involves measuring CPU utilization whenever a data application receives, processes and tranmsits data packets.

It is easy to monitor and determine data throughput in Omnet but I am wondering if it is possible to model or abstract a CPU utlization when it is processing data packets.

I am aware that modeling a CPU is a very complex topic as CPU utilization is linked to many processes and threads that are running in the background, but then i am wondering if there is any abstract model that is available in Omnet for the purpose or if someone more experienced in the area can lead me (with hints and/or literature) to some abstract models that I can implement in Omnet to serve my purpose.

Looking forward to ideas/suggestions,

Regards

Zarrar

Sebastian Subik

unread,
Aug 5, 2014, 8:06:18 AM8/5/14
to omn...@googlegroups.com

Hi Zarrar,

 

From my point of view the first question to answer is on which layer do you want to simulate the processing power? Are you talking about “the” CPU or are you more interested in low level hardware (e.g. within the network card, the CPU of a router etc). The last thesis I supervised (http://dx.doi.org/10.5281/zenodo.9907) deals with high precision measurements of network traffic and we found interesting differences between the used hardware, but they were very small compared to all the other parameter (us vs. ms).

I would suggest to try to identify the most time consuming calculations within your model and then to start with a rough estimation (no calculation, medium calculation, long calculation) to see if it has a significant impact on your overall simulation results.

 

Best

Sebastian

--
You received this message because you are subscribed to the Google Groups "omnetpp" group.
To unsubscribe from this group and stop receiving emails from it, send an email to omnetpp+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Vladimir Vesely

unread,
Aug 5, 2014, 9:20:59 AM8/5/14
to omn...@googlegroups.com, sebasti...@tu-dortmund.de
Please move your topic to other thread!

Vladimir Vesely

unread,
Aug 6, 2014, 12:11:00 PM8/6/14
to omn...@googlegroups.com
I have discovered that cModule::gate() and cModule::gateHalf() are returning me only outside part of compound module gate. To create proper connection path I need also inside portions of gate. Is there any method which returns inside gate?

Rudolf Hornig

unread,
Aug 6, 2014, 1:43:48 PM8/6/14
to omn...@googlegroups.com
There are no such thing inner our outer half of a gate. In a compound module the a gate represents both side and this leads to your confusion. If you attach a simple module to it's parent compound module, you actually attach two OUTPUT gates together:

module Parent {
  gates:
      output myParentOut;
  submodules:
      sub : mySubmod;
  connections:
      mySubmod.out --> myParentOut;

}

In short, to chain parent-child modules you have to connect outputs, to outputs and inputs, to input:
    // out chain
    g3o->connectTo(g2o);
    g2o->connectTo(g1o);
    // input chain
    g21->connectTo(g2i);
    g2i->connectTo(g3i);

Rudolf

Vladimir Vesely

unread,
Aug 6, 2014, 4:07:57 PM8/6/14
to omn...@googlegroups.com
Thank you very much! That is exactly solution to my problem...
Reply all
Reply to author
Forward
0 new messages