29 #include "ns3/ampdu-subframe-header.h"
30 #include "ns3/application-container.h"
31 #include "ns3/boolean.h"
32 #include "ns3/command-line.h"
33 #include "ns3/config.h"
34 #include "ns3/double.h"
35 #include "ns3/gnuplot.h"
36 #include "ns3/integer.h"
38 #include "ns3/mobility-helper.h"
39 #include "ns3/node-list.h"
40 #include "ns3/packet-socket-client.h"
41 #include "ns3/packet-socket-helper.h"
42 #include "ns3/packet-socket-server.h"
43 #include "ns3/propagation-delay-model.h"
44 #include "ns3/propagation-loss-model.h"
45 #include "ns3/queue-size.h"
46 #include "ns3/rng-seed-manager.h"
48 #include "ns3/string.h"
49 #include "ns3/uinteger.h"
50 #include "ns3/wifi-mac-header.h"
51 #include "ns3/wifi-mac.h"
52 #include "ns3/wifi-net-device.h"
53 #include "ns3/yans-wifi-helper.h"
58 #define PI 3.1415926535
74 std::map<Mac48Address, uint64_t>
76 std::map<Mac48Address, uint64_t>
78 std::map<Mac48Address, uint64_t>
82 std::map<Mac48Address, uint64_t>
87 std::map<Mac48Address, uint64_t>
90 std::map<Mac48Address, uint64_t>
93 std::map<Mac48Address, uint64_t>
96 std::map<Mac48Address, uint64_t>
100 std::map<Mac48Address, Time>
103 std::map<Mac48Address, Time>
119 std::map<std::string ,
120 std::map<
unsigned int ,
double >>
307 {
"ErpOfdmRate12Mbps",
320 {
"ErpOfdmRate18Mbps",
333 {
"ErpOfdmRate24Mbps",
346 {
"ErpOfdmRate36Mbps",
359 {
"ErpOfdmRate48Mbps",
372 {
"ErpOfdmRate54Mbps",
1013 std::map<std::string ,
1014 std::map<
unsigned int ,
double >>
1175 {
"ErpOfdmRate6Mbps",
1188 {
"ErpOfdmRate9Mbps",
1201 {
"ErpOfdmRate12Mbps",
1214 {
"ErpOfdmRate18Mbps",
1227 {
"ErpOfdmRate24Mbps",
1240 {
"ErpOfdmRate36Mbps",
1253 {
"ErpOfdmRate48Mbps",
1266 {
"ErpOfdmRate54Mbps",
1915 std::string sub = context.substr(10);
1916 uint32_t pos = sub.find(
"/Device");
1917 return std::stoi(sub.substr(0, pos));
1929 std::string sub = context.substr(10);
1930 uint32_t pos = sub.find(
"/Device");
1931 uint32_t nodeId = std::stoi(sub.substr(0, pos));
1957 uint64_t increment = 1)
1959 auto it = counter.find(addr);
1960 if (it != counter.end())
1962 it->second += increment;
1966 counter.insert(std::make_pair(addr, increment));
1984 uint16_t channelFreqMhz,
1994 uint32_t extractedLength;
1997 packet = packet->
CreateFragment(0,
static_cast<uint32_t
>(extractedLength));
2035 CwTrace(std::string context, uint32_t cw, uint8_t )
2056 <<
" val=" << newVal);
2060 << newVal << std::endl;
2090 <<
" psduDuration=" << psduDuration);
2104 <<
" size=" << p->
GetSize() <<
" reason=" << reason);
2160 NS_FATAL_ERROR(
"All devices should send with same power, so no packet switch during "
2161 "preamble detection should occur!");
2208 <<
" nMPDUs=" << +nMpdus <<
" snr=" << snr <<
" mode=" << mode
2209 <<
" preamble=" << preamble);
2214 NS_FATAL_ERROR(
"A-MPDU settings not properly applied: maximum configured MPDUs is "
2215 << +
maxMpdus <<
" but received an A-MPDU containing " << +nMpdus
2218 NS_LOG_WARN(
"Warning: less MPDUs aggregated in a received A-MPDU ("
2219 << +nMpdus <<
") than configured (" << +
maxMpdus <<
")");
2239 <<
" size=" << p->
GetSize() <<
" snr=" << snr);
2258 <<
" size=" << p->
GetSize() <<
" " << txPowerW);
2262 <<
" size=" << p->
GetSize() <<
" " << txPowerW << std::endl;
2329 <<
" " << p->
GetSize() <<
" " << addr << std::endl;
2420 uint32_t trialNumber,
2421 uint32_t networkSize,
2425 uint16_t guardIntervalNs,
2427 double apTxPowerDbm,
2428 double staTxPowerDbm,
2441 uint32_t trialNumber,
2442 uint32_t networkSize,
2446 uint16_t guardIntervalNs,
2448 double apTxPowerDbm,
2449 double staTxPowerDbm,
2458 wifiNodes.
Create(networkSize + 1);
2462 wifiNodes.
Create(networkSize);
2466 phy.SetErrorRateModel(
"ns3::NistErrorRateModel");
2473 uint32_t nNodes = wifiNodes.
GetN();
2477 uint64_t beaconInterval = std::min<uint64_t>(
2478 (ceil((duration.
GetSeconds() * 1000000) / 1024) * 1024),
2480 mac.SetType(
"ns3::ApWifiMac",
2489 mac.SetType(
"ns3::StaWifiMac",
2496 for (uint32_t i = 1; i < nNodes; ++i)
2503 mac.SetType(
"ns3::AdhocWifiMac");
2512 "/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/HtConfiguration/ShortGuardIntervalSupported",
2514 Config::Set(
"/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/HeConfiguration/GuardInterval",
2518 for (uint32_t i = 0; i < nNodes; ++i)
2534 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
2536 positionAlloc->Add(Vector(1.0, 1.0, 0.0));
2539 double angle = (
static_cast<double>(360) / (nNodes - 1));
2540 for (uint32_t i = 0; i < (nNodes - 1); ++i)
2542 positionAlloc->Add(Vector(1.0 + (distance * cos((i * angle *
PI) / 180)),
2543 1.0 + (distance * sin((i * angle *
PI) / 180)),
2547 mobility.SetPositionAllocator(positionAlloc);
2551 packetSocket.
Install(wifiNodes);
2558 uint32_t i = infra ? 1 : 0;
2559 for (; i < nNodes; ++i)
2561 uint32_t j = infra ? 0 : (i + 1) % nNodes;
2568 client->SetRemote(socketAddr);
2578 server->SetLocal(socketAddr);
2584 "/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/MonitorSnifferRx",
2590 Config::Connect(
"/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/$ns3::StaWifiMac/Assoc",
2592 Config::Connect(
"/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/$ns3::StaWifiMac/DeAssoc",
2597 StaticCast<WifiNetDevice>(wifiNodes.
Get(0)->
GetDevice(0))->GetMac()->GetQosSupported()
2601 Config::Connect(
"/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/$ns3::WifiMac/" + txop +
2605 Config::Connect(
"/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/$ns3::WifiMac/" + txop +
2609 Config::Connect(
"/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/PhyTxBegin",
2612 Config::Connect(
"/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/PhyTxEnd",
2615 Config::Connect(
"/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/PhyRxBegin",
2619 "/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/PhyRxPayloadBegin",
2622 Config::Connect(
"/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/PhyRxDrop",
2625 Config::Connect(
"/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/PhyRxEnd",
2628 Config::Connect(
"/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/State/RxError",
2631 Config::Connect(
"/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/State/RxOk",
2634 Config::Connect(
"/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/MacTx",
2637 Config::Connect(
"/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/MacRx",
2640 Config::Connect(
"/NodeList/*/$ns3::Node/ApplicationList/*/$ns3::PacketSocketClient/Tx",
2648 phy.EnablePcap(
"wifi_bianchi_pcap",
devices);
2678 auto it = counter.find(addr);
2679 if (it != counter.end())
2687 main(
int argc,
char* argv[])
2689 uint32_t nMinStas = 5;
2690 uint32_t nMaxStas = 50;
2691 uint32_t nStepSize = 5;
2693 double duration = 100;
2695 uint32_t trials = 1;
2698 std::string workDir =
"./";
2699 std::string phyMode =
2701 std::string standard(
"11a");
2702 bool validate =
false;
2704 uint16_t plotBianchiModel =
2706 double maxRelativeError =
2709 double frequency = 5;
2710 uint16_t channelWidth = 20;
2711 uint16_t guardIntervalNs = 800;
2713 uint16_t pktInterval =
2716 double distance = 0.001;
2717 double apTxPower = 16;
2718 double staTxPower = 16;
2732 "ns3::WifiMacQueue::MaxSize",
2737 cmd.AddValue(
"verbose",
2738 "Logging level (0: no log - 1: simulation script logs - 2: all logs)",
2740 cmd.AddValue(
"tracing",
"Generate trace files",
tracing);
2741 cmd.AddValue(
"pktSize",
"The packet size in bytes",
pktSize);
2742 cmd.AddValue(
"trials",
"The maximal number of runs per network size", trials);
2743 cmd.AddValue(
"duration",
"Time duration for each trial in seconds", duration);
2744 cmd.AddValue(
"pcap",
"Enable/disable PCAP tracing", pcap);
2745 cmd.AddValue(
"infra",
"True to use infrastructure mode, false to use ring adhoc mode", infra);
2746 cmd.AddValue(
"workDir",
"The working directory used to store generated files", workDir);
2747 cmd.AddValue(
"phyMode",
"Set the constant PHY mode string used to transmit frames", phyMode);
2748 cmd.AddValue(
"standard",
"Set the standard (11a, 11b, 11g, 11n, 11ac, 11ax)", standard);
2749 cmd.AddValue(
"nMinStas",
"Minimum number of stations to start with", nMinStas);
2750 cmd.AddValue(
"nMaxStas",
"Maximum number of stations to start with", nMaxStas);
2751 cmd.AddValue(
"nStepSize",
"Number of stations to add at each step", nStepSize);
2752 cmd.AddValue(
"plotBianchiModel",
2753 "First bit corresponds to the DIFS model, second bit to the EIFS model",
2755 cmd.AddValue(
"validate",
2756 "Enable/disable validation of the ns-3 simulations against the Bianchi model",
2758 cmd.AddValue(
"maxRelativeError",
2759 "The maximum relative error tolerated between ns-3 results and the Bianchi model "
2760 "(used for regression, i.e. when the validate flag is set)",
2762 cmd.AddValue(
"frequency",
"Set the operating frequency band in GHz: 2.4, 5 or 6", frequency);
2763 cmd.AddValue(
"channelWidth",
2764 "Set the constant channel width in MHz (only for 11n/ac/ax)",
2766 cmd.AddValue(
"guardIntervalNs",
2767 "Set the the guard interval in nanoseconds (800 or 400 for 11n/ac, 800 or 1600 or "
2770 cmd.AddValue(
"maxMpdus",
2771 "Set the maximum number of MPDUs in A-MPDUs (0 to disable MPDU aggregation)",
2773 cmd.AddValue(
"distance",
"Set the distance in meters between the AP and the STAs", distance);
2774 cmd.AddValue(
"apTxPower",
2775 "Set the transmit power of the AP in dBm (if infrastructure only)",
2777 cmd.AddValue(
"staTxPower",
2778 "Set the transmit power of each STA in dBm (or all STAs if adhoc)",
2780 cmd.AddValue(
"pktInterval",
"Set the socket packet interval in microseconds", pktInterval);
2781 cmd.Parse(argc, argv);
2793 NS_FATAL_ERROR(
"Failed to open file wifi-bianchi-backoff-trace.out");
2798 NS_FATAL_ERROR(
"Failed to open file wifi-bianchi-phy-tx-trace.out");
2803 NS_FATAL_ERROR(
"Failed to open file wifi-bianchi-mac-tx-trace.out");
2808 NS_FATAL_ERROR(
"Failed to open file wifi-bianchi-mac-rx-trace.out");
2813 NS_FATAL_ERROR(
"Failed to open file wifi-bianchi-socket-send-trace.out");
2830 std::stringstream phyModeStr;
2831 phyModeStr << phyMode;
2832 if (phyMode.find(
"Mcs") != std::string::npos)
2834 phyModeStr <<
"_" << channelWidth <<
"MHz";
2837 std::stringstream ss;
2838 ss <<
"wifi-" << standard <<
"-p-" <<
pktSize << (infra ?
"-infrastructure" :
"-adhoc") <<
"-r-"
2839 << phyModeStr.str() <<
"-min-" << nMinStas <<
"-max-" << nMaxStas <<
"-step-" << nStepSize
2840 <<
"-throughput.plt";
2841 std::ofstream throughputPlot(ss.str());
2843 ss <<
"wifi-" << standard <<
"-p-" <<
pktSize << (infra ?
"-infrastructure" :
"-adhoc") <<
"-r-"
2844 << phyModeStr.str() <<
"-min-" << nMinStas <<
"-max-" << nMaxStas <<
"-step-" << nStepSize
2845 <<
"-throughput.eps";
2849 if (standard ==
"11a")
2855 else if (standard ==
"11b")
2861 else if (standard ==
"11g")
2867 else if (standard ==
"11n")
2869 if (frequency == 2.4)
2873 else if (frequency == 5)
2879 NS_FATAL_ERROR(
"Unsupported frequency band " << frequency <<
" GHz for standard "
2883 else if (standard ==
"11ac")
2888 else if (standard ==
"11ax")
2890 if (frequency == 2.4)
2894 else if (frequency == 5)
2898 else if (frequency == 6)
2904 NS_FATAL_ERROR(
"Unsupported frequency band " << frequency <<
" GHz for standard "
2913 std::string channelStr =
"{0, " +
std::to_string(channelWidth) +
", BAND_" +
2914 (frequency == 2.4 ?
"2_4" : (frequency == 5 ?
"5" :
"6")) +
"GHZ, 0}";
2928 "ReferenceDistance",
2933 else if (frequency == 5)
2939 "ReferenceDistance",
2950 "ReferenceDistance",
2957 wifi.SetStandard(wifiStandard);
2958 wifi.SetRemoteStationManager(
"ns3::ConstantRateWifiManager",
2974 double averageThroughput;
2975 double throughputArray[trials];
2976 for (uint32_t n = nMinStas; n <= nMaxStas; n += nStepSize)
2978 averageThroughput = 0;
2980 for (uint32_t runIndex = 0; runIndex < trials; runIndex++)
2996 std::cout <<
"Trial " << runIndex + 1 <<
" of " << trials <<
"; " << phyModeStr.str()
2997 <<
" for " << n <<
" nodes " << std::endl;
3000 cwTraceFile <<
"# Trial " << runIndex + 1 <<
" of " << trials <<
"; "
3001 << phyModeStr.str() <<
" for " << n <<
" nodes" << std::endl;
3003 << phyModeStr.str() <<
" for " << n <<
" nodes" << std::endl;
3004 phyTxTraceFile <<
"# Trial " << runIndex + 1 <<
" of " << trials <<
"; "
3005 << phyModeStr.str() <<
" for " << n <<
" nodes" << std::endl;
3006 macTxTraceFile <<
"# Trial " << runIndex + 1 <<
" of " << trials <<
"; "
3007 << phyModeStr.str() <<
" for " << n <<
" nodes" << std::endl;
3008 macRxTraceFile <<
"# Trial " << runIndex + 1 <<
" of " << trials <<
"; "
3009 << phyModeStr.str() <<
" for " << n <<
" nodes" << std::endl;
3011 << phyModeStr.str() <<
" for " << n <<
" nodes" << std::endl;
3036 Time dataTransferDuration = last -
first;
3037 double nodeThroughput =
3038 (it->second * 8 /
static_cast<double>(dataTransferDuration.
GetMicroSeconds()));
3045 uint64_t nodeRxEventWhileDecodingPreamble =
3050 uint64_t nodeRxEvents = nodePhyHeaderFailures + nodePsduFailures + nodePsduSuccess +
3051 nodeRxEventWhileDecodingPreamble + nodeRxEventWhileRxing +
3052 nodeRxEventWhileTxing + nodeRxEventAbortedByTx;
3053 std::cout <<
"Node " << it->first <<
": TX packets " << nodeTxPackets
3054 <<
"; RX packets " << nodeRxPackets <<
"; PHY header failures "
3055 << nodePhyHeaderFailures <<
"; PSDU failures " << nodePsduFailures
3056 <<
"; PSDU success " << nodePsduSuccess
3057 <<
"; RX events while decoding preamble "
3058 << nodeRxEventWhileDecodingPreamble <<
"; RX events while RXing "
3059 << nodeRxEventWhileRxing <<
"; RX events while TXing "
3060 << nodeRxEventWhileTxing <<
"; RX events aborted by TX "
3061 << nodeRxEventAbortedByTx <<
"; total RX events " << nodeRxEvents
3062 <<
"; total events " << nodeTxPackets + nodeRxEvents <<
"; time first RX "
3063 <<
first <<
"; time last RX " << last <<
"; dataTransferDuration "
3064 << dataTransferDuration <<
"; throughput " << nodeThroughput <<
" Mbps"
3067 std::cout <<
"Total throughput: " <<
throughput <<
" Mbps" << std::endl;
3071 averageThroughput = averageThroughput / trials;
3073 bool rateFound =
false;
3074 double relativeErrorDifs = 0;
3075 double relativeErrorEifs = 0;
3080 auto it = itDifs->second.find(n);
3081 if (it != itDifs->second.end())
3083 relativeErrorDifs = (std::abs(averageThroughput - it->second) / it->second);
3084 std::cout <<
"Relative error (DIFS): " << 100 * relativeErrorDifs <<
"%"
3089 NS_FATAL_ERROR(
"No Bianchi results (DIFS) calculated for that number of stations!");
3096 auto it = itEifs->second.find(n);
3097 if (it != itEifs->second.end())
3099 relativeErrorEifs = (std::abs(averageThroughput - it->second) / it->second);
3100 std::cout <<
"Relative error (EIFS): " << 100 * relativeErrorEifs <<
"%"
3105 NS_FATAL_ERROR(
"No Bianchi results (EIFS) calculated for that number of stations!");
3108 if (!rateFound && validate)
3112 double relativeError =
std::min(relativeErrorDifs, relativeErrorEifs);
3113 if (validate && (relativeError > maxRelativeError))
3119 for (uint32_t i = 0; i < trials; ++i)
3121 stDev += pow(throughputArray[i] - averageThroughput, 2);
3123 stDev = sqrt(stDev / (trials - 1));
3124 dataset.
Add(n, averageThroughput, stDev);
3131 for (uint32_t i = nMinStas; i <= nMaxStas; i += nStepSize)
3134 auto it = itDifs->second.find(i);
3135 if (it != itDifs->second.end())
3139 datasetBianchiDifs.
Add(i, value);
3144 for (uint32_t i = nMinStas; i <= nMaxStas; i += nStepSize)
3146 datasetBianchiDifs.
Add(i, 0.0);
3153 for (uint32_t i = nMinStas; i <= nMaxStas; i += nStepSize)
3156 auto it = itEifs->second.find(i);
3157 if (it != itEifs->second.end())
3161 datasetBianchiEifs.
Add(i, value);
3166 for (uint32_t i = nMinStas; i <= nMaxStas; i += nStepSize)
3168 datasetBianchiEifs.
Add(i, 0.0);
3172 datasetBianchiEifs.
SetTitle(
"Bianchi (EIFS - lower bound)");
3173 datasetBianchiDifs.
SetTitle(
"Bianchi (DIFS - upper bound)");
3175 gnuplot.
SetTerminal(
"postscript eps color enh \"Times-BoldItalic\"");
3176 gnuplot.
SetLegend(
"Number of competing stations",
"Throughput (Mbps)");
3178 ss <<
"Frame size " <<
pktSize <<
" bytes";
3181 ss <<
"set xrange [" << nMinStas <<
":" << nMaxStas <<
"]\n"
3182 <<
"set xtics " << nStepSize <<
"\n"
3183 <<
"set grid xtics ytics\n"
3185 <<
"set style line 1 linewidth 5\n"
3186 <<
"set style line 2 linewidth 5\n"
3187 <<
"set style line 3 linewidth 5\n"
3188 <<
"set style line 4 linewidth 5\n"
3189 <<
"set style line 5 linewidth 5\n"
3190 <<
"set style line 6 linewidth 5\n"
3191 <<
"set style line 7 linewidth 5\n"
3192 <<
"set style line 8 linewidth 5\n"
3193 <<
"set style increment user";
3195 if (plotBianchiModel & 0x0001)
3197 datasetBianchiDifs.
SetTitle(
"Bianchi");
3200 if (plotBianchiModel & 0x0002)
3202 datasetBianchiEifs.
SetTitle(
"Bianchi");
3205 if (plotBianchiModel == 0x0003)
3207 datasetBianchiEifs.
SetTitle(
"Bianchi (EIFS - lower bound)");
3208 datasetBianchiDifs.
SetTitle(
"Bianchi (DIFS - upper bound)");
3211 throughputPlot.close();
WiFi adhoc experiment class.
Gnuplot2dDataset Run(const WifiHelper &wifi, const YansWifiPhyHelper &wifiPhy, const WifiMacHelper &wifiMac, const YansWifiChannelHelper &wifiChannel)
Run an experiment.
a polymophic address class
holds a vector of ns3::Application pointers.
Parse command-line arguments.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Class to represent a 2D points plot.
void SetErrorBars(enum ErrorBars errorBars)
void SetStyle(enum Style style)
void Add(double x, double y)
void SetTitle(const std::string &title)
Change line title.
a simple class to generate gnuplot-ready plotting commands from a set of datasets.
void AddDataset(const GnuplotDataset &dataset)
void SetLegend(const std::string &xLegend, const std::string &yLegend)
void SetTerminal(const std::string &terminal)
void GenerateOutput(std::ostream &os)
Writes gnuplot commands and data values to a single output stream.
void SetExtra(const std::string &extra)
void SetTitle(const std::string &title)
Hold a signed integer type.
static Mac48Address ConvertFrom(const Address &address)
Helper class used to assign positions and mobility models to nodes.
holds a vector of ns3::NetDevice pointers
keep track of a set of node pointers.
uint32_t GetN() const
Get the number of Ptr<Node> stored in this container.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
uint32_t GetNDevices() const
uint32_t AddApplication(Ptr< Application > application)
Associate an Application to this Node.
Ptr< NetDevice > GetDevice(uint32_t index) const
Retrieve the index-th NetDevice associated to this node.
static Ptr< Node > GetNode(uint32_t n)
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
uint32_t GetSize() const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Ptr< Packet > Copy() const
performs a COW copy of the packet.
uint32_t PeekHeader(Header &header) const
Deserialize but does not remove the header from the internal buffer.
Ptr< Packet > CreateFragment(uint32_t start, uint32_t length) const
Create a new packet which contains a fragment of the original packet.
an address for a packet socket
void SetProtocol(uint16_t protocol)
Set the protocol.
void SetPhysicalAddress(const Address address)
Set the destination address.
void SetSingleDevice(uint32_t device)
Set the address to match only a specified NetDevice.
Give ns3::PacketSocket powers to ns3::Node.
void Install(Ptr< Node > node) const
Aggregate an instance of a ns3::PacketSocketFactory onto the provided node.
Class for representing queue sizes.
static void SetRun(uint64_t run)
Set the run number of simulation.
static void SetSeed(uint32_t seed)
Set the seed.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
static Time Now()
Return the current simulation virtual time.
static void Run()
Run the simulation.
static void Stop()
Tell the Simulator the calling event should be the last one executed.
The IEEE 802.11 SSID Information Element.
Hold variables of type string.
Simulation virtual time values and global simulation resolution.
double GetSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
int64_t GetMicroSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
Hold an unsigned integer type.
helps to create WifiNetDevice objects
static void EnableLogComponents()
Helper to enable all WifiNetDevice log components with one statement.
create MAC layers for a ns3::WifiNetDevice.
represent a single transmission mode
Hold together all Wifi-related objects.
Ptr< WifiMac > GetMac() const
Address GetAddress() const override
void DisablePreambleDetectionModel()
Disable the preamble detection model on all links.
@ DLT_IEEE802_11_RADIO
Include Radiotap link layer information.
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
bool IsAggregation() const
Checks whether the PSDU contains A-MPDU.
manage and create wifi channel objects for the YANS model.
void SetPropagationDelay(std::string name, Ts &&... args)
void AddPropagationLoss(std::string name, Ts &&... args)
Ptr< YansWifiChannel > Create() const
Make it easy to create and manage PHY objects for the YANS model.
void experiment(std::string queue_disc_type)
void SetDefault(std::string name, const AttributeValue &value)
void Connect(std::string path, const CallbackBase &cb)
void Set(std::string path, const AttributeValue &value)
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
@ PACKETS
Use number of packets for queue size.
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Time NanoSeconds(uint64_t value)
Construct a Time in the indicated unit.
Time Seconds(double value)
Construct a Time in the indicated unit.
WifiStandard
Identifies the IEEE 802.11 specifications that a Wifi device can be configured to use.
WifiPhyRxfailureReason
Enumeration of the possible reception failure reasons.
WifiPreamble
The type of preamble to be used by an IEEE 802.11 transmission.
@ PREAMBLE_DETECT_FAILURE
@ FRAME_CAPTURE_PACKET_SWITCH
@ RECEPTION_ABORTED_BY_TX
@ PREAMBLE_DETECTION_PACKET_SWITCH
NLOHMANN_BASIC_JSON_TPL_DECLARATION std::string to_string(const NLOHMANN_BASIC_JSON_TPL &j)
user-defined to_string function for JSON values
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void LogComponentEnable(const std::string &name, LogLevel level)
Enable the logging output associated with that log component.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
std::map< WifiSpectrumBandInfo, double > RxPowerWattPerChannelBand
A map of the received power (Watts) for each band.
@ LOG_LEVEL_ALL
Print everything.
@ LOG_LEVEL_WARN
LOG_WARN and above.
SignalNoiseDbm structure.
std::map< Mac48Address, uint64_t > rxEventAbortedByTx
Map that stores the number of reception events aborted per STA because the PHY has started to transmi...
void BackoffTrace(std::string context, uint32_t newVal, uint8_t)
Backoff trace.
std::map< Mac48Address, uint64_t > rxEventWhileTxing
Map that stores the number of reception events per STA that occurred while PHY was already transmitti...
void PhyRxErrorTrace(std::string context, Ptr< const Packet > p, double snr)
PHY RX error trace.
std::map< Mac48Address, uint64_t > packetsReceived
Map that stores the total packets received per STA (and addressed to that STA)
std::ofstream backoffTraceFile
File that traces backoff over time.
void RestartCalc()
Reset the stats.
std::map< Mac48Address, uint64_t > bytesReceived
Map that stores the total bytes received per STA (and addressed to that STA)
std::map< Mac48Address, uint64_t > rxEventWhileDecodingPreamble
Map that stores the number of reception events per STA that occurred while PHY was already decoding a...
void AssociationLog(std::string context, Mac48Address address)
Association log trace.
void SocketSendTrace(std::string context, Ptr< const Packet > p, const Address &addr)
Socket send trace.
bool tracing
Flag to enable/disable generation of tracing files.
void CwTrace(std::string context, uint32_t cw, uint8_t)
Contention window trace.
uint32_t ContextToNodeId(std::string context)
Parse context strings of the form "/NodeList/x/DeviceList/x/..." to extract the NodeId integer.
std::map< Mac48Address, uint64_t > rxEventWhileRxing
Map that stores the number of reception events per STA that occurred while PHY was already receiving ...
void TracePacketReception(std::string context, Ptr< const Packet > p, uint16_t channelFreqMhz, WifiTxVector txVector, MpduInfo aMpdu, SignalNoiseDbm signalNoise, uint16_t staId)
Trace a packet reception.
void PhyRxDropTrace(std::string context, Ptr< const Packet > p, WifiPhyRxfailureReason reason)
PHY Drop trace.
void PhyTxTrace(std::string context, Ptr< const Packet > p, double txPowerW)
PHY TX trace.
std::map< Mac48Address, uint64_t > psduFailed
Map that stores the total number of unsuccessfuly received PSDUS (for which the PHY header was succes...
#define PI
Avoid std::numbers::pi because it's C++20.
std::map< Mac48Address, uint64_t > packetsTransmitted
Map that stores the total packets transmitted per STA.
std::map< std::string, std::map< unsigned int, double > > bianchiResultsDifs
Table of the expected values for DIFS.
std::map< Mac48Address, Time > timeLastReceived
Map that stores the time at which the last packet was received per STA (and the packet is addressed t...
std::map< Mac48Address, Time > timeFirstTransmitted
Map that stores the time at which the first packet was transmitted per STA.
uint8_t maxMpdus
The maximum number of MPDUs in A-MPDUs (0 to disable MPDU aggregation)
void PhyRxDoneTrace(std::string context, Ptr< const Packet > p)
PHY RX end trace.
std::set< uint32_t > associated
Contains the IDs of the STAs that successfully associated to the access point (in infrastructure mode...
std::map< Mac48Address, uint64_t > phyHeaderFailed
Map that stores the total number of unsuccessfuly received PHY headers per STA.
void MacTxTrace(std::string context, Ptr< const Packet > p)
MAC TX trace.
std::ofstream socketSendTraceFile
File that traces packets transmitted by the application over time.
uint64_t GetCount(const std::map< Mac48Address, uint64_t > &counter, Mac48Address addr)
Get the Counter associated with a MAC address.
std::ofstream macTxTraceFile
File that traces MAC transmissions over time.
void PhyRxTrace(std::string context, Ptr< const Packet > p, RxPowerWattPerChannelBand power)
PHY Rx trace.
std::ofstream phyTxTraceFile
File that traces PHY transmissions over time.
void IncrementCounter(std::map< Mac48Address, uint64_t > &counter, Mac48Address addr, uint64_t increment=1)
Incremement the counter for a given address.
std::map< Mac48Address, Time > timeFirstReceived
Map that stores the time at which the first packet was received per STA (and the packet is addressed ...
uint32_t pktSize
packet size used for the simulation (in bytes)
std::map< Mac48Address, uint64_t > psduSucceeded
Map that stores the total number of successfully received PSDUs per STA (including PSDUs not addresse...
std::map< Mac48Address, Time > timeLastTransmitted
Map that stores the time at which the last packet was transmitted per STA.
std::map< std::string, std::map< unsigned int, double > > bianchiResultsEifs
Table of the expected values for EIFS.
void MacRxTrace(std::string context, Ptr< const Packet > p)
MAC RX trace.
void PhyTxDoneTrace(std::string context, Ptr< const Packet > p)
PHY TX end trace.
void PhyRxPayloadTrace(std::string context, WifiTxVector txVector, Time psduDuration)
PHY Rx trace.
Mac48Address ContextToMac(std::string context)
Parse context strings of the form "/NodeList/x/DeviceList/x/..." and fetch the Mac address.
void PhyRxOkTrace(std::string context, Ptr< const Packet > p, double snr, WifiMode mode, WifiPreamble preamble)
PHY successful RX trace.
void DisassociationLog(std::string context, Mac48Address address)
Deassociation log trace.
std::ofstream cwTraceFile
File that traces CW over time.
std::ofstream macRxTraceFile
File that traces MAC receptions over time.