52 #include "ns3/core-module.h"
53 #include "ns3/yans-wifi-channel.h"
54 #include "ns3/propagation-loss-model.h"
55 #include "ns3/propagation-delay-model.h"
56 #include "ns3/nist-error-rate-model.h"
57 #include "ns3/constant-position-mobility-model.h"
58 #include "ns3/simple-frame-capture-model.h"
106 void SendA (
void)
const;
108 void SendB (
void)
const;
119 Ptr<Packet> p = Create<Packet> (m_input.packetSizeA);
122 txVector.SetMode (
WifiMode (m_input.txModeA));
123 txVector.SetPreambleType (m_input.preamble);
124 m_txA->SendPacket (p, txVector);
130 Ptr<Packet> p = Create<Packet> (m_input.packetSizeB);
133 txVector.SetMode (
WifiMode (m_input.txModeB));
134 txVector.SetPreambleType (m_input.preamble);
135 m_txB->SendPacket (p, txVector);
141 if (packet->
GetUid () == 0)
145 else if (packet->
GetUid () == 1)
157 : m_droppedA (false),
166 txModeA (
"OfdmRate54Mbps"),
167 txModeB (
"OfdmRate54Mbps"),
168 txPowerLevelA (16.0206),
169 txPowerLevelB (16.0206),
174 captureEnabled (false),
184 double range =
std::max (std::abs (input.
xA), input.
xB);
199 m_txA = CreateObject<YansWifiPhy> ();
202 m_txB = CreateObject<YansWifiPhy> ();
234 Simulator::Destroy ();
246 int main (
int argc,
char *argv[])
249 std::string str_standard =
"WIFI_PHY_STANDARD_80211a";
250 std::string str_preamble =
"WIFI_PREAMBLE_LONG";
254 cmd.
AddValue (
"delay",
"Delay in microseconds between frame transmission from sender A and frame transmission from sender B", delay);
255 cmd.
AddValue (
"xA",
"The position of transmitter A (< 0)", input.
xA);
256 cmd.
AddValue (
"xB",
"The position of transmitter B (> 0)", input.
xB);
261 cmd.
AddValue (
"txModeA",
"Wifi mode used for payload transmission of sender A", input.
txModeA);
262 cmd.
AddValue (
"txModeB",
"Wifi mode used for payload transmission of sender B", input.
txModeB);
263 cmd.
AddValue (
"standard",
"IEEE 802.11 flavor", str_standard);
264 cmd.
AddValue (
"preamble",
"Type of preamble", str_preamble);
270 cmd.
Parse (argc, argv);
279 if (input.
xA >= 0 || input.
xB <= 0)
281 std::cout <<
"Value of xA must be smaller than 0 and value of xB must be bigger than 0!" << std::endl;
285 if (str_standard ==
"WIFI_PHY_STANDARD_80211a")
289 else if (str_standard ==
"WIFI_PHY_STANDARD_80211b")
293 else if (str_standard ==
"WIFI_PHY_STANDARD_80211g")
297 else if (str_standard ==
"WIFI_PHY_STANDARD_80211n_2_4GHZ")
301 else if (str_standard ==
"WIFI_PHY_STANDARD_80211n_5GHZ")
305 else if (str_standard ==
"WIFI_PHY_STANDARD_80211ac")
332 std::cout <<
"Preamble does not exist or is not compatible with the selected standard!" << std::endl;
337 experiment.
Run (input);
ERP-OFDM PHY (Clause 19, Section 19.5)
void Dispose(void)
Dispose of this Object.
void experiment(bool enableCtsRts)
Run single 10 seconds experiment with enabled or disabled RTS/CTS mechanism.
Simulation virtual time values and global simulation resolution.
void SetPropagationLossModel(const Ptr< PropagationLossModel > loss)
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...
void SetChannel(const Ptr< YansWifiChannel > channel)
Set the YansWifiChannel this YansWifiPhy is to be connected to.
uint64_t GetUid(void) const
Returns the packet's Uid.
bool m_droppedB
flag to indicate whether packet B has been dropped
Ptr< YansWifiPhy > m_txA
transmit A function
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
void SetMobility(const Ptr< MobilityModel > mobility)
assign a mobility model to this device
HT PHY for the 2.4 GHz band (clause 20)
bool expectRxBSuccessfull
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
Ptr< YansWifiPhy > m_txB
transmit B function
bool m_droppedA
flag to indicate whether packet A has been dropped
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.
void SetPropagationDelayModel(const Ptr< PropagationDelayModel > delay)
void SetFrameCaptureModel(const Ptr< FrameCaptureModel > rate)
Sets the frame capture model.
void LogComponentEnable(char const *name, enum LogLevel level)
Enable the logging output associated with that log component.
void SetTxPowerEnd(double end)
Sets the maximum available transmission power level (dBm).
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
void SendA(void) const
Send A function.
Parse command-line arguments.
void SetErrorRateModel(const Ptr< ErrorRateModel > rate)
Sets the error rate model.
bool TraceConnectWithoutContext(std::string name, const CallbackBase &cb)
Connect a TraceSource to a Callback without a context.
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 SendB(void) const
Send B function.
void SetTxPowerStart(double start)
Sets the minimum available transmission power level (dBm).
void AddValue(const std::string &name, const std::string &help, T &value)
Add a program argument, assigning to POD.
Time Seconds(double value)
Construct a Time in the indicated unit.
void SetDefault(std::string name, const AttributeValue &value)
void PacketDropped(Ptr< const Packet > packet)
Function triggered when a packet is dropped.
void Parse(int argc, char *argv[])
Parse the program arguments.
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).
virtual void ConfigureStandard(WifiPhyStandard standard)
Configure the PHY-level parameters for different Wi-Fi standard.
This class can be used to hold variables of floating point type such as 'double' or 'float'...