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"
31 #include "ns3/wifi-psdu.h"
73 void
Receive (Ptr<WifiPsdu> psdu, RxSignalInfo rxSignalInfo,
74 WifiTxVector txVector, std::vector<bool> statusPerMpdu);
89 m_tx->Send (psdu, txVector);
104 txMode (
"OfdmRate6Mbps"),
123 channel->SetPropagationDelayModel (CreateObject<ConstantSpeedPropagationDelayModel> ());
125 channel->SetPropagationLossModel (log);
148 Simulator::Destroy ();
187 void
SendA (void) const;
189 void
SendB (void) const;
197 void
Receive (Ptr<WifiPsdu> psdu, RxSignalInfo rxSignalInfo,
198 WifiTxVector txVector, std::vector<bool> statusPerMpdu);
236 if ((*psdu->
begin ())->GetPacket ()->FindFirstMatchingByteTag (tag))
256 txModeA (
"OfdmRate6Mbps"),
257 txModeB (
"OfdmRate6Mbps"),
273 m_flowIdA = FlowIdTag::AllocateFlowId ();
274 m_flowIdB = FlowIdTag::AllocateFlowId ();
277 channel->SetPropagationDelayModel (CreateObject<ConstantSpeedPropagationDelayModel> ());
279 channel->SetPropagationLossModel (log);
320 Simulator::Destroy ();
331 cmd.AddValue (
"Distance",
"The distance between two phys", input.
distance);
332 cmd.AddValue (
"PacketSize",
"The size of each packet sent", input.
packetSize);
333 cmd.AddValue (
"TxMode",
"The mode to use to send each packet", input.
txMode);
334 cmd.AddValue (
"NPackets",
"The number of packets to send", input.
nPackets);
335 cmd.AddValue (
"TxPowerLevel",
"The power level index to use to send each packet", input.
txPowerLevel);
336 cmd.Parse (argc, argv);
341 double psr = output.received;
344 std::cout << psr << std::endl;
358 cmd.AddValue (
"TxPowerLevel",
"The power level index to use to send each packet", input.
txPowerLevel);
359 cmd.AddValue (
"TxMode",
"The mode to use to send each packet", input.
txMode);
360 cmd.AddValue (
"NPackets",
"The number of packets to send", input.
nPackets);
361 cmd.AddValue (
"PacketSize",
"The size of each packet sent", input.
packetSize);
362 cmd.Parse (argc, argv);
370 input.
txMode =
"OfdmRate6Mbps";
372 std::cout <<
" " <<
CalcPsr (output, input);
374 input.
txMode =
"OfdmRate9Mbps";
376 std::cout <<
" " <<
CalcPsr (output, input);
378 input.
txMode =
"OfdmRate12Mbps";
380 std::cout <<
" " <<
CalcPsr (output, input);
382 input.
txMode =
"OfdmRate18Mbps";
384 std::cout <<
" " <<
CalcPsr (output, input);
386 input.
txMode =
"OfdmRate24Mbps";
388 std::cout <<
" " <<
CalcPsr (output, input);
390 input.
txMode =
"OfdmRate36Mbps";
392 std::cout <<
" " <<
CalcPsr (output, input);
394 input.
txMode =
"OfdmRate48Mbps";
396 std::cout <<
" " <<
CalcPsr (output, input);
398 input.
txMode =
"OfdmRate54Mbps";
400 std::cout <<
" " <<
CalcPsr (output, input);
402 std::cout << std::endl;
408 double targetPsr = 0.05;
411 cmd.AddValue (
"TxPowerLevel",
"The power level index to use to send each packet", input.
txPowerLevel);
412 cmd.AddValue (
"TxMode",
"The mode to use to send each packet", input.
txMode);
413 cmd.AddValue (
"NPackets",
"The number of packets to send", input.
nPackets);
414 cmd.AddValue (
"TargetPsr",
"The psr needed to assume that we are within range", targetPsr);
415 cmd.Parse (argc, argv);
419 double precision = 0.1;
422 while (high - low > precision)
424 double middle = low + (high - low) / 2;
429 double psr =
CalcPsr (output, input);
430 if (psr >= targetPsr)
448 cmd.AddValue (
"NPackets",
"The number of packets to send for each transmitter", input.
nPackets);
449 cmd.AddValue (
"xA",
"the position of transmitter A", input.
xA);
450 cmd.AddValue (
"xB",
"the position of transmitter B", input.
xB);
451 cmd.Parse (argc, argv);
453 for (uint32_t i = 0; i < 100; i += 1)
461 std::cout << i <<
" " << perA <<
" " << perB << std::endl;
463 for (uint32_t i = 100; i < 4000; i += 50)
471 std::cout << i <<
" " << perA <<
" " << perB << std::endl;
476 int main (
int argc,
char *argv[])
480 std::cout <<
"Available experiments: "
484 <<
"PsrVsCollisionInterval "
488 std::string type = argv[1];
496 else if (type ==
"SizeVsRange")
500 else if (type ==
"PsrVsDistance")
504 else if (type ==
"PsrVsCollisionInterval")
510 std::cout <<
"Wrong arguments!" << std::endl;