20#include "ns3/command-line.h"
21#include "ns3/constant-position-mobility-model.h"
22#include "ns3/flow-id-tag.h"
23#include "ns3/nist-error-rate-model.h"
24#include "ns3/packet.h"
25#include "ns3/propagation-delay-model.h"
26#include "ns3/propagation-loss-model.h"
27#include "ns3/simulator.h"
28#include "ns3/wifi-psdu.h"
29#include "ns3/yans-wifi-channel.h"
30#include "ns3/yans-wifi-phy.h"
77 std::vector<bool> statusPerMpdu);
99 std::vector<bool> statusPerMpdu)
110 txMode(
"OfdmRate6Mbps"),
124 posTx->SetPosition(Vector(0.0, 0.0, 0.0));
129 channel->SetPropagationDelayModel(CreateObject<ConstantSpeedPropagationDelayModel>());
131 channel->SetPropagationLossModel(log);
136 tx->SetErrorRateModel(error);
137 rx->SetErrorRateModel(error);
138 tx->SetChannel(channel);
139 rx->SetChannel(channel);
140 tx->SetMobility(posTx);
141 rx->SetMobility(posRx);
209 std::vector<bool> statusPerMpdu);
222 (*psdu->begin())->GetPacket()->AddByteTag(
FlowIdTag(m_flowIdA));
227 m_txA->Send(psdu, txVector);
234 (*psdu->begin())->GetPacket()->AddByteTag(
FlowIdTag(m_flowIdB));
239 m_txB->Send(psdu, txVector);
246 std::vector<bool> statusPerMpdu)
249 if ((*psdu->begin())->GetPacket()->FindFirstMatchingByteTag(tag))
270 txModeA(
"OfdmRate6Mbps"),
271 txModeB(
"OfdmRate6Mbps"),
291 channel->SetPropagationDelayModel(CreateObject<ConstantSpeedPropagationDelayModel>());
293 channel->SetPropagationLossModel(log);
296 posTxA->SetPosition(Vector(input.
xA, 0.0, 0.0));
298 posTxB->SetPosition(Vector(input.
xB, 0.0, 0.0));
300 posRx->SetPosition(Vector(0, 0.0, 0.0));
307 txA->SetErrorRateModel(error);
308 txB->SetErrorRateModel(error);
309 rx->SetErrorRateModel(error);
310 txA->SetChannel(channel);
311 txB->SetChannel(channel);
312 rx->SetChannel(channel);
313 txA->SetMobility(posTxA);
314 txB->SetMobility(posTxB);
315 rx->SetMobility(posRx);
345 cmd.AddValue(
"Distance",
"The distance between two phys", input.
distance);
346 cmd.AddValue(
"PacketSize",
"The size of each packet sent", input.
packetSize);
347 cmd.AddValue(
"TxMode",
"The mode to use to send each packet", input.
txMode);
348 cmd.AddValue(
"NPackets",
"The number of packets to send", input.
nPackets);
349 cmd.AddValue(
"TxPowerLevel",
350 "The power level index to use to send each packet",
352 cmd.Parse(argc, argv);
360 std::cout << psr << std::endl;
376 cmd.AddValue(
"TxPowerLevel",
377 "The power level index to use to send each packet",
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(
"PacketSize",
"The size of each packet sent", input.
packetSize);
382 cmd.Parse(argc, argv);
390 input.
txMode =
"OfdmRate6Mbps";
392 std::cout <<
" " <<
CalcPsr(output, input);
394 input.
txMode =
"OfdmRate9Mbps";
396 std::cout <<
" " <<
CalcPsr(output, input);
398 input.
txMode =
"OfdmRate12Mbps";
400 std::cout <<
" " <<
CalcPsr(output, input);
402 input.
txMode =
"OfdmRate18Mbps";
404 std::cout <<
" " <<
CalcPsr(output, input);
406 input.
txMode =
"OfdmRate24Mbps";
408 std::cout <<
" " <<
CalcPsr(output, input);
410 input.
txMode =
"OfdmRate36Mbps";
412 std::cout <<
" " <<
CalcPsr(output, input);
414 input.
txMode =
"OfdmRate48Mbps";
416 std::cout <<
" " <<
CalcPsr(output, input);
418 input.
txMode =
"OfdmRate54Mbps";
420 std::cout <<
" " <<
CalcPsr(output, input);
422 std::cout << std::endl;
429 double targetPsr = 0.05;
432 cmd.AddValue(
"TxPowerLevel",
433 "The power level index to use to send each packet",
435 cmd.AddValue(
"TxMode",
"The mode to use to send each packet", input.
txMode);
436 cmd.AddValue(
"NPackets",
"The number of packets to send", input.
nPackets);
437 cmd.AddValue(
"TargetPsr",
"The psr needed to assume that we are within range", targetPsr);
438 cmd.Parse(argc, argv);
442 double precision = 0.1;
445 while (high - low > precision)
447 double middle = low + (high - low) / 2;
452 double psr =
CalcPsr(output, input);
453 if (psr >= targetPsr)
472 cmd.AddValue(
"NPackets",
"The number of packets to send for each transmitter", input.
nPackets);
473 cmd.AddValue(
"xA",
"the position of transmitter A", input.
xA);
474 cmd.AddValue(
"xB",
"the position of transmitter B", input.
xB);
475 cmd.Parse(argc, argv);
477 for (
uint32_t i = 0; i < 100; i += 1)
485 std::cout << i <<
" " << perA <<
" " << perB << std::endl;
487 for (
uint32_t i = 100; i < 4000; i += 50)
495 std::cout << i <<
" " << perA <<
" " << perB << std::endl;
500main(
int argc,
char* argv[])
504 std::cout <<
"Available experiments: "
508 <<
"PsrVsCollisionInterval " << std::endl;
511 std::string
type = argv[1];
519 else if (type ==
"SizeVsRange")
523 else if (type ==
"PsrVsDistance")
527 else if (type ==
"PsrVsCollisionInterval")
533 std::cout <<
"Wrong arguments!" << std::endl;
uint32_t m_flowIdB
flow ID B
void SendA() const
Send A function.
void SendB() const
Send B function.
CollisionExperiment::Output Run(CollisionExperiment::Input input)
Run function.
Ptr< WifiPhy > m_txB
transmit B
Ptr< WifiPhy > m_txA
transmit A
uint32_t m_flowIdA
flow ID A
void Receive(Ptr< const WifiPsdu > psdu, RxSignalInfo rxSignalInfo, WifiTxVector txVector, std::vector< bool > statusPerMpdu)
Receive function.
Ptr< WifiPhy > m_tx
transmit
PsrExperiment::Output Run(PsrExperiment::Input input)
Run function.
void Receive(Ptr< const WifiPsdu > psdu, RxSignalInfo rxSignalInfo, WifiTxVector txVector, std::vector< bool > statusPerMpdu)
Send receive function.
void Send()
Send function.
Parse command-line arguments.
Introspection did not find any typical Config paths.
uint32_t GetFlowId() const
Gets the flow id for the tag.
static uint32_t AllocateFlowId()
Uses a static variable to generate sequential flow id.
Smart pointer class similar to boost::intrusive_ptr.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
static void Run()
Run the simulation.
Simulation virtual time values and global simulation resolution.
represent a single transmission mode
void Send(Ptr< const WifiPsdu > psdu, const WifiTxVector &txVector)
This function is a wrapper for the Send variant that accepts a WifiConstPsduMap as first argument.
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
void SetTxPowerLevel(uint8_t powerlevel)
Sets the selected transmission power level.
void SetMode(WifiMode mode)
Sets the selected payload transmission mode.
void SetPreambleType(WifiPreamble preamble)
Sets the preamble type.
void experiment(std::string queue_disc_type)
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Time Seconds(double value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
uint32_t receivedA
received A
uint32_t receivedB
received B
uint32_t received
received
RxSignalInfo structure containing info on the received signal.
static void PrintPsr(int argc, char *argv[])
double CalcPsr(PsrExperiment::Output output, PsrExperiment::Input input)
static void PrintPsrVsCollisionInterval(int argc, char *argv[])
static void PrintPsrVsDistance(int argc, char *argv[])
static void PrintSizeVsRange(int argc, char *argv[])
static const uint32_t packetSize
Packet size generated at the AP.