28 #include <ns3/ipv4-header.h>
30 #include <ns3/singleton.h>
32 NS_LOG_COMPONENT_DEFINE(
"SatLorawanNetDevice");
37 NS_OBJECT_ENSURE_REGISTERED(SatLorawanNetDevice);
42 static TypeId tid = TypeId(
"ns3::SatLorawanNetDevice")
44 .AddConstructor<SatLorawanNetDevice>();
50 NS_LOG_FUNCTION(
this);
52 switch (Singleton<SatTopology>::Get()->GetForwardLinkRegenerationMode())
63 NS_FATAL_ERROR(
"Incorrect regeneration mode for LORA");
70 NS_LOG_FUNCTION(
this << packet);
71 NS_LOG_INFO(
"Receiving a packet: " << packet->GetUid());
93 bool isTaggedWithAddress =
false;
94 ByteTagIterator it = packet->GetByteTagIterator();
96 while (!isTaggedWithAddress && it.HasNext())
98 ByteTagIterator::Item item = it.Next();
102 NS_LOG_DEBUG(
this <<
" contains a SatAddressTag tag:"
103 <<
" start=" << item.GetStart() <<
" end=" << item.GetEnd());
105 item.GetTag(addrTag);
107 isTaggedWithAddress =
true;
114 if (packet->PeekPacketTag(timeTag))
116 NS_LOG_DEBUG(
this <<
" contains a SatDevTimeTag tag");
131 Ptr<Packet> pktCopy = packet->Copy();
138 Ipv4Header ipv4Header;
139 Ptr<Packet> pktCopy = packet->Copy();
140 pktCopy->RemoveHeader(mHdr);
141 pktCopy->RemoveHeader(fHdr);
142 if (pktCopy->PeekHeader(ipv4Header))
144 m_rxCallback(
this, pktCopy, Ipv4L3Protocol::PROT_NUMBER, Address());
151 NS_LOG_FUNCTION(
this << packet << dest << protocolNumber);
176 bool isTaggedWithAddress =
false;
177 ByteTagIterator it = packet->GetByteTagIterator();
179 while (!isTaggedWithAddress && it.HasNext())
181 ByteTagIterator::Item item = it.Next();
185 NS_LOG_DEBUG(
this <<
" contains a SatAddressTag tag:"
186 <<
" start=" << item.GetStart() <<
" end=" << item.GetEnd());
188 item.GetTag(addrTag);
190 isTaggedWithAddress =
true;
196 uint8_t flowId =
m_classifier->Classify(packet, dest, protocolNumber);
198 m_llc->Enque(packet, dest, flowId);
202 DynamicCast<LorawanMac>(
m_mac)->Send(packet, dest, protocolNumber);
218 NS_LOG_FUNCTION(
this << &cb);
225 NS_LOG_FUNCTION(
this);
Tag used to save various data about a packet, like its Spreading Factor and data about interference.
This class implements a tag that carries the MAC address of the sender of the packet.
static TypeId GetTypeId()
Inherited from ObjectBase base class.
Address GetSourceAddress() const
Get the source address.
Time tag used to identify the time when packet is enqueued at device level.
Time GetSenderTimestamp(void) const
Get sender time stamp of this tag.
SatLinkDir_t
Link direction used for packet tracing.
void Receive(Ptr< const Packet > packet)
void SetReceiveNetworkServerCallback(SatLorawanNetDevice::ReceiveCallback cb)
bool SendControlMsg(Ptr< SatControlMessage > msg, const Address &dest)
static TypeId GetTypeId(void)
Get the type ID.
SatLorawanNetDevice()
Default constructor.
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
ReceiveCallback m_rxNetworkServerCallback
virtual void DoDispose(void)
Method called to inform the Scheduler of a newly arrived uplink packet.
Callback< bool, Ptr< SatLorawanNetDevice >, Ptr< const Packet >, uint16_t, const Address & > ReceiveCallback
SatNetDevice to be utilized in the UT and GW nodes.
TracedCallback< const Time &, const Address & > m_rxDelayTrace
Traced callback for all received packets, including delay information and the address of the senders.
TracedCallback< Ptr< const Packet > > m_txTrace
Traced callback for all packets received to be transmitted.
Ptr< SatPacketClassifier > m_classifier
Time m_lastDelay
Last delay measurement.
virtual void DoDispose(void)
Dispose of this class instance.
TracedCallback< Ptr< const Packet >, const Address & > m_rxTrace
Traced callback for all received packets, including the address of the senders.
Ptr< SatNodeInfo > m_nodeInfo
TracedCallback< Time, SatEnums::SatPacketEvent_t, SatEnums::SatNodeType_t, uint32_t, Mac48Address, SatEnums::SatLogLevel_t, SatEnums::SatLinkDir_t, std::string > m_packetTrace
TracedCallback< const Time &, const Address & > m_rxJitterTrace
Traced callback for all received packets, including jitter information and the address of the senders...
NetDevice::ReceiveCallback m_rxCallback
bool m_isStatisticsTagsEnabled
EnableStatisticsTags attribute.
static std::string GetPacketInfo(const Ptr< const Packet > p)
Get packet information in std::string for printing purposes.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.