tx power in ns3

3,586 views
Skip to first unread message

fatma hrizi

unread,
Apr 11, 2009, 3:21:25 PM4/11/09
to ns-3-users
Hi all,

How can I change the transmission power of ns3 wifi nodes?
I tried to set the txpowermin and txpowermax but I get the same results for
txpowermin = txpowermax =1.
and txpowermin = txpowermax =30.
 

Thanks for your help
Regards.
--
   ***************
     Fatma HRIZI

Mathieu Lacage

unread,
Apr 11, 2009, 3:31:33 PM4/11/09
to ns-3-...@googlegroups.com
I can't reproduce your problem here:

mathieu@mathieu-laptop:~/code/ns-3-dev
$ ./build/debug/src/devices/wifi/wifi-phy-test SizeVsRange
--ns3::YansWifiPhy::TxPowerStart=1 --ns3::YansWifiPhy::TxPowerEnd=1
10 60.3696
50 56.4829
90 54.9282


mathieu@mathieu-laptop:~/code/ns-3-dev
$ ./build/debug/src/devices/wifi/wifi-phy-test SizeVsRange
--ns3::YansWifiPhy::TxPowerStart=10 --ns3::YansWifiPhy::TxPowerEnd=10
10 120.225
50 112.063

fatma hrizi

unread,
Apr 14, 2009, 11:38:20 AM4/14/09
to ns-3-...@googlegroups.com
Thank you mathieu for the answer,

I found out the problem. it works now when I set the transmission power in the scenario.

Actually, I aimed to set this value during the simulation run-time.
So, I added to the WifiNetDevice method some code (in red) in order to set the transmission power when a node send the frame to the network:

bool
WifiNetDevice::Send(Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber)
{
  NS_ASSERT (Mac48Address::IsMatchingType (dest));

  Mac48Address realTo = Mac48Address::ConvertFrom (dest);

          Ptr<WifiPhy> wifiphy = CreateObject<WifiPhy> ();
          wifiphy->SetTxPowerStart(m_txp);
          wifiphy->SetTxPowerEnd(m_txp);


  m_phy = wifiphy;

  LlcSnapHeader llc;
  llc.SetType (protocolNumber);
  packet->AddHeader (llc);

  m_txLogger (packet, realTo);
  m_mac->Enqueue (packet, realTo);
  return true;
}

I added also a new method to WifiNetDevice class:


void
WifiNetDevice::SetTxPower (double txp)
{
  m_txp = txp;
}

This method is used by upper layer to set the tx power.
So, a node which have a packet to send sets, first, its transmission power, then it uses the WifiNetDevice send method to send the frame.
Sould I add other changes to make it works?

Many Thanks
Regards

However, this seems not working.


2009/4/11 Mathieu Lacage <mathieu...@sophia.inria.fr>



--
   ***************
     Fatma HRIZI

fatma hrizi

unread,
Apr 15, 2009, 11:12:20 AM4/15/09
to ns-3-...@googlegroups.com
Thank you,
it works now!!

Regards
Fatma.

2009/4/14 Mathieu Lacage <mathieu...@sophia.inria.fr>
Maybe you should try to add

        wifiphy->SetTxPowerStart(m_txp);
        wifiphy->SetTxPowerEnd(m_txp);

in WifiNetDevice::SetTxPower

>






--
   ***************
     Fatma HRIZI

linda

unread,
Jan 5, 2014, 11:59:52 PM1/5/14
to ns-3-...@googlegroups.com
hi
can you please tell me how to change tx power during simulation? tx power can be set via YansWifiPhyHelper,

 YansWifiPhyHelper wifiPhy =  YansWifiPhyHelper::Default ();
wifiPhy.Set ("TxPowerStart", DoubleValue (a) );
a is a static global value and changes every time as function GenerateTraffic() is called by Simulator::ScheduleWithContext()

here is the main code:

double a=16.1589
static void GenerateTraffic(Ptr<Socket> socket, uint32_t pktSize,
                                                      uint32_t pktCount, Time pktInterval)
{
   a++;
    cout<<a<<endl;
  if (pktCount > 0)
    {
      Ptr<Packet> packet = Create<Packet> (pktSize);
      socket->Send (packet);
      Simulator::Schedule (pktInterval, &GenerateTraffic,
                           socket, pktSize,pktCount-1, pktInterval);
    }
  else
    {
      socket->Close ();
    }
}


