22 #include <ns3/object.h>
25 #include <ns3/simulator.h>
27 #include <ns3/constant-position-mobility-model.h>
28 #include <ns3/node-container.h>
29 #include <ns3/mobility-helper.h>
30 #include <ns3/net-device-container.h>
31 #include <ns3/lte-ue-rrc.h>
32 #include <ns3/lte-helper.h>
33 #include <ns3/lte-spectrum-value-helper.h>
34 #include <ns3/callback.h>
93 :
TestCase (BuildNameString (numberOfNodes, numberOfComponentCarriers, configToCheck, simulationDuration)),
94 m_numberOfNodes(numberOfNodes),
95 m_numberOfComponentCarriers(numberOfComponentCarriers),
96 m_configToCheck(configToCheck),
97 m_simulationDuration (simulationDuration)
99 m_connectionCounter = 0.0;
103 virtual void DoRun (
void);
114 std::string BuildNameString (uint32_t numberOfNodes, uint16_t numberOfComponentCarriers, std::vector<ConfigToCheck> configToCheck,
Time simulationDuration);
122 void Evaluate (std::string context,
Ptr<LteUeRrc> ueRrc, std::list<LteRrcSap::SCellToAddMod> sCellToAddModList);
128 std::vector<std::map<uint16_t, ConfigToCheck> > EquallySpacedCcs ();
141 std::ostringstream oss;
142 oss <<
" nodes " << numberOfNodes <<
" carriers " << numberOfComponentCarriers
143 <<
" configurations " << configToCheck.size ()
144 <<
" duration " << simulationDuration;
148 std::vector<std::map<uint16_t, ConfigToCheck> >
151 std::vector<std::map<uint16_t, ConfigToCheck> > configToCheckContainer;
153 for (
auto &it: m_configToCheck)
155 std::map<uint16_t, ConfigToCheck> ccmap;
156 uint32_t ulEarfcn = it.m_ulEarfcn;
157 uint32_t dlEarfcn = it.m_dlEarfcn;
158 uint32_t maxBandwidthRb = std::max<uint32_t> (it.m_ulBandwidth, it.m_dlBandwidth);
163 for (uint16_t i = 0; i < m_numberOfComponentCarriers; i++)
171 NS_FATAL_ERROR (
"Band is not wide enough to allocate " << m_numberOfComponentCarriers <<
" CCs");
180 ccmap.insert (std::pair<uint16_t, ConfigToCheck> (i, cc));
183 ", DL BW: " << it.m_dlBandwidth <<
184 ", UL Earfcn: " << ulEarfcn <<
185 ", DL Earfcn: " << dlEarfcn);
189 uint32_t frequencyShift = 300 * (1 + (maxBandwidthKhz - 1) / 300);
192 uint32_t earfcnShift = frequencyShift / 100;
193 ulEarfcn += earfcnShift;
194 dlEarfcn += earfcnShift;
197 configToCheckContainer.push_back (ccmap);
200 return configToCheckContainer;
210 NS_LOG_INFO (
"m_configToCheckContainer size " << m_configToCheckContainer.size ());
212 ++m_connectionCounter;
214 std::map<uint16_t, ConfigToCheck> configToCheckMap;
218 configToCheckMap = m_configToCheckContainer[cellId-1];
222 uint16_t n1 =
std::max(cellId, m_numberOfComponentCarriers);
223 uint16_t n2 =
std::min(cellId, m_numberOfComponentCarriers);
224 configToCheckMap = m_configToCheckContainer[n1-n2];
228 ", DL BW: " <<
static_cast<uint16_t
> (ueRrc->
GetDlBandwidth ()) <<
232 for (
auto scell: sCellToAddModList)
234 NS_LOG_INFO (
"SCarrier - UL BW: " <<
static_cast<uint16_t
> (scell.radioResourceConfigCommonSCell.ulConfiguration.ulFreqInfo.ulBandwidth)<<
235 ", DL BW: " <<
static_cast<uint16_t
> (scell.radioResourceConfigCommonSCell.nonUlConfiguration.dlBandwidth) <<
236 ", UL Earfcn: " << scell.radioResourceConfigCommonSCell.ulConfiguration.ulFreqInfo.ulCarrierFreq <<
237 ", DL Earfcn: " << scell.cellIdentification.dlCarrierFreq);
244 "Primary Carrier DL bandwidth configuration failed");
246 "Primary Carrier UL bandwidth configuration failed");
248 "Primary Carrier DL EARFCN configuration failed");
250 "Primary Carrier UL EARFCN configuration failed");
252 uint32_t ConfigToCheckMapIndex = 1;
254 for (
auto scell: sCellToAddModList)
256 sCConfig = configToCheckMap[ConfigToCheckMapIndex];
259 "Secondary Carrier DL bandwidth configuration failed");
261 "Secondary Carrier UL bandwidth configuration failed");
263 "Secondary Carrier DL EARFCN configuration failed");
265 "Secondary Carrier UL EARFCN configuration failed");
266 ConfigToCheckMapIndex++;
284 enbNodes.
Create (m_numberOfNodes);
285 ueNodes.
Create (m_numberOfNodes);
287 uint32_t totalNumberOfNodes = enbNodes.
GetN () + ueNodes.
GetN ();
291 for (uint16_t i = 0; i < totalNumberOfNodes; i++)
293 positionAlloc->
Add (Vector (2 * i, 0, 0));
297 mobility.SetMobilityModel (
"ns3::ConstantPositionMobilityModel");
298 mobility.SetPositionAllocator (positionAlloc);
300 for (uint32_t
n = 0;
n < m_numberOfNodes; ++
n)
311 for (uint32_t i = 0; i < m_configToCheck.size (); ++i)
313 configuration = m_configToCheck[i];
327 m_configToCheckContainer = EquallySpacedCcs ();
330 for(uint32_t
k = 0;
k < m_numberOfNodes; ++
k)
340 Config::Connect (
"/NodeList/*/DeviceList/*/LteUeRrc/SCarrierConfigured",
364 :
TestSuite (
"lte-carrier-aggregation-configuration", SYSTEM)
366 std::vector<ConfigToCheck> configToCheck;
377 configToCheck.push_back (configToCheckTest1);
378 uint32_t numberOfNodes = 1;
379 uint16_t numberOfComponentCarriers = 2;
385 configToCheck.clear ();
394 configToCheck.push_back (configToCheckTest1);
401 configToCheck.push_back (configToCheckTest2);
403 simulationDuration =
Seconds (2);