10#include "ns3/constant-position-mobility-model.h"
11#include "ns3/simulator.h"
15#include "ns3/lorawan-module.h"
35 void DoRun()
override;
40 :
TestCase(
"Verify that LoraInterferenceHelper works as expected")
59 uint32_t differentFrequencyHz = 868300000;
65 event = interferenceHelper.
Add(
Seconds(2), 14, 7,
nullptr, frequencyHz);
66 event1 = interferenceHelper.
Add(
Seconds(1), 14, 12,
nullptr, frequencyHz);
69 "Overlap computation didn't give the expected result");
72 event = interferenceHelper.
Add(
Seconds(2), 14, 7,
nullptr, frequencyHz);
73 event1 = interferenceHelper.
Add(
Seconds(1.5), 14, 12,
nullptr, frequencyHz);
76 "Overlap computation didn't give the expected result");
79 event = interferenceHelper.
Add(
Seconds(2), 14, 7,
nullptr, frequencyHz);
80 event1 = interferenceHelper.
Add(
Seconds(3), 14, 12,
nullptr, frequencyHz);
83 "Overlap computation didn't give the expected result");
86 event = interferenceHelper.
Add(
Seconds(2), 14, 7,
nullptr, frequencyHz);
87 event1 = interferenceHelper.
Add(
Seconds(2), 14, 12,
nullptr, frequencyHz);
95 event = interferenceHelper.
Add(
Seconds(2), 14, 7,
nullptr, frequencyHz);
96 interferenceHelper.
Add(
Seconds(2), 14, 12,
nullptr, frequencyHz);
99 "Packet did not survive interference as expected");
103 event = interferenceHelper.
Add(
Seconds(2), 14, 7,
nullptr, frequencyHz);
104 interferenceHelper.
Add(
Seconds(2), 14 - 7, 7,
nullptr, frequencyHz);
107 "Packet did not survive interference as expected");
111 event = interferenceHelper.
Add(
Seconds(2), 14, 7,
nullptr, frequencyHz);
112 interferenceHelper.
Add(
Seconds(2), 14 - 6, 7,
nullptr, frequencyHz);
115 "Packet was not destroyed by interference as expected");
119 event = interferenceHelper.
Add(
Seconds(2), 14, 7,
nullptr, frequencyHz);
120 interferenceHelper.
Add(
Seconds(1), 14 - 6, 7,
nullptr, frequencyHz);
123 "Packet did not survive interference as expected");
129 event = interferenceHelper.
Add(
Seconds(2), 14, 7,
nullptr, frequencyHz);
130 interferenceHelper.
Add(
Seconds(2), 14, 7,
nullptr, differentFrequencyHz);
133 "Packet did not survive interference as expected");
139 event = interferenceHelper.
Add(
Seconds(2), 14, 7,
nullptr, frequencyHz);
140 interferenceHelper.
Add(
Seconds(2), 14 + 16, 8,
nullptr, frequencyHz);
143 "Packet did not survive interference as expected");
148 event = interferenceHelper.
Add(
Seconds(2), 14, 7,
nullptr, frequencyHz);
149 interferenceHelper.
Add(
Seconds(2), 14 + 17, 8,
nullptr, frequencyHz);
152 "Packet was not destroyed by interference as expected");
156 event = interferenceHelper.
Add(
Seconds(2), 14, 7,
nullptr, frequencyHz);
157 interferenceHelper.
Add(
Seconds(2), 14 + 17, 10,
nullptr, frequencyHz);
160 "Packet was destroyed by interference while it should have survived");
165 event = interferenceHelper.
Add(
Seconds(2), 14, 7,
nullptr, frequencyHz);
166 interferenceHelper.
Add(
Seconds(2), 14 + 16, 8,
nullptr, frequencyHz);
167 interferenceHelper.
Add(
Seconds(2), 14 + 16, 8,
nullptr, frequencyHz);
168 interferenceHelper.
Add(
Seconds(2), 14 + 16, 8,
nullptr, frequencyHz);
171 "Packet was not destroyed by interference as expected");
176 event = interferenceHelper.
Add(
Seconds(2), 14, 7,
nullptr, frequencyHz);
177 interferenceHelper.
Add(
Seconds(2), 14 + 16, 8,
nullptr, frequencyHz);
178 interferenceHelper.
Add(
Seconds(2), 14 + 16, 9,
nullptr, frequencyHz);
179 interferenceHelper.
Add(
Seconds(2), 14 + 16, 10,
nullptr, frequencyHz);
182 "Packet did not survive interference as expected");
199 void DoRun()
override;
204 :
TestCase(
"Verify that LoraDeviceAddress works as expected")
234 "> function for addresses doesn't work correctly");
240 address.SetNwkAddr(0xFFFFFFF);
241 address.SetNwkID(0b1111111);
244 "Addresses set to be equal don't match");
253 "Serialization + Deserialization doesn't yield an equal address");
260 for (
int i = 0; i < 200; i++)
267 "LoraDeviceAddressGenerator doesn't increment as expected");
283 void DoRun()
override;
288 :
TestCase(
"Verify that LorawanMacHeader and LoraFrameHeader work as expected")
320 "MType changes in the serialization/deserialization process");
323 "MType changes in the serialization/deserialization process");
346 uint8_t margin = command->GetMargin();
347 uint8_t gwCnt = command->GetGwCnt();
351 "ACK bit changes in the serialization/deserialization process");
354 "ADR bit changes in the serialization/deserialization process");
357 "FCnt changes in the serialization/deserialization process");
360 "Address changes in the serialization/deserialization process");
363 "Margin changes in the serialization/deserialization process");
370 pkt->AddHeader(frameHdr);
371 pkt->AddHeader(macHdr);
379 pkt->RemoveHeader(macHdr1);
386 pkt->RemoveHeader(frameHdr1);
391 "Wrong size of packet + headers - macHeader - frameHeader");
396 "Removed header contents don't match");
399 "Removed header contents don't match");
404 "Removed header contents don't match");
407 "Removed header contents don't match");
410 "Removed header contents don't match");
413 "Removed header contents don't match");
416 "Removed header's MAC command contents don't match");
419 "Removed header's MAC command contents don't match");
436 void DoRun()
override;
480 :
TestCase(
"Verify that ReceivePaths work as expected")
868 void DoRun()
override;
873 :
TestCase(
"Verify that LogicalLoraChannel and LogicalLoraChannelHelper work as expected")
916 "Contains does not behave as expected");
919 "Contains does not behave as expected");
922 "Contains does not behave as expected");
941 channelHelper->AddSubBand(subBand);
942 channelHelper->AddSubBand(subBand1);
943 channelHelper->SetChannel(0, channel1);
944 channelHelper->SetChannel(1, channel2);
945 channelHelper->SetChannel(2, channel3);
951 channelHelper->AddEvent(
Seconds(2), channel1);
957 "Wait time doesn't behave as expected");
962 "Wait time doesn't behave as expected");
967 "Wait time affects other subbands");
983 void DoRun()
override;
989 "Verify that LoraPhy's function to compute the time on air of a packet works as expected")
1151 void DoRun()
override;
1168 :
TestCase(
"Verify that PhyConnectivity works as expected")
1222 return packet1->GetUid() == packet2->GetUid();
1235 loss->SetPathLossExponent(3.76);
1236 loss->SetReference(1, 7.7);
1248 edPhy1->SetFrequency(868100000);
1249 edPhy2->SetFrequency(868100000);
1250 edPhy3->SetFrequency(868100000);
1256 mob1->SetPosition(Vector(0.0, 0.0, 0.0));
1257 mob2->SetPosition(Vector(10.0, 0.0, 0.0));
1258 mob3->SetPosition(Vector(20.0, 0.0, 0.0));
1260 edPhy1->SetMobility(mob1);
1261 edPhy2->SetMobility(mob2);
1262 edPhy3->SetMobility(mob3);
1264 edPhy1->SwitchToStandby();
1265 edPhy2->SwitchToStandby();
1266 edPhy3->SwitchToStandby();
1277 edPhy1->SetSpreadingFactor(12);
1278 edPhy2->SetSpreadingFactor(12);
1279 edPhy3->SetSpreadingFactor(12);
1282 edPhy1->SetFrequency(868100000);
1283 edPhy2->SetFrequency(868100000);
1284 edPhy3->SetFrequency(868100000);
1286 edPhy1->TraceConnectWithoutContext(
"ReceivedPacket",
1288 edPhy2->TraceConnectWithoutContext(
"ReceivedPacket",
1290 edPhy3->TraceConnectWithoutContext(
"ReceivedPacket",
1293 edPhy1->TraceConnectWithoutContext(
"LostPacketBecauseUnderSensitivity",
1295 edPhy2->TraceConnectWithoutContext(
"LostPacketBecauseUnderSensitivity",
1297 edPhy3->TraceConnectWithoutContext(
"LostPacketBecauseUnderSensitivity",
1300 edPhy1->TraceConnectWithoutContext(
"LostPacketBecauseInterference",
1302 edPhy2->TraceConnectWithoutContext(
"LostPacketBecauseInterference",
1304 edPhy3->TraceConnectWithoutContext(
"LostPacketBecauseInterference",
1307 edPhy1->TraceConnectWithoutContext(
"LostPacketBecauseWrongFrequency",
1309 edPhy2->TraceConnectWithoutContext(
"LostPacketBecauseWrongFrequency",
1311 edPhy3->TraceConnectWithoutContext(
"LostPacketBecauseWrongFrequency",
1314 edPhy1->TraceConnectWithoutContext(
"LostPacketBecauseWrongSpreadingFactor",
1316 edPhy2->TraceConnectWithoutContext(
"LostPacketBecauseWrongSpreadingFactor",
1318 edPhy3->TraceConnectWithoutContext(
"LostPacketBecauseWrongSpreadingFactor",
1337 uint8_t buffer[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
1361 "Channel skipped some PHYs when delivering a packet");
1384 "Packet was received by a PHY in SLEEP mode");
1391 edPhy2->SetSpreadingFactor(7);
1393 ->SetPosition(Vector(2990, 0, 0));
1410 "Packet that should have been lost because of low receive power was received");
1416 edPhy2->SetSpreadingFactor(8);
1418 ->SetPosition(Vector(2990, 0, 0));
1434 "Packets that should have arrived above sensitivity were under it");
1462 "Packets that should be destroyed by interference weren't");
1482 "Packets were received even though PHY was on a different frequency");
1504 "Packets were received even though PHY was listening for a different spreading factor.");
1526 "Packet changed contents when going through the channel");
1549 "State didn't switch to STANDBY as expected");
1552 "State didn't switch to STANDBY as expected");
1569 void DoRun()
override;
1574 :
TestCase(
"Verify that the MAC layer of end devices behaves as expected")
1616 template <
typename T,
typename... Ts>
1626 void DoRun()
override;
1632 :
TestCase(
"Test functionality of MAC commands when received by a device")
1641template <
typename T,
typename... Ts>
1642std::vector<Ptr<MacCommand>>
1653 pkt->AddHeader(fhdr);
1655 pkt->AddHeader(mhdr);
1658 ->SwitchToStandby();
1659 m_mac->Receive(pkt);
1664 pkt->RemoveHeader(mhdr);
1666 pkt->RemoveHeader(fhdr);
1694 uint8_t margin = 20;
1699 "m_lastKnownMarginDb differs from Margin field of LinkCheckAns");
1702 "m_lastKnownGatewayCount differs GwCnt field of LinkCheckAns");
1705 "Unexpected uplink MAC command answer(s) to LinkCheckAns");
1711 uint8_t dataRate = 5;
1712 uint8_t txPower = 2;
1713 uint16_t chMask = 0b101;
1714 uint8_t chMaskCntl = 0;
1715 uint8_t nbTrans = 13;
1719 "m_dataRate does not match DataRate field of LinkAdrReq");
1722 "m_txPowerDbm does not match txPower field of LinkAdrReq");
1725 "m_nbTrans does not match nbTrans field of LinkAdrReq");
1726 auto channels =
m_mac->GetLogicalLoraChannelHelper()->GetRawChannelArray();
1727 for (
size_t i = 0; i < channels.size(); i++)
1729 const auto& c = channels.at(i + 16 * chMaskCntl);
1730 bool actual = (c) ? c->IsEnabledForUplink() :
false;
1731 bool expected = (chMask & 0b1 << i);
1745 uint8_t dataRate = 5;
1746 uint8_t txPower = 2;
1747 uint16_t chMask = 0b010;
1748 uint8_t chMaskCntl = 0;
1749 uint8_t nbTrans = 13;
1750 m_mac->SetUplinkAdrBit(
false);
1754 "m_dataRate expected to differ from DataRate field of LinkAdrReq");
1757 "m_txPowerDbm expected to not match txPower field of LinkAdrReq");
1760 "m_nbTrans expected to differ from nbTrans field of LinkAdrReq");
1761 auto channels =
m_mac->GetLogicalLoraChannelHelper()->GetRawChannelArray();
1762 for (
size_t i = 0; i < channels.size(); i++)
1764 const auto& c = channels.at(i + 16 * chMaskCntl);
1765 bool actual = (c) ? c->IsEnabledForUplink() :
false;
1766 bool expected = (chMask & 0b1 << i);
1780 uint8_t dataRate = 12;
1781 uint8_t txPower = 8;
1782 uint16_t chMask = 0b0;
1783 uint8_t chMaskCntl = 0;
1784 uint8_t nbTrans = 6;
1788 "m_dataRate expected to be default value");
1791 "m_txPowerDbm expected to be default value");
1794 "m_nbTrans expected to be default value");
1795 auto channels =
m_mac->GetLogicalLoraChannelHelper()->GetRawChannelArray();
1796 for (
size_t i = 0; i < channels.size(); i++)
1798 const auto& c = channels.at(i + 16 * chMaskCntl);
1799 bool actual = (c) ? c->IsEnabledForUplink() :
false;
1800 bool expected = (uint16_t(0b111) & 0b1 << i);
1814 uint8_t dataRate = 1;
1815 uint8_t txPower = 7;
1816 uint16_t chMask = 0b1000;
1817 uint8_t chMaskCntl = 0;
1818 uint8_t nbTrans = 3;
1822 "m_dataRate expected to be default value");
1825 "m_txPowerDbm expected to be default value");
1828 "m_nbTrans expected to be default value");
1829 auto channels =
m_mac->GetLogicalLoraChannelHelper()->GetRawChannelArray();
1830 for (
size_t i = 0; i < channels.size(); i++)
1832 const auto& c = channels.at(i + 16 * chMaskCntl);
1833 bool actual = (c) ? c->IsEnabledForUplink() :
false;
1834 bool expected = (uint16_t(0b111) & 0b1 << i);
1848 uint8_t dataRate = 0xF;
1849 uint8_t txPower = 0xF;
1850 uint16_t chMask = 0b0;
1851 uint8_t chMaskCntl = 6;
1852 uint8_t nbTrans = 0;
1854 m_mac->SetDataRate(3);
1855 m_mac->SetTransmissionPowerDbm(12);
1856 m_mac->SetMaxNumberOfTransmissions(15);
1857 auto channels =
m_mac->GetLogicalLoraChannelHelper()->GetRawChannelArray();
1858 channels.at(0)->DisableForUplink();
1862 "m_dataRate expected to be default value");
1865 "m_txPowerDbm expected to be default value");
1868 "m_nbTrans expected to be default value");
1869 for (
size_t i = 0; i < channels.size(); i++)
1871 const auto& c = channels.at(i);
1872 bool actual = (c) ? c->IsEnabledForUplink() :
false;
1873 bool expected = (uint16_t(0b111) & 0b1 << i);
1887 uint8_t maxDutyCycle = 0;
1890 1 / std::pow(2, maxDutyCycle),
1891 "m_aggregatedDutyCycle != 1");
1900 uint8_t maxDutyCycle = 3;
1903 1 / std::pow(2, maxDutyCycle),
1904 "m_aggregatedDutyCycle != 1");
1913 uint8_t rx1DrOffset = 5;
1914 uint8_t rx2DataRate = 5;
1915 double frequencyHz = 863500000;
1916 m_mac->SetDataRate(5);
1919 unsigned(5 - rx1DrOffset),
1920 "Rx1DataRate does not match rx1DrOffset from RxParamSetupReq");
1922 unsigned(rx2DataRate),
1923 "Rx2DataRate does not match rx2DataRate from RxParamSetupReq");
1926 "Rx2 frequency does not match frequency from RxParamSetupReq");
1938 uint8_t rx1DrOffset = 6;
1939 uint8_t rx2DataRate = 12;
1940 double frequencyHz = 871000000;
1941 m_mac->SetDataRate(5);
1945 "Rx1DataRate expected to be default value");
1948 "Rx2DataRate expected to be default value");
1951 "Rx2 frequency expected to be default value");
1974 uint8_t chIndex = 4;
1975 double frequencyHz = 865100000;
1976 uint8_t minDataRate = 1;
1977 uint8_t maxDataRate = 4;
1980 auto c =
m_mac->GetLogicalLoraChannelHelper()->GetRawChannelArray().at(chIndex);
1984 "Channel frequency expected to equal NewChannelReq frequency");
1986 unsigned(minDataRate),
1987 "Channel minDataRate expected to equal NewChannelReq minDataRate");
1989 unsigned(maxDataRate),
1990 "Channel maxDataRate expected to equal NewChannelReq maxDataRate");
2000 uint8_t chIndex = 1;
2001 double frequencyHz = 862000000;
2002 uint8_t minDataRate = 14;
2003 uint8_t maxDataRate = 13;
2006 double defaultFrequenciesHz[3] = {868100000, 868300000, 868500000};
2007 auto channels =
m_mac->GetLogicalLoraChannelHelper()->GetRawChannelArray();
2008 for (
size_t i = 0; i < channels.size(); i++)
2010 const auto& c = channels.at(i);
2017 defaultFrequenciesHz[i],
2018 "Channel frequency expected to equal NewChannelReq frequency");
2021 "Channel " << i <<
" minDataRate expected to be default");
2024 "Channel " << i <<
" maxDataRate expected to be default");
2027 "Channel " << i <<
" state expected to be active by default");
2072 void DoRun()
override;
2078 :
TestCase(
"Test the ADR backoff procedure of the LoRaWAN MAC protocol")
2097 pkt->RemoveHeader(mhdr);
2099 pkt->RemoveHeader(fhdr);
2112 pkt->AddHeader(fhdr);
2114 pkt->AddHeader(mhdr);
2117 ->SwitchToStandby();
2118 m_mac->Receive(pkt);
2147 auto llch =
m_mac->GetLogicalLoraChannelHelper();
2153 m_mac->SetDataRate(5);
2154 m_mac->SetTransmissionPowerDbm(0);
2155 m_mac->SetMaxNumberOfTransmissions(8);
2156 auto chVec = llch->GetRawChannelArray();
2157 chVec.at(0)->DisableForUplink();
2158 chVec.at(1)->DisableForUplink();
2159 chVec.at(2)->DisableForUplink();
2162 llch->SetChannel(3, nonDefaultChannel);
2165 for (
uint32_t fCnt = 0; fCnt <= ADR_ACK_LIMIT + ADR_ACK_DELAY * 7U; ++fCnt)
2170 fCnt >= ADR_ACK_LIMIT,
2171 "Unexpected ADRACKReq value in FHDR of uplink fCnt=" << fCnt);
2172 uint8_t step = (fCnt >= ADR_ACK_LIMIT) ? (fCnt - ADR_ACK_LIMIT) / ADR_ACK_DELAY : 0;
2174 (step > 0) ? 14 : 0,
2175 "Unexpected tx power on uplink fCnt=" << fCnt);
2176 uint8_t expectedDr = (step == 0) ? 5 : (step < 7) ? 5 - (step - 1) : 0;
2179 "Unexpected data rate on uplink fCnt=" << fCnt);
2180 auto chVec = llch->GetRawChannelArray();
2181 for (uint8_t i = 0; i < 3; ++i)
2185 "Unexpected activation state of channel "
2186 <<
unsigned(i) <<
" on uplink fCnt=" << fCnt);
2189 chVec.at(3)->IsEnabledForUplink(),
2191 "Unexpected activation state of channel 3 on uplink fCnt=" << fCnt);
2201 for (uint16_t fCnt = 0; fCnt <= ADR_ACK_LIMIT; ++fCnt)
2206 fCnt >= ADR_ACK_LIMIT,
2207 "Unexpected ADRACKReq value in FHDR of uplink fCnt=" << fCnt);
2213 "Unexpected FCnt value in uplink FHDR");
2217 "Unexpected ADRACKReq value in FHDR of uplink fCnt=" << fhdr.
GetFCnt());
It tests LoraDeviceAddress comparison operators overrides and generation of new addresses with LoraDe...
AddressTest()
Default constructor.
void DoRun() override
Implementation to actually run this TestCase.
~AddressTest() override
Destructor.
It tests the correct execution of the ADR backoff procedure of LoRaWAN devices.
AdrBackoffTest()
Default constructor.
void DoRun() override
Implementation to actually run this TestCase.
Ptr< ClassAEndDeviceLorawanMac > m_mac
The end device's MAC layer used in tests.
~AdrBackoffTest() override
Destructor.
void ReceiveDownlink()
Create and receive an empty payload downlink destined for the LoRaWAN MAC.
void Reset()
This function resets the simulation and device MAC layer, use before test sub-cases.
void SendUplink(Time after, LoraFrameHeader &fhdr)
Create and send an empty app payload unconfirmed frame through the MAC layer to increment of the FCnt...
It tests interference computations in a number of possible scenarios using the LoraInterferenceHelper...
~InterferenceTest() override
Destructor.
void DoRun() override
Implementation to actually run this TestCase.
InterferenceTest()
Default constructor.
It tests functionality of the LogicalLoraChannel, SubBand and LogicalLoraChannelHelper classes.
LogicalLoraChannelTest()
Default constructor.
~LogicalLoraChannelTest() override
Destructor.
void DoRun() override
Implementation to actually run this TestCase.
~LorawanMacTest() override
Destructor.
LorawanMacTest()
Default constructor.
void DoRun() override
Implementation to actually run this TestCase.
The TestSuite class names the TestSuite, identifies what type of TestSuite, and enables the TestCases...
LorawanTestSuite()
Default constructor.
It tests the functionalities of LoRaWAN MAC commands received by devices.
~MacCommandTest() override
Destructor.
MacCommandTest()
Default constructor.
void Reset()
This function resets the state of the MAC layer used for tests.
void DoRun() override
Implementation to actually run this TestCase.
Ptr< ClassAEndDeviceLorawanMac > m_mac
The end device's MAC layer used in tests.
std::vector< Ptr< MacCommand > > RunMacCommand(Ts &&... args)
Have this class' MAC layer receive a downlink packet carrying the input MAC command.
It tests sending packets over a LoRa physical channel between multiple devices and the resulting poss...
int m_interferenceCalls
Counter for LostPacketBecauseInterference calls.
void Reset()
Reset counters and end devices' PHYs for new sub test case.
Ptr< SimpleEndDeviceLoraPhy > edPhy2
The second end device's PHY layer used in tests.
void WrongFrequency(Ptr< const Packet > packet, uint32_t node)
Callback for tracing LostPacketBecauseWrongFrequency.
void DoRun() override
Implementation to actually run this TestCase.
void UnderSensitivity(Ptr< const Packet > packet, uint32_t node)
Callback for tracing LostPacketBecauseUnderSensitivity.
bool IsSamePacket(Ptr< Packet > packet1, Ptr< Packet > packet2)
Compare two packets to check if they are equal.
Ptr< SimpleEndDeviceLoraPhy > edPhy3
The third end device's PHY layer used in tests.
Ptr< SimpleEndDeviceLoraPhy > edPhy1
The first end device's PHY layer used in tests.
int m_wrongSfCalls
Counter for LostPacketBecauseWrongSpreadingFactor calls.
int m_wrongFrequencyCalls
Counter for LostPacketBecauseWrongFrequency calls.
~PhyConnectivityTest() override
Destructor.
int m_underSensitivityCalls
Counter for LostPacketBecauseUnderSensitivity calls.
int m_receivedPacketCalls
Counter for ReceivedPacket calls.
void WrongSf(Ptr< const Packet > packet, uint32_t node)
Callback for tracing LostPacketBecauseWrongSpreadingFactor.
Ptr< LoraChannel > channel
The LoRa channel used for tests.
PhyConnectivityTest()
Default constructor.
void Interference(Ptr< const Packet > packet, uint32_t node)
Callback for tracing LostPacketBecauseInterference.
Ptr< Packet > m_latestReceivedPacket
Pointer to track the last received packet.
void ReceivedPacket(Ptr< const Packet > packet, uint32_t node)
Callback for tracing ReceivedPacket.
It tests a number of cases related to SimpleGatewayLoraPhy's parallel reception paths.
~ReceivePathTest() override
Destructor.
ReceivePathTest()
Default constructor.
int m_receivedPacketCalls
Counter for ReceivedPacket calls.
void OccupiedReceptionPaths(int oldValue, int newValue)
Callback for tracing OccupiedReceptionPaths.
Ptr< SimpleGatewayLoraPhy > gatewayPhy
PHY layer of a gateway to be tested.
void ReceivedPacket(Ptr< const Packet > packet, uint32_t node)
Callback for tracing ReceivedPacket.
void Interference(Ptr< const Packet > packet, uint32_t node)
Callback for tracing LostPacketBecauseInterference.
void NoMoreDemodulators(Ptr< const Packet > packet, uint32_t node)
Callback for tracing LostPacketBecauseNoMoreReceivers.
void DoRun() override
Implementation to actually run this TestCase.
int m_noMoreDemodulatorsCalls
Counter for LostPacketBecauseNoMoreReceivers calls.
void Reset()
Reset counters and gateway PHY for new sub test case.
int m_interferenceCalls
Counter for LostPacketBecauseInterference calls.
int m_maxOccupiedReceptionPaths
Max number of concurrent OccupiedReceptionPaths.
It tests the correctness of the LoraPhy::GetOnAirTime calculator against a number of pre-sourced time...
void DoRun() override
Implementation to actually run this TestCase.
~TimeOnAirTest() override
Destructor.
TimeOnAirTest()
Default constructor.
iterator in a Buffer instance
automatically resized byte buffer
void AddAtStart(uint32_t start)
Buffer::Iterator Begin() const
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 Run()
Run the simulation.
static void Stop()
Tell the Simulator the calling event should be the last one executed.
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
TestCase(const TestCase &)=delete
Caller graph was not generated because of its size.
TestSuite(std::string name, Type type=Type::UNIT)
Construct a new test suite.
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.
@ STANDBY
The PHY layer is in STANDBY.
static constexpr uint16_t ADR_ACK_DELAY
ADRACKCnt threshold for ADR backoff action.
void Send(Ptr< Packet > packet) override
Send a packet.
static constexpr uint16_t ADR_ACK_LIMIT
ADRACKCnt threshold for setting ADRACKReq.
This class generates sequential LoraDeviceAddress instances.
LoraDeviceAddress NextAddress()
Allocate the next LoraDeviceAddress.
LoraDeviceAddress GetNextAddress()
Get the LoraDeviceAddress that will be allocated upon a call to NextAddress.
This class represents the device address of a LoraWAN end device.
static LoraDeviceAddress Deserialize(const uint8_t buf[4])
Convert the input buffer into a new address.
void Serialize(uint8_t buf[4]) const
Convert this address to a buffer.
Helper for LoraPhy that manages interference calculations.
Time GetOverlapTime(Ptr< LoraInterferenceHelper::Event > event1, Ptr< LoraInterferenceHelper::Event > event2)
Compute the time duration in which two given events are overlapping.
Ptr< LoraInterferenceHelper::Event > Add(Time duration, double rxPower, uint8_t spreadingFactor, Ptr< Packet > packet, uint32_t frequencyHz)
Add an event to the InterferenceHelper.
void ClearAllEvents()
Delete all events in the LoraInterferenceHelper.
uint8_t IsDestroyedByInterference(Ptr< LoraInterferenceHelper::Event > event)
Determine whether the event was destroyed by interference or not.
static Time GetOnAirTime(Ptr< Packet > packet, LoraTxParameters txParams)
Compute the time that a packet with certain characteristics will take to be transmitted.
Helper class for configuring and installing the LorawanMac class on devices and gateways.
void SetDeviceType(enum DeviceType dt)
Set the kind of MAC this helper will create.
void SetRegion(enum Regions region)
Set the region in which the device is to operate.
Ptr< LorawanMac > Install(Ptr< Node > node, Ptr< NetDevice > device) const
Create the LorawanMac instance and connect it to a device.
void Send(Ptr< Packet > packet, LoraTxParameters txParams, uint32_t frequencyHz, double txPowerDbm) override
Instruct the PHY to send a packet according to some parameters.
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...
#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_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
#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_EXPECT_MSG_NE(actual, limit, msg)
Test that an actual and expected (limit) value are not equal 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.
#define NS_TEST_ASSERT_MSG_NE(actual, limit, msg)
Test that an actual and expected (limit) value are not equal and report and abort if not.
#define NS_TEST_EXPECT_MSG_EQ_TOL(actual, limit, tol, msg)
Test that actual and expected (limit) values are equal to plus or minus some tolerance and report if ...
Time Seconds(double value)
Construct a Time in the indicated unit.
Time Hours(double value)
Construct a Time in the indicated unit.
Time Minutes(double value)
Construct a Time in the indicated unit.
static LorawanTestSuite lorawanTestSuite
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.
Structure to collect all parameters that are used to compute the duration of a packet (excluding payl...
uint32_t nPreamble
Number of preamble symbols.
CodingRate codingRate
Code rate (obtained as 4/(codingRate+4)).
uint32_t bandwidthHz
Bandwidth in Hz.
bool headerDisabled
Whether to use implicit header mode.
bool lowDataRateOptimizationEnabled
Whether low data rate optimization is enabled.
bool crcEnabled
Whether Cyclic Redundancy Check (CRC) is enabled.
uint8_t sf
Spreading Factor.