10#include "ns3/basic-energy-source-helper.h"
11#include "ns3/constant-position-mobility-model.h"
13#include "ns3/propagation-delay-model.h"
14#include "ns3/propagation-loss-model.h"
15#include "ns3/simulator.h"
19#include "ns3/class-a-end-device-lorawan-mac.h"
20#include "ns3/lora-net-device.h"
21#include "ns3/lora-radio-energy-model-helper.h"
22#include "ns3/lora-utils.h"
23#include "ns3/lorawan-mac-helper.h"
24#include "ns3/periodic-sender.h"
25#include "ns3/simple-end-device-lora-phy.h"
26#include "ns3/simple-gateway-lora-phy.h"
46 void DoRun()
override;
51 :
TestCase(
"Verify that LoraInterferenceHelper works as expected")
70 uint32_t differentFrequencyHz = 868300000;
76 event = interferenceHelper.
Add(
Seconds(2), 14, 7,
nullptr, frequencyHz);
77 event1 = interferenceHelper.
Add(
Seconds(1), 14, 12,
nullptr, frequencyHz);
80 "Overlap computation didn't give the expected result");
83 event = interferenceHelper.
Add(
Seconds(2), 14, 7,
nullptr, frequencyHz);
84 event1 = interferenceHelper.
Add(
Seconds(1.5), 14, 12,
nullptr, frequencyHz);
87 "Overlap computation didn't give the expected result");
90 event = interferenceHelper.
Add(
Seconds(2), 14, 7,
nullptr, frequencyHz);
91 event1 = interferenceHelper.
Add(
Seconds(3), 14, 12,
nullptr, frequencyHz);
94 "Overlap computation didn't give the expected result");
97 event = interferenceHelper.
Add(
Seconds(2), 14, 7,
nullptr, frequencyHz);
98 event1 = interferenceHelper.
Add(
Seconds(2), 14, 12,
nullptr, frequencyHz);
106 event = interferenceHelper.
Add(
Seconds(2), 14, 7,
nullptr, frequencyHz);
107 interferenceHelper.
Add(
Seconds(2), 14, 12,
nullptr, frequencyHz);
110 "Packet did not survive interference as expected");
114 event = interferenceHelper.
Add(
Seconds(2), 14, 7,
nullptr, frequencyHz);
115 interferenceHelper.
Add(
Seconds(2), 14 - 7, 7,
nullptr, frequencyHz);
118 "Packet did not survive interference as expected");
122 event = interferenceHelper.
Add(
Seconds(2), 14, 7,
nullptr, frequencyHz);
123 interferenceHelper.
Add(
Seconds(2), 14 - 6, 7,
nullptr, frequencyHz);
126 "Packet was not destroyed by interference as expected");
130 event = interferenceHelper.
Add(
Seconds(2), 14, 7,
nullptr, frequencyHz);
131 interferenceHelper.
Add(
Seconds(1), 14 - 6, 7,
nullptr, frequencyHz);
134 "Packet did not survive interference as expected");
140 event = interferenceHelper.
Add(
Seconds(2), 14, 7,
nullptr, frequencyHz);
141 interferenceHelper.
Add(
Seconds(2), 14, 7,
nullptr, differentFrequencyHz);
144 "Packet did not survive interference as expected");
150 event = interferenceHelper.
Add(
Seconds(2), 14, 7,
nullptr, frequencyHz);
151 interferenceHelper.
Add(
Seconds(2), 14 + 16, 8,
nullptr, frequencyHz);
154 "Packet did not survive interference as expected");
159 event = interferenceHelper.
Add(
Seconds(2), 14, 7,
nullptr, frequencyHz);
160 interferenceHelper.
Add(
Seconds(2), 14 + 17, 8,
nullptr, frequencyHz);
163 "Packet was not destroyed by interference as expected");
167 event = interferenceHelper.
Add(
Seconds(2), 14, 7,
nullptr, frequencyHz);
168 interferenceHelper.
Add(
Seconds(2), 14 + 17, 10,
nullptr, frequencyHz);
171 "Packet was destroyed by interference while it should have survived");
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, 8,
nullptr, frequencyHz);
179 interferenceHelper.
Add(
Seconds(2), 14 + 16, 8,
nullptr, frequencyHz);
182 "Packet was not destroyed by interference as expected");
187 event = interferenceHelper.
Add(
Seconds(2), 14, 7,
nullptr, frequencyHz);
188 interferenceHelper.
Add(
Seconds(2), 14 + 16, 8,
nullptr, frequencyHz);
189 interferenceHelper.
Add(
Seconds(2), 14 + 16, 9,
nullptr, frequencyHz);
190 interferenceHelper.
Add(
Seconds(2), 14 + 16, 10,
nullptr, frequencyHz);
193 "Packet did not survive interference as expected");
210 void DoRun()
override;
215 :
TestCase(
"Verify that LoraDeviceAddress works as expected")
245 "> function for addresses doesn't work correctly");
251 address.SetNwkAddr(0xFFFFFFF);
252 address.SetNwkID(0b1111111);
255 "Addresses set to be equal don't match");
264 "Serialization + Deserialization doesn't yield an equal address");
271 for (
int i = 0; i < 200; i++)
278 "LoraDeviceAddressGenerator doesn't increment as expected");
294 void DoRun()
override;
299 :
TestCase(
"Verify that LorawanMacHeader and LoraFrameHeader work as expected")
331 "FType changes in the serialization/deserialization process");
334 "FType changes in the serialization/deserialization process");
357 uint8_t margin = command->GetMargin();
358 uint8_t gwCnt = command->GetGwCnt();
362 "ACK bit changes in the serialization/deserialization process");
365 "ADR bit changes in the serialization/deserialization process");
368 "FCnt changes in the serialization/deserialization process");
371 "Address changes in the serialization/deserialization process");
374 "Margin changes in the serialization/deserialization process");
381 pkt->AddHeader(frameHdr);
382 pkt->AddHeader(macHdr);
390 pkt->RemoveHeader(macHdr1);
397 pkt->RemoveHeader(frameHdr1);
402 "Wrong size of packet + headers - macHeader - frameHeader");
407 "Removed header contents don't match");
410 "Removed header contents don't match");
415 "Removed header contents don't match");
418 "Removed header contents don't match");
421 "Removed header contents don't match");
424 "Removed header contents don't match");
427 "Removed header's MAC command contents don't match");
430 "Removed header's MAC command contents don't match");
445 void DoRun()
override;
451 void Reset(uint8_t rxPathNb);
491 :
TestCase(
"Verify that ReceivePaths work as expected")
517 for (uint8_t i = 0; i < rxPathNb; i++)
524 "LostPacketBecauseNoMoreReceivers",
527 "OccupiedReceptionPaths",
531 gatewayPhy->TraceConnectWithoutContext(
"LostPacketBecauseInterference",
533 gatewayPhy->TraceConnectWithoutContext(
"ReceivedPacket",
1171 void DoRun()
override;
1176 :
TestCase(
"Verify that LogicalLoraChannel and LogicalLoraChannelHelper work as expected")
1219 "Contains does not behave as expected");
1222 "Contains does not behave as expected");
1225 "Contains does not behave as expected");
1244 channelHelper->AddSubBand(subBand);
1245 channelHelper->AddSubBand(subBand1);
1246 channelHelper->SetChannel(0, channel1);
1247 channelHelper->SetChannel(1, channel2);
1248 channelHelper->SetChannel(2, channel3);
1254 channelHelper->AddEvent(
Seconds(2), channel1);
1260 "Wait time doesn't behave as expected");
1265 "Wait time doesn't behave as expected");
1270 "Wait time affects other subbands");
1286 void DoRun()
override;
1292 "Verify that LoraPhy's function to compute the time on air of a packet works as expected")
1450 void DoRun()
override;
1467 :
TestCase(
"Verify that PhyConnectivity works as expected")
1521 return packet1->GetUid() == packet2->GetUid();
1534 loss->SetPathLossExponent(3.76);
1535 loss->SetReference(1, 7.7);
1551 mob1->SetPosition(Vector(0.0, 0.0, 0.0));
1552 mob2->SetPosition(Vector(10.0, 0.0, 0.0));
1553 mob3->SetPosition(Vector(20.0, 0.0, 0.0));
1555 edPhy1->SetMobility(mob1);
1556 edPhy2->SetMobility(mob2);
1557 edPhy3->SetMobility(mob3);
1567 edPhy1->TraceConnectWithoutContext(
"ReceivedPacket",
1569 edPhy2->TraceConnectWithoutContext(
"ReceivedPacket",
1571 edPhy3->TraceConnectWithoutContext(
"ReceivedPacket",
1574 edPhy1->TraceConnectWithoutContext(
"LostPacketBecauseUnderSensitivity",
1576 edPhy2->TraceConnectWithoutContext(
"LostPacketBecauseUnderSensitivity",
1578 edPhy3->TraceConnectWithoutContext(
"LostPacketBecauseUnderSensitivity",
1581 edPhy1->TraceConnectWithoutContext(
"LostPacketBecauseInterference",
1583 edPhy2->TraceConnectWithoutContext(
"LostPacketBecauseInterference",
1585 edPhy3->TraceConnectWithoutContext(
"LostPacketBecauseInterference",
1588 edPhy1->TraceConnectWithoutContext(
"LostPacketBecauseWrongFrequency",
1590 edPhy2->TraceConnectWithoutContext(
"LostPacketBecauseWrongFrequency",
1592 edPhy3->TraceConnectWithoutContext(
"LostPacketBecauseWrongFrequency",
1595 edPhy1->TraceConnectWithoutContext(
"LostPacketBecauseWrongSpreadingFactor",
1597 edPhy2->TraceConnectWithoutContext(
"LostPacketBecauseWrongSpreadingFactor",
1599 edPhy3->TraceConnectWithoutContext(
"LostPacketBecauseWrongSpreadingFactor",
1613 uint8_t buffer[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
1668 "Channel skipped some PHYs when delivering a packet");
1702 "Packet was received by a PHY in SLEEP mode");
1711 ->SetPosition(Vector(2990, 0, 0));
1739 "Packet that should have been lost because of low receive power was received");
1747 ->SetPosition(Vector(2990, 0, 0));
1774 "Packets that should have arrived above sensitivity were under it");
1816 "Packets that should be destroyed by interference weren't");
1847 "Packets were received even though PHY was on a different frequency");
1881 "Packets were received even though PHY was listening for a different spreading factor.");
1917 "Packet changed contents when going through the channel");
1951 "State didn't switch to STANDBY as expected");
1954 "State didn't switch to STANDBY as expected");
1971 void DoRun()
override;
1976 :
TestCase(
"Verify that the MAC layer of end devices behaves as expected")
2018 template <
typename T,
typename... Ts>
2028 void DoRun()
override;
2034 :
TestCase(
"Test functionality of MAC commands when received by a device")
2043template <
typename T,
typename... Ts>
2044std::vector<Ptr<MacCommand>>
2055 pkt->AddHeader(fhdr);
2057 pkt->AddHeader(mhdr);
2058 pkt->AddPaddingAtEnd(4);
2065 pkt->RemoveHeader(mhdr);
2067 pkt->RemoveHeader(fhdr);
2095 uint8_t margin = 20;
2100 "m_lastKnownMarginDb differs from Margin field of LinkCheckAns");
2103 "m_lastKnownGatewayCount differs GwCnt field of LinkCheckAns");
2106 "Unexpected uplink MAC command answer(s) to LinkCheckAns");
2112 uint8_t dataRate = 5;
2113 uint8_t txPower = 2;
2114 uint16_t chMask = 0b101;
2115 uint8_t chMaskCntl = 0;
2116 uint8_t nbTrans = 13;
2120 "m_dataRate does not match DataRate field of LinkAdrReq");
2123 "m_txPowerDbm does not match txPower field of LinkAdrReq");
2126 "m_nbTrans does not match nbTrans field of LinkAdrReq");
2127 auto channels =
m_mac->GetLogicalLoraChannelHelper()->GetRawChannelArray();
2128 for (
size_t i = 0; i < channels.size(); i++)
2130 const auto& c = channels.at(i + 16 * chMaskCntl);
2131 bool actual = (c) ? c->IsEnabledForUplink() :
false;
2132 bool expected = (chMask & 0b1 << i);
2146 uint8_t dataRate = 5;
2147 uint8_t txPower = 2;
2148 uint16_t chMask = 0b010;
2149 uint8_t chMaskCntl = 0;
2150 uint8_t nbTrans = 13;
2151 m_mac->SetUplinkAdrBit(
false);
2155 "m_dataRate expected to differ from DataRate field of LinkAdrReq");
2158 "m_txPowerDbm expected to not match txPower field of LinkAdrReq");
2161 "m_nbTrans expected to differ from nbTrans field of LinkAdrReq");
2162 auto channels =
m_mac->GetLogicalLoraChannelHelper()->GetRawChannelArray();
2163 for (
size_t i = 0; i < channels.size(); i++)
2165 const auto& c = channels.at(i + 16 * chMaskCntl);
2166 bool actual = (c) ? c->IsEnabledForUplink() :
false;
2167 bool expected = (chMask & 0b1 << i);
2181 uint8_t dataRate = 12;
2182 uint8_t txPower = 8;
2183 uint16_t chMask = 0b0;
2184 uint8_t chMaskCntl = 0;
2185 uint8_t nbTrans = 6;
2189 "m_dataRate expected to be default value");
2192 "m_txPowerDbm expected to be default value");
2195 "m_nbTrans expected to be default value");
2196 auto channels =
m_mac->GetLogicalLoraChannelHelper()->GetRawChannelArray();
2197 for (
size_t i = 0; i < channels.size(); i++)
2199 const auto& c = channels.at(i + 16 * chMaskCntl);
2200 bool actual = (c) ? c->IsEnabledForUplink() :
false;
2201 bool expected = (uint16_t(0b111) & 0b1 << i);
2215 uint8_t dataRate = 1;
2216 uint8_t txPower = 7;
2217 uint16_t chMask = 0b1000;
2218 uint8_t chMaskCntl = 0;
2219 uint8_t nbTrans = 3;
2223 "m_dataRate expected to be default value");
2226 "m_txPowerDbm expected to be default value");
2229 "m_nbTrans expected to be default value");
2230 auto channels =
m_mac->GetLogicalLoraChannelHelper()->GetRawChannelArray();
2231 for (
size_t i = 0; i < channels.size(); i++)
2233 const auto& c = channels.at(i + 16 * chMaskCntl);
2234 bool actual = (c) ? c->IsEnabledForUplink() :
false;
2235 bool expected = (uint16_t(0b111) & 0b1 << i);
2249 uint8_t dataRate = 0xF;
2250 uint8_t txPower = 0xF;
2251 uint16_t chMask = 0b0;
2252 uint8_t chMaskCntl = 6;
2253 uint8_t nbTrans = 0;
2255 m_mac->SetDataRate(3);
2256 m_mac->SetTransmissionPowerDbm(12);
2257 m_mac->SetMaxNumberOfTransmissions(15);
2258 auto channels =
m_mac->GetLogicalLoraChannelHelper()->GetRawChannelArray();
2259 channels.at(0)->DisableForUplink();
2263 "m_dataRate expected to be default value");
2266 "m_txPowerDbm expected to be default value");
2269 "m_nbTrans expected to be default value");
2270 for (
size_t i = 0; i < channels.size(); i++)
2272 const auto& c = channels.at(i);
2273 bool actual = (c) ? c->IsEnabledForUplink() :
false;
2274 bool expected = (uint16_t(0b111) & 0b1 << i);
2288 uint8_t maxDutyCycle = 0;
2291 1 / std::pow(2, maxDutyCycle),
2292 "m_aggregatedDutyCycle != 1");
2301 uint8_t maxDutyCycle = 3;
2304 1 / std::pow(2, maxDutyCycle),
2305 "m_aggregatedDutyCycle != 1");
2314 uint8_t rx1DrOffset = 5;
2315 uint8_t rx2DataRate = 5;
2316 double frequencyHz = 863500000;
2317 m_mac->SetDataRate(5);
2320 unsigned(5 - rx1DrOffset),
2321 "Rx1DataRate does not match rx1DrOffset from RxParamSetupReq");
2323 unsigned(rx2DataRate),
2324 "Rx2DataRate does not match rx2DataRate from RxParamSetupReq");
2327 "Rx2 frequency does not match frequency from RxParamSetupReq");
2339 uint8_t rx1DrOffset = 6;
2340 uint8_t rx2DataRate = 12;
2341 double frequencyHz = 871000000;
2342 m_mac->SetDataRate(5);
2346 "Rx1DataRate expected to be default value");
2349 "Rx2DataRate expected to be default value");
2352 "Rx2 frequency expected to be default value");
2375 uint8_t chIndex = 4;
2376 double frequencyHz = 865100000;
2377 uint8_t minDataRate = 1;
2378 uint8_t maxDataRate = 4;
2381 auto c =
m_mac->GetLogicalLoraChannelHelper()->GetRawChannelArray().at(chIndex);
2385 "Channel frequency expected to equal NewChannelReq frequency");
2387 unsigned(minDataRate),
2388 "Channel minDataRate expected to equal NewChannelReq minDataRate");
2390 unsigned(maxDataRate),
2391 "Channel maxDataRate expected to equal NewChannelReq maxDataRate");
2401 uint8_t chIndex = 1;
2402 double frequencyHz = 862000000;
2403 uint8_t minDataRate = 14;
2404 uint8_t maxDataRate = 13;
2407 double defaultFrequenciesHz[3] = {868100000, 868300000, 868500000};
2408 auto channels =
m_mac->GetLogicalLoraChannelHelper()->GetRawChannelArray();
2409 for (
size_t i = 0; i < channels.size(); i++)
2411 const auto& c = channels.at(i);
2418 defaultFrequenciesHz[i],
2419 "Channel frequency expected to equal NewChannelReq frequency");
2422 "Channel " << i <<
" minDataRate expected to be default");
2425 "Channel " << i <<
" maxDataRate expected to be default");
2428 "Channel " << i <<
" state expected to be active by default");
2481 void DoRun()
override;
2487 :
TestCase(
"Test the ADR backoff procedure of the LoRaWAN MAC protocol")
2506 pkt->RemoveHeader(mhdr);
2508 pkt->RemoveHeader(fhdr);
2521 pkt->AddHeader(fhdr);
2523 pkt->AddHeader(mhdr);
2524 pkt->AddPaddingAtEnd(4);
2526 auto chVec =
m_mac->GetLogicalLoraChannelHelper()->GetRawChannelArray();
2527 chVec.at(1)->DisableForUplink();
2528 chVec.at(2)->DisableForUplink();
2535 chVec.at(0)->GetFrequency(),
2568 auto llch =
m_mac->GetLogicalLoraChannelHelper();
2574 m_mac->SetDataRate(5);
2575 m_mac->SetTransmissionPowerDbm(0);
2576 m_mac->SetMaxNumberOfTransmissions(8);
2577 auto chVec = llch->GetRawChannelArray();
2578 chVec.at(0)->DisableForUplink();
2579 chVec.at(1)->DisableForUplink();
2580 chVec.at(2)->DisableForUplink();
2583 llch->SetChannel(3, nonDefaultChannel);
2586 for (
uint32_t fCnt = 0; fCnt <= ADR_ACK_LIMIT + ADR_ACK_DELAY * 7U; ++fCnt)
2591 fCnt >= ADR_ACK_LIMIT,
2592 "Unexpected ADRACKReq value in FHDR of uplink fCnt=" << fCnt);
2593 uint8_t step = (fCnt >= ADR_ACK_LIMIT) ? (fCnt - ADR_ACK_LIMIT) / ADR_ACK_DELAY : 0;
2595 (step > 0) ? 14 : 0,
2596 "Unexpected tx power on uplink fCnt=" << fCnt);
2597 uint8_t expectedDr = (step == 0) ? 5 : (step < 7) ? 5 - (step - 1) : 0;
2600 "Unexpected data rate on uplink fCnt=" << fCnt);
2601 const auto chVec = llch->GetRawChannelArray();
2602 for (uint8_t i = 0; i < 3; ++i)
2606 "Unexpected activation state of channel "
2607 <<
unsigned(i) <<
" on uplink fCnt=" << fCnt);
2610 chVec.at(3)->IsEnabledForUplink(),
2612 "Unexpected activation state of channel 3 on uplink fCnt=" << fCnt);
2622 for (uint16_t fCnt = 0; fCnt <= ADR_ACK_LIMIT + 5; ++fCnt)
2627 fCnt >= ADR_ACK_LIMIT,
2628 "Unexpected ADRACKReq value in FHDR of uplink fCnt=" << fCnt);
2635 ADR_ACK_LIMIT + 5 + 1,
2636 "Unexpected FCnt value in uplink FHDR");
2640 "Unexpected ADRACKReq value in FHDR of uplink fCnt=" << fhdr.
GetFCnt());
2644 ADR_ACK_LIMIT + 5 + 2,
2645 "Unexpected FCnt value in uplink FHDR");
2649 "Unexpected ADRACKReq value in FHDR of uplink fCnt=" << fhdr.
GetFCnt());
2733 void DoRun()
override;
2748 :
TestCase(
"Test the retransmission process of the LoRaWAN MAC protocol")
2768 pkt->RemoveHeader(mhdr);
2770 pkt->RemoveHeader(fhdr);
2784 pkt->AddHeader(fhdr);
2786 pkt->AddHeader(mhdr);
2787 pkt->AddPaddingAtEnd(4);
2789 auto chVec =
m_mac->GetLogicalLoraChannelHelper()->GetRawChannelArray();
2790 chVec.at(1)->DisableForUplink();
2791 chVec.at(2)->DisableForUplink();
2798 chVec.at(0)->GetFrequency(),
2800 m_mac->GetSfFromDataRate(
m_mac->GetDataRate()),
2852 m_mac->SetDataRate(5);
2853 m_mac->TraceConnectWithoutContext(
"SentNewPacket",
2855 m_mac->TraceConnectWithoutContext(
2856 "ConfirmedTransmissionOutcome",
2862 phy->TraceConnectWithoutContext(
"StartSending",
2864 phy->TraceConnectWithoutContext(
"ReceivedPacket",
2883 "Unexpected MAC frame counter value");
2886 "Unexpected number of PHY layer StartSending calls");
2889 "Unexpected number of PHY layer ReceivedPacket calls");
2892 "Unexpected number of MAC layer SendNewPacket calls");
2895 "Unexpected number of MAC layer ConfirmedTransmissionOutcome calls");
2901 uint8_t nbTrans = 4;
2902 m_mac->SetMaxNumberOfTransmissions(nbTrans);
2909 "Unexpected FCnt value in MAC layer");
2912 "Unexpected number of PHY layer StartSending calls");
2915 "Unexpected number of PHY layer ReceivedPacket calls");
2918 "Unexpected number of MAC layer SendNewPacket calls");
2921 "Unexpected number of MAC layer ConfirmedTransmissionOutcome calls");
2927 uint8_t nbTrans = 15;
2928 m_mac->SetMaxNumberOfTransmissions(nbTrans);
2935 "Unexpected MAC frame counter value");
2938 "Unexpected number of physical layer transmissions");
2941 "Unexpected number of PHY layer ReceivedPacket calls");
2944 "Unexpected number of MAC layer SendNewPacket calls");
2947 "Unexpected number of MAC layer ConfirmedTransmissionOutcome calls");
2953 uint8_t nbTrans = 9;
2954 m_mac->SetMaxNumberOfTransmissions(nbTrans);
2965 "Unexpected FCnt value in MAC layer");
2968 "Unexpected number of PHY layer StartSending calls");
2971 "Unexpected number of PHY layer ReceivedPacket calls");
2974 "Unexpected number of MAC layer SendNewPacket calls");
2977 "Unexpected number of MAC layer ConfirmedTransmissionOutcome calls");
2983 uint8_t nbTrans = 8;
2984 m_mac->SetMaxNumberOfTransmissions(nbTrans);
2992 "Unexpected FCnt value in MAC layer");
2995 "Unexpected number of PHY layer StartSending calls");
2998 "Unexpected number of PHY layer ReceivedPacket calls");
3001 "Unexpected number of MAC layer SendNewPacket calls");
3004 "Unexpected number of MAC layer ConfirmedTransmissionOutcome calls");
3010 uint8_t nbTrans = 3;
3011 m_mac->SetMaxNumberOfTransmissions(nbTrans);
3019 "Unexpected FCnt value in MAC layer");
3022 "Unexpected number of PHY layer StartSending calls");
3025 "Unexpected number of PHY layer ReceivedPacket calls");
3028 "Unexpected number of MAC layer SendNewPacket calls");
3031 "Unexpected number of MAC layer ConfirmedTransmissionOutcome calls");
3037 uint8_t nbTrans = 13;
3038 m_mac->SetMaxNumberOfTransmissions(nbTrans);
3046 "Unexpected FCnt value in MAC layer");
3049 "Unexpected number of PHY layer StartSending calls");
3052 "Unexpected number of PHY layer ReceivedPacket calls");
3055 "Unexpected number of MAC layer SendNewPacket calls");
3058 "Unexpected number of MAC layer ConfirmedTransmissionOutcome calls");
3064 uint8_t nbTrans = 7;
3065 m_mac->SetMaxNumberOfTransmissions(nbTrans);
3072 "Unexpected FCnt value in MAC layer");
3075 "Unexpected number of PHY layer StartSending calls");
3078 "Unexpected number of PHY layer ReceivedPacket calls");
3081 "Unexpected number of MAC layer SendNewPacket calls");
3084 "Unexpected number of MAC layer ConfirmedTransmissionOutcome calls");
3087 "Unexpected number of transmissions for confirmed packet");
3090 "Unexpected acknowledgment state for confirmed packet");
3096 uint8_t nbTrans = 6;
3097 m_mac->SetMaxNumberOfTransmissions(nbTrans);
3108 "Unexpected FCnt value in MAC layer");
3111 "Unexpected number of PHY layer StartSending calls");
3114 "Unexpected number of PHY layer ReceivedPacket calls");
3117 "Unexpected number of MAC layer SendNewPacket calls");
3120 "Unexpected number of MAC layer ConfirmedTransmissionOutcome calls");
3123 "Unexpected number of transmissions for confirmed packet");
3126 "Unexpected acknowledgment state for confirmed packet");
3132 uint8_t nbTrans = 9;
3133 m_mac->SetMaxNumberOfTransmissions(nbTrans);
3144 "Unexpected FCnt value in MAC layer");
3147 "Unexpected number of PHY layer StartSending calls");
3150 "Unexpected number of PHY layer ReceivedPacket calls");
3153 "Unexpected number of MAC layer SendNewPacket calls");
3156 "Unexpected number of MAC layer ConfirmedTransmissionOutcome calls");
3159 "Unexpected number of transmissions for confirmed packet");
3162 "Unexpected acknowledgment state for confirmed packet");
3168 uint8_t nbTrans = 10;
3169 m_mac->SetMaxNumberOfTransmissions(nbTrans);
3177 "Unexpected FCnt value in MAC layer");
3180 "Unexpected number of PHY layer StartSending calls");
3183 "Unexpected number of PHY layer ReceivedPacket calls");
3186 "Unexpected number of MAC layer SendNewPacket calls");
3189 "Unexpected number of MAC layer ConfirmedTransmissionOutcome calls");
3192 "Unexpected number of transmissions for confirmed packet");
3195 "Unexpected acknowledgment state for confirmed packet");
3201 uint8_t nbTrans = 14;
3202 m_mac->SetMaxNumberOfTransmissions(nbTrans);
3210 "Unexpected FCnt value in MAC layer");
3213 "Unexpected number of PHY layer StartSending calls");
3216 "Unexpected number of PHY layer ReceivedPacket calls");
3219 "Unexpected number of MAC layer SendNewPacket calls");
3222 "Unexpected number of MAC layer ConfirmedTransmissionOutcome calls");
3225 "Unexpected number of transmissions for confirmed packet");
3228 "Unexpected acknowledgment state for confirmed packet");
3252 void Reset(
double energyJ,
double batteryTh,
Time rxTime =
Time());
3271 void DoRun()
override;
3282 :
TestCase(
"Test the energy depletion of a LoRaWAN device")
3305 phy->SetDevice(dev);
3315 app->SetInterval(
Seconds(1200));
3316 app->SetInitialDelay(
Time());
3317 app->SetPacketSize(0);
3319 m_node->AddApplication(app);
3323 basicSourceHelper.
Set(
"BasicEnergySourceInitialEnergyJ",
DoubleValue(energyJ));
3324 basicSourceHelper.
Set(
"BasicEnergySupplyVoltageV",
DoubleValue(3.3));
3325 basicSourceHelper.
Set(
"BasicEnergyLowBatteryThreshold",
DoubleValue(batteryTh));
3341 auto model = radioEnergyHelper.
Install(dev, source).
Get(0);
3346 const auto channels = mac->GetLogicalLoraChannelHelper()->GetRawChannelArray();
3347 channels.at(1)->DisableForUplink();
3348 channels.at(2)->DisableForUplink();
3350 const auto rx1Frequency = channels.at(0)->GetFrequency();
3351 const auto rx2Frequency = mac->GetSecondReceiveWindowFrequency();
3356 rxPkt->AddHeader(fHdr);
3359 rxPkt->AddHeader(mHdr);
3360 rxPkt->AddPaddingAtEnd(4);
3364 params.spreadingFactor = 12;
3365 params.lowDataRateOptimize =
true;
3372 (rxTime < pktToA +
Seconds(2)) ? rx1Frequency : rx2Frequency,
3374 params.spreadingFactor,
3380 phy->TraceConnectWithoutContext(
3383 model->TraceConnectWithoutContext(
3384 "TotalEnergyConsumption",
3402 "Too many state transitions");
3405 "Unexpected previous state after transition");
3408 "Unexpected current state after transition");
3421 params.spreadingFactor = 12;
3422 params.lowDataRateOptimize =
true;
3423 const double txPowerDbm = 14;
3424 const uint8_t rxWinSymN = 8;
3426 const auto pktInterval =
Seconds(1200);
3431 const double voltageV = 3.3;
3432 const double txEta = 0.452750;
3433 const double txBaseCurrentA = 0.014646;
3434 const double sleepCurrentA = 0.1e-6;
3435 const double rxCurrentA = 10.8e-3;
3438 const double txCurrentA =
DbmToW(txPowerDbm) / (voltageV * txEta) + txBaseCurrentA;
3439 const double txEnergy = txCurrentA * voltageV * pktToA.GetSeconds();
3441 const auto rxWinTime = rxWinSymN *
LoraPhy::GetTSym(params.spreadingFactor, params.bandwidthHz);
3442 const double rxWinEnergy = rxCurrentA * voltageV * rxWinTime.GetSeconds();
3443 const double rxEnergy = rxCurrentA * voltageV * pktToA.GetSeconds();
3446 const auto sleepTime1 =
Seconds(1);
3447 const double sleepEnergy1 = sleepCurrentA * voltageV * sleepTime1.GetSeconds();
3449 const auto sleepTime2 =
Seconds(1) - rxWinTime;
3450 const double sleepEnergy2 = sleepCurrentA * voltageV * sleepTime2.GetSeconds();
3452 const auto sleepTime3 = pktInterval - pktToA -
Seconds(1) - .5 * rxWinTime - pktToA;
3453 const double sleepEnergy3 = sleepCurrentA * voltageV * sleepTime3.GetSeconds();
3455 const auto sleepTime4 = pktInterval - pktToA -
Seconds(2) - .5 * rxWinTime - pktToA;
3456 const double sleepEnergy4 = sleepCurrentA * voltageV * sleepTime4.GetSeconds();
3458 const auto sleepTime5 = pktInterval - pktToA -
Seconds(2) - rxWinTime;
3459 const double sleepEnergy5 = sleepCurrentA * voltageV * sleepTime3.GetSeconds();
3461 static constexpr auto ENERGY_DEPLETION_SCHEDULING_TOLERANCE_J =
3466 const double initialEnergy = txEnergy / 2;
3467 const double lowBatteryTh = .1 * txEnergy / initialEnergy;
3474 Reset(initialEnergy, lowBatteryTh);
3478 "Unexpected number of state transitions");
3480 ENERGY_DEPLETION_SCHEDULING_TOLERANCE_J,
3481 "Unexpected energy consumption");
3486 const double initialEnergy = txEnergy + sleepEnergy1;
3487 const double lowBatteryTh = (txEnergy / 2 + sleepEnergy1) / initialEnergy;
3495 Reset(initialEnergy, lowBatteryTh);
3499 "Unexpected number of state transitions");
3501 initialEnergy * (1 - lowBatteryTh),
3502 "Unexpected energy consumption");
3507 const double initialEnergy = txEnergy + sleepEnergy1 / 2;
3508 const double lowBatteryTh = .1 * sleepEnergy1 / initialEnergy;
3517 Reset(initialEnergy, lowBatteryTh);
3521 "Unexpected number of state transitions");
3523 ENERGY_DEPLETION_SCHEDULING_TOLERANCE_J,
3524 "Unexpected energy consumption");
3529 const double initialEnergy = txEnergy + sleepEnergy1 + rxWinEnergy;
3530 const double lowBatteryTh = (sleepEnergy1 / 2 + rxWinEnergy) / initialEnergy;
3540 Reset(initialEnergy, lowBatteryTh);
3544 "Unexpected number of state transitions");
3546 initialEnergy * (1 - lowBatteryTh),
3547 "Unexpected energy consumption");
3552 const double initialEnergy = txEnergy + sleepEnergy1 + rxWinEnergy / 2;
3553 const double lowBatteryTh = .1 * rxWinEnergy / initialEnergy;
3563 Reset(initialEnergy, lowBatteryTh);
3567 "Unexpected number of state transitions");
3569 ENERGY_DEPLETION_SCHEDULING_TOLERANCE_J,
3570 "Unexpected energy consumption");
3575 const double initialEnergy = txEnergy + sleepEnergy1 + rxWinEnergy;
3576 const double lowBatteryTh = (rxWinEnergy / 2) / initialEnergy;
3577 const auto rxDelay = pktToA +
Seconds(1) + .75 * rxWinTime;
3588 Reset(initialEnergy, lowBatteryTh, rxDelay);
3592 "Unexpected number of state transitions");
3594 initialEnergy * (1 - lowBatteryTh),
3595 "Unexpected energy consumption");
3600 const double initialEnergy = txEnergy + sleepEnergy1 + .5 * rxWinEnergy + rxEnergy / 2;
3601 const double lowBatteryTh = .1 * rxEnergy / initialEnergy;
3602 const auto rxDelay = pktToA +
Seconds(1) + .5 * rxWinTime;
3613 Reset(initialEnergy, lowBatteryTh, rxDelay);
3617 "Unexpected number of state transitions");
3619 ENERGY_DEPLETION_SCHEDULING_TOLERANCE_J,
3620 "Unexpected energy consumption");
3625 const double initialEnergy =
3626 txEnergy + sleepEnergy1 + .5 * rxWinEnergy + rxEnergy + sleepEnergy3;
3627 const double lowBatteryTh = (rxEnergy / 2 + sleepEnergy3) / initialEnergy;
3628 const auto rxDelay = pktToA +
Seconds(1) + .5 * rxWinTime;
3640 Reset(initialEnergy, lowBatteryTh, rxDelay);
3644 "Unexpected number of state transitions");
3646 initialEnergy * (1 - lowBatteryTh),
3647 "Unexpected energy consumption");
3652 const double initialEnergy =
3653 txEnergy + sleepEnergy1 + .5 * rxWinEnergy + rxEnergy + sleepEnergy3 / 2;
3654 const double lowBatteryTh = .1 * sleepEnergy3 / initialEnergy;
3655 const auto rxDelay = pktToA +
Seconds(1) + .5 * rxWinTime;
3668 Reset(initialEnergy, lowBatteryTh, rxDelay);
3672 "Unexpected number of state transitions");
3674 ENERGY_DEPLETION_SCHEDULING_TOLERANCE_J,
3675 "Unexpected energy consumption");
3680 const double initialEnergy = txEnergy + sleepEnergy1 + rxWinEnergy + sleepEnergy2;
3681 const double lowBatteryTh = (rxWinEnergy / 2 + sleepEnergy2) / initialEnergy;
3692 Reset(initialEnergy, lowBatteryTh);
3696 "Unexpected number of state transitions");
3698 initialEnergy * (1 - lowBatteryTh),
3699 "Unexpected energy consumption");
3704 const double initialEnergy = txEnergy + sleepEnergy1 + rxWinEnergy + sleepEnergy2 / 2;
3705 const double lowBatteryTh = .1 * sleepEnergy2 / initialEnergy;
3717 Reset(initialEnergy, lowBatteryTh);
3721 "Unexpected number of state transitions");
3723 ENERGY_DEPLETION_SCHEDULING_TOLERANCE_J,
3724 "Unexpected energy consumption");
3729 const double initialEnergy =
3730 txEnergy + sleepEnergy1 + rxWinEnergy + sleepEnergy2 + rxWinEnergy;
3731 const double lowBatteryTh = (sleepEnergy2 / 2 + rxWinEnergy) / initialEnergy;
3744 Reset(initialEnergy, lowBatteryTh);
3748 "Unexpected number of state transitions");
3750 initialEnergy * (1 - lowBatteryTh),
3751 "Unexpected energy consumption");
3756 const double initialEnergy =
3757 txEnergy + sleepEnergy1 + rxWinEnergy + sleepEnergy2 + rxWinEnergy;
3758 const double lowBatteryTh = (rxWinEnergy / 2) / initialEnergy;
3759 const auto rxDelay = pktToA +
Seconds(2) + .75 * rxWinTime;
3773 Reset(initialEnergy, lowBatteryTh, rxDelay);
3777 "Unexpected number of state transitions");
3779 initialEnergy * (1 - lowBatteryTh),
3780 "Unexpected energy consumption");
3785 const double initialEnergy =
3786 txEnergy + sleepEnergy1 + rxWinEnergy + sleepEnergy2 + .5 * rxWinEnergy + rxEnergy / 2;
3787 const double lowBatteryTh = .1 * rxEnergy / initialEnergy;
3788 const auto rxDelay = pktToA +
Seconds(2) + .5 * rxWinTime;
3802 Reset(initialEnergy, lowBatteryTh, rxDelay);
3806 "Unexpected number of state transitions");
3808 ENERGY_DEPLETION_SCHEDULING_TOLERANCE_J,
3809 "Unexpected energy consumption");
3814 const double initialEnergy = txEnergy + sleepEnergy1 + rxWinEnergy + sleepEnergy2 +
3815 .5 * rxWinEnergy + rxEnergy + sleepEnergy4;
3816 const double lowBatteryTh = (rxEnergy / 2 + sleepEnergy4) / initialEnergy;
3817 const auto rxDelay = pktToA +
Seconds(2) + .5 * rxWinTime;
3832 Reset(initialEnergy, lowBatteryTh, rxDelay);
3836 "Unexpected number of state transitions");
3838 initialEnergy * (1 - lowBatteryTh),
3839 "Unexpected energy consumption");
3844 const double initialEnergy = txEnergy + sleepEnergy1 + rxWinEnergy + sleepEnergy2 +
3845 .5 * rxWinEnergy + rxEnergy + sleepEnergy4 / 2;
3846 const double lowBatteryTh = .1 * sleepEnergy4 / initialEnergy;
3847 const auto rxDelay = pktToA +
Seconds(2) + .5 * rxWinTime;
3863 Reset(initialEnergy, lowBatteryTh, rxDelay);
3867 "Unexpected number of state transitions");
3869 ENERGY_DEPLETION_SCHEDULING_TOLERANCE_J,
3870 "Unexpected energy consumption");
3875 const double initialEnergy =
3876 txEnergy + sleepEnergy1 + rxWinEnergy + sleepEnergy2 + rxWinEnergy / 2;
3877 const double lowBatteryTh = .1 * rxWinEnergy / initialEnergy;
3890 Reset(initialEnergy, lowBatteryTh);
3894 "Unexpected number of state transitions");
3896 ENERGY_DEPLETION_SCHEDULING_TOLERANCE_J,
3897 "Unexpected energy consumption");
3902 const double initialEnergy =
3903 txEnergy + sleepEnergy1 + rxWinEnergy + sleepEnergy2 + rxWinEnergy + sleepEnergy5;
3904 const double lowBatteryTh = (rxWinEnergy / 2 + sleepEnergy5) / initialEnergy;
3918 Reset(initialEnergy, lowBatteryTh);
3922 "Unexpected number of state transitions");
3924 initialEnergy * (1 - lowBatteryTh),
3925 "Unexpected energy consumption");
3930 const double initialEnergy =
3931 txEnergy + sleepEnergy1 + rxWinEnergy + sleepEnergy2 + rxWinEnergy + sleepEnergy5 / 2;
3932 const double lowBatteryTh = .1 * sleepEnergy5 / initialEnergy;
3947 Reset(initialEnergy, lowBatteryTh);
3951 "Unexpected number of state transitions");
3953 ENERGY_DEPLETION_SCHEDULING_TOLERANCE_J,
3954 "Unexpected energy consumption");
3959 const double initialEnergy = txEnergy + sleepEnergy1 + rxWinEnergy + sleepEnergy2 +
3960 rxWinEnergy + sleepEnergy5 + .1 * txEnergy;
3961 const double lowBatteryTh = (sleepEnergy5 / 2 + .1 * txEnergy) / initialEnergy;
3977 Reset(initialEnergy, lowBatteryTh);
3981 "Unexpected number of state transitions");
3983 initialEnergy * (1 - lowBatteryTh),
3984 "Unexpected energy consumption");
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 ScheduleRx1Downlink(Time after)
Create and schedule the PHY reception of a downlink transmission configured for the LoRaWAN MAC first...
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 that LoRa device correctly turning OFF on energy depletion.
Ptr< Node > m_node
LoRaWAN end device node used in tests.
size_t m_currentDeviceStateIndex
Track current PHY state of the device.
EndDeviceLoraPhy::State State
PHY state.
std::vector< State > m_expectedStates
States the PHY must go through.
void OnTotalEnergyConsumptionChange(double prev, double curr)
Callback for tracing a device PHY's energy model energy consumption.
~EnergyDepletionTest() override
Destructor.
void OnEndDeviceStateChange(State prev, State curr)
Callback for tracing changes in the LoRa PHY state.
double m_totalEnergyConsumption
Track PHY energy consumption in Joules.
void Reset(double energyJ, double batteryTh, Time rxTime=Time())
Reset device for new sub test case.
void DoRun() override
Implementation to actually run this TestCase.
EnergyDepletionTest()
Default constructor.
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.
It tests LoraDeviceAddress comparison operators overrides and generation of new addresses with LoraDe...
LorawanAddressTest()
Default constructor.
~LorawanAddressTest() 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.
void Reset(uint8_t rxPathNb)
Reset counters and gateway PHY for new sub test case.
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.
int m_interferenceCalls
Counter for LostPacketBecauseInterference calls.
int m_maxOccupiedReceptionPaths
Max number of concurrent OccupiedReceptionPaths.
It tests the correct execution of the retransmissions in LoRaWAN devices.
int m_macConfirmedTxOutcome
Counter for MacConfirmedTransmissionOutcome calls.
RetransmissionTest()
Default constructor.
int m_phyStartSendingCalls
Counter for PhyStartSending calls.
Ptr< Packet > m_packet
Target packet for tracing.
void DoRun() override
Implementation to actually run this TestCase.
Ptr< ClassAEndDeviceLorawanMac > m_mac
The end device's MAC layer used in tests.
int m_macSentNewPacketCalls
Counter for MacSentNewPacket calls.
uint8_t m_numTransmissions
Number of confirmed packet transmissions.
void PhyStartSending(Ptr< const Packet > packet, uint32_t node)
Callback for tracing PHY layer StartSending.
~RetransmissionTest() override
Destructor.
int m_phyReceivedPacketCalls
Counter for PhyReceivedPacket calls.
bool m_successfullyAcked
Acknowledgement of confirmed packet.
void SendUplink(LoraFrameHeader &fhdr)
Create and send an empty app payload unconfirmed frame through the MAC layer NbTrans times.
void PhyReceivedPacket(Ptr< const Packet > packet, uint32_t node)
Callback for tracing PHY layer ReceivedPacket.
void ScheduleRx1Downlink(Time after, bool ack=false)
Create and schedule the PHY reception of a downlink transmission configured for the LoRaWAN MAC first...
void MacConfirmedTransmissionOutcome(uint8_t txCount, bool ack, Time firstAttempt, Ptr< Packet > packet)
Callback for tracing the outcome of MAC layer's confirmed packet retransmission and acknowledgement.
void MacSentNewPacket(Ptr< const Packet > packet)
Callback for tracing MAC layer SentNewPacket.
void Reset()
This function resets the simulation and device MAC layer, use before test sub-cases.
It tests the correctness of the LoraPhy::GetTimeOnAir calculator against a number of pre-sourced time...
void DoRun() override
Implementation to actually run this TestCase.
~TimeOnAirTest() override
Destructor.
TimeOnAirTest()
Default constructor.
Creates a BasicEnergySource object.
void Set(std::string name, const AttributeValue &v) override
iterator in a Buffer instance
automatically resized byte buffer
void AddAtStart(uint32_t start)
Buffer::Iterator Begin() const
energy::DeviceEnergyModelContainer Install(Ptr< NetDevice > device, Ptr< energy::EnergySource > source) const
This class can be used to hold variables of floating point type such as 'double' or 'float'.
energy::EnergySourceContainer Install(Ptr< Node > node) 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 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 EventId ScheduleNow(FUNC f, Ts &&... args)
Schedule an event to expire Now.
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.
bool IsStrictlyPositive() const
Exactly equivalent to t > 0.
static Time Max()
Maximum representable Time Not to be confused with Max(Time,Time).
Ptr< DeviceEnergyModel > Get(uint32_t i) const
Get the i-th Ptr<DeviceEnergyModel> stored in this container.
Ptr< EnergySource > Get(uint32_t i) const
Get the i-th Ptr<EnergySource> stored in this container.
void ReceiveSingle(uint32_t frequencyHz, IQPolarity iqPolarity, uint8_t spreadingFactor, uint32_t bandwidthHz, uint8_t symbNumTimeout, RxTimeoutCallback rxTimeoutCallback)
This function starts a reception attempt that will time-out if no transmission preamble is detected.
Callback< void > RxTimeoutCallback
Type definition for a callback for when a packet reception hardware timeout expires.
State
An enumeration of the possible internal states of an EndDeviceLoraPhy.
@ STANDBY
The PHY layer is in standby mode.
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.
static CollisionMatrix collisionMatrix
Collision matrix type set by the constructor.
uint8_t IsDestroyedByInterference(Ptr< LoraInterferenceHelper::Event > event)
Determine whether the event was destroyed by interference or not.
static Time GetTimeOnAir(uint32_t phyPayloadLen, const LoraTxParameters &txParams)
Compute the total transmission time for a physical packet based on modulation parameters.
static Time GetTSym(uint8_t spreadingFactor, uint32_t bandwidthHz)
Compute the symbol time from spreading factor and bandwidth.
Installs LoraRadioEnergyModel on devices.
void Set(std::string name, const AttributeValue &v) override
void SetTxCurrentModel(std::string name, Ts &&... args)
static constexpr double ENERGY_EPSILON_J
Small constant in Joules, subtracted from remaining energy of the source while scheduling for the fut...
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 StartReceive(Ptr< Packet > packet, uint32_t frequencyHz, IQPolarity iqPolarity, uint8_t spreadingFactor, double rxPowerDbm, Time duration) override
Start receiving a packet.
void Send(Ptr< Packet > packet, uint32_t frequencyHz, IQPolarity iqPolarity, const LoraTxParameters &txParams, double txPowerDbm) override
Instruct the PHY to send a packet according to some parameters.
void StartReceive(Ptr< Packet > packet, uint32_t frequencyHz, IQPolarity iqPolarity, uint8_t spreadingFactor, double rxPowerDbm, Time duration) override
Start receiving a packet.
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 ",...
@ DOWN
Downlink / Downchirp / Inverted polarity.
@ UP
Uplink / Upchirp / Normal polarity.
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_EXPECT_MSG_GT_OR_EQ(actual, limit, msg)
Test that an actual value is greater than or equal to limit and report 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_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_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 NanoSeconds(uint64_t value)
Construct a Time in the indicated unit.
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.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
static LorawanTestSuite lorawanTestSuite
double DbmToW(double dBm)
Convert from dBm to Watts.
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...
CodingRate codingRate
Transmission coding rate.
uint32_t bandwidthHz
Transmission bandwidth in Hz.
bool implicitHeader
Whether to use implicit header mode.
uint8_t spreadingFactor
Symbol Spreading Factor (SF).
bool crcEnabled
Whether Cyclic Redundancy Check (CRC) is enabled.
bool lowDataRateOptimize
Low Data Rate Optimization (mandated for SF11 and SF12).
uint16_t preambleLenSymb
Number of symbols in the packet preamble.