Simulator::ScheduleWithContext (source[i]->GetNode ()->GetId (),
                                              Seconds (1), &GenerateTraffic,
                                              source[i], packetSize, numPackets, interPacketInterval);

i have found that "a" changes as GenerateTraffic is called but the tx power keeps the same,namely the initial value of a=16.1589. Can you tell me how to change tx power when sending each packet?


在 2009年4月14日星期二UTC+8下午11时38分20秒,fatma写道:1589

Mathieu Lacage

unread,
Apr 14, 2009, 1:23:32 PM4/14/09
to ns-3-...@googlegroups.com
On Tue, 2009-04-14 at 17:38 +0200, fatma hrizi wrote:

Maybe you should try to add

Annie

unread,
Sep 26, 2016, 11:01:34 PM9/26/16
to ns-3-users
Hi Mathieu,

I am trying to run your file wifi-phy-test.cc. But it doesn’t give me any output or any prints that I put in . Instead it gives me this :
[1962/2374] cxx: src/wifi/examples/wifi-phy-test.cc -> build/src/wifi/examples/wifi-phy-test.cc.1.o

Can you tell me how can I fix this ?

-Annie

pdbarnes

unread,
Sep 27, 2016, 12:07:20 PM9/27/16
to ns-3-users
That's one of many output lines from the build process. Please start with the tutorial to learn how to build then run ns-3 scripts.

Peter

P. S. You're replying to a thread from 2009. Please read the posting guidelines. In this case you should start a new subject thread.

mehrdad manoochehri

unread,
Apr 4, 2017, 1:58:38 PM4/4/17
to ns-3-users, fatma...@gmail.com
Thank you. my question is that how can we disable transmission and receiving part of access point during sleep mode ?
I put access point in sleep mode but i witness to decrease energy of AP. I suppose by disabling these two parts, i will be able to control it.

mehrdad manoochehri

unread,
Apr 5, 2017, 12:58:47 PM4/5/17
to ns-3-users
Thank you. how can we disable Tx power in access point  for a period of time?
Message has been deleted

incha adamou

unread,
Oct 4, 2018, 7:21:33 AM10/4/18
to ns-3-users
Hello
it does not work for me.
got this:

../src/wifi/model/wifi-net-device.cc:316:1: error: ‘WifiPhyNetDevice’ has not been declared
 WifiPhyNetDevice::SetTxPower (double txp)
 ^
../src/wifi/model/wifi-net-device.cc: In function ‘void ns3::SetTxPower(double)’:
../src/wifi/model/wifi-net-device.cc:318:3: error: ‘m_txp’ was not declared in this scope
   m_txp = txp;
   ^
../src/wifi/model/wifi-net-device.cc:319:3: error: ‘wifiphy’ was not declared in this scope
   wifiphy->SetTxPowerStart (m_txp);
   ^
../src/wifi/model/wifi-net-device.cc: In member function ‘virtual bool ns3::WifiNetDevice::Send(ns3::Ptr<ns3::Packet>, const ns3::Address&, uint16_t)’:
../src/wifi/model/wifi-net-device.cc:335:29: error: ‘m_txp’ was not declared in this scope
   wifiphy->SetTxPowerStart (m_txp);
                             ^
In file included from ./ns3/net-device.h:29:0,
                 from ../src/wifi/model/wifi-net-device.h:24,
                 from ../src/wifi/model/wifi-net-device.cc:21:
./ns3/object.h: In instantiation of ‘ns3::Ptr<T> ns3::CreateObject() [with T = ns3::WifiPhy]’:
../src/wifi/model/wifi-net-device.cc:334:49:   required from here
./ns3/object.h:533:37: error: cannot allocate an object of abstract type ‘ns3::WifiPhy’
   return CompleteConstruct (new T ());
                                     ^

Can you help please
Thank you

Raid Boudi

unread,
Jun 29, 2020, 5:30:35 AM6/29/20
to ns-3-users
Hey
I just want to know if your problem is resolved!
Reply all
Reply to author
Forward
0 new messages