21 #include "ns3/yans-wifi-channel.h"
22 #include "ns3/propagation-loss-model.h"
23 #include "ns3/propagation-delay-model.h"
24 #include "ns3/nist-error-rate-model.h"
25 #include "ns3/constant-position-mobility-model.h"
26 #include "ns3/simulator.h"
27 #include "ns3/command-line.h"
28 #include "ns3/flow-id-tag.h"
69 void
Receive (Ptr<Packet> p, double snr, WifiTxVector txVector);
78 Ptr<Packet> p = Create<Packet> (m_input.packetSize);
84 m_tx->SendPacket (p, txVector);
98 txMode (
"OfdmRate6Mbps"),
125 rx->SetErrorRateModel (error);
127 rx->SetChannel (channel);
129 rx->SetMobility (posRx);
142 Simulator::Destroy ();
181 void
SendA (void) const;
183 void
SendB (void) const;
190 void
Receive (Ptr<Packet> p, double snr, WifiTxVector txVector);
208 m_txA->SendPacket (p, txVector);
220 m_txB->SendPacket (p, txVector);
247 txModeA (
"OfdmRate6Mbps"),
248 txModeB (
"OfdmRate6Mbps"),
264 m_flowIdA = FlowIdTag::AllocateFlowId ();
265 m_flowIdB = FlowIdTag::AllocateFlowId ();
285 txB->SetErrorRateModel (error);
286 rx->SetErrorRateModel (error);
288 txB->SetChannel (channel);
289 rx->SetChannel (channel);
291 txB->SetMobility (posTxB);
292 rx->SetMobility (posRx);
311 Simulator::Destroy ();
322 cmd.AddValue (
"Distance",
"The distance between two phys", input.
distance);
323 cmd.AddValue (
"PacketSize",
"The size of each packet sent", input.
packetSize);
324 cmd.AddValue (
"TxMode",
"The mode to use to send each packet", input.
txMode);
325 cmd.AddValue (
"NPackets",
"The number of packets to send", input.
nPackets);
326 cmd.AddValue (
"TxPowerLevel",
"The power level index to use to send each packet", input.
txPowerLevel);
327 cmd.Parse (argc, argv);
330 output = experiment.
Run (input);
335 std::cout << psr << std::endl;
349 cmd.AddValue (
"TxPowerLevel",
"The power level index to use to send each packet", input.
txPowerLevel);
350 cmd.AddValue (
"TxMode",
"The mode to use to send each packet", input.
txMode);
351 cmd.AddValue (
"NPackets",
"The number of packets to send", input.
nPackets);
352 cmd.AddValue (
"PacketSize",
"The size of each packet sent", input.
packetSize);
353 cmd.Parse (argc, argv);
361 input.
txMode =
"OfdmRate6Mbps";
362 output = experiment.
Run (input);
363 std::cout <<
" " <<
CalcPsr (output, input);
365 input.
txMode =
"OfdmRate9Mbps";
366 output = experiment.
Run (input);
367 std::cout <<
" " <<
CalcPsr (output, input);
369 input.
txMode =
"OfdmRate12Mbps";
370 output = experiment.
Run (input);
371 std::cout <<
" " <<
CalcPsr (output, input);
373 input.
txMode =
"OfdmRate18Mbps";
374 output = experiment.
Run (input);
375 std::cout <<
" " <<
CalcPsr (output, input);
377 input.
txMode =
"OfdmRate24Mbps";
378 output = experiment.
Run (input);
379 std::cout <<
" " <<
CalcPsr (output, input);
381 input.
txMode =
"OfdmRate36Mbps";
382 output = experiment.
Run (input);
383 std::cout <<
" " <<
CalcPsr (output, input);
385 input.
txMode =
"OfdmRate48Mbps";
386 output = experiment.
Run (input);
387 std::cout <<
" " <<
CalcPsr (output, input);
389 input.
txMode =
"OfdmRate54Mbps";
390 output = experiment.
Run (input);
391 std::cout <<
" " <<
CalcPsr (output, input);
393 std::cout << std::endl;
399 double targetPsr = 0.05;
402 cmd.AddValue (
"TxPowerLevel",
"The power level index to use to send each packet", input.
txPowerLevel);
403 cmd.AddValue (
"TxMode",
"The mode to use to send each packet", input.
txMode);
404 cmd.AddValue (
"NPackets",
"The number of packets to send", input.
nPackets);
405 cmd.AddValue (
"TargetPsr",
"The psr needed to assume that we are within range", targetPsr);
406 cmd.Parse (argc, argv);
410 double precision = 0.1;
413 while (high - low > precision)
415 double middle = low + (high - low) / 2;
419 output = experiment.Run (input);
420 double psr =
CalcPsr (output, input);
421 if (psr >= targetPsr)
439 cmd.
AddValue (
"NPackets",
"The number of packets to send for each transmitter", input.
nPackets);
440 cmd.
AddValue (
"xA",
"the position of transmitter A", input.
xA);
441 cmd.
AddValue (
"xB",
"the position of transmitter B", input.
xB);
442 cmd.
Parse (argc, argv);
444 for (uint32_t i = 0; i < 100; i += 1)
449 output = experiment.
Run (input);
452 std::cout << i <<
" " << perA <<
" " << perB << std::endl;
454 for (uint32_t i = 100; i < 4000; i += 50)
459 output = experiment.
Run (input);
462 std::cout << i <<
" " << perA <<
" " << perB << std::endl;
467 int main (
int argc,
char *argv[])
471 std::cout <<
"Available experiments: "
475 <<
"PsrVsCollisionInterval "
479 std::string type = argv[1];
487 else if (type ==
"SizeVsRange")
491 else if (type ==
"PsrVsDistance")
495 else if (type ==
"PsrVsCollisionInterval")
501 std::cout <<
"Wrong arguments!" << std::endl;
bool FindFirstMatchingByteTag(Tag &tag) const
Finds the first tag matching the parameter Tag type.
Simulation virtual time values and global simulation resolution.
Smart pointer class similar to boost::intrusive_ptr.
void SetPropagationLossModel(const Ptr< PropagationLossModel > loss)
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.
struct Output m_output
output
void Receive(Ptr< Packet > p, double snr, WifiTxVector txVector)
Receive function.
struct Output m_output
output
void SetMobility(const Ptr< MobilityModel > mobility)
assign a mobility model to this device
uint32_t m_flowIdA
flow ID A
uint32_t receivedA
received A
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
static void PrintPsrVsDistance(int argc, char *argv[])
void SetPropagationDelayModel(const Ptr< PropagationDelayModel > delay)
static void PrintPsrVsCollisionInterval(int argc, char *argv[])
double CalcPsr(struct PsrExperiment::Output output, struct PsrExperiment::Input input)
uint32_t receivedB
received B
Ptr< WifiPhy > m_txA
transmit A
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
uint32_t GetFlowId(void) const
Gets the flow id for the tag.
uint32_t m_flowIdB
flow ID B
static void PrintPsr(int argc, char *argv[])
void SendA(void) const
Send A function.
Parse command-line arguments.
void Receive(Ptr< Packet > p, double snr, WifiTxVector txVector)
Send receive function.
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.
void SetPreambleType(WifiPreamble preamble)
Sets the preamble type.
void SetTxPowerLevel(uint8_t powerlevel)
Sets the selected transmission power level.
void Send(void)
Send function.
struct PsrExperiment::Output Run(struct PsrExperiment::Input input)
Run function.
void SetPosition(const Vector &position)
Ptr< WifiPhy > m_txB
transmit B
void SetMode(WifiMode mode)
Sets the selected payload transmission mode.
uint32_t received
received
void AddValue(const std::string &name, const std::string &help, T &value)
Add a program argument, assigning to POD.
struct Input m_input
input
Introspection did not find any typical Config paths.
Ptr< WifiPhy > m_tx
transmit
void SendB(void) const
Send B function.
Time Seconds(double value)
Construct a Time in the indicated unit.
struct CollisionExperiment::Output Run(struct CollisionExperiment::Input input)
Run function.
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
virtual void ConfigureStandard(WifiPhyStandard standard)
Configure the PHY-level parameters for different Wi-Fi standard.
struct Input m_input
input
void AddByteTag(const Tag &tag) const
Tag each byte included in this packet with a new byte tag.
void experiment(bool enableCtsRts, std::string wifiManager)
Run single 10 seconds experiment.