A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
spectrum-helper.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2010 CTTC
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Nicola Baldo <nbaldo@cttc.es>
7 */
8#include "spectrum-helper.h"
9
10#include <ns3/config.h>
11#include <ns3/half-duplex-ideal-phy.h>
12#include <ns3/multi-model-spectrum-channel.h>
13#include <ns3/names.h>
14#include <ns3/simulator.h>
15#include <ns3/single-model-spectrum-channel.h>
16#include <ns3/spectrum-channel.h>
17#include <ns3/spectrum-phy.h>
18
19namespace ns3
20{
21
22SpectrumChannelHelper
24{
26 h.SetChannel("ns3::SingleModelSpectrumChannel");
27 h.SetPropagationDelay("ns3::ConstantSpeedPropagationDelayModel");
28 h.AddSpectrumPropagationLoss("ns3::FriisSpectrumPropagationLossModel");
29 return h;
30}
31
32void
38
39void
45
48{
49 Ptr<SpectrumChannel> channel = (m_channel.Create())->GetObject<SpectrumChannel>();
50 channel->AddSpectrumPropagationLossModel(m_spectrumPropagationLossModel);
51 channel->AddPropagationLossModel(m_propagationLossModel);
53 channel->SetPropagationDelayModel(delay);
54 return channel;
55}
56
57void
62
63void
64SpectrumPhyHelper::SetChannel(std::string channelName)
65{
67 m_channel = channel;
68}
69
70void
72{
73 m_phy.Set(name, v);
74}
75
78{
80 Ptr<SpectrumPhy> phy = (m_phy.Create())->GetObject<SpectrumPhy>();
81 phy->SetChannel(m_channel);
82 phy->SetMobility(node->GetObject<MobilityModel>());
83 phy->SetDevice(device);
84 return phy;
85}
86
87} // namespace ns3
Hold a value for an Attribute.
Definition attribute.h:59
Keep track of the current position and velocity of an object.
static Ptr< T > Find(std::string path)
Given a name path string, look to see if there's an object in the system with that associated to it.
Definition names.h:443
Ptr< Object > Create() const
Create an Object instance of the configured TypeId.
void Set(const std::string &name, const AttributeValue &value, Args &&... args)
Set an attribute to be set during construction.
calculate a propagation delay.
Smart pointer class similar to boost::intrusive_ptr.
Setup a SpectrumChannel.
ObjectFactory m_propagationDelay
Propagation delay.
ObjectFactory m_channel
Channel.
Ptr< SpectrumChannel > Create() const
void AddPropagationLoss(std::string name, Ts &&... args)
static SpectrumChannelHelper Default()
Setup a default SpectrumChannel.
void AddSpectrumPropagationLoss(std::string name, Ts &&... args)
void SetPropagationDelay(std::string name, Ts &&... args)
void SetChannel(std::string type, Ts &&... args)
Ptr< SpectrumPropagationLossModel > m_spectrumPropagationLossModel
Spectrum propagation loss model.
Ptr< PropagationLossModel > m_propagationLossModel
Propagation loss model.
void SetChannel(Ptr< SpectrumChannel > channel)
set the channel that will be used by SpectrumPhy instances created by this helper
Ptr< SpectrumChannel > m_channel
Channel.
ObjectFactory m_phy
Object factory for the phy objects.
void SetPhyAttribute(std::string name, const AttributeValue &v)
Ptr< SpectrumPhy > Create(Ptr< Node > node, Ptr< NetDevice > device) const
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition assert.h:55
Every class exported by the ns3 library is enclosed in the ns3 namespace.