50#include "ns3/command-line.h"
51#include "ns3/config.h"
52#include "ns3/double.h"
53#include "ns3/internet-stack-helper.h"
54#include "ns3/ipv4-address-helper.h"
56#include "ns3/mobility-helper.h"
57#include "ns3/mobility-model.h"
58#include "ns3/neighbor-cache-helper.h"
60#include "ns3/string.h"
61#include "ns3/wifi-phy-rx-trace-helper.h"
62#include "ns3/yans-wifi-channel.h"
63#include "ns3/yans-wifi-helper.h"
78 while ((p = socket->Recv()))
80 NS_LOG_INFO(
"Received packet with size " << p->GetSize());
88 while ((p = socket->Recv()))
90 NS_LOG_INFO(
"Received packet on OBSS network with size " << p->GetSize());
139 bool logging =
false;
142 cmd.AddValue(
"packetSize",
"size of application packet sent",
packetSize);
143 cmd.AddValue(
"numPackets",
"number of packets generated",
numPackets);
144 cmd.AddValue(
"interval",
"interval between packets", interval);
145 cmd.AddValue(
"distance",
"distance between AP and STA", distance);
146 cmd.AddValue(
"enableTwoBss",
"enable a second BSS (not traced)",
enableTwoBss);
148 cmd.AddValue(
"logging",
"enable all wifi module log components", logging);
149 cmd.AddValue(
"verbose",
"enable this program's log components",
verbose);
154 std::cout <<
"No packets configured to be sent; exiting" << std::endl;
172 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
182 obssMobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
194 wifiChannel.AddPropagationLoss(
"ns3::FriisPropagationLossModel");
199 wifi.SetRemoteStationManager(
"ns3::ConstantRateWifiManager",
212 wifiMac.SetType(
"ns3::ApWifiMac",
227 wifiMac.SetType(
"ns3::ApWifiMac",
240 ipv4.SetBase(
"10.1.1.0",
"255.255.255.0");
246 ipv4.SetBase(
"10.1.2.0",
"255.255.255.0");
281 wifiPhy.EnablePcap(
"wifi-phy-rx-trace-example", devices);
283 wifiPhy.EnableAsciiAll(
asciiTrace.CreateFileStream(
"wifi-phy-rx-trace-example.tr"));
293 "WifiPhyRxTraceExample",
329 std::cout <<
"*** Print statistics for all nodes using built-in print method:" << std::endl;
331 std::cout << std::endl;
333 std::cout <<
"*** Print statistics for the STA only using built-in print method:" << std::endl;
335 std::cout << std::endl;
337 std::cout <<
"*** Print statistics for the AP only using built-in print method:" << std::endl;
339 std::cout << std::endl;
341 std::cout <<
"*** Get statistics object and print the fields one-by-one:" << std::endl;
343 std::cout <<
" overlapppingPpdu: " << stats.m_overlappingPpdus << std::endl;
344 std::cout <<
" nonOverlapppingPpdu: " << stats.m_nonOverlappingPpdus << std::endl;
345 std::cout <<
" receivedPpdus: " << stats.m_receivedPpdus << std::endl;
346 std::cout <<
" failedPpdus: " << stats.m_failedPpdus << std::endl;
347 std::cout <<
" receivedMpdus: " << stats.m_receivedMpdus << std::endl;
348 std::cout <<
" failedMpdus: " << stats.m_failedMpdus << std::endl;
349 std::cout << std::endl;
351 std::cout <<
"*** Get vector of reception records and print out some fields:" << std::endl;
356 std::cout <<
"*** Records vector has size of " <<
records.size() << std::endl;
360 std::cout <<
" First record:" << std::endl;
361 std::cout <<
" first PPDU's RSSI (dBm): " <<
records[0].m_rssi << std::endl;
362 std::cout <<
" first PPDU's receiver ID: " <<
records[0].m_receiverId << std::endl;
363 std::cout <<
" first PPDU's sender ID: " <<
records[0].m_senderId << std::endl;
364 std::cout <<
" first PPDU's start time: " <<
records[0].m_startTime.GetSeconds()
366 std::cout <<
" first PPDU's end time: " <<
records[0].m_endTime.GetSeconds()
368 std::cout <<
" first PPDU's number of MPDUs: " <<
records[0].m_statusPerMpdu.size()
370 std::cout <<
" first PPDU's sender device ID: " <<
records[0].m_senderDeviceId
376 std::cout <<
" Second record:" << std::endl;
377 std::cout <<
" second PPDU's RSSI (dBm): " <<
records[1].m_rssi << std::endl;
378 std::cout <<
" second PPDU's receiver ID: " <<
records[1].m_receiverId << std::endl;
379 std::cout <<
" second PPDU's sender ID: " <<
records[1].m_senderId << std::endl;
380 std::cout <<
" second PPDU's start time: " <<
records[1].m_startTime.GetSeconds()
382 std::cout <<
" second PPDU's end time: " <<
records[1].m_endTime.GetSeconds()
384 std::cout <<
" second PPDU's number of MPDUs: " <<
records[1].m_statusPerMpdu.size()
386 std::cout <<
" second PPDU's sender device ID: " <<
records[1].m_senderDeviceId
392 std::cout <<
" Third record:" << std::endl;
393 std::cout <<
" third PPDU's RSSI (dBm): " <<
records[2].m_rssi << std::endl;
394 std::cout <<
" third PPDU's receiver ID: " <<
records[2].m_receiverId << std::endl;
395 std::cout <<
" third PPDU's sender ID: " <<
records[2].m_senderId << std::endl;
396 std::cout <<
" third PPDU's start time: " <<
records[2].m_startTime.GetSeconds()
398 std::cout <<
" third PPDU's end time: " <<
records[2].m_endTime.GetSeconds()
400 std::cout <<
" third PPDU's number of MPDUs: " <<
records[2].m_statusPerMpdu.size()
402 std::cout <<
" third PPDU's sender device ID: " <<
records[2].m_senderDeviceId
405 std::cout << std::endl;
409 std::cout <<
"*** Records vector is empty" << std::endl;
410 std::cout << std::endl;
Manage ASCII trace files for device models.
Parse command-line arguments.
aggregate IP/TCP/UDP functionality to existing Nodes.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
Ipv4 addresses are stored in host order in this class.
static Ipv4Address GetAny()
holds a vector of std::pair of Ptr<Ipv4> and interface index.
Helper class used to assign positions and mobility models to nodes.
A helper class to populate neighbor cache.
void PopulateNeighborCache()
Populate neighbor ARP and NDISC caches for all devices.
holds a vector of ns3::NetDevice pointers
keep track of a set of node pointers.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Smart pointer class similar to boost::intrusive_ptr.
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 void ScheduleWithContext(uint32_t context, const Time &delay, FUNC f, Ts &&... args)
Schedule an event with the given context.
static void Run()
Run the simulation.
static void Stop()
Tell the Simulator the calling event should be the last one executed.
static Ptr< Socket > CreateSocket(Ptr< Node > node, TypeId tid)
This method wraps the creation of sockets that is performed on a given node by a SocketFactory specif...
The IEEE 802.11 SSID Information Element.
AttributeValue implementation for Ssid.
Hold variables of type string.
Simulation virtual time values and global simulation resolution.
AttributeValue implementation for Time.
a unique identifier for an interface.
static TypeId LookupByName(std::string name)
Get a TypeId by name.
helps to create WifiNetDevice objects
static void EnableLogComponents(LogLevel logLevel=LOG_LEVEL_ALL)
Helper to enable all WifiNetDevice log components with one statement.
create MAC layers for a ns3::WifiNetDevice.
void SetPcapDataLinkType(SupportedPcapDataLinkTypes dlt)
Set the data link type of PCAP traces to be used.
@ DLT_IEEE802_11_RADIO
Include Radiotap link layer information.
Assists in tracing and analyzing Wi-Fi Physical Layer (PHY) receptions.
void Enable(NodeContainer nodes)
Enables trace collection for all nodes and WifiNetDevices in the specified NodeContainer.
manage and create wifi channel objects for the YANS model.
void SetPropagationDelay(std::string name, Ts &&... args)
Make it easy to create and manage PHY objects for the YANS model.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Time Seconds(double value)
Construct a Time in the indicated unit.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
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...
LogLevel
Logging severity classes and levels.
@ LOG_LEVEL_ALL
Print everything.
@ LOG_PREFIX_FUNC
Prefix all trace prints with function.
@ LOG_PREFIX_TIME
Prefix all trace prints with simulation time.
@ LOG_PREFIX_NODE
Prefix all trace prints with simulation node.
@ LOG_LEVEL_INFO
LOG_INFO and above.
uint32_t pktSize
packet size used for the simulation (in bytes)
void ReceiveObssPacket(Ptr< Socket > socket)
static void GeneratePacket(Ptr< Socket > socket, uint32_t pktSize, uint32_t pktCount, Time pktInterval)
Generate traffic.
void ReceivePacket(Ptr< Socket > socket)
Function called when a packet is received.
void PopulateNeighborCache()
static const uint32_t packetSize
Packet size generated at the AP.