17 #include "ns3/config.h"
18 #include "ns3/mobility-helper.h"
19 #include "ns3/mobility-model.h"
20 #include "ns3/node-list.h"
21 #include "ns3/string.h"
23 #include "ns3/wave-helper.h"
24 #include "ns3/wave-mac-helper.h"
25 #include "ns3/wave-net-device.h"
26 #include "ns3/yans-wifi-helper.h"
59 void NotifyCchStartNow(
Time duration);
64 void NotifySchStartNow(
Time duration);
70 void NotifyGuardStartNow(
Time duration,
bool inCchInterval);
79 void TestIntervalAfter(
bool cchi,
bool schi,
bool guardi);
80 void DoRun()
override;
99 : m_coordinatorTest(coordinatorTest)
109 m_coordinatorTest->NotifyCchStartNow(duration);
114 m_coordinatorTest->NotifySchStartNow(duration);
119 m_coordinatorTest->NotifyGuardStartNow(duration, cchi);
142 "check whether is CCH interval");
147 "check whether is SCH interval");
152 "check whether is Guard interval");
165 bool test = (((now - guardi) % synci) == 0);
185 bool test = ((now - guardi - cchi) % synci == 0);
203 test = ((now % sync) == 0);
209 test = (((now - cchi) % sync) == 0);
224 "normally CCH interval is 50ms");
227 "normally SCH interval is 50ms");
230 "normally Sync interval is 50ms");
233 "normally Guard interval is 50ms");
238 "valid configuration of channel intervals");
243 "invalid configuration of channel intervals");
249 "invalid configuration of channel intervals");
387 Simulator::Destroy();
393 Simulator::Stop(
Seconds(100.0));
395 Simulator::Destroy();
415 #define PI 3.14159265
424 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
429 for (uint32_t n = 1; n != nodesNumber; ++n)
431 double angle = (
PI / 180) * (360 / (nodesNumber - 1) * n);
432 double x = cos(angle) * 10;
433 double y = sin(angle) * 10;
442 WaveHelper waveHelper = WaveHelper::Default();
463 void SendIp(
bool shouldSucceed,
bool ipv6);
478 void DoRun()
override;
512 const Address dest = Mac48Address::GetBroadcast();
513 uint16_t protocol = 0x80dd;
514 bool result =
m_sender->
SendX(packet, dest, protocol, txInfo);
522 const Address dest = Mac48Address::GetBroadcast();
523 const static uint16_t IPv4_PROT_NUMBER = 0x0800;
524 const static uint16_t IPv6_PROT_NUMBER = 0x86DD;
525 uint16_t protocol = ipv6 ? IPv6_PROT_NUMBER : IPv4_PROT_NUMBER;
545 Simulator::Schedule(
Seconds(0.1),
550 Simulator::Schedule(
Seconds(0.1),
555 Simulator::Schedule(
Seconds(0.1),
562 Simulator::Schedule(
Seconds(0.2), &WaveNetDevice::StartSch,
m_sender, schInfo);
564 Simulator::Schedule(
Seconds(0.3),
569 Simulator::Schedule(
Seconds(0.3),
574 Simulator::Schedule(
Seconds(0.3),
579 Simulator::Schedule(
Seconds(0.3),
584 Simulator::Schedule(
Seconds(0.3),
589 Simulator::Schedule(
Seconds(0.3),
594 Simulator::Schedule(
Seconds(0.3),
601 Simulator::Schedule(
Seconds(0.4),
607 Simulator::Schedule(
Seconds(0.4),
613 Simulator::Schedule(
Seconds(0.4),
631 Simulator::Schedule(
Seconds(0.4),
641 Simulator::Schedule(
Seconds(0.6),
646 Simulator::Schedule(
Seconds(0.6),
651 Simulator::Schedule(
Seconds(0.6),
659 Simulator::Destroy();
673 Simulator::Schedule(
Seconds(0.2), &WaveNetDevice::StartSch,
m_sender, schInfo);
679 Simulator::Schedule(
Seconds(0.4), &WaveNetDevice::RegisterTxProfile,
m_sender, txProfile);
699 Simulator::Destroy();
721 Simulator::Schedule(
Seconds(0.4), &WaveNetDevice::StartSch,
m_sender, schInfo);
742 Simulator::Destroy();
814 void DoRun()
override;
843 "TestContinuousAfter fail at " <<
Now().As(Time::S));
859 "TestExtendedAfter fail at " <<
Now().As(Time::S));
875 "TestAlternating fail at " <<
Now().As(Time::S));
881 const static uint16_t WSMP_PROT_NUMBER = 0x88DC;
885 uint8_t*
data =
new uint8_t[112];
886 data[0] = (receiverId >> 24) & 0xFF;
887 data[1] = (receiverId >> 16) & 0xFF;
888 data[2] = (receiverId >> 8) & 0xFF;
889 data[3] = (receiverId >> 0) & 0xFF;
892 data[4] = (ts >> 56) & 0xFF;
893 data[5] = (ts >> 48) & 0xFF;
894 data[6] = (ts >> 40) & 0xFF;
895 data[7] = (ts >> 32) & 0xFF;
896 data[8] = (ts >> 24) & 0xFF;
897 data[9] = (ts >> 16) & 0xFF;
898 data[10] = (ts >> 8) & 0xFF;
899 data[11] = (ts >> 0) & 0xFF;
917 uint32_t seq =
data[0];
925 uint64_t ts =
data[4];
940 Time sendTime = TimeStep(ts);
946 uint32_t curNodeId = dev->GetNode()->GetId();
970 Simulator::Schedule(
Seconds(2),
975 Simulator::Schedule(
Seconds(2.01),
980 Simulator::Schedule(
Seconds(2.049),
985 Simulator::Schedule(
Seconds(2.05),
990 Simulator::Schedule(
Seconds(2.051),
995 Simulator::Schedule(
Seconds(2.99),
1014 Simulator::Stop(
Seconds(7.0));
1016 Simulator::Destroy();
1025 for (uint32_t i = 1; i != 8; ++i)
1031 static std::vector<uint32_t> WaveChannels = ChannelManager::GetWaveChannels();
1032 uint32_t
channel = WaveChannels[i - 1];
1034 Simulator::Schedule(
Seconds(0), &WaveNetDevice::StartSch, device, info);
1050 Simulator::Schedule(
Seconds(1), &WaveNetDevice::StartSch,
m_sender, info);
1060 Simulator::Stop(
Seconds(10.0));
1062 Simulator::Destroy();
1088 Simulator::Schedule(
Seconds(2),
1093 Simulator::Schedule(
Seconds(2.01),
1098 Simulator::Schedule(
Seconds(2.049),
1103 Simulator::Schedule(
Seconds(2.05),
1108 Simulator::Schedule(
Seconds(2.051),
1113 Simulator::Schedule(
Seconds(2.99),
1120 Simulator::Schedule(
Seconds(3),
1125 Simulator::Schedule(
Seconds(3.1),
1130 Simulator::Schedule(
Seconds(3.2),
1135 Simulator::Schedule(
Seconds(3.3),
1149 Simulator::Schedule(
Seconds(5),
1154 Simulator::Schedule(
Seconds(5.1),
1159 Simulator::Schedule(
Seconds(5.2),
1165 Simulator::Stop(
Seconds(6.0));
1167 Simulator::Destroy();
1176 for (uint32_t i = 1; i != 8; ++i)
1182 static std::vector<uint32_t> WaveChannels = ChannelManager::GetWaveChannels();
1183 uint32_t
channel = WaveChannels[i - 1];
1185 Simulator::Schedule(
Seconds(0), &WaveNetDevice::StartSch, device, info);
1201 Simulator::Schedule(
Seconds(1), &WaveNetDevice::StartSch,
m_sender, info);
1221 Simulator::Stop(
Seconds(10.0));
1223 Simulator::Destroy();
1244 Simulator::Schedule(
Seconds(2),
1249 Simulator::Schedule(
Seconds(2.01),
1254 Simulator::Schedule(
Seconds(2.049),
1259 Simulator::Schedule(
Seconds(2.05),
1264 Simulator::Schedule(
Seconds(2.051),
1269 Simulator::Schedule(
Seconds(2.99),
1288 Simulator::Stop(
Seconds(6.0));
1290 Simulator::Destroy();
1299 for (uint32_t i = 1; i != 8; ++i)
1305 static std::vector<uint32_t> WaveChannels = ChannelManager::GetWaveChannels();
1306 uint32_t
channel = WaveChannels[i - 1];
1308 Simulator::Schedule(
Seconds(0), &WaveNetDevice::StartSch, device, info);
1324 Simulator::Schedule(
Seconds(1), &WaveNetDevice::StartSch,
m_sender, info);
1346 Simulator::Stop(
Seconds(10.0));
1348 Simulator::Destroy();
1368 void DoRun()
override;
1404 const static uint16_t WSMP_PROT_NUMBER = 0x88DC;
1408 data[0] = (sequence >> 24) & 0xFF;
1409 data[1] = (sequence >> 16) & 0xFF;
1410 data[2] = (sequence >> 8) & 0xFF;
1411 data[3] = (sequence >> 0) & 0xFF;
1414 data[4] = (ts >> 56) & 0xFF;
1415 data[5] = (ts >> 48) & 0xFF;
1416 data[6] = (ts >> 40) & 0xFF;
1417 data[7] = (ts >> 32) & 0xFF;
1418 data[8] = (ts >> 24) & 0xFF;
1419 data[9] = (ts >> 16) & 0xFF;
1420 data[10] = (ts >> 8) & 0xFF;
1421 data[11] = (ts >> 0) & 0xFF;
1439 uint32_t seq =
data[0];
1447 uint64_t ts =
data[4];
1462 Time sendTime = TimeStep(ts);
1467 Time duration = curTime - sendTime;
1472 ChannelCoordinator::GetDefaultSchInterval(),
1473 "fail to test Annex C when packet sequence is " << seq);
1478 ChannelCoordinator::GetDefaultSchInterval(),
1479 "fail to test Annex C when packet sequence is " << seq);
1484 ChannelCoordinator::GetDefaultCchInterval(),
1485 "fail to test Annex C when packet sequence is " << seq);
1490 ChannelCoordinator::GetDefaultCchInterval(),
1491 "fail to test Annex C when packet sequence is " << seq);
1530 Simulator::Stop(
Seconds(1.0));
1532 Simulator::Destroy();
#define EXTENDED_ALTERNATING
#define EXTENDED_CONTINUOUS
The Annex C of IEEE 1609.4 : "Avoiding transmission at scheduled guard intervals" This feature is imp...
bool Receive(Ptr< NetDevice > dev, Ptr< const Packet > pkt, uint16_t mode, const Address &sender)
Receive function.
~AnnexC_TestCase() override
Ptr< WaveNetDevice > m_sender
sender
Ptr< WaveNetDevice > m_receiver
receiver
void DoRun() override
Implementation to actually run this TestCase.
void SendPacket(uint32_t packetSize, const TxInfo &txInfo, uint32_t sequence)
Send packet function.
NetDeviceContainer m_devices
devices
This test case tests channel access assignments which is done by StartSch and StopSch method of WaveN...
void TestAlternating(SchInfo &info, bool shouldSucceed)
Test aternating function.
~ChannelAccessTestCase() override
void TestAlternatingAfter(uint32_t channelNumber, bool isAccessAssigned)
Test alternating after function.
NetDeviceContainer m_devices
the devices
void SendX(uint32_t channel, uint32_t receiverId)
Send X function.
uint32_t m_received
received
void DoRun() override
Implementation to actually run this TestCase.
void TestExtendedAfter(uint32_t channelNumber, bool isAccessAssigned)
Test extended after function.
void TestContinuousAfter(uint32_t channelNumber, bool isAccessAssigned)
Test continuous after function.
bool Receive(Ptr< NetDevice > dev, Ptr< const Packet > pkt, uint16_t mode, const Address &sender)
Receive function.
void TestContinuous(SchInfo &info, bool shouldSucceed)
Test continuous function.
void TestExtended(SchInfo &info, bool shouldSucceed)
Test extended function.
Ptr< WaveNetDevice > m_sender
sender
This test case tests the channel coordination.
~ChannelCoordinationTestCase() override
void NotifySchStartNow(Time duration)
Notify SCH start now function.
void TestIntervalAfter(bool cchi, bool schi, bool guardi)
Test interval after function.
void DoRun() override
Implementation to actually run this TestCase.
void NotifyGuardStartNow(Time duration, bool inCchInterval)
Notify guard start now function.
void NotifyCchStartNow(Time duration)
Notify CCS start now function.
Ptr< ChannelCoordinator > m_coordinator
coordinator
ChannelCoordinationTestCase()
route packets or frames in different approaches see 1609.4-2010 chapter 5.3.4
Ptr< WaveNetDevice > m_sender
sender
void SendWsa(bool shouldSucceed, const VsaInfo &vsaInfo)
Send VSA management frames.
void SendWsmp(bool shouldSucceed, const TxInfo &txInfo)
Send WSMP or other packets.
void SendIp(bool shouldSucceed, bool ipv6)
Send IP-based packets.
~ChannelRoutingTestCase() override
void DoRun() override
Implementation to actually run this TestCase.
bool ReceiveVsa(Ptr< const Packet > pkt, const Address &address, uint32_t, uint32_t)
Receive VSA function.
bool Receive(Ptr< NetDevice > dev, Ptr< const Packet > pkt, uint16_t mode, const Address &sender)
Receive function.
CoordinationTestListener is used to test channel coordination events.
void NotifyCchSlotStart(Time duration) override
ChannelCoordinationTestCase * m_coordinatorTest
coordinator test
void NotifySchSlotStart(Time duration) override
~CoordinationTestListener() override
CoordinationTestListener(ChannelCoordinationTestCase *coordinatorTest)
Constructor.
void NotifyGuardSlotStart(Time duration, bool cchi) override
static NetDeviceContainer CreatWaveDevice(uint32_t nodesNumber=2)
Create WAVE device function.
a polymophic address class
receive notifications about channel coordination events.
Time GetSyncInterval() const
void SetSchInterval(Time schi)
bool IsValidConfig() const
bool IsSchInterval(Time duration=Seconds(0.0)) const
bool IsGuardInterval(Time duration=Seconds(0.0)) const
Time GetSchInterval() const
void SetGuardInterval(Time guardi)
Time GetCchInterval() const
Time GetGuardInterval() const
void SetCchInterval(Time cchi)
bool IsCchInterval(Time duration=Seconds(0.0)) const
void RegisterListener(Ptr< ChannelCoordinationListener > listener)
Helper class used to assign positions and mobility models to nodes.
Keep track of the current position and velocity of an object.
void SetPosition(const Vector &position)
holds a vector of ns3::NetDevice pointers
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
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< T > GetObject() const
Get a pointer to the requested aggregated Object.
the organization identifier is a public organizationally unique identifier assigned by the IEEE.
uint32_t GetSize() const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
uint32_t CopyData(uint8_t *buffer, uint32_t size) const
Copy the packet contents to a byte buffer.
Qos Wave Mac Helper class.
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 GetMilliSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
int64_t GetTimeStep() const
Get the raw time value, in the current resolution unit.
helps to create WaveNetDevice objects
virtual NetDeviceContainer Install(const WifiPhyHelper &phy, const WifiMacHelper &mac, NodeContainer c) const
bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber) override
bool StartSch(const SchInfo &schInfo)
Address GetAddress() const override
Ptr< ChannelScheduler > GetChannelScheduler() const
void SetReceiveCallback(NetDevice::ReceiveCallback cb) override
bool SendX(Ptr< Packet > packet, const Address &dest, uint32_t protocol, const TxInfo &txInfo)
bool StartVsa(const VsaInfo &vsaInfo)
represent a single transmission mode
To trace WaveNetDevice, we have to overwrite the trace functions of class YansWifiPhyHelper.
manage and create wifi channel objects for the YANS model.
Ptr< YansWifiChannel > Create() const
void SetChannel(Ptr< YansWifiChannel > channel)
Time Now()
create an ns3::Time instance which contains the current simulation time.
#define NS_TEST_EXPECT_MSG_LT(actual, limit, msg)
Test that an actual value is less than a limit and report if not.
#define NS_TEST_EXPECT_MSG_GT(actual, limit, msg)
Test that an actual value is greater than a limit and report if not.
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
Time Seconds(double value)
Construct a Time in the indicated unit.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
static WaveMacTestSuite waveMacTestSuite
the test suite
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...
uint32_t channelNumber
channel number
static const uint32_t packetSize
Packet size generated at the AP.