9#include "ns3/command-line.h"
10#include "ns3/constant-position-mobility-model.h"
11#include "ns3/flow-id-tag.h"
12#include "ns3/nist-error-rate-model.h"
13#include "ns3/packet.h"
14#include "ns3/propagation-delay-model.h"
15#include "ns3/propagation-loss-model.h"
16#include "ns3/simulator.h"
17#include "ns3/wifi-psdu.h"
18#include "ns3/yans-wifi-channel.h"
19#include "ns3/yans-wifi-phy.h"
66 std::vector<bool> statusPerMpdu);
88 std::vector<bool> statusPerMpdu)
99 txMode(
"OfdmRate6Mbps"),
113 posTx->SetPosition(Vector(0.0, 0.0, 0.0));
120 channel->SetPropagationLossModel(log);
125 tx->SetErrorRateModel(error);
126 rx->SetErrorRateModel(error);
127 tx->SetChannel(channel);
128 rx->SetChannel(channel);
129 tx->SetMobility(posTx);
130 rx->SetMobility(posRx);
198 std::vector<bool> statusPerMpdu);
211 (*psdu->begin())->GetPacket()->AddByteTag(
FlowIdTag(m_flowIdA));
216 m_txA->Send(psdu, txVector);
223 (*psdu->begin())->GetPacket()->AddByteTag(
FlowIdTag(m_flowIdB));
228 m_txB->Send(psdu, txVector);
235 std::vector<bool> statusPerMpdu)
238 if ((*psdu->begin())->GetPacket()->FindFirstMatchingByteTag(tag))
259 txModeA(
"OfdmRate6Mbps"),
260 txModeB(
"OfdmRate6Mbps"),
282 channel->SetPropagationLossModel(log);
285 posTxA->SetPosition(Vector(input.
xA, 0.0, 0.0));
287 posTxB->SetPosition(Vector(input.
xB, 0.0, 0.0));
289 posRx->SetPosition(Vector(0, 0.0, 0.0));
296 txA->SetErrorRateModel(error);
297 txB->SetErrorRateModel(error);
298 rx->SetErrorRateModel(error);
299 txA->SetChannel(channel);
300 txB->SetChannel(channel);
301 rx->SetChannel(channel);
302 txA->SetMobility(posTxA);
303 txB->SetMobility(posTxB);
304 rx->SetMobility(posRx);
334 cmd.AddValue(
"Distance",
"The distance between two phys", input.
distance);
335 cmd.AddValue(
"PacketSize",
"The size of each packet sent", input.
packetSize);
336 cmd.AddValue(
"TxMode",
"The mode to use to send each packet", input.
txMode);
337 cmd.AddValue(
"NPackets",
"The number of packets to send", input.
nPackets);
338 cmd.AddValue(
"TxPowerLevel",
339 "The power level index to use to send each packet",
341 cmd.Parse(argc, argv);
349 std::cout << psr << std::endl;
365 cmd.AddValue(
"TxPowerLevel",
366 "The power level index to use to send each packet",
368 cmd.AddValue(
"TxMode",
"The mode to use to send each packet", input.
txMode);
369 cmd.AddValue(
"NPackets",
"The number of packets to send", input.
nPackets);
370 cmd.AddValue(
"PacketSize",
"The size of each packet sent", input.
packetSize);
371 cmd.Parse(argc, argv);
379 input.
txMode =
"OfdmRate6Mbps";
381 std::cout <<
" " <<
CalcPsr(output, input);
383 input.
txMode =
"OfdmRate9Mbps";
385 std::cout <<
" " <<
CalcPsr(output, input);
387 input.
txMode =
"OfdmRate12Mbps";
389 std::cout <<
" " <<
CalcPsr(output, input);
391 input.
txMode =
"OfdmRate18Mbps";
393 std::cout <<
" " <<
CalcPsr(output, input);
395 input.
txMode =
"OfdmRate24Mbps";
397 std::cout <<
" " <<
CalcPsr(output, input);
399 input.
txMode =
"OfdmRate36Mbps";
401 std::cout <<
" " <<
CalcPsr(output, input);
403 input.
txMode =
"OfdmRate48Mbps";
405 std::cout <<
" " <<
CalcPsr(output, input);
407 input.
txMode =
"OfdmRate54Mbps";
409 std::cout <<
" " <<
CalcPsr(output, input);
411 std::cout << std::endl;
418 double targetPsr = 0.05;
421 cmd.AddValue(
"TxPowerLevel",
422 "The power level index to use to send each packet",
424 cmd.AddValue(
"TxMode",
"The mode to use to send each packet", input.
txMode);
425 cmd.AddValue(
"NPackets",
"The number of packets to send", input.
nPackets);
426 cmd.AddValue(
"TargetPsr",
"The psr needed to assume that we are within range", targetPsr);
427 cmd.Parse(argc, argv);
431 double precision = 0.1;
434 while (high - low > precision)
436 double middle = low + (high - low) / 2;
441 double psr =
CalcPsr(output, input);
442 if (psr >= targetPsr)
461 cmd.AddValue(
"NPackets",
"The number of packets to send for each transmitter", input.
nPackets);
462 cmd.AddValue(
"xA",
"the position of transmitter A", input.
xA);
463 cmd.AddValue(
"xB",
"the position of transmitter B", input.
xB);
464 cmd.Parse(argc, argv);
466 for (
uint32_t i = 0; i < 100; i += 1)
474 std::cout << i <<
" " << perA <<
" " << perB << std::endl;
476 for (
uint32_t i = 100; i < 4000; i += 50)
484 std::cout << i <<
" " << perA <<
" " << perB << std::endl;
489main(
int argc,
char* argv[])
493 std::cout <<
"Available experiments: "
497 <<
"PsrVsCollisionInterval " << std::endl;
500 std::string
type = argv[1];
508 else if (type ==
"SizeVsRange")
512 else if (type ==
"PsrVsDistance")
516 else if (type ==
"PsrVsCollisionInterval")
522 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.
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)
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
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.