21 #include <ns3/object.h> 
   22 #include <ns3/spectrum-interference.h> 
   23 #include <ns3/spectrum-error-model.h> 
   26 #include <ns3/simulator.h> 
   27 #include <ns3/packet.h> 
   29 #include <ns3/string.h> 
   32 #include <ns3/spectrum-model-ism2400MHz-res1MHz.h> 
   33 #include <ns3/spectrum-model-300kHz-300GHz-log.h> 
   34 #include <ns3/wifi-spectrum-value-helper.h> 
   35 #include <ns3/single-model-spectrum-channel.h> 
   36 #include <ns3/waveform-generator.h> 
   37 #include <ns3/spectrum-analyzer.h> 
   40 #include <ns3/friis-spectrum-propagation-loss.h> 
   41 #include <ns3/propagation-delay-model.h> 
   42 #include <ns3/spectrum-helper.h> 
   43 #include <ns3/adhoc-aloha-noack-ideal-phy-helper.h> 
   44 #include <ns3/mobility-helper.h> 
   45 #include <ns3/data-rate.h> 
   46 #include <ns3/uinteger.h> 
   47 #include <ns3/packet-socket-helper.h> 
   48 #include <ns3/packet-socket-address.h> 
   49 #include <ns3/packet-socket-client.h> 
   50 #include <ns3/config.h> 
   72                 bool rateIsAchievable,
 
   73                 std::string channelType);
 
   77   virtual void DoRun (
void);
 
   78   static std::string 
Name (std::string channelType, 
double snrLinear, uint64_t phyRate);
 
   89   std::ostringstream oss;
 
   91       << 
" snr = " << snrLinear << 
" (linear), " 
   92       << 
" phyRate = " << phyRate << 
" bps";
 
   99                             bool rateIsAchievable,
 
  100                             std::string channelType)
 
  102     m_snrLinear (snrLinear),
 
  104     m_rateIsAchievable (rateIsAchievable),
 
  105     m_channelType (channelType)
 
  118   double txPowerW = 0.1; 
 
  121   const double k = 1.381e-23; 
 
  122   const double T = 290; 
 
  123   double noisePsdValue = k * T; 
 
  125   double lossDb = 10 * std::log10 (lossLinear);
 
  127   uint32_t pktSize = 50; 
 
  129   uint32_t numPkts = 200; 
 
  133   double testDuration = (numPkts * pktSize * 8.0) / phyRate;
 
  134   NS_LOG_INFO (
"test duration = " << std::fixed << testDuration);
 
  141   positionAlloc->
Add (Vector (0.0, 0.0, 0.0));
 
  142   positionAlloc->
Add (Vector (5.0, 0.0, 0.0));
 
  161   uint32_t channelNumber = 1;
 
  193   Simulator::Stop (
Seconds (testDuration+0.000000001));
 
  195   double throughputBps = (
g_rxBytes * 8.0) / testDuration;
 
  197   std::clog.unsetf(std::ios_base::floatfield);
 
  208   Simulator::Destroy ();
 
  221   : 
TestSuite (
"spectrum-ideal-phy", SYSTEM)
 
  224   NS_LOG_INFO (
"creating SpectrumIdealPhyTestSuite");
 
  226   for (
double snr = 0.01; snr <= 10 ; snr *= 2)
 
  236   for (
double snr = 0.01; snr <= 10 ; snr *= 10)
 
uint32_t AddApplication(Ptr< Application > application)
Associate an Application to this Node. 
 
void SetStopTime(Time stop)
Specify application stop time. 
 
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
 
void SetTxPowerSpectralDensity(Ptr< SpectrumValue > txPsd)
 
SpectrumIdealPhyTestCase(double snrLinear, uint64_t phyRate, bool rateIsAchievable, std::string channelType)
 
SpectrumIdealPhyTestSuite()
 
Ptr< T > GetObject(void) const 
Get a pointer to the requested aggregated Object. 
 
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 
 
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name. 
 
Ptr< SpectrumChannel > Create(void) const 
 
uint32_t GetSize(void) const 
Returns the the size in bytes of the packet (including the zero-filled initial payload). 
 
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO. 
 
Give ns3::PacketSocket powers to ns3::Node. 
 
void SetSingleDevice(uint32_t device)
Set the address to match only a specified NetDevice. 
 
static double g_bandwidth
 
std::string m_channelType
 
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. 
 
static std::string Name(std::string str, uint32_t totalStreamSize, uint32_t sourceWriteSize, uint32_t serverReadSize, uint32_t serverWriteSize, uint32_t sourceReadSize, bool useIpv6)
 
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())
 
void AddTestCase(TestCase *testCase, enum TestDuration duration)
Add an individual child TestCase to this test suite. 
 
AttributeValue implementation for Time. 
 
Hold an unsigned integer type. 
 
#define NS_TEST_ASSERT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report and abort if not. 
 
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())
 
#define NS_TEST_ASSERT_MSG_EQ_TOL(actual, limit, tol, msg)
Test that actual and expected (limit) values are equal to plus or minus some tolerance and report and...
 
void Connect(std::string path, const CallbackBase &cb)
 
static SpectrumIdealPhyTestSuite g_spectrumIdealPhyTestSuite
 
Every class exported by the ns3 library is enclosed in the ns3 namespace. 
 
void SetPhysicalAddress(const Address address)
Set the destination address. 
 
keep track of a set of node pointers. 
 
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())
 
virtual ~SpectrumIdealPhyTestCase()
 
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. 
 
void SetRemote(PacketSocketAddress addr)
set the remote address and protocol to be used 
 
AttributeValue implementation for DataRate. 
 
Ptr< Node > Get(uint32_t i) const 
Get the Ptr stored in this container at a given index. 
 
static std::string Name(std::string channelType, double snrLinear, uint64_t phyRate)
 
Time Seconds(double value)
Construct a Time in the indicated unit. 
 
void SetProtocol(uint16_t protocol)
Set the protocol. 
 
void Add(Vector v)
Add a position to the list of positions. 
 
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)
set the SpectrumChannel that will be used by SpectrumPhy instances created by this helper ...
 
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer. 
 
static uint64_t g_rxBytes
 
virtual void DoRun(void)
Implementation to actually run this TestCase. 
 
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 
 
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful. 
 
Implements WifiSpectrumValue for the 2.4 GHz ISM band only, with a 5 MHz spectrum resolution...
 
void SetStartTime(Time start)
Specify application start time. 
 
void SetNoisePowerSpectralDensity(Ptr< SpectrumValue > noisePsd)