OLD | NEW |
(Empty) | |
| 1 #include "ns3/lora-phy.h" |
| 2 #include "ns3/log.h" |
| 3 #include "ns3/command-line.h" |
| 4 |
| 5 using namespace ns3; |
| 6 |
| 7 NS_LOG_COMPONENT_DEFINE ("TimeOnAirTest"); |
| 8 |
| 9 int main (int argc, char *argv[]) |
| 10 { |
| 11 |
| 12 CommandLine cmd; |
| 13 cmd.Parse (argc, argv); |
| 14 |
| 15 LogComponentEnable ("TimeOnAirTest", LOG_LEVEL_ALL); |
| 16 LogComponentEnable ("LoraPhy", LOG_LEVEL_ALL); |
| 17 |
| 18 Ptr<Packet> packet; |
| 19 Time duration; |
| 20 |
| 21 // Available parameters: |
| 22 // PayloadSize, SF, HeaderDisabled, CodingRate, Bandwidth, nPreambleSyms, crcE
nabled, lowDROptimization |
| 23 |
| 24 // Starting parameters |
| 25 packet = Create<Packet> (10); |
| 26 LoraTxParameters txParams; |
| 27 txParams.sf = 7; |
| 28 txParams.headerDisabled = false; |
| 29 txParams.codingRate = 1; |
| 30 txParams.bandwidthHz = 125000; |
| 31 txParams.nPreamble = 8; |
| 32 txParams.crcEnabled = 1; |
| 33 txParams.lowDataRateOptimizationEnabled = 0; |
| 34 |
| 35 duration = LoraPhy::GetOnAirTime (packet, txParams); |
| 36 NS_LOG_DEBUG ("Computed: " << duration.GetSeconds () << " s, expected: " << 0.
041216 << " s"); |
| 37 |
| 38 txParams.sf = 8; |
| 39 duration = LoraPhy::GetOnAirTime (packet, txParams); |
| 40 NS_LOG_DEBUG ("Computed: " << duration.GetSeconds () << " s, expected: " << 0.
072192 << " s"); |
| 41 |
| 42 txParams.headerDisabled = true; |
| 43 duration = LoraPhy::GetOnAirTime (packet, txParams); |
| 44 NS_LOG_DEBUG ("Computed: " << duration.GetSeconds () << " s, expected: " << 0.
072192 << " s"); |
| 45 |
| 46 txParams.codingRate = 2; |
| 47 duration = LoraPhy::GetOnAirTime (packet, txParams); |
| 48 NS_LOG_DEBUG ("Computed: " << duration.GetSeconds () << " s, expected: " << 0.
078336 << " s"); |
| 49 |
| 50 txParams.nPreamble = 10; |
| 51 duration = LoraPhy::GetOnAirTime (packet, txParams); |
| 52 NS_LOG_DEBUG ("Computed: " << duration.GetSeconds () << " s, expected: " << 0.
082432 << " s"); |
| 53 |
| 54 txParams.lowDataRateOptimizationEnabled = true; |
| 55 duration = LoraPhy::GetOnAirTime (packet, txParams); |
| 56 NS_LOG_DEBUG ("Computed: " << duration.GetSeconds () << " s, expected: " << 0.
082432 << " s"); |
| 57 |
| 58 txParams.sf = 10; |
| 59 duration = LoraPhy::GetOnAirTime (packet, txParams); |
| 60 NS_LOG_DEBUG ("Computed: " << duration.GetSeconds () << " s, expected: " << 0.
280576 << " s"); |
| 61 |
| 62 txParams.bandwidthHz = 250000; |
| 63 duration = LoraPhy::GetOnAirTime (packet, txParams); |
| 64 NS_LOG_DEBUG ("Computed: " << duration.GetSeconds () << " s, expected: " << 0.
14028 << " s"); |
| 65 return 0; |
| 66 } |
OLD | NEW |