35 #include <ns3/simulator.h>
40 NS_LOG_COMPONENT_DEFINE(
"SatGwLlc");
45 NS_OBJECT_ENSURE_REGISTERED(SatGwLlc);
50 static TypeId tid = TypeId(
"ns3::SatGwLlc").SetParent<
SatLlc>().AddConstructor<SatGwLlc>();
57 NS_LOG_FUNCTION(
this);
62 NS_LOG_FUNCTION(
this);
68 NS_LOG_FUNCTION(
this);
76 NS_LOG_FUNCTION(
this << packet << dest << (uint32_t)flowId);
77 NS_LOG_INFO(
"p=" << packet);
78 NS_LOG_INFO(
"dest=" << dest);
79 NS_LOG_INFO(
"UID is " << packet->GetUid());
85 if (!packet->PeekPacketTag(groundStationAddressTag))
88 packet->AddPacketTag(groundStationAddressTag);
95 key = Create<EncapKey>(
m_nodeInfo->GetMacAddress(),
99 Mac48Address::ConvertFrom(dest));
103 key = Create<EncapKey>(
m_nodeInfo->GetMacAddress(),
104 Mac48Address::ConvertFrom(dest),
107 Mac48Address::ConvertFrom(dest));
110 EncapContainer_t::iterator it =
m_encaps.find(key);
125 packet->AddPacketTag(timeTag);
131 packet->AddPacketTag(addressE2ETag);
133 it->second->EnquePdu(packet, Mac48Address::ConvertFrom(dest));
155 uint32_t& nextMinTxO)
157 NS_LOG_FUNCTION(
this << utAddr << bytes << (uint32_t)flowId);
160 Ptr<EncapKey> key = Create<EncapKey>(
m_nodeInfo->GetMacAddress(), utAddr, flowId);
161 EncapContainer_t::iterator it =
m_encaps.find(key);
165 packet = it->second->NotifyTxOpportunity(bytes, bytesLeft, nextMinTxO);
184 NS_FATAL_ERROR(
"Encapsulator not found for key (" <<
m_nodeInfo->GetMacAddress() <<
", "
185 << utAddr <<
", " << (uint32_t)flowId
195 NS_LOG_FUNCTION(
this << key->m_encapAddress << key->m_decapAddress
196 << (uint32_t)(key->m_flowId));
198 Ptr<SatBaseEncapsulator> gwEncap;
203 gwEncap = CreateObject<SatBaseEncapsulator>(key->m_encapAddress,
205 key->m_sourceE2EAddress,
206 key->m_destE2EAddress,
211 gwEncap = CreateObject<SatGenericStreamEncapsulatorArq>(key->m_encapAddress,
213 key->m_sourceE2EAddress,
214 key->m_destE2EAddress,
220 gwEncap = CreateObject<SatGenericStreamEncapsulator>(key->m_encapAddress,
222 key->m_sourceE2EAddress,
223 key->m_destE2EAddress,
228 Ptr<SatQueue> queue = CreateObject<SatQueue>(key->m_flowId);
229 gwEncap->SetQueue(queue);
231 NS_LOG_INFO(
"Create encapsulator with key (" << key->m_encapAddress <<
", "
232 << key->m_decapAddress <<
", "
233 << (uint32_t)key->m_flowId <<
")");
236 std::pair<EncapContainer_t::iterator, bool> result =
237 m_encaps.insert(std::make_pair(key, gwEncap));
238 if (result.second ==
false)
240 NS_FATAL_ERROR(
"Insert to map with key (" << key->m_encapAddress <<
", "
241 << key->m_decapAddress <<
", "
242 << (uint32_t)key->m_flowId <<
") failed!");
249 NS_LOG_FUNCTION(
this << key->m_encapAddress << key->m_decapAddress
250 << (uint32_t)(key->m_flowId));
252 Ptr<SatBaseEncapsulator> gwDecap;
256 gwDecap = CreateObject<SatReturnLinkEncapsulatorArq>(key->m_encapAddress,
258 key->m_sourceE2EAddress,
259 key->m_destE2EAddress,
265 gwDecap = CreateObject<SatReturnLinkEncapsulator>(key->m_encapAddress,
267 key->m_sourceE2EAddress,
268 key->m_destE2EAddress,
276 NS_LOG_INFO(
"Create decapsulator with key (" << key->m_encapAddress <<
", "
277 << key->m_decapAddress <<
", "
278 << (uint32_t)key->m_flowId <<
")");
281 std::pair<EncapContainer_t::iterator, bool> result =
282 m_decaps.insert(std::make_pair(key, gwDecap));
283 if (result.second ==
false)
285 NS_FATAL_ERROR(
"Insert to map with key (" << key->m_encapAddress <<
", "
286 << key->m_decapAddress <<
", "
287 << (uint32_t)key->m_flowId <<
") failed!");
306 NS_LOG_FUNCTION(
this);
312 for (EncapContainer_t::const_iterator cit =
m_encaps.begin(); cit !=
m_encaps.end(); ++cit)
314 uint32_t buf = cit->second->GetTxBufferSizeInBytes();
318 holDelay = cit->second->GetHolDelay();
319 uint32_t minTxOpportunityInBytes = cit->second->GetMinTxOpportunityInBytes();
320 Ptr<SatSchedulingObject> so = Create<SatSchedulingObject>(cit->first->m_decapAddress,
322 minTxOpportunityInBytes,
324 cit->first->m_flowId);
325 output.push_back(so);
333 NS_LOG_FUNCTION(
this << utAddress);
337 for (EncapContainer_t::const_iterator it =
m_encaps.begin(); it !=
m_encaps.end(); ++it)
339 if (it->first->m_decapAddress == utAddress)
341 NS_ASSERT(it->second !=
nullptr);
342 Ptr<SatQueue> queue = it->second->GetQueue();
343 NS_ASSERT(queue !=
nullptr);
344 sum += queue->GetNBytes();
354 NS_LOG_FUNCTION(
this << utAddress);
358 for (EncapContainer_t::const_iterator it =
m_encaps.begin(); it !=
m_encaps.end(); ++it)
360 if (it->first->m_decapAddress == utAddress)
362 NS_ASSERT(it->second !=
nullptr);
363 Ptr<SatQueue> queue = it->second->GetQueue();
364 NS_ASSERT(queue !=
nullptr);
365 sum += queue->GetNPackets();
375 NS_LOG_FUNCTION(
this);
377 for (EncapContainer_t::const_iterator it =
m_encaps.begin(); it !=
m_encaps.end(); ++it)
379 NS_ASSERT(it->second !=
nullptr);
380 Ptr<SatQueue> queue = it->second->GetQueue();
381 NS_ASSERT(queue !=
nullptr);
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.
SatLinkDir_t
Link direction used for packet tracing.
Tag to store ground station destination address.
virtual void CreateDecap(Ptr< EncapKey > key)
Virtual method to create a new decapsulator 'on-a-need-basis' dynamically.
SatGwLlc()
Construct a SatGwLlc.
virtual Ptr< Packet > NotifyTxOpportunity(uint32_t bytes, Mac48Address utAddr, uint8_t flowId, uint32_t &bytesLeft, uint32_t &nextMinTxO)
Called from lower layer (MAC) to inform a tx opportunity of certain amount of bytes.
virtual SatEnums::SatLinkDir_t GetSatLinkRxDir()
Get the link RX direction.
virtual ~SatGwLlc()
Destroy a SatGwLlc.
virtual bool Enque(Ptr< Packet > packet, Address dest, uint8_t flowId)
Called from higher layer (SatNetDevice) to enque packet to LLC.
virtual void GetSchedulingContexts(std::vector< Ptr< SatSchedulingObject >> &output) const
Create and fill the scheduling objects based on LLC layer information.
static TypeId GetTypeId(void)
Get the type ID.
virtual void ClearQueues()
Remove all packets from the queues.
virtual SatEnums::SatLinkDir_t GetSatLinkTxDir()
Get the link TX direction.
virtual void CreateEncap(Ptr< EncapKey > key)
Virtual method to create a new encapsulator 'on-a-need-basis' dynamically.
void DoDispose()
Dispose of this class instance.
SatLlc base class holds the UT specific SatBaseEncapsulator instances, which are responsible of fragm...
Ptr< SatNodeInfo > m_nodeInfo
Node info containing node related information, such as node type, node id and MAC address (of the Sat...
virtual uint32_t GetNBytesInQueue() const
Get the total number of (new) bytes in all encapsulators.
uint32_t m_additionalHeaderSize
Additional header size to add to encapsulation/decapsulation.
bool m_fwdLinkArqEnabled
Is FWD link ARQ enabled.
SatBaseEncapsulator::SendCtrlCallback m_sendCtrlCallback
Callback to send control messages.
EncapContainer_t m_decaps
Map of decapsulator base pointers.
TracedCallback< Time, SatEnums::SatPacketEvent_t, SatEnums::SatNodeType_t, uint32_t, Mac48Address, SatEnums::SatLogLevel_t, SatEnums::SatLinkDir_t, std::string > m_packetTrace
Trace callback used for packet tracing:
virtual void DoDispose()
Dispose of this class instance.
EncapContainer_t m_encaps
Map of encapsulator base pointers.
SatEnums::RegenerationMode_t m_forwardLinkRegenerationMode
Regeneration mode on forward link.
virtual uint32_t GetNPacketsInQueue() const
Get the total number of (new) packets in all encapsulators.
virtual void ReceiveHigherLayerPdu(Ptr< Packet > packet, Mac48Address source, Mac48Address dest)
Receive HL PDU from encapsulator/decapsulator entity.
Mac48Address m_satelliteAddress
SAT address, used in case of network regeneration.
bool m_rtnLinkArqEnabled
Is RTN link ARQ enabled.
Time tag used to identify the time when packet is enqueued at LLC level.
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.