A Discrete-Event Network Simulator
API
lte-test-rlc-am-e2e.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2012 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Manuel Requena <manuel.requena@cttc.es>
18 * Nicola Baldo <nbaldo@cttc.es>
19 */
20
21#include "lte-test-rlc-am-e2e.h"
22
23#include "lte-simple-helper.h"
24#include "lte-test-entities.h"
25
26#include "ns3/config-store.h"
27#include "ns3/config.h"
28#include "ns3/error-model.h"
29#include "ns3/log.h"
30#include "ns3/lte-rlc-header.h"
31#include "ns3/lte-rlc-um.h"
32#include "ns3/net-device-container.h"
33#include "ns3/node-container.h"
34#include "ns3/packet.h"
35#include "ns3/pointer.h"
36#include "ns3/radio-bearer-stats-calculator.h"
37#include "ns3/rng-seed-manager.h"
38#include "ns3/simulator.h"
39
40using namespace ns3;
41
42NS_LOG_COMPONENT_DEFINE("LteRlcAmE2eTest");
43
45 : TestSuite("lte-rlc-am-e2e", SYSTEM)
46{
47 // NS_LOG_INFO ("Creating LteRlcAmE2eTestSuite");
48
49 double losses[] = {0.0, 0.05, 0.10, 0.15, 0.25, 0.50, 0.75, 0.90, 0.95};
50 uint32_t runs[] = {
51 1111, 2222, 3333, 4444, 5555, 6666, 7777, 8888, 9999, 11110,
52 12221, 13332, 14443, 15554, 16665, 17776, 18887, 19998, 21109, 22220,
53 23331, 24442, 25553, 26664, 27775, 28886, 29997, 31108, 32219, 33330,
54 };
55
56 for (uint32_t l = 0; l < (sizeof(losses) / sizeof(double)); l++)
57 {
58 for (uint32_t s = 0; s < (sizeof(runs) / sizeof(uint32_t)); s++)
59 {
60 for (uint32_t sduArrivalType = 0; sduArrivalType <= 1; ++sduArrivalType)
61 {
62 std::ostringstream name;
63 name << " losses = " << losses[l] * 100 << "%; run = " << runs[s];
64
65 bool bulkSduArrival;
66 switch (sduArrivalType)
67 {
68 case 0:
69 bulkSduArrival = false;
70 name << "; continuous SDU arrival";
71 break;
72 case 1:
73 bulkSduArrival = true;
74 name << "; bulk SDU arrival";
75 break;
76 default:
77 NS_FATAL_ERROR("unsupported option");
78 break;
79 }
80
81 TestCase::TestDuration testDuration;
82 if (l == 1 && s == 0)
83 {
84 testDuration = TestCase::QUICK;
85 }
86 else if (s <= 4)
87 {
88 testDuration = TestCase::EXTENSIVE;
89 }
90 else
91 {
92 testDuration = TestCase::TAKES_FOREVER;
93 }
94 AddTestCase(new LteRlcAmE2eTestCase(name.str(), runs[s], losses[l], bulkSduArrival),
95 testDuration);
96 }
97 }
98 }
99}
100
106
108 uint32_t run,
109 double losses,
110 bool bulkSduArrival)
111 : TestCase(name),
112 m_run(run),
113 m_losses(losses),
114 m_bulkSduArrival(bulkSduArrival),
115 m_dlDrops(0),
116 m_ulDrops(0)
117{
118 NS_LOG_INFO("Creating LteRlcAmTestingTestCase: " + name);
119}
120
122{
123}
124
125void
127{
128 // NS_LOG_FUNCTION (this);
129 m_dlDrops++;
130}
131
132void
134{
135 // NS_LOG_FUNCTION (this);
136 m_ulDrops++;
137}
138
139void
141{
142 uint16_t numberOfNodes = 1;
143
144 // LogLevel level = (LogLevel) (LOG_LEVEL_ALL | LOG_PREFIX_TIME | LOG_PREFIX_NODE |
145 // LOG_PREFIX_FUNC); LogComponentEnable ("LteRlcAmE2eTest", level); LogComponentEnable
146 // ("ErrorModel", level); LogComponentEnable ("LteSimpleHelper", level); LogComponentEnable
147 // ("LteSimpleNetDevice", level); LogComponentEnable ("SimpleNetDevice", level);
148 // LogComponentEnable ("SimpleChannel", level);
149 // LogComponentEnable ("LteTestEntities", level);
150 // LogComponentEnable ("LtePdcp", level);
151 // LogComponentEnable ("LteRlc", level);
152 // LogComponentEnable ("LteRlcUm", level);
153 // LogComponentEnable ("LteRlcAm", level);
154
156 Config::SetDefault("ns3::LteRlcAm::PollRetransmitTimer", TimeValue(MilliSeconds(20)));
157 Config::SetDefault("ns3::LteRlcAm::ReorderingTimer", TimeValue(MilliSeconds(10)));
158 Config::SetDefault("ns3::LteRlcAm::StatusProhibitTimer", TimeValue(MilliSeconds(40)));
159 // This test was written for an unlimited transmit buffer (special value of 0)
160 Config::SetDefault("ns3::LteRlcAm::MaxTxBufferSize", UintegerValue(0));
161
162 Ptr<LteSimpleHelper> lteSimpleHelper = CreateObject<LteSimpleHelper>();
163 // lteSimpleHelper->EnableLogComponents ();
164 // lteSimpleHelper->EnableTraces ();
165
166 lteSimpleHelper->SetAttribute("RlcEntity", StringValue("RlcAm"));
167
168 // eNB and UE nodes
169 NodeContainer ueNodes;
170 NodeContainer enbNodes;
171 enbNodes.Create(numberOfNodes);
172 ueNodes.Create(numberOfNodes);
173
174 // Install LTE Devices to the nodes
175 NetDeviceContainer enbLteDevs = lteSimpleHelper->InstallEnbDevice(enbNodes);
176 NetDeviceContainer ueLteDevs = lteSimpleHelper->InstallUeDevice(ueNodes);
177
178 // Note: Just one eNB and UE is supported. Everything is done in InstallEnbDevice and
179 // InstallUeDevice
180
181 // Attach one UE per eNodeB
182 // for (uint16_t i = 0; i < numberOfNodes; i++)
183 // {
184 // lteSimpleHelper->Attach (ueLteDevs.Get(i), enbLteDevs.Get(i));
185 // }
186
187 // lteSimpleHelper->ActivateEpsBearer (ueLteDevs, EpsBearer
188 // (EpsBearer::NGBR_VIDEO_TCP_DEFAULT), EpcTft::Default ());
189
190 // Error models: downlink and uplink
191 Ptr<RateErrorModel> dlEm = CreateObject<RateErrorModel>();
192 // fix the stream so that subsequent test cases get a number from the same stream
193 // if RngRun is different, the number shall then be different
194 dlEm->AssignStreams(3);
195 dlEm->SetAttribute("ErrorRate", DoubleValue(m_losses));
196 dlEm->SetAttribute("ErrorUnit", StringValue("ERROR_UNIT_PACKET"));
197
198 // Ptr<RateErrorModel> ueEm = CreateObjectWithAttributes<RateErrorModel> ("RanVar",
199 // StringValue ("ns3::UniformRandomVariable[Min=0.0|Max=1.0]")); ueEm->SetAttribute
200 // ("ErrorRate", DoubleValue (m_losses)); ueEm->SetAttribute ("ErrorUnit", StringValue
201 // ("ERROR_UNIT_PACKET"));
202
203 // The below hooks will cause drops and receptions to be counted
204 ueLteDevs.Get(0)->SetAttribute("ReceiveErrorModel", PointerValue(dlEm));
205 ueLteDevs.Get(0)->TraceConnectWithoutContext(
206 "PhyRxDrop",
208 // enbLteDevs.Get (0)->SetAttribute ("ReceiveErrorModel", PointerValue (enbEm));
209 // enbLteDevs.Get (0)->TraceConnectWithoutContext ("PhyRxDrop", MakeCallback
210 // (&LteRlcAmE2eTestCase::EnbDropEvent, this));
211
212 uint32_t sduSizeBytes = 100;
213 uint32_t numSdu = 1000;
214 double sduStartTimeSeconds = 0.100;
215 double sduStopTimeSeconds;
216 double sduArrivalTimeSeconds;
217 uint32_t dlTxOppSizeBytes = 150;
218 double dlTxOpprTimeSeconds = 0.003;
219 uint32_t ulTxOppSizeBytes = 140;
220 double ulTxOpprTimeSeconds = 0.003;
221
223 {
224 sduStopTimeSeconds = sduStartTimeSeconds + 0.010;
225 }
226 else
227 {
228 sduStopTimeSeconds = sduStartTimeSeconds + 10;
229 }
230 sduArrivalTimeSeconds = (sduStopTimeSeconds - sduStartTimeSeconds) / numSdu;
231
232 // Sending packets from RRC layer
233 lteSimpleHelper->m_enbRrc->SetArrivalTime(Seconds(sduArrivalTimeSeconds));
234 lteSimpleHelper->m_enbRrc->SetPduSize(sduSizeBytes);
235
236 // MAC sends transmission opportunities (TxOpp)
237 lteSimpleHelper->m_enbMac->SetTxOppSize(dlTxOppSizeBytes);
238 lteSimpleHelper->m_enbMac->SetTxOppTime(Seconds(dlTxOpprTimeSeconds));
239 lteSimpleHelper->m_enbMac->SetTxOpportunityMode(LteTestMac::AUTOMATIC_MODE);
240
241 // MAC sends transmission opportunities (TxOpp)
242 lteSimpleHelper->m_ueMac->SetTxOppSize(ulTxOppSizeBytes);
243 lteSimpleHelper->m_ueMac->SetTxOppTime(Seconds(ulTxOpprTimeSeconds));
244 lteSimpleHelper->m_ueMac->SetTxOpportunityMode(LteTestMac::AUTOMATIC_MODE);
245
246 // Start/Stop pseudo-application at RRC layer
247 Simulator::Schedule(Seconds(sduStartTimeSeconds),
248 &LteTestRrc::Start,
249 lteSimpleHelper->m_enbRrc);
250 Simulator::Schedule(Seconds(sduStopTimeSeconds), &LteTestRrc::Stop, lteSimpleHelper->m_enbRrc);
251
252 double maxDlThroughput = (dlTxOppSizeBytes / (dlTxOppSizeBytes + 4.0)) *
253 (dlTxOppSizeBytes / dlTxOpprTimeSeconds) * (1.0 - m_losses);
254 const double statusProhibitSeconds = 0.020;
255 double pollFrequency = (1.0 / dlTxOpprTimeSeconds) * (1 - m_losses);
256 double statusFrequency = std::min(pollFrequency, 1.0 / statusProhibitSeconds);
257 const uint32_t numNackSnPerStatusPdu = (ulTxOppSizeBytes * 8 - 14) / 10;
258 double maxRetxThroughput =
259 ((double)numNackSnPerStatusPdu * (double)dlTxOppSizeBytes) * statusFrequency;
260 double throughput = std::min(maxDlThroughput, maxRetxThroughput);
261 double totBytes =
262 ((sduSizeBytes) * (sduStopTimeSeconds - sduStartTimeSeconds) / sduArrivalTimeSeconds);
263
264 // note: the throughput estimation is valid only for the full buffer
265 // case. However, the test sends a finite number of SDUs. Hence, the
266 // estimated throughput will only be effective at the beginning of
267 // the test. Towards the end of the test, two issues are present:
268 // 1) no new data is transmitted, hence less feedback is sent,
269 // hence the transmission rate for the last PDUs to be
270 // retransmitted is much lower. This effect can be best noteed
271 // at very high loss rates, and can be adjusted by timers and
272 // params.
273 // 2) throuhgput is not meaningful, you need to evaluate the time
274 // it takes for all PDUs to be (re)transmitted successfully,
275 // i.e., how long it takes for the TX and reTX queues to deplete.
276
277 // Estimating correctly this effect would require a complex stateful
278 // model (e.g., a Markov chain model) so to avoid the hassle we just
279 // use a margin here which we empirically determine as something we
280 // think reasonable based on the PDU loss rate
281 Time margin;
282 if (m_losses < 0.07)
283 {
284 margin = Seconds(0.500);
285 }
286 else if (m_losses < 0.20)
287 {
288 margin = Seconds(1);
289 }
290 else if (m_losses < 0.50)
291 {
292 margin = Seconds(2);
293 }
294 else if (m_losses < 0.70)
295 {
296 margin = Seconds(10);
297 }
298 else if (m_losses < 0.91)
299 {
300 margin = Seconds(20);
301 }
302 else // 0.95
303 {
304 margin = Seconds(30);
305 }
306 Time stopTime =
307 Seconds(std::max(sduStartTimeSeconds + totBytes / throughput, sduStopTimeSeconds)) + margin;
308
309 NS_LOG_INFO("statusFrequency=" << statusFrequency << ", maxDlThroughput=" << maxDlThroughput
310 << ", maxRetxThroughput=" << maxRetxThroughput << ", totBytes="
311 << totBytes << ", stopTime=" << stopTime.As(Time::S));
312
313 Simulator::Stop(stopTime);
314 Simulator::Run();
315
316 uint32_t txEnbRrcPdus = lteSimpleHelper->m_enbRrc->GetTxPdus();
317 uint32_t rxUeRrcPdus = lteSimpleHelper->m_ueRrc->GetRxPdus();
318
319 uint32_t txEnbRlcPdus = lteSimpleHelper->m_enbMac->GetTxPdus();
320 uint32_t rxUeRlcPdus = lteSimpleHelper->m_ueMac->GetRxPdus();
321
322 NS_LOG_INFO("Run = " << m_run);
323 NS_LOG_INFO("Loss rate (%) = " << uint32_t(m_losses * 100));
324
325 NS_LOG_INFO("RLC PDUs TX: " << txEnbRlcPdus << " RX: " << rxUeRlcPdus
326 << " LOST: " << m_dlDrops << " ("
327 << (100.0 * (double)m_dlDrops) / txEnbRlcPdus << "%)");
328
329 NS_TEST_ASSERT_MSG_EQ(txEnbRlcPdus,
330 rxUeRlcPdus + m_dlDrops,
331 "lost RLC PDUs don't match TX + RX");
332
333 NS_LOG_INFO("eNB tx RRC count = " << txEnbRrcPdus);
334 NS_LOG_INFO("UE rx RRC count = " << rxUeRrcPdus);
335
336 NS_TEST_ASSERT_MSG_EQ(txEnbRrcPdus,
337 rxUeRrcPdus,
338 "TX PDUs (" << txEnbRrcPdus << ") != RX PDUs (" << rxUeRrcPdus << ")");
339
340 Simulator::Destroy();
341}
#define min(a, b)
Definition: 80211b.c:42
#define max(a, b)
Definition: 80211b.c:43
Test cases used for the test suite lte-rlc-am-e2e.
void DlDropEvent(Ptr< const Packet > p)
DL drop event.
uint32_t m_ulDrops
number of UL drops
bool m_bulkSduArrival
bulk SDU arrival
void DoRun() override
Implementation to actually run this TestCase.
void UlDropEvent(Ptr< const Packet > p)
UL drop event.
uint32_t m_dlDrops
number of Dl drops
double m_losses
error rate
Test suite for RlcAmE2e test case.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition: double.h:42
holds a vector of ns3::NetDevice pointers
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
keep track of a set of node pointers.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:200
Hold objects of type Ptr<T>.
Definition: pointer.h:37
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
Definition: error-model.cc:229
Hold variables of type string.
Definition: string.h:56
encapsulates test code
Definition: test.h:1060
TestDuration
How long the test takes to execute.
Definition: test.h:1064
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:305
A suite of tests to run.
Definition: test.h:1256
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
TimeWithUnit As(const Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
Definition: time.cc:417
AttributeValue implementation for Time.
Definition: nstime.h:1423
Hold an unsigned integer type.
Definition: uinteger.h:45
Time stopTime
void SetGlobal(std::string name, const AttributeValue &value)
Definition: config.cc:937
void SetDefault(std::string name, const AttributeValue &value)
Definition: config.cc:891
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:160
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:275
static LteRlcAmE2eTestSuite lteRlcAmE2eTestSuite
Static variable for test initialization.
#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.
Definition: test.h:144
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1336
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1348
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Definition: callback.h:691