30 #include <ns3/double.h>
33 #include <ns3/pointer.h>
34 #include <ns3/simulator.h>
35 #include <ns3/uinteger.h>
39 NS_LOG_COMPONENT_DEFINE(
"SatOrbiterMac");
44 NS_OBJECT_ENSURE_REGISTERED(SatOrbiterMac);
50 TypeId(
"ns3::SatOrbiterMac")
53 "DisableSchedulingIfNoDeviceConnected",
54 "If true, the periodic calls of StartTransmission are not called when no "
55 "devices are connected to this MAC",
59 .AddTraceSource(
"BBFrameTxTrace",
60 "Trace for transmitted BB Frames.",
62 "ns3::SatBbFrame::BbFrameCallback");
70 NS_LOG_FUNCTION(
this);
77 NS_LOG_FUNCTION(
this);
78 NS_FATAL_ERROR(
"SatOrbiterMac default constructor is not allowed to use");
83 m_disableSchedulingIfNoDeviceConnected(false),
85 m_guardTime(MicroSeconds(1)),
88 m_periodicTransmissionEnabled(false)
90 NS_LOG_FUNCTION(
this);
95 NS_LOG_FUNCTION(
this);
101 NS_LOG_FUNCTION(
this);
108 NS_LOG_FUNCTION(
this);
109 Object::DoInitialize();
115 NS_LOG_FUNCTION(
this);
119 NS_LOG_INFO(
"Do not start beam " <<
m_beamId <<
" because no device is connected");
125 NS_LOG_INFO(
"Beam " <<
m_beamId <<
" already enabled");
133 NS_FATAL_ERROR(
"Scheduler not set for orbiter MAC!!!");
136 m_llc->ClearQueues();
144 NS_LOG_FUNCTION(
this << carrierId);
150 std::pair<Ptr<SatBbFrame>,
const Time> bbFrameInfo =
m_fwdScheduler->GetNextFrame();
151 Ptr<SatBbFrame> bbFrame = bbFrameInfo.first;
152 txDuration = bbFrameInfo.second;
158 if (bbFrame !=
nullptr)
162 txInfo.
modCod = bbFrame->GetModcod();
163 txInfo.
sliceId = bbFrame->GetSliceId();
164 txInfo.
frameType = bbFrame->GetFrameType();
180 NS_LOG_INFO(
"TX is disabled, thus nothing is transmitted!");
196 NS_LOG_FUNCTION(
this);
211 Ptr<SatSignalParameters> txParams = Create<SatSignalParameters>();
212 txParams->m_duration = duration;
213 txParams->m_packetsInBurst = packets;
216 txParams->m_carrierId = carrierId;
217 txParams->m_txInfo = txInfo;
226 NS_LOG_FUNCTION(
this);
230 for (SatPhy::PacketContainer_t::const_iterator it1 = packets.begin(); it1 != packets.end();
235 bool mSuccess = (*it1)->PeekPacketTag(macTag);
238 NS_FATAL_ERROR(
"MAC tag was not found from the packet!");
244 if (destAddress ==
m_nodeInfo->GetMacAddress())
251 if ((*it1)->RemovePacketTag(linkTimeTag))
253 NS_LOG_DEBUG(
this <<
" contains a SatMacLinkTimeTag tag");
296 NS_LOG_FUNCTION(
this << &cb);
303 NS_LOG_FUNCTION(
this << &cb);
310 NS_LOG_FUNCTION(
this);
314 m_llc->ClearQueues();
@ PACKET_TYPE_DEDICATED_ACCESS
Base MAC class for SatNetDevices.
Callback< void, SatPhy::PacketContainer_t, uint32_t, Time, SatSignalParameters::txInfo_s > TransmitCallback
Callback to send packet to lower layer.
bool m_isStatisticsTagsEnabled
EnableStatisticsTags attribute.
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.
void SetTimeTag(SatPhy::PacketContainer_t packets)
Set SatMacTimeTag of packets.
TracedCallback< const Time &, const Address & > m_rxLinkJitterTrace
Traced callback for all received packets, including link jitter information and the address of the se...
TracedCallback< Ptr< const Packet >, const Address & > m_rxTrace
Traced callback for all received packets, including the address of the senders.
bool m_txEnabled
Flag indicating whether the MAC is enabled, i.e.
TracedCallback< const Time &, const Address & > m_rxLinkDelayTrace
Traced callback for all received packets, including link delay information and the address of the sen...
Ptr< SatNodeInfo > m_nodeInfo
Node info containing node related information, such as node type, node id and MAC address (of the Sat...
Time m_lastLinkDelay
Last delay measurement for link.
Time tag used to identify the time when packet is enqueued at MAC on current link level.
Time GetSenderLinkTimestamp(void) const
Get sender time stamp of this tag.
This class implements a tag that carries the satellite MAC specific information, such as source and d...
Mac48Address GetDestAddress(void) const
Get destination MAC address.
bool m_disableSchedulingIfNoDeviceConnected
If true, the periodic calls of StartTransmission are not called when no devices are connected to this...
uint32_t m_satId
ID of sat for UT.
SatOrbiterMac(void)
Default constructor.
virtual void SendPacket(SatPhy::PacketContainer_t packets, uint32_t carrierId, Time duration, SatSignalParameters::txInfo_s txInfo)
Send packets to lower layer by using a callback.
Ptr< SatOrbiterLlc > m_llc
LLC layer linked to this MAC.
Callback< void, SatPhy::PacketContainer_t, Ptr< SatSignalParameters > > ReceiveNetDeviceCallback
virtual Address GetRxUtAddress(Ptr< Packet > packet)=0
Get the UT address associated to this RX packet.
uint32_t m_beamId
ID of beam for UT.
virtual Time GetGuardTime() const
void SetTransmitCallback(SatOrbiterMac::TransmitCallback cb)
Time m_guardTime
Guard time for BB frames.
TransmitCallback m_txCallback
virtual ~SatOrbiterMac()
Destructor for SatOrbiterMac.
virtual void DoInitialize(void)
void StartTransmission(uint32_t carrierId)
Start sending a Packet Down the Wire.
void SetLlc(Ptr< SatOrbiterLlc > llc)
Set the orbiter LLC associated to this orbiter MAC layer.
virtual SatEnums::SatLinkDir_t GetSatLinkTxDir()=0
Get the link TX direction.
bool m_periodicTransmissionEnabled
Indicated if periodic transmission is enabled.
virtual void SetGuardTime(Time guardTime)
virtual void DoDispose(void)
Dispose of this class instance.
virtual void StopPeriodicTransmissions()
Stop periodic transmission, until a pacquet in enqued.
ReceiveNetDeviceCallback m_rxNetDeviceCallback
void StartPeriodicTransmissions()
Starts periodical transmissions.
static TypeId GetTypeId(void)
inherited from Object
void SetFwdScheduler(Ptr< SatFwdLinkScheduler > fwdScheduler)
Method to set link scheduler (forward or SCPC)
TracedCallback< Ptr< SatBbFrame > > m_bbFrameTxTrace
Trace for transmitted BB frames.
TypeId GetInstanceTypeId(void) const
Ptr< SatFwdLinkScheduler > m_fwdScheduler
Scheduler for the forward link.
void SetReceiveNetDeviceCallback(SatOrbiterMac::ReceiveNetDeviceCallback cb)
virtual void RxTraces(SatPhy::PacketContainer_t packets)
Invoke the Rx trace source for each received packet.
virtual bool HasPeer()=0
Indicates if at least one device is connected in this beam.
SatSignalParameters::PacketsInBurst_t PacketContainer_t
Define PacketContainer in SatPhy.
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.
Struct for storing the packet specific Tx information.
SatEnums::PacketType_t packetType
SatEnums::SatBbFrameType_t frameType
SatEnums::SatModcod_t modCod