Interferences on LrWpan nodes takes too mutch RAM and time

57 views
Skip to first unread message

tarek...@gmail.com

unread,
Apr 30, 2017, 7:21:49 AM4/30/17
to ns-3-users
hello ns3 users
i'm trying to make an adaptive channel hopping on TSCH network. after implementing my idea to the tsch protocol, i had to make some sort of an interferences on lrWpan nodes. so i used WaveformGenerator, here's the code that i used to create the interferences :

void SingleWifiPacket(NodeContainer ofdmNodes, Ptr<SpectrumChannel> channel)
{
    WifiSpectrumValue5MhzFactory sf;
    double txPower = 0.1; // Watts
    WaveformGeneratorHelper waveformGeneratorHelper;
    Ptr<SpectrumValue> txPsd = sf.CreateTxPowerSpectralDensity (txPower, 6);


    waveformGeneratorHelper.SetTxPowerSpectralDensity (txPsd);
    waveformGeneratorHelper.SetChannel (channel);
    waveformGeneratorHelper.SetPhyAttribute ("Period", TimeValue (Seconds (1)));
    waveformGeneratorHelper.SetPhyAttribute ("DutyCycle", DoubleValue (0.00022637));
    NetDeviceContainer waveformGenerator0 = waveformGeneratorHelper.Install (ofdmNodes.Get(0));

    //Data
    Simulator::Schedule (MicroSeconds(101.5), &WaveformGenerator::Start, waveformGenerator0.Get (0)->GetObject<NonCommunicatingNetDevice> ()->GetPhy ()->GetObject<WaveformGenerator> ());
    Simulator::Schedule (MicroSeconds(101.5+226.37), &WaveformGenerator::Stop, waveformGenerator0.Get (0)->GetObject<NonCommunicatingNetDevice> ()->GetPhy ()->GetObject<WaveformGenerator> ());

    if(Simulator::Now().GetSeconds()< 15.0)
    {
        Simulator::Schedule (MicroSeconds(101.5+226.37), &SingleWifiPacket, ofdmNodes, channel);
    }

}
 
so i call the method SingleWifiPacket at 5 seconds in the simulation and stop after 15 second , the problem is (and I'm not sure if this is a real problem or how it's suppose to be in the first place) the simulation takes a stupid amount of RAM and Time. the last simulation that i ran took 1.2 GiB and about 30 min , here's the parameters of the simulation :
number of nodes : 20 sensors +1 pan coordinator + 1 node for interferences
duration : 60 seconds
duration of interferences : 10 seconds

Any help will be appreciated (and sorry for bad english), thanks.

Tommaso Pecorella

unread,
Apr 30, 2017, 7:47:34 AM4/30/17
to ns-3-users
Hi,

you have one evident mistake (the evidence is your simulation memory going crazy) and one hidden bug.

The hidden bug is that MicroSeconds(101.5+226.37) won't o what you think. MicroSeconds() takes an integer in input, and your double number will be rounded.

The mistake is that you're installing a NEW WaveformGenerator application every time you send a packet. The previous ones are not destroyed tho, and your memory will grow. You must use only one application.

T.

tarek...@gmail.com

unread,
Apr 30, 2017, 9:03:34 AM4/30/17
to ns-3-users
Hi
thank you so much for the fast reply , i tweaked it a bit to this :

