satellite-lora-phy-rx.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2017 University of Padova
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Davide Magrin <magrinda@dei.unipd.it>
19  */
20 
21 #include "satellite-lora-phy-rx.h"
22 
23 #include <ns3/log.h>
24 
25 namespace ns3
26 {
27 
28 NS_LOG_COMPONENT_DEFINE("SatLoraPhyRx");
29 
30 NS_OBJECT_ENSURE_REGISTERED(SatLoraPhyRx);
31 
32 TypeId
34 {
35  static TypeId tid = TypeId("ns3::SatLoraPhyRx").SetParent<SatPhyRx>();
36  return tid;
37 }
38 
40  : m_state(SLEEP)
41 {
42 }
43 
45 {
46 }
47 
48 void
49 SatLoraPhyRx::StartRx(Ptr<SatSignalParameters> rxParams)
50 {
51  NS_LOG_FUNCTION(this);
52 
53  // Switch on the current PHY state
54  switch (m_state)
55  {
56  // In the SLEEP, TX and RX cases we cannot receive the packet: we only add
57  // it to the list of interferers and do not schedule an EndReceive event for
58  // it.
59  case SLEEP: {
60  NS_LOG_INFO("Dropping packet because device is in SLEEP state");
61  break;
62  }
63  case TX: {
64  NS_LOG_INFO("Dropping packet because device is in TX state");
65  break;
66  }
67  case RX: {
68  NS_LOG_INFO("Dropping packet because device is already in RX state");
69  break;
70  }
71  // If we are in STANDBY mode, we can potentially lock on the currently
72  // incoming transmission
73  case STANDBY: {
74  SatPhyRx::StartRx(rxParams);
75  break;
76  }
77  }
78 }
79 
80 bool
82 {
83  return true;
84 }
85 
86 bool
87 SatLoraPhyRx::IsOnFrequency(double frequency)
88 {
89  return m_frequency == frequency;
90 }
91 
92 void
93 SatLoraPhyRx::SetFrequency(double frequencyMHz)
94 {
95  m_frequency = frequencyMHz;
96 }
97 
98 void
100 {
101  m_sf = sf;
102 }
103 
106 {
107  return m_state;
108 }
109 
110 void
112 {
113  NS_LOG_FUNCTION_NOARGS();
114 
115  m_state = STANDBY;
116 }
117 
118 void
120 {
121  NS_LOG_FUNCTION_NOARGS();
122 
123  NS_ASSERT(m_state == STANDBY);
124 
125  m_state = RX;
126 }
127 
128 void
130 {
131  NS_LOG_FUNCTION_NOARGS();
132 
133  NS_ASSERT(m_state != RX);
134 
135  m_state = TX;
136 }
137 
138 void
140 {
141  NS_LOG_FUNCTION_NOARGS();
142 
143  NS_ASSERT(m_state == STANDBY);
144 
145  m_state = SLEEP;
146 }
147 
148 } // namespace ns3
virtual void StartRx(Ptr< SatSignalParameters > rxParams)
Start receiving a packet.
void SetSpreadingFactor(uint8_t sf)
Set the Spreading Factor this EndDevice will listen for.
void SetFrequency(double frequencyMHz)
Set the frequency this EndDevice will listen on.
SatLoraPhyRx()
Constructor and destructor.
@ SLEEP
The PHY layer is sleeping.
@ TX
The PHY layer is sending a packet.
@ RX
The PHY layer is receiving a packet.
@ STANDBY
The PHY layer is in STANDBY.
bool IsOnFrequency(double frequency)
Whether this device is listening on the specified frequency or not.
void SwitchToSleep(void)
Switch to the SLEEP state.
void SwitchToStandby(void)
Switch to the STANDBY state.
void SwitchToRx()
Switch to the RX state.
bool IsTransmitting(void)
Whether this device is transmitting or not.
static TypeId GetTypeId(void)
void SwitchToTx()
Switch to the TX state.
The SatPhyRx models the physical layer receiver of satellite system.
virtual void StartRx(Ptr< SatSignalParameters > rxParams)
Start packet reception from the SatChannel.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.