24 #include <ns3/pointer.h>
25 #include <ns3/packet.h>
26 #include <ns3/simulator.h>
33 #include <ns3/lte-enb-mac.h>
34 #include <ns3/lte-radio-bearer-tag.h>
35 #include <ns3/lte-ue-phy.h>
37 #include "ns3/lte-mac-sap.h"
38 #include <ns3/lte-common.h>
61 virtual void ConfigureMac (uint8_t ulBandwidth, uint8_t dlBandwidth);
62 virtual void AddUe (uint16_t rnti);
63 virtual void RemoveUe (uint16_t rnti);
66 virtual void ReleaseLc (uint16_t rnti, uint8_t lcid);
318 .AddConstructor<LteEnbMac> ()
319 .AddAttribute (
"NumberOfRaPreambles",
320 "how many random access preambles are available for the contention based RACH process",
323 MakeUintegerChecker<uint8_t> (4, 64))
324 .AddAttribute (
"PreambleTransMax",
325 "Maximum number of random access preamble transmissions",
328 MakeUintegerChecker<uint8_t> (3, 200))
329 .AddAttribute (
"RaResponseWindowSize",
330 "length of the window (in TTIs) for the reception of the random access response (RAR); the resulting RAR timeout is this value + 3 ms",
333 MakeUintegerChecker<uint8_t> (2, 10))
334 .AddTraceSource (
"DlScheduling",
335 "Information regarding DL scheduling.",
337 .AddTraceSource (
"UlScheduling",
338 "Information regarding UL scheduling.",
448 NS_LOG_FUNCTION (
this <<
" EnbMac - frame " << frameNo <<
" subframe " << subframeNo);
460 dlcqiInfoReq.
m_sfnSf = ((0x3FF & frameNo) << 4) | (0xF & subframeNo);
476 NS_ASSERT (subframeNo > 0 && subframeNo <= 10);
481 NS_LOG_INFO (
this <<
" preambleId " << (uint32_t) it->first <<
": " << it->second <<
" received");
485 NS_LOG_INFO (
"preambleId " << (uint32_t) it->first <<
": collision");
495 rnti = jt->second.rnti;
496 NS_LOG_INFO (
"preambleId previously allocated for NC based RA, RNTI =" << (uint32_t) rnti <<
", sending RAR");
502 NS_LOG_INFO (
"preambleId " << (uint32_t) it->first <<
": allocated T-C-RNTI " << (uint32_t) rnti <<
", sending RAR");
508 rachInfoReqParams.
m_rachList.push_back (rachLe);
509 m_rapIdRntiMap.insert (std::pair <uint16_t, uint32_t> (rnti, it->first));
529 dlparams.
m_sfnSf = ((0x3FF & dlSchedFrameNo) << 4) | (0xF & dlSchedSubframeNo);
544 std::vector <FfMacSchedSapProvider::SchedUlCqiInfoReqParameters>::iterator itCqi;
549 m_ulCqiReceived.at (i).m_sfnSf = ((0x3FF & frameNo) << 4) | (0xF & (subframeNo - 1));
553 m_ulCqiReceived.at (i).m_sfnSf = ((0x3FF & (frameNo-1)) << 4) | (0xF & 10);
563 ulMacReq.
m_sfnSf = ((0x3FF & frameNo) << 4) | (0xF & subframeNo);
584 ulparams.
m_sfnSf = ((0x3FF & ulSchedFrameNo) << 4) | (0xF & ulSchedSubframeNo);
705 uint16_t rnti = tag.
GetRnti ();
707 std::map <uint16_t, std::map<uint8_t, LteMacSapUser*> >::iterator rntiIt =
m_rlcAttached.find (rnti);
709 std::map<uint8_t, LteMacSapUser*>::iterator lcidIt = rntiIt->second.find (lcid);
710 NS_ASSERT_MSG (lcidIt != rntiIt->second.end (),
"could not find LCID" << lcid);
711 (*lcidIt).second->ReceivePdu (p);
724 NS_LOG_FUNCTION (
this <<
" ulBandwidth=" << (uint16_t) ulBandwidth <<
" dlBandwidth=" << (uint16_t) dlBandwidth);
739 std::map<uint8_t, LteMacSapUser*>
empty;
740 std::pair <std::map <uint16_t, std::map<uint8_t, LteMacSapUser*> >::iterator,
bool>
741 ret =
m_rlcAttached.insert (std::pair <uint16_t, std::map<uint8_t, LteMacSapUser*> >
743 NS_ASSERT_MSG (ret.second,
"element already present, RNTI already existed");
752 std::vector < Ptr<PacketBurst> > dlHarqLayer0pkt;
753 dlHarqLayer0pkt.resize (8);
754 for (uint8_t i = 0; i < 8; i++)
757 dlHarqLayer0pkt.at (i) = pb;
759 std::vector < Ptr<PacketBurst> > dlHarqLayer1pkt;
760 dlHarqLayer1pkt.resize (8);
761 for (uint8_t i = 0; i < 8; i++)
764 dlHarqLayer1pkt.at (i) = pb;
767 buf.push_back (dlHarqLayer0pkt);
768 buf.push_back (dlHarqLayer1pkt);
788 std::map <LteFlowId_t, LteMacSapUser* >::iterator it;
792 std::map <uint16_t, std::map<uint8_t, LteMacSapUser*> >::iterator rntiIt =
m_rlcAttached.find (lcinfo.
rnti);
794 std::map<uint8_t, LteMacSapUser*>::iterator lcidIt = rntiIt->second.find (lcinfo.
lcId);
795 if (lcidIt == rntiIt->second.end ())
797 rntiIt->second.insert (std::pair<uint8_t, LteMacSapUser*> (lcinfo.
lcId, msu));
808 if (lcinfo.
lcId != 0)
881 preambleInfo.
rnti = rnti;
882 NS_LOG_INFO (
"allocated preamble for NC based RA: preamble " << preambleId <<
", RNTI " << preambleInfo.
rnti <<
", exiryTime " << preambleInfo.
expiryTime);
955 std::map <LteFlowId_t, LteMacSapUser* >::iterator it;
959 for (uint16_t layer = 0; layer < ind.
m_buildDataList.at (i).m_dci.m_ndi.size (); layer++)
966 for (uint16_t lcId = 0; lcId < (*it).second.size (); lcId ++)
969 (*it).second.at (lcId).at (ind.
m_buildDataList.at (i).m_dci.m_harqProcess) = pb;
973 for (
unsigned int j = 0; j < ind.
m_buildDataList.at (i).m_rlcPduList.size (); j++)
975 for (uint16_t k = 0; k < ind.
m_buildDataList.at (i).m_rlcPduList.at (j).size (); k++)
981 uint8_t lcid = ind.
m_buildDataList.at (i).m_rlcPduList.at (j).at (k).m_logicalChannelIdentity;
982 std::map <uint16_t, std::map<uint8_t, LteMacSapUser*> >::iterator rntiIt =
m_rlcAttached.find (rnti);
984 std::map<uint8_t, LteMacSapUser*>::iterator lcidIt = rntiIt->second.find (lcid);
985 NS_ASSERT_MSG (lcidIt != rntiIt->second.end (),
"could not find LCID" << lcid);
986 NS_LOG_DEBUG (
this <<
" rnti= " << rnti <<
" lcid= " << (uint32_t) lcid <<
" layer= " << k);
987 (*lcidIt).second->NotifyTxOpportunity (ind.
m_buildDataList.at (i).m_rlcPduList.at (j).at (k).m_size, k, ind.
m_buildDataList.at (i).m_dci.m_harqProcess);
1037 NS_FATAL_ERROR (
"Found element with more than two transport blocks");
1054 rarMsg->SetRaRnti (raRnti);
1063 rar.
rapId = itRapId->second;
1065 rarMsg->AddRar (rar);
1081 for (
unsigned int i = 0; i < ind.
m_dciList.size (); i++)
1090 for ( uint32_t i = 0; i < ind.
m_dciList.size (); i++ )
1171 for (uint8_t layer = 0; layer < params.
m_harqStatus.size (); layer++)