Using variables in the ini file

1,068 views
Skip to first unread message

David van Wyk

unread,
Jun 4, 2015, 3:23:52 AM6/4/15
to omn...@googlegroups.com
Good morning all,

I want to add variables to my ini file in order to more easily ensure that all my clients are sending the correct packet sizes. This will also help me determine the final packet that should be sent from an intermediate server to a final destination?

How do you create and then use variables in the ini file? (Note: I have managed to figure out how to use variables that were defined in the NED file, such as making modular networks and determining  how many there will be through variables in the ini file)

Regards
David

Michael Kirsche

unread,
Jun 4, 2015, 9:09:25 AM6/4/15
to omn...@googlegroups.com
Aren't those variables in a NED file again?
Your correct packet size is probably used in a traffic generator / application layer module and thus a parameter of the according NED file.
Probably like the packet size in applications like the PingApp. Those variables are then set again in the ini file, just like you've learned already.
Why use a "variable" to set something that is not reflected in the source code / NED file? If you use it in the source code and want to manipulate it, make it a NED module parameter.

David van Wyk

unread,
Jun 5, 2015, 4:58:59 AM6/5/15
to omn...@googlegroups.com
I should probably clarify "correct" packet size to be "the same packet size". I have clients sending data to a "server" which has 2 tcpApps, one which is a sink and one which is a session. The session app initialises much later into the simulation. This session app then has to send the combined total of all the data that the "server" has received to another server.

I could calculate this by hand, and I could write a C script to calculate and then write the INI file, but that would be as a last resort. 

For example:
**.MSAN_srv.tcpApp[1].sendBytes = 1 MiB
This is what I have at the moment, now if there are 10 clients sending 1 MiB data to that intermediate server, That would need to be changed to 
**.MSAN_srv.tcpApp[1].sendBytes = 10 MiB

I would like to know if there is an easier way of doing this (such as by using variables). Sorry, I am fairly new to OMNeT++ and have only recently started exploring really manipulating the ini files.

L. Jacob Mariscal Fernández

unread,
Jun 5, 2015, 6:36:40 AM6/5/15
to omn...@googlegroups.com
I think easy way is out of the ini file (in ned or c++ files).
But beware if you mix different units, for example:
delay = 2ms + convertUnit(jitter, "ms");
this is a good way to define the delay of a channel regarding the jitter.
So in your example, it could be:
sendBytes = clients * 1 MiB;
  if there is no problem with units.
Cheers

David van Wyk

unread,
Jun 8, 2015, 6:47:23 AM6/8/15
to omn...@googlegroups.com
Fantastic thanks, will give it a look.

will sendBytes be declared in the NED file then? If so where will it be declared (Parameters or within the client submodule)?

David van Wyk

unread,
Jun 8, 2015, 7:31:27 AM6/8/15
to omn...@googlegroups.com
Thanks so much! Seems like I managed to figure it out!

For others reading this, the trick is that the assignment is done basically the same way as in the INI file, except that when using INET, the NED file seems to give un undefined parameter warning. You can double check that you have used the correct parameter by assigned it as a default in the NED.
Reply all
Reply to author
Forward
0 new messages