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, double snr, WifiTxVector txVector, std::vector<bool> statusPerMpdu);
88 m_tx->Send (psdu, txVector);
102 txMode (
"OfdmRate6Mbps"),
121 channel->SetPropagationDelayModel (CreateObject<ConstantSpeedPropagationDelayModel> ());
123 channel->SetPropagationLossModel (log);
129 rx->SetErrorRateModel (error);
133 rx->SetMobility (posRx);
146 Simulator::Destroy ();
185 void
SendA (void) const;
187 void
SendB (void) const;
195 void
Receive (Ptr<WifiPsdu> psdu, double snr, WifiTxVector txVector, std::vector<bool> statusPerMpdu);
208 (*psdu->
begin ())->GetPacket ()->AddByteTag (
FlowIdTag (m_flowIdA));
213 m_txA->Send (psdu, txVector);
220 (*psdu->
begin ())->GetPacket ()->AddByteTag (
FlowIdTag (m_flowIdB));
225 m_txB->Send (psdu, txVector);
232 if ((*psdu->
begin ())->GetPacket ()->FindFirstMatchingByteTag (tag))
252 txModeA (
"OfdmRate6Mbps"),
253 txModeB (
"OfdmRate6Mbps"),
269 m_flowIdA = FlowIdTag::AllocateFlowId ();
270 m_flowIdB = FlowIdTag::AllocateFlowId ();
273 channel->SetPropagationDelayModel (CreateObject<ConstantSpeedPropagationDelayModel> ());
275 channel->SetPropagationLossModel (log);
290 txB->SetErrorRateModel (error);
291 rx->SetErrorRateModel (error);
296 txB->SetMobility (posTxB);
297 rx->SetMobility (posRx);
316 Simulator::Destroy ();
327 cmd.AddValue (
"Distance",
"The distance between two phys", input.
distance);
328 cmd.AddValue (
"PacketSize",
"The size of each packet sent", input.
packetSize);
329 cmd.AddValue (
"TxMode",
"The mode to use to send each packet", input.
txMode);
330 cmd.AddValue (
"NPackets",
"The number of packets to send", input.
nPackets);
331 cmd.AddValue (
"TxPowerLevel",
"The power level index to use to send each packet", input.
txPowerLevel);
332 cmd.Parse (argc, argv);
337 double psr = output.received;
340 std::cout << psr << std::endl;
354 cmd.AddValue (
"TxPowerLevel",
"The power level index to use to send each packet", input.
txPowerLevel);
355 cmd.AddValue (
"TxMode",
"The mode to use to send each packet", input.
txMode);
356 cmd.AddValue (
"NPackets",
"The number of packets to send", input.
nPackets);
357 cmd.AddValue (
"PacketSize",
"The size of each packet sent", input.
packetSize);
358 cmd.Parse (argc, argv);
366 input.
txMode =
"OfdmRate6Mbps";
368 std::cout <<
" " <<
CalcPsr (output, input);
370 input.
txMode =
"OfdmRate9Mbps";
372 std::cout <<
" " <<
CalcPsr (output, input);
374 input.
txMode =
"OfdmRate12Mbps";
376 std::cout <<
" " <<
CalcPsr (output, input);
378 input.
txMode =
"OfdmRate18Mbps";
380 std::cout <<
" " <<
CalcPsr (output, input);
382 input.
txMode =
"OfdmRate24Mbps";
384 std::cout <<
" " <<
CalcPsr (output, input);
386 input.
txMode =
"OfdmRate36Mbps";
388 std::cout <<
" " <<
CalcPsr (output, input);
390 input.
txMode =
"OfdmRate48Mbps";
392 std::cout <<
" " <<
CalcPsr (output, input);
394 input.
txMode =
"OfdmRate54Mbps";
396 std::cout <<
" " <<
CalcPsr (output, input);
398 std::cout << std::endl;
404 double targetPsr = 0.05;
407 cmd.AddValue (
"TxPowerLevel",
"The power level index to use to send each packet", input.
txPowerLevel);
408 cmd.AddValue (
"TxMode",
"The mode to use to send each packet", input.
txMode);
409 cmd.AddValue (
"NPackets",
"The number of packets to send", input.
nPackets);
410 cmd.AddValue (
"TargetPsr",
"The psr needed to assume that we are within range", targetPsr);
411 cmd.Parse (argc, argv);
415 double precision = 0.1;
418 while (high - low > precision)
420 double middle = low + (high - low) / 2;
425 double psr =
CalcPsr (output, input);
426 if (psr >= targetPsr)
444 cmd.AddValue (
"NPackets",
"The number of packets to send for each transmitter", input.
nPackets);
445 cmd.AddValue (
"xA",
"the position of transmitter A", input.
xA);
446 cmd.AddValue (
"xB",
"the position of transmitter B", input.
xB);
447 cmd.Parse (argc, argv);
449 for (uint32_t i = 0; i < 100; i += 1)
457 std::cout << i <<
" " << perA <<
" " << perB << std::endl;
459 for (uint32_t i = 100; i < 4000; i += 50)
467 std::cout << i <<
" " << perA <<
" " << perB << std::endl;
472 int main (
int argc,
char *argv[])
476 std::cout <<
"Available experiments: " 480 <<
"PsrVsCollisionInterval " 484 std::string type = argv[1];
492 else if (type ==
"SizeVsRange")
496 else if (type ==
"PsrVsDistance")
500 else if (type ==
"PsrVsCollisionInterval")
506 std::cout <<
"Wrong arguments!" << std::endl;
static void Send(Ptr< NetDevice > dev, int level, std::string emuMode)
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...
static const uint32_t packetSize
void SetChannel(const Ptr< YansWifiChannel > channel)
Set the YansWifiChannel this YansWifiPhy is to be connected to.
struct Output m_output
output
virtual void ConfigureStandardAndBand(WifiPhyStandard standard, WifiPhyBand band)
Configure the PHY-level parameters for different Wi-Fi standard.
void SendB(void) const
Send B function.
struct Output m_output
output
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
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.
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.
uint32_t received
received
void experiment(std::string queue_disc_type)
struct Input m_input
input
void Receive(Ptr< WifiPsdu > psdu, double snr, WifiTxVector txVector, std::vector< bool > statusPerMpdu)
Receive function.
Introspection did not find any typical Config paths.
Ptr< WifiPhy > m_tx
transmit
Time Seconds(double value)
Construct a Time in the indicated unit.
std::vector< Ptr< WifiMacQueueItem > >::const_iterator begin(void) const
Return a const iterator to the first MPDU.
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.
uint32_t GetFlowId(void) const
Gets the flow id for the tag.
void Receive(Ptr< WifiPsdu > psdu, double snr, WifiTxVector txVector, std::vector< bool > statusPerMpdu)
Send receive function.
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
struct Input m_input
input