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"
36 #include "ns3/wifi-tx-vector.h"
62 void
Receive (Ptr<Packet> p, double snr, WifiMode mode, enum WifiPreamble preamble);
71 Ptr<Packet> p = Create<Packet> (m_input.packetSize);
75 txVector.SetMode (mode);
90 txMode (
"OfdmRate6Mbps"),
109 channel->SetPropagationDelayModel (CreateObject<ConstantSpeedPropagationDelayModel> ());
111 channel->SetPropagationLossModel (log);
116 tx->SetErrorRateModel (error);
117 rx->SetErrorRateModel (error);
118 tx->SetChannel (channel);
119 rx->SetChannel (channel);
120 tx->SetMobility (posTx);
121 rx->SetMobility (posRx);
131 Simulator::Destroy();
162 void
SendA (void) const;
163 void
SendB (void) const;
164 void
Receive (Ptr<Packet> p, double snr, WifiMode mode, enum WifiPreamble preamble);
218 : interval (MicroSeconds (0)),
221 txModeA (
"OfdmRate6Mbps"),
222 txModeB (
"OfdmRate6Mbps"),
238 m_flowIdA = FlowIdTag::AllocateFlowId ();
239 m_flowIdB = FlowIdTag::AllocateFlowId ();
242 channel->SetPropagationDelayModel (CreateObject<ConstantSpeedPropagationDelayModel> ());
244 channel->SetPropagationLossModel (log);
258 txA->SetErrorRateModel (error);
259 txB->SetErrorRateModel (error);
260 rx->SetErrorRateModel (error);
261 txA->SetChannel (channel);
262 txB->SetChannel (channel);
263 rx->SetChannel (channel);
264 txA->SetMobility (posTxA);
265 txB->SetMobility (posTxB);
266 rx->SetMobility (posRx);
282 Simulator::Destroy();
294 cmd.AddValue (
"PacketSize",
"The size of each packet sent", input.
packetSize);
295 cmd.AddValue (
"TxMode",
"The mode to use to send each packet", input.
txMode);
296 cmd.AddValue (
"NPackets",
"The number of packets to send", input.
nPackets);
297 cmd.AddValue (
"TxPowerLevel",
"The power level index to use to send each packet", input.
txPowerLevel);
298 cmd.Parse (argc, argv);
301 output = experiment.
Run (input);
306 std::cout << psr << std::endl;
320 cmd.
AddValue (
"TxPowerLevel",
"The power level index to use to send each packet", input.
txPowerLevel);
321 cmd.AddValue (
"TxMode",
"The mode to use to send each packet", input.
txMode);
322 cmd.AddValue (
"NPackets",
"The number of packets to send", input.
nPackets);
323 cmd.AddValue (
"PacketSize",
"The size of each packet sent", input.
packetSize);
324 cmd.Parse (argc, argv);
331 input.
txMode =
"OfdmRate6Mbps";
332 output = experiment.
Run (input);
333 std::cout <<
" " <<
CalcPsr (output, input);
335 input.
txMode =
"OfdmRate9Mbps";
336 output = experiment.
Run (input);
337 std::cout <<
" " <<
CalcPsr (output, input);
339 input.
txMode =
"OfdmRate12Mbps";
340 output = experiment.
Run (input);
341 std::cout <<
" " <<
CalcPsr (output, input);
343 input.
txMode =
"OfdmRate18Mbps";
344 output = experiment.
Run (input);
345 std::cout <<
" " <<
CalcPsr (output, input);
347 input.
txMode =
"OfdmRate24Mbps";
348 output = experiment.
Run (input);
349 std::cout <<
" " <<
CalcPsr (output, input);
351 input.
txMode =
"OfdmRate36Mbps";
352 output = experiment.
Run (input);
353 std::cout <<
" " <<
CalcPsr (output, input);
355 input.
txMode =
"OfdmRate48Mbps";
356 output = experiment.
Run (input);
357 std::cout <<
" " <<
CalcPsr (output, input);
359 input.
txMode =
"OfdmRate54Mbps";
360 output = experiment.
Run (input);
361 std::cout <<
" " <<
CalcPsr (output, input);
363 std::cout << std::endl;
369 double targetPsr = 0.05;
372 cmd.
AddValue (
"TxPowerLevel",
"The power level index to use to send each packet", input.
txPowerLevel);
373 cmd.AddValue (
"TxMode",
"The mode to use to send each packet", input.
txMode);
374 cmd.AddValue (
"NPackets",
"The number of packets to send", input.
nPackets);
375 cmd.AddValue (
"TargetPsr",
"The psr needed to assume that we are within range", targetPsr);
376 cmd.Parse (argc, argv);
379 double precision = 0.1;
382 while (high - low > precision)
384 double middle = low + (high - low) / 2;
388 output = experiment.Run (input);
389 double psr =
CalcPsr (output, input);
390 if (psr >= targetPsr)
408 cmd.
AddValue (
"NPackets",
"The number of packets to send for each transmitter", input.
nPackets);
409 cmd.
AddValue (
"xA",
"the position of transmitter A", input.
xA);
410 cmd.
AddValue (
"xB",
"the position of transmitter B", input.
xB);
411 for (uint32_t i = 0; i < 100; i += 1)
416 output = experiment.
Run (input);
419 std::cout << i <<
" " << perA <<
" " << perB << std::endl;
421 for (uint32_t i = 100; i < 4000; i += 50)
426 output = experiment.
Run (input);
429 std::cout << i <<
" " << perA <<
" " << perB << std::endl;
435 int main (
int argc,
char *argv[])
439 std::cout <<
"Available experiments: "
443 <<
"PsrVsCollisionInterval "
447 std::string type = argv[1];
455 else if (type ==
"SizeVsRange")
459 else if (type ==
"PsrVsDistance")
463 else if (type ==
"PsrVsCollisionInterval")
bool FindFirstMatchingByteTag(Tag &tag) const
void experiment(bool enableCtsRts)
Run single 10 seconds experiment with enabled or disabled RTS/CTS mechanism.
keep track of time values and allow control of 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...
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
WifiPreamble
The type of preamble to be used by an IEEE 802.11 transmission.
static void PrintPsrVsDistance(int argc, char *argv[])
static void PrintPsrVsCollisionInterval(int argc, char *argv[])
double CalcPsr(struct PsrExperiment::Output output, struct PsrExperiment::Input input)
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
uint32_t GetFlowId(void) const
Gets the flow id for the tag.
static void PrintPsr(int argc, char *argv[])
Parse command-line arguments.
void SetTxPowerLevel(uint8_t powerlevel)
Sets the selected transmission power level.
struct PsrExperiment::Output Run(struct PsrExperiment::Input input)
void SetPosition(const Vector &position)
void SetMode(WifiMode mode)
Sets the selected payload transmission mode.
void Receive(Ptr< Packet > p, double snr, WifiMode mode, enum WifiPreamble preamble)
void AddValue(const std::string &name, const std::string &help, T &value)
Add a program argument, assigning to POD.
Doxygen introspection did not find any typical Config paths.
struct CollisionExperiment::Output Run(struct CollisionExperiment::Input input)
static void PrintSizeVsRange(int argc, char *argv[])
void Receive(Ptr< Packet > p, double snr, WifiMode mode, enum WifiPreamble preamble)
int main(int argc, char *argv[])
void AddByteTag(const Tag &tag) const
Tag each byte included in this packet with a new byte tag.