38 #include <ns3/channel.h>
39 #include <ns3/error-model.h>
40 #include <ns3/ipv4-header.h>
41 #include <ns3/ipv4-l3-protocol.h>
44 #include <ns3/object-map.h>
45 #include <ns3/packet.h>
46 #include <ns3/pointer.h>
47 #include <ns3/singleton.h>
48 #include <ns3/trace-source-accessor.h>
49 #include <ns3/uinteger.h>
57 NS_LOG_COMPONENT_DEFINE(
"SatOrbiterNetDeviceDvb");
62 NS_OBJECT_ENSURE_REGISTERED(SatOrbiterNetDeviceDvb);
67 static TypeId tid = TypeId(
"ns3::SatOrbiterNetDeviceDvb")
69 .AddConstructor<SatOrbiterNetDeviceDvb>();
76 NS_LOG_FUNCTION(
this);
82 NS_LOG_FUNCTION(
this << packet);
83 NS_LOG_INFO(
"Receiving a packet: " << packet->GetUid());
85 Mac48Address macUserAddress = Mac48Address::ConvertFrom(userAddress);
107 if (packet->RemovePacketTag(linkTimeTag))
109 NS_LOG_DEBUG(
this <<
" contains a SatDevLinkTimeTag tag");
114 Time jitter = Abs(delay -
m_lastDelays[macUserAddress]);
122 if (!packet->PeekPacketTag(groundStationAddressTag))
124 NS_FATAL_ERROR(
"SatGroundStationAddressTag not found");
129 if (!packet->PeekPacketTag(satUplinkInfoTag))
131 NS_FATAL_ERROR(
"SatUplinkInfoTag not found");
143 ->EnquePacket(packet);
157 NS_LOG_FUNCTION(
this << packet);
158 NS_LOG_INFO(
"Receiving a packet: " << packet->GetUid());
160 Mac48Address macFeederAddress = Mac48Address::ConvertFrom(feederAddress);
182 if (packet->RemovePacketTag(linkTimeTag))
184 NS_LOG_DEBUG(
this <<
" contains a SatDevLinkTimeTag tag");
189 Time jitter = Abs(delay -
m_lastDelays[macFeederAddress]);
197 if (!packet->PeekPacketTag(groundStationAddressTag))
199 NS_FATAL_ERROR(
"SatGroundStationAddressTag not found");
203 if (destination.IsBroadcast())
209 if (!packet->PeekPacketTag(satUplinkInfoTag))
211 NS_FATAL_ERROR(
"SatUplinkInfoTag not found");
214 if (
m_utConnected.count(destination) > 0 || destination.IsBroadcast())
223 ->EnquePacket(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");
286 ->EnquePacket(packet);
288 if ((
m_utConnected.count(destination) == 0 || destination.IsBroadcast()) &&
299 Ptr<SatSignalParameters> rxParams)
301 NS_LOG_FUNCTION(
this << msg << dest);
303 Ptr<Packet> packet = Create<Packet>(msg->GetSizeInBytes());
317 packet->AddPacketTag(addressE2ETag);
322 packet->AddPacketTag(macTag);
328 packet->AddPacketTag(tag);
333 satUplinkInfoTag.
SetSinr(std::numeric_limits<double>::infinity(), 0);
334 satUplinkInfoTag.
SetBeamId(rxParams->m_beamId);
335 satUplinkInfoTag.
SetSatId(rxParams->m_satId);
336 packet->AddPacketTag(satUplinkInfoTag);
339 rxParams->m_packetsInBurst.clear();
340 rxParams->m_packetsInBurst.push_back(packet);
346 DynamicCast<SatOrbiterFeederPhy>(
m_feederPhy[rxParams->m_beamId])
347 ->SendPduWithParams(rxParams);
352 for (SatPhy::PacketContainer_t::const_iterator it = rxParams->m_packetsInBurst.begin();
353 it != rxParams->m_packetsInBurst.end();
356 DynamicCast<SatOrbiterFeederMac>(
m_feederMac[rxParams->m_beamId])->EnquePacket(*it);
361 NS_FATAL_ERROR(
"Not implemented yet");
371 NS_LOG_FUNCTION(
this << utAddress << beamId);
374 "Cannot add same UT twice to map");
377 Singleton<SatIdMapper>::Get()->AttachMacToSatIdIsl(utAddress,
m_nodeId);
381 Ptr<SatOrbiterUserMac> orbiterUserMac = DynamicCast<SatOrbiterUserMac>(
GetUserMac(beamId));
382 NS_ASSERT(orbiterUserMac !=
nullptr);
384 orbiterUserMac->AddPeer(utAddress);
392 NS_LOG_FUNCTION(
this << utAddress << beamId);
397 Singleton<SatIdMapper>::Get()->RemoveMacToSatIdIsl(utAddress);
401 Ptr<SatOrbiterUserMac> orbiterUserMac = DynamicCast<SatOrbiterUserMac>(
GetUserMac(beamId));
402 NS_ASSERT(orbiterUserMac !=
nullptr);
404 orbiterUserMac->RemovePeer(utAddress);
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.
This class implements a tag that is used to identify control messages (packages).
void SetMsgType(SatControlMsgType_t type)
Set type of the control message.
virtual void SetMsgId(uint32_t msgId)
Set message type specific identifier.
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.
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.
void ReceivePacketUser(Ptr< Packet > packet, const Address &userAddress)
Receive the packet from the lower layers, in network regeneration on return link.
SatOrbiterNetDeviceDvb()
Default constructor.
void ReceivePacketFeeder(Ptr< Packet > packet, const Address &feederAddress)
Receive the packet from the lower layers, in network regeneration on forward link.
static TypeId GetTypeId(void)
Get the type ID.
virtual void ConnectUt(Mac48Address utAddress, uint32_t beamId)
Connect a UT to this satellite.
virtual void DisconnectUt(Mac48Address utAddress, uint32_t beamId)
Disconnect a UT to this satellite.
void ReceiveFromIsl(Ptr< Packet > packet, Mac48Address destination)
Receive a packet from ISL.
virtual bool SendControlMsgToFeeder(Ptr< SatControlMessage > msg, const Address &dest, Ptr< SatSignalParameters > rxParams)
Send a control packet on the feeder link.
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
SatEnums::RegenerationMode_t m_returnLinkRegenerationMode
std::map< uint32_t, Ptr< SatMac > > GetUserMac()
Get all User MAC objects attached to this satellite.
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...
std::map< uint32_t, Ptr< SatPhy > > m_feederPhy
bool m_isStatisticsTagsEnabled
std::map< Mac48Address, uint32_t > m_utConnected
Set containing all connected UTs.
Tag to store uplink phy info that need to be forwarded to the downlink.
void SetSinr(double sinr, double additionalInterference)
Set uplink SINR.
void SetBeamId(uint32_t beamId)
Set the UT beam ID.
uint32_t GetBeamId(void) const
Get the UT beam ID.
void SetSatId(uint32_t satId)
Set the UT sat 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.