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 "FType changes in the serialization/deserialization process");
323 "FType 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");
434 void DoRun()
override;
440 void Reset(uint8_t rxPathNb);
480 :
TestCase(
"Verify that ReceivePaths work as expected")
506 for (uint8_t i = 0; i < rxPathNb; i++)
513 "LostPacketBecauseNoMoreReceivers",
516 "OccupiedReceptionPaths",
520 gatewayPhy->TraceConnectWithoutContext(
"LostPacketBecauseInterference",
522 gatewayPhy->TraceConnectWithoutContext(
"ReceivedPacket",
1160 void DoRun()
override;
1165 :
TestCase(
"Verify that LogicalLoraChannel and LogicalLoraChannelHelper work as expected")
1208 "Contains does not behave as expected");
1211 "Contains does not behave as expected");
1214 "Contains does not behave as expected");
1233 channelHelper->AddSubBand(subBand);
1234 channelHelper->AddSubBand(subBand1);
1235 channelHelper->SetChannel(0, channel1);
1236 channelHelper->SetChannel(1, channel2);
1237 channelHelper->SetChannel(2, channel3);
1243 channelHelper->AddEvent(
Seconds(2), channel1);
1249 "Wait time doesn't behave as expected");
1254 "Wait time doesn't behave as expected");
1259 "Wait time affects other subbands");
1275 void DoRun()
override;
1281 "Verify that LoraPhy's function to compute the time on air of a packet works as expected")
1439 void DoRun()
override;
1456 :
TestCase(
"Verify that PhyConnectivity works as expected")
1510 return packet1->GetUid() == packet2->GetUid();
1523 loss->SetPathLossExponent(3.76);
1524 loss->SetReference(1, 7.7);
1540 mob1->SetPosition(Vector(0.0, 0.0, 0.0));
1541 mob2->SetPosition(Vector(10.0, 0.0, 0.0));
1542 mob3->SetPosition(Vector(20.0, 0.0, 0.0));
1544 edPhy1->SetMobility(mob1);
1545 edPhy2->SetMobility(mob2);
1546 edPhy3->SetMobility(mob3);
1556 edPhy1->TraceConnectWithoutContext(
"ReceivedPacket",
1558 edPhy2->TraceConnectWithoutContext(
"ReceivedPacket",
1560 edPhy3->TraceConnectWithoutContext(
"ReceivedPacket",
1563 edPhy1->TraceConnectWithoutContext(
"LostPacketBecauseUnderSensitivity",
1565 edPhy2->TraceConnectWithoutContext(
"LostPacketBecauseUnderSensitivity",
1567 edPhy3->TraceConnectWithoutContext(
"LostPacketBecauseUnderSensitivity",
1570 edPhy1->TraceConnectWithoutContext(
"LostPacketBecauseInterference",
1572 edPhy2->TraceConnectWithoutContext(
"LostPacketBecauseInterference",
1574 edPhy3->TraceConnectWithoutContext(
"LostPacketBecauseInterference",
1577 edPhy1->TraceConnectWithoutContext(
"LostPacketBecauseWrongFrequency",
1579 edPhy2->TraceConnectWithoutContext(
"LostPacketBecauseWrongFrequency",
1581 edPhy3->TraceConnectWithoutContext(
"LostPacketBecauseWrongFrequency",
1584 edPhy1->TraceConnectWithoutContext(
"LostPacketBecauseWrongSpreadingFactor",
1586 edPhy2->TraceConnectWithoutContext(
"LostPacketBecauseWrongSpreadingFactor",
1588 edPhy3->TraceConnectWithoutContext(
"LostPacketBecauseWrongSpreadingFactor",
1602 uint8_t buffer[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
1658 "Channel skipped some PHYs when delivering a packet");
1692 "Packet was received by a PHY in SLEEP mode");
1701 ->SetPosition(Vector(2990, 0, 0));
1729 "Packet that should have been lost because of low receive power was received");
1737 ->SetPosition(Vector(2990, 0, 0));
1764 "Packets that should have arrived above sensitivity were under it");
1806 "Packets that should be destroyed by interference weren't");
1837 "Packets were received even though PHY was on a different frequency");
1871 "Packets were received even though PHY was listening for a different spreading factor.");
1905 "Packet changed contents when going through the channel");
1939 "State didn't switch to STANDBY as expected");
1942 "State didn't switch to STANDBY as expected");
1959 void DoRun()
override;
1964 :
TestCase(
"Verify that the MAC layer of end devices behaves as expected")
2006 template <
typename T,
typename... Ts>
2016 void DoRun()
override;
2022 :
TestCase(
"Test functionality of MAC commands when received by a device")
2031template <
typename T,
typename... Ts>
2032std::vector<Ptr<MacCommand>>
2043 pkt->AddHeader(fhdr);
2045 pkt->AddHeader(mhdr);
2052 pkt->RemoveHeader(mhdr);
2054 pkt->RemoveHeader(fhdr);
2082 uint8_t margin = 20;
2087 "m_lastKnownMarginDb differs from Margin field of LinkCheckAns");
2090 "m_lastKnownGatewayCount differs GwCnt field of LinkCheckAns");
2093 "Unexpected uplink MAC command answer(s) to LinkCheckAns");
2099 uint8_t dataRate = 5;
2100 uint8_t txPower = 2;
2101 uint16_t chMask = 0b101;
2102 uint8_t chMaskCntl = 0;
2103 uint8_t nbTrans = 13;
2107 "m_dataRate does not match DataRate field of LinkAdrReq");
2110 "m_txPowerDbm does not match txPower field of LinkAdrReq");
2113 "m_nbTrans does not match nbTrans field of LinkAdrReq");
2114 auto channels =
m_mac->GetLogicalLoraChannelHelper()->GetRawChannelArray();
2115 for (
size_t i = 0; i < channels.size(); i++)
2117 const auto& c = channels.at(i + 16 * chMaskCntl);
2118 bool actual = (c) ? c->IsEnabledForUplink() :
false;
2119 bool expected = (chMask & 0b1 << i);
2133 uint8_t dataRate = 5;
2134 uint8_t txPower = 2;
2135 uint16_t chMask = 0b010;
2136 uint8_t chMaskCntl = 0;
2137 uint8_t nbTrans = 13;
2138 m_mac->SetUplinkAdrBit(
false);
2142 "m_dataRate expected to differ from DataRate field of LinkAdrReq");
2145 "m_txPowerDbm expected to not match txPower field of LinkAdrReq");
2148 "m_nbTrans expected to differ from nbTrans field of LinkAdrReq");
2149 auto channels =
m_mac->GetLogicalLoraChannelHelper()->GetRawChannelArray();
2150 for (
size_t i = 0; i < channels.size(); i++)
2152 const auto& c = channels.at(i + 16 * chMaskCntl);
2153 bool actual = (c) ? c->IsEnabledForUplink() :
false;
2154 bool expected = (chMask & 0b1 << i);
2168 uint8_t dataRate = 12;
2169 uint8_t txPower = 8;
2170 uint16_t chMask = 0b0;
2171 uint8_t chMaskCntl = 0;
2172 uint8_t nbTrans = 6;
2176 "m_dataRate expected to be default value");
2179 "m_txPowerDbm expected to be default value");
2182 "m_nbTrans expected to be default value");
2183 auto channels =
m_mac->GetLogicalLoraChannelHelper()->GetRawChannelArray();
2184 for (
size_t i = 0; i < channels.size(); i++)
2186 const auto& c = channels.at(i + 16 * chMaskCntl);
2187 bool actual = (c) ? c->IsEnabledForUplink() :
false;
2188 bool expected = (uint16_t(0b111) & 0b1 << i);
2202 uint8_t dataRate = 1;
2203 uint8_t txPower = 7;
2204 uint16_t chMask = 0b1000;
2205 uint8_t chMaskCntl = 0;
2206 uint8_t nbTrans = 3;
2210 "m_dataRate expected to be default value");
2213 "m_txPowerDbm expected to be default value");
2216 "m_nbTrans expected to be default value");
2217 auto channels =
m_mac->GetLogicalLoraChannelHelper()->GetRawChannelArray();
2218 for (
size_t i = 0; i < channels.size(); i++)
2220 const auto& c = channels.at(i + 16 * chMaskCntl);
2221 bool actual = (c) ? c->IsEnabledForUplink() :
false;
2222 bool expected = (uint16_t(0b111) & 0b1 << i);
2236 uint8_t dataRate = 0xF;
2237 uint8_t txPower = 0xF;
2238 uint16_t chMask = 0b0;
2239 uint8_t chMaskCntl = 6;
2240 uint8_t nbTrans = 0;
2242 m_mac->SetDataRate(3);
2243 m_mac->SetTransmissionPowerDbm(12);
2244 m_mac->SetMaxNumberOfTransmissions(15);
2245 auto channels =
m_mac->GetLogicalLoraChannelHelper()->GetRawChannelArray();
2246 channels.at(0)->DisableForUplink();
2250 "m_dataRate expected to be default value");
2253 "m_txPowerDbm expected to be default value");
2256 "m_nbTrans expected to be default value");
2257 for (
size_t i = 0; i < channels.size(); i++)
2259 const auto& c = channels.at(i);
2260 bool actual = (c) ? c->IsEnabledForUplink() :
false;
2261 bool expected = (uint16_t(0b111) & 0b1 << i);
2275 uint8_t maxDutyCycle = 0;
2278 1 / std::pow(2, maxDutyCycle),
2279 "m_aggregatedDutyCycle != 1");
2288 uint8_t maxDutyCycle = 3;
2291 1 / std::pow(2, maxDutyCycle),
2292 "m_aggregatedDutyCycle != 1");
2301 uint8_t rx1DrOffset = 5;
2302 uint8_t rx2DataRate = 5;
2303 double frequencyHz = 863500000;
2304 m_mac->SetDataRate(5);
2307 unsigned(5 - rx1DrOffset),
2308 "Rx1DataRate does not match rx1DrOffset from RxParamSetupReq");
2310 unsigned(rx2DataRate),
2311 "Rx2DataRate does not match rx2DataRate from RxParamSetupReq");
2314 "Rx2 frequency does not match frequency from RxParamSetupReq");
2326 uint8_t rx1DrOffset = 6;
2327 uint8_t rx2DataRate = 12;
2328 double frequencyHz = 871000000;
2329 m_mac->SetDataRate(5);
2333 "Rx1DataRate expected to be default value");
2336 "Rx2DataRate expected to be default value");
2339 "Rx2 frequency expected to be default value");
2362 uint8_t chIndex = 4;
2363 double frequencyHz = 865100000;
2364 uint8_t minDataRate = 1;
2365 uint8_t maxDataRate = 4;
2368 auto c =
m_mac->GetLogicalLoraChannelHelper()->GetRawChannelArray().at(chIndex);
2372 "Channel frequency expected to equal NewChannelReq frequency");
2374 unsigned(minDataRate),
2375 "Channel minDataRate expected to equal NewChannelReq minDataRate");
2377 unsigned(maxDataRate),
2378 "Channel maxDataRate expected to equal NewChannelReq maxDataRate");
2388 uint8_t chIndex = 1;
2389 double frequencyHz = 862000000;
2390 uint8_t minDataRate = 14;
2391 uint8_t maxDataRate = 13;
2394 double defaultFrequenciesHz[3] = {868100000, 868300000, 868500000};
2395 auto channels =
m_mac->GetLogicalLoraChannelHelper()->GetRawChannelArray();
2396 for (
size_t i = 0; i < channels.size(); i++)
2398 const auto& c = channels.at(i);
2405 defaultFrequenciesHz[i],
2406 "Channel frequency expected to equal NewChannelReq frequency");
2409 "Channel " << i <<
" minDataRate expected to be default");
2412 "Channel " << i <<
" maxDataRate expected to be default");
2415 "Channel " << i <<
" state expected to be active by default");
2468 void DoRun()
override;
2474 :
TestCase(
"Test the ADR backoff procedure of the LoRaWAN MAC protocol")
2493 pkt->RemoveHeader(mhdr);
2495 pkt->RemoveHeader(fhdr);
2508 pkt->AddHeader(fhdr);
2510 pkt->AddHeader(mhdr);
2512 auto chVec =
m_mac->GetLogicalLoraChannelHelper()->GetRawChannelArray();
2513 chVec.at(1)->DisableForUplink();
2514 chVec.at(2)->DisableForUplink();
2521 chVec.at(0)->GetFrequency(),
2554 auto llch =
m_mac->GetLogicalLoraChannelHelper();
2560 m_mac->SetDataRate(5);
2561 m_mac->SetTransmissionPowerDbm(0);
2562 m_mac->SetMaxNumberOfTransmissions(8);
2563 auto chVec = llch->GetRawChannelArray();
2564 chVec.at(0)->DisableForUplink();
2565 chVec.at(1)->DisableForUplink();
2566 chVec.at(2)->DisableForUplink();
2569 llch->SetChannel(3, nonDefaultChannel);
2572 for (
uint32_t fCnt = 0; fCnt <= ADR_ACK_LIMIT + ADR_ACK_DELAY * 7U; ++fCnt)
2577 fCnt >= ADR_ACK_LIMIT,
2578 "Unexpected ADRACKReq value in FHDR of uplink fCnt=" << fCnt);
2579 uint8_t step = (fCnt >= ADR_ACK_LIMIT) ? (fCnt - ADR_ACK_LIMIT) / ADR_ACK_DELAY : 0;
2581 (step > 0) ? 14 : 0,
2582 "Unexpected tx power on uplink fCnt=" << fCnt);
2583 uint8_t expectedDr = (step == 0) ? 5 : (step < 7) ? 5 - (step - 1) : 0;
2586 "Unexpected data rate on uplink fCnt=" << fCnt);
2587 const auto chVec = llch->GetRawChannelArray();
2588 for (uint8_t i = 0; i < 3; ++i)
2592 "Unexpected activation state of channel "
2593 <<
unsigned(i) <<
" on uplink fCnt=" << fCnt);
2596 chVec.at(3)->IsEnabledForUplink(),
2598 "Unexpected activation state of channel 3 on uplink fCnt=" << fCnt);
2608 for (uint16_t fCnt = 0; fCnt <= ADR_ACK_LIMIT + 5; ++fCnt)
2613 fCnt >= ADR_ACK_LIMIT,
2614 "Unexpected ADRACKReq value in FHDR of uplink fCnt=" << fCnt);
2621 ADR_ACK_LIMIT + 5 + 1,
2622 "Unexpected FCnt value in uplink FHDR");
2626 "Unexpected ADRACKReq value in FHDR of uplink fCnt=" << fhdr.
GetFCnt());
2630 ADR_ACK_LIMIT + 5 + 2,
2631 "Unexpected FCnt value in uplink FHDR");
2635 "Unexpected ADRACKReq value in FHDR of uplink fCnt=" << fhdr.
GetFCnt());
2719 void DoRun()
override;
2734 :
TestCase(
"Test the retransmission process of the LoRaWAN MAC protocol")
2754 pkt->RemoveHeader(mhdr);
2756 pkt->RemoveHeader(fhdr);
2770 pkt->AddHeader(fhdr);
2772 pkt->AddHeader(mhdr);
2774 auto chVec =
m_mac->GetLogicalLoraChannelHelper()->GetRawChannelArray();
2775 chVec.at(1)->DisableForUplink();
2776 chVec.at(2)->DisableForUplink();
2783 chVec.at(0)->GetFrequency(),
2785 m_mac->GetSfFromDataRate(
m_mac->GetDataRate()),
2837 m_mac->SetDataRate(5);
2838 m_mac->TraceConnectWithoutContext(
"SentNewPacket",
2840 m_mac->TraceConnectWithoutContext(
2841 "ConfirmedTransmissionOutcome",
2847 phy->TraceConnectWithoutContext(
"StartSending",
2849 phy->TraceConnectWithoutContext(
"ReceivedPacket",
2852 m_mac->Initialize();
2869 "Unexpected MAC frame counter value");
2872 "Unexpected number of PHY layer StartSending calls");
2875 "Unexpected number of PHY layer ReceivedPacket calls");
2878 "Unexpected number of MAC layer SendNewPacket calls");
2881 "Unexpected number of MAC layer ConfirmedTransmissionOutcome calls");
2887 uint8_t nbTrans = 4;
2888 m_mac->SetMaxNumberOfTransmissions(nbTrans);
2895 "Unexpected FCnt value in MAC layer");
2898 "Unexpected number of PHY layer StartSending calls");
2901 "Unexpected number of PHY layer ReceivedPacket calls");
2904 "Unexpected number of MAC layer SendNewPacket calls");
2907 "Unexpected number of MAC layer ConfirmedTransmissionOutcome calls");
2913 uint8_t nbTrans = 15;
2914 m_mac->SetMaxNumberOfTransmissions(nbTrans);
2921 "Unexpected MAC frame counter value");
2924 "Unexpected number of physical layer transmissions");
2927 "Unexpected number of PHY layer ReceivedPacket calls");
2930 "Unexpected number of MAC layer SendNewPacket calls");
2933 "Unexpected number of MAC layer ConfirmedTransmissionOutcome calls");
2939 uint8_t nbTrans = 9;
2940 m_mac->SetMaxNumberOfTransmissions(nbTrans);
2951 "Unexpected FCnt value in MAC layer");
2954 "Unexpected number of PHY layer StartSending calls");
2957 "Unexpected number of PHY layer ReceivedPacket calls");
2960 "Unexpected number of MAC layer SendNewPacket calls");
2963 "Unexpected number of MAC layer ConfirmedTransmissionOutcome calls");
2969 uint8_t nbTrans = 8;
2970 m_mac->SetMaxNumberOfTransmissions(nbTrans);
2978 "Unexpected FCnt value in MAC layer");
2981 "Unexpected number of PHY layer StartSending calls");
2984 "Unexpected number of PHY layer ReceivedPacket calls");
2987 "Unexpected number of MAC layer SendNewPacket calls");
2990 "Unexpected number of MAC layer ConfirmedTransmissionOutcome calls");
2996 uint8_t nbTrans = 3;
2997 m_mac->SetMaxNumberOfTransmissions(nbTrans);
3005 "Unexpected FCnt value in MAC layer");
3008 "Unexpected number of PHY layer StartSending calls");
3011 "Unexpected number of PHY layer ReceivedPacket calls");
3014 "Unexpected number of MAC layer SendNewPacket calls");
3017 "Unexpected number of MAC layer ConfirmedTransmissionOutcome calls");
3023 uint8_t nbTrans = 13;
3024 m_mac->SetMaxNumberOfTransmissions(nbTrans);
3032 "Unexpected FCnt value in MAC layer");
3035 "Unexpected number of PHY layer StartSending calls");
3038 "Unexpected number of PHY layer ReceivedPacket calls");
3041 "Unexpected number of MAC layer SendNewPacket calls");
3044 "Unexpected number of MAC layer ConfirmedTransmissionOutcome calls");
3050 uint8_t nbTrans = 7;
3051 m_mac->SetMaxNumberOfTransmissions(nbTrans);
3058 "Unexpected FCnt value in MAC layer");
3061 "Unexpected number of PHY layer StartSending calls");
3064 "Unexpected number of PHY layer ReceivedPacket calls");
3067 "Unexpected number of MAC layer SendNewPacket calls");
3070 "Unexpected number of MAC layer ConfirmedTransmissionOutcome calls");
3073 "Unexpected number of transmissions for confirmed packet");
3076 "Unexpected acknowledgment state for confirmed packet");
3082 uint8_t nbTrans = 6;
3083 m_mac->SetMaxNumberOfTransmissions(nbTrans);
3094 "Unexpected FCnt value in MAC layer");
3097 "Unexpected number of PHY layer StartSending calls");
3100 "Unexpected number of PHY layer ReceivedPacket calls");
3103 "Unexpected number of MAC layer SendNewPacket calls");
3106 "Unexpected number of MAC layer ConfirmedTransmissionOutcome calls");
3109 "Unexpected number of transmissions for confirmed packet");
3112 "Unexpected acknowledgment state for confirmed packet");
3118 uint8_t nbTrans = 9;
3119 m_mac->SetMaxNumberOfTransmissions(nbTrans);
3130 "Unexpected FCnt value in MAC layer");
3133 "Unexpected number of PHY layer StartSending calls");
3136 "Unexpected number of PHY layer ReceivedPacket calls");
3139 "Unexpected number of MAC layer SendNewPacket calls");
3142 "Unexpected number of MAC layer ConfirmedTransmissionOutcome calls");
3145 "Unexpected number of transmissions for confirmed packet");
3148 "Unexpected acknowledgment state for confirmed packet");
3154 uint8_t nbTrans = 10;
3155 m_mac->SetMaxNumberOfTransmissions(nbTrans);
3163 "Unexpected FCnt value in MAC layer");
3166 "Unexpected number of PHY layer StartSending calls");
3169 "Unexpected number of PHY layer ReceivedPacket calls");
3172 "Unexpected number of MAC layer SendNewPacket calls");
3175 "Unexpected number of MAC layer ConfirmedTransmissionOutcome calls");
3178 "Unexpected number of transmissions for confirmed packet");
3181 "Unexpected acknowledgment state for confirmed packet");
3187 uint8_t nbTrans = 14;
3188 m_mac->SetMaxNumberOfTransmissions(nbTrans);
3196 "Unexpected FCnt value in MAC layer");
3199 "Unexpected number of PHY layer StartSending calls");
3202 "Unexpected number of PHY layer ReceivedPacket calls");
3205 "Unexpected number of MAC layer SendNewPacket calls");
3208 "Unexpected number of MAC layer ConfirmedTransmissionOutcome calls");
3211 "Unexpected number of transmissions for confirmed packet");
3214 "Unexpected acknowledgment state for confirmed packet");
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 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 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.
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.
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 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.
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.
@ 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.
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_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 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
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.