void SingleWifiPacket(NodeContainer ofdmNodes, Ptr<SpectrumChannel> channel)
{
    WifiSpectrumValue5MhzFactory sf;
    double txPower = 0.1; // Watts
    WaveformGeneratorHelper waveformGeneratorHelper;
    Ptr<SpectrumValue> txPsd = sf.CreateTxPowerSpectralDensity (txPower, 6);


    waveformGeneratorHelper.SetTxPowerSpectralDensity (txPsd);
    waveformGeneratorHelper.SetChannel (channel);
    waveformGeneratorHelper.SetPhyAttribute ("Period", TimeValue (Seconds (1)));
    waveformGeneratorHelper.SetPhyAttribute ("DutyCycle", DoubleValue (0.00022637));
    NetDeviceContainer waveformGenerator0 = waveformGeneratorHelper.Install (ofdmNodes.Get(0));

    int i = 0;
    while(Simulator::Now().GetSeconds()< 15.0)
    {
    //Data
        Simulator::Schedule (MicroSeconds(i+102), &WaveformGenerator::Start, waveformGenerator0.Get (0)->GetObject<NonCommunicatingNetDevice> ()->GetPhy ()->GetObject<WaveformGenerator> ());
        Simulator::Schedule (MicroSeconds(i+102+226), &WaveformGenerator::Stop, waveformGenerator0.Get (0)->GetObject<NonCommunicatingNetDevice> ()->GetPhy ()->GetObject<WaveformGenerator> ());
        i += 102+226;
    }
}

the simulation now run so much faster than before , but it still consumes so much RAM.

Tommaso Pecorella

unread,
Apr 30, 2017, 9:34:02 AM4/30/17
to ns-3-users
That's better, but you're launching a LOT of events in the future, and this is eating your RAM. You should use two functions.

1) Create the WaveformGenerator application, setup its params and so on (the first part of your function)
2) Launch an iterative function (the second part of your old approach), which will call itself periodically.

You can pass the pointer to the WaveformGenerator application as a parameter.


T.

tarek...@gmail.com

unread,
Apr 30, 2017, 10:45:56 AM4/30/17
to ns-3-users
i assume that you mean something like this :

void MakeInterferences(NetDeviceContainer waveformGenerator0)
{
    //Data
    Simulator::Schedule (MicroSeconds(102), &WaveformGenerator::Start, waveformGenerator0.Get (0)->GetObject<NonCommunicatingNetDevice> ()->GetPhy ()->GetObject<WaveformGenerator> ());
    Simulator::Schedule (MicroSeconds(102+226), &WaveformGenerator::Stop, waveformGenerator0.Get (0)->GetObject<NonCommunicatingNetDevice> ()->GetPhy ()->GetObject<WaveformGenerator> ());

    if(Simulator::Now().GetSeconds()< 10.0)
    {
        Simulator::Schedule (MicroSeconds(102+226+1000), &MakeInterferences, waveformGenerator0);
    }
}

void CreateWaveformGenerator(NodeContainer ofdmNodes, Ptr<SpectrumChannel> channel)

{
    WifiSpectrumValue5MhzFactory sf;
    double txPower = 0.1; // Watts
    WaveformGeneratorHelper waveformGeneratorHelper;
    Ptr<SpectrumValue> txPsd = sf.CreateTxPowerSpectralDensity (txPower, 6);


    waveformGeneratorHelper.SetTxPowerSpectralDensity (txPsd);
    waveformGeneratorHelper.SetChannel (channel);
    waveformGeneratorHelper.SetPhyAttribute ("Period", TimeValue (Seconds (1)));
    waveformGeneratorHelper.SetPhyAttribute ("DutyCycle", DoubleValue (0.00022637));
    NetDeviceContainer waveformGenerator0 = waveformGeneratorHelper.Install (ofdmNodes.Get(0));

    MakeInterferences(waveformGenerator0);
}

I'll turn down the number of events a little bit so the simulation work much smoother.
anyway thank so much for help , i appreciate it a lot.
Cheers D.T.

Tommaso Pecorella

unread,
Apr 30, 2017, 12:21:21 PM4/30/17
to ns-3-users
One last thing...

waveformGenerator0.Get (0)->GetObject<NonCommunicatingNetDevice> ()->GetPhy ()->GetObject<WaveformGenerator> ()
This is a convoluted way to get what you have.

Try checking if
waveformGenerator0.Get (0) == waveformGenerator0.Get (0)->GetObject<NonCommunicatingNetDevice> ()->GetPhy ()->GetObject<WaveformGenerator> ()

answer: it's always true.

Moreover, don't pass the node container to the function (waveformGenerator0), pass the application pointer (waveformGenerator0.Get(0)), it will consume even LESS memory.


T.
Reply all
Reply to author
Forward
0 new messages