20 #include "ns3/config.h"
21 #include "ns3/data-rate.h"
22 #include "ns3/mobility-helper.h"
23 #include "ns3/mobility-model.h"
24 #include "ns3/ocb-wifi-mac.h"
25 #include "ns3/packet-socket-address.h"
26 #include "ns3/packet-socket-client.h"
27 #include "ns3/packet-socket-helper.h"
28 #include "ns3/packet-socket-server.h"
29 #include "ns3/position-allocator.h"
30 #include "ns3/qos-txop.h"
31 #include "ns3/rng-seed-manager.h"
32 #include "ns3/sta-wifi-mac.h"
33 #include "ns3/string.h"
35 #include "ns3/vector.h"
36 #include "ns3/wave-mac-helper.h"
37 #include "ns3/wifi-80211p-helper.h"
38 #include "ns3/wifi-net-device.h"
39 #include "ns3/yans-wifi-helper.h"
50 int64_t currentStream = stream;
52 if (!
mac->GetQosSupported())
54 mac->GetAttribute(
"Txop", ptr);
60 mac->GetAttribute(
"VO_Txop", ptr);
64 mac->GetAttribute(
"VI_Txop", ptr);
68 mac->GetAttribute(
"BE_Txop", ptr);
72 mac->GetAttribute(
"BK_Txop", ptr);
91 void DoRun()
override;
130 Vector GetCurrentPosition(uint32_t i);
138 void PreRandomConfiguration();
179 :
TestCase(
"Association time: Ap+Sta mode vs Adhoc mode vs Ocb mode")
193 Vector pos =
mobility->GetPosition();
213 Vector pos =
mobility->GetPosition();
281 wifi.SetRemoteStationManager(
"ns3::ConstantRateWifiManager",
286 wifi.Install(wifiPhy, wifiStaMac, mobile_node);
287 wifi.Install(wifiPhy, wifiApMac, static_node);
298 wifiMac.
SetType(
"ns3::AdhocWifiMac");
302 wifi.SetRemoteStationManager(
"ns3::ConstantRateWifiManager",
307 wifi.Install(wifiPhy, wifiMac, mobile_node);
308 wifi.Install(wifiPhy, wifiMac, static_node);
326 wifi80211p.
Install(wifiPhy, wifi80211pMac, mobile_node);
327 wifi80211p.
Install(wifiPhy, wifi80211pMac, static_node);
362 packetSocket.
Install(static_node);
363 packetSocket.
Install(mobile_node);
366 client->SetRemote(socket);
368 client->SetStartTime(
Seconds(0.5));
369 client->SetStopTime(
Seconds(70.0));
372 server->SetLocal(socket);
374 server->SetStartTime(
Seconds(0.0));
375 server->SetStopTime(
Seconds(70.5));
380 if (DynamicCast<StaWifiMac>(mobile_device->
GetMac()))
408 std::cout <<
"test time point for Ap-Sta mode" << std::endl;
416 Simulator::Stop(
Seconds(71.0));
418 Simulator::Destroy();
422 "In Sta mode with AP, you cannot associate until receive beacon or AssocResponse frame");
425 "In Sta mode with AP, you cannot send data packet until associate");
434 std::cout <<
"test time point for Adhoc mode" << std::endl;
442 Simulator::Stop(
Seconds(71.0));
444 Simulator::Destroy();
455 std::cout <<
"test time point for Ocb mode" << std::endl;
463 Simulator::Stop(
Seconds(71.0));
465 Simulator::Destroy();
468 "In Ocb mode, there is no associate state machine");
471 "before mobile node receives frames from far static node, it can send "
472 "data packet directly");
482 RngSeedManager::SetSeed(1);
483 RngSeedManager::SetRun(17);
Time phytx_time
Phy transmit time.
void PhyTxTrace(std::string context, Ptr< const Packet > packet, WifiMode mode, WifiPreamble preamble, uint8_t txPower)
Phy transmit trace function.
Vector macassoc_pos
MAC associate position.
void PhyRxOkTrace(std::string context, Ptr< const Packet > packet, double snr, WifiMode mode, WifiPreamble preamble)
Phy receive ok trace function.
void ConfigureApStaMode(Ptr< Node > static_node, Ptr< Node > mobile_node)
Configure AP STA mode function.
void PostDeviceConfiguration(Ptr< Node > static_node, Ptr< Node > mobile_node)
Post device configuration function.
~OcbWifiMacTestCase() override
Vector GetCurrentPosition(uint32_t i)
Get current position function.
void DoRun() override
static-node:0 <-— mobile-node:1
Time macassoc_time
MAC associate time.
void ConfigureAdhocMode(Ptr< Node > static_node, Ptr< Node > mobile_node)
Configure adhoc mode function.
void MacAssoc(std::string context, Mac48Address bssid)
MAC associate function.
void AdvancePosition(Ptr< Node > node)
Advance position function.
void ConfigureOcbMode(Ptr< Node > static_node, Ptr< Node > mobile_node)
Configure OCB mode function.
Vector phytx_pos
Phy transmit position.
NodeContainer nodes
the nodes
Time phyrx_time
Phy receive time.
Vector phyrx_pos
Phy receive position.
void PreRandomConfiguration()
Pre random configuration function.
Helper class used to assign positions and mobility models to nodes.
Keep track of the current position and velocity of an object.
Vector GetPosition() const
void SetPosition(const Vector &position)
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.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
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.
Nqos Wave Mac Helper class.
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
uint32_t PeekHeader(Header &header) const
Deserialize but does not remove the header from the internal buffer.
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.
Hold objects of type Ptr<T>.
Handle packet fragmentation and retransmissions for QoS data frames as well as MSDU aggregation (A-MS...
The IEEE 802.11 SSID Information Element.
AttributeValue implementation for Ssid.
Hold variables of type string.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Simulation virtual time values and global simulation resolution.
int64_t GetNanoSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
TimeWithUnit As(const Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
Handle packet fragmentation and retransmissions for data and management frames.
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
Vector3D Vector
Vector alias typedef for compatibility with mobility models.
helps to create wifi 802.11p objects of WifiNetDevice class
NetDeviceContainer Install(const WifiPhyHelper &phy, const WifiMacHelper &macHelper, NodeContainer c) const override
helps to create WifiNetDevice objects
void SetRemoteStationManager(std::string type, Args &&... args)
Helper function used to set the station manager.
create MAC layers for a ns3::WifiNetDevice.
void SetType(std::string type, Args &&... args)
represent a single transmission mode
Ptr< WifiMac > GetMac() const
uint32_t GetIfIndex() const override
Address GetAddress() const override
manage and create wifi channel objects for the YANS model.
Ptr< YansWifiChannel > Create() const
Make it easy to create and manage PHY objects for the YANS model.
void SetChannel(Ptr< YansWifiChannel > channel)
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
void Connect(std::string path, const CallbackBase &cb)
Time Now()
create an ns3::Time instance which contains the current simulation time.
#define NS_TEST_ASSERT_MSG_LT(actual, limit, msg)
Test that an actual value is less than a limit and report and abort if not.
#define NS_TEST_ASSERT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report and abort if not.
#define NS_TEST_ASSERT_MSG_GT(actual, limit, msg)
Test that an actual value is greater than a limit and report and abort if not.
Time Seconds(double value)
Construct a Time in the indicated unit.
WifiPreamble
The type of preamble to be used by an IEEE 802.11 transmission.
void(* Time)(Time oldValue, Time newValue)
TracedValue callback signature for Time.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
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...
static void AssignWifiRandomStreams(Ptr< WifiMac > mac, int64_t stream)
static OcbTestSuite ocbTestSuite
the test suite
void PhyRxOkTrace(std::string context, Ptr< const Packet > packet, double snr, WifiMode mode, WifiPreamble preamble)
PHY-level RX OK trace.
void PhyTxTrace(std::string context, Ptr< const Packet > packet, WifiMode mode, WifiPreamble preamble, uint8_t txPower)
PHY-level TX trace.
static void AdvancePosition(Ptr< Node > node)
Move a node position by 5m on the x axis every second, up to 210m.