Re: Propagation Loss - Cannot use static member on model class

75 views
Skip to first unread message
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted

jared...@gmail.com

unread,
Apr 11, 2018, 3:38:03 PM4/11/18
to ns-3-users
Vitor, this seems like a nice addition to the loss model classes.  Probably unimportant but maybe a more appropriate name would be TracePropagationLossModel or something like that.  I'm also not sure why you want a static member, that seems unnecessarily limiting.  Your issue with attribute defaults not being set correctly is prob. a separate issue you'll need to investigate.

Your new class seems to be related to the MatrixPropagationLossModel in that the losses are explicit and are not based on simulated positions (within ns3), but vary with simulation time according to the traces.  You may consider building your TracePropagationLossModel on top of the Matrix...Model, where your code loads the losses from the trace up to the simulation time on each call to CalcRxPower, and then returns the MatrixPropagationLossModel value that was loaded.  The only catch is that you need to properly map the node IDs in your trace file to the node mobility models passed to CalcRxPower.  Good luck, I can imagine this would be a useful feature.

On Wednesday, April 4, 2018 at 3:21:53 AM UTC-7, Vitor Lamela wrote:

Hello everyone! I'm new to ns-3 and I'm currently working on my master thesis, doing some simulations on VANET. After searching for my specific problem with static variables, I could not find anything here related to it.

I'm making a Propagation Loss Model that will read RSSI values from a tracefile, in order to use real measured values in the simulation.


In my current implementation i have a std::map that stores RSSI values with respect to (origin_node,destination_node,simtime).

There are other class members which are necessary, just to check if the model can be used ( in order to limit the usage of the model outside of the data range).

Those are simTime ( which keeps the simulation time to obtain the correspondent RSSI when calcRxPower is called), nodeNum (to check orig and dest values) and duration (to check if simtime is within data boundaries).


Currently have 2 approaches:
- Using non-static variables and defining parameters with Config::Set and Config::SetDefault 
- Using static variables and loading parameters by calling static class methods (doesn't work)

The problem here is that i want to make this map a static member of my propagation model class and load the values from the file into that variable.

I've managed to do it without using static members, by making it load the traceFile on the constructor. Although, i noticed that when the constructor is called the attributes (set on the simulation script with Config::SetDefault before running simulation) are still undefined. If I change all the variables to static and change the loadtracefile method to static as well, removing the .AddAtribute(because it doesn't work with static members). Then i obtain this error:

[2300/2543] Linking build/libns3-dev-propagation-debug.dylib Undefined symbols for architecture x86_64:   "ns3::RealSignalPropagationLossModel::m_duration", referenced from:       ns3::RealSignalPropagationLossModel::LoadTraceFile(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >) in propagation-loss-model.cc.1.o       ns3::RealSignalPropagationLossModel::SetLinkRSSI(int, int, int, double) in propagation-loss-model.cc.1.o       ns3::RealSignalPropagationLossModel::SetParameters(double, int) in propagation-loss-model.cc.1.o       ns3::RealSignalPropagationLossModel::DoCalcRxPower(double, ns3::Ptr<ns3::MobilityModel>, ns3::Ptr<ns3::MobilityModel>) const in propagation-loss-model.cc.1.o   "ns3::RealSignalPropagationLossModel::m_nodeRssi", referenced from:       ns3::RealSignalPropagationLossModel::LoadTraceFile(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >) in propagation-loss-model.cc.1.o       ns3::RealSignalPropagationLossModel::SetLinkRSSI(int, int, int, double) in propagation-loss-model.cc.1.o       ns3::RealSignalPropagationLossModel::DoCalcRxPower(double, ns3::Ptr<ns3::MobilityModel>, ns3::Ptr<ns3::MobilityModel>) const in propagation-loss-model.cc.1.o   "ns3::RealSignalPropagationLossModel::m_traceFile", referenced from:       ns3::RealSignalPropagationLossModel::RealSignalPropagationLossModel() in propagation-loss-model.cc.1.o   "ns3::RealSignalPropagationLossModel::m_nodeNum", referenced from:
The code for both versions of the model is in attachment.
So, my questions are: - What is the issue of using static variables in the class? Is it recommended or not? knowing that in this case i want the model to be exactly the same for each vehicle - Why can't I use .AddAtribute when the members are static in the class? - When I do Config::SetDefault for all the parameters (with the non-static version of the model) first and then do .AddPropagationLoss to the channel, why aren't these members set when the constructor of the class runs? Are the attributes only set before the constructor runs? Hope you can help me with this. Thanks in advance.
Reply all
Reply to author
Forward
0 new messages