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);
157 void
SendA (void) const;
158 void
SendB (void) const;
159 void
Receive (Ptr<Packet> p, double snr, WifiMode mode, enum WifiPreamble preamble);
208 txModeA (
"OfdmRate6Mbps"),
209 txModeB (
"OfdmRate6Mbps"),
225 m_flowIdA = FlowIdTag::AllocateFlowId ();
226 m_flowIdB = FlowIdTag::AllocateFlowId ();
231 channel->SetPropagationLossModel (log);
245 txA->SetErrorRateModel (error);
246 txB->SetErrorRateModel (error);
247 rx->SetErrorRateModel (error);
248 txA->SetChannel (channel);
249 txB->SetChannel (channel);
250 rx->SetChannel (channel);
251 txA->SetMobility (posTxA);
252 txB->SetMobility (posTxB);
253 rx->SetMobility (posRx);
280 cmd.AddValue (
"PacketSize",
"The size of each packet sent", input.
packetSize);
281 cmd.AddValue (
"TxMode",
"The mode to use to send each packet", input.
txMode);
282 cmd.AddValue (
"NPackets",
"The number of packets to send", input.
nPackets);
283 cmd.AddValue (
"TxPowerLevel",
"The power level index to use to send each packet", input.
txPowerLevel);
284 cmd.Parse (argc, argv);
287 output = experiment.
Run (input);
292 std::cout << psr << std::endl;
306 cmd.
AddValue (
"TxPowerLevel",
"The power level index to use to send each packet", input.
txPowerLevel);
307 cmd.AddValue (
"TxMode",
"The mode to use to send each packet", input.
txMode);
308 cmd.AddValue (
"NPackets",
"The number of packets to send", input.
nPackets);
309 cmd.AddValue (
"PacketSize",
"The size of each packet sent", input.
packetSize);
310 cmd.Parse (argc, argv);
317 input.
txMode =
"OfdmRate6Mbps";
318 output = experiment.
Run (input);
319 std::cout <<
" " <<
CalcPsr (output, input);
321 input.
txMode =
"OfdmRate9Mbps";
322 output = experiment.
Run (input);
323 std::cout <<
" " <<
CalcPsr (output, input);
325 input.
txMode =
"OfdmRate12Mbps";
326 output = experiment.
Run (input);
327 std::cout <<
" " <<
CalcPsr (output, input);
329 input.
txMode =
"OfdmRate18Mbps";
330 output = experiment.
Run (input);
331 std::cout <<
" " <<
CalcPsr (output, input);
333 input.
txMode =
"OfdmRate24Mbps";
334 output = experiment.
Run (input);
335 std::cout <<
" " <<
CalcPsr (output, input);
337 input.
txMode =
"OfdmRate36Mbps";
338 output = experiment.
Run (input);
339 std::cout <<
" " <<
CalcPsr (output, input);
341 input.
txMode =
"OfdmRate48Mbps";
342 output = experiment.
Run (input);
343 std::cout <<
" " <<
CalcPsr (output, input);
345 input.
txMode =
"OfdmRate54Mbps";
346 output = experiment.
Run (input);
347 std::cout <<
" " <<
CalcPsr (output, input);
349 std::cout << std::endl;
355 double targetPsr = 0.05;
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 (
"TargetPsr",
"The psr needed to assume that we are within range", targetPsr);
362 cmd.Parse (argc, argv);
365 double precision = 0.1;
368 while (high - low > precision)
370 double middle = low + (high - low) / 2;
374 output = experiment.Run (input);
375 double psr =
CalcPsr (output, input);
376 if (psr >= targetPsr)
394 cmd.
AddValue (
"NPackets",
"The number of packets to send for each transmitter", input.
nPackets);
395 cmd.
AddValue (
"xA",
"the position of transmitter A", input.
xA);
396 cmd.
AddValue (
"xB",
"the position of transmitter B", input.
xB);
397 for (uint32_t i = 0; i < 100; i += 1)
402 output = experiment.
Run (input);
405 std::cout << i <<
" " << perA <<
" " << perB << std::endl;
407 for (uint32_t i = 100; i < 4000; i += 50)
412 output = experiment.
Run (input);
415 std::cout << i <<
" " << perA <<
" " << perB << std::endl;
421 int main (
int argc,
char *argv[])
425 std::cout <<
"Available experiments: "
429 <<
"PsrVsCollisionInterval "
433 std::string type = argv[1];
441 else if (type ==
"SizeVsRange")
445 else if (type ==
"PsrVsDistance")
449 else if (type ==
"PsrVsCollisionInterval")