54 #include "ns3/packet.h" 55 #include "ns3/config.h" 56 #include "ns3/double.h" 57 #include "ns3/simulator.h" 58 #include "ns3/command-line.h" 59 #include "ns3/single-model-spectrum-channel.h" 60 #include "ns3/spectrum-wifi-phy.h" 61 #include "ns3/propagation-loss-model.h" 62 #include "ns3/propagation-delay-model.h" 63 #include "ns3/nist-error-rate-model.h" 64 #include "ns3/constant-position-mobility-model.h" 65 #include "ns3/simple-frame-capture-model.h" 66 #include "ns3/wifi-psdu.h" 67 #include "ns3/wifi-mac-trailer.h" 68 #include "ns3/wifi-net-device.h" 120 void SendA (
void)
const;
122 void SendB (
void)
const;
142 txVector.SetMode (
WifiMode (m_input.txModeA));
143 txVector.SetChannelWidth (m_input.widthA);
144 txVector.SetPreambleType (m_input.preamble);
145 m_txA->Send (psdu, txVector);
158 txVector.SetMode (
WifiMode (m_input.txModeB));
159 txVector.SetChannelWidth (m_input.widthB);
160 txVector.SetPreambleType (m_input.preamble);
161 m_txB->Send (psdu, txVector);
167 if (packet->
GetUid () == m_uidA)
171 else if (packet->
GetUid () == m_uidB)
183 : m_droppedA (false),
194 txModeA (
"OfdmRate54Mbps"),
195 txModeB (
"OfdmRate54Mbps"),
196 txPowerLevelA (16.0206),
197 txPowerLevelB (16.0206),
206 captureEnabled (false),
216 double range =
std::max (std::abs (input.
xA), input.
xB);
220 channel->SetPropagationDelayModel (CreateObject<ConstantSpeedPropagationDelayModel> ());
222 channel->AddPropagationLossModel (loss);
233 m_txA = CreateObject<SpectrumWifiPhy> ();
241 m_txB = CreateObject<SpectrumWifiPhy> ();
247 Ptr<Node> nodeRx = CreateObject<Node> ();
251 rx->SetDevice (devRx);
256 rx->SetErrorRateModel (error);
262 rx->SetMobility (posRx);
267 rx->SetFrameCaptureModel (frameCaptureModel);
272 rx->ConfigureStandard (input.
standard);
274 devA->SetPhy (
m_txA);
276 devB->SetPhy (
m_txB);
291 Simulator::Destroy ();
303 int main (
int argc,
char *argv[])
306 std::string str_standard =
"WIFI_PHY_STANDARD_80211a";
307 std::string str_preamble =
"WIFI_PREAMBLE_LONG";
311 cmd.AddValue (
"delay",
"Delay in microseconds between frame transmission from sender A and frame transmission from sender B", delay);
312 cmd.AddValue (
"xA",
"The position of transmitter A (< 0)", input.
xA);
313 cmd.AddValue (
"xB",
"The position of transmitter B (> 0)", input.
xB);
314 cmd.AddValue (
"packetSizeA",
"Packet size in bytes of transmitter A", input.
packetSizeA);
315 cmd.AddValue (
"packetSizeB",
"Packet size in bytes of transmitter B", input.
packetSizeB);
316 cmd.AddValue (
"txPowerA",
"TX power level of transmitter A", input.
txPowerLevelA);
317 cmd.AddValue (
"txPowerB",
"TX power level of transmitter B", input.
txPowerLevelB);
318 cmd.AddValue (
"txModeA",
"Wifi mode used for payload transmission of sender A", input.
txModeA);
319 cmd.AddValue (
"txModeB",
"Wifi mode used for payload transmission of sender B", input.
txModeB);
320 cmd.AddValue (
"channelA",
"The selected channel number of sender A", input.
channelA);
321 cmd.AddValue (
"channelB",
"The selected channel number of sender B", input.
channelB);
322 cmd.AddValue (
"widthA",
"The selected channel width (MHz) of sender A", input.
widthA);
323 cmd.AddValue (
"widthB",
"The selected channel width (MHz) of sender B", input.
widthB);
324 cmd.AddValue (
"standard",
"IEEE 802.11 flavor", str_standard);
325 cmd.AddValue (
"preamble",
"Type of preamble", str_preamble);
326 cmd.AddValue (
"enableCapture",
"Enable/disable physical layer capture", input.
captureEnabled);
327 cmd.AddValue (
"captureMargin",
"Margin used for physical layer capture", input.
captureMargin);
328 cmd.AddValue (
"checkResults",
"Used to check results at the end of the test",
checkResults);
329 cmd.AddValue (
"expectRxASuccessfull",
"Indicate whether packet A is expected to be successfully received",
expectRxASuccessfull);
330 cmd.AddValue (
"expectRxBSuccessfull",
"Indicate whether packet B is expected to be successfully received",
expectRxBSuccessfull);
331 cmd.Parse (argc, argv);
335 if (input.
xA >= 0 || input.
xB <= 0)
337 std::cout <<
"Value of xA must be smaller than 0 and value of xB must be bigger than 0!" << std::endl;
341 if (str_standard ==
"WIFI_PHY_STANDARD_80211a")
345 else if (str_standard ==
"WIFI_PHY_STANDARD_80211b")
349 else if (str_standard ==
"WIFI_PHY_STANDARD_80211g")
353 else if (str_standard ==
"WIFI_PHY_STANDARD_80211n_2_4GHZ")
357 else if (str_standard ==
"WIFI_PHY_STANDARD_80211n_5GHZ")
361 else if (str_standard ==
"WIFI_PHY_STANDARD_80211ac")
365 else if (str_standard ==
"WIFI_PHY_STANDARD_80211ax_2_4GHZ")
369 else if (str_standard ==
"WIFI_PHY_STANDARD_80211ax_5GHZ")
400 std::cout <<
"Preamble does not exist or is not compatible with the selected standard!" << std::endl;
ERP-OFDM PHY (Clause 19, Section 19.5)
void Dispose(void)
Dispose of this Object.
uint64_t GetUid(void) const
Returns the packet's Uid.
Simulation virtual time values and global simulation resolution.
void SendB(void) const
Send B function.
HT PHY for the 5 GHz band (clause 20)
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
bool expectRxBSuccessfull
bool m_droppedB
flag to indicate whether packet B has been dropped
static const uint16_t WIFI_MAC_FCS_LENGTH
The length in octects of the IEEE 802.11 MAC FCS field.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
HE PHY for the 2.4 GHz band (clause 26)
void SetMobility(const Ptr< MobilityModel > mobility)
assign a mobility model to this device
HT PHY for the 2.4 GHz band (clause 20)
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
virtual void SetChannelNumber(uint8_t id)
Set channel number.
bool m_droppedA
flag to indicate whether packet A has been dropped
void SetDevice(const Ptr< NetDevice > device)
Sets the device this PHY is associated with.
WifiPreamble
The type of preamble to be used by an IEEE 802.11 transmission.
WifiPhyStandard
Identifies the PHY specification that a Wifi device is configured to use.
HE PHY for the 5 GHz band (clause 26)
Ptr< SpectrumWifiPhy > m_txB
transmit B function
void PacketDropped(Ptr< const Packet > packet, WifiPhyRxfailureReason reason)
Function triggered when a packet is dropped.
virtual void ConfigureStandard(WifiPhyStandard standard)
Configure the PHY-level parameters for different Wi-Fi standard.
void SetTxPowerEnd(double end)
Sets the maximum available transmission power level (dBm).
Parse command-line arguments.
void SetErrorRateModel(const Ptr< ErrorRateModel > rate)
Sets the error rate model.
OFDM PHY for the 5 GHz band (Clause 17)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
DSSS PHY (Clause 15) and HR/DSSS PHY (Clause 18)
struct Input m_input
input
void Run(struct InterferenceExperiment::Input input)
Run function.
void SetTxPowerLevel(uint8_t powerlevel)
Sets the selected transmission power level.
bool expectRxASuccessfull
void SetPosition(const Vector &position)
void experiment(std::string queue_disc_type)
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
void SetTxPowerStart(double start)
Sets the minimum available transmission power level (dBm).
Time Seconds(double value)
Construct a Time in the indicated unit.
WifiPhyRxfailureReason
Enumeration of the possible reception failure reasons.
void SetDefault(std::string name, const AttributeValue &value)
Ptr< SpectrumWifiPhy > m_txA
transmit A function
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
void SetMargin(double margin)
Sets the frame capture margin (dB).
void SetChannel(const Ptr< SpectrumChannel > channel)
Set the SpectrumChannel this SpectrumWifiPhy is to be connected to.
This class can be used to hold variables of floating point type such as 'double' or 'float'...
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
void CreateWifiSpectrumPhyInterface(Ptr< NetDevice > device)
Method to encapsulate the creation of the WifiSpectrumPhyInterface object (used to bind the WifiSpect...
void SendA(void) const
Send A function.