53 #include "ns3/packet.h" 54 #include "ns3/config.h" 55 #include "ns3/double.h" 56 #include "ns3/simulator.h" 57 #include "ns3/command-line.h" 58 #include "ns3/yans-wifi-channel.h" 59 #include "ns3/yans-wifi-phy.h" 60 #include "ns3/propagation-loss-model.h" 61 #include "ns3/propagation-delay-model.h" 62 #include "ns3/nist-error-rate-model.h" 63 #include "ns3/constant-position-mobility-model.h" 64 #include "ns3/simple-frame-capture-model.h" 111 void SendA (
void)
const;
113 void SendB (
void)
const;
124 Ptr<Packet> p = Create<Packet> (m_input.packetSizeA);
127 txVector.SetMode (
WifiMode (m_input.txModeA));
128 txVector.SetPreambleType (m_input.preamble);
129 m_txA->SendPacket (p, txVector);
135 Ptr<Packet> p = Create<Packet> (m_input.packetSizeB);
138 txVector.SetMode (
WifiMode (m_input.txModeB));
139 txVector.SetPreambleType (m_input.preamble);
140 m_txB->SendPacket (p, txVector);
146 if (packet->
GetUid () == 0)
150 else if (packet->
GetUid () == 1)
162 : m_droppedA (false),
171 txModeA (
"OfdmRate54Mbps"),
172 txModeB (
"OfdmRate54Mbps"),
173 txPowerLevelA (16.0206),
174 txPowerLevelB (16.0206),
179 captureEnabled (false),
189 double range =
std::max (std::abs (input.
xA), input.
xB);
193 channel->SetPropagationDelayModel (CreateObject<ConstantSpeedPropagationDelayModel> ());
195 channel->SetPropagationLossModel (loss);
204 m_txA = CreateObject<YansWifiPhy> ();
207 m_txB = CreateObject<YansWifiPhy> ();
239 Simulator::Destroy ();
251 int main (
int argc,
char *argv[])
254 std::string str_standard =
"WIFI_PHY_STANDARD_80211a";
255 std::string str_preamble =
"WIFI_PREAMBLE_LONG";
259 cmd.AddValue (
"delay",
"Delay in microseconds between frame transmission from sender A and frame transmission from sender B", delay);
260 cmd.AddValue (
"xA",
"The position of transmitter A (< 0)", input.
xA);
261 cmd.AddValue (
"xB",
"The position of transmitter B (> 0)", input.
xB);
262 cmd.AddValue (
"packetSizeA",
"Packet size in bytes of transmitter A", input.
packetSizeA);
263 cmd.AddValue (
"packetSizeB",
"Packet size in bytes of transmitter B", input.
packetSizeB);
264 cmd.AddValue (
"txPowerA",
"TX power level of transmitter A", input.
txPowerLevelA);
265 cmd.AddValue (
"txPowerB",
"TX power level of transmitter B", input.
txPowerLevelB);
266 cmd.AddValue (
"txModeA",
"Wifi mode used for payload transmission of sender A", input.
txModeA);
267 cmd.AddValue (
"txModeB",
"Wifi mode used for payload transmission of sender B", input.
txModeB);
268 cmd.AddValue (
"standard",
"IEEE 802.11 flavor", str_standard);
269 cmd.AddValue (
"preamble",
"Type of preamble", str_preamble);
270 cmd.AddValue (
"enableCapture",
"Enable/disable physical layer capture", input.
captureEnabled);
271 cmd.AddValue (
"captureMargin",
"Margin used for physical layer capture", input.
captureMargin);
272 cmd.AddValue (
"checkResults",
"Used to check results at the end of the test",
checkResults);
273 cmd.AddValue (
"expectRxASuccessfull",
"Indicate whether packet A is expected to be successfully received",
expectRxASuccessfull);
274 cmd.AddValue (
"expectRxBSuccessfull",
"Indicate whether packet B is expected to be successfully received",
expectRxBSuccessfull);
275 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;
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...
void SetChannel(const Ptr< YansWifiChannel > channel)
Set the YansWifiChannel this YansWifiPhy is to be connected to.
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
void SetFrameCaptureModel(const Ptr< FrameCaptureModel > frameCaptureModel)
Sets the frame capture model.
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 SetTxPowerEnd(double end)
Sets the maximum available transmission power level (dBm).
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
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 SetTxPowerStart(double start)
Sets the minimum available transmission power level (dBm).
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.
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'...
void SendA(void) const
Send A function.
void experiment(bool enableCtsRts, std::string wifiManager)
Run single 10 seconds experiment.