Dynamically create Module with omnet++ 4

618 views
Skip to first unread message

yshalaby

unread,
Oct 6, 2009, 12:39:32 AM10/6/09
to omnetpp
Hi

I have recently migrated to omnet++4 and I am having a problem with
"dynamically created modules".
My model creates modules dynamically and I get an error: "NED module
type ""src.nodes.Car"" not found."

I don't know how should I specify the path of my module.

Note that my project folder has a subfolder called src which contains
another folder called nodes and inside this later folder I have a ned
file called "Car" which is the type of my created module.

I have also tried "inet.nodes.wireless.WirelessHost" and I get the
same error.

Wish anyone could advice me how should I write my module type.

Thanks.

Regards,
Y Shalaby

Christoph Sommer

unread,
Oct 6, 2009, 4:10:13 AM10/6/09
to yasmin....@gmail.com, omn...@googlegroups.com
yshalaby wrote:
> I have recently migrated to omnet++4 and I am having a problem with
> "dynamically created modules".
> My model creates modules dynamically and I get an error: "NED module
> type ""src.nodes.Car"" not found."
>
> I don't know how should I specify the path of my module.

This will depend on the NED search path you're supplying when running
the simulation and any "package ..."-directives OMNeT++ might encounter
in folders of your search path.

Take, for example this simulation, which instantiates Cars at runtime:

<http://github.com/sommer/inet-sommer/tree/traci/examples/traci/>

The ./run script supplies "-n .:../../src" to OMNeT++, so it NED files
will be searched for in
- /examples/traci/
- /src/
OMNeT++ encounters two package.ned files, namely
- /examples/package.ned
- /src/package.ned
Those files contain
- package inet.examples;
- package inet;

This means that the module in /examples/traci/Car.ned is known to
OMNeT++ as "inet.examples.traci.Car", so this is the module type
supplied in omnetpp.ini. Have a look at the TraCIScenarioManager module
to see the actual instantiation taking place.

Hope this clears things up a bit.


--
Christoph Sommer
Computer Networks and Communication Systems
University of Erlangen-Nuremberg, Germany
Phone: +49 9131 85-27993 / Fax: +49 9131 85-27409
http://www7.informatik.uni-erlangen.de/~sommer/

Yasmin Shalaby

unread,
Oct 6, 2009, 6:53:26 AM10/6/09
to Christoph Sommer, omn...@googlegroups.com
Thanks for your reply.

Actually I am using the IDE to build and run my codes andI don't know where should I check the "NED search path" that is checked by omnet.
I have tried to run "traci" codes as a separate project, but I get an error stating that the Makefile is manually written and cannot be overriden.

The package of my Car.ned file is: package src.nodes; (i.e. that's the first line in the ned file) and in the omnet.ini, I state the module name as follows:
ParamicsTrafficNetwork.factory.moduleType = "src.nodes.Car"

So from my understanding to your email, I guess it should work like that, but actually it doesn't. Can you please explain more what shall I do to get it work?


Best Regards,
--
Yassmin Shalaby
Master's Student
Intelligent Transportation Systems Lab
Civil Engineering Department
University of Toronto

Christoph Sommer

unread,
Oct 6, 2009, 7:12:08 AM10/6/09
to omn...@googlegroups.com
Yasmin Shalaby wrote:
> Actually I am using the IDE to build and run my codes andI don't know where
> should I check the "NED search path" that is checked by omnet.

Could you re-try using the command line? Running "make makefiles all" in
the INET base directory, then starting the simulation using something
along the lines of "run_inet -n path-to-nedfiles1:path-to-nedfiles2 -u
Cmdenv -c configuration1" should work.

> I have tried to run "traci" codes as a separate project, but I get an error
> stating that the Makefile is manually written and cannot be overriden.

Did you try this in a separate copy? If you want to confirm, you can
download and extract
<http://github.com/sommer/inet-sommer/tarball/traci> to get a patched
version of the INET framework. Running "make makefiles all" should work
there, too.

Cheers,

Christoph

Patrick Haeflinger

unread,
Oct 6, 2009, 8:20:35 AM10/6/09
to omn...@googlegroups.com
Hi Yassmin

To get access to the NED search path in the IDE do :
1) select your project
2) right click "Properties"
3) OMNEST -> NED source folders

Patrick

Yasmin Shalaby a écrit :

Yasmin Shalaby

unread,
Oct 6, 2009, 8:31:55 AM10/6/09
to omn...@googlegroups.com
I have that already done. I checked Properties/Omnet++/NED source folders and found that my project is selected which contains all my Ned files
However, I still get this error: <!> Error in module (TrafficSimulator) ParamicsTrafficNetwork.factory (id=3): NED module type ""src.nodes.Car"" not found.

which means that in my factory called Trafficsimulator (creates the cars dynamically), it can't find the module type "src.nodes.Car" so that it can create it.

I still don't know how to solve that. I tried to debug and found that it searches something called fullMapname, but I couldn't get to its contents either.

I appreciate anyone's help about that error.

--
Yassmin Shalaby
Master's Student
Intelligent Transportation Systems Lab
Civil Engineering Department
University of Toronto



Christoph Sommer

unread,
Oct 7, 2009, 3:44:29 AM10/7/09
to omn...@googlegroups.com
Yasmin Shalaby wrote:
> I still get this error: <!> Error in module (TrafficSimulator)
> ParamicsTrafficNetwork.factory (id=3): NED module type ""src.nodes.Car"" not
> found. [...]

> I still don't know how to solve that. I tried to debug and found that it
> searches something called fullMapname, but I couldn't get to its contents
> either.

Ist the class in the .ned editor palette? What's it called there?


If it's there, you can try the following:

If you don't have it already, download the STL helper scripts for gdb:
<http://www.yolinux.com/TUTORIALS/src/dbinit_stl_views-1.03.txt>

...run the simulation either in gdb:
~/src/gdb/gdb/gdb --args opp_run
-l ../../src/inet
-n ../../src:..
-u Cmdenv
-c lndw2009


...or run it in the OMNeT++ GUI debugger. Don't forget to uncheck
"Window > Preferences > Run/Debug > Console > Limit console output"
first though.


Then enter the following commands in the console:

break NEDResourceCache::doneLoadingNedFiles
run (or click the "run/resume" button)
next
source where-you-downloaded/dbinit_stl_views-1.03.txt
pvector getTypeNames()


This should give you a list of all modules known to the simulation when
your simulation runs.


Cheers,

Christoph

Yasmin Shalaby

unread,
Oct 7, 2009, 12:40:53 PM10/7/09
to omn...@googlegroups.com
Thank you for your reply, it helped me get all the modules known to the simulation and actually I found my file there.

However, I knew my problem. I was using: moduleType = (par("moduleType")).str(); to read the moduleType from the parameters instead of using moduleType = (par("moduleType")).stdstringValue(); . The difference is that the first includes the quotes while parsing the name and that's why I used to have the error as can't find ""src.nodes.Car"" with double quotes!
I found the later in the traci codes, so thank you for that as well.

Best Regards,
--
Yassmin Shalaby
Master's Student
Intelligent Transportation Systems Lab
Civil Engineering Department
University of Toronto



Reply all
Reply to author
Forward
0 new messages