satellite-gw-mac.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2014 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: Jani Puttonen <jani.puttonen@magister.fi>
19  */
20 
21 #include "satellite-gw-mac.h"
22 
23 #include "satellite-bbframe.h"
26 #include "satellite-log.h"
27 #include "satellite-mac-tag.h"
30 #include "satellite-time-tag.h"
32 #include "satellite-utils.h"
33 
34 #include <ns3/address.h>
35 #include <ns3/boolean.h>
36 #include <ns3/log.h>
37 #include <ns3/mac48-address.h>
38 #include <ns3/packet.h>
39 #include <ns3/pointer.h>
40 #include <ns3/simulator.h>
41 #include <ns3/singleton.h>
42 #include <ns3/uinteger.h>
43 
44 NS_LOG_COMPONENT_DEFINE("SatGwMac");
45 
46 namespace ns3
47 {
48 
49 NS_OBJECT_ENSURE_REGISTERED(SatGwMac);
50 
51 TypeId
53 {
54  static TypeId tid =
55  TypeId("ns3::SatGwMac")
56  .SetParent<SatMac>()
57  .AddConstructor<SatGwMac>()
58  .AddAttribute("Scheduler",
59  "Forward link scheduler used by this Sat GW MAC.",
60  PointerValue(),
61  MakePointerAccessor(&SatGwMac::m_fwdScheduler),
62  MakePointerChecker<SatFwdLinkScheduler>())
63  .AddAttribute("GuardTime",
64  "Guard time in forward link",
65  TimeValue(MicroSeconds(1)),
66  MakeTimeAccessor(&SatGwMac::m_guardTime),
67  MakeTimeChecker())
68  .AddAttribute("NcrBroadcastPeriod",
69  "Interval between two broadcast of NCR dates",
70  TimeValue(MilliSeconds(100)),
71  MakeTimeAccessor(&SatGwMac::m_ncrInterval),
72  MakeTimeChecker())
73  .AddAttribute("UseCmt",
74  "Use CMT control messages to correct time on the UTs",
75  BooleanValue(false),
76  MakeBooleanAccessor(&SatGwMac::m_useCmt),
77  MakeBooleanChecker())
78  .AddAttribute("CmtPeriodMin",
79  "Minimum interval between two CMT control messages for a same UT",
80  TimeValue(MilliSeconds(550)),
81  MakeTimeAccessor(&SatGwMac::m_cmtPeriodMin),
82  MakeTimeChecker())
83  .AddAttribute("SendNcrBroadcast",
84  "Broadcast NCR messages to all UTs",
85  BooleanValue(true),
86  MakeBooleanAccessor(&SatGwMac::m_broadcastNcr),
87  MakeBooleanChecker())
88  .AddTraceSource("BBFrameTxTrace",
89  "Trace for transmitted BB Frames.",
90  MakeTraceSourceAccessor(&SatGwMac::m_bbFrameTxTrace),
91  "ns3::SatBbFrame::BbFrameCallback");
92  return tid;
93 }
94 
95 TypeId
97 {
98  NS_LOG_FUNCTION(this);
99 
100  return GetTypeId();
101 }
102 
104  : SatMac(),
105  m_fwdScheduler(),
106  m_guardTime(MicroSeconds(1)),
107  m_ncrInterval(MilliSeconds(100)),
108  m_useCmt(false),
109  m_lastCmtSent(),
110  m_cmtPeriodMin(MilliSeconds(550)),
111  m_broadcastNcr(true)
112 {
113  NS_LOG_FUNCTION(this);
114 
115  NS_FATAL_ERROR("SatUtMac::SatGwMac - Constructor not in use");
116 }
117 
118 SatGwMac::SatGwMac(uint32_t satId,
119  uint32_t beamId,
120  SatEnums::RegenerationMode_t forwardLinkRegenerationMode,
121  SatEnums::RegenerationMode_t returnLinkRegenerationMode)
122  : SatMac(satId, beamId, forwardLinkRegenerationMode, returnLinkRegenerationMode),
123  m_fwdScheduler(),
124  m_guardTime(MicroSeconds(1)),
125  m_ncrInterval(MilliSeconds(100)),
126  m_useCmt(false),
127  m_lastCmtSent(),
128  m_cmtPeriodMin(MilliSeconds(550)),
129  m_broadcastNcr(true)
130 {
131  NS_LOG_FUNCTION(this);
132 }
133 
135 {
136  NS_LOG_FUNCTION(this);
137 }
138 
139 void
141 {
142  NS_LOG_FUNCTION(this);
143 
144  m_txOpportunityCallback.Nullify();
145  m_crReceiveCallback.Nullify();
146  m_handoverCallback.Nullify();
147  m_logonCallback.Nullify();
149 
151 }
152 
153 void
155 {
156  NS_LOG_FUNCTION(this);
157 
158  if (m_fwdScheduler == NULL)
159  {
160  NS_FATAL_ERROR("Scheduler not set for GW MAC!!!");
161  }
162 
170  Simulator::Schedule(Seconds(0), &SatGwMac::StartTransmission, this, 0);
171 
172  if (m_broadcastNcr)
173  {
174  Simulator::Schedule(MilliSeconds(50), &SatGwMac::StartNcrTransmission, this);
175  }
176 }
177 
178 void
179 SatGwMac::Receive(SatPhy::PacketContainer_t packets, Ptr<SatSignalParameters> rxParams)
180 {
181  NS_LOG_FUNCTION(this);
182 
183  // Add packet trace entry:
184  m_packetTrace(Simulator::Now(),
186  m_nodeInfo->GetNodeType(),
187  m_nodeInfo->GetNodeId(),
188  m_nodeInfo->GetMacAddress(),
191  SatUtils::GetPacketInfo(packets));
192 
193  // Invoke the `Rx` and `RxDelay` trace sources.
194  RxTraces(packets);
195 
196  Address utId;
197 
198  for (SatPhy::PacketContainer_t::iterator i = packets.begin(); i != packets.end(); i++)
199  {
200  // Remove packet tag
201  SatMacTag macTag;
202  bool mSuccess = (*i)->PeekPacketTag(macTag);
203  if (!mSuccess)
204  {
205  NS_FATAL_ERROR("MAC tag was not found from the packet!");
206  }
207  SatAddressE2ETag addressE2ETag;
208  mSuccess = (*i)->PeekPacketTag(addressE2ETag);
209  if (!mSuccess)
210  {
211  NS_FATAL_ERROR("Address E2E tag was not found from the packet!");
212  }
213 
214  NS_LOG_INFO("Packet from " << macTag.GetSourceAddress() << " to "
215  << macTag.GetDestAddress());
216  NS_LOG_INFO("Receiver " << m_nodeInfo->GetMacAddress());
217 
218  // If the packet is intended for this receiver
219  Mac48Address destAddress = macTag.GetDestAddress();
220  utId = addressE2ETag.GetE2ESourceAddress();
221 
222  if (destAddress == m_nodeInfo->GetMacAddress() || destAddress.IsBroadcast())
223  {
224  // Peek control msg tag
225  SatControlMsgTag ctrlTag;
226  bool cSuccess = (*i)->PeekPacketTag(ctrlTag);
227 
228  if (cSuccess)
229  {
231 
233  {
234  uint32_t beamId;
235  uint32_t satId;
237  {
240  beamId = rxParams->m_beamId;
241  satId = rxParams->m_satId;
242  break;
243  }
246  SatUplinkInfoTag satUplinkInfoTag;
247  if (!(*i)->PeekPacketTag(satUplinkInfoTag))
248  {
249  NS_FATAL_ERROR("SatUplinkInfoTag not found!");
250  }
251  beamId = satUplinkInfoTag.GetBeamId();
252  satId = satUplinkInfoTag.GetSatId();
253  break;
254  }
255  default:
256  NS_FATAL_ERROR("Unknown regeneration mode");
257  }
258  ReceiveSignalingPacket(*i, satId, beamId);
259  }
260  else
261  {
262  NS_FATAL_ERROR("A control message received with not valid msg type!");
263  }
264  }
265  else
266  {
267  // Pass the source address to LLC
268  m_rxCallback(*i,
269  addressE2ETag.GetE2ESourceAddress(),
270  addressE2ETag.GetE2EDestAddress());
271  }
272  }
273  else
274  {
275  NS_LOG_INFO(
276  "Packet intended for others received by MAC: " << m_nodeInfo->GetMacAddress());
277  }
278  }
279 
280  if (m_useCmt)
281  {
283  {
284  case SatEnums::TRANSPARENT: {
285  if (rxParams->m_txInfo.waveformId == 2)
286  {
287  SendCmtMessage(utId,
288  rxParams->m_duration,
289  Seconds(0),
290  rxParams->m_satId,
291  rxParams->m_beamId);
292  m_controlMessageReceivedCallback(utId, rxParams->m_satId, rxParams->m_beamId);
293  }
294  break;
295  }
297  if (rxParams->m_txInfo.waveformId == 2)
298  {
299  for (SatPhy::PacketContainer_t::iterator i = packets.begin(); i != packets.end();
300  i++)
301  {
302  SatControlMsgTag ctrlTag;
303  if ((*i)->PeekPacketTag(ctrlTag))
304  {
305  // This is a NCR CTRL packet, do not use it
306  continue;
307  }
308  SatUplinkInfoTag satUplinkInfoTag;
309  if (!(*i)->PeekPacketTag(satUplinkInfoTag))
310  {
311  NS_FATAL_ERROR("SatUplinkInfoTag not found !");
312  }
313  Time satelliteReceptionTime = satUplinkInfoTag.GetSatelliteReceptionTime();
314  uint32_t beamId = satUplinkInfoTag.GetBeamId();
315  uint32_t satId = satUplinkInfoTag.GetSatId();
316 
317  SendCmtMessage(utId, Seconds(0), satelliteReceptionTime, satId, beamId);
318  m_controlMessageReceivedCallback(utId, satId, beamId);
319  }
320  }
321  break;
322  }
325  for (SatPhy::PacketContainer_t::iterator i = packets.begin(); i != packets.end(); i++)
326  {
327  SatUplinkInfoTag satUplinkInfoTag;
328  if (!(*i)->PeekPacketTag(satUplinkInfoTag))
329  {
330  NS_FATAL_ERROR("SatUplinkInfoTag not found !");
331  }
332  Time satelliteReceptionTime = satUplinkInfoTag.GetSatelliteReceptionTime();
333  uint32_t beamId = satUplinkInfoTag.GetBeamId();
334  uint32_t satId = satUplinkInfoTag.GetSatId();
335  bool isControl = satUplinkInfoTag.IsControl();
336 
337  if (isControl)
338  {
339  SendCmtMessage(utId, Seconds(0), satelliteReceptionTime, satId, beamId);
340  m_controlMessageReceivedCallback(utId, satId, beamId);
341  }
342  }
343  break;
344  }
345  default:
346  NS_FATAL_ERROR("Unknown regeneration mode, or received");
347  }
348  }
349 }
350 
351 void
352 SatGwMac::StartTransmission(uint32_t carrierId)
353 {
354  NS_LOG_FUNCTION(this);
355 
356  if (m_nodeInfo->GetNodeType() == SatEnums::NT_GW)
357  {
358  m_lastSOF.push(Simulator::Now());
359  uint8_t lastSOFSize = m_ncrV2 ? 3 : 1;
360  if (m_lastSOF.size() > lastSOFSize)
361  {
362  m_lastSOF.pop();
363  }
364  }
365 
366  Time txDuration;
367 
368  if (m_txEnabled)
369  {
370  std::pair<Ptr<SatBbFrame>, const Time> bbFrameInfo = m_fwdScheduler->GetNextFrame();
371  Ptr<SatBbFrame> bbFrame = bbFrameInfo.first;
372  txDuration = bbFrameInfo.second;
373 
374  // trace out BB frames sent.
375  m_bbFrameTxTrace(bbFrame);
376 
377  // Handle both dummy frames and normal frames
378  if (bbFrame != NULL)
379  {
380  // Add packet trace entry:
381  m_packetTrace(Simulator::Now(),
383  m_nodeInfo->GetNodeType(),
384  m_nodeInfo->GetNodeId(),
385  m_nodeInfo->GetMacAddress(),
388  SatUtils::GetPacketInfo(bbFrame->GetPayload()));
389 
392  txInfo.modCod = bbFrame->GetModcod();
393  txInfo.sliceId = bbFrame->GetSliceId();
394  txInfo.frameType = bbFrame->GetFrameType();
395  txInfo.waveformId = 0;
396 
400  SendPacket(bbFrame->GetPayload(), carrierId, txDuration - m_guardTime, txInfo);
401  }
402  }
403  else
404  {
410  NS_LOG_INFO("TX is disabled, thus nothing is transmitted!");
411  txDuration = m_fwdScheduler->GetDefaultFrameDuration();
412  }
413 
421  Simulator::Schedule(txDuration, &SatGwMac::StartTransmission, this, 0);
422 }
423 
424 void
425 SatGwMac::TbtpSent(Ptr<SatTbtpMessage> tbtp)
426 {
427  NS_LOG_FUNCTION(this << tbtp);
428 
429  uint32_t superframeCounter = tbtp->GetSuperframeCounter();
430 
431  if (m_tbtps.find(superframeCounter) == m_tbtps.end())
432  {
433  m_tbtps[superframeCounter] = std::vector<Ptr<SatTbtpMessage>>();
434  }
435  m_tbtps[superframeCounter].push_back(tbtp);
436 
437  Simulator::Schedule(Seconds(10), &SatGwMac::RemoveTbtp, this, superframeCounter);
438 }
439 
440 void
441 SatGwMac::RemoveTbtp(uint32_t superframeCounter)
442 {
443  m_tbtps.erase(superframeCounter);
444 }
445 
446 void
448 {
449  NS_LOG_FUNCTION(this);
450 
451  SendNcrMessage();
452 
453  Simulator::Schedule(m_ncrInterval, &SatGwMac::StartNcrTransmission, this);
454 }
455 
456 void
457 SatGwMac::ReceiveSignalingPacket(Ptr<Packet> packet, uint32_t satId, uint32_t beamId)
458 {
459  NS_LOG_FUNCTION(this << packet << beamId);
460 
461  // Remove the mac tag
462  SatMacTag macTag;
463  packet->PeekPacketTag(macTag);
464 
465  SatAddressE2ETag addressE2ETag;
466  packet->PeekPacketTag(addressE2ETag);
467 
468  // Peek control msg tag
469  SatControlMsgTag ctrlTag;
470  bool cSuccess = packet->PeekPacketTag(ctrlTag);
471 
472  if (!cSuccess)
473  {
474  NS_FATAL_ERROR("SatControlMsgTag not found in the packet!");
475  }
476 
477  switch (ctrlTag.GetMsgType())
478  {
480  uint32_t msgId = ctrlTag.GetMsgId();
481  Ptr<SatCrMessage> crMsg = DynamicCast<SatCrMessage>(m_readCtrlCallback(msgId));
482 
483  if (crMsg != NULL)
484  {
485  Mac48Address sourceAddress;
487  {
490  sourceAddress = addressE2ETag.GetE2ESourceAddress();
491  break;
492  }
494  sourceAddress = Mac48Address::ConvertFrom(m_satelliteAddress);
495  break;
496  }
497  default:
498  NS_FATAL_ERROR("Unknown regeneration mode");
499  }
500  m_fwdScheduler->CnoInfoUpdated(sourceAddress, crMsg->GetCnoEstimate());
501 
502  if (m_crReceiveCallback.IsNull() == false)
503  {
504  m_crReceiveCallback(satId, beamId, addressE2ETag.GetE2ESourceAddress(), crMsg);
505  }
506  }
507  else
508  {
514  std::stringstream msg;
515  msg << "Control message " << ctrlTag.GetMsgType()
516  << " is not found from the RTN link control msg container!";
517  msg << " at: " << Now().GetSeconds() << "s";
518  Singleton<SatLog>::Get()->AddToLog(SatLog::LOG_WARNING, "", msg.str());
519  }
520 
521  packet->RemovePacketTag(macTag);
522  packet->RemovePacketTag(addressE2ETag);
523  packet->RemovePacketTag(ctrlTag);
524 
525  break;
526  }
528  uint32_t msgId = ctrlTag.GetMsgId();
529  Ptr<SatCnoReportMessage> cnoReport =
530  DynamicCast<SatCnoReportMessage>(m_readCtrlCallback(msgId));
531 
532  if (cnoReport != NULL)
533  {
534  m_fwdScheduler->CnoInfoUpdated(addressE2ETag.GetE2ESourceAddress(),
535  cnoReport->GetCnoEstimate());
536  }
537  else
538  {
544  std::stringstream msg;
545  msg << "Control message " << ctrlTag.GetMsgType()
546  << " is not found from the RTN link control msg container!";
547  msg << " at: " << Now().GetSeconds() << "s";
548  Singleton<SatLog>::Get()->AddToLog(SatLog::LOG_WARNING, "", msg.str());
549  }
550 
551  packet->RemovePacketTag(macTag);
552  packet->RemovePacketTag(addressE2ETag);
553  packet->RemovePacketTag(ctrlTag);
554 
555  break;
556  }
558  // ARQ ACK messages are forwarded to LLC, since they may be fragmented
559  m_rxCallback(packet, addressE2ETag.GetE2ESourceAddress(), macTag.GetDestAddress());
560  break;
561  }
563  uint32_t msgId = ctrlTag.GetMsgId();
564  Ptr<SatHandoverRecommendationMessage> handoverRecommendation =
565  DynamicCast<SatHandoverRecommendationMessage>(m_readCtrlCallback(msgId));
566 
567  if (handoverRecommendation != NULL)
568  {
569  uint32_t newBeamId = handoverRecommendation->GetRecommendedBeamId();
570  m_handoverCallback(addressE2ETag.GetE2ESourceAddress(), satId, beamId, newBeamId);
571  }
572  else
573  {
579  std::stringstream msg;
580  msg << "Control message " << ctrlTag.GetMsgType()
581  << " is not found from the RTN link control msg container!";
582  msg << " at: " << Now().GetSeconds() << "s";
583  Singleton<SatLog>::Get()->AddToLog(SatLog::LOG_WARNING, "", msg.str());
584  }
585 
586  break;
587  }
589  uint32_t msgId = ctrlTag.GetMsgId();
590  Ptr<SatLogonMessage> logonMessage = DynamicCast<SatLogonMessage>(m_readCtrlCallback(msgId));
591 
592  if (logonMessage != NULL)
593  {
594  Address utId = addressE2ETag.GetE2ESourceAddress();
595  Callback<void, uint32_t> raChannelCallback =
596  MakeBoundCallback(&SatGwMac::SendLogonResponseHelper, this, utId);
597  m_logonCallback(utId, satId, beamId, raChannelCallback);
598  }
599  else
600  {
606  std::stringstream msg;
607  msg << "Control message " << ctrlTag.GetMsgType()
608  << " is not found from the RTN link control msg container!";
609  msg << " at: " << Now().GetSeconds() << "s";
610  Singleton<SatLog>::Get()->AddToLog(SatLog::LOG_WARNING, "", msg.str());
611  }
612  break;
613  }
615  // We do nothing, from SAT to GW, these messages only add load on link
616  break;
617  }
618  default: {
619  NS_FATAL_ERROR("SatGwMac received a non-supported control packet!");
620  break;
621  }
622  }
623 }
624 
625 void
627 {
628  NS_LOG_FUNCTION(this);
629  Ptr<SatNcrMessage> ncrMessage = CreateObject<SatNcrMessage>();
630  m_fwdScheduler->SendControlMsg(ncrMessage, Mac48Address::GetBroadcast());
631  m_ncrMessagesToSend.push(ncrMessage);
632 }
633 
634 void
636  Time burstDuration,
637  Time satelliteReceptionTime,
638  uint32_t satId,
639  uint32_t beamId)
640 {
641  NS_LOG_FUNCTION(this << utId);
642 
643  Time lastCmtSent = Seconds(0);
644  if (m_lastCmtSent.find(utId) != m_lastCmtSent.end())
645  {
646  lastCmtSent = m_lastCmtSent[utId];
647  }
648 
649  Time timeReceived = satelliteReceptionTime;
650  if (satelliteReceptionTime == Seconds(0))
651  {
652  timeReceived = Simulator::Now();
653  }
654 
655  if (timeReceived < lastCmtSent + m_cmtPeriodMin)
656  {
657  return;
658  }
659 
660  uint32_t indexClosest = 0;
661  uint32_t tbtpIndexClosest = 0;
662  uint32_t timeSlotIndexClosest = 0;
663  Time differenceClosest = Seconds(1000000);
664  std::vector<Ptr<SatTbtpMessage>> tbtpsForCurrentSF;
665  Ptr<SatTbtpMessage> tbtp;
666  for (uint32_t i = 0; i < m_tbtps.size(); i++)
667  {
668  tbtpsForCurrentSF = m_tbtps[i];
669  for (uint32_t tbtpIndex = 0; tbtpIndex < tbtpsForCurrentSF.size(); tbtpIndex++)
670  {
671  tbtp = tbtpsForCurrentSF[tbtpIndex];
672  std::pair<uint8_t, std::vector<Ptr<SatTimeSlotConf>>> timeslots =
673  tbtp->GetDaTimeslots(utId);
674  for (uint32_t j = 0; j < timeslots.second.size(); j++)
675  {
676  Ptr<SatTimeSlotConf> tsConf = timeslots.second[j];
677  if (tsConf->GetSlotType() == SatTimeSlotConf::SLOT_TYPE_C)
678  {
679  Time frameStartTime = Singleton<SatRtnLinkTime>::Get()->GetSuperFrameTxTime(
681  i,
682  Seconds(0));
683  Time slotStartTime = tsConf->GetStartTime();
684  Time difference = timeReceived - frameStartTime - slotStartTime - burstDuration;
685  if (Abs(difference) < differenceClosest)
686  {
687  differenceClosest = Abs(difference);
688  indexClosest = i;
689  timeSlotIndexClosest = j;
690  tbtpIndexClosest = tbtpIndex;
691  }
692  }
693  }
694  }
695  }
696 
697  if (indexClosest == 0)
698  {
699  return;
700  }
701 
702  tbtp = m_tbtps[indexClosest][tbtpIndexClosest];
703  std::pair<uint8_t, std::vector<Ptr<SatTimeSlotConf>>> timeslots = tbtp->GetDaTimeslots(utId);
704 
705  if (timeslots.second[timeSlotIndexClosest]->GetSlotType() == 0)
706  {
707  Time frameStartTime = Singleton<SatRtnLinkTime>::Get()->GetSuperFrameTxTime(
709  indexClosest,
710  Seconds(0));
711  Time slotStartTime = timeslots.second[timeSlotIndexClosest]->GetStartTime();
712 
713  Time difference = frameStartTime + slotStartTime + burstDuration - timeReceived;
714  int32_t differenceNcr = difference.GetMicroSeconds() * 27;
715 
716  if (differenceNcr > 16256 || differenceNcr < -16256)
717  {
718  NS_LOG_INFO("Burst Time Correction outside bounds, should be at least -16256 and at "
719  "most 16256, but got "
720  << differenceNcr << ". Forcing logoff of UT " << utId);
721  Ptr<SatLogoffMessage> logoffMsg = CreateObject<SatLogoffMessage>();
722  m_fwdScheduler->SendControlMsg(logoffMsg, utId);
723  m_removeUtCallback(utId, satId, beamId);
724  }
725  else
726  {
727  Ptr<SatCmtMessage> cmt = CreateObject<SatCmtMessage>();
728  cmt->SetBurstTimeCorrection(differenceNcr);
729  m_fwdScheduler->SendControlMsg(cmt, utId);
730  m_lastCmtSent[utId] = Simulator::Now();
731  }
732 
733  return;
734  }
735 }
736 
737 void
738 SatGwMac::SendLogonResponse(Address utId, uint32_t raChannel)
739 {
740  NS_LOG_FUNCTION(this << utId << raChannel);
741  Ptr<SatLogonResponseMessage> logonResponse = CreateObject<SatLogonResponseMessage>();
742  logonResponse->SetRaChannel(raChannel);
743  m_fwdScheduler->SendControlMsg(logonResponse, utId);
744 }
745 
746 void
747 SatGwMac::SendLogonResponseHelper(SatGwMac* self, Address utId, uint32_t raChannel)
748 {
749  self->SendLogonResponse(utId, raChannel);
750 }
751 
752 void
754 {
755  NS_LOG_FUNCTION(this << &cb);
756  m_crReceiveCallback = cb;
757 }
758 
759 void
761 {
762  NS_LOG_FUNCTION(this << &cb);
763  m_handoverCallback = cb;
764 }
765 
766 void
768 {
769  NS_LOG_FUNCTION(this << &cb);
770  m_logonCallback = cb;
771 }
772 
773 void
775 {
776  NS_LOG_FUNCTION(this << &cb);
778 }
779 
780 void
782 {
783  NS_LOG_FUNCTION(this << &cb);
784  m_removeUtCallback = cb;
785 }
786 
787 void
788 SatGwMac::SetFwdScheduler(Ptr<SatFwdLinkScheduler> fwdScheduler)
789 {
790  m_fwdScheduler = fwdScheduler;
791 
792  if (m_ncrV2)
793  {
794  m_fwdScheduler->SetDummyFrameSendingEnabled(true);
795  }
796 }
797 
798 } // namespace ns3
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_NON_CTRL_MSG
SAT_NON_CTRL_MSG.
@ SAT_LOGON_CTRL_MSG
SAT_LOGON_CTRL_MSG.
@ SAT_CMT_CTRL_MSG
SAT_CMT_CTRL_MSG.
virtual uint32_t GetMsgId() const
Get message type specific identifier.
SatControlMsgType_t GetMsgType(void) const
Get type of the control message.
RegenerationMode_t
The regeneration mode used in satellites.
GW specific Mac class for Sat Net Devices.
void SetLogonCallback(SatGwMac::LogonCallback cb)
Method to set logon callback.
SatGwMac::HandoverCallback m_handoverCallback
Callback to query/apply handover on the terrestrial network.
Ptr< SatFwdLinkScheduler > m_fwdScheduler
Scheduler for the forward link.
void TbtpSent(Ptr< SatTbtpMessage > tbtp)
Function called when a TBTP has been sent by the SatBeamScheduler.
SatGwMac::TxOpportunityCallback m_txOpportunityCallback
Callback to notify the txOpportunity to upper layer Returns a packet Attributes: payload in bytes.
void SendLogonResponse(Address utId, uint32_t raChannel)
std::map< Address, Time > m_lastCmtSent
Time of last CMT sending for each UT.
void SetRemoveUtCallback(SatGwMac::RemoveUtCallback cb)
Method to set callback for UT removing.
Time m_cmtPeriodMin
Minimum interval between two CMT control messages for a same UT.
Callback< void, Address, uint32_t, uint32_t > RemoveUtCallback
Callback to indicate NCC a UT needs to be removed.
void SetFwdScheduler(Ptr< SatFwdLinkScheduler > fwdScheduler)
Method to set forward link scheduler.
static TypeId GetTypeId(void)
Get the type ID.
Callback< void, Address, uint32_t, uint32_t, uint32_t > HandoverCallback
Callback to query/apply handover on the terrestrial network.
SatGwMac::CrReceiveCallback m_crReceiveCallback
Capacity request receive callback.
bool m_broadcastNcr
Broadcast NCR messages to all UTs.
static void SendLogonResponseHelper(SatGwMac *self, Address utId, uint32_t raChannel)
void SetHandoverCallback(SatGwMac::HandoverCallback cb)
Method to set handover callback.
void SetCrReceiveCallback(SatGwMac::CrReceiveCallback cb)
Method to set read control message callback.
SatGwMac::LogonCallback m_logonCallback
Callback to log a terminal on.
Callback< void, Address, uint32_t, uint32_t, Callback< void, uint32_t > > LogonCallback
Callback to register UT logon.
void StartNcrTransmission()
Send a NCR packet to the UTs.
void ReceiveSignalingPacket(Ptr< Packet > packet, uint32_t satId, uint32_t beamId)
Signaling packet receiver, which handles all the signaling packet receptions.
~SatGwMac()
Destroy a SatGwMac.
SatGwMac()
Default constructor, which is not used.
TracedCallback< Ptr< SatBbFrame > > m_bbFrameTxTrace
Trace for transmitted BB frames.
void SendCmtMessage(Address utId, Time burstDuration, Time satelliteReceptionTime, uint32_t satId, uint32_t beamId)
void StartTransmission(uint32_t carrierId)
Start sending a Packet Down the Wire.
Callback< void, uint32_t, uint32_t, Address, Ptr< SatCrMessage > > CrReceiveCallback
Callback to receive capacity request (CR) messages.
SatGwMac::RemoveUtCallback m_removeUtCallback
Callback to indicate NCC a UT needs to be removed.
void DoDispose(void)
SatGwMac::ControlMessageReceivedCallback m_controlMessageReceivedCallback
Callback to indicate NCC a control burst has been received.
std::map< uint32_t, std::vector< Ptr< SatTbtpMessage > > > m_tbtps
List of TBTPs sent to UTs.
void Receive(SatPhy::PacketContainer_t packets, Ptr< SatSignalParameters >)
Receive packet from lower layer.
void SetControlMessageReceivedCallback(SatGwMac::ControlMessageReceivedCallback cb)
Method to set callback for control burst reception.
bool m_useCmt
Use CMT control messages to correct time on the UTs.
void RemoveTbtp(uint32_t superframeCounter)
Function used to clear old TBTP.
void StartPeriodicTransmissions()
Starts periodical transmissions.
Time m_ncrInterval
Interval between two broadcast of NCR dates.
Callback< void, Address, uint32_t, uint32_t > ControlMessageReceivedCallback
Callback to inform NCC a control burst has been received.
TypeId GetInstanceTypeId(void) const
Derived from Object.
Time m_guardTime
Guard time for BB frames.
@ LOG_WARNING
LOG_WARNING.
Definition: satellite-log.h:64
Base MAC class for SatNetDevices.
Definition: satellite-mac.h:52
void RxTraces(SatPhy::PacketContainer_t packets)
Invoke the Rx trace source for each received packet.
std::queue< Ptr< SatNcrMessage > > m_ncrMessagesToSend
List of NCR control messages created but not sent yet.
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.
Address m_satelliteAddress
MAC address of satellite on other side of the link.
void DoDispose(void)
Dispose of SatMac.
SatMac::ReceiveCallback m_rxCallback
The upper layer package receive callback.
bool m_ncrV2
Use of version 2 of NCR dates.
bool m_txEnabled
Flag indicating whether the MAC is enabled, i.e.
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.
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.
std::queue< Time > m_lastSOF
Store last 3 SOF date for Forward messages, to insert in NCR packets.
This class implements a tag that carries the satellite MAC specific information, such as source and d...
Mac48Address GetSourceAddress(void) const
Get source MAC address.
Mac48Address GetDestAddress(void) const
Get destination MAC address.
SatSignalParameters::PacketsInBurst_t PacketContainer_t
Define PacketContainer in SatPhy.
Definition: satellite-phy.h:78
static std::string GetPacketInfo(const Ptr< const Packet > p)
Get packet information in std::string for printing purposes.
constexpr uint8_t SUPERFRAME_SEQUENCE
Used superframe sequence in the RTN link.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.
Struct for storing the packet specific Tx information.