21 #include "ns3/wifi-net-device.h"
22 #include "ns3/yans-wifi-channel.h"
23 #include "ns3/yans-wifi-phy.h"
24 #include "ns3/propagation-loss-model.h"
25 #include "ns3/propagation-delay-model.h"
26 #include "ns3/error-rate-model.h"
27 #include "ns3/yans-error-rate-model.h"
29 #include "ns3/mobility-model.h"
30 #include "ns3/constant-position-mobility-model.h"
31 #include "ns3/vector.h"
32 #include "ns3/packet.h"
33 #include "ns3/simulator.h"
34 #include "ns3/nstime.h"
35 #include "ns3/command-line.h"
36 #include "ns3/flow-id-tag.h"
37 #include "ns3/wifi-tx-vector.h"
63 void
Receive (Ptr<Packet> p, double snr, WifiTxVector txVector, enum WifiPreamble preamble);
72 Ptr<Packet> p = Create<Packet> (m_input.packetSize);
91 txMode (
"OfdmRate6Mbps"),
118 rx->SetErrorRateModel (error);
120 rx->SetChannel (channel);
122 rx->SetMobility (posRx);
135 Simulator::Destroy ();
166 void
SendA (void) const;
167 void
SendB (void) const;
168 void
Receive (Ptr<Packet> p, double snr, WifiTxVector txVector, enum WifiPreamble preamble);
223 txModeA (
"OfdmRate6Mbps"),
224 txModeB (
"OfdmRate6Mbps"),
240 m_flowIdA = FlowIdTag::AllocateFlowId ();
241 m_flowIdB = FlowIdTag::AllocateFlowId ();
261 txB->SetErrorRateModel (error);
262 rx->SetErrorRateModel (error);
264 txB->SetChannel (channel);
265 rx->SetChannel (channel);
267 txB->SetMobility (posTxB);
268 rx->SetMobility (posRx);
287 Simulator::Destroy ();
298 cmd.AddValue (
"Distance",
"The distance between two phys", input.
distance);
299 cmd.AddValue (
"PacketSize",
"The size of each packet sent", input.
packetSize);
300 cmd.AddValue (
"TxMode",
"The mode to use to send each packet", input.
txMode);
301 cmd.AddValue (
"NPackets",
"The number of packets to send", input.
nPackets);
302 cmd.AddValue (
"TxPowerLevel",
"The power level index to use to send each packet", input.
txPowerLevel);
303 cmd.Parse (argc, argv);
306 output = experiment.
Run (input);
311 std::cout << psr << std::endl;
325 cmd.AddValue (
"TxPowerLevel",
"The power level index to use to send each packet", input.
txPowerLevel);
326 cmd.AddValue (
"TxMode",
"The mode to use to send each packet", input.
txMode);
327 cmd.AddValue (
"NPackets",
"The number of packets to send", input.
nPackets);
328 cmd.AddValue (
"PacketSize",
"The size of each packet sent", input.
packetSize);
329 cmd.Parse (argc, argv);
337 input.
txMode =
"OfdmRate6Mbps";
338 output = experiment.
Run (input);
339 std::cout <<
" " <<
CalcPsr (output, input);
341 input.
txMode =
"OfdmRate9Mbps";
342 output = experiment.
Run (input);
343 std::cout <<
" " <<
CalcPsr (output, input);
345 input.
txMode =
"OfdmRate12Mbps";
346 output = experiment.
Run (input);
347 std::cout <<
" " <<
CalcPsr (output, input);
349 input.
txMode =
"OfdmRate18Mbps";
350 output = experiment.
Run (input);
351 std::cout <<
" " <<
CalcPsr (output, input);
353 input.
txMode =
"OfdmRate24Mbps";
354 output = experiment.
Run (input);
355 std::cout <<
" " <<
CalcPsr (output, input);
357 input.
txMode =
"OfdmRate36Mbps";
358 output = experiment.
Run (input);
359 std::cout <<
" " <<
CalcPsr (output, input);
361 input.
txMode =
"OfdmRate48Mbps";
362 output = experiment.
Run (input);
363 std::cout <<
" " <<
CalcPsr (output, input);
365 input.
txMode =
"OfdmRate54Mbps";
366 output = experiment.
Run (input);
367 std::cout <<
" " <<
CalcPsr (output, input);
369 std::cout << std::endl;
375 double targetPsr = 0.05;
378 cmd.AddValue (
"TxPowerLevel",
"The power level index to use to send each packet", input.
txPowerLevel);
379 cmd.AddValue (
"TxMode",
"The mode to use to send each packet", input.
txMode);
380 cmd.AddValue (
"NPackets",
"The number of packets to send", input.
nPackets);
381 cmd.AddValue (
"TargetPsr",
"The psr needed to assume that we are within range", targetPsr);
382 cmd.Parse (argc, argv);
386 double precision = 0.1;
389 while (high - low > precision)
391 double middle = low + (high - low) / 2;
395 output = experiment.Run (input);
396 double psr =
CalcPsr (output, input);
397 if (psr >= targetPsr)
415 cmd.
AddValue (
"NPackets",
"The number of packets to send for each transmitter", input.
nPackets);
416 cmd.
AddValue (
"xA",
"the position of transmitter A", input.
xA);
417 cmd.
AddValue (
"xB",
"the position of transmitter B", input.
xB);
418 cmd.
Parse (argc, argv);
420 for (uint32_t i = 0; i < 100; i += 1)
425 output = experiment.
Run (input);
428 std::cout << i <<
" " << perA <<
" " << perB << std::endl;
430 for (uint32_t i = 100; i < 4000; i += 50)
435 output = experiment.
Run (input);
438 std::cout << i <<
" " << perA <<
" " << perB << std::endl;
443 int main (
int argc,
char *argv[])
447 std::cout <<
"Available experiments: "
451 <<
"PsrVsCollisionInterval "
455 std::string type = argv[1];
463 else if (type ==
"SizeVsRange")
467 else if (type ==
"PsrVsDistance")
471 else if (type ==
"PsrVsCollisionInterval")
477 std::cout <<
"Wrong arguments!" << std::endl;
bool FindFirstMatchingByteTag(Tag &tag) const
Finds the first tag matching the parameter Tag type.
void experiment(bool enableCtsRts)
Run single 10 seconds experiment with enabled or disabled RTS/CTS mechanism.
Simulation virtual time values and global simulation resolution.
Smart pointer class similar to boost::intrusive_ptr.
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
void SetErrorRateModel(Ptr< ErrorRateModel > rate)
Sets the error rate model.
void SetPropagationLossModel(Ptr< PropagationLossModel > loss)
void SetPropagationDelayModel(Ptr< PropagationDelayModel > delay)
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
void SetMobility(Ptr< MobilityModel > mobility)
assign a mobility model to this device
WifiPreamble
The type of preamble to be used by an IEEE 802.11 transmission.
void Receive(Ptr< Packet > p, double snr, WifiTxVector txVector, enum WifiPreamble preamble)
static void PrintPsrVsDistance(int argc, char *argv[])
static void PrintPsrVsCollisionInterval(int argc, char *argv[])
The MPDU is not part of an A-MPDU.
double CalcPsr(struct PsrExperiment::Output output, struct PsrExperiment::Input input)
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
uint32_t GetFlowId(void) const
Gets the flow id for the tag.
static void PrintPsr(int argc, char *argv[])
Parse command-line arguments.
void SetChannel(Ptr< YansWifiChannel > channel)
Set the YansWifiChannel this YansWifiPhy is to be connected to.
OFDM PHY for the 5 GHz band (Clause 17)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void SetTxPowerLevel(uint8_t powerlevel)
Sets the selected transmission power level.
struct PsrExperiment::Output Run(struct PsrExperiment::Input input)
void SetPosition(const Vector &position)
void SetMode(WifiMode mode)
Sets the selected payload transmission mode.
void Receive(Ptr< Packet > p, double snr, WifiTxVector txVector, enum WifiPreamble preamble)
void AddValue(const std::string &name, const std::string &help, T &value)
Add a program argument, assigning to POD.
virtual void ConfigureStandard(enum WifiPhyStandard standard)
Configure the PHY-level parameters for different Wi-Fi standard.
Introspection did not find any typical Config paths.
Time Seconds(double value)
Construct a Time in the indicated unit.
struct CollisionExperiment::Output Run(struct CollisionExperiment::Input input)
static void PrintSizeVsRange(int argc, char *argv[])
void Parse(int argc, char *argv[])
Parse the program arguments.
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
static const uint32_t packetSize
void AddByteTag(const Tag &tag) const
Tag each byte included in this packet with a new byte tag.