30 #include <ns3/double.h>
33 #include <ns3/pointer.h>
34 #include <ns3/simulator.h>
35 #include <ns3/uinteger.h>
37 NS_LOG_COMPONENT_DEFINE(
"SatOrbiterUserMac");
42 NS_OBJECT_ENSURE_REGISTERED(SatOrbiterUserMac);
47 static TypeId tid = TypeId(
"ns3::SatOrbiterUserMac")
49 .AddConstructor<SatOrbiterUserMac>()
50 .AddAttribute(
"GuardTime",
51 "Guard time in this fwd user link scheduler",
52 TimeValue(MicroSeconds(1)),
62 NS_LOG_FUNCTION(
this);
69 NS_LOG_FUNCTION(
this);
70 NS_FATAL_ERROR(
"SatOrbiterUserMac default constructor is not allowed to use");
76 NS_LOG_FUNCTION(
this << satId << beamId);
81 NS_LOG_FUNCTION(
this);
87 NS_LOG_FUNCTION(
this);
97 NS_LOG_FUNCTION(
this);
98 Object::DoInitialize();
104 NS_LOG_FUNCTION(
this << packet);
108 NS_LOG_INFO(
"Do not enque packet to this beam because it is disabled");
113 bool success = packet->PeekPacketTag(addressE2ETag);
116 success &= packet->RemovePacketTag(mTag);
125 packet->AddPacketTag(mTag);
131 if (packet->PeekPacketTag(ctrlTag))
144 NS_LOG_FUNCTION(
this);
162 rxParams->m_packetsInBurst.clear();
163 for (SatPhy::PacketContainer_t::iterator i = packets.begin(); i != packets.end(); i++)
167 bool mSuccess = (*i)->PeekPacketTag(macTag);
170 NS_FATAL_ERROR(
"MAC tag was not found from the packet!");
175 NS_LOG_INFO(
"Receiver " <<
m_nodeInfo->GetMacAddress());
178 mSuccess = (*i)->PeekPacketTag(satAddressE2ETag);
181 NS_FATAL_ERROR(
"SatAddressE2E tag was not found from the packet!");
184 if (destE2EAddress ==
m_nodeInfo->GetMacAddress())
188 bool cSuccess = (*i)->PeekPacketTag(ctrlTag);
200 NS_FATAL_ERROR(
"A control message received with not valid msg type!");
206 rxParams->m_packetsInBurst.push_back(*i);
212 for (SatPhy::PacketContainer_t::iterator i = rxParams->m_packetsInBurst.begin();
213 i != rxParams->m_packetsInBurst.end();
218 bool mSuccess = (*i)->PeekPacketTag(macTag);
221 NS_FATAL_ERROR(
"MAC tag was not found from the packet!");
227 NS_LOG_INFO(
"Receiver " <<
m_nodeInfo->GetMacAddress());
229 if (destAddress ==
m_nodeInfo->GetMacAddress() || destAddress.IsBroadcast() ||
230 destAddress.IsGroup())
245 NS_LOG_FUNCTION(
this << packet);
249 packet->PeekPacketTag(macTag);
253 bool cSuccess = packet->PeekPacketTag(ctrlTag);
257 NS_FATAL_ERROR(
"SatControlMsgTag not found in the packet!");
263 uint32_t msgId = ctrlTag.
GetMsgId();
264 Ptr<SatCnoReportMessage> cnoReport =
267 if (cnoReport !=
nullptr)
273 NS_LOG_WARN(
"Control message "
275 <<
" is not found from the RTN link control msg container!"
276 <<
" at: " << Now().GetSeconds() <<
"s");
279 packet->RemovePacketTag(macTag);
280 packet->RemovePacketTag(ctrlTag);
285 NS_FATAL_ERROR(
"Control message unkonwn on user MAC");
305 NS_LOG_FUNCTION(
this << packet);
310 if (packet->PeekPacketTag(addressE2ETag))
312 NS_LOG_DEBUG(
this <<
" contains a SatE2E tag");
322 NS_LOG_FUNCTION(
this << address);
328 NS_LOG_INFO(
"Start beam " <<
m_beamId);
343 NS_LOG_FUNCTION(
this << address);
351 NS_LOG_INFO(
"Stop beam " <<
m_beamId);
361 NS_LOG_FUNCTION(
this);
This class implements a tag that carries the satellite MAC of GW and UT.
Mac48Address GetE2ESourceAddress(void) const
Get E2E source MAC address.
Mac48Address GetE2EDestAddress(void) const
Get E2E destination MAC address.
This class implements a tag that is used to identify control messages (packages).
SatControlMsgType_t
Definition for different types of control messages.
@ SAT_CN0_REPORT
SAT_CN0_REPORT.
@ SAT_NON_CTRL_MSG
SAT_NON_CTRL_MSG.
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.
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.
SatMac::ReceiveCallback m_rxCallback
The upper layer package receive callback.
SatMac::ReadCtrlMsgCallback m_readCtrlCallback
The read control message callback.
SatEnums::RegenerationMode_t m_forwardLinkRegenerationMode
Regeneration mode on forward link.
Ptr< SatNodeInfo > m_nodeInfo
Node info containing node related information, such as node type, node id and MAC address (of the Sat...
SatEnums::RegenerationMode_t m_returnLinkRegenerationMode
Regeneration mode on return link.
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.
Mac48Address GetSourceAddress(void) const
Get source MAC address.
Mac48Address GetDestAddress(void) const
Get destination MAC address.
void SetSourceAddress(Mac48Address source)
Set source MAC address.
The SatOrbiterMac models the global link MAC layer of the satellite node.
bool m_disableSchedulingIfNoDeviceConnected
If true, the periodic calls of StartTransmission are not called when no devices are connected to this...
Ptr< SatOrbiterLlc > m_llc
LLC layer linked to this MAC.
uint32_t m_beamId
ID of beam for UT.
virtual Time GetGuardTime() const
bool m_periodicTransmissionEnabled
Indicated if periodic transmission is enabled.
virtual void SetGuardTime(Time guardTime)
virtual void StopPeriodicTransmissions()
Stop periodic transmission, until a pacquet in enqued.
ReceiveNetDeviceCallback m_rxNetDeviceCallback
void StartPeriodicTransmissions()
Starts periodical transmissions.
Ptr< SatFwdLinkScheduler > m_fwdScheduler
Scheduler for the forward link.
virtual void RxTraces(SatPhy::PacketContainer_t packets)
Invoke the Rx trace source for each received packet.
virtual void EnquePacket(Ptr< Packet > packet)
Add new packet to the LLC queue.
virtual ~SatOrbiterUserMac()
Destructor for SatOrbiterUserMac.
virtual bool RemovePeer(Mac48Address address)
Remove a remote peer from this MAC.
virtual bool AddPeer(Mac48Address address)
Add a remote peer to this MAC.
std::set< Mac48Address > m_peers
List of UT MAC connected to this MAC.
TypeId GetInstanceTypeId(void) const
void Receive(SatPhy::PacketContainer_t packets, Ptr< SatSignalParameters > txParams)
Receive packet from lower layer.
virtual void DoDispose(void)
Dispose of this class instance.
virtual SatEnums::SatLinkDir_t GetSatLinkRxDir()
Get the link RX direction.
SatOrbiterUserMac(void)
Default constructor.
virtual SatEnums::SatLinkDir_t GetSatLinkTxDir()
Get the link TX direction.
static TypeId GetTypeId(void)
inherited from Object
virtual void DoInitialize(void)
void ReceiveSignalingPacket(Ptr< Packet > packet)
virtual Address GetRxUtAddress(Ptr< Packet > packet)
Get the UT address associated to this RX packet.
virtual bool HasPeer()
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.