Loading...
Searching...
No Matches
satellite-orbiter-feeder-mac.cc
Go to the documentation of this file.
1/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2013 Magister Solutions Ltd.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Author: Bastien Tauran <bastien.tauran@viveris.fr>
19 */
20
22
24#include "satellite-mac.h"
26#include "satellite-time-tag.h"
27#include "satellite-utils.h"
28
29#include "ns3/double.h"
30#include "ns3/enum.h"
31#include "ns3/log.h"
32#include "ns3/pointer.h"
33#include "ns3/simulator.h"
34#include "ns3/uinteger.h"
35
36NS_LOG_COMPONENT_DEFINE("SatOrbiterFeederMac");
37
38namespace ns3
39{
40
41NS_OBJECT_ENSURE_REGISTERED(SatOrbiterFeederMac);
42
43TypeId
45{
46 static TypeId tid = TypeId("ns3::SatOrbiterFeederMac")
47 .SetParent<SatOrbiterMac>()
48 .AddConstructor<SatOrbiterFeederMac>()
49 .AddAttribute("GuardTime",
50 "Guard time in this SCPC scheduler",
51 TimeValue(MicroSeconds(1)),
52 MakeTimeAccessor(&SatOrbiterMac::GetGuardTime,
54 MakeTimeChecker());
55 return tid;
56}
57
59{
60 NS_LOG_FUNCTION(this);
61 NS_FATAL_ERROR("SatOrbiterFeederMac default constructor is not allowed to use");
62}
63
64SatOrbiterFeederMac::SatOrbiterFeederMac(uint32_t satId, uint32_t beamId)
65 : SatOrbiterMac(satId, beamId)
66{
67 NS_LOG_FUNCTION(this << satId << beamId);
68}
69
71{
72 NS_LOG_FUNCTION(this);
73}
74
75void
77{
78 NS_LOG_FUNCTION(this);
79 Object::DoDispose();
80}
81
82void
84{
85 NS_LOG_FUNCTION(this);
86 Object::DoInitialize();
87}
88
89void
91{
92 NS_LOG_FUNCTION(this << packet);
93
95 {
96 NS_LOG_INFO("Do not enque packet to this beam because it is disabled");
97 return;
98 }
99
100 SatAddressE2ETag addressE2ETag;
101 bool success = packet->PeekPacketTag(addressE2ETag);
102
103 SatMacTag mTag;
104 success &= packet->RemovePacketTag(mTag);
105
107 {
108 // MAC tag and E2E address tag found
109 if (success)
110 {
111 mTag.SetDestAddress(addressE2ETag.GetE2EDestAddress());
112 mTag.SetSourceAddress(m_nodeInfo->GetMacAddress());
113 packet->AddPacketTag(mTag);
114 }
115 }
116
117 uint8_t flowId = 1;
118 SatControlMsgTag ctrlTag;
119 if (packet->PeekPacketTag(ctrlTag))
120 {
121 flowId = 0;
122 }
123
124 m_llc->Enque(packet, addressE2ETag.GetE2EDestAddress(), flowId);
125
127}
128
129void
130SatOrbiterFeederMac::Receive(SatPhy::PacketContainer_t packets, Ptr<SatSignalParameters> rxParams)
131{
132 NS_LOG_FUNCTION(this);
133
136 {
137 // Add packet trace entry:
138 m_packetTrace(Simulator::Now(),
140 m_nodeInfo->GetNodeType(),
141 m_nodeInfo->GetNodeId(),
142 m_nodeInfo->GetMacAddress(),
145 SatUtils::GetPacketInfo(packets));
146
147 RxTraces(packets);
148 }
149
150 rxParams->m_packetsInBurst.clear();
151 for (SatPhy::PacketContainer_t::iterator i = packets.begin(); i != packets.end(); i++)
152 {
153 // Remove packet tag
154 SatMacTag macTag;
155 bool mSuccess = (*i)->PeekPacketTag(macTag);
156 if (!mSuccess)
157 {
158 NS_FATAL_ERROR("MAC tag was not found from the packet!");
159 }
160
161 NS_LOG_INFO("Packet from " << macTag.GetSourceAddress() << " to "
162 << macTag.GetDestAddress());
163 NS_LOG_INFO("Receiver " << m_nodeInfo->GetMacAddress());
164
165 SatAddressE2ETag satAddressE2ETag;
166 mSuccess = (*i)->PeekPacketTag(satAddressE2ETag);
167 if (!mSuccess)
168 {
169 NS_FATAL_ERROR("SatAddressE2E tag was not found from the packet!");
170 }
171 Mac48Address destE2EAddress = satAddressE2ETag.GetE2EDestAddress();
172 if (destE2EAddress == m_nodeInfo->GetMacAddress())
173 {
174 // Remove control msg tag
175 SatControlMsgTag ctrlTag;
176 bool cSuccess = (*i)->PeekPacketTag(ctrlTag);
177
178 if (cSuccess)
179 {
181
183 {
185 }
186 else
187 {
188 NS_FATAL_ERROR("A control message received with not valid msg type!");
189 }
190 }
191 }
192 else
193 {
194 rxParams->m_packetsInBurst.push_back(*i);
195 }
196 }
197
199 {
200 for (SatPhy::PacketContainer_t::iterator i = rxParams->m_packetsInBurst.begin();
201 i != rxParams->m_packetsInBurst.end();
202 i++)
203 {
204 // Remove packet tag
205 SatMacTag macTag;
206 bool mSuccess = (*i)->PeekPacketTag(macTag);
207 if (!mSuccess)
208 {
209 NS_FATAL_ERROR("MAC tag was not found from the packet!");
210 }
211 Mac48Address destAddress = macTag.GetDestAddress();
212
213 NS_LOG_INFO("Packet from " << macTag.GetSourceAddress() << " to "
214 << macTag.GetDestAddress());
215 NS_LOG_INFO("Receiver " << m_nodeInfo->GetMacAddress());
216
217 if (destAddress == m_nodeInfo->GetMacAddress() || destAddress.IsBroadcast() ||
218 destAddress.IsGroup())
219 {
220 m_rxCallback(*i, macTag.GetSourceAddress(), macTag.GetDestAddress());
221 }
222 }
223 }
224 else
225 {
226 m_rxNetDeviceCallback(rxParams->m_packetsInBurst, rxParams);
227 }
228}
229
230void
232{
233 NS_LOG_FUNCTION(this << packet);
234
235 // Remove the mac tag
236 SatMacTag macTag;
237 packet->PeekPacketTag(macTag);
238
239 // Peek control msg tag
240 SatControlMsgTag ctrlTag;
241 bool cSuccess = packet->PeekPacketTag(ctrlTag);
242
243 if (!cSuccess)
244 {
245 NS_FATAL_ERROR("SatControlMsgTag not found in the packet!");
246 }
247
248 switch (ctrlTag.GetMsgType())
249 {
251 uint32_t msgId = ctrlTag.GetMsgId();
252 Ptr<SatCnoReportMessage> cnoReport =
253 DynamicCast<SatCnoReportMessage>(m_readCtrlCallback(msgId));
254
255 if (cnoReport != nullptr)
256 {
257 m_fwdScheduler->CnoInfoUpdated(macTag.GetSourceAddress(), cnoReport->GetCnoEstimate());
258 }
259 else
260 {
261 NS_LOG_WARN("Control message "
262 << ctrlTag.GetMsgType()
263 << " is not found from the RTN link control msg container!"
264 << " at: " << Now().GetSeconds() << "s");
265 }
266
267 packet->RemovePacketTag(macTag);
268 packet->RemovePacketTag(ctrlTag);
269
270 break;
271 }
272 default: {
273 NS_FATAL_ERROR("Control message unkonwn on feeder MAC");
274 }
275 }
276}
277
283
289
290Address
292{
293 NS_LOG_FUNCTION(this << packet);
294
295 Address utAddr; // invalid address.
296
297 SatAddressE2ETag addressE2ETag;
298 if (packet->PeekPacketTag(addressE2ETag))
299 {
300 NS_LOG_DEBUG(this << " contains a SatE2E tag");
301 utAddr = addressE2ETag.GetE2EDestAddress();
302 }
303
304 return utAddr;
305}
306
307bool
308SatOrbiterFeederMac::AddPeer(Mac48Address address)
309{
310 NS_LOG_FUNCTION(this << address);
311
312 return false;
313}
314
315bool
317{
318 NS_LOG_FUNCTION(this << address);
319
320 return false;
321}
322
323bool
325{
326 NS_LOG_FUNCTION(this);
327
328 return true;
329}
330
331} // namespace ns3
This class implements a tag that carries the satellite MAC of GW and UT.
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_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 SatOrbiterFeederMac models the user link MAC layer of the satellite node.
void Receive(SatPhy::PacketContainer_t packets, Ptr< SatSignalParameters > rxParams)
Receive packet from lower layer.
virtual ~SatOrbiterFeederMac()
Destructor for SatOrbiterFeederMac.
virtual bool AddPeer(Mac48Address address)
Add a remote peer to this MAC.
SatOrbiterFeederMac(void)
Default constructor.
virtual bool RemovePeer(Mac48Address address)
Remove a remote peer from this MAC.
static TypeId GetTypeId(void)
inherited from Object
void ReceiveSignalingPacket(Ptr< Packet > packet)
virtual Address GetRxUtAddress(Ptr< Packet > packet)
Get the UT address associated to this RX packet.
virtual void DoDispose(void)
Dispose of this class instance.
virtual void EnquePacket(Ptr< Packet > packet)
Add new packet to the LLC queue.
virtual SatEnums::SatLinkDir_t GetSatLinkTxDir()
Get the link TX direction.
virtual bool HasPeer()
Indicates if at least one device is connected in this beam.
virtual SatEnums::SatLinkDir_t GetSatLinkRxDir()
Get the link RX direction.
SatOrbiterMac(void)
Default constructor.
Ptr< SatOrbiterLlc > m_llc
LLC layer linked to this MAC.
virtual Time GetGuardTime() const
bool m_periodicTransmissionEnabled
Indicated if periodic transmission is enabled.
virtual void SetGuardTime(Time guardTime)
ReceiveNetDeviceCallback m_rxNetDeviceCallback
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.
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.