38 #include <ns3/boolean.h>
40 #include <ns3/mac48-address.h>
41 #include <ns3/packet.h>
42 #include <ns3/pointer.h>
43 #include <ns3/random-variable-stream.h>
44 #include <ns3/simulator.h>
45 #include <ns3/singleton.h>
47 NS_LOG_COMPONENT_DEFINE(
"SatUtMac");
52 NS_OBJECT_ENSURE_REGISTERED(SatUtMac);
58 TypeId(
"ns3::SatUtMac")
60 .AddConstructor<SatUtMac>()
61 .AddAttribute(
"MaxHandoverMessages",
62 "Max amount of handover messages to send without a handover response "
66 MakeUintegerChecker<uint32_t>())
67 .AddAttribute(
"SuperframeSequence",
68 "Superframe sequence containing information of superframes.",
71 MakePointerChecker<SatSuperframeSeq>())
72 .AddAttribute(
"GuardTime",
73 "Guard time in return link",
74 TimeValue(MicroSeconds(1)),
77 .AddAttribute(
"Scheduler",
78 "UT scheduler used by this Sat UT MAC.",
81 MakePointerChecker<SatUtScheduler>())
82 .AddAttribute(
"WindowInitLogon",
83 "The initial window for logon waiting time before transmission.",
84 TimeValue(Seconds(20)),
87 .AddAttribute(
"MaxWaitingTimeLogonResponse",
88 "Timeout for waiting for a response for a logon message.",
89 TimeValue(Seconds(1)),
92 .AddAttribute(
"ClockDrift",
93 "Clock drift (number of ticks per second).",
96 MakeIntegerChecker<int32_t>())
97 .AddTraceSource(
"DaResourcesTrace",
98 "Assigned dedicated access resources in return link to this UT.",
100 "ns3::SatUtMac::TbtpResourcesTraceCallback");
107 NS_LOG_FUNCTION(
this);
118 m_randomAccess(NULL),
119 m_guardTime(MicroSeconds(1)),
125 m_windowInitLogon(Seconds(20)),
126 m_maxWaitingTimeLogonResponse(Seconds(1)),
127 m_waitingTimeLogonRng(CreateObject<UniformRandomVariable>()),
128 m_nextLogonTransmissionPossible(Seconds(0)),
129 m_crdsaUniquePacketId(1),
130 m_crdsaOnlyForControl(false),
131 m_nextPacketTime(Now()),
132 m_isRandomAccessScheduled(false),
135 m_lastNcrDateReceived(Seconds(0)),
139 m_handoverState(NO_HANDOVER),
140 m_handoverMessagesCount(0),
141 m_maxHandoverMessagesSent(20),
142 m_firstTransmittableSuperframeId(0),
143 m_handoverCallback(),
144 m_gatewayUpdateCallback(),
145 m_beamCheckerCallback(),
146 m_askedBeamCallback(),
148 m_sliceSubscriptionCallback(),
149 m_sendLogonCallback(),
150 m_updateGwAddressCallback(),
151 m_beamScheculerCallback()
153 NS_LOG_FUNCTION(
this);
156 NS_FATAL_ERROR(
"SatUtMac::SatUtMac - Constructor not in use");
161 Ptr<SatSuperframeSeq> seq,
164 bool crdsaOnlyForControl)
165 :
SatMac(satId, beamId, forwardLinkRegenerationMode, returnLinkRegenerationMode),
168 m_superframeSeq(seq),
170 m_guardTime(MicroSeconds(1)),
176 m_windowInitLogon(Seconds(20)),
177 m_maxWaitingTimeLogonResponse(Seconds(1)),
178 m_waitingTimeLogonRng(CreateObject<UniformRandomVariable>()),
179 m_nextLogonTransmissionPossible(Seconds(0)),
180 m_crdsaUniquePacketId(1),
181 m_crdsaOnlyForControl(crdsaOnlyForControl),
182 m_nextPacketTime(Now()),
183 m_isRandomAccessScheduled(false),
186 m_lastNcrDateReceived(Seconds(0)),
190 m_handoverState(NO_HANDOVER),
191 m_handoverMessagesCount(0),
192 m_maxHandoverMessagesSent(20),
193 m_firstTransmittableSuperframeId(0),
194 m_handoverCallback(),
195 m_gatewayUpdateCallback(),
196 m_beamCheckerCallback(),
197 m_askedBeamCallback(),
199 m_sliceSubscriptionCallback(),
200 m_sendLogonCallback(),
201 m_updateGwAddressCallback(),
202 m_beamScheculerCallback()
204 NS_LOG_FUNCTION(
this);
212 NS_LOG_FUNCTION(
this);
222 NS_LOG_FUNCTION(
this);
244 NS_LOG_FUNCTION(
this << &cb);
251 NS_LOG_FUNCTION(
this << &cb);
258 NS_LOG_FUNCTION(
this << &cb);
265 NS_LOG_FUNCTION(
this << &cb);
272 NS_LOG_FUNCTION(
this << &cb);
280 NS_LOG_FUNCTION(
this << &cb);
288 NS_LOG_FUNCTION(
this << &cb);
296 NS_LOG_FUNCTION(
this << &cb);
304 NS_LOG_FUNCTION(
this << &cb);
319 NS_LOG_FUNCTION(
this);
327 NS_LOG_FUNCTION(
this << gwAddress);
336 NS_LOG_FUNCTION(
this << nodeInfo);
346 NS_LOG_FUNCTION(
this);
355 NS_LOG_FUNCTION(
this);
363 NS_LOG_FUNCTION(
this << raChannel);
371 NS_LOG_FUNCTION(
this);
379 NS_LOG_FUNCTION(
this);
389 NS_LOG_FUNCTION(
this);
403 NS_LOG_FUNCTION(
this);
405 bool stateCorrect = (
m_rcstState.
GetState() == SatUtMacState::RcstState_t::READY_FOR_LOGON);
408 return m_useLogon && stateCorrect && ncrReceived;
414 NS_LOG_FUNCTION(
this << &cb);
421 if (Now() >= nextSuperFrameTxTime)
423 NS_FATAL_ERROR(
"Scheduling next superframe start time to the past!");
426 Time schedulingDelay = nextSuperFrameTxTime - Now();
434 NS_LOG_FUNCTION(
this << &cb);
442 NS_LOG_FUNCTION(
this << (uint32_t)superFrameSeqId);
446 Singleton<SatRtnLinkTime>::Get()->GetNextSuperFrameTxTime(superFrameSeqId, timingAdvance);
453 NS_LOG_FUNCTION(
this << (uint32_t)superFrameSeqId);
456 Time txTime = Singleton<SatRtnLinkTime>::Get()->GetCurrentSuperFrameTxTime(superFrameSeqId,
464 NS_LOG_FUNCTION(
this << (uint32_t)superFrameSeqId);
466 return Singleton<SatRtnLinkTime>::Get()->GetCurrentSuperFrameCount(superFrameSeqId,
473 NS_LOG_FUNCTION(
this << tbtp);
474 NS_LOG_INFO(
"UT: " <<
m_nodeInfo->GetMacAddress() <<
" received TBTP "
475 << tbtp->GetSuperframeCounter());
494 Singleton<SatRtnLinkTime>::Get()->GetSuperFrameTxTime(tbtp->GetSuperframeSeqId(),
495 tbtp->GetSuperframeCounter(),
499 Time startDelay = txTime - Simulator::Now();
505 if (txTime < Simulator::Now())
507 NS_FATAL_ERROR(
"UT: " <<
m_nodeInfo->GetMacAddress() <<
" received TBTP "
508 << tbtp->GetSuperframeCounter()
509 <<
", which should have been sent already in the past");
512 NS_LOG_INFO(
"Time to start sending the superframe for this UT: " << txTime.GetSeconds());
513 NS_LOG_INFO(
"Waiting delay before the superframe start: " << startDelay.GetSeconds());
518 uint32_t payloadSumInSuperFrame = 0;
521 if (!info.second.empty())
523 NS_LOG_INFO(
"TBTP contains " << info.second.size()
524 <<
" timeslots for UT: " <<
m_nodeInfo->GetMacAddress());
526 uint8_t frameId = info.first;
529 for (SatTbtpMessage::DaTimeSlotConfContainer_t::iterator it = info.second.begin();
530 it != info.second.end();
533 Ptr<SatSuperframeConf> superframeConf =
535 Ptr<SatFrameConf> frameConf = superframeConf->GetFrameConf(frameId);
536 Ptr<SatTimeSlotConf> timeSlotConf = *it;
539 Time slotDelay = startDelay + timeSlotConf->GetStartTime();
540 NS_LOG_INFO(
"Slot start delay: " << slotDelay.GetSeconds());
543 Ptr<SatWaveform> wf =
544 m_superframeSeq->GetWaveformConf()->GetWaveform(timeSlotConf->GetWaveFormId());
545 Time duration = wf->GetBurstDuration(frameConf->GetBtuConf()->GetSymbolRateInBauds());
551 duration = wf->GetBurstDuration(frameConf->GetBtuConf()->GetSymbolRateInBauds());
561 m_superframeSeq->GetCarrierId(0, frameId, timeSlotConf->GetCarrierId());
568 payloadSumInSuperFrame += wf->GetPayloadInBytes();
569 payloadSumPerRcIndex[timeSlotConf->GetRcIndex()] += wf->GetPayloadInBytes();
588 Ptr<SatTimeSlotConf> tsConf,
591 NS_LOG_FUNCTION(
this << transmitDelay.GetSeconds() << duration.GetSeconds()
592 << wf->GetPayloadInBytes() << (uint32_t)(tsConf->GetRcIndex())
594 NS_LOG_INFO(
"After delay: " << transmitDelay.GetSeconds() <<
" duration: "
595 << duration.GetSeconds() <<
", payload: " << wf->GetPayloadInBytes()
596 <<
", rcIndex: " << (uint32_t)(tsConf->GetRcIndex())
597 <<
", carrier: " << carrierId);
601 if (transmitDelay >= Seconds(0))
603 Simulator::Schedule(transmitDelay,
618 Ptr<SatTimeSlotConf> tsConf,
621 NS_LOG_FUNCTION(
this << duration.GetSeconds() << wf->GetPayloadInBytes() << carrierId
622 << (uint32_t)(tsConf->GetRcIndex()));
626 NS_LOG_INFO(
"Tx is unavailable");
638 FetchPackets(wf->GetPayloadInBytes(), tsConf->GetSlotType(), tsConf->GetRcIndex(), policy);
642 if (packets.size() == 0)
644 Ptr<Packet> p = Create<Packet>(wf->GetPayloadInBytes());
649 p->AddPacketTag(tag);
663 p->AddPacketTag(mTag);
669 p->AddPacketTag(addressE2ETag);
671 packets.push_back(p);
675 NS_LOG_INFO(
"DA Tx opportunity for UT: "
676 <<
m_nodeInfo->GetMacAddress() <<
" duration: " << duration.GetSeconds()
677 <<
", payload: " << wf->GetPayloadInBytes() <<
", carrier: " << carrierId
678 <<
", RC index: " << (uint32_t)(tsConf->GetRcIndex()));
682 txInfo.
modCod = wf->GetModCod();
689 NS_FATAL_ERROR(
"WF02 should only be used for control bursts");
697 Ptr<SatWaveform> waveform,
702 NS_LOG_FUNCTION(
this << duration.GetSeconds() << waveform->GetPayloadInBytes() << carrierId
703 << (uint32_t)(rcIndex));
704 NS_LOG_INFO(
"Tx opportunity for UT: "
705 <<
m_nodeInfo->GetMacAddress() <<
" duration: " << duration.GetSeconds()
706 <<
", payload: " << waveform->GetPayloadInBytes() <<
", carrier: " << carrierId
707 <<
", RC index: " << (uint32_t)(rcIndex));
712 uint32_t payloadBytes = waveform->GetPayloadInBytes();
715 payloadBytes -=
m_randomAccess->GetSlottedAlohaSignalingOverheadInBytes();
717 if (payloadBytes < 1)
720 "SatUtMac::DoSlottedAlohaTransmit - Not enough capacity in Slotted ALOHA payload");
730 if (!packets.empty())
732 NS_LOG_INFO(
"Number of packets sent in a slotted ALOHA slot: " << packets.size());
734 for (SatPhy::PacketContainer_t::const_iterator it = packets.begin(); it != packets.end();
750 txInfo.
modCod = waveform->GetModCod();
753 txInfo.
waveformId = waveform->GetWaveformId();
761 Ptr<SatWaveform> waveform,
766 NS_LOG_FUNCTION(
this << duration.GetSeconds() << waveform->GetPayloadInBytes() << carrierId
767 << (uint32_t)(rcIndex));
768 NS_LOG_INFO(
"SatUtMac::DoEssaTransmit - Tx opportunity for UT: "
769 <<
m_nodeInfo->GetMacAddress() <<
" at time: " << Simulator::Now().GetSeconds()
770 <<
" duration: " << duration.GetSeconds()
771 <<
", payload: " << waveform->GetPayloadInBytes() <<
", carrier: " << carrierId
772 <<
", RC index: " << (uint32_t)(rcIndex));
775 uint32_t payloadBytes = waveform->GetPayloadInBytes();
785 if (!packets.empty())
787 NS_LOG_INFO(
"Number of packets sent in a ESSA frame: " << packets.size());
789 for (SatPhy::PacketContainer_t::const_iterator it = packets.begin(); it != packets.end();
806 txInfo.
modCod = waveform->GetModCod();
809 txInfo.
waveformId = waveform->GetWaveformId();
821 if (duration >= Seconds(0))
823 Simulator::Schedule(duration,
842 NS_LOG_FUNCTION(
this << payloadBytes << (uint32_t)(rcIndex));
851 if (payloadBytes <= 0)
853 NS_FATAL_ERROR(
"SatUtMac::FetchPackets - unvalid slot payload: " << payloadBytes);
859 if (!packets.empty())
861 NS_LOG_INFO(
"Number of packets: " << packets.size());
863 for (SatPhy::PacketContainer_t::const_iterator it = packets.begin(); it != packets.end();
878 NS_LOG_INFO(
"The Frame PDU holds " << packets.size() <<
" RLE PDUs");
889 NS_LOG_FUNCTION(
this << packets.size() << duration.GetSeconds() << carrierId);
902 if (!packets.empty())
904 NS_LOG_INFO(
"UT: " <<
m_nodeInfo->GetMacAddress() <<
", transmitting " << packets.size()
905 <<
" packets, duration: " << duration.GetSeconds()
906 <<
", carrier: " << carrierId);
909 Time durationWithoutGuardPeriod(duration -
m_guardTime);
910 NS_LOG_INFO(
"Duration: " << duration.GetSeconds() <<
" duration with guard period: "
911 << durationWithoutGuardPeriod.GetSeconds());
912 NS_LOG_INFO(
"UT: " <<
m_nodeInfo->GetMacAddress() <<
" send packet");
914 SendPacket(packets, carrierId, durationWithoutGuardPeriod, txInfo);
921 NS_LOG_FUNCTION(
this << event << (uint32_t)rcIndex);
923 NS_LOG_INFO(
"UT: " <<
m_nodeInfo->GetMacAddress() <<
" Queue: " << (uint32_t)rcIndex);
930 NS_LOG_INFO(
"Buffered packet event received");
934 NS_LOG_INFO(
"Doing Slotted ALOHA");
945 NS_LOG_FUNCTION(
this << event << (uint32_t)rcIndex);
947 NS_LOG_INFO(
"SatUtMac::ReceiveQueueEventEssa - UT: " <<
m_nodeInfo->GetMacAddress()
948 <<
" time: " << Now().GetSeconds()
949 <<
" Queue: " << (uint32_t)rcIndex);
957 NS_LOG_INFO(
"SatUtMac::ReceiveQueueEventEssa - Buffered packet event received");
961 NS_LOG_INFO(
"SatUtMac::ReceiveQueueEventEssa - Doing ESSA");
973 packets.push_back(packet);
975 Ptr<SatSuperframeConf> superframeConf =
977 uint8_t frameId = superframeConf->GetRaChannelFrameId(
m_logonChannel);
978 Ptr<SatFrameConf> frameConf = superframeConf->GetFrameConf(frameId);
980 Ptr<SatTimeSlotConf> timeSlotConf = frameConf->GetTimeSlotConf(0);
982 Ptr<SatWaveform> wf =
983 m_superframeSeq->GetWaveformConf()->GetWaveform(timeSlotConf->GetWaveFormId());
984 Time duration = wf->GetBurstDuration(frameConf->GetBtuConf()->GetSymbolRateInBauds());
988 timeSlotConf->GetCarrierId());
992 txInfo.
modCod = wf->GetModCod();
1003 if (waitingTime >= Seconds(0))
1005 Simulator::Schedule(waitingTime,
1021 NS_LOG_FUNCTION(
this << packets.size());
1042 for (SatPhy::PacketContainer_t::iterator i = packets.begin(); i != packets.end(); i++)
1046 bool mSuccess = (*i)->PeekPacketTag(macTag);
1049 NS_FATAL_ERROR(
"MAC tag was not found from the packet!");
1053 mSuccess = (*i)->PeekPacketTag(addressE2ETag);
1056 NS_FATAL_ERROR(
"SatAddressE2ETag was not found from the packet!");
1061 NS_LOG_INFO(
"Receiver " <<
m_nodeInfo->GetMacAddress());
1064 if (destAddress ==
m_nodeInfo->GetMacAddress() || destAddress.IsBroadcast() ||
1065 destAddress.IsGroup())
1069 bool cSuccess = (*i)->PeekPacketTag(ctrlTag);
1081 NS_FATAL_ERROR(
"A control message received with not valid msg type!");
1084 else if (destAddress.IsBroadcast())
1104 NS_LOG_FUNCTION(
this);
1108 packet->PeekPacketTag(macTag);
1111 packet->PeekPacketTag(addressE2ETag);
1115 bool cSuccess = packet->PeekPacketTag(ctrlTag);
1119 NS_FATAL_ERROR(
"SatControlMsgTag not found in the packet!");
1125 uint32_t tbtpId = ctrlTag.
GetMsgId();
1136 NS_FATAL_ERROR(
"TBTP not found, check SatBeamHelper::CtrlMsgStoreTimeInFwdLink "
1137 "attribute is long enough!");
1147 packet->RemovePacketTag(macTag);
1148 packet->RemovePacketTag(addressE2ETag);
1149 packet->RemovePacketTag(ctrlTag);
1159 uint32_t raCtrlId = ctrlTag.
GetMsgId();
1164 uint32_t allocationChannelId = raMsg->GetAllocationChannelId();
1165 uint16_t backoffProbability = raMsg->GetBackoffProbability();
1166 uint16_t backoffTime = raMsg->GetBackoffTime();
1168 NS_LOG_INFO(
"UT: " <<
m_nodeInfo->GetMacAddress()
1169 <<
" Updating RA backoff probability for AC: "
1170 << allocationChannelId <<
" to: " << backoffProbability);
1172 m_randomAccess->SetBackoffProbability(allocationChannelId, backoffProbability);
1173 m_randomAccess->SetBackoffTime(allocationChannelId, backoffTime);
1175 packet->RemovePacketTag(macTag);
1176 packet->RemovePacketTag(addressE2ETag);
1177 packet->RemovePacketTag(ctrlTag);
1186 std::stringstream msg;
1187 msg <<
"Control message " << ctrlTag.
GetMsgType()
1188 <<
" is not found from the FWD link control msg container!";
1189 msg <<
" at: " << Now().GetSeconds() <<
"s";
1195 uint32_t timuCtrlId = ctrlTag.
GetMsgId();
1196 Ptr<SatTimuMessage> timuMsg = DynamicCast<SatTimuMessage>(
m_readCtrlCallback(timuCtrlId));
1198 if (timuMsg != NULL)
1200 uint32_t beamId = timuMsg->GetAllocatedBeamId();
1201 NS_LOG_INFO(
"UT: " <<
m_nodeInfo->GetMacAddress() <<
" switching from beam " <<
m_beamId
1202 <<
" to beam " << beamId);
1205 NS_LOG_INFO(
"Storing TIM-U information internally for later");
1206 m_timuInfo = Create<SatTimuInfo>(beamId, timuMsg->GetGwAddress());
1216 std::stringstream msg;
1217 msg <<
"Control message " << ctrlTag.
GetMsgType()
1218 <<
" is not found from the FWD link control msg container!";
1219 msg <<
" at: " << Now().GetSeconds() <<
"s";
1225 uint32_t sliceCtrlId = ctrlTag.
GetMsgId();
1226 Ptr<SatSliceSubscriptionMessage> sliceMsg =
1229 if (sliceMsg != NULL)
1231 if (
m_nodeInfo->GetMacAddress() == sliceMsg->GetAddress())
1243 std::stringstream msg;
1244 msg <<
"Control message " << ctrlTag.
GetMsgType()
1245 <<
" is not found from the FWD link control msg container!";
1246 msg <<
" at: " << Now().GetSeconds() <<
"s";
1252 uint32_t logonId = ctrlTag.
GetMsgId();
1253 Ptr<SatLogonResponseMessage> logonMsg =
1256 if (logonMsg != NULL)
1272 std::stringstream msg;
1273 msg <<
"Control message " << ctrlTag.
GetMsgType()
1274 <<
" is not found from the FWD link control msg container!";
1275 msg <<
" at: " << Now().GetSeconds() <<
"s";
1281 uint32_t ncrCtrlId = ctrlTag.
GetMsgId();
1282 Ptr<SatNcrMessage> ncrMsg = DynamicCast<SatNcrMessage>(
m_readCtrlCallback(ncrCtrlId));
1285 m_ncr = ncrMsg->GetNcrDate();
1302 uint32_t cmtCtrlId = ctrlTag.
GetMsgId();
1303 Ptr<SatCmtMessage> cmtMsg = DynamicCast<SatCmtMessage>(
m_readCtrlCallback(cmtCtrlId));
1304 int16_t burstTimeCorrection = cmtMsg->GetBurstTimeCorrection();
1309 uint32_t logoffCtrlId = ctrlTag.
GetMsgId();
1310 Ptr<SatLogoffMessage> logoffMsg =
1316 NS_FATAL_ERROR(
"SatUtMac received a non-supported control packet!");
1325 NS_LOG_FUNCTION(
this << randomAccessTriggerType);
1327 NS_LOG_INFO(
"UT: " <<
m_nodeInfo->GetMacAddress());
1345 NS_LOG_INFO(
"Logon channel cannot be used for RA transmition");
1350 txOpportunities =
m_randomAccess->DoRandomAccess(allocationChannel, randomAccessTriggerType);
1358 NS_LOG_INFO(
"Processing Slotted ALOHA results, Tx evaluation @: "
1359 << (Now() + txOpportunity).GetSeconds() <<
" seconds");
1362 if (txOpportunity >= Seconds(0))
1364 Simulator::Schedule(txOpportunity,
1373 NS_LOG_INFO(
"Processing CRDSA results");
1381 NS_LOG_INFO(
"SatUtMac::DoRandomAccess - Processing ESSA results");
1390 if (txOpportunity >= Seconds(0))
1392 Simulator::Schedule(txOpportunity,
1403 NS_LOG_FUNCTION(
this);
1414 NS_LOG_FUNCTION(
this << allocationChannel);
1416 NS_LOG_INFO(
"UT: " <<
m_nodeInfo->GetMacAddress() <<
" AC: " << allocationChannel);
1423 NS_LOG_INFO(
"No known DAMA, selecting a slot for Slotted ALOHA");
1425 Ptr<SatSuperframeConf> superframeConf =
1427 uint8_t frameId = superframeConf->GetRaChannelFrameId(allocationChannel);
1428 Ptr<SatFrameConf> frameConf = superframeConf->GetFrameConf(frameId);
1429 uint32_t timeSlotCount = frameConf->GetTimeSlotCount();
1431 std::pair<bool, uint32_t> result = std::make_pair(
false, 0);
1432 Time superframeStartTime =
1435 if (Now() < superframeStartTime)
1437 NS_FATAL_ERROR(
"SatUtMac::ScheduleSlottedAlohaTransmission - Invalid SF start time");
1442 NS_LOG_INFO(
"Searching for next available slot");
1446 while (!result.first)
1448 NS_LOG_INFO(
"SuperFrameId: " << superFrameId <<
", superframeStartTime: "
1449 << superframeStartTime.GetSeconds());
1459 NS_LOG_INFO(
"Increasing frame offset!");
1461 superframeStartTime += frameConf->GetDuration();
1466 Ptr<SatTimeSlotConf> timeSlotConf = frameConf->GetTimeSlotConf(result.second);
1469 Time slotStartTime = superframeStartTime + timeSlotConf->GetStartTime();
1470 Time offset = slotStartTime - Now();
1472 if (offset.IsStrictlyNegative())
1474 NS_FATAL_ERROR(
"SatUtMac::ScheduleSlottedAlohaTransmission - Invalid transmit time: "
1475 << offset.GetSeconds());
1479 Ptr<SatWaveform> wf =
1480 m_superframeSeq->GetWaveformConf()->GetWaveform(timeSlotConf->GetWaveFormId());
1481 Time duration = wf->GetBurstDuration(frameConf->GetBtuConf()->GetSymbolRateInBauds());
1484 uint32_t carrierId =
1485 m_superframeSeq->GetCarrierId(0, frameId, timeSlotConf->GetCarrierId());
1487 NS_LOG_INFO(
"Starting to schedule, SF ID: "
1488 << superFrameId <<
" slot: " << result.second
1489 <<
" SF start: " << superframeStartTime.GetSeconds()
1490 <<
" Tx start: " << (Now() + offset).GetSeconds()
1491 <<
" duration: " << duration.GetSeconds() <<
" carrier ID: " << carrierId
1492 <<
" payload in bytes: " << wf->GetPayloadInBytes());
1496 if (offset >= Seconds(0))
1498 Simulator::Schedule(offset,
1510 NS_LOG_INFO(
"UT has known DAMA, aborting Slotted ALOHA");
1514 std::pair<bool, uint32_t>
1516 Ptr<SatFrameConf> frameConf,
1517 uint32_t timeSlotCount,
1518 uint32_t superFrameId,
1519 uint32_t allocationChannel)
1521 NS_LOG_FUNCTION(
this << superframeStartTime << timeSlotCount << superFrameId
1522 << allocationChannel);
1524 Time opportunityOffset = Now() - superframeStartTime;
1526 NS_LOG_INFO(
"UT: " <<
m_nodeInfo->GetMacAddress()
1527 <<
" offset: " << opportunityOffset.GetSeconds());
1531 if (opportunityOffset.IsStrictlyNegative())
1533 opportunityOffset = Seconds(0);
1543 std::pair<bool, uint32_t>
1545 Ptr<SatFrameConf> frameConf,
1546 uint32_t timeSlotCount,
1547 uint32_t superFrameId,
1548 uint32_t allocationChannel)
1550 NS_LOG_FUNCTION(
this << opportunityOffset << timeSlotCount << superFrameId
1551 << allocationChannel);
1553 NS_LOG_INFO(
"UT: " <<
m_nodeInfo->GetMacAddress());
1555 Ptr<SatTimeSlotConf> slotConf;
1557 bool availableSlotFound =
false;
1560 for (slotId = 0; slotId < timeSlotCount; slotId++)
1562 slotConf = frameConf->GetTimeSlotConf(slotId);
1570 if (slotConf->GetStartTime() >= opportunityOffset)
1575 availableSlotFound =
true;
1581 NS_LOG_INFO(
"Success: " << availableSlotFound <<
" SF: " << superFrameId <<
" AC: "
1582 << allocationChannel <<
" slot: " << slotId <<
"/" << timeSlotCount);
1584 return std::make_pair(availableSlotFound, slotId);
1591 NS_LOG_FUNCTION(
this << allocationChannel);
1593 NS_LOG_INFO(
"SatUtMac::ScheduleEssaTransmission - UT: " <<
m_nodeInfo->GetMacAddress()
1594 <<
" time: " << Now().GetSeconds()
1595 <<
" AC: " << allocationChannel);
1600 if (offset.IsStrictlyNegative())
1603 offset = Seconds(0);
1607 Ptr<SatSuperframeConf> superframeConf =
1609 uint8_t frameId = superframeConf->GetRaChannelFrameId(allocationChannel);
1610 Ptr<SatFrameConf> frameConf = superframeConf->GetFrameConf(frameId);
1611 Ptr<SatTimeSlotConf> timeSlotConf = frameConf->GetTimeSlotConf(0);
1613 Ptr<SatWaveform> wf =
1614 m_superframeSeq->GetWaveformConf()->GetWaveform(timeSlotConf->GetWaveFormId());
1615 Time duration = wf->GetBurstDuration(frameConf->GetBtuConf()->GetSymbolRateInBauds());
1617 NS_LOG_INFO(
"SatUtMac::ScheduleEssaTransmission - Starting to schedule @ "
1618 << Now().GetSeconds() <<
" Tx start: " << (Now() + offset).GetSeconds()
1619 <<
" duration: " << duration.GetSeconds()
1620 <<
" payload in bytes: " << wf->GetPayloadInBytes());
1623 uint32_t carrierId = 0;
1627 if (offset >= Seconds(0))
1629 Simulator::Schedule(offset,
1644 NS_LOG_FUNCTION(
this << allocationChannel);
1647 Time now = Simulator::Now();
1650 NS_LOG_INFO(
"Checking for CRDSA transmission at "
1651 << now.GetMilliSeconds() - superFrameStart.GetMilliSeconds()
1652 <<
" milliseconds into superframe " << superFrameId);
1658 NS_LOG_INFO(
"UT: " <<
m_nodeInfo->GetMacAddress() <<
" AC: " << allocationChannel
1659 <<
", SF: " << superFrameId <<
", num of opportunities: "
1662 std::map<uint32_t, std::set<uint32_t>>::iterator iter;
1669 std::set<uint32_t>::iterator iterSet;
1672 for (iterSet = iter->second.begin(); iterSet != iter->second.end(); iterSet++)
1680 "SatUtMac::ScheduleCrdsaTransmission - Slot unavailable: " << *iterSet);
1693 NS_LOG_FUNCTION(
this << allocationChannel);
1695 NS_LOG_INFO(
"UT: " <<
m_nodeInfo->GetMacAddress() <<
" AC: " << allocationChannel);
1697 Ptr<SatSuperframeConf> superframeConf =
1699 uint8_t frameId = superframeConf->GetRaChannelFrameId(allocationChannel);
1700 Ptr<SatFrameConf> frameConf = superframeConf->GetFrameConf(frameId);
1704 Time superframeStartTime = Now();
1707 uint32_t payloadBytes = superframeConf->GetRaChannelTimeSlotPayloadInBytes(allocationChannel);
1710 payloadBytes -=
m_randomAccess->GetCrdsaSignalingOverheadInBytes();
1712 if (payloadBytes < 1)
1715 "SatUtMac::CreateCrdsaPacketInstances - Not enough capacity in CRDSA payload");
1739 NS_LOG_INFO(
"Processing the packet container, fragments: " << uniq.size());
1743 std::vector<std::pair<uint16_t, SatPhy::PacketContainer_t>> replicas;
1744 std::map<uint16_t, SatCrdsaReplicaTag> tags;
1745 std::set<uint32_t>::iterator iterSet;
1747 NS_LOG_INFO(
"Creating replicas for a packet");
1750 for (iterSet = slots.begin(); iterSet != slots.end(); iterSet++)
1753 SatPhy::PacketContainer_t::const_iterator it = uniq.begin();
1755 for (; it != uniq.end(); ++it)
1757 rep.push_back((*it)->Copy());
1760 << (*iterSet) <<
", original (HL packet) fragment UID: " << (*it)->GetUid()
1761 <<
", copied replica fragment (HL packet) UID: " << rep.back()->GetUid());
1764 NS_LOG_INFO(
"One replica created");
1766 replicas.push_back(std::make_pair(*iterSet, rep));
1769 NS_LOG_INFO(
"Creating replica tags");
1772 for (uint32_t i = 0; i < replicas.size(); i++)
1776 replicaTag.
AddSlotId(replicas[i].first);
1778 NS_LOG_INFO(
"Own packet tag: " << replicas[i].first);
1780 for (uint32_t j = 0; j < replicas.size(); j++)
1784 replicaTag.
AddSlotId(replicas[j].first);
1786 NS_LOG_INFO(
"Other packet tag: " << replicas[j].first);
1789 tags.insert(std::make_pair(replicas[i].first, replicaTag));
1792 NS_LOG_INFO(
"Scheduling replicas");
1795 for (uint32_t i = 0; i < replicas.size(); i++)
1797 for (uint32_t j = 0; j < replicas[i].second.size(); j++)
1799 NS_LOG_INFO(
"Replica: " << i <<
", fragment: " << j
1800 <<
", key: " << replicas[i].first <<
", tag: "
1801 << tags.at(replicas[i].first).GetSlotIds().at(0)
1802 <<
", fragment (HL packet) UID: "
1803 << replicas[i].second.at(j)->GetUid());
1806 replicas[i].second.at(j)->AddPacketTag(tags.at(replicas[i].first));
1810 Ptr<SatTimeSlotConf> timeSlotConf = frameConf->GetTimeSlotConf(replicas[i].first);
1813 Time slotDelay = superframeStartTime + timeSlotConf->GetStartTime();
1814 Time offset = slotDelay - Now();
1816 if (offset.IsStrictlyNegative())
1818 NS_FATAL_ERROR(
"SatUtMac::CreateCrdsaPacketInstances - Invalid transmit time: "
1819 << offset.GetSeconds());
1823 Ptr<SatWaveform> wf =
1824 m_superframeSeq->GetWaveformConf()->GetWaveform(timeSlotConf->GetWaveFormId());
1825 Time duration = wf->GetBurstDuration(frameConf->GetBtuConf()->GetSymbolRateInBauds());
1828 uint32_t carrierId =
1831 timeSlotConf->GetCarrierId());
1836 txInfo.
modCod = wf->GetModCod();
1845 if (offset >= Seconds(0))
1847 Simulator::Schedule(offset,
1855 NS_LOG_INFO(
"Scheduled a replica in slot " << replicas[i].first <<
" with offset "
1856 << offset.GetSeconds());
1867 uint32_t allocationChannelId,
1870 NS_LOG_FUNCTION(
this << superFrameId << allocationChannelId << slotId);
1872 NS_LOG_INFO(
"UT: " <<
m_nodeInfo->GetMacAddress() <<
" SF: " << superFrameId
1873 <<
" AC: " << allocationChannelId <<
" slot: " << slotId);
1875 std::map<std::pair<uint32_t, uint32_t>, std::set<uint32_t>>::iterator iter;
1876 bool isSlotFree =
false;
1881 std::pair<uint32_t, uint32_t> key = std::make_pair(superFrameId, allocationChannelId);
1887 std::set<uint32_t> txOpportunities{{slotId}};
1888 std::pair<std::map<std::pair<uint32_t, uint32_t>, std::set<uint32_t>>::iterator,
bool>
1895 NS_LOG_INFO(
"No saved SF, slot " << slotId <<
" saved in SF " << superFrameId);
1899 NS_LOG_WARN(
"No saved SF but unable to create one");
1904 std::pair<std::set<uint32_t>::iterator,
bool> result;
1905 result = iter->second.insert(slotId);
1910 NS_LOG_INFO(
"Saved SF exist, slot " << slotId <<
" saved in SF " << superFrameId);
1914 NS_LOG_WARN(
"Saved SF exist but unable to add slot " << slotId);
1923 NS_LOG_FUNCTION(
this << superFrameId);
1925 NS_LOG_INFO(
"UT: " <<
m_nodeInfo->GetMacAddress() <<
" SF: " << superFrameId);
1927 std::map<std::pair<uint32_t, uint32_t>, std::set<uint32_t>>::iterator iter;
1931 if (iter->first.first < superFrameId)
1945 NS_LOG_FUNCTION(
this);
1947 NS_LOG_INFO(
"UT: " <<
m_nodeInfo->GetMacAddress());
1948 std::cout <<
"UT: " <<
m_nodeInfo->GetMacAddress() << std::endl;
1952 for (
auto& slot : iter.second)
1954 std::cout <<
"SF: " << iter.first.first <<
" AC: " << iter.first.second
1955 <<
" slot: " << slot << std::endl;
1963 NS_LOG_FUNCTION(
this);
1965 NS_LOG_INFO(
"UT: " <<
m_nodeInfo->GetMacAddress());
1969 NS_LOG_INFO(
"Applying TIM-U parameters received during the previous frame");
1972 Address gwAddress =
m_timuInfo->GetGwAddress();
1973 Mac48Address gwAddress48 = Mac48Address::ConvertFrom(gwAddress);
1987 NS_LOG_INFO(
"Tx is permitted");
1996 NS_LOG_INFO(
"UT checking for beam handover recommendation");
2016 Mac48Address gwAddress48 = Mac48Address::ConvertFrom(gwAddress);
2055 NS_LOG_INFO(
"Tx is disabled");
2060 NS_ASSERT_MSG(Now() < nextSuperFrameTxTime,
2061 "Scheduling next superframe start time to the past!");
2063 Time schedulingDelay = nextSuperFrameTxTime - Now();
2065 if (realDelay == Seconds(0))
2080 uint32_t driftTicks = (t + Simulator::Now()).GetMicroSeconds() *
m_clockDrift / 1000000;
2081 int32_t deltaTicks =
m_deltaNcr - driftTicks;
2082 Time deltaTime = NanoSeconds(deltaTicks * 1000 / 27.0);
2084 return t - deltaTime;
2089 m_gwAddress(address)
2091 NS_LOG_FUNCTION(
this << beamId << address);
2097 NS_LOG_FUNCTION(
this);
2104 NS_LOG_FUNCTION(
this);
2111 NS_LOG_FUNCTION(
this);
2117 uint32_t payloadBytes,
2121 bool randomAccessChannel)
2123 NS_LOG_INFO(
this << payloadBytes << type << rcIndex << policy << randomAccessChannel);
2130 NS_LOG_INFO(
"Regular scheduling");
2131 m_utScheduler->DoScheduling(packets, payloadBytes, type, rcIndex, policy);
2135 NS_LOG_INFO(
"Handover recommendation sent, force control packets only");
2143 SatPhy::PacketContainer_t::iterator it = packets.begin();
2144 while (it != packets.end())
2147 bool success = (*it)->PeekPacketTag(ctrlTag);
2155 it = packets.erase(it);
This class implements a tag that carries the satellite MAC of GW and UT.
void SetE2ESourceAddress(Mac48Address e2eSourceAddress)
Set E2E source MAC address.
Mac48Address GetE2ESourceAddress(void) const
Get E2E source MAC address.
void SetE2EDestAddress(Mac48Address e2eDestAddress)
Set E2E destination 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_ARQ_ACK
SAT_ARQ_ACK.
@ SAT_LOGON_RESPONSE_CTRL_MSG
SAT_LOGON_RESPONSE_CTRL_MSG.
@ SAT_SLICE_CTRL_MSG
SAT_SLICE_CTRL_MSG.
@ SAT_TIMU_CTRL_MSG
SAT_TIMU_CTRL_MSG.
@ SAT_HR_CTRL_MSG
SAT_HR_CTRL_MSG.
@ SAT_LOGOFF_CTRL_MSG
SAT_LOGOFF CTRL_MSG.
@ SAT_NON_CTRL_MSG
SAT_NON_CTRL_MSG.
@ SAT_CMT_CTRL_MSG
SAT_CMT_CTRL_MSG.
@ SAT_TBTP_CTRL_MSG
SAT_TBTP_CTRL_MSG.
@ SAT_NCR_CTRL_MSG
SAT_NCR_CTRL_MSG.
@ SAT_RA_CTRL_MSG
SAT_RA_CTRL_MSG.
virtual uint32_t GetMsgId() const
Get message type specific identifier.
SatControlMsgType_t GetMsgType(void) const
Get type of the control message.
This class implements a tag that carries information about the slot IDs of CRDSA packet replicas.
void AddSlotId(uint16_t slotId)
SatEncapPduStatusTag is used temporarily to tag packets with the fragmentation status in the encapsul...
void SetStatus(uint8_t status)
Set PDU status.
@ RA_TX_OPPORTUNITY_SLOTTED_ALOHA
@ RA_TX_OPPORTUNITY_CRDSA
@ PACKET_TYPE_DEDICATED_ACCESS
@ PACKET_TYPE_SLOTTED_ALOHA
RegenerationMode_t
The regeneration mode used in satellites.
RandomAccessTriggerType_t
The defined random access trigger types.
@ RA_TRIGGER_TYPE_SLOTTED_ALOHA
@ LOG_WARNING
LOG_WARNING.
Base MAC class for SatNetDevices.
void RxTraces(SatPhy::PacketContainer_t packets)
Invoke the Rx trace source for each received packet.
SatMac::RoutingUpdateCallback m_routingUpdateCallback
Callback to update routing and ARP tables after a beam handover.
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.
virtual void SetNodeInfo(Ptr< SatNodeInfo > nodeInfo)
Set the node info.
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_isRegenerative
Indicate if satellite is regeneration (at least LINK level) for TX.
SatMac::ReadCtrlMsgCallback m_readCtrlCallback
The read control message callback.
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.
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.
SatSignalParameters::PacketsInBurst_t PacketContainer_t
Define PacketContainer in SatPhy.
@ CONFIG_TYPE_4
Configuration type 4 (ESSA)
bool HasScheduledTimeSlots()
Method of checking whether the UT has been scheduled time slots into the future.
std::pair< uint8_t, DaTimeSlotConfContainer_t > DaTimeSlotInfoItem_t
Item for DA time slot information.
SatTimeSlotType_t
Types for time slot.
@ SLOT_TYPE_TRC
Control or traffic slot.
@ SLOT_TYPE_C
Control slot.
SatTimuInfo(uint32_t beamId, Address address)
Address GetGwAddress() const
uint32_t GetBeamId() const
void SetRandomAccess(Ptr< SatRandomAccess > randomAccess)
Set the random access module.
void SetBeamScheculerCallback(SatUtMac::BeamScheculerCallback cb)
Set the beam scheduler callback.
void SetAskedBeamCallback(SatUtMac::AskedBeamCallback cb)
Method to get the best beam when performing handover.
Callback< void, uint32_t > HandoverCallback
Callback to reconfigure physical layer during handover.
Ptr< SatSuperframeSeq > m_superframeSeq
Used superframe sequence for the return link.
Callback< bool > TxCheckCallback
Callback to check if TX is operational.
virtual void ReceiveQueueEventEssa(SatQueue::QueueEvent_t event, uint8_t rcIndex)
Receive a queue event:
Ptr< SatTbtpContainer > m_tbtpContainer
Container for storing all the TBTP information related to this UT.
virtual void Receive(SatPhy::PacketContainer_t packets, Ptr< SatSignalParameters >)
Receive packet from lower layer.
Time m_guardTime
Guard time for time slots.
void DoEssaTransmit(Time duration, Ptr< SatWaveform > waveform, uint32_t carrierId, uint8_t rcIndex, SatUtScheduler::SatCompliancePolicy_t policy=SatUtScheduler::LOOSE)
Notify the upper layer about the ESSA Tx opportunity.
static TypeId GetTypeId(void)
Derived from Object.
int64_t m_deltaNcr
Correction to apply to NCR dates.
void PrintUsedRandomAccessSlots()
uint32_t m_beamId
ID of beam for UT.
uint32_t m_handoverMessagesCount
Time m_maxWaitingTimeLogonResponse
Timeout for waiting for a response for a logon message.
std::pair< bool, uint32_t > SearchFrameForAvailableSlot(Time superframeStartTime, Ptr< SatFrameConf > frameConf, uint32_t timeSlotCount, uint32_t superFrameId, uint32_t allocationChannel)
void SetAssignedDaResourcesCallback(SatUtMac::AssignedDaResourcesCallback cb)
Set the assigned DA resources callback.
SatUtMac::HandoverCallback m_handoverCallback
The physical layer handover callback.
SatUtMacState::RcstState_t GetRcstState() const
uint64_t m_ncr
NCR value of last NCR control message.
void SendLogon(Ptr< Packet > packet)
Receive a logon message to transmit /param packet The logon packet to send.
virtual void SetSatelliteAddress(Address satelliteAddress)
Set the satellite MAC address on the other side of this link (if regenerative satellite).
void ScheduleTimeSlots(Ptr< SatTbtpMessage > tbtp)
Schedules time slots according to received TBTP message.
void SetHandoverCallback(SatUtMac::HandoverCallback cb)
Method to set handover callback.
virtual void ReceiveQueueEvent(SatQueue::QueueEvent_t event, uint8_t rcIndex)
Receive a queue event:
Callback< void, Mac48Address > UpdateGwAddressCallback
Callback to update GW address to SatRequestManager.
Callback< void > SendLogonCallback
Callback to send a logon message to the gateway.
@ HANDOVER_RECOMMENDATION_SENT
SatUtMac::SliceSubscriptionCallback m_sliceSubscriptionCallback
Tx checking callback.
Time GetRealSendingTime(Time t)
Compute real sending time of UT based on last NCR reception date and clock drift.
void ScheduleEssaTransmission(uint32_t allocationChannel)
Function for scheduling the ESSA transmissions.
virtual TypeId GetInstanceTypeId(void) const
Derived from Object.
void SetTxCheckCallback(SatUtMac::TxCheckCallback cb)
Set the TX check callback.
Ptr< SatTimuInfo > m_timuInfo
void RemovePastRandomAccessSlots(uint32_t superFrameId)
Function for removing the past used RA slots.
void ScheduleCrdsaTransmission(uint32_t allocationChannel, SatRandomAccess::RandomAccessTxOpportunities_s txOpportunities)
Function for scheduling the CRDSA transmissions.
Callback< Time > TimingAdvanceCallback
uint32_t m_maxHandoverMessagesSent
void SetUpdateGwAddressCallback(SatUtMac::UpdateGwAddressCallback cb)
Set the gw update callback.
SatUtMac::UpdateGwAddressCallback m_updateGwAddressCallback
Callback for sending a logon message.
uint32_t m_firstTransmittableSuperframeId
std::map< std::pair< uint32_t, uint32_t >, std::set< uint32_t > > m_usedRandomAccessSlots
A container for storing the used RA slots in each frame and allocation channel.
void SetSliceSubscriptionCallback(SatUtMac::SliceSubscriptionCallback cb)
Get sliec subscription info from MAC layer.
void DoSlottedAlohaTransmit(Time duration, Ptr< SatWaveform > waveform, uint32_t carrierId, uint8_t rcIndex, SatUtScheduler::SatCompliancePolicy_t policy=SatUtScheduler::LOOSE)
Notify the upper layer about the Slotted ALOHA Tx opportunity.
uint32_t m_crdsaUniquePacketId
CRDSA packet ID (per frame)
Time m_lastNcrDateReceived
Reception date of last NCR control message.
void SetSendLogonCallback(SatUtMac::SendLogonCallback cb)
Set the logon callback.
~SatUtMac()
Destroy a SatUtMac.
Time m_windowInitLogon
The initial max time to wait when sending a logon message.
Time GetNextSuperFrameTxTime(uint8_t superFrameSeqId) const
Get Tx time for the next possible superframe.
SatUtMac::GatewayUpdateCallback m_gatewayUpdateCallback
Gateway address update callback.
void ScheduleSlottedAlohaTransmission(uint32_t allocationChannel)
Function for scheduling the Slotted ALOHA transmissions.
SatUtMac::BeamScheculerCallback m_beamScheculerCallback
Callback to get the SatBeamScheduler linked to a beam ID.
HandoverState_t m_handoverState
uint32_t GetCurrentSuperFrameId(uint8_t superFrameSeqId) const
void SetRaChannel(uint32_t raChannel)
Set RA channel assigned for this UT.
Mac48Address GetGwAddress()
Get address of the GW (or its MAC) serving this UT.
std::queue< Time > m_receptionDates
Store last 3 packets reception date, to be associated to NCR dates.
void ExtractPacketsToSchedule(SatPhy::PacketContainer_t &packets, uint32_t payloadBytes, SatTimeSlotConf::SatTimeSlotType_t type, uint8_t rcIndex, SatUtScheduler::SatCompliancePolicy_t policy, bool randomAccessChannel)
Extract packets from the underlying queue and put them in the provided container.
SatUtMacState m_rcstState
Time m_nextPacketTime
Next time when a next ESSA packet can be safely sent.
uint32_t m_logonChannel
RA channel dedicated to logon messages.
void ReceiveSignalingPacket(Ptr< Packet > packet)
Signaling packet receiver, which handles all the signaling packet receptions.
Callback< uint32_t > AskedBeamCallback
Callback to ask for the best beam ID during handover.
void SetTimingAdvanceCallback(SatUtMac::TimingAdvanceCallback cb)
Set the timing advance callback.
SatPhy::PacketContainer_t FetchPackets(uint32_t payloadBytes, SatTimeSlotConf::SatTimeSlotType_t type, uint8_t rcIndex, SatUtScheduler::SatCompliancePolicy_t policy)
Callback< void, uint8_t, uint32_t > AssignedDaResourcesCallback
Callback for informing the amount of dedicated access bytes received from TBTP.
TracedCallback< uint32_t > m_tbtpResourcesTrace
Assigned TBTP resources in superframe for this UT (in bytes).
std::pair< bool, uint32_t > FindNextAvailableRandomAccessSlot(Time opportunityOffset, Ptr< SatFrameConf > frameConf, uint32_t timeSlotCount, uint32_t superFrameId, uint32_t allocationChannel)
bool m_crdsaOnlyForControl
Planned CRDSA usage:
void DoDispose(void)
Dispose of SatUtMac.
uint32_t GetNextRandomAccessAllocationChannel()
Function for selecting the allocation channel for the current RA evaluation.
void SetLogonChannel(uint32_t channelId)
void ScheduleDaTxOpportunity(Time transmitDelay, Time duration, Ptr< SatWaveform > wf, Ptr< SatTimeSlotConf > tsConf, uint32_t carrierId)
Schdules one Tx opportunity, i.e.
SatUtMac()
Default constructor, which is not used.
SatUtMac::BeamCheckerCallback m_beamCheckerCallback
Beam checker and handover recommendation sending callback.
Callback< bool, uint32_t, uint32_t > BeamCheckerCallback
Callback to check whether the current beam is still the best one to use for sending data; and sending...
Ptr< SatUtScheduler > m_utScheduler
UT scheduler.
bool UpdateUsedRandomAccessSlots(uint32_t superFrameId, uint32_t allocationChannel, uint32_t slot)
Function for updating the used RA slots.
void TransmitPackets(SatPhy::PacketContainer_t packets, Time duration, uint32_t carrierId, SatSignalParameters::txInfo_s txInfo)
void CreateCrdsaPacketInstances(uint32_t allocationChannel, std::set< uint32_t > slots)
void SetBeamCheckerCallback(SatUtMac::BeamCheckerCallback cb)
Method to set the beam checker callback.
Ptr< SatRandomAccess > m_randomAccess
RA main module.
bool m_isRandomAccessScheduled
Flag that indicates if a method DoRandomAccess is scheduled for asynchronous access.
Callback< Ptr< SatBeamScheduler >, uint32_t, uint32_t > BeamScheculerCallback
Callback to get the SatBeamScheduler from the beam ID for handover.
TimingAdvanceCallback m_timingAdvanceCb
Callback for getting the timing advance information.
uint32_t m_satId
ID of sat for UT.
SatUtMac::AskedBeamCallback m_askedBeamCallback
Beam checker and handover recommendation sending callback.
bool ControlMsgTransmissionPossible() const
Method to check whether a transmission of a control msg is somewhat possible.
int32_t m_clockDrift
Clock drift (number of ticks per second)
void DoTransmit(Time duration, uint32_t carrierId, Ptr< SatWaveform > wf, Ptr< SatTimeSlotConf > tsConf, SatUtScheduler::SatCompliancePolicy_t policy=SatUtScheduler::LOOSE)
Notify the upper layer about the Tx opportunity.
void DoFrameStart()
Function which is executed at every frame start.
Callback< void, Mac48Address > GatewayUpdateCallback
Callback to update gateway address after handover.
Time m_nextLogonTransmissionPossible
Instant when a logon message can be transmitted.
Ptr< UniformRandomVariable > m_waitingTimeLogonRng
The random generator for waiting transmission time.
void SetGwAddress(Mac48Address gwAddress)
Set address of the GW (or its MAC) serving this UT.
bool LogonMsgTransmissionPossible() const
Method to check whether a transmission of a logon msg is somewhat possible.
Time GetCurrentSuperFrameStartTime(uint8_t superFrameSeqId) const
Get start time for the current superframe.
void SetGatewayUpdateCallback(SatUtMac::GatewayUpdateCallback cb)
Method to set the gateway address update callback.
bool m_useLogon
Should logon be simulated?
virtual void SetNodeInfo(Ptr< SatNodeInfo > nodeInfo)
Set the node info.
uint32_t m_sendLogonTries
Number of times a logon message has been sent without response.
uint32_t m_raChannel
RA channel assigned to the UT.
uint32_t GetRaChannel() const
Get RA channel assigned for this UT.
void DoRandomAccess(SatEnums::RandomAccessTriggerType_t randomAccessTriggerType)
Do random access evaluation for Tx opportunities.
Callback< void, uint8_t > SliceSubscriptionCallback
Callback to check if TX is operational.
Ptr< UniformRandomVariable > m_uniformRandomVariable
Uniform random variable distribution generator.
AssignedDaResourcesCallback m_assignedDaResourcesCallback
Callback for informing the assigned TBTP resources.
SatUtMac::SendLogonCallback m_sendLogonCallback
Callback for sending a logon message.
bool m_loggedOn
UT is logged on.
SatUtMac::TxCheckCallback m_txCheckCallback
Tx checking callback.
Class handling UT Mac states and transitions.
void SwitchToReadyForTdmaSync()
Change state to READY_FOR_TDMA_SYNC.
void SetLogOffCallback(LogOffCallback cb)
Set logOff callback.
void SwitchToOffStandby()
Change state to OFF_STANDBY.
void NcrControlMessageReceived()
Inform the state diagram that a NCR message has been received.
void SwitchToReadyForLogon()
Change state to READY_FOR_LOGON.
RcstState_t GetState() const
Get the current state.
void SwitchToTdmaSync()
Change state to TDMA_SYNC.
void SwitchToHoldStandby()
Change state to HOLD_STANDBY.
bool IsNcrTimeout() const
Check if NCR m_ncrSyncTimeout has been reached.
SatCompliancePolicy_t
Enum describing the wanted scheduler policy.
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.
Random access Tx opportunities.
uint32_t slottedAlohaTxOpportunity
SatEnums::RandomAccessTxOpportunityType_t txOpportunityType
std::map< uint32_t, std::set< uint32_t > > crdsaTxOpportunities
Struct for storing the packet specific Tx information.
SatEnums::PacketType_t packetType
uint32_t crdsaUniquePacketId
SatEnums::SatBbFrameType_t frameType
uint32_t fecBlockSizeInBytes
SatEnums::SatModcod_t modCod