|
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
|
2 /* |
|
3 * Copyright (c) 2012 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC) |
|
4 * |
|
5 * This program is free software; you can redistribute it and/or modify |
|
6 * it under the terms of the GNU General Public License version 2 as |
|
7 * published by the Free Software Foundation; |
|
8 * |
|
9 * This program is distributed in the hope that it will be useful, |
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 * GNU General Public License for more details. |
|
13 * |
|
14 * You should have received a copy of the GNU General Public License |
|
15 * along with this program; if not, write to the Free Software |
|
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
17 * |
|
18 * Author: Manuel Requena <manuel.requena@cttc.es> |
|
19 */ |
|
20 |
|
21 #include "ns3/config.h" |
|
22 #include "ns3/simulator.h" |
|
23 #include "ns3/pointer.h" |
|
24 #include "ns3/log.h" |
|
25 #include "ns3/packet.h" |
|
26 #include "ns3/node-container.h" |
|
27 #include "ns3/net-device-container.h" |
|
28 #include "ns3/lte-simple-helper.h" |
|
29 #include "ns3/error-model.h" |
|
30 #include "ns3/radio-bearer-stats-calculator.h" |
|
31 |
|
32 #include "ns3/lte-rlc-header.h" |
|
33 #include "ns3/lte-rlc-um.h" |
|
34 |
|
35 #include "ns3/lte-test-entities.h" |
|
36 #include "ns3/lte-test-rlc-um-e2e.h" |
|
37 |
|
38 |
|
39 NS_LOG_COMPONENT_DEFINE ("LteRlcUmE2eTest"); |
|
40 |
|
41 using namespace ns3; |
|
42 |
|
43 |
|
44 /** |
|
45 * Test x.x.x RLC UM: End-to-end flow |
|
46 */ |
|
47 |
|
48 /** |
|
49 * TestSuite |
|
50 */ |
|
51 |
|
52 LteRlcUmE2eTestSuite::LteRlcUmE2eTestSuite () |
|
53 : TestSuite ("lte-rlc-um-e2e", SYSTEM) |
|
54 { |
|
55 // NS_LOG_INFO ("Creating LteRlcUmE2eTestSuite"); |
|
56 |
|
57 double losses[] = {0.0, 0.10, 0.25, 0.50, 0.75, 0.90, 1.00}; |
|
58 uint32_t seeds[] = {1111, 2222, 3333, 4444, 5555, 6666, 7777, 8888, 9999, 10101}; |
|
59 |
|
60 for ( uint32_t l = 0 ; l < (sizeof (losses) / sizeof (double)) ; l++ ) |
|
61 { |
|
62 for ( uint32_t s = 0 ; s < (sizeof (seeds) / sizeof (uint32_t)) ; s++ ) |
|
63 { |
|
64 std::ostringstream name; |
|
65 name << " Losses = " << losses[l] << "%. Seed = " << seeds[s]; |
|
66 AddTestCase (new LteRlcUmE2eTestCase (name.str (), seeds[s], losses[l])); |
|
67 } |
|
68 } |
|
69 } |
|
70 |
|
71 static LteRlcUmE2eTestSuite lteRlcUmE2eTestSuite; |
|
72 |
|
73 |
|
74 /** |
|
75 * TestCase |
|
76 */ |
|
77 |
|
78 LteRlcUmE2eTestCase::LteRlcUmE2eTestCase (std::string name, uint32_t seed, double losses) |
|
79 : TestCase (name) |
|
80 { |
|
81 // NS_LOG_UNCOND ("Creating LteRlcUmTestingTestCase: " + name); |
|
82 |
|
83 m_seed = seed; |
|
84 m_losses = losses; |
|
85 |
|
86 m_dlDrops = 0; |
|
87 m_ulDrops = 0; |
|
88 } |
|
89 |
|
90 LteRlcUmE2eTestCase::~LteRlcUmE2eTestCase () |
|
91 { |
|
92 } |
|
93 |
|
94 |
|
95 void |
|
96 LteRlcUmE2eTestCase::DlDropEvent (Ptr<const Packet> p) |
|
97 { |
|
98 // NS_LOG_FUNCTION (this); |
|
99 m_dlDrops++; |
|
100 } |
|
101 |
|
102 void |
|
103 LteRlcUmE2eTestCase::UlDropEvent (Ptr<const Packet> p) |
|
104 { |
|
105 // NS_LOG_FUNCTION (this); |
|
106 m_ulDrops++; |
|
107 } |
|
108 |
|
109 void |
|
110 LteRlcUmE2eTestCase::DoRun (void) |
|
111 { |
|
112 uint16_t numberOfNodes = 1; |
|
113 |
|
114 LogLevel level = (LogLevel) (LOG_LEVEL_ALL | LOG_PREFIX_TIME | LOG_PREFIX_NODE | LOG_PREFIX_FUNC); |
|
115 LogComponentEnable ("LteRlcUmE2eTest", level); |
|
116 // LogComponentEnable ("ErrorModel", level); |
|
117 // LogComponentEnable ("LteSimpleHelper", level); |
|
118 // LogComponentEnable ("LteSimpleNetDevice", level); |
|
119 // LogComponentEnable ("SimpleNetDevice", level); |
|
120 // LogComponentEnable ("SimpleChannel", level); |
|
121 // LogComponentEnable ("LteTestEntities", level); |
|
122 // LogComponentEnable ("LtePdcp", level); |
|
123 // LogComponentEnable ("LteRlc", level); |
|
124 // LogComponentEnable ("LteRlcUm", level); |
|
125 // LogComponentEnable ("LteRlcAm", level); |
|
126 |
|
127 SeedManager::SetSeed (m_seed); |
|
128 |
|
129 Ptr<LteSimpleHelper> lteSimpleHelper = CreateObject<LteSimpleHelper> (); |
|
130 // lteSimpleHelper->EnableLogComponents (); |
|
131 // lteSimpleHelper->EnableTraces (); |
|
132 |
|
133 lteSimpleHelper->SetAttribute ("RlcEntity", StringValue ("RlcUm")); |
|
134 |
|
135 // eNB and UE nodes |
|
136 NodeContainer ueNodes; |
|
137 NodeContainer enbNodes; |
|
138 enbNodes.Create (numberOfNodes); |
|
139 ueNodes.Create (numberOfNodes); |
|
140 |
|
141 // Install LTE Devices to the nodes |
|
142 NetDeviceContainer enbLteDevs = lteSimpleHelper->InstallEnbDevice (enbNodes); |
|
143 NetDeviceContainer ueLteDevs = lteSimpleHelper->InstallUeDevice (ueNodes); |
|
144 |
|
145 // Note: Just one eNB and UE are supported. Everything is done in InstallEnbDevice and InstallUeDevice |
|
146 |
|
147 // Attach one UE per eNodeB |
|
148 // for (uint16_t i = 0; i < numberOfNodes; i++) |
|
149 // { |
|
150 // lteSimpleHelper->Attach (ueLteDevs.Get(i), enbLteDevs.Get(i)); |
|
151 // } |
|
152 |
|
153 // lteSimpleHelper->ActivateEpsBearer (ueLteDevs, EpsBearer (EpsBearer::NGBR_VIDEO_TCP_DEFAULT), EpcTft::Default ()); |
|
154 |
|
155 // Error models: downlink and uplink |
|
156 Ptr<RateErrorModel> dlEm = CreateObjectWithAttributes<RateErrorModel> ("RanVar", RandomVariableValue (UniformVariable (0.0, 1.0))); |
|
157 dlEm->SetAttribute ("ErrorRate", DoubleValue (m_losses)); |
|
158 dlEm->SetAttribute ("ErrorUnit", StringValue ("ERROR_UNIT_PACKET")); |
|
159 |
|
160 Ptr<RateErrorModel> ulEm = CreateObjectWithAttributes<RateErrorModel> ("RanVar", RandomVariableValue (UniformVariable (0.0, 1.0))); |
|
161 ulEm->SetAttribute ("ErrorRate", DoubleValue (m_losses)); |
|
162 ulEm->SetAttribute ("ErrorUnit", StringValue ("ERROR_UNIT_PACKET")); |
|
163 |
|
164 // The below hooks will cause drops to be counted at simple phy layer |
|
165 ueLteDevs.Get (0)->SetAttribute ("ReceiveErrorModel", PointerValue (dlEm)); |
|
166 ueLteDevs.Get (0)->TraceConnectWithoutContext ("PhyRxDrop", MakeCallback (&LteRlcUmE2eTestCase::DlDropEvent, this)); |
|
167 enbLteDevs.Get (0)->SetAttribute ("ReceiveErrorModel", PointerValue (ulEm)); |
|
168 enbLteDevs.Get (0)->TraceConnectWithoutContext ("PhyRxDrop", MakeCallback (&LteRlcUmE2eTestCase::UlDropEvent, this)); |
|
169 |
|
170 // Sending packets from eNB RRC layer (eNB -> UE) |
|
171 lteSimpleHelper->m_enbRrc->SetArrivalTime (Seconds (0.010)); |
|
172 lteSimpleHelper->m_enbRrc->SetPduSize (100); |
|
173 |
|
174 // MAC sends transmission opportunities (TxOpp) |
|
175 lteSimpleHelper->m_enbMac->SetTxOppSize (150); |
|
176 lteSimpleHelper->m_enbMac->SetTxOppTime (Seconds (0.005)); |
|
177 lteSimpleHelper->m_enbMac->SetTxOpportunityMode (LteTestMac::RANDOM_MODE); |
|
178 |
|
179 // Sending packets from UE RRC layer (UE -> eNB) |
|
180 lteSimpleHelper->m_ueRrc->SetArrivalTime (Seconds (0.010)); |
|
181 lteSimpleHelper->m_ueRrc->SetPduSize (100); |
|
182 |
|
183 // MAC sends transmission opportunities (TxOpp) |
|
184 lteSimpleHelper->m_ueMac->SetTxOppSize (150); |
|
185 lteSimpleHelper->m_ueMac->SetTxOppTime (Seconds (0.005)); |
|
186 lteSimpleHelper->m_ueMac->SetTxOpportunityMode (LteTestMac::RANDOM_MODE); |
|
187 |
|
188 // Start/Stop pseudo-application at eNB RRC |
|
189 Simulator::Schedule (Seconds (0.100), &LteTestRrc::Start, lteSimpleHelper->m_enbRrc); |
|
190 Simulator::Schedule (Seconds (10.100), &LteTestRrc::Stop, lteSimpleHelper->m_enbRrc); |
|
191 |
|
192 // Start/Stop pseudo-application at UE RRC |
|
193 Simulator::Schedule (Seconds (20.100), &LteTestRrc::Start, lteSimpleHelper->m_ueRrc); |
|
194 Simulator::Schedule (Seconds (30.100), &LteTestRrc::Stop, lteSimpleHelper->m_ueRrc); |
|
195 |
|
196 |
|
197 Simulator::Stop (Seconds (31.000)); |
|
198 Simulator::Run (); |
|
199 |
|
200 uint32_t txEnbRrcPdus = lteSimpleHelper->m_enbRrc->GetTxPdus (); |
|
201 uint32_t rxUeRrcPdus = lteSimpleHelper->m_ueRrc->GetRxPdus (); |
|
202 |
|
203 uint32_t txUeRrcPdus = lteSimpleHelper->m_ueRrc->GetTxPdus (); |
|
204 uint32_t rxEnbRrcPdus = lteSimpleHelper->m_enbRrc->GetRxPdus (); |
|
205 |
|
206 // NS_LOG_INFO ("Seed = " << m_seed); |
|
207 // NS_LOG_INFO ("Losses (%) = " << uint32_t (m_losses * 100)); |
|
208 |
|
209 // NS_LOG_INFO ("dl dev drops = " << m_dlDrops); |
|
210 // NS_LOG_INFO ("ul dev drops = " << m_ulDrops); |
|
211 |
|
212 // NS_LOG_INFO ("eNB tx RRC count = " << txEnbRrcPdus); |
|
213 // NS_LOG_INFO ("eNB rx RRC count = " << rxEnbRrcPdus); |
|
214 // NS_LOG_INFO ("UE tx RRC count = " << txUeRrcPdus); |
|
215 // NS_LOG_INFO ("UE rx RRC count = " << rxUeRrcPdus); |
|
216 |
|
217 NS_LOG_INFO (m_seed << "\t" << m_losses << "\t" << txEnbRrcPdus << "\t" << rxUeRrcPdus << "\t" << m_dlDrops); |
|
218 NS_LOG_INFO (m_seed << "\t" << m_losses << "\t" << txUeRrcPdus << "\t" << rxEnbRrcPdus << "\t" << m_ulDrops); |
|
219 |
|
220 NS_TEST_ASSERT_MSG_EQ (txEnbRrcPdus, rxUeRrcPdus + m_dlDrops, |
|
221 "Downlink: TX PDUs (" << txEnbRrcPdus << ") != RX PDUs (" << rxUeRrcPdus << ") + DROPS (" << m_dlDrops << ")"); |
|
222 NS_TEST_ASSERT_MSG_EQ (txUeRrcPdus, rxEnbRrcPdus + m_ulDrops, |
|
223 "Uplink: TX PDUs (" << txUeRrcPdus << ") != RX PDUs (" << rxEnbRrcPdus << ") + DROPS (" << m_ulDrops << ")"); |
|
224 |
|
225 Simulator::Destroy (); |
|
226 } |