Problems with WifiChannel

284 views
Skip to first unread message

Ignasi

unread,
Nov 9, 2010, 11:21:39 AM11/9/10
to ns-3-users
Hi all,

I'm new to ns-3 and C++. I've installed ns-3 and read the tutorial.
Now I wanted to start understanding an old program which worked on
ns-3.2 but it fails on ns-3.9. I supose there have been some changes
in wifi channels but i don't know where to look for them. Could you
help me?

this is the code:

//
#include "ns3/core-module.h"
#include "ns3/common-module.h"
#include "ns3/simulator-module.h"
#include "ns3/node-module.h"
#include "ns3/helper-module.h"
#include "ns3/global-routing-module.h"
#include "ns3/wifi-module.h"
#include "ns3/mobility-module.h"
#include "ns3/uinteger.h"
#include "ns3/tcp-socket-factory.h"
#include "ns3/packet-sink.h"
#include <vector>
#include <stdint.h>
#include <sstream>

using namespace ns3;

NS_LOG_COMPONENT_DEFINE ("Escenari1");

int main (int argc, char *argv[ ])
{
uint32_t nCsma = 1; //Nombre d'estacions CSMA
uint32_t nWifi = 1; //Nombre d'estacions WiFi

NodeContainer p2pNodes;
p2pNodes.Create(2);

PointToPointHelper pointToPoint;
pointToPoint.SetDeviceAttribute("DataRate",StringValue("100Mbps"));
pointToPoint.SetChannelAttribute("Delay",StringValue("2ms"));

NetDeviceContainer p2pInterfaces = pointToPoint.Install (p2pNodes);
p2pInterfaces.Get(0) -> SetMtu(1500);
p2pInterfaces.Get(1) -> SetMtu(1500);

NetDeviceContainer p2pDevices;
p2pDevices = pointToPoint.Install (p2pNodes);

NodeContainer csmaNodes;
csmaNodes.Add (p2pNodes.Get (1));
csmaNodes.Create (nCsma);

CsmaHelper csma;
NetDeviceContainer csmaDevices;
csmaDevices = csma.Install (csmaNodes);

NodeContainer wifiStaNodes;
wifiStaNodes.Create (nWifi);

NodeContainer wifiApNode = p2pNodes.Get (0);

Ptr<WifiChannel> channel = CreateObject<WifiChannel> ();

channel->SetPropagationDelayModel
(CreateObject<ConstantSpeedPropagationDelayModel> ());

Ptr<LogDistancePropagationLossModel> log =
CreateObject<LogDistancePropagationLossModel> ();

log->SetReferenceModel(CreateObject<FriisPropagationLossModel> ());

channel->SetPropagationLossModel (log);

WifiHelper wifi;
wifi.SetPhy ("ns3::WifiPhy");
wifi.SetRemoteStationManager ("ns3::ArfWifiManager");

Ssid ssid = Ssid ("ns-3-ssid");
wifi.SetMac ("ns3::NqstaWifiMac", "Ssid",
SsidValue(ssid),"ActiveProbing", BooleanValue (false));

NetDeviceContainer staDevices;
staDevices = wifi.Install (wifiStaNodes, channel);

wifi.SetMac ("ns3::NqapWifiMac",
"Ssid", SsidValue (ssid),
"BeaconGeneration", BooleanValue (true),
"BeaconInterval", TimeValue (Seconds (2.5)));

NetDeviceContainer apDevices;
apDevices = wifi.Install (wifiApNode, channel);

MobilityHelper mobility;
mobility.Install (wifiStaNodes);
mobility.Install (wifiApNode);

InternetStackHelper stack;
stack.Install (csmaNodes);
stack.Install (wifiApNode);
stack.Install (wifiStaNodes);

Ipv4AddressHelper address;
address.SetBase ("192.168.1.0", "255.255.255.0");
Ipv4InterfaceContainer p2pInterfaces;
p2pInterfaces = address.Assign (p2pDevices);
address.SetBase ("192.168.2.0", "255.255.255.0");
Ipv4InterfaceContainer csmaInterfaces;
csmaInterfaces = address.Assign (csmaDevices);
address.SetBase ("192.168.3.0", "255.255.255.0");
address.Assign (staDevices);
address.Assign (apDevices);

PacketSinkHelper sinkHelper
("ns3::TcpSocketFactory",InetSocketAddress ("192.168.3.1",1025));
ApplicationContainer sinkApp = sinkHelper.Install (wifiStaNodes);
sinkApp.Start (Seconds (0.0));
sinkApp.Stop (Seconds (20.0));

Address dest = InetSocketAddress("192.168.3.1",1025);
std::string protocol = "ns3::TcpSocketFactory";
Config::SetDefault
("ns3::TcpSocket::SegmentSize", UintegerValue (1024));

OnOffHelper onoff = OnOffHelper (protocol, dest);
onoff.SetAttribute
("OnTime",RandomVariableValue(ConstantVariable(1)));
onoff.SetAttribute ("DataRate", StringValue("30Mbps"));
onoff.SetAttribute ("PacketSize", UintegerValue(1024));
onoff.SetAttribute ("OffTime",RandomVariableValue
(ConstantVariable(0)));

ApplicationContainer apps = onoff.Install (csmaNodes.Get(1));
apps.Start (Seconds (0.5));
apps.Stop (Seconds (20.0));

GlobalRouteManager::PopulateRoutingTables ();

Simulator::Stop (Seconds (30.0));

WifiHelper::EnablePcap("escenarictcp",wifiStaNodes.Get (nWifi -1)-
>GetId(),0);
CsmaHelper::EnablePcap("escenariwtcp",csmaNodes.Get(nCsma)->GetId(),
0);

Simulator::Run ();
Simulator::Destroy ();
}
//

