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);
92 m_tx->Send(psdu, txVector);
99 std::vector<bool> statusPerMpdu)
110 txMode(
"OfdmRate6Mbps"),
129 channel->SetPropagationDelayModel(CreateObject<ConstantSpeedPropagationDelayModel>());
131 channel->SetPropagationLossModel(log);
154 Simulator::Destroy();
209 std::vector<bool> statusPerMpdu);
227 m_txA->Send(psdu, txVector);
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);
334 Simulator::Destroy();
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;
500 main(
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.
uint32_t GetFlowId() const
Gets the flow id for the tag.
void SetPosition(const Vector &position)
Simulation virtual time values and global simulation resolution.
represent a single transmission mode
void SetErrorRateModel(const Ptr< ErrorRateModel > model)
Sets the error rate model.
virtual void ConfigureStandard(WifiStandard standard)
Configure the PHY-level parameters for different Wi-Fi standard.
void SetMobility(const Ptr< MobilityModel > mobility)
assign a mobility model to this device
void SetReceiveOkCallback(RxOkCallback callback)
std::vector< Ptr< WifiMpdu > >::const_iterator begin() const
Return a const iterator to the first MPDU.
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 SetChannel(const Ptr< YansWifiChannel > channel)
Set the YansWifiChannel this YansWifiPhy is to be connected to.
void experiment(std::string queue_disc_type)
static void Send(Ptr< NetDevice > dev, int level, std::string emuMode)
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.