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>
85 :
TestCase (BuildNameString (numberOfNodes, numberOfComponentCarriers, configToCheck, simulationDuration)),
86 m_numberOfNodes(numberOfNodes),
87 m_numberOfComponentCarriers(numberOfComponentCarriers),
88 m_configToCheck(configToCheck),
89 m_simulationDuration (simulationDuration)
91 m_connectionCounter = 0.0;
95 virtual void DoRun (
void);
97 std::string BuildNameString (uint32_t numberOfNodes, uint16_t numberOfComponentCarriers, std::vector<ConfigToCheck> configToCheck,
Time simulationDuration);
98 void Evaluate (std::string context,
Ptr<LteUeRrc> ueRrc, std::list<LteRrcSap::SCellToAddMod> sCellToAddModList);
99 std::vector<std::map<uint16_t, ConfigToCheck> > EquallySpacedCcs ();
112 std::ostringstream oss;
113 oss <<
" nodes " << numberOfNodes <<
" carriers " << numberOfComponentCarriers
114 <<
" configurations " << configToCheck.size ()
115 <<
" duration " << simulationDuration;
119 std::vector<std::map<uint16_t, ConfigToCheck> >
122 std::vector<std::map<uint16_t, ConfigToCheck> > configToCheckContainer;
124 for (
auto &it: m_configToCheck)
126 std::map<uint16_t, ConfigToCheck> ccmap;
127 uint32_t ulEarfcn = it.m_ulEarfcn;
128 uint32_t dlEarfcn = it.m_dlEarfcn;
129 uint32_t maxBandwidthRb = std::max<uint32_t> (it.m_ulBandwidth, it.m_dlBandwidth);
134 for (uint16_t i = 0; i < m_numberOfComponentCarriers; i++)
142 NS_FATAL_ERROR (
"Band is not wide enough to allocate " << m_numberOfComponentCarriers <<
" CCs");
151 ccmap.insert (std::pair<uint16_t, ConfigToCheck> (i, cc));
154 ", DL BW: " << it.m_dlBandwidth <<
155 ", UL Earfcn: " << ulEarfcn <<
156 ", DL Earfcn: " << dlEarfcn);
160 uint32_t frequencyShift = 300 * (1 + (maxBandwidthKhz - 1) / 300);
163 uint32_t earfcnShift = frequencyShift / 100;
164 ulEarfcn += earfcnShift;
165 dlEarfcn += earfcnShift;
168 configToCheckContainer.push_back (ccmap);
171 return configToCheckContainer;
181 NS_LOG_INFO (
"m_configToCheckContainer size " << m_configToCheckContainer.size ());
183 ++m_connectionCounter;
185 std::map<uint16_t, ConfigToCheck> configToCheckMap;
189 configToCheckMap = m_configToCheckContainer[cellId-1];
193 uint16_t n1 =
std::max(cellId, m_numberOfComponentCarriers);
194 uint16_t n2 =
std::min(cellId, m_numberOfComponentCarriers);
195 configToCheckMap = m_configToCheckContainer[n1-n2];
199 ", DL BW: " << static_cast<uint16_t> (ueRrc->
GetDlBandwidth ()) <<
203 for (
auto scell: sCellToAddModList)
205 NS_LOG_INFO (
"SCarrier - UL BW: " << static_cast<uint16_t> (scell.radioResourceConfigCommonSCell.ulConfiguration.ulFreqInfo.ulBandwidth)<<
206 ", DL BW: " << static_cast<uint16_t> (scell.radioResourceConfigCommonSCell.nonUlConfiguration.dlBandwidth) <<
207 ", UL Earfcn: " << scell.radioResourceConfigCommonSCell.ulConfiguration.ulFreqInfo.ulCarrierFreq <<
208 ", DL Earfcn: " << scell.cellIdentification.dlCarrierFreq);
215 "Primary Carrier DL bandwidth configuration failed");
217 "Primary Carrier UL bandwidth configuration failed");
219 "Primary Carrier DL EARFCN configuration failed");
221 "Primary Carrier UL EARFCN configuration failed");
223 uint32_t ConfigToCheckMapIndex = 1;
225 for (
auto scell: sCellToAddModList)
227 sCConfig = configToCheckMap[ConfigToCheckMapIndex];
230 "Secondary Carrier DL bandwidth configuration failed");
232 "Secondary Carrier UL bandwidth configuration failed");
234 "Secondary Carrier DL EARFCN configuration failed");
236 "Secondary Carrier UL EARFCN configuration failed");
237 ConfigToCheckMapIndex++;
255 enbNodes.
Create (m_numberOfNodes);
256 ueNodes.
Create (m_numberOfNodes);
258 uint32_t totalNumberOfNodes = enbNodes.GetN () + ueNodes.
GetN ();
262 for (uint16_t i = 0; i < totalNumberOfNodes; i++)
264 positionAlloc->
Add (Vector (2 * i, 0, 0));
271 for (uint32_t n = 0; n < m_numberOfNodes; ++n)
273 mobility.
Install (enbNodes.Get (n));
282 for (uint32_t i = 0; i < m_configToCheck.size (); ++i)
284 configuration = m_configToCheck[i];
298 m_configToCheckContainer = EquallySpacedCcs ();
301 for(uint32_t k = 0; k < m_numberOfNodes; ++k)
311 Config::Connect (
"/NodeList/*/DeviceList/*/LteUeRrc/SCarrierConfigured",
330 :
TestSuite (
"lte-carrier-aggregation-configuration", SYSTEM)
332 std::vector<ConfigToCheck> configToCheck;
343 configToCheck.push_back (configToCheckTest1);
344 uint32_t numberOfNodes = 1;
345 uint16_t numberOfComponentCarriers = 2;
351 configToCheck.clear ();
360 configToCheck.push_back (configToCheckTest1);
367 configToCheck.push_back (configToCheckTest2);
369 simulationDuration =
Seconds (2);
Simulation virtual time values and global simulation resolution.
Smart pointer class similar to boost::intrusive_ptr.
AttributeValue implementation for Boolean.
NetDeviceContainer InstallEnbDevice(NodeContainer c)
Create a set of eNodeB devices.
This test suite verifies following two things:
Hold variables of type string.
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr stored in this container at a given index.
std::vector< ConfigToCheck > m_configToCheck
std::vector< std::map< uint16_t, ConfigToCheck > > EquallySpacedCcs()
static void Run(void)
Run the simulation.
void Attach(NetDeviceContainer ueDevices)
Enables automatic attachment of a set of UE devices to a suitable cell using Idle mode initial cell s...
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
uint32_t m_connectionCounter
void SetUeDeviceAttribute(std::string n, const AttributeValue &v)
Set an attribute for the UE devices (LteUeNetDevice) to be created.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
static CarrierAggregationConfigTestSuite g_carrierAggregationConfigTestSuite
int64_t AssignStreams(NetDeviceContainer c, int64_t stream)
Assign a fixed random variable stream number to the random variables used.
void ActivateDataRadioBearer(NetDeviceContainer ueDevices, EpsBearer bearer)
Activate a Data Radio Bearer on a given UE devices (for LTE-only simulation).
std::vector< std::map< uint16_t, ConfigToCheck > > m_configToCheckContainer
CarrierAggregationConfigTestCase(uint32_t numberOfNodes, uint16_t numberOfComponentCarriers, std::vector< ConfigToCheck > configToCheck, Time simulationDuration)
Constructor.
uint32_t GetN(void) const
Get the number of Ptr stored in this container.
This class contains the specification of EPS Bearers.
void Install(Ptr< Node > node) const
"Layout" a single node according to the current position allocator type.
virtual void DoRun(void)
Implementation to actually run this TestCase.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
void Add(NetDeviceContainer other)
Append the contents of another NetDeviceContainer to the end of this container.
Hold an unsigned integer type.
#define NS_TEST_ASSERT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report and abort if not.
holds a vector of ns3::NetDevice pointers
uint8_t GetUlBandwidth() const
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
void Connect(std::string path, const CallbackBase &cb)
static void Destroy(void)
Execute the events scheduled with ScheduleDestroy().
static uint16_t GetUplinkCarrierBand(uint32_t nDl)
Converts uplink EARFCN to corresponding LTE frequency band number.
Time m_simulationDuration
static uint16_t GetDownlinkCarrierBand(uint32_t nDl)
Converts downlink EARFCN to corresponding LTE frequency band number.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
keep track of a set of node pointers.
static double GetChannelBandwidth(uint8_t txBandwidthConf)
uint32_t GetUlEarfcn() const
void SetMobilityModel(std::string type, std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue(), std::string n6="", const AttributeValue &v6=EmptyAttributeValue(), std::string n7="", const AttributeValue &v7=EmptyAttributeValue(), std::string n8="", const AttributeValue &v8=EmptyAttributeValue(), std::string n9="", const AttributeValue &v9=EmptyAttributeValue())
uint8_t GetDlBandwidth() const
void Evaluate(std::string context, Ptr< LteUeRrc > ueRrc, std::list< LteRrcSap::SCellToAddMod > sCellToAddModList)
NetDeviceContainer InstallUeDevice(NodeContainer c)
Create a set of UE devices.
Helper class used to assign positions and mobility models to nodes.
static void Stop(void)
Tell the Simulator the calling event should be the last one executed.
Ptr< Node > Get(uint32_t i) const
Get the Ptr stored in this container at a given index.
uint16_t GetCellId() const
uint16_t m_numberOfComponentCarriers
Time Seconds(double value)
Construct a Time in the indicated unit.
void SetDefault(std::string name, const AttributeValue &value)
void Add(Vector v)
Add a position to the list of positions.
std::string BuildNameString(uint32_t numberOfNodes, uint16_t numberOfComponentCarriers, std::vector< ConfigToCheck > configToCheck, Time simulationDuration)
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
void SetPositionAllocator(Ptr< PositionAllocator > allocator)
Set the position allocator which will be used to allocate the initial position of every node initiali...
uint32_t GetDlEarfcn() const
CarrierAggregationConfigTestSuite()
void SetEnbDeviceAttribute(std::string n, const AttributeValue &v)
Set an attribute for the eNodeB devices (LteEnbNetDevice) to be created.