and this is the output from ./waf -run scratch/escenari1

Waf: Entering directory `/home/ignasi/repos/ns-3-allinone/ns-3.9/
build'
[ 518/1088] cxx: scratch/escenari1.cc -> build/debug/scratch/
escenari1_7.o
../scratch/escenari1.cc: In function ‘int main(int, char**)’:
../scratch/escenari1.cc:57: error: ‘class ns3::WifiChannel’ has no
member named ‘SetPropagationDelayModel’
../scratch/escenari1.cc:62: error: ‘class
ns3::LogDistancePropagationLossModel’ has no member named
‘SetReferenceModel’
../scratch/escenari1.cc:64: error: ‘class ns3::WifiChannel’ has no
member named ‘SetPropagationLossModel’
../scratch/escenari1.cc:67: error: ‘class ns3::WifiHelper’ has no
member named ‘SetPhy’
../scratch/escenari1.cc:71: error: ‘class ns3::WifiHelper’ has no
member named ‘SetMac’
../scratch/escenari1.cc:74: error: no matching function for call to
‘ns3::WifiHelper::Install(ns3::NodeContainer&,
ns3::Ptr<ns3::WifiChannel>&)’
debug/ns3/wifi-helper.h:143: note: candidates are:
ns3::NetDeviceContainer ns3::WifiHelper::Install(const
ns3::WifiPhyHelper&, const ns3::WifiMacHelper&, ns3::NodeContainer)
const
debug/ns3/wifi-helper.h:151: note:
ns3::NetDeviceContainer ns3::WifiHelper::Install(const
ns3::WifiPhyHelper&, const ns3::WifiMacHelper&, ns3::Ptr<ns3::Node>)
const
debug/ns3/wifi-helper.h:159: note:
ns3::NetDeviceContainer ns3::WifiHelper::Install(const
ns3::WifiPhyHelper&, const ns3::WifiMacHelper&, std::string) const
../scratch/escenari1.cc:76: error: ‘class ns3::WifiHelper’ has no
member named ‘SetMac’
../scratch/escenari1.cc:82: error: no matching function for call to
‘ns3::WifiHelper::Install(ns3::NodeContainer&,
ns3::Ptr<ns3::WifiChannel>&)’
debug/ns3/wifi-helper.h:143: note: candidates are:
ns3::NetDeviceContainer ns3::WifiHelper::Install(const
ns3::WifiPhyHelper&, const ns3::WifiMacHelper&, ns3::NodeContainer)
const
debug/ns3/wifi-helper.h:151: note:
ns3::NetDeviceContainer ns3::WifiHelper::Install(const
ns3::WifiPhyHelper&, const ns3::WifiMacHelper&, ns3::Ptr<ns3::Node>)
const
debug/ns3/wifi-helper.h:159: note:
ns3::NetDeviceContainer ns3::WifiHelper::Install(const
ns3::WifiPhyHelper&, const ns3::WifiMacHelper&, std::string) const
../scratch/escenari1.cc:95: error: conflicting declaration
‘ns3::Ipv4InterfaceContainer p2pInterfaces’
../scratch/escenari1.cc:35: error: ‘p2pInterfaces’ has a previous
declaration as ‘ns3::NetDeviceContainer p2pInterfaces’
../scratch/escenari1.cc:96: error: no match for ‘operator=’ in
‘p2pInterfaces = ns3::Ipv4AddressHelper::Assign(const
ns3::NetDeviceContainer&)(((const ns3::NetDeviceContainer&)((const
ns3::NetDeviceContainer*)(& p2pDevices))))’
debug/ns3/net-device-container.h:42: note: candidates are:
ns3::NetDeviceContainer& ns3::NetDeviceContainer::operator=(const
ns3::NetDeviceContainer&)
../scratch/escenari1.cc:124: error: ‘PopulateRoutingTables’ is not a
member of ‘ns3::GlobalRouteManager’
../scratch/escenari1.cc:128: error: ‘EnablePcap’ is not a member of
‘ns3::WifiHelper’
../scratch/escenari1.cc:129: error: cannot call member function ‘void
ns3::PcapHelperForDevice::EnablePcap(std::string, uint32_t, uint32_t,
bool)’ without object
In file included from debug/ns3/names.h:23,
from debug/ns3/core-module.h:32,
from ../scratch/escenari1.cc:4:
debug/ns3/object.h: In function ‘ns3::Ptr<T> ns3::CreateObject() [with
T = ns3::WifiChannel]’:
../scratch/escenari1.cc:55: instantiated from here
debug/ns3/object.h:515: error: cannot allocate an object of abstract
type ‘ns3::WifiChannel’
debug/ns3/wifi-channel.h:43: note: because the following virtual
functions are pure within ‘ns3::WifiChannel’:
debug/ns3/channel.h:64: note: virtual uint32_t
ns3::Channel::GetNDevices() const
debug/ns3/channel.h:71: note: virtual ns3::Ptr<ns3::NetDevice>
ns3::Channel::GetDevice(uint32_t) const
Waf: Leaving directory `/home/ignasi/repos/ns-3-allinone/ns-3.9/build'
Build failed: -> task failed (err #1):
{task: cxx escenari1.cc -> escenari1_7.o}
------------

Could you tell me how to start to solve this errors?

Thank you very much

Ignasi

Quincy

unread,
Nov 10, 2010, 6:14:13 PM11/10/10
to ns-3-users
You really need to first learn C++ and your compiler output. NS3 is
not a good starting point for learning C++ as there are too many NS3-
specific "magic" behind the scenes.

On Nov 10, 3:21 am, Ignasi <nign...@gmail.com> wrote:
> i don't know where to look for them. Could you help me?

The NS3 Manual and the Doxygen documentation should contain required
info regarding the current way of doing things with NS3. You can also
use the example code provided with NS3. NS-3.2 is over 2 years old and
a lot have changed (2878 changesets, each may contain many changes)
since then. You would be better off using the current example programs
as your base.

Quincy

Ataur Rahman

unread,
Nov 10, 2010, 9:25:58 PM11/10/10
to ns-3-...@googlegroups.com
Hello everybody,

Could anybody tell me how many routing protocols are plugged into NS3. Like in NS2 five protocols are there including AODV,DSDV, DSR, TORA ....
it will be highly appreciated. thanks.


--
You received this message because you are subscribed to the Google Groups "ns-3-users" group.
To post to this group, send email to ns-3-...@googlegroups.com.
To unsubscribe from this group, send email to ns-3-users+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/ns-3-users?hl=en.




--
Sincerely yours,

Mohammod Ataur Rahman
University Malaya
Kuala Lumpur, Malaysia

Reply all
Reply to author
Forward
0 new messages