40#include "ns3/command-line.h" 
   41#include "ns3/config.h" 
   42#include "ns3/constant-position-mobility-model.h" 
   43#include "ns3/double.h" 
   44#include "ns3/interference-helper.h" 
   46#include "ns3/nist-error-rate-model.h" 
   48#include "ns3/packet.h" 
   49#include "ns3/propagation-delay-model.h" 
   50#include "ns3/propagation-loss-model.h" 
   51#include "ns3/simple-frame-capture-model.h" 
   52#include "ns3/simulator.h" 
   53#include "ns3/single-model-spectrum-channel.h" 
   54#include "ns3/spectrum-wifi-phy.h" 
   55#include "ns3/wifi-mac-trailer.h" 
   56#include "ns3/wifi-net-device.h" 
   57#include "ns3/wifi-psdu.h" 
  136    m_txA->Send(psdu, txVector);
 
 
  153    m_txB->Send(psdu, txVector);
 
 
  159    if (packet->GetUid() == 
m_uidA)
 
  163    else if (packet->GetUid() == 
m_uidB)
 
 
  209    double maxRange = std::max(std::abs(input.
xA), input.
xB);
 
  215    channel->AddPropagationLossModel(loss);
 
  218    posTxA->SetPosition(Vector(input.
xA, 0.0, 0.0));
 
  220    posTxB->SetPosition(Vector(input.
xB, 0.0, 0.0));
 
  222    posRx->SetPosition(Vector(0.0, 0.0, 0.0));
 
  227    m_txA->SetDevice(devA);
 
  234    m_txB->SetDevice(devB);
 
  241    rx->SetDevice(devRx);
 
  244    m_txA->SetInterferenceHelper(interferenceTxA);
 
  246    m_txA->SetErrorRateModel(errorTxA);
 
  248    m_txB->SetInterferenceHelper(interferenceTxB);
 
  250    m_txB->SetErrorRateModel(errorTxB);
 
  252    rx->SetInterferenceHelper(interferenceRx);
 
  254    rx->SetErrorRateModel(errorRx);
 
  255    m_txA->AddChannel(channel);
 
  256    m_txB->AddChannel(channel);
 
  257    rx->AddChannel(channel);
 
  258    m_txA->SetMobility(posTxA);
 
  259    m_txB->SetMobility(posTxB);
 
  260    rx->SetMobility(posRx);
 
  265        rx->SetFrameCaptureModel(frameCaptureModel);
 
  270    rx->ConfigureStandard(input.
standard);
 
  273    nodeA->AddDevice(devA);
 
  275    nodeB->AddDevice(devB);
 
  277    nodeRx->AddDevice(devRx);
 
  281    rx->SetOperatingChannel(
 
  284    rx->TraceConnectWithoutContext(
"PhyRxDrop",
 
 
  304main(
int argc, 
char* argv[])
 
  307    std::string str_standard = 
"WIFI_PHY_STANDARD_80211a";
 
  308    std::string str_preamble = 
"WIFI_PREAMBLE_LONG";
 
  311    CommandLine 
cmd(__FILE__);
 
  314        "Delay between frame transmission from sender A and frame transmission from sender B",
 
  316    cmd.AddValue(
"xA", 
"The position of transmitter A (< 0)", input.
xA);
 
  317    cmd.AddValue(
"xB", 
"The position of transmitter B (> 0)", input.
xB);
 
  318    cmd.AddValue(
"packetSizeA", 
"Packet size in bytes of transmitter A", input.
packetSizeA);
 
  319    cmd.AddValue(
"packetSizeB", 
"Packet size in bytes of transmitter B", input.
packetSizeB);
 
  320    cmd.AddValue(
"txPowerA", 
"TX power level of transmitter A", input.
txPowerLevelA);
 
  321    cmd.AddValue(
"txPowerB", 
"TX power level of transmitter B", input.
txPowerLevelB);
 
  322    cmd.AddValue(
"txModeA", 
"Wifi mode used for payload transmission of sender A", input.
txModeA);
 
  323    cmd.AddValue(
"txModeB", 
"Wifi mode used for payload transmission of sender B", input.
txModeB);
 
  324    cmd.AddValue(
"channelA", 
"The selected channel number of sender A", input.
channelA);
 
  325    cmd.AddValue(
"channelB", 
"The selected channel number of sender B", input.
channelB);
 
  326    cmd.AddValue(
"widthA", 
"The selected channel width (MHz) of sender A", input.
widthA);
 
  327    cmd.AddValue(
"widthB", 
"The selected channel width (MHz) of sender B", input.
widthB);
 
  328    cmd.AddValue(
"standard", 
"IEEE 802.11 flavor", str_standard);
 
  329    cmd.AddValue(
"preamble", 
"Type of preamble", str_preamble);
 
  330    cmd.AddValue(
"enableCapture", 
"Enable/disable physical layer capture", input.
captureEnabled);
 
  331    cmd.AddValue(
"captureMargin", 
"Margin used for physical layer capture", input.
captureMargin);
 
  332    cmd.AddValue(
"checkResults", 
"Used to check results at the end of the test", 
checkResults);
 
  333    cmd.AddValue(
"expectRxASuccessful",
 
  334                 "Indicate whether packet A is expected to be successfully received",
 
  336    cmd.AddValue(
"expectRxBSuccessful",
 
  337                 "Indicate whether packet B is expected to be successfully received",
 
  339    cmd.Parse(argc, argv);
 
  343    if (input.
xA >= 0 || input.
xB <= 0)
 
  345        std::cout << 
"Value of xA must be smaller than 0 and value of xB must be bigger than 0!" 
  350    if (str_standard == 
"WIFI_PHY_STANDARD_80211a")
 
  355    else if (str_standard == 
"WIFI_PHY_STANDARD_80211b")
 
  360    else if (str_standard == 
"WIFI_PHY_STANDARD_80211g")
 
  365    else if (str_standard == 
"WIFI_PHY_STANDARD_80211n_2_4GHZ")
 
  370    else if (str_standard == 
"WIFI_PHY_STANDARD_80211n_5GHZ")
 
  375    else if (str_standard == 
"WIFI_PHY_STANDARD_80211ac")
 
  380    else if (str_standard == 
"WIFI_PHY_STANDARD_80211ax_2_4GHZ")
 
  385    else if (str_standard == 
"WIFI_PHY_STANDARD_80211ax_5GHZ")
 
  391    if (str_preamble == 
"WIFI_PREAMBLE_LONG" &&
 
  397    else if (str_preamble == 
"WIFI_PREAMBLE_SHORT" &&
 
  416        std::cout << 
"Preamble does not exist or is not compatible with the selected standard!" 
Ptr< SpectrumWifiPhy > m_txA
transmit A function
bool m_droppedB
flag to indicate whether packet B has been dropped
uint64_t m_uidB
UID to use for packet B.
bool m_droppedA
flag to indicate whether packet A has been dropped
void SendB() const
Send B function.
void PacketDropped(Ptr< const Packet > packet, WifiPhyRxfailureReason reason)
Function triggered when a packet is dropped.
Ptr< SpectrumWifiPhy > m_txB
transmit B function
uint64_t m_uidA
UID to use for packet A.
void SendA() const
Send A function.
void Run(InterferenceExperiment::Input input)
Run function.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Smart pointer class similar to boost::intrusive_ptr.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
static void Run()
Run the simulation.
Simulation virtual time values and global simulation resolution.
represent a single transmission mode
WifiChannelConfig::SegmentWithoutUnits ChannelTuple
kept for backward compatibility, can be deprecated when using strong types
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
void SetTxPowerLevel(uint8_t powerlevel)
Sets the selected transmission power level.
void SetChannelWidth(MHz_u channelWidth)
Sets the selected channelWidth.
void SetMode(WifiMode mode)
Sets the selected payload transmission mode.
void SetPreambleType(WifiPreamble preamble)
Sets the preamble type.
void experiment(std::string queue_disc_type)
void SetDefault(std::string name, const AttributeValue &value)
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
#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.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Time Seconds(double value)
Construct a Time in the indicated unit.
WifiStandard
Identifies the IEEE 802.11 specifications that a Wifi device can be configured to use.
WifiPhyRxfailureReason
Enumeration of the possible reception failure reasons.
WifiPreamble
The type of preamble to be used by an IEEE 802.11 transmission.
WifiPhyBand
Identifies the PHY band.
@ WIFI_PHY_BAND_2_4GHZ
The 2.4 GHz band.
@ WIFI_PHY_BAND_5GHZ
The 5 GHz band.
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...
static constexpr uint16_t WIFI_MAC_FCS_LENGTH
The length in octets of the IEEE 802.11 MAC FCS field.
double MHz_u
MHz weak type.
double dBm_u
dBm weak type
double meter_u
meter weak type
bool expectRxASuccessful
True if Rx from A is expected to be successful.
bool expectRxBSuccessful
True if Rx from B is expected to be successful.
bool checkResults
True if results have to be checked.