9#include <ns3/adhoc-aloha-noack-ideal-phy-helper.h>
10#include <ns3/applications-module.h>
11#include <ns3/core-module.h>
12#include <ns3/friis-spectrum-propagation-loss.h>
13#include <ns3/ism-spectrum-value-helper.h>
15#include <ns3/mobility-module.h>
16#include <ns3/network-module.h>
17#include <ns3/propagation-delay-model.h>
18#include <ns3/single-model-spectrum-channel.h>
19#include <ns3/spectrum-analyzer.h>
20#include <ns3/spectrum-helper.h>
21#include <ns3/spectrum-model-300kHz-300GHz-log.h>
22#include <ns3/spectrum-model-ism2400MHz-res1MHz.h>
23#include <ns3/waveform-generator.h>
46 std::cout << context <<
" PHY TX START p: " << p << std::endl;
61 std::cout << context <<
" PHY TX END p: " << p << std::endl;
76 std::cout << context <<
" PHY RX START p:" << p << std::endl;
91 std::cout << context <<
" PHY RX END OK p:" << p << std::endl;
106 std::cout << context <<
" PHY RX END ERROR p:" << p << std::endl;
120 while ((packet = socket->Recv()))
122 bytes += packet->GetSize();
126 std::cout <<
"SOCKET received " << bytes <<
" bytes" << std::endl;
147main(
int argc,
char** argv)
150 cmd.AddValue(
"verbose",
"Print trace information if true",
g_verbose);
151 cmd.Parse(argc, argv);
158 positionAlloc->Add(Vector(0.0, 0.0, 0.0));
159 positionAlloc->Add(Vector(5.0, 0.0, 0.0));
160 mobility.SetPositionAllocator(positionAlloc);
161 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
170 double txPower = 0.1;
176 const double k = 1.381e-23;
177 const double T = 290;
178 double noisePsdValue =
k * T;
void PhyTxEndTrace(std::string context, Ptr< const Packet > p)
PHY end TX trace.
Ptr< Socket > SetupPacketReceive(Ptr< Node > node)
Create a socket and prepare it for packet reception.
void PhyRxEndErrorTrace(std::string context, Ptr< const Packet > p)
PHY end error RX trace.
void PhyRxStartTrace(std::string context, Ptr< const Packet > p)
PHY start RX trace.
void ReceivePacket(Ptr< Socket > socket)
Receive callback.
static bool g_verbose
True for verbose output.
void PhyRxEndOkTrace(std::string context, Ptr< const Packet > p)
PHY end OK RX trace.
void PhyTxStartTrace(std::string context, Ptr< const Packet > p)
PHY start TX trace.
a polymophic address class
create the AlohaNoackNetDevice
void SetPhyAttribute(std::string name, const AttributeValue &v)
void SetTxPowerSpectralDensity(Ptr< SpectrumValue > txPsd)
void SetNoisePowerSpectralDensity(Ptr< SpectrumValue > noisePsd)
void SetChannel(Ptr< SpectrumChannel > channel)
set the SpectrumChannel that will be used by SpectrumPhy instances created by this helper
NetDeviceContainer Install(NodeContainer c) const
holds a vector of ns3::Application pointers.
void Start(Time start) const
Start all of the Applications in this container at the start time given as a parameter.
void Stop(Time stop) const
Arrange for all of the Applications in this container to Stop() at the Time given as a parameter.
Parse command-line arguments.
Class for representing data rates.
Helper class used to assign positions and mobility models to nodes.
holds a vector of ns3::NetDevice pointers
keep track of a set of node pointers.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
A helper to make it easier to instantiate an ns3::OnOffApplication on a set of nodes.
an address for a packet socket
void SetProtocol(uint16_t protocol)
Set the protocol.
void SetPhysicalAddress(const Address address)
Set the destination address.
void SetSingleDevice(uint32_t device)
Set the address to match only a specified NetDevice.
Give ns3::PacketSocket powers to ns3::Node.
void Install(Ptr< Node > node) const
Aggregate an instance of a ns3::PacketSocketFactory onto the provided node.
Smart pointer class similar to boost::intrusive_ptr.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
static void Run()
Run the simulation.
static void Stop()
Tell the Simulator the calling event should be the last one executed.
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...
Ptr< SpectrumChannel > Create() const
static SpectrumChannelHelper Default()
Setup a default SpectrumChannel.
Implements Wifi SpectrumValue for the 2.4 GHz ISM band only, with a 5 MHz spectrum resolution.
virtual Ptr< SpectrumValue > CreateConstant(double psd)
Creates a SpectrumValue instance with a constant value for all frequencies.
virtual Ptr< SpectrumValue > CreateTxPowerSpectralDensity(double txPower, uint8_t channel)
Creates a SpectrumValue instance that represents the TX Power Spectral Density of a wifi device corre...
a unique identifier for an interface.
static TypeId LookupByName(std::string name)
Get a TypeId by name.
Hold an unsigned integer type.
void Connect(std::string path, const CallbackBase &cb)
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Time Seconds(double value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Ptr< PacketSink > sink
Pointer to the packet sink application.