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/single-model-spectrum-channel.h>
31 #include <ns3/waveform-generator.h>
32 #include <ns3/spectrum-analyzer.h>
36 #include <ns3/friis-spectrum-propagation-loss.h>
37 #include <ns3/propagation-delay-model.h>
38 #include <ns3/mobility-module.h>
39 #include <ns3/spectrum-helper.h>
40 #include <ns3/applications-module.h>
41 #include <ns3/adhoc-aloha-noack-ideal-phy-helper.h>
56 std::cout << context <<
" PHY RX END OK p:" << p << std::endl;
101 m_pathlossMap[txNodeId][rxNodeId] = lossDb;
107 for (std::map<uint32_t, std::map<uint32_t, double> >::const_iterator txit = m_pathlossMap.begin ();
108 txit != m_pathlossMap.end ();
111 for (std::map<uint32_t, double>::const_iterator rxit = txit->second.begin ();
112 rxit != txit->second.end ();
115 std::cout << txit->first <<
" --> " << rxit->first <<
" : " << rxit->second <<
" dB" << std::endl;
122 int main (
int argc,
char** argv)
126 double txPowerW = 0.1;
127 uint64_t phyRate = 500000;
128 uint32_t pktSize = 1000;
129 double simDuration = 0.5;
130 std::string channelType (
"ns3::SingleModelSpectrumChannel");
132 cmd.
AddValue (
"lossDb",
"link loss in dB", lossDb);
133 cmd.
AddValue (
"txPowerW",
"txPower in Watts", txPowerW);
134 cmd.
AddValue (
"phyRate",
"PHY rate in bps", phyRate);
135 cmd.
AddValue (
"pktSize",
"packet size in bytes", pktSize);
136 cmd.
AddValue (
"simDuration",
"duration of the simulation in seconds", simDuration);
137 cmd.
AddValue (
"channelType",
"which SpectrumChannel implementation to be used", channelType);
138 cmd.
Parse (argc, argv);
160 uint32_t channelNumber = 1;
165 const double k = 1.381e-23;
166 const double T = 290;
167 double noisePsdValue = k * T;
190 apps.
Start (Seconds (0.0));
191 apps.
Stop (Seconds (simDuration));
205 globalPathlossDatabase.
Print ();
207 double throughputBps = (
g_rxBytes * 8.0) / simDuration;
208 std::cout <<
"throughput: " << throughputBps << std::endl;
209 std::cout <<
"throughput: " << std::setw (20) << std::fixed << throughputBps <<
" bps" << std::endl;
210 std::cout <<
"phy rate : " << std::setw (20) << std::fixed << phyRate*1.0 <<
" bps" << std::endl;
211 double rxPowerW = txPowerW / (std::pow (10.0, lossDb/10.0));
212 double capacity = 20e6*log2 (1.0 + (rxPowerW/20.0e6)/noisePsdValue);
213 std::cout <<
"shannon capacity: " << std::setw (20) << std::fixed << capacity <<
" bps" << std::endl;
holds a vector of ns3::Application pointers.
void SetTxPowerSpectralDensity(Ptr< SpectrumValue > txPsd)
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr stored in this container at a given index.
create the AlohaNoackNetDevice
void PhyRxEndOkTrace(std::string context, Ptr< const Packet > p)
void SetPhyAttribute(std::string name, const AttributeValue &v)
an address for a packet socket
Ptr< SpectrumChannel > Create(void) const
uint32_t GetSize(void) const
void Connect(std::string path, const CallbackBase &cb)
virtual Ptr< MobilityModel > GetMobility()=0
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)
a polymophic address class
Class for representing data rates.
Keep track of the current position and velocity of an object.
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.
void AddPropagationLoss(std::string name, 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())
Hold an unsigned integer type.
void UpdatePathloss(std::string context, Ptr< SpectrumPhy > txPhy, Ptr< SpectrumPhy > rxPhy, double lossDb)
holds a vector of ns3::NetDevice pointers
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
void SetPropagationDelay(std::string name, 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 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)
void SetConstantRate(DataRate dataRate, uint32_t packetSize=512)
void SetPhysicalAddress(const Address address)
keep track of a set of node pointers.
int main(int argc, char **argv)
virtual Ptr< SpectrumValue > CreateConstant(double psd)
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
Helper class used to assign positions and mobility models to nodes.
void Stop(Time stop)
Arrange for all of the Applications in this container to Stop() at the Time given as a parameter...
static uint64_t g_rxBytes
hold objects of type ns3::DataRate
void AddValue(const std::string &name, const std::string &help, T &value)
Ptr< Node > Get(uint32_t i) const
Get the Ptr stored in this container at a given index.
void SetProtocol(uint16_t protocol)
void SetLoss(Ptr< MobilityModel > a, Ptr< MobilityModel > b, double loss, bool symmetric=true)
Set loss (in dB, positive) between pair of ns-3 objects (typically, nodes).
void SetChannel(Ptr< SpectrumChannel > channel)
NS_LOG_COMPONENT_DEFINE("TestAdhocOfdmAloha")
void Parse(int argc, char *argv[])
std::map< uint32_t, std::map< uint32_t, double > > m_pathlossMap
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
NetDeviceContainer Install(NodeContainer c) const
Ptr< T > GetObject(void) const
ApplicationContainer Install(NodeContainer c) const
void SetAttribute(std::string name, const AttributeValue &value)
void SetNoisePowerSpectralDensity(Ptr< SpectrumValue > noisePsd)