41 #include <ns3/boolean.h>
43 #include <ns3/mac48-address.h>
44 #include <ns3/packet.h>
45 #include <ns3/pointer.h>
46 #include <ns3/random-variable-stream.h>
47 #include <ns3/simulator.h>
48 #include <ns3/singleton.h>
57 NS_LOG_COMPONENT_DEFINE(
"SatUtMac");
62 NS_OBJECT_ENSURE_REGISTERED(SatUtMac);
68 TypeId(
"ns3::SatUtMac")
70 .AddConstructor<SatUtMac>()
71 .AddAttribute(
"MaxHandoverMessages",
72 "Max amount of handover messages to send without a handover response "
76 MakeUintegerChecker<uint32_t>())
77 .AddAttribute(
"SuperframeSequence",
78 "Superframe sequence containing information of superframes.",
81 MakePointerChecker<SatSuperframeSeq>())
82 .AddAttribute(
"GuardTime",
83 "Guard time in return link",
84 TimeValue(MicroSeconds(1)),
87 .AddAttribute(
"Scheduler",
88 "UT scheduler used by this Sat UT MAC.",
91 MakePointerChecker<SatUtScheduler>())
92 .AddAttribute(
"WindowInitLogon",
93 "The initial window for logon waiting time before transmission.",
94 TimeValue(Seconds(20)),
97 .AddAttribute(
"MaxWaitingTimeLogonResponse",
98 "Timeout for waiting for a response for a logon message.",
99 TimeValue(Seconds(1)),
102 .AddAttribute(
"ClockDrift",
103 "Clock drift (number of ticks per second).",
106 MakeIntegerChecker<int32_t>())
107 .AddTraceSource(
"DaResourcesTrace",
108 "Assigned dedicated access resources in return link to this UT.",
110 "ns3::SatUtMac::TbtpResourcesTraceCallback");
117 NS_LOG_FUNCTION(
this);
128 m_randomAccess(nullptr),
129 m_guardTime(MicroSeconds(1)),
135 m_windowInitLogon(Seconds(20)),
136 m_maxWaitingTimeLogonResponse(Seconds(1)),
137 m_waitingTimeLogonRng(CreateObject<UniformRandomVariable>()),
138 m_nextLogonTransmissionPossible(Seconds(0)),
139 m_crdsaUniquePacketId(1),
140 m_crdsaOnlyForControl(false),
141 m_nextPacketTime(Now()),
142 m_isRandomAccessScheduled(false),
145 m_lastNcrDateReceived(Seconds(0)),
149 m_handoverState(NO_HANDOVER),
150 m_handoverMessagesCount(0),
151 m_maxHandoverMessagesSent(20),
152 m_firstTransmittableSuperframeId(0),
153 m_handoverCallback(),
154 m_gatewayUpdateCallback(),
156 m_sliceSubscriptionCallback(),
157 m_sendLogonCallback(),
158 m_updateGwAddressCallback()
160 NS_LOG_FUNCTION(
this);
163 NS_FATAL_ERROR(
"SatUtMac::SatUtMac - Constructor not in use");
169 Ptr<SatSuperframeSeq> seq,
170 bool crdsaOnlyForControl)
175 m_superframeSeq(seq),
177 m_guardTime(MicroSeconds(1)),
183 m_windowInitLogon(Seconds(20)),
184 m_maxWaitingTimeLogonResponse(Seconds(1)),
185 m_waitingTimeLogonRng(CreateObject<UniformRandomVariable>()),
186 m_nextLogonTransmissionPossible(Seconds(0)),
187 m_crdsaUniquePacketId(1),
188 m_crdsaOnlyForControl(crdsaOnlyForControl),
189 m_nextPacketTime(Now()),
190 m_isRandomAccessScheduled(false),
193 m_lastNcrDateReceived(Seconds(0)),
197 m_handoverState(NO_HANDOVER),
198 m_handoverMessagesCount(0),
199 m_maxHandoverMessagesSent(20),
200 m_firstTransmittableSuperframeId(0),
201 m_handoverCallback(),
202 m_gatewayUpdateCallback(),
204 m_sliceSubscriptionCallback(),
205 m_sendLogonCallback(),
206 m_updateGwAddressCallback()
208 NS_LOG_FUNCTION(
this);
216 NS_LOG_FUNCTION(
this);
226 NS_LOG_FUNCTION(
this);
245 NS_LOG_FUNCTION(
this << &cb);
252 NS_LOG_FUNCTION(
this << &cb);
259 NS_LOG_FUNCTION(
this << &cb);
266 NS_LOG_FUNCTION(
this << &cb);
274 NS_LOG_FUNCTION(
this << &cb);
282 NS_LOG_FUNCTION(
this << &cb);
290 NS_LOG_FUNCTION(
this << &cb);
305 NS_LOG_FUNCTION(
this);
313 NS_LOG_FUNCTION(
this << gwAddress);
322 NS_LOG_FUNCTION(
this << nodeInfo);
332 NS_LOG_FUNCTION(
this);
341 NS_LOG_FUNCTION(
this);
349 NS_LOG_FUNCTION(
this << raChannel);
357 NS_LOG_FUNCTION(
this);
365 NS_LOG_FUNCTION(
this);
375 NS_LOG_FUNCTION(
this);
389 NS_LOG_FUNCTION(
this);
391 bool stateCorrect = (
m_rcstState.
GetState() == SatUtMacState::RcstState_t::READY_FOR_LOGON);
394 return m_useLogon && stateCorrect && ncrReceived;
400 NS_LOG_FUNCTION(
this << &cb);
407 if (Now() >= nextSuperFrameTxTime)
409 NS_FATAL_ERROR(
"Scheduling next superframe start time to the past!");
412 Time schedulingDelay = nextSuperFrameTxTime - Now();
420 NS_LOG_FUNCTION(
this << &cb);
428 NS_LOG_FUNCTION(
this << (uint32_t)superFrameSeqId);
432 Singleton<SatRtnLinkTime>::Get()->GetNextSuperFrameTxTime(superFrameSeqId, timingAdvance);
439 NS_LOG_FUNCTION(
this << (uint32_t)superFrameSeqId);
442 Time txTime = Singleton<SatRtnLinkTime>::Get()->GetCurrentSuperFrameTxTime(superFrameSeqId,
450 NS_LOG_FUNCTION(
this << (uint32_t)superFrameSeqId);
452 return Singleton<SatRtnLinkTime>::Get()->GetCurrentSuperFrameCount(superFrameSeqId,
459 NS_LOG_FUNCTION(
this << tbtp);
460 NS_LOG_INFO(
"UT: " <<
m_nodeInfo->GetMacAddress() <<
" received TBTP "
461 << tbtp->GetSuperframeCounter());
480 Singleton<SatRtnLinkTime>::Get()->GetSuperFrameTxTime(tbtp->GetSuperframeSeqId(),
481 tbtp->GetSuperframeCounter(),
485 Time startDelay = txTime - Simulator::Now();
491 if (txTime < Simulator::Now())
493 NS_FATAL_ERROR(
"UT: " <<
m_nodeInfo->GetMacAddress() <<
" received TBTP "
494 << tbtp->GetSuperframeCounter()
495 <<
", which should have been sent already in the past");
498 NS_LOG_INFO(
"Time to start sending the superframe for this UT: " << txTime.GetSeconds());
499 NS_LOG_INFO(
"Waiting delay before the superframe start: " << startDelay.GetSeconds());
504 uint32_t payloadSumInSuperFrame = 0;
507 if (!info.second.empty())
509 NS_LOG_INFO(
"TBTP contains " << info.second.size()
510 <<
" timeslots for UT: " <<
m_nodeInfo->GetMacAddress());
512 uint8_t frameId = info.first;
515 for (SatTbtpMessage::DaTimeSlotConfContainer_t::iterator it = info.second.begin();
516 it != info.second.end();
519 Ptr<SatSuperframeConf> superframeConf =
521 Ptr<SatFrameConf> frameConf = superframeConf->GetFrameConf(frameId);
522 Ptr<SatTimeSlotConf> timeSlotConf = *it;
525 Time slotDelay = startDelay + timeSlotConf->GetStartTime();
526 NS_LOG_INFO(
"Slot start delay: " << slotDelay.GetSeconds());
529 Ptr<SatWaveform> wf =
530 m_superframeSeq->GetWaveformConf()->GetWaveform(timeSlotConf->GetWaveFormId());
531 Time duration = wf->GetBurstDuration(frameConf->GetBtuConf()->GetSymbolRateInBauds());
537 duration = wf->GetBurstDuration(frameConf->GetBtuConf()->GetSymbolRateInBauds());
547 m_superframeSeq->GetCarrierId(0, frameId, timeSlotConf->GetCarrierId());
554 payloadSumInSuperFrame += wf->GetPayloadInBytes();
555 payloadSumPerRcIndex[timeSlotConf->GetRcIndex()] += wf->GetPayloadInBytes();
574 Ptr<SatTimeSlotConf> tsConf,
577 NS_LOG_FUNCTION(
this << transmitDelay.GetSeconds() << duration.GetSeconds()
578 << wf->GetPayloadInBytes() << (uint32_t)(tsConf->GetRcIndex())
580 NS_LOG_INFO(
"After delay: " << transmitDelay.GetSeconds() <<
" duration: "
581 << duration.GetSeconds() <<
", payload: " << wf->GetPayloadInBytes()
582 <<
", rcIndex: " << (uint32_t)(tsConf->GetRcIndex())
583 <<
", carrier: " << carrierId);
587 if (transmitDelay >= Seconds(0))
589 Simulator::Schedule(transmitDelay,
604 Ptr<SatTimeSlotConf> tsConf,
607 NS_LOG_FUNCTION(
this << duration.GetSeconds() << wf->GetPayloadInBytes() << carrierId
608 << (uint32_t)(tsConf->GetRcIndex()));
612 NS_LOG_INFO(
"Tx is unavailable");
624 FetchPackets(wf->GetPayloadInBytes(), tsConf->GetSlotType(), tsConf->GetRcIndex(), policy);
628 if (packets.size() == 0)
630 Ptr<Packet> p = Create<Packet>(wf->GetPayloadInBytes());
635 p->AddPacketTag(tag);
649 p->AddPacketTag(mTag);
655 p->AddPacketTag(addressE2ETag);
657 packets.push_back(p);
661 NS_LOG_INFO(
"DA Tx opportunity for UT: "
662 <<
m_nodeInfo->GetMacAddress() <<
" duration: " << duration.GetSeconds()
663 <<
", payload: " << wf->GetPayloadInBytes() <<
", carrier: " << carrierId
664 <<
", RC index: " << (uint32_t)(tsConf->GetRcIndex()));
668 txInfo.
modCod = wf->GetModCod();
675 NS_FATAL_ERROR(
"WF02 should only be used for control bursts");
683 Ptr<SatWaveform> waveform,
688 NS_LOG_FUNCTION(
this << duration.GetSeconds() << waveform->GetPayloadInBytes() << carrierId
689 << (uint32_t)(rcIndex));
690 NS_LOG_INFO(
"Tx opportunity for UT: "
691 <<
m_nodeInfo->GetMacAddress() <<
" duration: " << duration.GetSeconds()
692 <<
", payload: " << waveform->GetPayloadInBytes() <<
", carrier: " << carrierId
693 <<
", RC index: " << (uint32_t)(rcIndex));
698 uint32_t payloadBytes = waveform->GetPayloadInBytes();
701 payloadBytes -=
m_randomAccess->GetSlottedAlohaSignalingOverheadInBytes();
703 if (payloadBytes < 1)
706 "SatUtMac::DoSlottedAlohaTransmit - Not enough capacity in Slotted ALOHA payload");
716 if (!packets.empty())
718 NS_LOG_INFO(
"Number of packets sent in a slotted ALOHA slot: " << packets.size());
720 for (SatPhy::PacketContainer_t::const_iterator it = packets.begin(); it != packets.end();
736 txInfo.
modCod = waveform->GetModCod();
739 txInfo.
waveformId = waveform->GetWaveformId();
747 Ptr<SatWaveform> waveform,
752 NS_LOG_FUNCTION(
this << duration.GetSeconds() << waveform->GetPayloadInBytes() << carrierId
753 << (uint32_t)(rcIndex));
754 NS_LOG_INFO(
"SatUtMac::DoEssaTransmit - Tx opportunity for UT: "
755 <<
m_nodeInfo->GetMacAddress() <<
" at time: " << Simulator::Now().GetSeconds()
756 <<
" duration: " << duration.GetSeconds()
757 <<
", payload: " << waveform->GetPayloadInBytes() <<
", carrier: " << carrierId
758 <<
", RC index: " << (uint32_t)(rcIndex));
761 uint32_t payloadBytes = waveform->GetPayloadInBytes();
771 if (!packets.empty())
773 NS_LOG_INFO(
"Number of packets sent in a ESSA frame: " << packets.size());
775 for (SatPhy::PacketContainer_t::const_iterator it = packets.begin(); it != packets.end();
792 txInfo.
modCod = waveform->GetModCod();
795 txInfo.
waveformId = waveform->GetWaveformId();
807 if (duration >= Seconds(0))
809 Simulator::Schedule(duration,
828 NS_LOG_FUNCTION(
this << payloadBytes << (uint32_t)(rcIndex));
837 if (payloadBytes <= 0)
839 NS_FATAL_ERROR(
"SatUtMac::FetchPackets - unvalid slot payload: " << payloadBytes);
845 if (!packets.empty())
847 NS_LOG_INFO(
"Number of packets: " << packets.size());
849 for (SatPhy::PacketContainer_t::const_iterator it = packets.begin(); it != packets.end();
864 NS_LOG_INFO(
"The Frame PDU holds " << packets.size() <<
" RLE PDUs");
875 NS_LOG_FUNCTION(
this << packets.size() << duration.GetSeconds() << carrierId);
888 if (!packets.empty())
890 NS_LOG_INFO(
"UT: " <<
m_nodeInfo->GetMacAddress() <<
", transmitting " << packets.size()
891 <<
" packets, duration: " << duration.GetSeconds()
892 <<
", carrier: " << carrierId);
895 Time durationWithoutGuardPeriod(duration -
m_guardTime);
896 NS_LOG_INFO(
"Duration: " << duration.GetSeconds() <<
" duration with guard period: "
897 << durationWithoutGuardPeriod.GetSeconds());
898 NS_LOG_INFO(
"UT: " <<
m_nodeInfo->GetMacAddress() <<
" send packet");
900 SendPacket(packets, carrierId, durationWithoutGuardPeriod, txInfo);
907 NS_LOG_FUNCTION(
this << event << (uint32_t)rcIndex);
909 NS_LOG_INFO(
"UT: " <<
m_nodeInfo->GetMacAddress() <<
" Queue: " << (uint32_t)rcIndex);
916 NS_LOG_INFO(
"Buffered packet event received");
920 NS_LOG_INFO(
"Doing Slotted ALOHA");
931 NS_LOG_FUNCTION(
this << event << (uint32_t)rcIndex);
933 NS_LOG_INFO(
"SatUtMac::ReceiveQueueEventEssa - UT: " <<
m_nodeInfo->GetMacAddress()
934 <<
" time: " << Now().GetSeconds()
935 <<
" Queue: " << (uint32_t)rcIndex);
943 NS_LOG_INFO(
"SatUtMac::ReceiveQueueEventEssa - Buffered packet event received");
947 NS_LOG_INFO(
"SatUtMac::ReceiveQueueEventEssa - Doing ESSA");
959 packets.push_back(packet);
961 Ptr<SatSuperframeConf> superframeConf =
963 uint8_t frameId = superframeConf->GetRaChannelFrameId(
m_logonChannel);
964 Ptr<SatFrameConf> frameConf = superframeConf->GetFrameConf(frameId);
966 Ptr<SatTimeSlotConf> timeSlotConf = frameConf->GetTimeSlotConf(0);
968 Ptr<SatWaveform> wf =
969 m_superframeSeq->GetWaveformConf()->GetWaveform(timeSlotConf->GetWaveFormId());
970 Time duration = wf->GetBurstDuration(frameConf->GetBtuConf()->GetSymbolRateInBauds());
974 timeSlotConf->GetCarrierId());
978 txInfo.
modCod = wf->GetModCod();
989 if (waitingTime >= Seconds(0))
991 Simulator::Schedule(waitingTime,
1007 NS_LOG_FUNCTION(
this << packets.size());
1028 for (SatPhy::PacketContainer_t::iterator i = packets.begin(); i != packets.end(); i++)
1032 bool mSuccess = (*i)->PeekPacketTag(macTag);
1035 NS_FATAL_ERROR(
"MAC tag was not found from the packet!");
1039 mSuccess = (*i)->PeekPacketTag(addressE2ETag);
1042 NS_FATAL_ERROR(
"SatAddressE2ETag was not found from the packet!");
1047 NS_LOG_INFO(
"Receiver " <<
m_nodeInfo->GetMacAddress());
1050 if (destAddress ==
m_nodeInfo->GetMacAddress() || destAddress.IsBroadcast() ||
1051 destAddress.IsGroup())
1055 bool cSuccess = (*i)->PeekPacketTag(ctrlTag);
1067 NS_FATAL_ERROR(
"A control message received with not valid msg type!");
1070 else if (destAddress.IsBroadcast())
1090 NS_LOG_FUNCTION(
this);
1094 packet->PeekPacketTag(macTag);
1097 packet->PeekPacketTag(addressE2ETag);
1101 bool cSuccess = packet->PeekPacketTag(ctrlTag);
1105 NS_FATAL_ERROR(
"SatControlMsgTag not found in the packet!");
1111 uint32_t tbtpId = ctrlTag.
GetMsgId();
1120 if (tbtp ==
nullptr)
1122 NS_FATAL_ERROR(
"TBTP not found, check SatBeamHelper::CtrlMsgStoreTimeInFwdLink "
1123 "attribute is long enough!");
1133 packet->RemovePacketTag(macTag);
1134 packet->RemovePacketTag(addressE2ETag);
1135 packet->RemovePacketTag(ctrlTag);
1145 uint32_t raCtrlId = ctrlTag.
GetMsgId();
1148 if (raMsg !=
nullptr)
1150 uint32_t allocationChannelId = raMsg->GetAllocationChannelId();
1151 uint16_t backoffProbability = raMsg->GetBackoffProbability();
1152 uint16_t backoffTime = raMsg->GetBackoffTime();
1154 NS_LOG_INFO(
"UT: " <<
m_nodeInfo->GetMacAddress()
1155 <<
" Updating RA backoff probability for AC: "
1156 << allocationChannelId <<
" to: " << backoffProbability);
1158 m_randomAccess->SetBackoffProbability(allocationChannelId, backoffProbability);
1159 m_randomAccess->SetBackoffTime(allocationChannelId, backoffTime);
1161 packet->RemovePacketTag(macTag);
1162 packet->RemovePacketTag(addressE2ETag);
1163 packet->RemovePacketTag(ctrlTag);
1172 std::stringstream msg;
1173 msg <<
"Control message " << ctrlTag.
GetMsgType()
1174 <<
" is not found from the FWD link control msg container!";
1175 msg <<
" at: " << Now().GetSeconds() <<
"s";
1181 uint32_t timuCtrlId = ctrlTag.
GetMsgId();
1182 Ptr<SatTimuMessage> timuMsg = DynamicCast<SatTimuMessage>(
m_readCtrlCallback(timuCtrlId));
1184 if (timuMsg !=
nullptr)
1186 uint32_t beamId = timuMsg->GetAllocatedBeamId();
1187 uint32_t satId = timuMsg->GetAllocatedSatId();
1188 NS_LOG_INFO(
"UT: " <<
m_nodeInfo->GetMacAddress() <<
" switching from beam " <<
m_beamId
1189 <<
" to beam " << beamId);
1192 NS_LOG_INFO(
"Storing TIM-U information internally for later");
1195 timuMsg->GetSatAddress(),
1196 timuMsg->GetGwAddress());
1206 std::stringstream msg;
1207 msg <<
"Control message " << ctrlTag.
GetMsgType()
1208 <<
" is not found from the FWD link control msg container!";
1209 msg <<
" at: " << Now().GetSeconds() <<
"s";
1215 uint32_t sliceCtrlId = ctrlTag.
GetMsgId();
1216 Ptr<SatSliceSubscriptionMessage> sliceMsg =
1219 if (sliceMsg !=
nullptr)
1221 if (
m_nodeInfo->GetMacAddress() == sliceMsg->GetAddress())
1233 std::stringstream msg;
1234 msg <<
"Control message " << ctrlTag.
GetMsgType()
1235 <<
" is not found from the FWD link control msg container!";
1236 msg <<
" at: " << Now().GetSeconds() <<
"s";
1242 uint32_t logonId = ctrlTag.
GetMsgId();
1243 Ptr<SatLogonResponseMessage> logonMsg =
1246 if (logonMsg !=
nullptr)
1262 std::stringstream msg;
1263 msg <<
"Control message " << ctrlTag.
GetMsgType()
1264 <<
" is not found from the FWD link control msg container!";
1265 msg <<
" at: " << Now().GetSeconds() <<
"s";
1271 uint32_t ncrCtrlId = ctrlTag.
GetMsgId();
1272 Ptr<SatNcrMessage> ncrMsg = DynamicCast<SatNcrMessage>(
m_readCtrlCallback(ncrCtrlId));
1275 m_ncr = ncrMsg->GetNcrDate();
1292 uint32_t cmtCtrlId = ctrlTag.
GetMsgId();
1293 Ptr<SatCmtMessage> cmtMsg = DynamicCast<SatCmtMessage>(
m_readCtrlCallback(cmtCtrlId));
1294 int16_t burstTimeCorrection = cmtMsg->GetBurstTimeCorrection();
1299 uint32_t logoffCtrlId = ctrlTag.
GetMsgId();
1300 Ptr<SatLogoffMessage> logoffMsg =
1306 NS_FATAL_ERROR(
"SatUtMac received a non-supported control packet!");
1315 NS_LOG_FUNCTION(
this << randomAccessTriggerType);
1317 NS_LOG_INFO(
"UT: " <<
m_nodeInfo->GetMacAddress());
1335 NS_LOG_INFO(
"Logon channel cannot be used for RA transmition");
1340 txOpportunities =
m_randomAccess->DoRandomAccess(allocationChannel, randomAccessTriggerType);
1348 NS_LOG_INFO(
"Processing Slotted ALOHA results, Tx evaluation @: "
1349 << (Now() + txOpportunity).GetSeconds() <<
" seconds");
1352 if (txOpportunity >= Seconds(0))
1354 Simulator::Schedule(txOpportunity,
1363 NS_LOG_INFO(
"Processing CRDSA results");
1371 NS_LOG_INFO(
"SatUtMac::DoRandomAccess - Processing ESSA results");
1380 if (txOpportunity >= Seconds(0))
1382 Simulator::Schedule(txOpportunity,
1393 NS_LOG_FUNCTION(
this);
1404 NS_LOG_FUNCTION(
this << allocationChannel);
1406 NS_LOG_INFO(
"UT: " <<
m_nodeInfo->GetMacAddress() <<
" AC: " << allocationChannel);
1413 NS_LOG_INFO(
"No known DAMA, selecting a slot for Slotted ALOHA");
1415 Ptr<SatSuperframeConf> superframeConf =
1417 uint8_t frameId = superframeConf->GetRaChannelFrameId(allocationChannel);
1418 Ptr<SatFrameConf> frameConf = superframeConf->GetFrameConf(frameId);
1419 uint32_t timeSlotCount = frameConf->GetTimeSlotCount();
1421 std::pair<bool, uint32_t> result = std::make_pair(
false, 0);
1422 Time superframeStartTime =
1425 if (Now() < superframeStartTime)
1427 NS_FATAL_ERROR(
"SatUtMac::ScheduleSlottedAlohaTransmission - Invalid SF start time");
1432 NS_LOG_INFO(
"Searching for next available slot");
1436 while (!result.first)
1438 NS_LOG_INFO(
"SuperFrameId: " << superFrameId <<
", superframeStartTime: "
1439 << superframeStartTime.GetSeconds());
1449 NS_LOG_INFO(
"Increasing frame offset!");
1451 superframeStartTime += frameConf->GetDuration();
1456 Ptr<SatTimeSlotConf> timeSlotConf = frameConf->GetTimeSlotConf(result.second);
1459 Time slotStartTime = superframeStartTime + timeSlotConf->GetStartTime();
1460 Time offset = slotStartTime - Now();
1462 if (offset.IsStrictlyNegative())
1464 NS_FATAL_ERROR(
"SatUtMac::ScheduleSlottedAlohaTransmission - Invalid transmit time: "
1465 << offset.GetSeconds());
1469 Ptr<SatWaveform> wf =
1470 m_superframeSeq->GetWaveformConf()->GetWaveform(timeSlotConf->GetWaveFormId());
1471 Time duration = wf->GetBurstDuration(frameConf->GetBtuConf()->GetSymbolRateInBauds());
1474 uint32_t carrierId =
1475 m_superframeSeq->GetCarrierId(0, frameId, timeSlotConf->GetCarrierId());
1477 NS_LOG_INFO(
"Starting to schedule, SF ID: "
1478 << superFrameId <<
" slot: " << result.second
1479 <<
" SF start: " << superframeStartTime.GetSeconds()
1480 <<
" Tx start: " << (Now() + offset).GetSeconds()
1481 <<
" duration: " << duration.GetSeconds() <<
" carrier ID: " << carrierId
1482 <<
" payload in bytes: " << wf->GetPayloadInBytes());
1486 if (offset >= Seconds(0))
1488 Simulator::Schedule(offset,
1500 NS_LOG_INFO(
"UT has known DAMA, aborting Slotted ALOHA");
1504 std::pair<bool, uint32_t>
1506 Ptr<SatFrameConf> frameConf,
1507 uint32_t timeSlotCount,
1508 uint32_t superFrameId,
1509 uint32_t allocationChannel)
1511 NS_LOG_FUNCTION(
this << superframeStartTime << timeSlotCount << superFrameId
1512 << allocationChannel);
1514 Time opportunityOffset = Now() - superframeStartTime;
1516 NS_LOG_INFO(
"UT: " <<
m_nodeInfo->GetMacAddress()
1517 <<
" offset: " << opportunityOffset.GetSeconds());
1521 if (opportunityOffset.IsStrictlyNegative())
1523 opportunityOffset = Seconds(0);
1533 std::pair<bool, uint32_t>
1535 Ptr<SatFrameConf> frameConf,
1536 uint32_t timeSlotCount,
1537 uint32_t superFrameId,
1538 uint32_t allocationChannel)
1540 NS_LOG_FUNCTION(
this << opportunityOffset << timeSlotCount << superFrameId
1541 << allocationChannel);
1543 NS_LOG_INFO(
"UT: " <<
m_nodeInfo->GetMacAddress());
1545 Ptr<SatTimeSlotConf> slotConf;
1547 bool availableSlotFound =
false;
1550 for (slotId = 0; slotId < timeSlotCount; slotId++)
1552 slotConf = frameConf->GetTimeSlotConf(slotId);
1560 if (slotConf->GetStartTime() >= opportunityOffset)
1565 availableSlotFound =
true;
1571 NS_LOG_INFO(
"Success: " << availableSlotFound <<
" SF: " << superFrameId <<
" AC: "
1572 << allocationChannel <<
" slot: " << slotId <<
"/" << timeSlotCount);
1574 return std::make_pair(availableSlotFound, slotId);
1581 NS_LOG_FUNCTION(
this << allocationChannel);
1583 NS_LOG_INFO(
"SatUtMac::ScheduleEssaTransmission - UT: " <<
m_nodeInfo->GetMacAddress()
1584 <<
" time: " << Now().GetSeconds()
1585 <<
" AC: " << allocationChannel);
1590 if (offset.IsStrictlyNegative())
1593 offset = Seconds(0);
1597 Ptr<SatSuperframeConf> superframeConf =
1599 uint8_t frameId = superframeConf->GetRaChannelFrameId(allocationChannel);
1600 Ptr<SatFrameConf> frameConf = superframeConf->GetFrameConf(frameId);
1601 Ptr<SatTimeSlotConf> timeSlotConf = frameConf->GetTimeSlotConf(0);
1603 Ptr<SatWaveform> wf =
1604 m_superframeSeq->GetWaveformConf()->GetWaveform(timeSlotConf->GetWaveFormId());
1605 Time duration = wf->GetBurstDuration(frameConf->GetBtuConf()->GetSymbolRateInBauds());
1607 NS_LOG_INFO(
"SatUtMac::ScheduleEssaTransmission - Starting to schedule @ "
1608 << Now().GetSeconds() <<
" Tx start: " << (Now() + offset).GetSeconds()
1609 <<
" duration: " << duration.GetSeconds()
1610 <<
" payload in bytes: " << wf->GetPayloadInBytes());
1613 uint32_t carrierId = 0;
1617 if (offset >= Seconds(0))
1619 Simulator::Schedule(offset,
1634 NS_LOG_FUNCTION(
this << allocationChannel);
1637 Time now = Simulator::Now();
1640 NS_LOG_INFO(
"Checking for CRDSA transmission at "
1641 << now.GetMilliSeconds() - superFrameStart.GetMilliSeconds()
1642 <<
" milliseconds into superframe " << superFrameId);
1648 NS_LOG_INFO(
"UT: " <<
m_nodeInfo->GetMacAddress() <<
" AC: " << allocationChannel
1649 <<
", SF: " << superFrameId <<
", num of opportunities: "
1652 std::map<uint32_t, std::set<uint32_t>>::iterator iter;
1659 std::set<uint32_t>::iterator iterSet;
1662 for (iterSet = iter->second.begin(); iterSet != iter->second.end(); iterSet++)
1670 "SatUtMac::ScheduleCrdsaTransmission - Slot unavailable: " << *iterSet);
1683 NS_LOG_FUNCTION(
this << allocationChannel);
1685 NS_LOG_INFO(
"UT: " <<
m_nodeInfo->GetMacAddress() <<
" AC: " << allocationChannel);
1687 Ptr<SatSuperframeConf> superframeConf =
1689 uint8_t frameId = superframeConf->GetRaChannelFrameId(allocationChannel);
1690 Ptr<SatFrameConf> frameConf = superframeConf->GetFrameConf(frameId);
1694 Time superframeStartTime = Now();
1697 uint32_t payloadBytes = superframeConf->GetRaChannelTimeSlotPayloadInBytes(allocationChannel);
1700 payloadBytes -=
m_randomAccess->GetCrdsaSignalingOverheadInBytes();
1702 if (payloadBytes < 1)
1705 "SatUtMac::CreateCrdsaPacketInstances - Not enough capacity in CRDSA payload");
1729 NS_LOG_INFO(
"Processing the packet container, fragments: " << uniq.size());
1733 std::vector<std::pair<uint16_t, SatPhy::PacketContainer_t>> replicas;
1734 std::map<uint16_t, SatCrdsaReplicaTag> tags;
1735 std::set<uint32_t>::iterator iterSet;
1737 NS_LOG_INFO(
"Creating replicas for a packet");
1740 for (iterSet = slots.begin(); iterSet != slots.end(); iterSet++)
1743 SatPhy::PacketContainer_t::const_iterator it = uniq.begin();
1745 for (; it != uniq.end(); ++it)
1747 rep.push_back((*it)->Copy());
1750 << (*iterSet) <<
", original (HL packet) fragment UID: " << (*it)->GetUid()
1751 <<
", copied replica fragment (HL packet) UID: " << rep.back()->GetUid());
1754 NS_LOG_INFO(
"One replica created");
1756 replicas.push_back(std::make_pair(*iterSet, rep));
1759 NS_LOG_INFO(
"Creating replica tags");
1762 for (uint32_t i = 0; i < replicas.size(); i++)
1766 replicaTag.
AddSlotId(replicas[i].first);
1768 NS_LOG_INFO(
"Own packet tag: " << replicas[i].first);
1770 for (uint32_t j = 0; j < replicas.size(); j++)
1774 replicaTag.
AddSlotId(replicas[j].first);
1776 NS_LOG_INFO(
"Other packet tag: " << replicas[j].first);
1779 tags.insert(std::make_pair(replicas[i].first, replicaTag));
1782 NS_LOG_INFO(
"Scheduling replicas");
1785 for (uint32_t i = 0; i < replicas.size(); i++)
1787 for (uint32_t j = 0; j < replicas[i].second.size(); j++)
1789 NS_LOG_INFO(
"Replica: " << i <<
", fragment: " << j
1790 <<
", key: " << replicas[i].first <<
", tag: "
1791 << tags.at(replicas[i].first).GetSlotIds().at(0)
1792 <<
", fragment (HL packet) UID: "
1793 << replicas[i].second.at(j)->GetUid());
1796 replicas[i].second.at(j)->AddPacketTag(tags.at(replicas[i].first));
1800 Ptr<SatTimeSlotConf> timeSlotConf = frameConf->GetTimeSlotConf(replicas[i].first);
1803 Time slotDelay = superframeStartTime + timeSlotConf->GetStartTime();
1804 Time offset = slotDelay - Now();
1806 if (offset.IsStrictlyNegative())
1808 NS_FATAL_ERROR(
"SatUtMac::CreateCrdsaPacketInstances - Invalid transmit time: "
1809 << offset.GetSeconds());
1813 Ptr<SatWaveform> wf =
1814 m_superframeSeq->GetWaveformConf()->GetWaveform(timeSlotConf->GetWaveFormId());
1815 Time duration = wf->GetBurstDuration(frameConf->GetBtuConf()->GetSymbolRateInBauds());
1818 uint32_t carrierId =
1821 timeSlotConf->GetCarrierId());
1826 txInfo.
modCod = wf->GetModCod();
1835 if (offset >= Seconds(0))
1837 Simulator::Schedule(offset,
1845 NS_LOG_INFO(
"Scheduled a replica in slot " << replicas[i].first <<
" with offset "
1846 << offset.GetSeconds());
1857 uint32_t allocationChannelId,
1860 NS_LOG_FUNCTION(
this << superFrameId << allocationChannelId << slotId);
1862 NS_LOG_INFO(
"UT: " <<
m_nodeInfo->GetMacAddress() <<
" SF: " << superFrameId
1863 <<
" AC: " << allocationChannelId <<
" slot: " << slotId);
1865 std::map<std::pair<uint32_t, uint32_t>, std::set<uint32_t>>::iterator iter;
1866 bool isSlotFree =
false;
1871 std::pair<uint32_t, uint32_t> key = std::make_pair(superFrameId, allocationChannelId);
1877 std::set<uint32_t> txOpportunities{{slotId}};
1878 std::pair<std::map<std::pair<uint32_t, uint32_t>, std::set<uint32_t>>::iterator,
bool>
1885 NS_LOG_INFO(
"No saved SF, slot " << slotId <<
" saved in SF " << superFrameId);
1889 NS_LOG_WARN(
"No saved SF but unable to create one");
1894 std::pair<std::set<uint32_t>::iterator,
bool> result;
1895 result = iter->second.insert(slotId);
1900 NS_LOG_INFO(
"Saved SF exist, slot " << slotId <<
" saved in SF " << superFrameId);
1904 NS_LOG_WARN(
"Saved SF exist but unable to add slot " << slotId);
1913 NS_LOG_FUNCTION(
this << superFrameId);
1915 NS_LOG_INFO(
"UT: " <<
m_nodeInfo->GetMacAddress() <<
" SF: " << superFrameId);
1917 std::map<std::pair<uint32_t, uint32_t>, std::set<uint32_t>>::iterator iter;
1921 if (iter->first.first < superFrameId)
1935 NS_LOG_FUNCTION(
this);
1937 NS_LOG_INFO(
"UT: " <<
m_nodeInfo->GetMacAddress());
1938 std::cout <<
"UT: " <<
m_nodeInfo->GetMacAddress() << std::endl;
1942 for (
auto& slot : iter.second)
1944 std::cout <<
"SF: " << iter.first.first <<
" AC: " << iter.first.second
1945 <<
" slot: " << slot << std::endl;
1953 NS_LOG_FUNCTION(
this);
1955 NS_LOG_INFO(
"UT: " <<
m_nodeInfo->GetMacAddress());
1959 NS_LOG_INFO(
"Applying TIM-U parameters received during the previous frame");
1963 NS_LOG_INFO(
"UT handover, old satellite is " <<
m_satId <<
", old beam is " <<
m_beamId);
1968 NS_LOG_INFO(
"UT handover, new satellite is " <<
m_satId <<
", new beam is " <<
m_beamId);
1973 Address satAddress =
m_timuInfo->GetSatAddress();
1974 Mac48Address satAddress48 = Mac48Address::ConvertFrom(satAddress);
1980 Ptr<SatTopology> satTopology = Singleton<SatTopology>::Get();
1983 Ptr<Node> gwNode = satTopology->GetGwFromBeam(
m_beamId);
1984 satTopology->UpdateGwConnectedToUt(
m_node, gwNode);
1986 Mac48Address gwAddress =
1987 Singleton<SatTopology>::Get()->GetGwAddressInUt(
m_nodeInfo->GetNodeId());
1994 srcScheduler->DisconnectUt(
m_nodeInfo->GetMacAddress());
1995 dstScheduler->ConnectUt(
m_nodeInfo->GetMacAddress());
1997 Ptr<SatIdMapper> satIdMapper = Singleton<SatIdMapper>::Get();
2016 NS_LOG_INFO(
"Tx is permitted");
2025 NS_LOG_INFO(
"UT checking for beam handover recommendation");
2047 Ptr<SatTopology> satTopology = Singleton<SatTopology>::Get();
2050 Ptr<Node> gwNode = satTopology->GetGwFromBeam(
m_beamId);
2051 satTopology->UpdateGwConnectedToUt(
m_node, gwNode);
2053 Address satAddress =
2055 Mac48Address satAddress48 = Mac48Address::ConvertFrom(satAddress);
2061 Mac48Address gwAddress =
2062 Singleton<SatTopology>::Get()->GetGwAddressInUt(
m_nodeInfo->GetNodeId());
2072 srcScheduler->DisconnectUt(
m_nodeInfo->GetMacAddress());
2073 dstScheduler->ConnectUt(
m_nodeInfo->GetMacAddress());
2075 Ptr<SatIdMapper> satIdMapper = Singleton<SatIdMapper>::Get();
2116 NS_LOG_INFO(
"Tx is disabled");
2121 NS_ASSERT_MSG(Now() < nextSuperFrameTxTime,
2122 "Scheduling next superframe start time to the past!");
2124 Time schedulingDelay = nextSuperFrameTxTime - Now();
2126 if (realDelay == Seconds(0))
2141 uint32_t driftTicks = (t + Simulator::Now()).GetMicroSeconds() *
m_clockDrift / 1000000;
2142 int32_t deltaTicks =
m_deltaNcr - driftTicks;
2143 Time deltaTime = NanoSeconds(deltaTicks * 1000 / 27.0);
2145 return t - deltaTime;
2154 m_satAddress(satAddress),
2155 m_gwAddress(gwAddress)
2157 NS_LOG_FUNCTION(
this << beamId << satAddress << gwAddress);
2163 NS_LOG_FUNCTION(
this);
2170 NS_LOG_FUNCTION(
this);
2177 NS_LOG_FUNCTION(
this);
2178 return m_satAddress;
2184 NS_LOG_FUNCTION(
this);
2191 NS_LOG_FUNCTION(
this);
2197 uint32_t payloadBytes,
2201 bool randomAccessChannel)
2203 NS_LOG_INFO(
this << payloadBytes << type << rcIndex << policy << randomAccessChannel);
2210 NS_LOG_INFO(
"Regular scheduling");
2211 m_utScheduler->DoScheduling(packets, payloadBytes, type, rcIndex, policy);
2215 NS_LOG_INFO(
"Handover recommendation sent, force control packets only");
2223 SatPhy::PacketContainer_t::iterator it = packets.begin();
2224 while (it != packets.end())
2227 bool success = (*it)->PeekPacketTag(ctrlTag);
2235 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
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.
void SetBeamId(uint32_t beamId)
Set beam ID of the object.
SatMac::BeamSchedulerCallback m_beamSchedulerCallback
Callback to get the SatBeamScheduler linked to a beam ID.
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.
void SetSatId(uint32_t satId)
Set sat ID of the object.
Ptr< SatHandoverModule > m_handoverModule
Module used to perform handovers.
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.
SatMac::UpdateIslCallback m_updateIslCallback
The update ISL routes 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.
Address GetGwAddress() const
Address GetSatAddress() const
uint32_t GetBeamId() const
SatTimuInfo(uint32_t beamId, uint32_t satId, Address satAddress, Address gwAddress)
uint32_t GetSatId() const
void SetRandomAccess(Ptr< SatRandomAccess > randomAccess)
Set the random access module.
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)
Callback< void, uint32_t, uint32_t > HandoverCallback
Callback to reconfigure physical layer during handover.
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.
SatUtMac::UpdateAddressAndIdentifierCallback m_updateAddressAndIdentifierCallback
Callback to update addresses in statistics helpers.
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.
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.
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.
Ptr< Node > m_node
Node containing this MAC.
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)
Ptr< SatRandomAccess > m_randomAccess
RA main module.
bool m_isRandomAccessScheduled
Flag that indicates if a method DoRandomAccess is scheduled for asynchronous access.
TimingAdvanceCallback m_timingAdvanceCb
Callback for getting the timing advance information.
uint32_t m_satId
ID of sat for UT.
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 SetUpdateAddressAndIdentifierCallback(SatUtMac::UpdateAddressAndIdentifierCallback cb)
Set the callback to update addresses in statistics helpers.
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.
Callback< void, Ptr< Node > > UpdateAddressAndIdentifierCallback
Callback to update addresses in statistics helpers.
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