25 #include <ns3/core-module.h>
26 #include <ns3/network-module.h>
27 #include <ns3/spectrum-model-ism2400MHz-res1MHz.h>
28 #include <ns3/spectrum-model-300kHz-300GHz-log.h>
29 #include <ns3/wifi-spectrum-value-helper.h>
30 #include <ns3/multi-model-spectrum-channel.h>
31 #include <ns3/waveform-generator.h>
32 #include <ns3/spectrum-analyzer.h>
35 #include <ns3/friis-spectrum-propagation-loss.h>
36 #include <ns3/propagation-delay-model.h>
37 #include <ns3/mobility-module.h>
38 #include <ns3/spectrum-helper.h>
39 #include <ns3/applications-module.h>
40 #include <ns3/adhoc-aloha-noack-ideal-phy-helper.h>
41 #include <ns3/waveform-generator-helper.h>
42 #include <ns3/spectrum-analyzer-helper.h>
43 #include <ns3/non-communicating-net-device.h>
44 #include <ns3/microwave-oven-spectrum-value-helper.h>
58 std::cout << context <<
" PHY TX START p: " << p << std::endl;
68 std::cout << context <<
" PHY TX END p: " << p << std::endl;
77 std::cout << context <<
" PHY RX START p:" << p << std::endl;
86 std::cout << context <<
" PHY RX END OK p:" << p << std::endl;
95 std::cout << context <<
" PHY RX END ERROR p:" << p << std::endl;
105 while ((packet = socket->
Recv ()))
111 std::cout <<
"SOCKET received " << bytes <<
" bytes" << std::endl;
125 int main (
int argc,
char** argv)
129 cmd.
Parse (argc, argv);
137 waveformGeneratorNodes.
Create (1);
138 spectrumAnalyzerNodes.
Create (1);
139 allNodes.
Add (ofdmNodes);
140 allNodes.
Add (waveformGeneratorNodes);
141 allNodes.
Add (spectrumAnalyzerNodes);
145 nodePositionList->
Add (
Vector (5.0, 0.0, 0.0));
146 nodePositionList->
Add (
Vector (0.0, 0.0, 0.0));
147 nodePositionList->
Add (
Vector (30.0, 0.0, 0.0));
148 nodePositionList->
Add (
Vector (0.0, 0.0, 0.0));
156 channelHelper.
SetChannel (
"ns3::MultiModelSpectrumChannel");
166 double txPower = 0.1;
167 uint32_t channelNumber = 4;
172 const double k = 1.381e-23;
173 const double T = 290;
174 double noisePsdValue = k * T;
186 packetSocket.
Install (ofdmNodes);
239 spectrumAnalyzerHelper.
EnableAsciiAll (
"spectrum-analyzer-output");
holds a vector of ns3::Application pointers.
void SetTxPowerSpectralDensity(Ptr< SpectrumValue > txPsd)
hold variables of type string
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr stored in this container at a given index.
NetDeviceContainer Install(NodeContainer c) const
create the AlohaNoackNetDevice
static Ptr< SpectrumValue > CreatePowerSpectralDensityMwo1()
void SetPhyAttribute(std::string name, const AttributeValue &v)
an address for a packet socket
Ptr< SpectrumModel > SpectrumModelIsm2400MhzRes1Mhz
static void Run(void)
Run the simulation until one of:
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Ptr< SpectrumChannel > Create(void) const
void ReceivePacket(Ptr< Socket > socket)
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
void PhyRxStartTrace(std::string context, Ptr< const Packet > p)
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
Schedule an event to expire at the relative time "time" is reached.
This class implements a device which does not communicate, in the sense that it does not interact wit...
void Connect(std::string path, const CallbackBase &cb)
A helper to make it easier to instantiate an ns3::OnOffApplication on a set of nodes.
Give ns3::PacketSocket powers to ns3::Node.
void SetSingleDevice(uint32_t device)
Set the address to match only a specified NetDevice.
a polymophic address class
Class for representing data rates.
void PhyTxStartTrace(std::string context, Ptr< const Packet > p)
virtual Ptr< SpectrumValue > CreateTxPowerSpectralDensity(double txPower, uint32_t channel)
void Install(Ptr< Node > node) const
"Layout" a single node according to the current position allocator type.
Attribute for objects of type ns3::Time.
Hold an unsigned integer type.
holds a vector of ns3::NetDevice pointers
void PhyRxEndErrorTrace(std::string context, Ptr< const Packet > p)
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
void SetRecvCallback(Callback< void, Ptr< Socket > >)
Notify application when new data is available to be read.
static Ptr< Socket > CreateSocket(Ptr< Node > node, TypeId tid)
This method wraps the creation of sockets that is performed on a given node by a SocketFactory specif...
void Start(Time start)
Arrange for all of the Applications in this container to Start() at the Time given as a parameter...
Parse command-line arguments.
static void Destroy(void)
Every event scheduled by the Simulator::insertAtDestroy method is invoked.
void SetPhyAttribute(std::string name, const AttributeValue &v)
Ptr< Socket > SetupPacketReceive(Ptr< Node > node)
virtual int Bind(const Address &address)=0
Allocate a local endpoint for this socket.
void SetPhysicalAddress(const Address address)
Set the destination address.
keep track of a set of node pointers.
virtual Ptr< SpectrumValue > CreateConstant(double psd)
virtual Ptr< Packet > Recv(uint32_t maxSize, uint32_t flags)=0
Read data from the socket.
void SetMobilityModel(std::string type, std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue(), std::string n6="", const AttributeValue &v6=EmptyAttributeValue(), std::string n7="", const AttributeValue &v7=EmptyAttributeValue(), std::string n8="", const AttributeValue &v8=EmptyAttributeValue(), std::string n9="", const AttributeValue &v9=EmptyAttributeValue())
void SetChannel(std::string type, std::string n0="", const AttributeValue &v0=EmptyAttributeValue(), std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue(), std::string n6="", const AttributeValue &v6=EmptyAttributeValue(), std::string n7="", const AttributeValue &v7=EmptyAttributeValue())
void Install(Ptr< Node > node) const
Aggregate an instance of a ns3::PacketSocketFactory onto the provided node.
Helper class used to assign positions and mobility models to nodes.
static SpectrumChannelHelper Default()
void Stop(Time stop)
Arrange for all of the Applications in this container to Stop() at the Time given as a parameter...
int main(int argc, char **argv)
void Add(NodeContainer other)
Append the contents of another NodeContainer to the end of this container.
hold objects of type ns3::DataRate
void AddValue(const std::string &name, const std::string &help, T &value)
Add a program argument, assigning to POD.
static void Stop(void)
If an event invokes this method, it will be the last event scheduled by the Simulator::run method bef...
Ptr< Node > Get(uint32_t i) const
Get the Ptr stored in this container at a given index.
void PhyTxEndTrace(std::string context, Ptr< const Packet > p)
Time Seconds(double value)
Construct a Time in the indicated unit.
void SetProtocol(uint16_t protocol)
Set the protocol.
void SetChannel(Ptr< SpectrumChannel > channel)
set the SpectrumChannel that will be used by SpectrumPhy instances created by this helper ...
void SetChannel(Ptr< SpectrumChannel > channel)
set the SpectrumChannel that will be used by SpectrumPhy instances created by this helper ...
void SetRxSpectrumModel(Ptr< SpectrumModel > m)
Set the spectrum model used by the created SpectrumAnalyzer instances to represent incoming signals...
void PhyRxEndOkTrace(std::string context, Ptr< const Packet > p)
void EnableAsciiAll(std::string prefix)
Enable ASCII output.
void Parse(int argc, char *argv[])
Parse the program arguments.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
void SetPositionAllocator(Ptr< PositionAllocator > allocator)
Set the position allocator which will be used to allocate the initial position of every node initiali...
NetDeviceContainer Install(NodeContainer c) const
Hold a floating point type.
Ptr< T > GetObject(void) const
ApplicationContainer Install(NodeContainer c) const
Install an ns3::OnOffApplication on each node of the input container configured with all the attribut...
a unique identifier for an interface.
Implements WifiSpectrumValue for the 2.4 GHz ISM band only, with a 5 MHz spectrum resolution...
void SetAttribute(std::string name, const AttributeValue &value)
Helper function used to set the underlying application attributes.
void SetNoisePowerSpectralDensity(Ptr< SpectrumValue > noisePsd)
static TypeId LookupByName(std::string name)