How to get the RSSI of APs at STAs?

99 views
Skip to first unread message

wuf...@gmail.com

unread,
Mar 25, 2019, 4:45:59 AM3/25/19
to ns-3-users
Hello,

I am using ns-3.28 to simulate the WiFi environment. I want to get the RSSI of APs in the environment at some STAs like smartphones. I have learned the MonitorSnifferRx, WifiTxVector and GetTxPowerLevel functions. But the output is 0. I don't know the reason. Can you help me? This is my code.

static void phyTrace(std::string context, Ptr<const Packet> packet,uint16_t channelFreqMhz, WifiTxVector wifiTx, MpduInfo mpduInfo, SignalNoiseDbm signalNoise){
  std
::cout<<context<<"phyTrace...packet received with signal Dbm:"<<wifiTx.GetTxPowerLevel()<<std::endl;
}

int
main
(int argc, char *argv[])
{
 
Time::SetResolution (Time::NS);
 
 
bool verbose = true;
  uint32_t nWifi
= 5;

 
NodeContainer wifiStaNodes;
  wifiStaNodes
.Create (nWifi);  //STA
 
NodeContainer wifiApNode;
  wifiApNode
.Create(1);   //AP
   
 
YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();  
 
YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();
  phy
.SetChannel (channel.Create ());
 
 
WifiHelper wifi;
  wifi
.SetRemoteStationManager ("ns3::AarfWifiManager");  //wifihelper
 
 
//mac
 
WifiMacHelper mac;
 
Ssid ssid = Ssid ("ns-3-aqiao");  
  mac
.SetType ("ns3::StaWifiMac",    
               
"Ssid", SsidValue (ssid),  
               
"ActiveProbing", BooleanValue (false));  
 
 
NetDeviceContainer staDevices;
  staDevices
= wifi.Install (phy, mac, wifiStaNodes);
 
  mac
.SetType ("ns3::ApWifiMac",  
               
"Ssid", SsidValue (ssid));  
 
 
NetDeviceContainer apDevices;
  apDevices
= wifi.Install (phy, mac, wifiApNode);  


 
// MobilityHelper
 
MobilityHelper mobility;
 
  mobility
.SetPositionAllocator ("ns3::GridPositionAllocator",
                                 
"MinX", DoubleValue (0.0),// start in x
                                 
"MinY", DoubleValue (0.0),// start in y
                                 
"DeltaX", DoubleValue (5.0),// internal in x
                                 
"DeltaY", DoubleValue (10.0),// internal in y
                                 
"GridWidth", UintegerValue (2),//3 point every row
                                 
"LayoutType", StringValue ("RowFirst"));//row first
   
  mobility
.SetMobilityModel ("ns3::RandomWalk2dMobilityModel",  
                             
"Bounds", RectangleValue (Rectangle (0,10, 0, 30)));  
  mobility
.Install (wifiStaNodes);
   
  mobility
.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
  mobility
.Install (wifiApNode);
 
 
InternetStackHelper stack;
  stack
.Install (wifiApNode);
  stack
.Install (wifiStaNodes);  
 
 
Ipv4AddressHelper address;
 
  address
.SetBase ("10.1.3.0", "255.255.255.0");
 
Ipv4InterfaceContainer wifiInterfaces;
  wifiInterfaces
=address.Assign (staDevices);
  address
.Assign (apDevices);
 
 
//application
 
UdpEchoServerHelper echoServer (9);
 
 
ApplicationContainer serverApps = echoServer.Install (wifiStaNodes.Get (0));
  serverApps
.Start (Seconds (1.0));
  serverApps
.Stop (Seconds (10.0));
 
 
UdpEchoClientHelper echoClient (wifiInterfaces.GetAddress (0), 9);
  echoClient
.SetAttribute ("MaxPackets", UintegerValue (5));
  echoClient
.SetAttribute ("Interval", TimeValue (Seconds (1.0)));
  echoClient
.SetAttribute ("PacketSize", UintegerValue (1024));
 
 
ApplicationContainer clientApps =
    echoClient
.Install (wifiStaNodes.Get (nWifi - 1));


  clientApps
.Start (Seconds (2.0));
  clientApps
.Stop (Seconds (10.0));
 
 
Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
 
 
Simulator::Stop (Seconds (10.0));
 
  phy
.EnablePcap ("wifiwifi", apDevices.Get (0));

 
AnimationInterface anim("1.xml");

 
Config::Connect("/NodeList/0/DeviceList/0/$ns3::WifiNetDevice/Phy/MonitorSnifferRx",MakeCallback(&phyTrace));

 
Simulator::Run ();
 
 
Simulator::Destroy ();
 
return 0;
}


Best regards.

姜忠泰

unread,
Apr 7, 2019, 9:29:17 PM4/7/19
to ns-3-...@googlegroups.com
您好。请问解决了么?我也遇到相同的问题

<wuf...@gmail.com> 于2019年3月25日周一 下午4:46写道:
--
Posting to this group should follow these guidelines https://www.nsnam.org/wiki/Ns-3-users-guidelines-for-posting
---
You received this message because you are subscribed to the Google Groups "ns-3-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ns-3-users+...@googlegroups.com.
To post to this group, send email to ns-3-...@googlegroups.com.
Visit this group at https://groups.google.com/group/ns-3-users.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages