'TDMA implementation using a variable
I am new to OMNeT++. I have implemented simple TDMA. Now i want to make it dynamic with respect to the number of nodes. As i enter it should automatically assign slots to each node. Right now I have to enter slots in .ini file manually. Example is as shown:
Manual Procedure:
**.noHost = 10
**.host[0].slotTime = 0.0
**.host[1].slotTime = 0.1
**.host[2].slotTime = 0.2
**.host[3].slotTime = 0.3
**.host[4].slotTime = 0.4
**.host[5].slotTime = 0.5
**.host[6].slotTime = 0.6
**.host[7].slotTime = 0.7
**.host[8].slotTime = 0.8
**.host[9].slotTime = 0.9
However, now I want to change it w.r.t. noHost. How can I apply loop in .ini file for this. Can anyone help? I will be highly obliged.
Solution 1:[1]
You can use the special value index
to achieve this, for example:
**.host[*].slotTime = index * 0.1
The value of index
is the index of each submodule in the vector. For example, when evaluating the above expression for host[6]
, the value of index
will be 6
. So this will result in the same thing as the manual method you described.
See the corresponding manual section: https://omnetpp.org/doc/omnetpp/manual/#sec:ned-lang:expressions
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |