20 #include "ns3/wifi-net-device.h"
21 #include "ns3/yans-wifi-channel.h"
22 #include "ns3/yans-wifi-phy.h"
23 #include "ns3/propagation-loss-model.h"
24 #include "ns3/propagation-delay-model.h"
25 #include "ns3/error-rate-model.h"
26 #include "ns3/yans-error-rate-model.h"
28 #include "ns3/mobility-model.h"
29 #include "ns3/constant-position-mobility-model.h"
30 #include "ns3/vector.h"
31 #include "ns3/packet.h"
32 #include "ns3/simulator.h"
33 #include "ns3/nstime.h"
34 #include "ns3/command-line.h"
35 #include "ns3/flow-id-tag.h"
61 void
Receive (Ptr<Packet> p, double snr, WifiMode mode, enum WifiPreamble preamble);
70 Ptr<Packet> p = Create<Packet> (m_input.packetSize);
86 txMode (
"OfdmRate6Mbps"),
107 channel->SetPropagationLossModel (log);
112 tx->SetErrorRateModel (error);
113 rx->SetErrorRateModel (error);
114 tx->SetChannel (channel);
115 rx->SetChannel (channel);
116 tx->SetMobility (posTx);
117 rx->SetMobility (posRx);
127 Simulator::Destroy();
158 void
SendA (void) const;
159 void
SendB (void) const;
160 void
Receive (Ptr<Packet> p, double snr, WifiMode mode, enum WifiPreamble preamble);
209 txModeA (
"OfdmRate6Mbps"),
210 txModeB (
"OfdmRate6Mbps"),
226 m_flowIdA = FlowIdTag::AllocateFlowId ();
227 m_flowIdB = FlowIdTag::AllocateFlowId ();
232 channel->SetPropagationLossModel (log);
246 txA->SetErrorRateModel (error);
247 txB->SetErrorRateModel (error);
248 rx->SetErrorRateModel (error);
249 txA->SetChannel (channel);
250 txB->SetChannel (channel);
251 rx->SetChannel (channel);
252 txA->SetMobility (posTxA);
253 txB->SetMobility (posTxB);
254 rx->SetMobility (posRx);
270 Simulator::Destroy();
282 cmd.AddValue (
"PacketSize",
"The size of each packet sent", input.
packetSize);
283 cmd.AddValue (
"TxMode",
"The mode to use to send each packet", input.
txMode);
284 cmd.AddValue (
"NPackets",
"The number of packets to send", input.
nPackets);
285 cmd.AddValue (
"TxPowerLevel",
"The power level index to use to send each packet", input.
txPowerLevel);
286 cmd.Parse (argc, argv);
289 output = experiment.
Run (input);
294 std::cout << psr << std::endl;
308 cmd.
AddValue (
"TxPowerLevel",
"The power level index to use to send each packet", input.
txPowerLevel);
309 cmd.AddValue (
"TxMode",
"The mode to use to send each packet", input.
txMode);
310 cmd.AddValue (
"NPackets",
"The number of packets to send", input.
nPackets);
311 cmd.AddValue (
"PacketSize",
"The size of each packet sent", input.
packetSize);
312 cmd.Parse (argc, argv);
319 input.
txMode =
"OfdmRate6Mbps";
320 output = experiment.
Run (input);
321 std::cout <<
" " <<
CalcPsr (output, input);
323 input.
txMode =
"OfdmRate9Mbps";
324 output = experiment.
Run (input);
325 std::cout <<
" " <<
CalcPsr (output, input);
327 input.
txMode =
"OfdmRate12Mbps";
328 output = experiment.
Run (input);
329 std::cout <<
" " <<
CalcPsr (output, input);
331 input.
txMode =
"OfdmRate18Mbps";
332 output = experiment.
Run (input);
333 std::cout <<
" " <<
CalcPsr (output, input);
335 input.
txMode =
"OfdmRate24Mbps";
336 output = experiment.
Run (input);
337 std::cout <<
" " <<
CalcPsr (output, input);
339 input.
txMode =
"OfdmRate36Mbps";
340 output = experiment.
Run (input);
341 std::cout <<
" " <<
CalcPsr (output, input);
343 input.
txMode =
"OfdmRate48Mbps";
344 output = experiment.
Run (input);
345 std::cout <<
" " <<
CalcPsr (output, input);
347 input.
txMode =
"OfdmRate54Mbps";
348 output = experiment.
Run (input);
349 std::cout <<
" " <<
CalcPsr (output, input);
351 std::cout << std::endl;
357 double targetPsr = 0.05;
360 cmd.
AddValue (
"TxPowerLevel",
"The power level index to use to send each packet", input.
txPowerLevel);
361 cmd.AddValue (
"TxMode",
"The mode to use to send each packet", input.
txMode);
362 cmd.AddValue (
"NPackets",
"The number of packets to send", input.
nPackets);
363 cmd.AddValue (
"TargetPsr",
"The psr needed to assume that we are within range", targetPsr);
364 cmd.Parse (argc, argv);
367 double precision = 0.1;
370 while (high - low > precision)
372 double middle = low + (high - low) / 2;
376 output = experiment.Run (input);
377 double psr =
CalcPsr (output, input);
378 if (psr >= targetPsr)
396 cmd.
AddValue (
"NPackets",
"The number of packets to send for each transmitter", input.
nPackets);
397 cmd.
AddValue (
"xA",
"the position of transmitter A", input.
xA);
398 cmd.
AddValue (
"xB",
"the position of transmitter B", input.
xB);
399 for (uint32_t i = 0; i < 100; i += 1)
404 output = experiment.
Run (input);
407 std::cout << i <<
" " << perA <<
" " << perB << std::endl;
409 for (uint32_t i = 100; i < 4000; i += 50)
414 output = experiment.
Run (input);
417 std::cout << i <<
" " << perA <<
" " << perB << std::endl;
423 int main (
int argc,
char *argv[])
427 std::cout <<
"Available experiments: "
431 <<
"PsrVsCollisionInterval "
435 std::string type = argv[1];
443 else if (type ==
"SizeVsRange")
447 else if (type ==
"PsrVsDistance")
451 else if (type ==
"PsrVsCollisionInterval")