21 #include "ns3/packet.h" 22 #include "ns3/constant-position-mobility-model.h" 23 #include "ns3/simulator.h" 24 #include "ns3/command-line.h" 25 #include "ns3/flow-id-tag.h" 26 #include "ns3/yans-wifi-channel.h" 27 #include "ns3/yans-wifi-phy.h" 28 #include "ns3/propagation-loss-model.h" 29 #include "ns3/propagation-delay-model.h" 30 #include "ns3/nist-error-rate-model.h" 72 void
Receive (Ptr<Packet> p, double snr, WifiTxVector txVector, std::vector<bool> statusPerMpdu);
81 Ptr<Packet> p = Create<Packet> (m_input.packetSize);
87 m_tx->SendPacket (p, txVector);
101 txMode (
"OfdmRate6Mbps"),
120 channel->SetPropagationDelayModel (CreateObject<ConstantSpeedPropagationDelayModel> ());
122 channel->SetPropagationLossModel (log);
128 rx->SetErrorRateModel (error);
132 rx->SetMobility (posRx);
145 Simulator::Destroy ();
184 void
SendA (void) const;
186 void
SendB (void) const;
194 void
Receive (Ptr<Packet> p, double snr, WifiTxVector txVector, std::vector<bool> statusPerMpdu);
212 m_txA->SendPacket (p, txVector);
224 m_txB->SendPacket (p, txVector);
251 txModeA (
"OfdmRate6Mbps"),
252 txModeB (
"OfdmRate6Mbps"),
268 m_flowIdA = FlowIdTag::AllocateFlowId ();
269 m_flowIdB = FlowIdTag::AllocateFlowId ();
272 channel->SetPropagationDelayModel (CreateObject<ConstantSpeedPropagationDelayModel> ());
274 channel->SetPropagationLossModel (log);
289 txB->SetErrorRateModel (error);
290 rx->SetErrorRateModel (error);
295 txB->SetMobility (posTxB);
296 rx->SetMobility (posRx);
315 Simulator::Destroy ();
326 cmd.AddValue (
"Distance",
"The distance between two phys", input.
distance);
327 cmd.AddValue (
"PacketSize",
"The size of each packet sent", input.
packetSize);
328 cmd.AddValue (
"TxMode",
"The mode to use to send each packet", input.
txMode);
329 cmd.AddValue (
"NPackets",
"The number of packets to send", input.
nPackets);
330 cmd.AddValue (
"TxPowerLevel",
"The power level index to use to send each packet", input.
txPowerLevel);
331 cmd.Parse (argc, argv);
336 double psr = output.received;
339 std::cout << psr << std::endl;
353 cmd.AddValue (
"TxPowerLevel",
"The power level index to use to send each packet", input.
txPowerLevel);
354 cmd.AddValue (
"TxMode",
"The mode to use to send each packet", input.
txMode);
355 cmd.AddValue (
"NPackets",
"The number of packets to send", input.
nPackets);
356 cmd.AddValue (
"PacketSize",
"The size of each packet sent", input.
packetSize);
357 cmd.Parse (argc, argv);
365 input.
txMode =
"OfdmRate6Mbps";
367 std::cout <<
" " <<
CalcPsr (output, input);
369 input.
txMode =
"OfdmRate9Mbps";
371 std::cout <<
" " <<
CalcPsr (output, input);
373 input.
txMode =
"OfdmRate12Mbps";
375 std::cout <<
" " <<
CalcPsr (output, input);
377 input.
txMode =
"OfdmRate18Mbps";
379 std::cout <<
" " <<
CalcPsr (output, input);
381 input.
txMode =
"OfdmRate24Mbps";
383 std::cout <<
" " <<
CalcPsr (output, input);
385 input.
txMode =
"OfdmRate36Mbps";
387 std::cout <<
" " <<
CalcPsr (output, input);
389 input.
txMode =
"OfdmRate48Mbps";
391 std::cout <<
" " <<
CalcPsr (output, input);
393 input.
txMode =
"OfdmRate54Mbps";
395 std::cout <<
" " <<
CalcPsr (output, input);
397 std::cout << std::endl;
403 double targetPsr = 0.05;
406 cmd.AddValue (
"TxPowerLevel",
"The power level index to use to send each packet", input.
txPowerLevel);
407 cmd.AddValue (
"TxMode",
"The mode to use to send each packet", input.
txMode);
408 cmd.AddValue (
"NPackets",
"The number of packets to send", input.
nPackets);
409 cmd.AddValue (
"TargetPsr",
"The psr needed to assume that we are within range", targetPsr);
410 cmd.Parse (argc, argv);
414 double precision = 0.1;
417 while (high - low > precision)
419 double middle = low + (high - low) / 2;
424 double psr =
CalcPsr (output, input);
425 if (psr >= targetPsr)
443 cmd.AddValue (
"NPackets",
"The number of packets to send for each transmitter", input.
nPackets);
444 cmd.AddValue (
"xA",
"the position of transmitter A", input.
xA);
445 cmd.AddValue (
"xB",
"the position of transmitter B", input.
xB);
446 cmd.Parse (argc, argv);
448 for (uint32_t i = 0; i < 100; i += 1)
456 std::cout << i <<
" " << perA <<
" " << perB << std::endl;
458 for (uint32_t i = 100; i < 4000; i += 50)
466 std::cout << i <<
" " << perA <<
" " << perB << std::endl;
471 int main (
int argc,
char *argv[])
475 std::cout <<
"Available experiments: " 479 <<
"PsrVsCollisionInterval " 483 std::string type = argv[1];
491 else if (type ==
"SizeVsRange")
495 else if (type ==
"PsrVsDistance")
499 else if (type ==
"PsrVsCollisionInterval")
505 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.
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 SendB(void) const
Send B function.
struct Output m_output
output
void Receive(Ptr< Packet > p, double snr, WifiTxVector txVector, std::vector< bool > statusPerMpdu)
Send receive function.
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...
void SendA(void) const
Send A function.
static void PrintPsrVsDistance(int argc, char *argv[])
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 m_flowIdB
flow ID B
static void PrintPsr(int argc, char *argv[])
Parse command-line arguments.
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.
void Receive(Ptr< Packet > p, double snr, WifiTxVector txVector, std::vector< bool > statusPerMpdu)
Receive function.
uint32_t received
received
void experiment(std::string queue_disc_type)
struct Input m_input
input
Introspection did not find any typical Config paths.
Ptr< WifiPhy > m_tx
transmit
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[])
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
static const uint32_t packetSize
uint32_t GetFlowId(void) const
Gets the flow id for the tag.
virtual void ConfigureStandard(WifiPhyStandard standard)
Configure the PHY-level parameters for different Wi-Fi standard.
void AddByteTag(const Tag &tag) const
Tag each byte included in this packet with a new byte tag.
struct Input m_input
input