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"
57NS_LOG_COMPONENT_DEFINE(
"SatUtMac");
62NS_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");
152 NS_LOG_FUNCTION(
this);
155 NS_FATAL_ERROR(
"SatUtMac::SatUtMac - Constructor not in use");
161 Ptr<SatSuperframeSeq> seq,
162 bool crdsaOnlyForControl)
200 NS_LOG_FUNCTION(
this);
208 NS_LOG_FUNCTION(
this);
218 NS_LOG_FUNCTION(
this);
237 NS_LOG_FUNCTION(
this << &cb);
244 NS_LOG_FUNCTION(
this << &cb);
251 NS_LOG_FUNCTION(
this << &cb);
258 NS_LOG_FUNCTION(
this << &cb);
266 NS_LOG_FUNCTION(
this << &cb);
274 NS_LOG_FUNCTION(
this << &cb);
282 NS_LOG_FUNCTION(
this << &cb);
297 NS_LOG_FUNCTION(
this);
305 NS_LOG_FUNCTION(
this << gwAddress);
314 NS_LOG_FUNCTION(
this << nodeInfo);
324 NS_LOG_FUNCTION(
this);
333 NS_LOG_FUNCTION(
this);
341 NS_LOG_FUNCTION(
this << raChannel);
349 NS_LOG_FUNCTION(
this);
357 NS_LOG_FUNCTION(
this);
367 NS_LOG_FUNCTION(
this);
381 NS_LOG_FUNCTION(
this);
386 return m_useLogon && stateCorrect && ncrReceived;
392 NS_LOG_FUNCTION(
this << &cb);
399 if (Now() >= nextSuperFrameTxTime)
401 NS_FATAL_ERROR(
"Scheduling next superframe start time to the past!");
404 Time schedulingDelay = nextSuperFrameTxTime - Now();
412 NS_LOG_FUNCTION(
this << &cb);
420 NS_LOG_FUNCTION(
this << (uint32_t)superFrameSeqId);
424 Singleton<SatRtnLinkTime>::Get()->GetNextSuperFrameTxTime(superFrameSeqId, timingAdvance);
431 NS_LOG_FUNCTION(
this << (uint32_t)superFrameSeqId);
434 Time txTime = Singleton<SatRtnLinkTime>::Get()->GetCurrentSuperFrameTxTime(superFrameSeqId,
442 NS_LOG_FUNCTION(
this << (uint32_t)superFrameSeqId);
444 return Singleton<SatRtnLinkTime>::Get()->GetCurrentSuperFrameCount(superFrameSeqId,
451 NS_LOG_FUNCTION(
this << tbtp);
452 NS_LOG_INFO(
"UT: " <<
m_nodeInfo->GetMacAddress() <<
" received TBTP "
453 << tbtp->GetSuperframeCounter());
472 Singleton<SatRtnLinkTime>::Get()->GetSuperFrameTxTime(tbtp->GetSuperframeSeqId(),
473 tbtp->GetSuperframeCounter(),
477 Time startDelay = txTime - Simulator::Now();
483 if (txTime < Simulator::Now())
485 NS_FATAL_ERROR(
"UT: " <<
m_nodeInfo->GetMacAddress() <<
" received TBTP "
486 << tbtp->GetSuperframeCounter()
487 <<
", which should have been sent already in the past");
490 NS_LOG_INFO(
"Time to start sending the superframe for this UT: " << txTime.GetSeconds());
491 NS_LOG_INFO(
"Waiting delay before the superframe start: " << startDelay.GetSeconds());
496 uint32_t payloadSumInSuperFrame = 0;
499 if (!info.second.empty())
501 NS_LOG_INFO(
"TBTP contains " << info.second.size()
502 <<
" timeslots for UT: " <<
m_nodeInfo->GetMacAddress());
504 uint8_t frameId = info.first;
507 for (SatTbtpMessage::DaTimeSlotConfContainer_t::iterator it = info.second.begin();
508 it != info.second.end();
511 Ptr<SatSuperframeConf> superframeConf =
513 Ptr<SatFrameConf> frameConf = superframeConf->GetFrameConf(frameId);
514 Ptr<SatTimeSlotConf> timeSlotConf = *it;
517 Time slotDelay = startDelay + timeSlotConf->GetStartTime();
518 NS_LOG_INFO(
"Slot start delay: " << slotDelay.GetSeconds());
521 Ptr<SatWaveform> wf =
522 m_superframeSeq->GetWaveformConf()->GetWaveform(timeSlotConf->GetWaveFormId());
523 Time duration = wf->GetBurstDuration(frameConf->GetBtuConf()->GetSymbolRateInBauds());
529 duration = wf->GetBurstDuration(frameConf->GetBtuConf()->GetSymbolRateInBauds());
539 m_superframeSeq->GetCarrierId(0, frameId, timeSlotConf->GetCarrierId());
546 payloadSumInSuperFrame += wf->GetPayloadInBytes();
547 payloadSumPerRcIndex[timeSlotConf->GetRcIndex()] += wf->GetPayloadInBytes();
566 Ptr<SatTimeSlotConf> tsConf,
569 NS_LOG_FUNCTION(
this << transmitDelay.GetSeconds() << duration.GetSeconds()
570 << wf->GetPayloadInBytes() << (uint32_t)(tsConf->GetRcIndex())
572 NS_LOG_INFO(
"After delay: " << transmitDelay.GetSeconds() <<
" duration: "
573 << duration.GetSeconds() <<
", payload: " << wf->GetPayloadInBytes()
574 <<
", rcIndex: " << (uint32_t)(tsConf->GetRcIndex())
575 <<
", carrier: " << carrierId);
579 if (transmitDelay >= Seconds(0))
581 Simulator::Schedule(transmitDelay,
596 Ptr<SatTimeSlotConf> tsConf,
599 NS_LOG_FUNCTION(
this << duration.GetSeconds() << wf->GetPayloadInBytes() << carrierId
600 << (uint32_t)(tsConf->GetRcIndex()));
604 NS_LOG_INFO(
"Tx is unavailable");
616 FetchPackets(wf->GetPayloadInBytes(), tsConf->GetSlotType(), tsConf->GetRcIndex(), policy);
620 if (packets.size() == 0)
622 Ptr<Packet> p = Create<Packet>(wf->GetPayloadInBytes());
627 p->AddPacketTag(tag);
641 p->AddPacketTag(mTag);
647 p->AddPacketTag(addressE2ETag);
649 packets.push_back(p);
653 NS_LOG_INFO(
"DA Tx opportunity for UT: "
654 <<
m_nodeInfo->GetMacAddress() <<
" duration: " << duration.GetSeconds()
655 <<
", payload: " << wf->GetPayloadInBytes() <<
", carrier: " << carrierId
656 <<
", RC index: " << (uint32_t)(tsConf->GetRcIndex()));
660 txInfo.
modCod = wf->GetModCod();
667 NS_FATAL_ERROR(
"WF02 should only be used for control bursts");
675 Ptr<SatWaveform> waveform,
680 NS_LOG_FUNCTION(
this << duration.GetSeconds() << waveform->GetPayloadInBytes() << carrierId
681 << (uint32_t)(rcIndex));
682 NS_LOG_INFO(
"Tx opportunity for UT: "
683 <<
m_nodeInfo->GetMacAddress() <<
" duration: " << duration.GetSeconds()
684 <<
", payload: " << waveform->GetPayloadInBytes() <<
", carrier: " << carrierId
685 <<
", RC index: " << (uint32_t)(rcIndex));
690 uint32_t payloadBytes = waveform->GetPayloadInBytes();
693 payloadBytes -=
m_randomAccess->GetSlottedAlohaSignalingOverheadInBytes();
695 if (payloadBytes < 1)
698 "SatUtMac::DoSlottedAlohaTransmit - Not enough capacity in Slotted ALOHA payload");
708 if (!packets.empty())
710 NS_LOG_INFO(
"Number of packets sent in a slotted ALOHA slot: " << packets.size());
712 for (SatPhy::PacketContainer_t::const_iterator it = packets.begin(); it != packets.end();
728 txInfo.
modCod = waveform->GetModCod();
731 txInfo.
waveformId = waveform->GetWaveformId();
739 Ptr<SatWaveform> waveform,
744 NS_LOG_FUNCTION(
this << duration.GetSeconds() << waveform->GetPayloadInBytes() << carrierId
745 << (uint32_t)(rcIndex));
746 NS_LOG_INFO(
"SatUtMac::DoEssaTransmit - Tx opportunity for UT: "
747 <<
m_nodeInfo->GetMacAddress() <<
" at time: " << Simulator::Now().GetSeconds()
748 <<
" duration: " << duration.GetSeconds()
749 <<
", payload: " << waveform->GetPayloadInBytes() <<
", carrier: " << carrierId
750 <<
", RC index: " << (uint32_t)(rcIndex));
753 uint32_t payloadBytes = waveform->GetPayloadInBytes();
763 if (!packets.empty())
765 NS_LOG_INFO(
"Number of packets sent in a ESSA frame: " << packets.size());
767 for (SatPhy::PacketContainer_t::const_iterator it = packets.begin(); it != packets.end();
784 txInfo.
modCod = waveform->GetModCod();
787 txInfo.
waveformId = waveform->GetWaveformId();
799 if (duration >= Seconds(0))
801 Simulator::Schedule(duration,
820 NS_LOG_FUNCTION(
this << payloadBytes << (uint32_t)(rcIndex));
829 if (payloadBytes <= 0)
831 NS_FATAL_ERROR(
"SatUtMac::FetchPackets - unvalid slot payload: " << payloadBytes);
837 if (!packets.empty())
839 NS_LOG_INFO(
"Number of packets: " << packets.size());
841 for (SatPhy::PacketContainer_t::const_iterator it = packets.begin(); it != packets.end();
856 NS_LOG_INFO(
"The Frame PDU holds " << packets.size() <<
" RLE PDUs");
867 NS_LOG_FUNCTION(
this << packets.size() << duration.GetSeconds() << carrierId);
880 if (!packets.empty())
882 NS_LOG_INFO(
"UT: " <<
m_nodeInfo->GetMacAddress() <<
", transmitting " << packets.size()
883 <<
" packets, duration: " << duration.GetSeconds()
884 <<
", carrier: " << carrierId);
887 Time durationWithoutGuardPeriod(duration -
m_guardTime);
888 NS_LOG_INFO(
"Duration: " << duration.GetSeconds() <<
" duration with guard period: "
889 << durationWithoutGuardPeriod.GetSeconds());
890 NS_LOG_INFO(
"UT: " <<
m_nodeInfo->GetMacAddress() <<
" send packet");
892 SendPacket(packets, carrierId, durationWithoutGuardPeriod, txInfo);
899 NS_LOG_FUNCTION(
this << event << (uint32_t)rcIndex);
901 NS_LOG_INFO(
"UT: " <<
m_nodeInfo->GetMacAddress() <<
" Queue: " << (uint32_t)rcIndex);
908 NS_LOG_INFO(
"Buffered packet event received");
912 NS_LOG_INFO(
"Doing Slotted ALOHA");
923 NS_LOG_FUNCTION(
this << event << (uint32_t)rcIndex);
925 NS_LOG_INFO(
"SatUtMac::ReceiveQueueEventEssa - UT: " <<
m_nodeInfo->GetMacAddress()
926 <<
" time: " << Now().GetSeconds()
927 <<
" Queue: " << (uint32_t)rcIndex);
935 NS_LOG_INFO(
"SatUtMac::ReceiveQueueEventEssa - Buffered packet event received");
939 NS_LOG_INFO(
"SatUtMac::ReceiveQueueEventEssa - Doing ESSA");
951 packets.push_back(packet);
953 Ptr<SatSuperframeConf> superframeConf =
955 uint8_t frameId = superframeConf->GetRaChannelFrameId(
m_logonChannel);
956 Ptr<SatFrameConf> frameConf = superframeConf->GetFrameConf(frameId);
958 Ptr<SatTimeSlotConf> timeSlotConf = frameConf->GetTimeSlotConf(0);
960 Ptr<SatWaveform> wf =
961 m_superframeSeq->GetWaveformConf()->GetWaveform(timeSlotConf->GetWaveFormId());
962 Time duration = wf->GetBurstDuration(frameConf->GetBtuConf()->GetSymbolRateInBauds());
966 timeSlotConf->GetCarrierId());
970 txInfo.
modCod = wf->GetModCod();
981 if (waitingTime >= Seconds(0))
983 Simulator::Schedule(waitingTime,
999 NS_LOG_FUNCTION(
this << packets.size());
1020 for (SatPhy::PacketContainer_t::iterator i = packets.begin(); i != packets.end(); i++)
1024 bool mSuccess = (*i)->PeekPacketTag(macTag);
1027 NS_FATAL_ERROR(
"MAC tag was not found from the packet!");
1031 mSuccess = (*i)->PeekPacketTag(addressE2ETag);
1034 NS_FATAL_ERROR(
"SatAddressE2ETag was not found from the packet!");
1039 NS_LOG_INFO(
"Receiver " <<
m_nodeInfo->GetMacAddress());
1042 if (destAddress ==
m_nodeInfo->GetMacAddress() || destAddress.IsBroadcast() ||
1043 destAddress.IsGroup())
1047 bool cSuccess = (*i)->PeekPacketTag(ctrlTag);
1059 NS_FATAL_ERROR(
"A control message received with not valid msg type!");
1062 else if (destAddress.IsBroadcast())
1082 NS_LOG_FUNCTION(
this);
1086 packet->PeekPacketTag(macTag);
1089 packet->PeekPacketTag(addressE2ETag);
1093 bool cSuccess = packet->PeekPacketTag(ctrlTag);
1097 NS_FATAL_ERROR(
"SatControlMsgTag not found in the packet!");
1103 uint32_t tbtpId = ctrlTag.
GetMsgId();
1112 if (tbtp ==
nullptr)
1114 NS_FATAL_ERROR(
"TBTP not found, check SatBeamHelper::CtrlMsgStoreTimeInFwdLink "
1115 "attribute is long enough!");
1125 packet->RemovePacketTag(macTag);
1126 packet->RemovePacketTag(addressE2ETag);
1127 packet->RemovePacketTag(ctrlTag);
1137 uint32_t raCtrlId = ctrlTag.
GetMsgId();
1140 if (raMsg !=
nullptr)
1142 uint32_t allocationChannelId = raMsg->GetAllocationChannelId();
1143 uint16_t backoffProbability = raMsg->GetBackoffProbability();
1144 uint16_t backoffTime = raMsg->GetBackoffTime();
1146 NS_LOG_INFO(
"UT: " <<
m_nodeInfo->GetMacAddress()
1147 <<
" Updating RA backoff probability for AC: "
1148 << allocationChannelId <<
" to: " << backoffProbability);
1150 m_randomAccess->SetBackoffProbability(allocationChannelId, backoffProbability);
1151 m_randomAccess->SetBackoffTime(allocationChannelId, backoffTime);
1153 packet->RemovePacketTag(macTag);
1154 packet->RemovePacketTag(addressE2ETag);
1155 packet->RemovePacketTag(ctrlTag);
1164 std::stringstream msg;
1165 msg <<
"Control message " << ctrlTag.
GetMsgType()
1166 <<
" is not found from the FWD link control msg container!";
1167 msg <<
" at: " << Now().GetSeconds() <<
"s";
1173 uint32_t timuCtrlId = ctrlTag.
GetMsgId();
1174 Ptr<SatTimuMessage> timuMsg = DynamicCast<SatTimuMessage>(
m_readCtrlCallback(timuCtrlId));
1176 if (timuMsg !=
nullptr)
1178 uint32_t beamId = timuMsg->GetAllocatedBeamId();
1179 uint32_t satId = timuMsg->GetAllocatedSatId();
1180 NS_LOG_INFO(
"UT: " <<
m_nodeInfo->GetMacAddress() <<
" switching from beam " <<
m_beamId
1181 <<
" to beam " << beamId);
1184 NS_LOG_INFO(
"Storing TIM-U information internally for later");
1187 timuMsg->GetSatAddress(),
1188 timuMsg->GetGwAddress());
1198 std::stringstream msg;
1199 msg <<
"Control message " << ctrlTag.
GetMsgType()
1200 <<
" is not found from the FWD link control msg container!";
1201 msg <<
" at: " << Now().GetSeconds() <<
"s";
1207 uint32_t sliceCtrlId = ctrlTag.
GetMsgId();
1208 Ptr<SatSliceSubscriptionMessage> sliceMsg =
1211 if (sliceMsg !=
nullptr)
1213 if (
m_nodeInfo->GetMacAddress() == sliceMsg->GetAddress())
1225 std::stringstream msg;
1226 msg <<
"Control message " << ctrlTag.
GetMsgType()
1227 <<
" is not found from the FWD link control msg container!";
1228 msg <<
" at: " << Now().GetSeconds() <<
"s";
1234 uint32_t logonId = ctrlTag.
GetMsgId();
1235 Ptr<SatLogonResponseMessage> logonMsg =
1238 if (logonMsg !=
nullptr)
1254 std::stringstream msg;
1255 msg <<
"Control message " << ctrlTag.
GetMsgType()
1256 <<
" is not found from the FWD link control msg container!";
1257 msg <<
" at: " << Now().GetSeconds() <<
"s";
1263 uint32_t ncrCtrlId = ctrlTag.
GetMsgId();
1264 Ptr<SatNcrMessage> ncrMsg = DynamicCast<SatNcrMessage>(
m_readCtrlCallback(ncrCtrlId));
1267 m_ncr = ncrMsg->GetNcrDate();
1284 uint32_t cmtCtrlId = ctrlTag.
GetMsgId();
1285 Ptr<SatCmtMessage> cmtMsg = DynamicCast<SatCmtMessage>(
m_readCtrlCallback(cmtCtrlId));
1286 int16_t burstTimeCorrection = cmtMsg->GetBurstTimeCorrection();
1291 uint32_t logoffCtrlId = ctrlTag.
GetMsgId();
1292 Ptr<SatLogoffMessage> logoffMsg =
1298 NS_FATAL_ERROR(
"SatUtMac received a non-supported control packet!");
1307 NS_LOG_FUNCTION(
this << randomAccessTriggerType);
1309 NS_LOG_INFO(
"UT: " <<
m_nodeInfo->GetMacAddress());
1327 NS_LOG_INFO(
"Logon channel cannot be used for RA transmition");
1332 txOpportunities =
m_randomAccess->DoRandomAccess(allocationChannel, randomAccessTriggerType);
1340 NS_LOG_INFO(
"Processing Slotted ALOHA results, Tx evaluation @: "
1341 << (Now() + txOpportunity).GetSeconds() <<
" seconds");
1344 if (txOpportunity >= Seconds(0))
1346 Simulator::Schedule(txOpportunity,
1355 NS_LOG_INFO(
"Processing CRDSA results");
1363 NS_LOG_INFO(
"SatUtMac::DoRandomAccess - Processing ESSA results");
1372 if (txOpportunity >= Seconds(0))
1374 Simulator::Schedule(txOpportunity,
1385 NS_LOG_FUNCTION(
this);
1396 NS_LOG_FUNCTION(
this << allocationChannel);
1398 NS_LOG_INFO(
"UT: " <<
m_nodeInfo->GetMacAddress() <<
" AC: " << allocationChannel);
1405 NS_LOG_INFO(
"No known DAMA, selecting a slot for Slotted ALOHA");
1407 Ptr<SatSuperframeConf> superframeConf =
1409 uint8_t frameId = superframeConf->GetRaChannelFrameId(allocationChannel);
1410 Ptr<SatFrameConf> frameConf = superframeConf->GetFrameConf(frameId);
1411 uint32_t timeSlotCount = frameConf->GetTimeSlotCount();
1413 std::pair<bool, uint32_t> result = std::make_pair(
false, 0);
1414 Time superframeStartTime =
1417 if (Now() < superframeStartTime)
1419 NS_FATAL_ERROR(
"SatUtMac::ScheduleSlottedAlohaTransmission - Invalid SF start time");
1424 NS_LOG_INFO(
"Searching for next available slot");
1428 while (!result.first)
1430 NS_LOG_INFO(
"SuperFrameId: " << superFrameId <<
", superframeStartTime: "
1431 << superframeStartTime.GetSeconds());
1441 NS_LOG_INFO(
"Increasing frame offset!");
1443 superframeStartTime += frameConf->GetDuration();
1448 Ptr<SatTimeSlotConf> timeSlotConf = frameConf->GetTimeSlotConf(result.second);
1451 Time slotStartTime = superframeStartTime + timeSlotConf->GetStartTime();
1452 Time offset = slotStartTime - Now();
1454 if (offset.IsStrictlyNegative())
1456 NS_FATAL_ERROR(
"SatUtMac::ScheduleSlottedAlohaTransmission - Invalid transmit time: "
1457 << offset.GetSeconds());
1461 Ptr<SatWaveform> wf =
1462 m_superframeSeq->GetWaveformConf()->GetWaveform(timeSlotConf->GetWaveFormId());
1463 Time duration = wf->GetBurstDuration(frameConf->GetBtuConf()->GetSymbolRateInBauds());
1466 uint32_t carrierId =
1467 m_superframeSeq->GetCarrierId(0, frameId, timeSlotConf->GetCarrierId());
1469 NS_LOG_INFO(
"Starting to schedule, SF ID: "
1470 << superFrameId <<
" slot: " << result.second
1471 <<
" SF start: " << superframeStartTime.GetSeconds()
1472 <<
" Tx start: " << (Now() + offset).GetSeconds()
1473 <<
" duration: " << duration.GetSeconds() <<
" carrier ID: " << carrierId
1474 <<
" payload in bytes: " << wf->GetPayloadInBytes());
1478 if (offset >= Seconds(0))
1480 Simulator::Schedule(offset,
1492 NS_LOG_INFO(
"UT has known DAMA, aborting Slotted ALOHA");
1496std::pair<bool, uint32_t>
1498 Ptr<SatFrameConf> frameConf,
1499 uint32_t timeSlotCount,
1500 uint32_t superFrameId,
1501 uint32_t allocationChannel)
1503 NS_LOG_FUNCTION(
this << superframeStartTime << timeSlotCount << superFrameId
1504 << allocationChannel);
1506 Time opportunityOffset = Now() - superframeStartTime;
1508 NS_LOG_INFO(
"UT: " <<
m_nodeInfo->GetMacAddress()
1509 <<
" offset: " << opportunityOffset.GetSeconds());
1513 if (opportunityOffset.IsStrictlyNegative())
1515 opportunityOffset = Seconds(0);
1525std::pair<bool, uint32_t>
1527 Ptr<SatFrameConf> frameConf,
1528 uint32_t timeSlotCount,
1529 uint32_t superFrameId,
1530 uint32_t allocationChannel)
1532 NS_LOG_FUNCTION(
this << opportunityOffset << timeSlotCount << superFrameId
1533 << allocationChannel);
1535 NS_LOG_INFO(
"UT: " <<
m_nodeInfo->GetMacAddress());
1537 Ptr<SatTimeSlotConf> slotConf;
1539 bool availableSlotFound =
false;
1542 for (slotId = 0; slotId < timeSlotCount; slotId++)
1544 slotConf = frameConf->GetTimeSlotConf(slotId);
1552 if (slotConf->GetStartTime() >= opportunityOffset)
1557 availableSlotFound =
true;
1563 NS_LOG_INFO(
"Success: " << availableSlotFound <<
" SF: " << superFrameId <<
" AC: "
1564 << allocationChannel <<
" slot: " << slotId <<
"/" << timeSlotCount);
1566 return std::make_pair(availableSlotFound, slotId);
1573 NS_LOG_FUNCTION(
this << allocationChannel);
1575 NS_LOG_INFO(
"SatUtMac::ScheduleEssaTransmission - UT: " <<
m_nodeInfo->GetMacAddress()
1576 <<
" time: " << Now().GetSeconds()
1577 <<
" AC: " << allocationChannel);
1582 if (offset.IsStrictlyNegative())
1585 offset = Seconds(0);
1589 Ptr<SatSuperframeConf> superframeConf =
1591 uint8_t frameId = superframeConf->GetRaChannelFrameId(allocationChannel);
1592 Ptr<SatFrameConf> frameConf = superframeConf->GetFrameConf(frameId);
1593 Ptr<SatTimeSlotConf> timeSlotConf = frameConf->GetTimeSlotConf(0);
1595 Ptr<SatWaveform> wf =
1596 m_superframeSeq->GetWaveformConf()->GetWaveform(timeSlotConf->GetWaveFormId());
1597 Time duration = wf->GetBurstDuration(frameConf->GetBtuConf()->GetSymbolRateInBauds());
1599 NS_LOG_INFO(
"SatUtMac::ScheduleEssaTransmission - Starting to schedule @ "
1600 << Now().GetSeconds() <<
" Tx start: " << (Now() + offset).GetSeconds()
1601 <<
" duration: " << duration.GetSeconds()
1602 <<
" payload in bytes: " << wf->GetPayloadInBytes());
1605 uint32_t carrierId = 0;
1609 if (offset >= Seconds(0))
1611 Simulator::Schedule(offset,
1626 NS_LOG_FUNCTION(
this << allocationChannel);
1629 Time now = Simulator::Now();
1632 NS_LOG_INFO(
"Checking for CRDSA transmission at "
1633 << now.GetMilliSeconds() - superFrameStart.GetMilliSeconds()
1634 <<
" milliseconds into superframe " << superFrameId);
1640 NS_LOG_INFO(
"UT: " <<
m_nodeInfo->GetMacAddress() <<
" AC: " << allocationChannel
1641 <<
", SF: " << superFrameId <<
", num of opportunities: "
1644 std::map<uint32_t, std::set<uint32_t>>::iterator iter;
1651 std::set<uint32_t>::iterator iterSet;
1654 for (iterSet = iter->second.begin(); iterSet != iter->second.end(); iterSet++)
1662 "SatUtMac::ScheduleCrdsaTransmission - Slot unavailable: " << *iterSet);
1675 NS_LOG_FUNCTION(
this << allocationChannel);
1677 NS_LOG_INFO(
"UT: " <<
m_nodeInfo->GetMacAddress() <<
" AC: " << allocationChannel);
1679 Ptr<SatSuperframeConf> superframeConf =
1681 uint8_t frameId = superframeConf->GetRaChannelFrameId(allocationChannel);
1682 Ptr<SatFrameConf> frameConf = superframeConf->GetFrameConf(frameId);
1686 Time superframeStartTime = Now();
1689 uint32_t payloadBytes = superframeConf->GetRaChannelTimeSlotPayloadInBytes(allocationChannel);
1692 payloadBytes -=
m_randomAccess->GetCrdsaSignalingOverheadInBytes();
1694 if (payloadBytes < 1)
1697 "SatUtMac::CreateCrdsaPacketInstances - Not enough capacity in CRDSA payload");
1721 NS_LOG_INFO(
"Processing the packet container, fragments: " << uniq.size());
1725 std::vector<std::pair<uint16_t, SatPhy::PacketContainer_t>> replicas;
1726 std::map<uint16_t, SatCrdsaReplicaTag> tags;
1727 std::set<uint32_t>::iterator iterSet;
1729 NS_LOG_INFO(
"Creating replicas for a packet");
1732 for (iterSet = slots.begin(); iterSet != slots.end(); iterSet++)
1735 SatPhy::PacketContainer_t::const_iterator it = uniq.begin();
1737 for (; it != uniq.end(); ++it)
1739 rep.push_back((*it)->Copy());
1742 << (*iterSet) <<
", original (HL packet) fragment UID: " << (*it)->GetUid()
1743 <<
", copied replica fragment (HL packet) UID: " << rep.back()->GetUid());
1746 NS_LOG_INFO(
"One replica created");
1748 replicas.push_back(std::make_pair(*iterSet, rep));
1751 NS_LOG_INFO(
"Creating replica tags");
1754 for (uint32_t i = 0; i < replicas.size(); i++)
1758 replicaTag.
AddSlotId(replicas[i].first);
1760 NS_LOG_INFO(
"Own packet tag: " << replicas[i].first);
1762 for (uint32_t j = 0; j < replicas.size(); j++)
1766 replicaTag.
AddSlotId(replicas[j].first);
1768 NS_LOG_INFO(
"Other packet tag: " << replicas[j].first);
1771 tags.insert(std::make_pair(replicas[i].first, replicaTag));
1774 NS_LOG_INFO(
"Scheduling replicas");
1777 for (uint32_t i = 0; i < replicas.size(); i++)
1779 for (uint32_t j = 0; j < replicas[i].second.size(); j++)
1781 NS_LOG_INFO(
"Replica: " << i <<
", fragment: " << j
1782 <<
", key: " << replicas[i].first <<
", tag: "
1783 << tags.at(replicas[i].first).GetSlotIds().at(0)
1784 <<
", fragment (HL packet) UID: "
1785 << replicas[i].second.at(j)->GetUid());
1788 replicas[i].second.at(j)->AddPacketTag(tags.at(replicas[i].first));
1792 Ptr<SatTimeSlotConf> timeSlotConf = frameConf->GetTimeSlotConf(replicas[i].first);
1795 Time slotDelay = superframeStartTime + timeSlotConf->GetStartTime();
1796 Time offset = slotDelay - Now();
1798 if (offset.IsStrictlyNegative())
1800 NS_FATAL_ERROR(
"SatUtMac::CreateCrdsaPacketInstances - Invalid transmit time: "
1801 << offset.GetSeconds());
1805 Ptr<SatWaveform> wf =
1806 m_superframeSeq->GetWaveformConf()->GetWaveform(timeSlotConf->GetWaveFormId());
1807 Time duration = wf->GetBurstDuration(frameConf->GetBtuConf()->GetSymbolRateInBauds());
1810 uint32_t carrierId =
1813 timeSlotConf->GetCarrierId());
1818 txInfo.
modCod = wf->GetModCod();
1827 if (offset >= Seconds(0))
1829 Simulator::Schedule(offset,
1837 NS_LOG_INFO(
"Scheduled a replica in slot " << replicas[i].first <<
" with offset "
1838 << offset.GetSeconds());
1849 uint32_t allocationChannelId,
1852 NS_LOG_FUNCTION(
this << superFrameId << allocationChannelId << slotId);
1854 NS_LOG_INFO(
"UT: " <<
m_nodeInfo->GetMacAddress() <<
" SF: " << superFrameId
1855 <<
" AC: " << allocationChannelId <<
" slot: " << slotId);
1857 std::map<std::pair<uint32_t, uint32_t>, std::set<uint32_t>>::iterator iter;
1858 bool isSlotFree =
false;
1863 std::pair<uint32_t, uint32_t> key = std::make_pair(superFrameId, allocationChannelId);
1869 std::set<uint32_t> txOpportunities{{slotId}};
1870 std::pair<std::map<std::pair<uint32_t, uint32_t>, std::set<uint32_t>>::iterator,
bool>
1877 NS_LOG_INFO(
"No saved SF, slot " << slotId <<
" saved in SF " << superFrameId);
1881 NS_LOG_WARN(
"No saved SF but unable to create one");
1886 std::pair<std::set<uint32_t>::iterator,
bool> result;
1887 result = iter->second.insert(slotId);
1892 NS_LOG_INFO(
"Saved SF exist, slot " << slotId <<
" saved in SF " << superFrameId);
1896 NS_LOG_WARN(
"Saved SF exist but unable to add slot " << slotId);
1905 NS_LOG_FUNCTION(
this << superFrameId);
1907 NS_LOG_INFO(
"UT: " <<
m_nodeInfo->GetMacAddress() <<
" SF: " << superFrameId);
1909 std::map<std::pair<uint32_t, uint32_t>, std::set<uint32_t>>::iterator iter;
1913 if (iter->first.first < superFrameId)
1927 NS_LOG_FUNCTION(
this);
1929 NS_LOG_INFO(
"UT: " <<
m_nodeInfo->GetMacAddress());
1930 std::cout <<
"UT: " <<
m_nodeInfo->GetMacAddress() << std::endl;
1934 for (
auto& slot : iter.second)
1936 std::cout <<
"SF: " << iter.first.first <<
" AC: " << iter.first.second
1937 <<
" slot: " << slot << std::endl;
1945 NS_LOG_FUNCTION(
this);
1947 NS_LOG_INFO(
"UT: " <<
m_nodeInfo->GetMacAddress());
1951 NS_LOG_INFO(
"Applying TIM-U parameters received during the previous frame");
1955 NS_LOG_INFO(
"UT handover, old satellite is " <<
m_satId <<
", old beam is " <<
m_beamId);
1960 NS_LOG_INFO(
"UT handover, new satellite is " <<
m_satId <<
", new beam is " <<
m_beamId);
1965 Address satAddress =
m_timuInfo->GetSatAddress();
1966 Mac48Address satAddress48 = Mac48Address::ConvertFrom(satAddress);
1972 Ptr<SatTopology> satTopology = Singleton<SatTopology>::Get();
1975 Ptr<Node> gwNode = satTopology->GetGwFromBeam(
m_beamId);
1976 satTopology->UpdateGwConnectedToUt(
m_node, gwNode);
1978 Mac48Address gwAddress =
1979 Singleton<SatTopology>::Get()->GetGwAddressInUt(
m_nodeInfo->GetNodeId());
1986 srcScheduler->DisconnectUt(
m_nodeInfo->GetMacAddress());
1987 dstScheduler->ConnectUt(
m_nodeInfo->GetMacAddress());
1989 Ptr<SatIdMapper> satIdMapper = Singleton<SatIdMapper>::Get();
2008 NS_LOG_INFO(
"Tx is permitted");
2017 NS_LOG_INFO(
"UT checking for beam handover recommendation");
2039 Ptr<SatTopology> satTopology = Singleton<SatTopology>::Get();
2042 Ptr<Node> gwNode = satTopology->GetGwFromBeam(
m_beamId);
2043 satTopology->UpdateGwConnectedToUt(
m_node, gwNode);
2045 Address satAddress =
2047 Mac48Address satAddress48 = Mac48Address::ConvertFrom(satAddress);
2053 Mac48Address gwAddress =
2054 Singleton<SatTopology>::Get()->GetGwAddressInUt(
m_nodeInfo->GetNodeId());
2064 srcScheduler->DisconnectUt(
m_nodeInfo->GetMacAddress());
2065 dstScheduler->ConnectUt(
m_nodeInfo->GetMacAddress());
2067 Ptr<SatIdMapper> satIdMapper = Singleton<SatIdMapper>::Get();
2108 NS_LOG_INFO(
"Tx is disabled");
2113 NS_ASSERT_MSG(Now() < nextSuperFrameTxTime,
2114 "Scheduling next superframe start time to the past!");
2116 Time schedulingDelay = nextSuperFrameTxTime - Now();
2118 if (realDelay == Seconds(0))
2133 uint32_t driftTicks = (t + Simulator::Now()).GetMicroSeconds() *
m_clockDrift / 1000000;
2134 int32_t deltaTicks =
m_deltaNcr - driftTicks;
2135 Time deltaTime = NanoSeconds(deltaTicks * 1000 / 27.0);
2137 return t - deltaTime;
2149 NS_LOG_FUNCTION(
this << beamId << satAddress << gwAddress);
2155 NS_LOG_FUNCTION(
this);
2162 NS_LOG_FUNCTION(
this);
2169 NS_LOG_FUNCTION(
this);
2176 NS_LOG_FUNCTION(
this);
2183 NS_LOG_FUNCTION(
this);
2189 uint32_t payloadBytes,
2193 bool randomAccessChannel)
2195 NS_LOG_INFO(
this << payloadBytes << type << rcIndex << policy << randomAccessChannel);
2202 NS_LOG_INFO(
"Regular scheduling");
2203 m_utScheduler->DoScheduling(packets, payloadBytes, type, rcIndex, policy);
2207 NS_LOG_INFO(
"Handover recommendation sent, force control packets only");
2215 SatPhy::PacketContainer_t::iterator it = packets.begin();
2216 while (it != packets.end())
2219 bool success = (*it)->PeekPacketTag(ctrlTag);
2227 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.
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.
SatMac()
Construct a SatMac.
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
UT specific Mac class for Sat Net Devices.
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.
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.
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