39 #include <ns3/channel.h>
40 #include <ns3/error-model.h>
41 #include <ns3/ipv4-header.h>
42 #include <ns3/ipv4-l3-protocol.h>
45 #include <ns3/object-map.h>
46 #include <ns3/packet.h>
47 #include <ns3/pointer.h>
48 #include <ns3/singleton.h>
49 #include <ns3/trace-source-accessor.h>
50 #include <ns3/uinteger.h>
58 NS_LOG_COMPONENT_DEFINE(
"SatOrbiterNetDeviceLora");
63 NS_OBJECT_ENSURE_REGISTERED(SatOrbiterNetDeviceLora);
68 static TypeId tid = TypeId(
"ns3::SatOrbiterNetDeviceLora")
70 .AddConstructor<SatOrbiterNetDeviceLora>();
77 NS_LOG_FUNCTION(
this);
83 NS_LOG_FUNCTION(
this << packet);
84 NS_LOG_INFO(
"Receiving a packet: " << packet->GetUid());
86 Mac48Address macUserAddress = Mac48Address::ConvertFrom(userAddress);
108 if (packet->RemovePacketTag(linkTimeTag))
110 NS_LOG_DEBUG(
this <<
" contains a SatDevLinkTimeTag tag");
115 Time jitter = Abs(delay -
m_lastDelays[macUserAddress]);
123 if (!packet->PeekPacketTag(groundStationAddressTag))
125 NS_FATAL_ERROR(
"SatGroundStationAddressTag not found");
130 if (!packet->PeekPacketTag(satUplinkInfoTag))
132 NS_FATAL_ERROR(
"SatUplinkInfoTag not found");
144 ->EnquePacket(packet);
158 NS_LOG_FUNCTION(
this << packet);
159 NS_LOG_INFO(
"Receiving a packet: " << packet->GetUid());
161 Mac48Address macFeederAddress = Mac48Address::ConvertFrom(feederAddress);
183 if (packet->RemovePacketTag(linkTimeTag))
185 NS_LOG_DEBUG(
this <<
" contains a SatDevLinkTimeTag tag");
190 Time jitter = Abs(delay -
m_lastDelays[macFeederAddress]);
198 if (!packet->PeekPacketTag(groundStationAddressTag))
200 NS_FATAL_ERROR(
"SatGroundStationAddressTag not found");
204 if (destination.IsBroadcast())
210 if (!packet->PeekPacketTag(satUplinkInfoTag))
212 NS_FATAL_ERROR(
"SatUplinkInfoTag not found");
215 if (
m_utConnected.count(destination) > 0 || destination.IsBroadcast())
223 DynamicCast<LorawanMacGateway>(
m_userMac[satUplinkInfoTag.
GetBeamId()])->Send(packet);
225 if ((
m_utConnected.count(destination) == 0 || destination.IsBroadcast()) &&
235 NS_LOG_FUNCTION(
this << packet << destination);
237 if (destination.IsBroadcast())
254 if (!packet->PeekPacketTag(satUplinkInfoTag))
256 NS_FATAL_ERROR(
"SatUplinkInfoTag not found");
266 ->EnquePacket(packet);
270 if (
m_utConnected.count(destination) > 0 || destination.IsBroadcast())
273 if (!packet->PeekPacketTag(satUplinkInfoTag))
275 NS_FATAL_ERROR(
"SatUplinkInfoTag not found");
285 DynamicCast<LorawanMacGateway>(
m_userMac[satUplinkInfoTag.
GetBeamId()])->Send(packet);
287 if ((
m_utConnected.count(destination) == 0 || destination.IsBroadcast()) &&
298 Ptr<SatSignalParameters> rxParams)
300 NS_LOG_FUNCTION(
this << msg << dest);
308 NS_LOG_FUNCTION(
this << utAddress << beamId);
311 "Cannot add same UT twice to map");
314 Singleton<SatIdMapper>::Get()->AttachMacToSatIdIsl(utAddress,
m_nodeId);
320 NS_LOG_FUNCTION(
this << utAddress << beamId);
325 Singleton<SatIdMapper>::Get()->RemoveMacToSatIdIsl(utAddress);
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.
Tag to store ground station destination address.
Mac48Address GetGroundStationAddress(void) const
Get the ground station MAC address.
SatOrbiterNetDevice to be utilized in geostationary satellite.
std::map< Mac48Address, uint32_t > m_gwConnected
Set containing all connected GWs.
std::set< uint32_t > m_broadcastReceived
Keep a count of all incoming broadcast data to avoid handling them several times.
Address GetRxUtAddress(Ptr< Packet > packet, SatEnums::SatLinkDir_t ld)
Get UT MAC address associated to this packet.
std::vector< Ptr< PointToPointIslNetDevice > > m_islNetDevices
List of ISLs starting from this node.
TracedCallback< const Time &, const Address & > m_rxUserLinkJitterTrace
Traced callback for all received packets, including user link jitter information and the address of t...
TracedCallback< Ptr< const Packet >, const Address & > m_rxUserTrace
Traced callback for all received packets on user, including the address of the senders.
TracedCallback< Ptr< const Packet >, const Address & > m_rxFeederTrace
Traced callback for all received packets on feeder, including the address of the senders.
TracedCallback< const Time &, const Address & > m_rxFeederLinkDelayTrace
Traced callback for all received packets, including feeder link delay information and the address of ...
std::map< uint32_t, Ptr< SatMac > > m_feederMac
std::map< Mac48Address, Time > m_lastDelays
std::map< uint32_t, Ptr< SatMac > > m_userMac
void SendToIsl(Ptr< Packet > packet, Mac48Address destination)
Send a packet to ISL.
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_rxUserLinkDelayTrace
Traced callback for all received packets, including user link delay information and the address of th...
TracedCallback< const Time &, const Address & > m_rxFeederLinkJitterTrace
Traced callback for all received packets, including feeder link jitter information and the address of...
bool m_isStatisticsTagsEnabled
std::map< Mac48Address, uint32_t > m_utConnected
Set containing all connected UTs.
virtual void DisconnectUt(Mac48Address utAddress, uint32_t beamId)
Disconnect a UT to this satellite.
void ReceivePacketUser(Ptr< Packet > packet, const Address &userAddress)
Receive the packet from the lower layers, in network regeneration on return link.
static TypeId GetTypeId(void)
Get the type ID.
void ReceivePacketFeeder(Ptr< Packet > packet, const Address &feederAddress)
Receive the packet from the lower layers, in network regeneration on forward link.
virtual bool SendControlMsgToFeeder(Ptr< SatControlMessage > msg, const Address &dest, Ptr< SatSignalParameters > rxParams)
Send a control packet on the feeder link.
SatOrbiterNetDeviceLora()
Default constructor.
void ReceiveFromIsl(Ptr< Packet > packet, Mac48Address destination)
Receive a packet from ISL.
virtual void ConnectUt(Mac48Address utAddress, uint32_t beamId)
Connect a UT to this satellite.
Tag to store uplink phy info that need to be forwarded to the downlink.
uint32_t GetBeamId(void) const
Get the UT beam ID.
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.