30 NS_LOG_COMPONENT_DEFINE(
"SatOrbiterLlc");
35 NS_OBJECT_ENSURE_REGISTERED(SatOrbiterLlc);
40 static TypeId tid = TypeId(
"ns3::SatOrbiterLlc").SetParent<
SatLlc>();
47 NS_LOG_FUNCTION(
this);
52 NS_LOG_FUNCTION(
this);
70 NS_LOG_FUNCTION(
this << packet << dest << (uint32_t)flowId);
71 NS_LOG_INFO(
"p=" << packet);
72 NS_LOG_INFO(
"dest=" << dest);
73 NS_LOG_INFO(
"UID is " << packet->GetUid());
75 Ptr<EncapKey> key = Create<EncapKey>(
m_nodeInfo->GetMacAddress(),
76 Mac48Address::ConvertFrom(dest),
79 Mac48Address::ConvertFrom(dest));
81 EncapContainer_t::iterator it =
m_encaps.find(key);
94 it->second->EnquePdu(packet, Mac48Address::ConvertFrom(dest));
116 uint32_t& nextMinTxO)
118 NS_LOG_FUNCTION(
this << utAddr << bytes << (uint32_t)flowId);
121 Ptr<EncapKey> key = Create<EncapKey>(
m_nodeInfo->GetMacAddress(), utAddr, flowId);
122 EncapContainer_t::iterator it =
m_encaps.find(key);
126 packet = it->second->NotifyTxOpportunity(bytes, bytesLeft, nextMinTxO);
145 NS_FATAL_ERROR(
"Encapsulator not found for key (" <<
m_nodeInfo->GetMacAddress() <<
", "
146 << utAddr <<
", " << (uint32_t)flowId
156 NS_LOG_FUNCTION(
this << packet << source << dest);
160 bool cSuccess = packet->PeekPacketTag(ctrlTag);
171 uint32_t ackId = ctrlTag.
GetMsgId();
178 "ARQ ACK not found, check that control msg storage time is set long enough!");
193 NS_LOG_FUNCTION(
this << key->m_encapAddress << key->m_decapAddress
194 << (uint32_t)(key->m_flowId));
196 Ptr<SatBaseEncapsulator> encap = CreateObject<SatBaseEncapsulator>(key->m_encapAddress,
198 key->m_sourceE2EAddress,
199 key->m_destE2EAddress,
202 Ptr<SatQueue> queue = CreateObject<SatQueue>(key->m_flowId);
203 encap->SetQueue(queue);
205 NS_LOG_INFO(
"Create encapsulator with key (" << key->m_encapAddress <<
", "
206 << key->m_decapAddress <<
", "
207 << (uint32_t)key->m_flowId <<
")");
210 std::pair<EncapContainer_t::iterator, bool> result =
211 m_encaps.insert(std::make_pair(key, encap));
212 if (result.second ==
false)
214 NS_FATAL_ERROR(
"Insert to map with key (" << key->m_encapAddress <<
", "
215 << key->m_decapAddress <<
", "
216 << (uint32_t)key->m_flowId <<
") failed!");
223 NS_LOG_FUNCTION(
this << key->m_encapAddress << key->m_decapAddress
224 << (uint32_t)(key->m_flowId));
226 Ptr<SatBaseEncapsulator> decap = CreateObject<SatBaseEncapsulator>(key->m_encapAddress,
228 key->m_sourceE2EAddress,
229 key->m_destE2EAddress,
235 NS_LOG_INFO(
"Create decapsulator with key (" << key->m_encapAddress <<
", "
236 << key->m_decapAddress <<
", "
237 << (uint32_t)key->m_flowId <<
")");
240 std::pair<EncapContainer_t::iterator, bool> result =
241 m_decaps.insert(std::make_pair(key, decap));
242 if (result.second ==
false)
244 NS_FATAL_ERROR(
"Insert to map with key (" << key->m_encapAddress <<
", "
245 << key->m_decapAddress <<
", "
246 << (uint32_t)key->m_flowId <<
") failed!");
253 NS_LOG_FUNCTION(
this);
259 for (EncapContainer_t::const_iterator cit =
m_encaps.begin(); cit !=
m_encaps.end(); ++cit)
261 uint32_t buf = cit->second->GetTxBufferSizeInBytes();
265 holDelay = cit->second->GetHolDelay();
266 uint32_t minTxOpportunityInBytes = cit->second->GetMinTxOpportunityInBytes();
267 Ptr<SatSchedulingObject> so = Create<SatSchedulingObject>(cit->first->m_decapAddress,
269 minTxOpportunityInBytes,
271 cit->first->m_flowId);
272 output.push_back(so);
280 NS_LOG_FUNCTION(
this << utAddress);
284 for (EncapContainer_t::const_iterator it =
m_encaps.begin(); it !=
m_encaps.end(); ++it)
286 if (it->first->m_encapAddress == utAddress)
288 NS_ASSERT(it->second !=
nullptr);
289 Ptr<SatQueue> queue = it->second->GetQueue();
290 NS_ASSERT(queue !=
nullptr);
291 sum += queue->GetNBytes();
301 NS_LOG_FUNCTION(
this << utAddress);
305 for (EncapContainer_t::const_iterator it =
m_encaps.begin(); it !=
m_encaps.end(); ++it)
307 if (it->first->m_encapAddress == utAddress)
309 NS_ASSERT(it->second !=
nullptr);
310 Ptr<SatQueue> queue = it->second->GetQueue();
311 NS_ASSERT(queue !=
nullptr);
312 sum += queue->GetNPackets();
322 NS_LOG_FUNCTION(
this);
324 for (EncapContainer_t::const_iterator it =
m_encaps.begin(); it !=
m_encaps.end(); ++it)
326 NS_ASSERT(it->second !=
nullptr);
327 Ptr<SatQueue> queue = it->second->GetQueue();
328 NS_ASSERT(queue !=
nullptr);
This class implements a tag that is used to identify control messages (packages).
@ SAT_ARQ_ACK
SAT_ARQ_ACK.
virtual uint32_t GetMsgId() const
Get message type specific identifier.
SatControlMsgType_t GetMsgType(void) const
Get type of the control message.
SatLinkDir_t
Link direction used for packet tracing.
SatLlc base class holds the UT specific SatBaseEncapsulator instances, which are responsible of fragm...
virtual SatEnums::SatLinkDir_t GetSatLinkTxDir()
Get the link TX direction.
Ptr< SatNodeInfo > m_nodeInfo
Node info containing node related information, such as node type, node id and MAC address (of the Sat...
SatLlc::ReadCtrlMsgCallback m_readCtrlCallback
The read control message callback.
virtual uint32_t GetNBytesInQueue() const
Get the total number of (new) bytes in all encapsulators.
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 ReceiveAck(Ptr< SatArqAckMessage > ack, Mac48Address source, Mac48Address dest)
Receive a control msg (ARQ ACK) from lower layer.
EncapContainer_t m_encaps
Map of encapsulator base pointers.
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.
virtual void CreateEncap(Ptr< EncapKey > key)
Virtual method to create a new encapsulator 'on-a-need-basis' dynamically.
virtual ~SatOrbiterLlc()
Destroy a SatOrbiterLlc.
virtual void DoDispose()
Dispose of this class instance.
Callback< void, Ptr< Packet >, const Address & > ReceiveSatelliteCallback
Receive callback used for sending packet to netdevice layer.
virtual void ReceiveHigherLayerPdu(Ptr< Packet > packet, Mac48Address source, Mac48Address dest)
Receive HL PDU from encapsulator/decapsulator entity.
virtual bool Enque(Ptr< Packet > packet, Address dest, uint8_t flowId)
Called from higher layer (SatNetDevice) to enque packet to LLC.
static TypeId GetTypeId(void)
Derived from Object.
virtual void CreateDecap(Ptr< EncapKey > key)
Virtual method to create a new decapsulator 'on-a-need-basis' dynamically.
SatOrbiterLlc()
Construct a SatOrbiterLlc.
virtual void ClearQueues()
Remove all packets from the queues.
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 void GetSchedulingContexts(std::vector< Ptr< SatSchedulingObject >> &output) const
Create and fill the scheduling objects based on LLC layer information.
ReceiveSatelliteCallback m_rxSatelliteCallback
The upper layer package receive callback.
void SetReceiveSatelliteCallback(SatOrbiterLlc::ReceiveSatelliteCallback cb)
Set Receive callback to forward packet to upper layer on satellite.
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.