15#include "ns3/config.h"
16#include "ns3/error-model.h"
18#include "ns3/lte-rlc-header.h"
19#include "ns3/lte-rlc-um.h"
20#include "ns3/net-device-container.h"
21#include "ns3/node-container.h"
22#include "ns3/packet.h"
23#include "ns3/pointer.h"
24#include "ns3/radio-bearer-stats-calculator.h"
25#include "ns3/rng-seed-manager.h"
26#include "ns3/simulator.h"
37 double losses[] = {0.0, 0.05, 0.10, 0.15, 0.25, 0.50, 0.75, 0.90, 0.95};
39 1111, 2222, 3333, 4444, 5555, 6666, 7777, 8888, 9999, 11110,
40 12221, 13332, 14443, 15554, 16665, 17776, 18887, 19998, 21109, 22220,
41 23331, 24442, 25553, 26664, 27775, 28886, 29997, 31108, 32219, 33330,
44 for (
uint32_t l = 0; l < (
sizeof(losses) /
sizeof(
double)); l++)
48 for (
uint32_t sduArrivalType = 0; sduArrivalType <= 1; ++sduArrivalType)
50 std::ostringstream name;
51 name <<
" losses = " << losses[l] * 100 <<
"%; run = " << runs[s];
54 switch (sduArrivalType)
57 bulkSduArrival =
false;
58 name <<
"; continuous SDU arrival";
61 bulkSduArrival =
true;
62 name <<
"; bulk SDU arrival";
72 testDuration = TestCase::Duration::QUICK;
76 testDuration = TestCase::Duration::EXTENSIVE;
80 testDuration = TestCase::Duration::TAKES_FOREVER;
102 m_bulkSduArrival(bulkSduArrival),
106 NS_LOG_INFO(
"Creating LteRlcAmTestingTestCase: " + name);
130 uint16_t numberOfNodes = 1;
154 lteSimpleHelper->SetAttribute(
"RlcEntity",
StringValue(
"RlcAm"));
159 enbNodes.
Create(numberOfNodes);
160 ueNodes.
Create(numberOfNodes);
182 dlEm->AssignStreams(3);
184 dlEm->SetAttribute(
"ErrorUnit",
StringValue(
"ERROR_UNIT_PACKET"));
192 ueLteDevs.
Get(0)->SetAttribute(
"ReceiveErrorModel",
PointerValue(dlEm));
193 ueLteDevs.
Get(0)->TraceConnectWithoutContext(
202 double sduStartTimeSeconds = 0.100;
203 double sduStopTimeSeconds;
204 double sduArrivalTimeSeconds;
206 double dlTxOpprTimeSeconds = 0.003;
208 double ulTxOpprTimeSeconds = 0.003;
212 sduStopTimeSeconds = sduStartTimeSeconds + 0.010;
216 sduStopTimeSeconds = sduStartTimeSeconds + 10;
218 sduArrivalTimeSeconds = (sduStopTimeSeconds - sduStartTimeSeconds) / numSdu;
221 lteSimpleHelper->m_enbRrc->SetArrivalTime(
Seconds(sduArrivalTimeSeconds));
222 lteSimpleHelper->m_enbRrc->SetPduSize(sduSizeBytes);
225 lteSimpleHelper->m_enbMac->SetTxOppSize(dlTxOppSizeBytes);
226 lteSimpleHelper->m_enbMac->SetTxOppTime(
Seconds(dlTxOpprTimeSeconds));
230 lteSimpleHelper->m_ueMac->SetTxOppSize(ulTxOppSizeBytes);
231 lteSimpleHelper->m_ueMac->SetTxOppTime(
Seconds(ulTxOpprTimeSeconds));
237 lteSimpleHelper->m_enbRrc);
240 double maxDlThroughput = (dlTxOppSizeBytes / (dlTxOppSizeBytes + 4.0)) *
241 (dlTxOppSizeBytes / dlTxOpprTimeSeconds) * (1.0 -
m_losses);
242 const double statusProhibitSeconds = 0.020;
243 double pollFrequency = (1.0 / dlTxOpprTimeSeconds) * (1 -
m_losses);
244 double statusFrequency = std::min(pollFrequency, 1.0 / statusProhibitSeconds);
245 const uint32_t numNackSnPerStatusPdu = (ulTxOppSizeBytes * 8 - 14) / 10;
246 double maxRetxThroughput =
247 ((
double)numNackSnPerStatusPdu * (
double)dlTxOppSizeBytes) * statusFrequency;
248 double throughput = std::min(maxDlThroughput, maxRetxThroughput);
250 ((sduSizeBytes) * (sduStopTimeSeconds - sduStartTimeSeconds) / sduArrivalTimeSeconds);
295 Seconds(std::max(sduStartTimeSeconds + totBytes /
throughput, sduStopTimeSeconds)) + margin;
297 NS_LOG_INFO(
"statusFrequency=" << statusFrequency <<
", maxDlThroughput=" << maxDlThroughput
298 <<
", maxRetxThroughput=" << maxRetxThroughput <<
", totBytes="
304 uint32_t txEnbRrcPdus = lteSimpleHelper->m_enbRrc->GetTxPdus();
305 uint32_t rxUeRrcPdus = lteSimpleHelper->m_ueRrc->GetRxPdus();
307 uint32_t txEnbRlcPdus = lteSimpleHelper->m_enbMac->GetTxPdus();
308 uint32_t rxUeRlcPdus = lteSimpleHelper->m_ueMac->GetRxPdus();
313 NS_LOG_INFO(
"RLC PDUs TX: " << txEnbRlcPdus <<
" RX: " << rxUeRlcPdus
315 << (100.0 * (
double)
m_dlDrops) / txEnbRlcPdus <<
"%)");
319 "lost RLC PDUs don't match TX + RX");
321 NS_LOG_INFO(
"eNB tx RRC count = " << txEnbRrcPdus);
326 "TX PDUs (" << txEnbRrcPdus <<
") != RX PDUs (" << rxUeRrcPdus <<
")");
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
~LteRlcAmE2eTestCase() override
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'.
void Stop()
Stop function.
void Start()
Start function.
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.
AttributeValue implementation for Pointer.
Smart pointer class similar to boost::intrusive_ptr.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
static void Run()
Run the simulation.
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Hold variables of type string.
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Duration
How long the test takes to execute.
Simulation virtual time values and global simulation resolution.
TimeWithUnit As(const Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
Hold an unsigned integer type.
void SetGlobal(std::string name, const AttributeValue &value)
void SetDefault(std::string name, const AttributeValue &value)
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
static LteRlcAmE2eTestSuite lteRlcAmE2eTestSuite
Static variable for test initialization.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
#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.
Time Seconds(double value)
Construct a Time in the indicated unit.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
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...