51 #include "ns3/command-line.h"
52 #include "ns3/config.h"
53 #include "ns3/constant-position-mobility-model.h"
54 #include "ns3/double.h"
55 #include "ns3/interference-helper.h"
57 #include "ns3/nist-error-rate-model.h"
59 #include "ns3/packet.h"
60 #include "ns3/propagation-delay-model.h"
61 #include "ns3/propagation-loss-model.h"
62 #include "ns3/simple-frame-capture-model.h"
63 #include "ns3/simulator.h"
64 #include "ns3/single-model-spectrum-channel.h"
65 #include "ns3/spectrum-wifi-phy.h"
66 #include "ns3/wifi-mac-trailer.h"
67 #include "ns3/wifi-net-device.h"
68 #include "ns3/wifi-psdu.h"
147 m_txA->Send(psdu, txVector);
164 m_txB->Send(psdu, txVector);
170 if (packet->
GetUid() == m_uidA)
174 else if (packet->
GetUid() == m_uidB)
197 txModeA(
"OfdmRate54Mbps"),
198 txModeB(
"OfdmRate54Mbps"),
199 txPowerLevelA(16.0206),
200 txPowerLevelB(16.0206),
210 captureEnabled(false),
224 channel->SetPropagationDelayModel(CreateObject<ConstantSpeedPropagationDelayModel>());
226 channel->AddPropagationLossModel(loss);
237 m_txA = CreateObject<SpectrumWifiPhy>();
245 m_txB = CreateObject<SpectrumWifiPhy>();
305 Simulator::Destroy();
318 main(
int argc,
char* argv[])
321 std::string str_standard =
"WIFI_PHY_STANDARD_80211a";
322 std::string str_preamble =
"WIFI_PREAMBLE_LONG";
326 cmd.AddValue(
"delay",
327 "Delay in microseconds between frame transmission from sender A and frame "
328 "transmission from sender B",
330 cmd.AddValue(
"xA",
"The position of transmitter A (< 0)", input.
xA);
331 cmd.AddValue(
"xB",
"The position of transmitter B (> 0)", input.
xB);
332 cmd.AddValue(
"packetSizeA",
"Packet size in bytes of transmitter A", input.
packetSizeA);
333 cmd.AddValue(
"packetSizeB",
"Packet size in bytes of transmitter B", input.
packetSizeB);
334 cmd.AddValue(
"txPowerA",
"TX power level of transmitter A", input.
txPowerLevelA);
335 cmd.AddValue(
"txPowerB",
"TX power level of transmitter B", input.
txPowerLevelB);
336 cmd.AddValue(
"txModeA",
"Wifi mode used for payload transmission of sender A", input.
txModeA);
337 cmd.AddValue(
"txModeB",
"Wifi mode used for payload transmission of sender B", input.
txModeB);
338 cmd.AddValue(
"channelA",
"The selected channel number of sender A", input.
channelA);
339 cmd.AddValue(
"channelB",
"The selected channel number of sender B", input.
channelB);
340 cmd.AddValue(
"widthA",
"The selected channel width (MHz) of sender A", input.
widthA);
341 cmd.AddValue(
"widthB",
"The selected channel width (MHz) of sender B", input.
widthB);
342 cmd.AddValue(
"standard",
"IEEE 802.11 flavor", str_standard);
343 cmd.AddValue(
"preamble",
"Type of preamble", str_preamble);
344 cmd.AddValue(
"enableCapture",
"Enable/disable physical layer capture", input.
captureEnabled);
345 cmd.AddValue(
"captureMargin",
"Margin used for physical layer capture", input.
captureMargin);
346 cmd.AddValue(
"checkResults",
"Used to check results at the end of the test",
checkResults);
347 cmd.AddValue(
"expectRxASuccessful",
348 "Indicate whether packet A is expected to be successfully received",
350 cmd.AddValue(
"expectRxBSuccessful",
351 "Indicate whether packet B is expected to be successfully received",
353 cmd.Parse(argc, argv);
357 if (input.
xA >= 0 || input.
xB <= 0)
359 std::cout <<
"Value of xA must be smaller than 0 and value of xB must be bigger than 0!"
364 if (str_standard ==
"WIFI_PHY_STANDARD_80211a")
369 else if (str_standard ==
"WIFI_PHY_STANDARD_80211b")
374 else if (str_standard ==
"WIFI_PHY_STANDARD_80211g")
379 else if (str_standard ==
"WIFI_PHY_STANDARD_80211n_2_4GHZ")
384 else if (str_standard ==
"WIFI_PHY_STANDARD_80211n_5GHZ")
389 else if (str_standard ==
"WIFI_PHY_STANDARD_80211ac")
394 else if (str_standard ==
"WIFI_PHY_STANDARD_80211ax_2_4GHZ")
399 else if (str_standard ==
"WIFI_PHY_STANDARD_80211ax_5GHZ")
405 if (str_preamble ==
"WIFI_PREAMBLE_LONG" &&
411 else if (str_preamble ==
"WIFI_PREAMBLE_SHORT" &&
430 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(struct InterferenceExperiment::Input input)
Run function.
Parse command-line arguments.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
void SetPosition(const Vector &position)
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
bool TraceConnectWithoutContext(std::string name, const CallbackBase &cb)
Connect a TraceSource to a Callback without a context.
void Dispose()
Dispose of this Object.
uint64_t GetUid() const
Returns the packet's Uid.
void SetChannel(const Ptr< SpectrumChannel > channel)
Set the SpectrumChannel this SpectrumWifiPhy is to be connected to.
void CreateWifiSpectrumPhyInterface(Ptr< NetDevice > device)
Method to encapsulate the creation of the WifiSpectrumPhyInterface object (used to bind the WifiSpect...
Simulation virtual time values and global simulation resolution.
represent a single transmission mode
void SetPhy(const Ptr< WifiPhy > phy)
virtual void SetInterferenceHelper(const Ptr< InterferenceHelper > helper)
Sets the interference helper.
void SetErrorRateModel(const Ptr< ErrorRateModel > model)
Sets the error rate model.
virtual void ConfigureStandard(WifiStandard standard)
Configure the PHY-level parameters for different Wi-Fi standard.
void SetOperatingChannel(const ChannelTuple &channelTuple)
If the standard for this object has not been set yet, store the given channel settings.
void SetDevice(const Ptr< WifiNetDevice > device)
Sets the device this PHY is associated with.
void SetTxPowerEnd(double end)
Sets the maximum available transmission power level (dBm).
void SetMobility(const Ptr< MobilityModel > mobility)
assign a mobility model to this device
void SetFrameCaptureModel(const Ptr< FrameCaptureModel > frameCaptureModel)
Sets the frame capture model.
std::tuple< uint8_t, uint16_t, int, uint8_t > ChannelTuple
Tuple identifying an operating channel.
void SetTxPowerStart(double start)
Sets the minimum available transmission power level (dBm).
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(uint16_t channelWidth)
Sets the selected channelWidth (in MHz)
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.
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
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.
static const uint16_t WIFI_MAC_FCS_LENGTH
The length in octets of the IEEE 802.11 MAC FCS field.
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...
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.