36 NS_LOG_COMPONENT_DEFINE(
"LorawanMacGateway");
38 NS_OBJECT_ENSURE_REGISTERED(LorawanMacGateway);
43 static TypeId tid = TypeId(
"ns3::LorawanMacGateway").SetParent<
LorawanMac>();
49 NS_FATAL_ERROR(
"Default constructor not in use");
55 NS_LOG_FUNCTION(
this);
60 NS_LOG_FUNCTION(
this);
66 NS_LOG_FUNCTION(
this << packet);
70 packet->RemovePacketTag(tag);
74 NS_LOG_DEBUG(
"DR: " << (uint32_t)
unsigned(dataRate));
77 NS_LOG_DEBUG(
"Freq: " << frequency <<
" MHz");
78 packet->AddPacketTag(tag);
89 packet->RemovePacketTag(satDevTag);
97 NS_LOG_WARN(
"Trying to send a packet but Duty Cycle won't allow it. Aborting.");
104 NS_LOG_WARN(
"Gateway is already transmitting. Aborting.");
127 NS_LOG_DEBUG(
"Duration: " << duration.GetSeconds());
135 packet->AddPacketTag(mTag);
140 packet->AddPacketTag(addressE2ETag);
143 packets.push_back(packet);
144 uint32_t carrierId = 0;
147 m_phy->SendPdu(packets, carrierId, duration, txInfo);
155 return DynamicCast<SatLoraPhyTx>(
m_phy->GetPhyTx())->IsTransmitting();
161 NS_LOG_FUNCTION(
this << packets);
167 for (SatPhy::PacketContainer_t::iterator i = packets.begin(); i != packets.end(); i++)
171 Ptr<Packet> packetCopy = packet->Copy();
174 packetCopy->RemovePacketTag(mTag);
178 packetCopy->PeekHeader(macHdr);
183 lorawanNetDevice->
Receive(packetCopy);
185 NS_LOG_DEBUG(
"Received packet: " << packet);
191 NS_LOG_DEBUG(
"Not forwarding downlink message to NetDevice");
199 NS_LOG_FUNCTION(
this << packet);
205 NS_LOG_FUNCTION_NOARGS();
211 NS_LOG_FUNCTION(
this << frequency);
Time GetWaitingTime(Ptr< LoraLogicalChannel > channel)
Get the time it is necessary to wait for before transmitting on a given channel.
void AddEvent(Time duration, Ptr< LoraLogicalChannel > channel)
Register the transmission of a packet.
Tag used to save various data about a packet, like its Spreading Factor and data about interference.
double GetFrequency(void)
Get the frequency of the packet.
uint8_t GetDataRate(void)
Get the data rate for this packet.
uint8_t GetModcod(void)
Get the modcod for this packet.
virtual void Receive(SatPhy::PacketContainer_t packets, Ptr< SatSignalParameters >)=0
Receive a packet from the lower layer.
virtual void FailedReception(Ptr< const Packet > packet)
Function called by lower layers to inform this layer that reception of a packet we were locked on fai...
Time GetWaitingTime(double frequency)
Return the next time at which we will be able to transmit.
virtual void Send(Ptr< Packet > packet)=0
Send a packet.
bool IsTransmitting(void)
virtual void TxFinished()
Perform actions after sending a packet.
static TypeId GetTypeId(void)
virtual ~LorawanMacGateway()
Class representing the LoRaWAN MAC layer.
TracedCallback< Ptr< const Packet > > m_receivedPacket
Trace source that is fired when a packet reaches the MAC layer.
Time GetOnAirTime(Ptr< Packet > packet, LoraTxParameters txParams)
Compute the time that a packet with certain characteristics will take to be transmitted.
Ptr< SatPhy > m_phy
The PHY instance that sits under this MAC layer.
TracedCallback< Ptr< const Packet > > m_sentNewPacket
Trace source that is fired when a new APP layer packet arrives at the MAC layer.
uint8_t GetSfFromDataRate(uint8_t dataRate)
Get the SF corresponding to a data rate, based on this MAC's region.
Ptr< NetDevice > m_device
The device this MAC layer is installed on.
LoraLogicalChannelHelper m_channelHelper
The LoraLogicalChannelHelper instance that is assigned to this MAC.
double GetBandwidthFromDataRate(uint8_t dataRate)
Get the BW corresponding to a data rate, based on this MAC's region.
This class implements a tag that carries the satellite MAC of GW and UT.
void SetE2ESourceAddress(Mac48Address e2eSourceAddress)
Set E2E source MAC address.
void SetE2EDestAddress(Mac48Address e2eDestAddress)
Set E2E destination MAC address.
This class implements a tag that carries the MAC address of the sender of the packet.
Time tag used to identify the time when packet is enqueued at device level.
SatModcod_t
Modulation scheme and coding rate for DVB-S2.
@ PACKET_TYPE_DEDICATED_ACCESS
SatLorawanNetDevice to be utilized in the UT and GW nodes for IoT configuration.
void Receive(Ptr< const Packet > packet)
void RxTraces(SatPhy::PacketContainer_t packets)
Invoke the Rx trace source for each received packet.
bool m_isStatisticsTagsEnabled
EnableStatisticsTags attribute.
Ptr< SatNodeInfo > m_nodeInfo
Node info containing node related information, such as node type, node id and MAC address (of the Sat...
This class implements a tag that carries the satellite MAC specific information, such as source and d...
void SetDestAddress(Mac48Address dest)
Set destination MAC address.
void SetSourceAddress(Mac48Address source)
Set source MAC address.
Time tag used to identify the time when packet is enqueued at MAC level.
SatSignalParameters::PacketsInBurst_t PacketContainer_t
Define PacketContainer in SatPhy.
static double GetCodingRate(SatEnums::SatModcod_t modcod)
Gets the coding rate of a certain MODCOD.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.
Structure to collect all parameters that are used to compute the duration of a packet (excluding payl...
bool lowDataRateOptimizationEnabled
Whether Low Data Rate Optimization is enabled.
uint32_t nPreamble
Number of preamble symbols.
bool headerDisabled
Whether to use implicit header mode.
uint8_t sf
Spreading Factor.
double bandwidthHz
Bandwidth in Hz.
double codingRate
Code rate.
bool crcEnabled
Whether Cyclic Redundancy Check is enabled.
Struct for storing the packet specific Tx information.
SatEnums::PacketType_t packetType
SatEnums::SatBbFrameType_t frameType
SatEnums::SatModcod_t modCod