Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

How to stop only one wifi node in the network.

95 views
Skip to first unread message

Rui Yang

unread,
Apr 19, 2018, 10:36:28 AM4/19/18
to ns-3-users
Hi group,

I'm working on a wifi scenario with node failure and energy tracking. If I use Simulator::Stop(), the whole application will shut down. If I use a "manual" flag to condition the sending/receiving behavior, the energy consumption keeps going on. So I wonder whether there is a way to simulate a one node failure in wifi scenario.

On the other hand, I'm a little confused about the energy model. I'm currently using flag to label sending/receiving, and node 1 will stop sending at 1500s, node 2~5 keep sending until 3000s. The sending mechanism is gossip. However, they have almost the same energy consumption, so I wonder what's the main factor of energy consumption.

I used the example in https://www.nsnam.org/doxygen/energy-model-example_8cc_source.html. And the only modification is that I change basicSourcePtr to a vector so that I could trace all the nodes. So my energy-related codes are:

/***************************************************************************/
  /* energy source */
  BasicEnergySourceHelper basicSourceHelper;
  // configure energy source
  basicSourceHelper.Set ("BasicEnergySourceInitialEnergyJ", DoubleValue (t_max * 20.0));
  // install source
  EnergySourceContainer sources = basicSourceHelper.Install (nodes);
  /* device energy model */
  WifiRadioEnergyModelHelper radioEnergyHelper;
  // configure radio energy model
  radioEnergyHelper.Set ("TxCurrentA", DoubleValue (0.0174));
  // install device model
  DeviceEnergyModelContainer deviceModels = radioEnergyHelper.Install (devices, sources);
  /***************************************************************************/

  /*** Setup Energy Tracing ****/
  Ptr<BasicEnergySource>* basicSourcePtr = new Ptr<BasicEnergySource>[numNode];

  for (int i = 0; i < numNode; ++i) {
    basicSourcePtr[i] = DynamicCast<BasicEnergySource> (sources.Get(i));
    basicSourcePtr[i]->TraceConnectWithoutContext ("RemainingEnergy", MakeCallback (&RemainingEnergy));
    // device energy model
    Ptr<DeviceEnergyModel> basicRadioModelPtr =
      basicSourcePtr[i]->FindDeviceEnergyModels ("ns3::WifiRadioEnergyModel").Get (0);
    NS_ASSERT (basicRadioModelPtr != NULL);
    basicRadioModelPtr->TraceConnectWithoutContext ("TotalEnergyConsumption", MakeCallback (&TotalEnergy));
  }

  // print remaining energy
  for (DeviceEnergyModelContainer::Iterator iter = deviceModels.Begin (); iter != deviceModels.End (); iter ++) {
    double energyConsumed = (*iter)->GetTotalEnergyConsumption ();
    std::cout << "Total energy consumed by radio = " << energyConsumed << "J \n";
  }

I'll sincerely appreciate it if there is any suggestion

Thanks,
-Rui

Varun Reddy

unread,
Apr 20, 2018, 11:35:59 AM4/20/18
to ns-3-users
Reply all
Reply to author
Forward
0 new messages