Buildings Propagation Loss Model problem

1,059 views
Skip to first unread message

Kamil

unread,
Jun 5, 2014, 9:28:56 PM6/5/14
to ns-3-...@googlegroups.com
hi, 4first sry for my English.
whats done : a simulation of wifi with 3 nodes (1ap) and one of this nodes is moving away from ap
what i'm trying to do: a simulation of wifi with some shadowing/packet loss using HybridPropagationLossModel. Unfortunately i don't know what to add to the code to make it working properly - now it works same like without buildings and hybridpropagation models.
i would really appreciate if any1 reply how to repair this.

code: /// i run it with --visualize option

#include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/applications-module.h"
#include "ns3/mobility-module.h"
#include "ns3/wifi-module.h"
#include <iostream>
#include <ns3/buildings-module.h>
#include <ns3/buildings-helper.h>
#include <ns3/hybrid-buildings-propagation-loss-model.h>
#include <ns3/constant-position-mobility-model.h>

using namespace ns3;

static void
SetPosition (Ptr<Node> node, Vector position)
{
  Ptr<ConstantPositionMobilityModel> mobility = node->GetObject<ConstantPositionMobilityModel> ();
  mobility->SetPosition (position);
}

static Vector
GetPosition (Ptr<Node> node)
{
  Ptr<MobilityModel> mobility = node->GetObject<MobilityModel> ();
  return mobility->GetPosition ();
}

static void
ChangePosition (Ptr<Node> node, double_t _x, double_t _y)
{
 Vector pos = GetPosition (node);
 pos.x += _x;
 
 pos.y += _y;
 SetPosition(node, pos);
}

static void
AdvancePosition (Ptr<Node> node)
{
  Vector pos = GetPosition (node);
  pos.x += 5.0;
  if (pos.x >= 210.0)
    {
      return;
    }
  SetPosition (node, pos);

  Simulator::Schedule (Seconds (1.0), &AdvancePosition, node);
}

int main (int argc, char *argv[])
{
  CommandLine cmd;
 
  cmd.Parse (argc, argv);
 
  Ptr<Building> b = CreateObject<Building> ();
  b->SetBoundaries (Box (0.0, 10.0, 0.0, 20.0, 0.0, 10.0));
  b->SetBuildingType (Building::Residential);
  b->SetExtWallsType (Building::ConcreteWithWindows);
  b->SetNFloors(3);
  b->SetNRoomsX(3);
  b->SetNRoomsY(2);
 
  Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue ("0"));
 
  Config::SetDefault ("ns3::WifiRemoteStationManager::FragmentationThreshold", StringValue ("2200"));

  WifiHelper wifi = WifiHelper::Default ();
  MobilityHelper mobility;
  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
 
  NodeContainer stas;
  NodeContainer ap;
 
  NetDeviceContainer staDevs;
  PacketSocketHelper packetSocket;

  stas.Create (2);
  ap.Create (1);
 
  mobility.Install (stas);
  mobility.Install (ap);
 
  SetPosition(ap.Get(0), Vector (1.0, 1.0, 1.5));
  SetPosition(stas.Get(0), Vector (1.0, 1.0, 1.5));
  SetPosition(stas.Get(1), Vector (1.0, 1.0, 1.5));
 
  packetSocket.Install (stas);
  packetSocket.Install (ap);
 
 
  NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default ();
  YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
  YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default ();

  wifiPhy.SetChannel (wifiChannel.Create ());
  Ssid ssid = Ssid ("wifi");
  wifi.SetRemoteStationManager ("ns3::ArfWifiManager");
 
  wifiMac.SetType ("ns3::StaWifiMac",
                   "Ssid", SsidValue (ssid),
                   "ActiveProbing", BooleanValue (false));
  staDevs = wifi.Install (wifiPhy, wifiMac, stas);
 
  wifiMac.SetType ("ns3::ApWifiMac",
                   "Ssid", SsidValue (ssid));
  wifi.Install (wifiPhy, wifiMac, ap);

  ChangePosition(stas.Get(1), 5.0, 5.0);
  ChangePosition(stas.Get(0), 5.0, 0.0);
  BuildingsHelper::Install (stas);
  BuildingsHelper::Install (ap);
 
   
  Ptr<HybridBuildingsPropagationLossModel> propagationLossModel = CreateObject<HybridBuildingsPropagationLossModel> ();
  
  Simulator::Schedule (Seconds (1.0), &AdvancePosition, stas.Get (0));

  PacketSocketAddress socket;
  socket.SetSingleDevice (staDevs.Get (0)->GetIfIndex ());
  socket.SetPhysicalAddress (staDevs.Get (1)->GetAddress ());
  socket.SetProtocol (1);

  OnOffHelper onoff ("ns3::PacketSocketFactory", Address (socket));
  onoff.SetConstantRate (DataRate ("1Mbps"));
   BuildingsHelper::MakeMobilityModelConsistent();
  ApplicationContainer apps = onoff.Install (stas.Get (0));
  apps.Start (Seconds (0.5));
  apps.Stop (Seconds (30.0));

  Simulator::Stop (Seconds (31.0));

  Simulator::Run ();

  Simulator::Destroy ();

  return 0;
}


Konstantinos

unread,
Jun 6, 2014, 7:04:23 AM6/6/14
to ns-3-...@googlegroups.com
Hi,

Please do not post your code as is in your question, that's what attachments are for. 
I would recommend to read the documentation and particularly look at examples of wireless on how they configure the PHY to add a propagation loss model. Currently you use a default configuration and you create a HybridProagation model without using it anywhere. See highlighted code in your post on where/what should be changed.

For example in /examples/wireless/wifi-simple-adhoc-grid.cc the configuration of propagation loss model is as follows:

166  YansWifiChannelHelper wifiChannel;
167  wifiChannel.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel");
168  wifiChannel.AddPropagationLoss ("ns3::FriisPropagationLossModel");
169  wifiPhy.SetChannel (wifiChannel.Create ());

Kamil

unread,
Jun 6, 2014, 9:05:04 AM6/6/14
to ns-3-...@googlegroups.com
sry about pasting my code like that and yes, i studied that examples and documentation but i can't find how to use hybrid propagation model with wifi. That's why i asked where and what i need to add

Shahwaiz

unread,
Jun 12, 2014, 12:37:17 PM6/12/14
to ns-3-...@googlegroups.com
Hi,

Have you solved your problem? If not then as Konstantinos mentioned, you need to add HybridPropagationLossModel to the channel profile. Furthermore, do not use YansWifiChannelHelper as by default LogDistancePropagationLossModel is used in YansWifiHelper.

Regards,
Shahwaiz

Kamil

unread,
Jun 12, 2014, 2:26:50 PM6/12/14
to ns-3-...@googlegroups.com
hi, yea thx for replies, i solved it.
I tried to use ohbuildingpropagationlossmodel and everything works now. There were some problems with yans and hybridmodel (no difference with or without hybrid channel profile)

sumon Debnath

unread,
Jan 15, 2017, 10:31:42 AM1/15/17
to ns-3-users

Dear Kamil
I want to model wall effect in throughput performance in 802.11n. Can you pleas share your code to me.

Best Regards
sumon
Reply all
Reply to author
Forward
0 new messages