Browse Source

LTE module form GSoC project

ndnSIM-v1
Giuseppe Piro 15 years ago
parent
commit
87f01507ea
  1. 324
      doc/manual/lte.texi
  2. 16
      src/devices/lte/AUTHORS
  3. 219
      src/devices/lte/examples/lte-amc.cc
  4. 153
      src/devices/lte/examples/lte-channel-model.cc
  5. 179
      src/devices/lte/examples/lte-device.cc
  6. 237
      src/devices/lte/examples/lte-multiple-flows.cc
  7. 176
      src/devices/lte/examples/lte-phy-downlink.cc
  8. 172
      src/devices/lte/examples/lte-phy-uplink.cc
  9. 1
      src/devices/lte/examples/waf
  10. 27
      src/devices/lte/examples/wscript
  11. 323
      src/devices/lte/helper/lte-helper.cc
  12. 142
      src/devices/lte/helper/lte-helper.h
  13. 33
      src/devices/lte/model/JakesTraces/multipath_v0_M10.h
  14. 32
      src/devices/lte/model/JakesTraces/multipath_v0_M12.h
  15. 32
      src/devices/lte/model/JakesTraces/multipath_v0_M6.h
  16. 32
      src/devices/lte/model/JakesTraces/multipath_v0_M8.h
  17. 32
      src/devices/lte/model/JakesTraces/multipath_v120_M10.h
  18. 32
      src/devices/lte/model/JakesTraces/multipath_v120_M12.h
  19. 32
      src/devices/lte/model/JakesTraces/multipath_v120_M6.h
  20. 31
      src/devices/lte/model/JakesTraces/multipath_v120_M8.h
  21. 31
      src/devices/lte/model/JakesTraces/multipath_v30_M10.h
  22. 32
      src/devices/lte/model/JakesTraces/multipath_v30_M12.h
  23. 31
      src/devices/lte/model/JakesTraces/multipath_v30_M6.h
  24. 32
      src/devices/lte/model/JakesTraces/multipath_v30_M8.h
  25. 31
      src/devices/lte/model/JakesTraces/multipath_v3_M10.h
  26. 32
      src/devices/lte/model/JakesTraces/multipath_v3_M12.h
  27. 32
      src/devices/lte/model/JakesTraces/multipath_v3_M6.h
  28. 32
      src/devices/lte/model/JakesTraces/multipath_v3_M8.h
  29. 199
      src/devices/lte/model/amc-module.cc
  30. 93
      src/devices/lte/model/amc-module.h
  31. 170
      src/devices/lte/model/bearer-qos-parameters.cc
  32. 157
      src/devices/lte/model/bearer-qos-parameters.h
  33. 122
      src/devices/lte/model/channel-realization.cc
  34. 107
      src/devices/lte/model/channel-realization.h
  35. 94
      src/devices/lte/model/enb-lte-spectrum-phy.cc
  36. 56
      src/devices/lte/model/enb-lte-spectrum-phy.h
  37. 144
      src/devices/lte/model/enb-mac-entity.cc
  38. 86
      src/devices/lte/model/enb-mac-entity.h
  39. 225
      src/devices/lte/model/enb-net-device.cc
  40. 139
      src/devices/lte/model/enb-net-device.h
  41. 208
      src/devices/lte/model/enb-phy.cc
  42. 105
      src/devices/lte/model/enb-phy.h
  43. 188
      src/devices/lte/model/ideal-control-messages.cc
  44. 248
      src/devices/lte/model/ideal-control-messages.h
  45. 100
      src/devices/lte/model/loss-model.cc
  46. 92
      src/devices/lte/model/loss-model.h
  47. 109
      src/devices/lte/model/lte-mac-header.cc
  48. 74
      src/devices/lte/model/lte-mac-header.h
  49. 247
      src/devices/lte/model/lte-mac-queue.cc
  50. 156
      src/devices/lte/model/lte-mac-queue.h
  51. 411
      src/devices/lte/model/lte-net-device.cc
  52. 203
      src/devices/lte/model/lte-net-device.h
  53. 263
      src/devices/lte/model/lte-phy.cc
  54. 236
      src/devices/lte/model/lte-phy.h
  55. 157
      src/devices/lte/model/lte-propagation-loss-model.cc
  56. 91
      src/devices/lte/model/lte-propagation-loss-model.h
  57. 503
      src/devices/lte/model/lte-spectrum-phy.cc
  58. 218
      src/devices/lte/model/lte-spectrum-phy.h
  59. 152
      src/devices/lte/model/lte-spectrum-value-helper.cc
  60. 74
      src/devices/lte/model/lte-spectrum-value-helper.h
  61. 89
      src/devices/lte/model/mac-entity.cc
  62. 77
      src/devices/lte/model/mac-entity.h
  63. 333
      src/devices/lte/model/multipath-loss-model.cc
  64. 100
      src/devices/lte/model/multipath-loss-model.h
  65. 47
      src/devices/lte/model/multipath.h
  66. 112
      src/devices/lte/model/packet-scheduler.cc
  67. 96
      src/devices/lte/model/packet-scheduler.h
  68. 86
      src/devices/lte/model/path-loss-model.cc
  69. 65
      src/devices/lte/model/path-loss-model.h
  70. 74
      src/devices/lte/model/penetration-loss-model.cc
  71. 60
      src/devices/lte/model/penetration-loss-model.h
  72. 188
      src/devices/lte/model/radio-bearer-instance.cc
  73. 170
      src/devices/lte/model/radio-bearer-instance.h
  74. 109
      src/devices/lte/model/rlc-entity.cc
  75. 90
      src/devices/lte/model/rlc-entity.h
  76. 250
      src/devices/lte/model/rrc-entity.cc
  77. 133
      src/devices/lte/model/rrc-entity.h
  78. 89
      src/devices/lte/model/shadowing-loss-model.cc
  79. 71
      src/devices/lte/model/shadowing-loss-model.h
  80. 148
      src/devices/lte/model/simple-packet-scheduler.cc
  81. 63
      src/devices/lte/model/simple-packet-scheduler.h
  82. 138
      src/devices/lte/model/ue-lte-spectrum-phy.cc
  83. 56
      src/devices/lte/model/ue-lte-spectrum-phy.h
  84. 88
      src/devices/lte/model/ue-mac-entity.cc
  85. 58
      src/devices/lte/model/ue-mac-entity.h
  86. 174
      src/devices/lte/model/ue-manager.cc
  87. 108
      src/devices/lte/model/ue-manager.h
  88. 223
      src/devices/lte/model/ue-net-device.cc
  89. 128
      src/devices/lte/model/ue-net-device.h
  90. 224
      src/devices/lte/model/ue-phy.cc
  91. 109
      src/devices/lte/model/ue-phy.h
  92. 96
      src/devices/lte/model/ue-record.cc
  93. 119
      src/devices/lte/model/ue-record.h
  94. 123
      src/devices/lte/test/lte-bearer-test.cc
  95. 199
      src/devices/lte/test/lte-device-test.cc
  96. 189
      src/devices/lte/test/lte-phy-test.cc
  97. 221
      src/devices/lte/test/lte-propagation-loss-model-test.cc
  98. 85
      src/devices/lte/wscript

324
doc/manual/lte.texi

@ -0,0 +1,324 @@
@node LTE Module
@chapter LTE Module
@anchor{chap:lte}
This chapter describes the ns-3 LteNetDevice and related models.
By adding LteNetDevice objects to ns-3 nodes, one can create models of 3GPP E-UTRAN infrastructure
and Long Term Evolution (LTE) networks.
Below, we list some more details about what
ns-3 LTE models cover but, in summary, the most important features
of the ns-3 model are:
@itemize @bullet
@item a standard compliant physical layer and channel model
@item a Radio Resouce Control (RRC) entity for the LTE net device
@item a MAC layer for both User Equipment (UE) and evolved Node B (eNB) devices
@item an efficient Adaptive Modulation and Coding (AMC) scheme for the downlink
@item an implementation of radio bearer, bearer qos parameters, MAC queue, and Radio Link Control Entity
@item an outdoor E-UTRAN propagation loss model
@item Channel Quality Indicator (CQI) management and ideal control messages
@end itemize
@menu
* lte-Model Description::
* lte-Usage::
* lte-Validation::
@end menu
@node lte-Model Description
@section Model Description
The source code for the LTE models lives in the directory
@code{src/devices/lte}.
@menu
* lte-Design::
* lte-Scope and Limitations::
* lte-Future Work::
* lte-References::
@end menu
@node lte-Design
@subsection Design
The LTE model has been developed in order to simulate a downlink transmission over the E-UTRAN network interfacei (composed by two type of nodes: the User Equipment (UE) and evolved Node B (eNB)). To this aim, the definition of standard compliant PHY and MAC models were a crucial rule the module design.
The PHY layer, has been developed extending the Spectrum Frameworki [1]. The MAC model, instead, as been developed extending and adding some features to the base class @code{ns3::NetDevice}.
@subsubsection Physical layer
A @code{ns3::LtePhy} class models the LTE PHY layer.
Basic functionalities of the PHY layer are: (i) transmit packets coming from the device to the channel; (ii) receive packets from the channel; (ii) evaluate the quality of the channel from the Signal To Noise ratio of the received signal; and (iii) forward received packets to the device.
Both the PHY and channel have been developed exending @code{ns3::SpectrumPhy} and @code{ns3::SpectrumChannel} classes, respectively.
The module implements an FDD channel access. In FDD channel access, downlink and uplink transmissions work together in the time but using a different set of frequencies.
Since DL and UL are indipendent between them, the PHY is composed by couple of LteSpectrumPhy object (i.e., implemented into the @code{ns3::LteSpectrumPhy} class); one for the downlink and one for the uplink.
The LtePhy stores and manages both downlink and uplink LteSpectrumPhy elements.
In order to customize all physical functionalities for both UE and eNB devices, dedicated classes have been inherited from ones described before. In particular, UePhy and EnbPhy classes, inherited from the LtePhy class, implement the PHY layer for the UE and the eNB, respectively. In the same way, UeLteSpectrumPhy and EnbLteSpectrumPhy classes, inherited from the LteSpectrumPhy, implement the downlink/uplink spectrum channel for the UE and the eNB, respectively.
Fig, @ref{fig:lte-transmission} shows how UE and eNB can exchange packets througth the considered PHY layer.
@float Figure,fig:lte-transmission
@caption{DL and UL transmision on the LTE network}
@image{figures/lte-transmission,,3in}
@end float
For the downlink, when the eNB whants to send packets, it calls StartTx function to send them into the downlink channel. Then, the downlink channel delivers the burst of packets to all the UeLteSpectrumPhy attached to it, handling the StartRx function. When the UE receives packets, it executes the follos tasks:
@itemize @bullet
@item compute the SINR for all the sub channel used in the downlink
@item create and send CQI feedbacks
@item forward all the received packets to the device
@end itemize
The uplink works similary to the previous one.
@subsubsection Propagation Loss Models
A proper propagation loss model has been developed for the LTE E-UTRAN interface [2][3].
It is used by the PHY layer to compute the loss due to the propagation.
The LTE propagation loss model is composed by 4 different models (shadowing, multipath, penetration loss and path loss) [2]:
@itemize @bullet
@item Pathloss: PL = 128.1 + (37.6 * log10 (R)), where R is the distance between the UE and the eNB in Km.
@item Multipath: Jakes model
@item PenetrationLoss: 10 dB
@item Shadowing: log-normal distribution (mean=0dB, standard deviation=8dB)
@end itemize
Every time that the LteSpectrumPHY::StartRx () function is called, the SpectrumInterferenceModel is used to computed the SINR, as proposed in [3]. Then, the network device uses the AMC module to map the SINR to a proper CQI and to send it to the eNB using the ideal control channel.
@subsubsection LTE Devices
All the common functionalities of the LTE network devices have been defined into the @code{ns3::LteNetDevice} class. Moreover, the LTE device has been conceived as a container of several entities such as MAC, RRC, RLC etc .. For each of these entity a dedicated class has been developed.
For each device are defined the following entity/element
@itemize @bullet
@item the LTE PHY layer (described in the previous sub section)
@item rrc entity
@item mac entity
@item rlc entity
@end itemize
The module is perfectly integrated into the whole ns-3 project: it is already possible to attach to each device a TCP/IP protocol stack and all the implemented applications (i.e., udp client/server, trace based, etc..).
@subsubsection The RRC Entity
The RRC entity manages all active downlink and uplink radio bearer for a given device.
For each radio bearer, a MAC queue has been developed to store packets coming
from the upper layer and that whait for the transmission.
In general, to each flow should be created a dedicated radio bearer. Furthermore, actually only one radio bearer has been created for each device. All packet that arrive from the upper layer, will be enqueued into this default bearer, independently form the aplication whose generated it.
@subsubsection The MAC Entity
Class @code{ns3::MacEntity} provides a basic implementation of the MAC entity for the LTE device. Moreover, @code{ns3::EnbMacEntity} and @code{ns3::UeMacEntity} classes, inherited from the previous one, provides an implementation for the eNB and the UE MAC entity, respectively.
In all MAC entities is defined the AMC module [4]. Furthermore, into the @code{ns3::EnbMacEntity} class are defined also both uplink and downlink schedulers.
Every time the PHY layer of the UE receives a packet form the channel, it calls the AMC module, define into the MAC entity, in order to convert the SINR of the received signal to CQI feedbacks.
Every sub frame, the eNB performs both uplink and downlink radio resource allocation. Actually only a simple packet scheduler has been implemented that is able to send, every sub frame, only one packet in the downlink.
@subsubsection The RLC Entity
The RLC entity performs an interface between the MAC layer and the MAC queue for a given bearer. Actually, only the RLC Transport Mode has been implemented.
@subsubsection Control Channel
Control channel keeps a very important role in LTE networks. In fact, it is responsible of the transmission of several information (i.e., CQI feedback, allocation map, etc...). For this reason, also in a framework oriented to data transmision, it is necesary to find a tecnique for exchange these information. To this aim, an ideal control channel will be developed.
Using ideal control messages, both UE and eNB can exchange control information without simulating a realistic transmission over the LTE channel.
Two types of control messages have been implemented: the Pdcch Map Ideal Control Message and the Cqi Ideal Control Message. The first one is used by the eNB to send the uplink and downlink resource mapping to all registered UE. In particular, this message carries information about UEs that have been scheduled in the ul/dl, a list of assigned sub channels and the selected MCS for the transmission.
The second one, instead, is used by the UE to send CQI feedbacks to the eNB.
@node lte-Scope and Limitations
@subsection Scope and Limitations
The framework has been designed in order to support data transmission for both uplink and downlink. It is important to note that downlin and uplink transmissions are managed by the packet scheduler that works at the eNB. It decides, in fact, what UEs should be scheduled every TTI and what radio resource should be allocated to them.
In the current implementation, the downlink transmission is administrated by the downlink packet scheduler. Furthermore, no packet scheduler for uplink transmission has been developed.
As a consequence, for the downlink packet are sent only after scheduling decisions; for the uplink, instead, packet are sent directly, without any scheduling decisions.
Finally, the transmission of control messages (such as CQI feedbacks, PDCCH, etc..) is done by an ideal control channel.
@node lte-Future Work
@subsection Future Work
In the future, several LTE features will be developed in order to improve the proposed module.
In particular, for the near future have been scheduled the following implementations:
- a complete packet scheduler (i.e., a simple round robin scheme) for both downlink and uplink, in order to support a standard compliant packet transmission
- ideal PDCCH control messages
- a standard compliant RLC entity
- PHY error model
@node lte-References
@subsection References
@enumerate
@item N. Baldo and M. Miozzo, Spectrum-aware Channel and PHY layer modeling for ns3, Proceedings of ICST NSTools 2009, Pisa, Italy.
The framework is designed to simulate only data transmissions. For the transmission of control messages (such as CQI feedback, PDCCH, etc..) will be used an ideal control channel).
@item 3GPP TS 25.814 ( http://www.3gpp.org/ftp/specs/html-INFO/25814.htm )
@item Giuseppe Piro, Luigi Alfredo Grieco, Gennaro Boggia, and Pietro Camarda", A Two-level Scheduling Algorithm for QoS Support in the Downlink of LTE Cellular Networks", Proc. of European Wireless, EW2010, Lucca, Italy, Apr., 2010 ( draft version is available on http://telematics.poliba.it/index.php?option=com_jombib&task=showbib&id=330)
@item 3GPP R1-081483 (available on @*
http://www.3gpp.org/ftp/tsg_ran/WG1_RL1/TSGR1_52b/Docs/R1-081483.zip)
@end enumerate
@node lte-Usage
@section Usage
The main way that users who write simulation scripts will typically
interact with the LTE models is through the helper API and through
the publicly visible attributes of the model.
The helper API is defined in @code{src/helper/lte-helper{cc,h}}.
The example @code{examples/lte/} contain some basic
code that shows how to set up the model in order to simualte an E-UTRAN downlink transmission.
@menu
* lte-Examples::
* lte-Helpers::
* lte-Attributes::
* lte-Tracing::
* lte-Logging::
* lte-Caveats::
@end menu
@node lte-Examples
@subsection Examples
@code{examples/lte/lte.device.cc} shows how it is possible to set up the LTE module:
@smallformat
@example
NodeContainer ueNodes;
NodeContainer enbNodes;
ueNodes.Create (1);
enbNodes.Create (1);
LteHelper lte;
NetDeviceContainer ueDevs, enbDevs;
ueDevs = lte.Install (ueNodes, LteHelper::DEVICE_TYPE_USER_EQUIPMENT);
enbDevs = lte.Install (enbNodes, LteHelper::DEVICE_TYPE_ENODEB);
@end example
@end smallformat
The helper method @code{Install} creates LTE device, the DL, UL physical layer and attach the to proper LTE channels.
Moreover, to simulate a complete LTE system, it is necessary to define other information, as expressed in what follows:
(i) install IP protocol stack
@smallformat
@example
InternetStackHelper stack;
stack.Install (ueNodes);
stack.Install (enbNodes);
Ipv4AddressHelper address;
address.SetBase ("10.1.1.0", "255.255.255.0");
Ipv4InterfaceContainer UEinterfaces = address.Assign (ueDevs);
Ipv4InterfaceContainer ENBinterface = address.Assign (enbDevs);
@end example
@end smallformat
(ii) register UE to a given eNB
@smallformat
@example
Ptr<EnbNetDevice> enb = enbDevs.Get (0)->GetObject<EnbNetDevice> ();
Ptr<UeNetDevice> ue = ueDevs.Get (i)->GetObject<UeNetDevice> ();
lte.RegisterUeToTheEnb (ue, enb);
@end example
@end smallformat
(ii) create the mobility model for each device
@smallformat
@example
Ptr<ConstantPositionMobilityModel> enbMobility = new ConstantPositionMobilityModel ();
enbMobility->SetPosition (Vector (0.0, 0.0, 0.0));
lte.AddMobility (enb->GetPhy (), enbMobility);
Ptr<ConstantVelocityMobilityModel> ueMobility = new ConstantVelocityMobilityModel ();
ueMobility->SetPosition (Vector (30.0, 0.0, 0.0));
ueMobility->SetVelocity (Vector (30.0, 0.0, 0.0));
lte.AddMobility (ue->GetPhy (), ueMobility);
@end example
@end smallformat
(iii) define a set of sub channels to use for dl and ul transmission
@smallformat
@example
std::vector<int> dlSubChannels;
for (int i = 0; i < 25; i++)
{
dlSubChannels.push_back (i);
}
std::vector<int> ulSubChannels;
for (int i = 50; i < 100; i++)
{
ulSubChannels.push_back (i);
}
enb->GetPhy ()->SetDownlinkSubChannels (dlSubChannels);
enb->GetPhy ()->SetUplinkSubChannels (ulSubChannels);
ue->GetPhy ()->SetDownlinkSubChannels (dlSubChannels);
ue>GetPhy ()->SetUplinkSubChannels (ulSubChannels);
@end example
@end smallformat
(iv) define a channel realization for the PHY model
@smallformat
@example
lte.AddDownlinkChannelRealization (enbMobility, ueMobility, ue->GetPhy ());
@end example
@end smallformat
@node Helpers
@subsection Helpers
@node lte-Attributes
@subsection Attributes
@node lte-Tracing
@subsection Tracing
@node lte-Logging
@subsection Logging
@node lte-Caveats
@subsection Caveats
@node lte-Validation
@section Validation
This model has been tested as follows...
Large scale tests [have|have not] been performed with lots of nodes and
devices.

16
src/devices/lte/AUTHORS

@ -0,0 +1,16 @@
Giuseppe Piro
===============
Module manager and main developer
2010
TELEMATICS LAB, Politecnico di Bari
G.Piro@poliba.it
The module has been firtly developed with
the support of Google Summer of Code Program,
under the supervision of
Nicola Baldo (n.baldo@cttc.es)
and Marco Miozzo (m.miozzo@cttc.es)

219
src/devices/lte/examples/lte-amc.cc

@ -0,0 +1,219 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Giuseppe Piro <g.piro@poliba.it>
*/
/*
* Test for LTE AMC module
*/
#include <iostream>
#include <vector>
#include <ns3/core-module.h>
#include <ns3/common-module.h>
#include <ns3/node-module.h>
#include <ns3/simulator-module.h>
#include <ns3/log.h>
#include <string>
#include <ns3/mobility-module.h>
#include <ns3/spectrum-helper.h>
#include <ns3/helper-module.h>
#include <ns3/lte-helper.h>
#include <ns3/enb-phy.h>
#include <ns3/ue-phy.h>
#include <ns3/packet-burst.h>
#include <ns3/constant-position-mobility-model.h>
#include <ns3/constant-velocity-mobility-model.h>
#include "ns3/single-model-spectrum-channel.h"
#include "ns3/lte-spectrum-phy.h"
#include "ns3/enb-lte-spectrum-phy.h"
#include "ns3/ue-lte-spectrum-phy.h"
#include "ns3/ue-net-device.h"
#include "ns3/enb-net-device.h"
#include "ns3/ue-manager.h"
#include "ns3/spectrum-propagation-loss-model.h"
#include "ns3/lte-propagation-loss-model.h"
#include "ns3/lte-spectrum-value-helper.h"
#include "ns3/amc-module.h"
NS_LOG_COMPONENT_DEFINE ("TestAmcModule");
using namespace ns3;
int main (int argc, char** argv)
{
/*
* This example shows how the AMC module works.
*
* The value of the CQI feedback and the selected MCS is
* reported varying the SINR value.
*
* We suppose that
* - the eNB uses 50 sub channels for downlink transmission
* - the total power transmission is equal to 43 dbM and it is distributed uniformly among dl sub channels
*
* We analyze how the SINR value, estimated by the UE varying its distance form the eNB,
* impacts on the CQI value and the MCS selected by the AMC
*/
LogComponentEnable ("LtePropagationLossModel", LOG_LEVEL_ALL);
std::cout << "AMC MODULE" << std::endl;
LteSpectrumValueHelper h;
double powerTx = 43; // in dBm
// Define a list of sub channels for the downlink
std::vector<int> channels;
for (int i = 0; i < 50; i++)
{
channels.push_back (i);
}
Ptr<SpectrumValue> psdTx = h.CreateDownlinkTxPowerSpectralDensity (powerTx, channels);
Ptr<SpectrumValue> psdNoise = h.CreateDownlinkNoisePowerSpectralDensity ();
// DEFINE THE LTE PROPAGATION LOSS MODEL
LtePropagationLossModel lossModel;
// CREATE UE PHYSICAL LAYER
Ptr<UeLtePhy> uePhy = CreateObject<UeLtePhy> ();
Ptr<UeLteSpectrumPhy> dl = CreateObject<UeLteSpectrumPhy> ();
uePhy->SetDownlinkSubChannels (channels);
uePhy->SetDownlinkSpectrumPhy (dl);
// DEFINE THE AMC MODULE
AmcModule amc;
// CONFIGURE MOBILITY
Ptr<ConstantPositionMobilityModel> enbMobility = CreateObject<ConstantPositionMobilityModel> ();
enbMobility->SetPosition (Vector (0.0, 0.0, 0.0));
for (int distance = 30; distance < 1000; distance = distance + 30)
{
std::cout << "Test AMC module for distance ue-enb = " << distance << " m" << std::endl;
Ptr<ConstantVelocityMobilityModel> ueMobility = CreateObject<ConstantVelocityMobilityModel> ();
ueMobility->SetPosition (Vector (distance, 0.0, 0.0));
ueMobility->SetVelocity (Vector (30.0, 0.0, 0.0));
uePhy->GetDownlinkSpectrumPhy ()->SetMobility (ueMobility);
lossModel.CreateChannelRealization (enbMobility, ueMobility);
Ptr<JakesFadingLossModel> m = lossModel.GetChannelRealization (enbMobility, ueMobility)->GetJakesFadingLossModel ();
m->SetPhy (uePhy);
// ADD PROPAGATION LOSS
Ptr<SpectrumValue> psdRx = lossModel.CalcRxPowerSpectralDensity (psdTx, enbMobility, ueMobility);
// Compute SINR
std::vector<double> sinr, rx, n;
std::cout << "POWER TX: " << std::endl;
for (Values::const_iterator it = psdRx->ConstValuesBegin ();
it != psdRx->ConstValuesEnd (); it++ )
{
double power; // power transmission for the current sub channel [dB]
if ((*it) != 0.)
{
power = (*it);
power = 10 * log10 (180000. * power);
}
else
{
power = 0.;
}
rx.push_back (power);
std::cout << " " << power;
}
std::cout << std::endl;
std::cout << "NOISE: " << std::endl;
for (Values::const_iterator it = psdNoise->ConstValuesBegin ();
it != psdNoise->ConstValuesEnd (); it++ )
{
double noise = (*it);
noise = 10 * log10 (180000. * noise);
n.push_back (noise);
std::cout << " " << noise;
}
std::cout << std::endl;
int subChannels = rx.size ();
std::cout << "SINR: ";
for (int i = 0; i < subChannels; i++)
{
if (rx.at (i) != 0)
{
double sinr_ = rx.at (i) - n.at (i);
sinr.push_back (sinr_);
std::cout << " " << sinr_;
}
}
std::cout << std::endl;
// COMPUTE THE CQI value
std::vector<int> cqi = amc.CreateCqiFeedbacks (sinr);
int feedbacks = cqi.size ();
std::cout << "CQI: ";
for (int i = 0; i < feedbacks; i++)
{
std::cout << " " << cqi.at (i);
}
std::cout << std::endl;
// COMPUTE THE MCS scheme
std::cout << "MCS: ";
for (int i = 0; i < feedbacks; i++)
{
std::cout << " " << amc.GetMcsFromCqi (cqi.at (i));
}
std::cout << std::endl;
// COMPUTE THE TRANSPORT BLOCK SIZE
std::cout << "TB: ";
for (int i = 0; i < feedbacks; i++)
{
std::cout << " " << amc.GetTbSizeFromMcs (amc.GetMcsFromCqi (cqi.at (i)));
}
std::cout << std::endl;
}
Simulator::Destroy ();
return 0;
}

153
src/devices/lte/examples/lte-channel-model.cc

@ -0,0 +1,153 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Giuseppe Piro <g.piro@poliba.it>
*/
/*
* Test for the LTE DL Channel Model
*/
#include <iostream>
#include <vector>
#include <ns3/core-module.h>
#include <ns3/common-module.h>
#include <ns3/node-module.h>
#include <ns3/simulator-module.h>
#include <ns3/log.h>
#include <string>
#include <ns3/mobility-module.h>
#include <ns3/spectrum-helper.h>
#include <ns3/helper-module.h>
#include <ns3/lte-helper.h>
#include <ns3/enb-phy.h>
#include <ns3/ue-phy.h>
#include <ns3/packet-burst.h>
#include <ns3/constant-position-mobility-model.h>
#include <ns3/constant-velocity-mobility-model.h>
#include "ns3/single-model-spectrum-channel.h"
#include "ns3/lte-spectrum-phy.h"
#include "ns3/enb-lte-spectrum-phy.h"
#include "ns3/ue-lte-spectrum-phy.h"
#include "ns3/ue-net-device.h"
#include "ns3/enb-net-device.h"
#include "ns3/ue-manager.h"
#include "ns3/spectrum-propagation-loss-model.h"
#include "ns3/lte-propagation-loss-model.h"
NS_LOG_COMPONENT_DEFINE ("TestChannelModel");
using namespace ns3;
int main (int argc, char** argv)
{
LogComponentEnable ("LtePropagationLossModel", LOG_LEVEL_ALL);
// CREATE PHY LAYER FOR BOTH UE AND ENB
Ptr<EnbLtePhy> phyEnb = CreateObject<EnbLtePhy> ();
Ptr<EnbLteSpectrumPhy> dlEnb = CreateObject<EnbLteSpectrumPhy> ();
Ptr<EnbLteSpectrumPhy> ulEnb = CreateObject<EnbLteSpectrumPhy> ();
phyEnb->SetDownlinkSpectrumPhy (dlEnb);
phyEnb->SetUplinkSpectrumPhy (ulEnb);
phyEnb->SetTxPower (43);
Ptr<UeLtePhy> phyUe = CreateObject<UeLtePhy> ();
Ptr<UeLteSpectrumPhy> dlUe = CreateObject<UeLteSpectrumPhy> ();
Ptr<UeLteSpectrumPhy> ulUe = CreateObject<UeLteSpectrumPhy> ();
phyUe->SetDownlinkSpectrumPhy (dlUe);
phyUe->SetUplinkSpectrumPhy (ulUe);
// CONFIGURE MOBILITY
Ptr<ConstantPositionMobilityModel> enbMobility = CreateObject<ConstantPositionMobilityModel> ();
enbMobility->SetPosition (Vector (0.0, 0.0, 0.0));
phyEnb->GetDownlinkSpectrumPhy ()->SetMobility (enbMobility);
phyEnb->GetUplinkSpectrumPhy ()->SetMobility (enbMobility);
Ptr<ConstantVelocityMobilityModel> ueMobility = CreateObject<ConstantVelocityMobilityModel> ();
ueMobility->SetPosition (Vector (30.0, 0.0, 0.0));
ueMobility->SetVelocity (Vector (30.0, 0.0, 0.0));
phyUe->GetDownlinkSpectrumPhy ()->SetMobility (ueMobility);
phyUe->GetUplinkSpectrumPhy ()->SetMobility (ueMobility);
// CONFIGURE DL and UL SUB CHANNELS
// Define a list of sub channels for the downlink
std::vector<int> dlSubChannels;
for (int i = 0; i < 25; i++)
{
dlSubChannels.push_back (i);
}
// Define a list of sub channels for the uplink
std::vector<int> ulSubChannels;
for (int i = 50; i < 100; i++)
{
ulSubChannels.push_back (i);
}
phyEnb->SetDownlinkSubChannels (dlSubChannels);
phyEnb->SetUplinkSubChannels (ulSubChannels);
phyUe->SetDownlinkSubChannels (dlSubChannels);
phyUe->SetUplinkSubChannels (ulSubChannels);
// CREATE CHANNEL AND ATTACH DEVICE BY ITS, create also PROPAGATION LOSS MODEL
Ptr<SingleModelSpectrumChannel> downlinkChannel = CreateObject<SingleModelSpectrumChannel> ();
Ptr<SingleModelSpectrumChannel> uplinkChannel = CreateObject<SingleModelSpectrumChannel> ();
dlUe->SetChannel (downlinkChannel);
ulUe->SetChannel (uplinkChannel);
downlinkChannel->AddRx (dlUe);
dlEnb->SetChannel (downlinkChannel);
ulEnb->SetChannel (uplinkChannel);
downlinkChannel->AddRx (dlEnb);
uplinkChannel->AddRx (ulEnb);
Ptr<LtePropagationLossModel> mobility = CreateObject<LtePropagationLossModel> ();
downlinkChannel->AddSpectrumPropagationLossModel (mobility->GetObject<SpectrumPropagationLossModel> ());
mobility->CreateChannelRealization (enbMobility, ueMobility);
// initialize multipath model
Ptr<JakesFadingLossModel> m = mobility->GetChannelRealization (enbMobility, ueMobility)->GetJakesFadingLossModel ();
m->SetPhy (phyUe);
/*
* ******************
* analyze the propagation loss model
* ******************
*/
Ptr<SpectrumValue> txPsd = phyEnb->CreateTxPowerSpectralDensity ();
Ptr<SpectrumValue> rxPsd = mobility->CalcRxPowerSpectralDensity (txPsd,enbMobility, ueMobility);
Simulator::Destroy ();
return 0;
}

179
src/devices/lte/examples/lte-device.cc

@ -0,0 +1,179 @@
// +-----+ +-----+ +-----+
// | UE0 | | UE1 | | UE2 |
// +-----+ +-----+ +-----+
// 10.1.1.1 10.1.1.2 10.1.1.3
// -------- -------- -------
// ((*)) ((*)) ((*))
//
// 10.1.1.4
// +------------+
// |eNB | ==((*))
// +------------+
#include "ns3/core-module.h"
#include "ns3/common-module.h"
#include "ns3/node-module.h"
#include "ns3/helper-module.h"
#include "ns3/mobility-module.h"
#include "ns3/contrib-module.h"
#include "ns3/lte-module.h"
#include <iostream>
#include "ns3/global-route-manager.h"
NS_LOG_COMPONENT_DEFINE ("lte-device");
using namespace ns3;
int main (int argc, char *argv[])
{
// default values
int nbUE = 3;
LteHelper lte;
//lte.EnableLogComponents ();
LogComponentEnable ("UdpClient", LOG_LEVEL_INFO);
LogComponentEnable ("UdpServer", LOG_LEVEL_INFO);
// CREATE NODE CONTAINER AND CREATE LTE NODES
NodeContainer ueNodes;
NodeContainer enbNodes;
ueNodes.Create (nbUE);
enbNodes.Create (1);
// CREATE DEVICE CONTAINER, INSTALL DEVICE TO NODE
NetDeviceContainer ueDevs, enbDevs;
ueDevs = lte.Install (ueNodes, LteHelper::DEVICE_TYPE_USER_EQUIPMENT);
enbDevs = lte.Install (enbNodes, LteHelper::DEVICE_TYPE_ENODEB);
// INSTALL INTERNET STACKS
InternetStackHelper stack;
stack.Install (ueNodes);
stack.Install (enbNodes);
Ipv4AddressHelper address;
address.SetBase ("10.1.1.0", "255.255.255.0");
Ipv4InterfaceContainer UEinterfaces = address.Assign (ueDevs);
Ipv4InterfaceContainer ENBinterface = address.Assign (enbDevs);
// MANAGE LTE NET DEVICES
Ptr<EnbNetDevice> enb;
enb = enbDevs.Get (0)->GetObject<EnbNetDevice> ();
Ptr<UeNetDevice> ue[nbUE];
for (int i = 0; i < nbUE; i++)
{
ue[i] = ueDevs.Get (i)->GetObject<UeNetDevice> ();
lte.RegisterUeToTheEnb (ue[i], enb);
}
// CONFIGURE DL and UL SUB CHANNELS
// Define a list of sub channels for the downlink
std::vector<int> dlSubChannels;
for (int i = 0; i < 25; i++)
{
dlSubChannels.push_back (i);
}
// Define a list of sub channels for the uplink
std::vector<int> ulSubChannels;
for (int i = 50; i < 100; i++)
{
ulSubChannels.push_back (i);
}
enb->GetPhy ()->SetDownlinkSubChannels (dlSubChannels);
enb->GetPhy ()->SetUplinkSubChannels (ulSubChannels);
for (int i = 0; i < nbUE; i++)
{
ue[i]->GetPhy ()->SetDownlinkSubChannels (dlSubChannels);
ue[i]->GetPhy ()->SetUplinkSubChannels (ulSubChannels);
}
// CONFIGURE MOBILITY
Ptr<ConstantPositionMobilityModel> enbMobility = CreateObject<ConstantPositionMobilityModel> ();
enbMobility->SetPosition (Vector (0.0, 0.0, 0.0));
lte.AddMobility (enb->GetPhy (), enbMobility);
for (int i = 0; i < nbUE; i++)
{
Ptr<ConstantVelocityMobilityModel> ueMobility = CreateObject<ConstantVelocityMobilityModel> ();
ueMobility->SetPosition (Vector (30.0, 0.0, 0.0));
ueMobility->SetVelocity (Vector (30.0, 0.0, 0.0));
lte.AddMobility (ue[i]->GetPhy (), ueMobility);
lte.AddDownlinkChannelRealization (enbMobility, ueMobility, ue[i]->GetPhy ());
}
// CONGIFURE CLIENT SERVER APPLICATION
UdpServerHelper udpServer;
ApplicationContainer serverApp;
UdpClientHelper udpClient;
ApplicationContainer clientApp;
udpServer = UdpServerHelper (100);
serverApp = udpServer.Install (ueNodes.Get (0));
serverApp.Start (Seconds (0.02));
serverApp.Stop (Seconds (2));
udpClient = UdpClientHelper (UEinterfaces.GetAddress (0), 100);
udpClient.SetAttribute ("MaxPackets", UintegerValue (1200));
udpClient.SetAttribute ("Interval", TimeValue (Seconds (0.12)));
udpClient.SetAttribute ("PacketSize", UintegerValue (800));
clientApp = udpClient.Install (enbNodes.Get (0));
clientApp.Start (Seconds (0.01));
clientApp.Stop (Seconds (2));
//CREATE RADIO BEARER
Ptr<RadioBearerInstance> bearer = CreateObject<RadioBearerInstance> ();
bearer->SetBearerDirection (RadioBearerInstance::DIRECTION_TYPE_DL);
bearer->SetBearerType (RadioBearerInstance::BEARER_TYPE_DRB);
IpcsClassifierRecord *ipcs = new IpcsClassifierRecord (UEinterfaces.GetAddress (0),
"255.255.255.0",
ENBinterface.GetAddress (0),
"255.255.255.0",
100, 100, 0, 10000, 17, 1);
bearer->SetIpcsClassifierRecord (ipcs);
enb->GetRrcEntity ()->AddDownlinkNgbrBearer (bearer);
std::cout << "Starting simulation....." << std::endl;
Simulator::Stop (Seconds (2.0));
Simulator::Run ();
Simulator::Destroy ();
std::cout << "Done." << std::endl;
return 0;
}

237
src/devices/lte/examples/lte-multiple-flows.cc

@ -0,0 +1,237 @@
// +-----+ +-----+ +-----+
// | UE0 | | UE1 | | UE2 |
// +-----+ +-----+ +-----+
// 10.1.1.1 10.1.1.2 10.1.1.3
// -------- -------- -------
// ((*)) ((*)) ((*))
//
// 10.1.1.4
// +------------+
// |eNB | ==((*))
// +------------+
#include "ns3/core-module.h"
#include "ns3/common-module.h"
#include "ns3/node-module.h"
#include "ns3/helper-module.h"
#include "ns3/mobility-module.h"
#include "ns3/contrib-module.h"
#include "ns3/lte-module.h"
#include <iostream>
#include "ns3/global-route-manager.h"
NS_LOG_COMPONENT_DEFINE ("lte-device");
using namespace ns3;
int main (int argc, char *argv[])
{
// default values
int nbUE = 3;
LteHelper lte;
//lte.EnableLogComponents ();
LogComponentEnable ("UdpClient", LOG_LEVEL_INFO);
LogComponentEnable ("UdpServer", LOG_LEVEL_INFO);
// CREATE NODE CONTAINER AND CREATE LTE NODES
NodeContainer ueNodes;
NodeContainer enbNodes;
ueNodes.Create (nbUE);
enbNodes.Create (1);
// CREATE DEVICE CONTAINER, INSTALL DEVICE TO NODE
NetDeviceContainer ueDevs, enbDevs;
ueDevs = lte.Install (ueNodes, LteHelper::DEVICE_TYPE_USER_EQUIPMENT);
enbDevs = lte.Install (enbNodes, LteHelper::DEVICE_TYPE_ENODEB);
// INSTALL INTERNET STACKS
InternetStackHelper stack;
stack.Install (ueNodes);
stack.Install (enbNodes);
Ipv4AddressHelper address;
address.SetBase ("10.1.1.0", "255.255.255.0");
Ipv4InterfaceContainer UEinterfaces = address.Assign (ueDevs);
Ipv4InterfaceContainer ENBinterface = address.Assign (enbDevs);
// MANAGE LTE NET DEVICES
Ptr<EnbNetDevice> enb;
enb = enbDevs.Get (0)->GetObject<EnbNetDevice> ();
Ptr<UeNetDevice> ue[nbUE];
for (int i = 0; i < nbUE; i++)
{
ue[i] = ueDevs.Get (i)->GetObject<UeNetDevice> ();
lte.RegisterUeToTheEnb (ue[i], enb);
}
// CONFIGURE DL and UL SUB CHANNELS
// Define a list of sub channels for the downlink
std::vector<int> dlSubChannels;
for (int i = 0; i < 25; i++)
{
dlSubChannels.push_back (i);
}
// Define a list of sub channels for the uplink
std::vector<int> ulSubChannels;
for (int i = 50; i < 100; i++)
{
ulSubChannels.push_back (i);
}
enb->GetPhy ()->SetDownlinkSubChannels (dlSubChannels);
enb->GetPhy ()->SetUplinkSubChannels (ulSubChannels);
for (int i = 0; i < nbUE; i++)
{
ue[i]->GetPhy ()->SetDownlinkSubChannels (dlSubChannels);
ue[i]->GetPhy ()->SetUplinkSubChannels (ulSubChannels);
}
// CONFIGURE MOBILITY
Ptr<ConstantPositionMobilityModel> enbMobility = CreateObject<ConstantPositionMobilityModel> ();
enbMobility->SetPosition (Vector (0.0, 0.0, 0.0));
lte.AddMobility (enb->GetPhy (), enbMobility);
for (int i = 0; i < nbUE; i++)
{
Ptr<ConstantVelocityMobilityModel> ueMobility = CreateObject<ConstantVelocityMobilityModel> ();
ueMobility->SetPosition (Vector (30.0, 0.0, 0.0));
ueMobility->SetVelocity (Vector (30.0, 0.0, 0.0));
lte.AddMobility (ue[i]->GetPhy (), ueMobility);
lte.AddDownlinkChannelRealization (enbMobility, ueMobility, ue[i]->GetPhy ());
}
//******* FLOW N° 1 *********
UdpServerHelper udpServer_1;
ApplicationContainer serverApp_1;
UdpClientHelper udpClient_1;
ApplicationContainer clientApp_1;
udpServer_1 = UdpServerHelper (100);
serverApp_1 = udpServer_1.Install (ueNodes.Get (0));
serverApp_1.Start (Seconds (0.02));
serverApp_1.Stop (Seconds (2));
udpClient_1 = UdpClientHelper (UEinterfaces.GetAddress (0), 100);
udpClient_1.SetAttribute ("MaxPackets", UintegerValue (1200));
udpClient_1.SetAttribute ("Interval", TimeValue (Seconds (0.12)));
udpClient_1.SetAttribute ("PacketSize", UintegerValue (800));
clientApp_1 = udpClient_1.Install (enbNodes.Get (0));
clientApp_1.Start (Seconds (0.01));
clientApp_1.Stop (Seconds (2));
Ptr<RadioBearerInstance> bearer_1 = CreateObject<RadioBearerInstance> ();
bearer_1->SetBearerDirection (RadioBearerInstance::DIRECTION_TYPE_DL);
bearer_1->SetBearerType (RadioBearerInstance::BEARER_TYPE_DRB);
IpcsClassifierRecord *ipcs_1 = new IpcsClassifierRecord (UEinterfaces.GetAddress (0),
"255.255.255.0",
ENBinterface.GetAddress (0),
"255.255.255.0",
100, 100, 0, 10000, 17, 1);
bearer_1->SetIpcsClassifierRecord (ipcs_1);
enb->GetRrcEntity ()->AddDownlinkNgbrBearer (bearer_1);
//******* FLOW N° 2 *********
UdpServerHelper udpServer_2;
ApplicationContainer serverApp_2;
UdpClientHelper udpClient_2;
ApplicationContainer clientApp_2;
udpServer_2 = UdpServerHelper (100);
serverApp_2 = udpServer_2.Install (ueNodes.Get (1));
serverApp_2.Start (Seconds (0.02));
serverApp_2.Stop (Seconds (2));
udpClient_2 = UdpClientHelper (UEinterfaces.GetAddress (1), 100);
udpClient_2.SetAttribute ("MaxPackets", UintegerValue (1200));
udpClient_2.SetAttribute ("Interval", TimeValue (Seconds (0.12)));
udpClient_2.SetAttribute ("PacketSize", UintegerValue (800));
clientApp_2 = udpClient_2.Install (enbNodes.Get (0));
clientApp_2.Start (Seconds (0.011));
clientApp_2.Stop (Seconds (2));
Ptr<RadioBearerInstance> bearer_2 = CreateObject<RadioBearerInstance> ();
bearer_2->SetBearerDirection (RadioBearerInstance::DIRECTION_TYPE_DL);
bearer_2->SetBearerType (RadioBearerInstance::BEARER_TYPE_DRB);
IpcsClassifierRecord *ipcs_2 = new IpcsClassifierRecord (UEinterfaces.GetAddress (1),
"255.255.255.0",
ENBinterface.GetAddress (0),
"255.255.255.0",
100, 100, 0, 10000, 17, 1);
bearer_2->SetIpcsClassifierRecord (ipcs_2);
enb->GetRrcEntity ()->AddDownlinkNgbrBearer (bearer_2);
//******* FLOW N° 3 *********
UdpServerHelper udpServer_3;
ApplicationContainer serverApp_3;
UdpClientHelper udpClient_3;
ApplicationContainer clientApp_3;
udpServer_3 = UdpServerHelper (100);
serverApp_3 = udpServer_3.Install (ueNodes.Get (2));
serverApp_3.Start (Seconds (0.02));
serverApp_3.Stop (Seconds (2));
udpClient_3 = UdpClientHelper (UEinterfaces.GetAddress (2), 100);
udpClient_3.SetAttribute ("MaxPackets", UintegerValue (1200));
udpClient_3.SetAttribute ("Interval", TimeValue (Seconds (0.12)));
udpClient_3.SetAttribute ("PacketSize", UintegerValue (800));
clientApp_3 = udpClient_2.Install (enbNodes.Get (0));
clientApp_3.Start (Seconds (0.011));
clientApp_3.Stop (Seconds (2));
Ptr<RadioBearerInstance> bearer_3 = CreateObject<RadioBearerInstance> ();
bearer_3->SetBearerDirection (RadioBearerInstance::DIRECTION_TYPE_DL);
bearer_3->SetBearerType (RadioBearerInstance::BEARER_TYPE_DRB);
IpcsClassifierRecord *ipcs_3 = new IpcsClassifierRecord (UEinterfaces.GetAddress (2),
"255.255.255.0",
ENBinterface.GetAddress (0),
"255.255.255.0",
100, 100, 0, 10000, 17, 1);
bearer_3->SetIpcsClassifierRecord (ipcs_3);
enb->GetRrcEntity ()->AddDownlinkNgbrBearer (bearer_3);
std::cout << "Starting simulation....." << std::endl;
Simulator::Stop (Seconds (2.0));
Simulator::Run ();
Simulator::Destroy ();
std::cout << "Done." << std::endl;
return 0;
}

176
src/devices/lte/examples/lte-phy-downlink.cc

@ -0,0 +1,176 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Giuseppe Piro <g.piro@poliba.it>
*/
/*
* Test for LTE PHY layer in the downlink
*
* /\ +
* /--\ __|
* /....\ | |
* /------\ |__|
* eNB UE
*
* SendPacket(Pb)
* |
* V
* |+++++++++++++++++++++++++++++| |+++++++++++++++++++++++++++++|
* | EnbLtePhy | | EnbLtePhy |
* |+++++++++++++++++++++++++++++| |+++++++++++++++++++++++++++++|
* | SpectrumPhy | SpectrumPhy | | SpectrumPhy | SpectrumPhy |
* | dl | ul | | dl | ul |
* |+++++++++++++++++++++++++++++| |+++++++++++++++++++++++++++++|
* | |
* | |
* V |
* StartTx (pb) StartRx(Pb)
* | |
* V |
* |+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++|
* | Downlink Spectrum Channel |
* |+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++|
*/
#include <iostream>
#include <ns3/core-module.h>
#include <ns3/common-module.h>
#include <ns3/node-module.h>
#include <ns3/simulator-module.h>
#include <ns3/single-model-spectrum-channel.h>
#include <ns3/log.h>
#include <string>
#include <ns3/mobility-module.h>
#include <ns3/spectrum-helper.h>
#include <ns3/helper-module.h>
#include <ns3/lte-helper.h>
#include <ns3/enb-phy.h>
#include <ns3/ue-phy.h>
#include <ns3/packet-burst.h>
#include <ns3/constant-position-mobility-model.h>
#include <ns3/constant-velocity-mobility-model.h>
#include <vector>
NS_LOG_COMPONENT_DEFINE ("TestSimpleLtePhy");
using namespace ns3;
int main (int argc, char** argv)
{
LteHelper lte;
lte.EnableLogComponents ();
// CREATE NODE CONTAINER AND CREATE LTE NODES
NodeContainer ueNodes;
NodeContainer enbNodes;
ueNodes.Create (1);
enbNodes.Create (1);
// CREATE DEVICE CONTAINER, INSTALL DEVICE TO NODE
NetDeviceContainer ueDevs, enbDevs;
ueDevs = lte.Install (ueNodes, LteHelper::DEVICE_TYPE_USER_EQUIPMENT);
enbDevs = lte.Install (enbNodes, LteHelper::DEVICE_TYPE_ENODEB);
// INSTALL INTERNET STACKS
InternetStackHelper stack;
stack.Install (ueNodes);
stack.Install (enbNodes);
Ipv4AddressHelper address;
address.SetBase ("10.1.1.0", "255.255.255.0");
Ipv4InterfaceContainer UEinterfaces = address.Assign (ueDevs);
Ipv4InterfaceContainer ENBinterface = address.Assign (enbDevs);
// MANAGE LTE NET DEVICES
Ptr<EnbNetDevice> enb;
enb = enbDevs.Get (0)->GetObject<EnbNetDevice> ();
Ptr<UeNetDevice> ue = ueDevs.Get (0)->GetObject<UeNetDevice> ();
lte.RegisterUeToTheEnb (ue, enb);
// CONFIGURE DL and UL SUB CHANNELS
// Define a list of sub channels for the downlink
std::vector<int> dlSubChannels;
for (int i = 0; i < 25; i++)
{
dlSubChannels.push_back (i);
}
// Define a list of sub channels for the uplink
std::vector<int> ulSubChannels;
for (int i = 50; i < 100; i++)
{
ulSubChannels.push_back (i);
}
enb->GetPhy ()->SetDownlinkSubChannels (dlSubChannels);
enb->GetPhy ()->SetUplinkSubChannels (ulSubChannels);
ue->GetPhy ()->SetDownlinkSubChannels (dlSubChannels);
ue->GetPhy ()->SetUplinkSubChannels (ulSubChannels);
// CONFIGURE MOBILITY
Ptr<ConstantPositionMobilityModel> enbMobility = CreateObject<ConstantPositionMobilityModel> ();
enbMobility->SetPosition (Vector (0.0, 0.0, 0.0));
lte.AddMobility (enb->GetPhy (), enbMobility);
Ptr<ConstantVelocityMobilityModel> ueMobility = CreateObject<ConstantVelocityMobilityModel> ();
ueMobility->SetPosition (Vector (30.0, 0.0, 0.0));
ueMobility->SetVelocity (Vector (30.0, 0.0, 0.0));
lte.AddMobility (ue->GetPhy (), ueMobility);
lte.AddDownlinkChannelRealization (enbMobility, ueMobility, ue->GetPhy ());
// ****** simulate a packet transmission in the downlink ******
Ptr<PacketBurst> pb = Create<PacketBurst> ();
Ptr<Packet> p1 = Create<Packet> (500);
Ptr<Packet> p2 = Create<Packet> (500);
pb->AddPacket (p1);
pb->AddPacket (p2);
enb->GetPhy ()->SendPacket (pb);
Simulator::Stop (Seconds (.1));
Simulator::Run ();
Simulator::Destroy ();
return 0;
}

172
src/devices/lte/examples/lte-phy-uplink.cc

@ -0,0 +1,172 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Giuseppe Piro <g.piro@poliba.it>
*/
/*
* Test for LTE PHY layer in the downlink
*
* /\ +
* /--\ __|
* /....\ | |
* /------\ |__|
* eNB UE
*
* SendPacket(Pb)
* |
* V
* |+++++++++++++++++++++++++++++| |+++++++++++++++++++++++++++++|
* | EnbLtePhy | | EnbLtePhy |
* |+++++++++++++++++++++++++++++| |+++++++++++++++++++++++++++++|
* | SpectrumPhy | SpectrumPhy | | SpectrumPhy | SpectrumPhy |
* | dl | ul | | dl | ul |
* |+++++++++++++++++++++++++++++| |+++++++++++++++++++++++++++++|
* \ |
* | |
* | |
* StartRx (pb) StartTx(bb)
* | |
* | V
* |+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++|
* | Uplink Spectrum Channel |
* |+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++|
*/
#include <iostream>
#include <ns3/core-module.h>
#include <ns3/common-module.h>
#include <ns3/node-module.h>
#include <ns3/simulator-module.h>
#include <ns3/single-model-spectrum-channel.h>
#include <ns3/log.h>
#include <string>
#include <ns3/mobility-module.h>
#include <ns3/spectrum-helper.h>
#include <ns3/helper-module.h>
#include <ns3/lte-helper.h>
#include <ns3/enb-phy.h>
#include <ns3/ue-phy.h>
#include <ns3/packet-burst.h>
#include <ns3/constant-position-mobility-model.h>
#include <ns3/constant-velocity-mobility-model.h>
#include <vector>
NS_LOG_COMPONENT_DEFINE ("TestSimpleLtePhy");
using namespace ns3;
int main (int argc, char** argv)
{
LteHelper lte;
lte.EnableLogComponents ();
// CREATE NODE CONTAINER AND CREATE LTE NODES
NodeContainer ueNodes;
NodeContainer enbNodes;
ueNodes.Create (1);
enbNodes.Create (1);
// CREATE DEVICE CONTAINER, INSTALL DEVICE TO NODE
NetDeviceContainer ueDevs, enbDevs;
ueDevs = lte.Install (ueNodes, LteHelper::DEVICE_TYPE_USER_EQUIPMENT);
enbDevs = lte.Install (enbNodes, LteHelper::DEVICE_TYPE_ENODEB);
// INSTALL INTERNET STACKS
InternetStackHelper stack;
stack.Install (ueNodes);
stack.Install (enbNodes);
Ipv4AddressHelper address;
address.SetBase ("10.1.1.0", "255.255.255.0");
Ipv4InterfaceContainer UEinterfaces = address.Assign (ueDevs);
Ipv4InterfaceContainer ENBinterface = address.Assign (enbDevs);
// MANAGE LTE NET DEVICES
Ptr<EnbNetDevice> enb;
enb = enbDevs.Get (0)->GetObject<EnbNetDevice> ();
Ptr<UeNetDevice> ue = ueDevs.Get (0)->GetObject<UeNetDevice> ();
lte.RegisterUeToTheEnb (ue, enb);
// CONFIGURE DL and UL SUB CHANNELS
// Define a list of sub channels for the downlink
std::vector<int> dlSubChannels;
for (int i = 0; i < 25; i++)
{
dlSubChannels.push_back (i);
}
// Define a list of sub channels for the uplink
std::vector<int> ulSubChannels;
for (int i = 50; i < 100; i++)
{
ulSubChannels.push_back (i);
}
enb->GetPhy ()->SetDownlinkSubChannels (dlSubChannels);
enb->GetPhy ()->SetUplinkSubChannels (ulSubChannels);
ue->GetPhy ()->SetDownlinkSubChannels (dlSubChannels);
ue->GetPhy ()->SetUplinkSubChannels (ulSubChannels);
// CONFIGURE MOBILITY
Ptr<ConstantPositionMobilityModel> enbMobility = CreateObject<ConstantPositionMobilityModel> ();
enbMobility->SetPosition (Vector (0.0, 0.0, 0.0));
lte.AddMobility (enb->GetPhy (), enbMobility);
Ptr<ConstantVelocityMobilityModel> ueMobility = CreateObject<ConstantVelocityMobilityModel> ();
ueMobility->SetPosition (Vector (30.0, 0.0, 0.0));
ueMobility->SetVelocity (Vector (30.0, 0.0, 0.0));
lte.AddMobility (ue->GetPhy (), ueMobility);
lte.AddDownlinkChannelRealization (enbMobility, ueMobility, ue->GetPhy ());
// ****** simulate a packet transmission in the downlink ******
Ptr<PacketBurst> pb = Create<PacketBurst> ();
Ptr<Packet> p1 = Create<Packet> (500);
Ptr<Packet> p2 = Create<Packet> (500);
pb->AddPacket (p1);
pb->AddPacket (p2);
ue->GetPhy ()->SendPacket (pb);
Simulator::Stop (Seconds (.1));
Simulator::Run ();
Simulator::Destroy ();
return 0;
}

1
src/devices/lte/examples/waf vendored

@ -0,0 +1 @@
exec "`dirname "$0"`"/../../waf "$@"

27
src/devices/lte/examples/wscript

@ -0,0 +1,27 @@
## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
def build(bld):
obj = bld.create_ns3_program('lte-phy-downlink',
['lte'])
obj.source = 'lte-phy-downlink.cc'
obj = bld.create_ns3_program('lte-phy-uplink',
['lte'])
obj.source = 'lte-phy-uplink.cc'
obj = bld.create_ns3_program('lte-device',
['lte'])
obj.source = 'lte-device.cc'
obj = bld.create_ns3_program('lte-channel-model',
['lte'])
obj.source = 'lte-channel-model.cc'
obj = bld.create_ns3_program('lte-amc',
['lte'])
obj.source = 'lte-amc.cc'
obj = bld.create_ns3_program('lte-multiple-flows',
['lte'])
obj.source = 'lte-multiple-flows.cc'

323
src/devices/lte/helper/lte-helper.cc

@ -0,0 +1,323 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Giuseppe Piro <peppe.piro@gmail.com>, <g.piro@poliba.it>
*/
#include "lte-helper.h"
#include "ns3/simulator.h"
#include "ns3/packet.h"
#include "ns3/log.h"
#include "ns3/pointer.h"
#include <string>
#include "ns3/config.h"
#include "ns3/single-model-spectrum-channel.h"
#include "ns3/lte-spectrum-phy.h"
#include "ns3/enb-lte-spectrum-phy.h"
#include "ns3/ue-lte-spectrum-phy.h"
#include "ns3/ue-net-device.h"
#include "ns3/enb-net-device.h"
#include "ns3/ue-manager.h"
#include "ns3/spectrum-propagation-loss-model.h"
#include "ns3/lte-propagation-loss-model.h"
NS_LOG_COMPONENT_DEFINE ("LteHelper");
namespace ns3 {
LteHelper::LteHelper (void)
: m_downlinkChannel (CreateObject<SingleModelSpectrumChannel> ()),
m_uplinkChannel (CreateObject<SingleModelSpectrumChannel> ())
{
Ptr<LtePropagationLossModel> model = CreateObject<LtePropagationLossModel> ();
m_downlinkChannel->AddSpectrumPropagationLossModel (model);
}
LteHelper::~LteHelper (void)
{
m_downlinkChannel = 0;
m_uplinkChannel = 0;
}
Ptr<LtePhy>
LteHelper::CreatePhy (Ptr<SpectrumChannel> dlChannel, Ptr<SpectrumChannel> ulChannel, NetDeviceType t)
{
Ptr<LtePhy> phy;
Ptr<LteSpectrumPhy> dl;
Ptr<LteSpectrumPhy> ul;
if (t == LteHelper::DEVICE_TYPE_ENODEB)
{
phy = CreateObject<EnbLtePhy> ();
dl = CreateObject<EnbLteSpectrumPhy> ();
ul = CreateObject<EnbLteSpectrumPhy> ();
}
if (t == LteHelper::DEVICE_TYPE_USER_EQUIPMENT)
{
phy = CreateObject<UeLtePhy> ();
dl = CreateObject<UeLteSpectrumPhy> ();
ul = CreateObject<UeLteSpectrumPhy> ();
}
phy->SetDownlinkSpectrumPhy (dl);
phy->SetUplinkSpectrumPhy (ul);
if (t == LteHelper::DEVICE_TYPE_ENODEB)
{
dl->SetChannel (dlChannel);
ul->SetChannel (ulChannel);
m_downlinkChannel->AddRx (dl);
m_uplinkChannel->AddRx (ul);
}
else if (t == LteHelper::DEVICE_TYPE_USER_EQUIPMENT)
{
dl->SetChannel (dlChannel);
ul->SetChannel (ulChannel);
m_downlinkChannel->AddRx (dl);
}
else
{
NS_FATAL_ERROR ("LteHelper: Invalid Device type");
}
return phy;
}
Ptr<LtePhy>
LteHelper::CreatePhy (NetDeviceType t)
{
Ptr<LtePhy> phy;
Ptr<LteSpectrumPhy> dl;
Ptr<LteSpectrumPhy> ul;
if (t == LteHelper::DEVICE_TYPE_ENODEB)
{
phy = CreateObject<EnbLtePhy> ();
dl = CreateObject<EnbLteSpectrumPhy> ();
ul = CreateObject<EnbLteSpectrumPhy> ();
}
if (t == LteHelper::DEVICE_TYPE_USER_EQUIPMENT)
{
phy = CreateObject<UeLtePhy> ();
dl = CreateObject<UeLteSpectrumPhy> ();
ul = CreateObject<UeLteSpectrumPhy> ();
}
phy->SetDownlinkSpectrumPhy (dl);
phy->SetUplinkSpectrumPhy (ul);
if (t == LteHelper::DEVICE_TYPE_ENODEB)
{
dl->SetChannel (m_downlinkChannel);
ul->SetChannel (m_uplinkChannel);
m_downlinkChannel->AddRx (dl);
m_uplinkChannel->AddRx (ul);
}
else if (t == LteHelper::DEVICE_TYPE_USER_EQUIPMENT)
{
dl->SetChannel (m_downlinkChannel);
ul->SetChannel (m_uplinkChannel);
m_downlinkChannel->AddRx (dl);
}
else
{
NS_FATAL_ERROR ("LteHelper: Invalid Device type");
}
return phy;
}
Ptr<UeLtePhy>
LteHelper::CreateUePhy (void)
{
Ptr<UeLtePhy> phy = CreateObject<UeLtePhy> ();
Ptr<UeLteSpectrumPhy> dl = CreateObject<UeLteSpectrumPhy> ();;
Ptr<UeLteSpectrumPhy> ul = CreateObject<UeLteSpectrumPhy> ();;
phy->SetDownlinkSpectrumPhy (dl);
phy->SetUplinkSpectrumPhy (ul);
dl->SetChannel (m_downlinkChannel);
ul->SetChannel (m_uplinkChannel);
m_downlinkChannel->AddRx (dl);
return phy;
}
Ptr<EnbLtePhy>
LteHelper::CreateEnbPhy (void)
{
Ptr<EnbLtePhy> phy = CreateObject<EnbLtePhy> ();
Ptr<EnbLteSpectrumPhy> dl = CreateObject<EnbLteSpectrumPhy> ();;
Ptr<EnbLteSpectrumPhy> ul = CreateObject<EnbLteSpectrumPhy> ();;
phy->SetDownlinkSpectrumPhy (dl);
phy->SetUplinkSpectrumPhy (ul);
dl->SetChannel (m_downlinkChannel);
ul->SetChannel (m_uplinkChannel);
m_downlinkChannel->AddRx (dl);
m_uplinkChannel->AddRx (ul);
return phy;
}
void
LteHelper::AddMobility (Ptr<LtePhy> phy, Ptr<MobilityModel> m)
{
phy->GetDownlinkSpectrumPhy ()->SetMobility(m);
phy->GetUplinkSpectrumPhy ()->SetMobility(m);
}
NetDeviceContainer
LteHelper::Install (NodeContainer c, NetDeviceType type)
{
NetDeviceContainer devices;
for (NodeContainer::Iterator i = c.Begin (); i != c.End (); i++)
{
Ptr<Node> node = *i;
Ptr<LteNetDevice> device;
Ptr<LtePhy> phy;
if (type == LteHelper::DEVICE_TYPE_ENODEB)
{
Ptr<EnbLtePhy> p = CreateEnbPhy ();
Ptr<EnbNetDevice> dev = CreateObject<EnbNetDevice> (node, p);
p->GetUplinkSpectrumPhy ()->SetPhyMacRxEndOkCallback (MakeCallback (&LteNetDevice::Receive, dev));
device = dev;
phy = p;
}
else if (type == LteHelper::DEVICE_TYPE_USER_EQUIPMENT)
{
Ptr<UeLtePhy> p = CreateUePhy ();
Ptr<UeNetDevice> dev = CreateObject<UeNetDevice> (node, p);
p->GetDownlinkSpectrumPhy ()->SetPhyMacRxEndOkCallback (MakeCallback (&LteNetDevice::Receive, dev));
device = dev;
phy = p;
}
else
{
NS_FATAL_ERROR ("LteHelper: Invalid Device type");
}
device->SetAddress (Mac48Address::Allocate ());
phy->SetDevice (device);
phy->GetDownlinkSpectrumPhy ()->SetDevice (device);
phy->GetUplinkSpectrumPhy ()->SetDevice (device);
device->Start ();
node->AddDevice (device);
devices.Add (device);
}
return devices;
}
void
LteHelper::RegisterUeToTheEnb (Ptr<UeNetDevice> ue, Ptr<EnbNetDevice> enb)
{
ue->SetTargetEnb (enb);
enb->GetUeManager ()->CreateUeRecord (ue, enb);
}
void
LteHelper::AddDownlinkChannelRealization (Ptr<MobilityModel> enbMobility, Ptr<MobilityModel> ueMobility, Ptr<LtePhy> phy)
{
Ptr<LtePropagationLossModel> model = m_downlinkChannel->GetSpectrumPropagationLossModel ()->GetObject<LtePropagationLossModel> ();
model->CreateChannelRealization (enbMobility, ueMobility);
//initialize multipath model
Ptr<JakesFadingLossModel> m = model->GetChannelRealization (enbMobility, ueMobility)->GetJakesFadingLossModel ();
m->SetPhy (phy);
}
void
LteHelper::EnableLogComponents (void)
{
LogComponentEnable ("LtePhy", LOG_LEVEL_ALL);
LogComponentEnable ("EnbLtePhy", LOG_LEVEL_ALL);
LogComponentEnable ("UeLtePhy", LOG_LEVEL_ALL);
LogComponentEnable ("LteSpectrumPhy", LOG_LEVEL_ALL);
LogComponentEnable ("EnbLteSpectrumPhy", LOG_LEVEL_ALL);
LogComponentEnable ("UeLteSpectrumPhy", LOG_LEVEL_ALL);
LogComponentEnable ("LtePropagationLossModel", LOG_LEVEL_ALL);
LogComponentEnable ("LossModel", LOG_LEVEL_ALL);
LogComponentEnable ("ShadowingLossModel", LOG_LEVEL_ALL);
LogComponentEnable ("PenetrationLossModel", LOG_LEVEL_ALL);
LogComponentEnable ("MultipathLossModel", LOG_LEVEL_ALL);
LogComponentEnable ("PathLossModel", LOG_LEVEL_ALL);
LogComponentEnable ("RrcEntity", LOG_LEVEL_ALL);
LogComponentEnable ("MacEntity", LOG_LEVEL_ALL);
LogComponentEnable ("EnbMacEntity", LOG_LEVEL_ALL);
LogComponentEnable ("UeMacEntity", LOG_LEVEL_ALL);
LogComponentEnable ("RlcEntity", LOG_LEVEL_ALL);
LogComponentEnable ("RadioBearerInstance", LOG_LEVEL_ALL);
LogComponentEnable ("LteMacQueue", LOG_LEVEL_ALL);
LogComponentEnable ("LteNetDevice", LOG_LEVEL_ALL);
LogComponentEnable ("UeNetDevice", LOG_LEVEL_ALL);
LogComponentEnable ("EnbNetDevice", LOG_LEVEL_ALL);
LogComponentEnable ("UeManager", LOG_LEVEL_ALL);
LogComponentEnable ("UeRecord", LOG_LEVEL_ALL);
LogComponentEnable ("PacketScheduler", LOG_LEVEL_ALL);
LogComponentEnable ("SimplePacketScheduler", LOG_LEVEL_ALL);
}
} // namespace ns3

142
src/devices/lte/helper/lte-helper.h

@ -0,0 +1,142 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Giuseppe Piro <peppe.piro@gmail.com>, <g.piro@poliba.it>
*/
#ifndef LTE_HELPER_H
#define LTE_HELPER_H
#include <string>
#include "ns3/object-factory.h"
#include "ns3/node-container.h"
#include "ns3/net-device-container.h"
#include "ns3/lte-net-device.h"
#include "ns3/enb-net-device.h"
#include "ns3/ue-net-device.h"
#include "ns3/packet-scheduler.h"
#include "ns3/single-model-spectrum-channel.h"
#include "ns3/lte-phy.h"
#include "ns3/ue-phy.h"
#include "ns3/enb-phy.h"
#include <ns3/mobility-model.h>
namespace ns3 {
/**
* \brief helps to manage and create LteNetDevice objects
*
* This class can help to create a LteNetDevice objects
* and to configure their attributes during creation.
*/
class LteHelper
{
public:
/**
* Net Device Type
* Distinguish a user equipment (UE) device from eNodeB (eNB) device
*/
enum NetDeviceType
{
DEVICE_TYPE_USER_EQUIPMENT, /**< UE device */
DEVICE_TYPE_ENODEB /**< eNB device */
};
/**
* \brief Create a Lte helper in an empty state.
*/
LteHelper (void);
~LteHelper (void);
/**
* \brief Add mobility model to a physical device
* \param phy the physical device
* \param m the mobility model
*/
void AddMobility (Ptr<LtePhy> phy, Ptr<MobilityModel>m);
/**
* \param c a set of nodes
* \param type device type to create
*/
NetDeviceContainer Install (NodeContainer c, NetDeviceType type);
/**
* \brief register UEs to the target eNB
* \param ue
* \param enb
*/
void RegisterUeToTheEnb (Ptr<UeNetDevice> ue, Ptr<EnbNetDevice> enb);
/**
* Helper to enable all LTE log components with one statement
*/
void EnableLogComponents (void);
/**
* \brief Add a downlink channel realization
* \param enbMobility, the enb mobility model
* \param ueMobility the ue mobility model
* \param phy the physical layer of the UE
*/
void AddDownlinkChannelRealization (Ptr<MobilityModel> enbMobility,
Ptr<MobilityModel> ueMobility,
Ptr<LtePhy> phy);
private:
/**
* \brief Create a PHY layer for a LTE device
* \param dlChannel the downlink channel
* \param ulChannel the uplink channel
* \return the pointer to the LTE physical layer
*/
Ptr<LtePhy> CreatePhy (Ptr<SpectrumChannel> dlChannel, Ptr<SpectrumChannel> ulChannel, NetDeviceType t);
/**
* \brief Create a PHY layer for a LTE device
* \return the pointer to the LTE physical layer
*/
Ptr<LtePhy> CreatePhy (NetDeviceType t);
/**
* \brief Create a PHY layer for a UE LTE device
* \return the pointer to the UE LTE physical layer
*/
Ptr<UeLtePhy> CreateUePhy (void);
/**
* \brief Create a PHY layer for a eNB LTE device
* \return the pointer to the eNB LTE physical layer
*/
Ptr<EnbLtePhy> CreateEnbPhy (void);
Ptr<SingleModelSpectrumChannel> m_downlinkChannel;
Ptr<SingleModelSpectrumChannel> m_uplinkChannel;
};
} // namespace ns3
#endif /* LTE_HELPER_H */

33
src/devices/lte/model/JakesTraces/multipath_v0_M10.h

File diff suppressed because one or more lines are too long

32
src/devices/lte/model/JakesTraces/multipath_v0_M12.h

File diff suppressed because one or more lines are too long

32
src/devices/lte/model/JakesTraces/multipath_v0_M6.h

File diff suppressed because one or more lines are too long

32
src/devices/lte/model/JakesTraces/multipath_v0_M8.h

File diff suppressed because one or more lines are too long

32
src/devices/lte/model/JakesTraces/multipath_v120_M10.h

File diff suppressed because one or more lines are too long

32
src/devices/lte/model/JakesTraces/multipath_v120_M12.h

File diff suppressed because one or more lines are too long

32
src/devices/lte/model/JakesTraces/multipath_v120_M6.h

File diff suppressed because one or more lines are too long

31
src/devices/lte/model/JakesTraces/multipath_v120_M8.h

File diff suppressed because one or more lines are too long

31
src/devices/lte/model/JakesTraces/multipath_v30_M10.h

File diff suppressed because one or more lines are too long

32
src/devices/lte/model/JakesTraces/multipath_v30_M12.h

File diff suppressed because one or more lines are too long

31
src/devices/lte/model/JakesTraces/multipath_v30_M6.h

File diff suppressed because one or more lines are too long

32
src/devices/lte/model/JakesTraces/multipath_v30_M8.h

File diff suppressed because one or more lines are too long

31
src/devices/lte/model/JakesTraces/multipath_v3_M10.h

File diff suppressed because one or more lines are too long

32
src/devices/lte/model/JakesTraces/multipath_v3_M12.h

File diff suppressed because one or more lines are too long

32
src/devices/lte/model/JakesTraces/multipath_v3_M6.h

File diff suppressed because one or more lines are too long

32
src/devices/lte/model/JakesTraces/multipath_v3_M8.h

File diff suppressed because one or more lines are too long

199
src/devices/lte/model/amc-module.cc

@ -0,0 +1,199 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Giuseppe Piro <g.piro@poliba.it>
*/
#include "amc-module.h"
#include <ns3/log.h>
#include <math.h>
NS_LOG_COMPONENT_DEFINE ("AmcModule");
namespace ns3 {
NS_OBJECT_ENSURE_REGISTERED (AmcModule);
int CqiIndex[15] = {
1, 2, 3, 4, 5, 6, // QAM
7, 8, 9, // 4-QAM
10, 11, 12, 13, 14, 15 // 16QAM
};
double SpectralEfficiencyForCqiIndex[15] = {
0.15, 0.23, 0.38, 0.6, 0.88, 1.18,
1.48, 1.91, 2.41,
2.73, 3.32, 3.9, 4.52, 5.12, 5.55
};
int McsIndex[32] = {
0, // RESERVED
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, // QAM
12, 13, 14, 15, 16, 17, 18, // 4-QAM
19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, // 16-QAM
30, // QAM, RESERVED
31 // RESERVED
};
int ModulationSchemeForMcsIndex[32] = {
0, // Not defined
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
4, 4, 4, 4, 4, 4, 4,
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
2,
0 // Not defined
};
double SpectralEfficiencyForMcsIndex[32] = {
0,
0.15, 0.19, 0.23, 0.31, 0.38, 0.49, 0.6, 0.74, 0.88, 1.03, 1.18,
1.33, 1.48, 1.7, 1.91, 2.16, 2.41, 2.57,
2.73, 3.03, 3.32, 3.61, 3.9, 4.21, 4.52, 4.82, 5.12, 5.33, 5.55,
2.4,
0
};
int TransportBlockSize[32] = {
0,
18, 23, 28, 37, 45, 59, 72, 89, 105, 123, 141,
159, 177, 203, 230, 259, 289, 288,
308, 328, 363, 399, 433, 468, 506, 543, 578, 614, 640,
667,
0
};
AmcModule::AmcModule ()
{
Initialize ();
}
TypeId
AmcModule::GetTypeId (void)
{
static TypeId tid = TypeId ("ns3::AmcModule")
.SetParent<Object> ()
.AddConstructor<AmcModule> ()
;
return tid;
}
AmcModule::~AmcModule ()
{
}
void
AmcModule::Initialize ()
{
NS_LOG_FUNCTION (this);
}
int
AmcModule::GetCqiFromSpectralEfficiency (double s)
{
NS_LOG_FUNCTION (this << s);
int cqi = 1; // == CqiIndex[0]
while (SpectralEfficiencyForCqiIndex[cqi] < s && cqi <= 14)
{
cqi++;
}
NS_LOG_FUNCTION (this << s << cqi);
return cqi;
}
int
AmcModule::GetMcsFromCqi (int cqi)
{
NS_LOG_FUNCTION (this << cqi);
double spectralEfficiency = SpectralEfficiencyForCqiIndex[cqi - 1];
int mcs = 1;
while (SpectralEfficiencyForMcsIndex[mcs] < spectralEfficiency && mcs < 30)
{
mcs++;
}
NS_LOG_FUNCTION (this << cqi << mcs);
return mcs;
}
int
AmcModule::GetTbSizeFromMcs (int mcs)
{
NS_LOG_FUNCTION (this << mcs);
NS_LOG_FUNCTION (this << mcs << TransportBlockSize[mcs]);
return TransportBlockSize[mcs];
}
double
AmcModule::GetSpectralEfficiencyFromCqi (int cqi)
{
NS_LOG_FUNCTION (this << cqi);
NS_LOG_FUNCTION (this << cqi << SpectralEfficiencyForCqiIndex[cqi - 1]);
return SpectralEfficiencyForCqiIndex[cqi - 1];
}
std::vector<int>
AmcModule::CreateCqiFeedbacks (std::vector<double> sinr)
{
NS_LOG_FUNCTION (this);
std::vector<int> cqi;
std::vector<double>::iterator it;
for (it = sinr.begin (); it != sinr.end (); it++)
{
double sinr_ = (*it);
/*
* Compute the spectral efficiency from the SINR
* SINR
* spectralEfficiency = log2 (1 + -------------------- )
* -ln(5*BER)/1.5
* NB: SINR must be expressed in natural unit:
* (SINR)dB => 10 ^ (SINR/10)
*/
double s = log2 ( 1 + (
pow (10, sinr_ / 10 ) /
( (-log (5.0 * 0.00005 )) / 1.5) ));
int cqi_ = GetCqiFromSpectralEfficiency (s);
NS_LOG_FUNCTION (this << "channel_id = " << cqi.size ()
<< "sinr = " << sinr_
<< "spectral efficiency =" << s
<< " ---- CQI = " << cqi_ );
cqi.push_back (cqi_);
}
return cqi;
}
} // namespace ns3

93
src/devices/lte/model/amc-module.h

@ -0,0 +1,93 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Giuseppe Piro <g.piro@poliba.it>
*/
#ifndef AMCMODULE_H
#define AMCMODULE_H
#include "ns3/object.h"
#include <vector>
namespace ns3 {
/**
* \brief The AMC module attached to the LTE networ device
* AmcModule class implements the Adaptive Modulation And Coding Scheme
* as proposed in 3GPP TSG-RAN WG1 - R1-081483
* http://www.3gpp.org/ftp/tsg_ran/WG1_RL1/TSGR1_52b/Docs/R1-081483.zip
*/
class AmcModule : public Object
{
public:
static TypeId GetTypeId (void);
AmcModule ();
virtual ~AmcModule ();
/**
* \brief Initialize CQI, MCS, SpectralEfficiency e TBs values
*/
void Initialize ();
/**
* \brief Get the Modulation anc Coding Scheme for
* a CQI value
* \param cqi the cqi value
* \return the MCS value
*/
int GetMcsFromCqi (int cqi);
/**
* \brief Get the Transport Block Size for a selected MCS
* \param mcs the mcs index
* \return the TBs value
*/
int GetTbSizeFromMcs (int mcs);
/**
* \brief Get the spectral efficiency value associated
* to the received CQI
* \param cqi the cqi value
* \return the spectral efficiency value
*/
double GetSpectralEfficiencyFromCqi (int cqi);
/**
* \brief Create a message with CQI feedbaks
*/
std::vector<int> CreateCqiFeedbacks (std::vector<double> sinr);
private:
/**
* \brief Get a proper CQI for the spectrale efficiency value.
* In order to assure a fewer block error rate, the AMC chooses the lower CQI value
* for a given spectral efficiency
* \param s the spectral efficiency
* \return the CQI value
*/
int GetCqiFromSpectralEfficiency (double s);
};
}
#endif /* AMCMODULE_H */

170
src/devices/lte/model/bearer-qos-parameters.cc

@ -0,0 +1,170 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Giuseppe Piro <g.piro@poliba.it>
*/
#include "bearer-qos-parameters.h"
#include <ns3/log.h>
NS_LOG_COMPONENT_DEFINE ("BearerQosParameters");
namespace ns3 {
BearerQosParameters::BearerQosParameters (void)
: m_qci (0),
m_arpPreEmptionCapability (false),
m_arpPreEmptionVulnerability (false),
m_gbr (0),
m_mbr (0),
m_maxDelay (0)
{
}
BearerQosParameters::BearerQosParameters (int qci,
double gbr,
double mbr)
: m_qci (qci),
m_arpPreEmptionCapability (false),
m_arpPreEmptionVulnerability (false),
m_gbr (gbr),
m_mbr (mbr),
m_maxDelay (0)
{
}
BearerQosParameters::BearerQosParameters (int qci,
bool apec,
bool apev,
double gbr,
double mbr)
: m_qci (qci),
m_arpPreEmptionCapability (apec),
m_arpPreEmptionVulnerability (apev),
m_gbr (gbr),
m_mbr (mbr),
m_maxDelay (0)
{
}
BearerQosParameters::~BearerQosParameters ()
{
}
void
BearerQosParameters::SetQci (int qci)
{
m_qci = qci;
}
int
BearerQosParameters::GetQci (void) const
{
return m_qci;
}
void
BearerQosParameters::SetArpPreEmptionCapability (bool apec)
{
m_arpPreEmptionCapability = apec;
}
bool
BearerQosParameters::GetArpPreEmptionCapability (void) const
{
return m_arpPreEmptionCapability;
}
void
BearerQosParameters::SetArpPreEmptionVulnerability (bool apev)
{
m_arpPreEmptionVulnerability = apev;
}
bool
BearerQosParameters::GetArpPreEmptionVulnerability (void) const
{
return m_arpPreEmptionVulnerability;
}
void
BearerQosParameters::SetGbr (double gbr)
{
m_gbr = gbr;
}
double
BearerQosParameters::GetGbr (void) const
{
return m_gbr;
}
void
BearerQosParameters::SetMbr (double mbr)
{
m_mbr = mbr;
}
double
BearerQosParameters::GetMbr (void) const
{
return m_mbr;
}
void
BearerQosParameters::SetMaxDelay (double targetDelay)
{
m_maxDelay = targetDelay;
}
double
BearerQosParameters::GetMaxDelay (void) const
{
return m_maxDelay;
}
void
BearerQosParameters::SetBearerQosType (BearerQosType QosType)
{
m_bearerQosType = QosType;
}
BearerQosParameters::BearerQosType
BearerQosParameters::GetBearerQosType (void) const
{
return m_bearerQosType;
}
} // namespace ns3

157
src/devices/lte/model/bearer-qos-parameters.h

@ -0,0 +1,157 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Giuseppe Piro <g.piro@poliba.it>
*/
#ifndef BEARER_QOS_PARAMETERS_H_
#define BEARER_QOS_PARAMETERS_H_
#include "ns3/object.h"
namespace ns3 {
/**
* \brief the BearerQosParameters class implements a set of Qos
* parameters associated to the bearer.
* Bearer Level Qos (TS 23.401, Clause 4.7.3)
* A bearer uniquely identifies traffic flows that receive a
* common Qos treatment.
*/
class BearerQosParameters : public Object
{
public:
BearerQosParameters (void);
/**
* \brief Create a Qos Parameters Set
*
* \param qci the Qos Class Identifier
* \param gbr the maximum bit rate to guarantee
* \param mbr the minimum bit rate to guarantee
*/
BearerQosParameters (int qci,
double gbr,
double mbr);
/**
* \brief Create a Qos Parameters Set
*
* \param qci the Qos Class Identifier
* \param apec the Allocation and Retention Priority of pre-emption capability
* \param apev the Allocation and Retention Priority of pre-emption vulnerability
* \param gbr the maximum bit rate to guarantee
* \param mbr the minimum bit rate to guarantee
*/
BearerQosParameters (int qci,
bool apec,
bool apev,
double gbr,
double mbr);
virtual ~BearerQosParameters (void);
/**
* Type og bearer (GBR or non GBR)
*/
enum BearerQosType
{
BEARER_TYPE_GBR, BEARER_TYPE_NGBR
};
/**
* \brief Set the Qos type of the bearer
* \param QosType the Qos type
*/
void SetBearerQosType (BearerQosType QosType);
/**
* \brief Get the Qos type of the bearer
* \return the Qos tyope of the bearer
*/
BearerQosType GetBearerQosType (void) const;
/**
* \param qci the Qos Class Identifier
*/
void SetQci (int qci);
/**
* \return the QCI value
*/
int GetQci (void) const;
/**
* \param apec the Allocation and Retention Priority of pre-emption capability
*/
void SetArpPreEmptionCapability (bool apec);
/**
* \return the ArpPreEmptionCapability value
*/
bool GetArpPreEmptionCapability (void) const;
/**
* \param apev the Allocation and Retention Priority of pre-emption vulnerability
*/
void SetArpPreEmptionVulnerability (bool apev);
/**
* \return the ArpPreEmptionVulnerability value
*/
bool GetArpPreEmptionVulnerability (void) const;
/**
* \param gbr the maximum bit rate to guarantee
*/
void SetGbr (double gbr);
/**
* \return the maximum bit rate
*/
double GetGbr (void) const;
/**
* \param mbr the minimum bit rate to guarantee
*/
void SetMbr (double mbr);
/**
* \return the minimum bit rate
*/
double GetMbr (void) const;
/**
* \param targetDelay the target delay
*/
void SetMaxDelay (double targetDelay);
/**
* \return the targetDelay value
*/
double GetMaxDelay (void) const;
private:
BearerQosType m_bearerQosType;
int m_qci;
bool m_arpPreEmptionCapability;
bool m_arpPreEmptionVulnerability;
double m_gbr;
double m_mbr;
double m_maxDelay;
};
}
#endif /* BEARER_QOS_PARAMETERS_H_ */

122
src/devices/lte/model/channel-realization.cc

@ -0,0 +1,122 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Giuseppe Piro <g.piro@poliba.it>
*/
#include <ns3/log.h>
#include <ns3/simulator.h>
#include "channel-realization.h"
NS_LOG_COMPONENT_DEFINE ("ChannelRealization");
namespace ns3 {
NS_OBJECT_ENSURE_REGISTERED (ChannelRealization);
ChannelRealization::ChannelRealization ()
{
m_shadowing = CreateObject<ShadowingLossModel> ();
m_pathloss = CreateObject<PathLossModel> ();
m_multipath = CreateObject<JakesFadingLossModel> ();
m_penetration = CreateObject<PenetrationLossModel> ();
}
TypeId
ChannelRealization::GetTypeId (void)
{
static TypeId tid = TypeId ("ns3::ChannelRealization")
.SetParent<Object> ()
.AddConstructor<ChannelRealization> ()
;
return tid;
}
ChannelRealization::~ChannelRealization ()
{
}
void
ChannelRealization::SetJakesFadingLossModel (Ptr<JakesFadingLossModel> l)
{
NS_LOG_FUNCTION (this);
m_multipath = l;
}
void
ChannelRealization::SetPathLossModel (Ptr<PathLossModel> l)
{
NS_LOG_FUNCTION (this << l);
m_pathloss = l;
}
void
ChannelRealization::SetShadowingLossModel (Ptr<ShadowingLossModel> l)
{
NS_LOG_FUNCTION (this << l);
m_shadowing = l;
}
void
ChannelRealization::SetPenetrationLossModel (Ptr<PenetrationLossModel> l)
{
NS_LOG_FUNCTION (this << l);
m_penetration = l;
}
Ptr<JakesFadingLossModel>
ChannelRealization::GetJakesFadingLossModel (void)
{
NS_LOG_FUNCTION (this);
return m_multipath;
}
Ptr<PathLossModel>
ChannelRealization::GetPathLossModel (void)
{
NS_LOG_FUNCTION (this);
return m_pathloss;
}
Ptr<ShadowingLossModel>
ChannelRealization::GetShadowingLossModel (void)
{
NS_LOG_FUNCTION (this);
return m_shadowing;
}
Ptr<PenetrationLossModel>
ChannelRealization::GetPenetrationLossModel (void)
{
NS_LOG_FUNCTION (this);
return m_penetration;
}
} // namespace ns3

107
src/devices/lte/model/channel-realization.h

@ -0,0 +1,107 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Giuseppe Piro <g.piro@poliba.it>
*/
#ifndef CHANNEL_REALIZATION_H
#define CHANNEL_REALIZATION_H
#include <ns3/nstime.h>
#include "ns3/object.h"
#include "multipath-loss-model.h"
#include "path-loss-model.h"
#include "shadowing-loss-model.h"
#include "penetration-loss-model.h"
namespace ns3 {
/**
* \brief the ChannelRealization class implements a complete propagation model
* used by the channel to compute the loss due to the propagation of the signal.
* A ChannelRealization object is created for each couple of UE - eNB.
*/
class ChannelRealization : public Object
{
public:
ChannelRealization ();
virtual ~ChannelRealization ();
static TypeId GetTypeId (void);
/**
* \brief Set the multipath loss model
* \param l the multipath loss model
*/
void SetJakesFadingLossModel (Ptr<JakesFadingLossModel> l);
/**
* \brief Set the path loss model
* \param l the path loss model
*/
void SetPathLossModel (Ptr<PathLossModel> l);
/**
* \brief Set the shadowing loss model
* \param l the shadowing loss model
*/
void SetShadowingLossModel (Ptr<ShadowingLossModel> l);
/**
* \brief Set the penetration loss model
* \param l the penetration loss model
*/
void SetPenetrationLossModel (Ptr<PenetrationLossModel> l);
/**
* \brief Get the multipath loss model
* \return the pointer to the multipath loss model
*/
Ptr<JakesFadingLossModel> GetJakesFadingLossModel (void);
/**
* \brief Get the path loss model
* \return the pointer to the path loss model
*/
Ptr<PathLossModel> GetPathLossModel (void);
/**
* \brief Get the shadowing loss model
* \return the pointer to the shadowing loss model
*/
Ptr<ShadowingLossModel> GetShadowingLossModel (void);
/**
* \brief Get the penetration loss model
* \return the pointer to the penetration loss model
*/
Ptr<PenetrationLossModel> GetPenetrationLossModel (void);
private:
Ptr<ShadowingLossModel> m_shadowing;
Ptr<PathLossModel> m_pathloss;
Ptr<JakesFadingLossModel> m_multipath;
Ptr<PenetrationLossModel> m_penetration;
};
} // namespace ns3
#endif /* CHANNEL_REALIZATION_H */

94
src/devices/lte/model/enb-lte-spectrum-phy.cc

@ -0,0 +1,94 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Giuseppe Piro <g.piro@poliba.it>
*/
#include <ns3/waveform-generator.h>
#include <ns3/object-factory.h>
#include <ns3/log.h>
#include <math.h>
#include <ns3/simulator.h>
#include <ns3/trace-source-accessor.h>
#include "ns3/spectrum-error-model.h"
#include "lte-spectrum-phy.h"
#include "enb-lte-spectrum-phy.h"
#include "lte-net-device.h"
#include "lte-spectrum-value-helper.h"
NS_LOG_COMPONENT_DEFINE ("EnbLteSpectrumPhy");
namespace ns3 {
NS_OBJECT_ENSURE_REGISTERED (EnbLteSpectrumPhy);
EnbLteSpectrumPhy::EnbLteSpectrumPhy ()
{
SetMobility (0);
SetDevice (0);
SetChannel (0);
SetState (LteSpectrumPhy::IDLE);
//GetSpectrumInterference ()->SetErrorModel (CreateObject<LteSpectrumErrorModel> ());
LteSpectrumValueHelper psdHelper;
Ptr<SpectrumValue> noisePsd = psdHelper.CreateUplinkNoisePowerSpectralDensity ();
SetNoisePowerSpectralDensity (noisePsd);
}
EnbLteSpectrumPhy::~EnbLteSpectrumPhy ()
{
}
TypeId
EnbLteSpectrumPhy::GetTypeId (void)
{
static TypeId tid = TypeId ("ns3::EnbLteSpectrumPhy")
.SetParent<LteSpectrumPhy> ()
.AddConstructor<EnbLteSpectrumPhy> ()
;
return tid;
}
void
EnbLteSpectrumPhy::CalcSinrValues (Ptr <const SpectrumValue> rxPsd,Ptr <const SpectrumValue> noise)
{
NS_LOG_FUNCTION (this << rxPsd << noise);
/*
* TO DO:
* Compute the SINR of the incoming signal, using the rxPsd and the Noise Psd.
* Transfer this value to the device that will compute the CQI valuei or the MCS.
*
* Downlink:
* the UE receives the signal from the eNB. It computes the SINR and tranfers
* it to the UeNetDevice. The UeNetDevice, receiving SINR values, uses the AMC module to convert
* SINR to CQI. Then, it will send CQI feedback to the eNB.
*
* Uplink:
* when the eNB receives the signal from a UE, it must computes the quality of channel
* for this particular uplink connection. So, the eNB computes the SINR and transfers it to the
* net device.
*/
}
} // namespace ns3

56
src/devices/lte/model/enb-lte-spectrum-phy.h

@ -0,0 +1,56 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Giuseppe Piro <g.piro@poliba.it>
*/
#ifndef ENB_LTE_SPECTRUM_PHY_H
#define ENB_LTE_SPECTRUM_PHY_H
#include "lte-spectrum-phy.h"
namespace ns3 {
class LteNetDevice;
class EnbNetDevice;
/**
* The EnbLteSpectrumPhy models the UL/DL physical layer for the eNodeB device
*/
class EnbLteSpectrumPhy : public LteSpectrumPhy
{
public:
EnbLteSpectrumPhy ();
virtual ~EnbLteSpectrumPhy ();
static TypeId GetTypeId (void);
void CalcSinrValues (Ptr <const SpectrumValue> rxPsd, Ptr <const SpectrumValue> noise);
private:
};
}
#endif /* ENB_LTE_SPECTRUM_PHY_H */

144
src/devices/lte/model/enb-mac-entity.cc

@ -0,0 +1,144 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Giuseppe Piro <g.piro@poliba.it>
*/
#include "enb-mac-entity.h"
#include <ns3/log.h>
#include <ns3/pointer.h>
#include <ns3/packet.h>
#include "packet-scheduler.h"
#include "simple-packet-scheduler.h"
#include "amc-module.h"
#include "ideal-control-messages.h"
#include "enb-net-device.h"
#include "ue-net-device.h"
#include "ue-record.h"
#include "ue-manager.h"
NS_LOG_COMPONENT_DEFINE ("EnbMacEntity");
namespace ns3 {
NS_OBJECT_ENSURE_REGISTERED (EnbMacEntity);
TypeId EnbMacEntity::GetTypeId (void)
{
static TypeId tid = TypeId ("ns3::EnbMacEntity")
.SetParent<Object> ();
return tid;
}
EnbMacEntity::EnbMacEntity ()
{
SetAmcModule (CreateObject<AmcModule> ());
m_downlinkScheduler = CreateObject<SimplePacketScheduler> ();
m_downlinkScheduler->SetMacEntity (this);
m_uplinkScheduler = 0;
}
EnbMacEntity::~EnbMacEntity ()
{
m_downlinkScheduler = 0;
m_uplinkScheduler = 0;
}
void
EnbMacEntity::SetUplinkPacketScheduler (Ptr<PacketScheduler> s)
{
NS_LOG_FUNCTION (this << s);
m_uplinkScheduler = s;
}
void
EnbMacEntity::SetDownlinkPacketScheduler (Ptr<PacketScheduler> s)
{
NS_LOG_FUNCTION (this << s);
m_downlinkScheduler = s;
}
Ptr<PacketScheduler>
EnbMacEntity::GetUplinkPacketScheduler (void)
{
NS_LOG_FUNCTION (this);
return m_uplinkScheduler;
}
Ptr<PacketScheduler>
EnbMacEntity::GetDownlinkPacketScheduler (void)
{
NS_LOG_FUNCTION (this);
return m_downlinkScheduler;
}
void
EnbMacEntity::ReceiveCqiIdealControlMessage (CqiIdealControlMessage* msg)
{
NS_LOG_FUNCTION (this << msg);
NS_LOG_FUNCTION (this << msg->GetSourceDevice () << msg->GetDestinationDevice ());
CqiIdealControlMessage::CqiFeedbacks *cqi = msg->GetMessage ();
Ptr<UeNetDevice> ue = msg->GetSourceDevice ()->GetObject<UeNetDevice> ();
Ptr<UeRecord> record = GetDevice ()->GetObject<EnbNetDevice> ()->GetUeManager ()->GetUeRecord (ue);
UeRecord::CqiFeedbacks cqiFeedbacks;
// STORE RECEIVED CQI FEEDBACKS INTO A PROPER UeRecord
for (CqiIdealControlMessage::CqiFeedbacks::iterator it = cqi->begin (); it != cqi->end (); it++)
{
NS_LOG_FUNCTION (this << "cqi " << (*it).m_idSubChannel << (*it).m_cqi);
UeRecord::CqiFeedback cqi;
cqi.m_subChannelId = (*it).m_idSubChannel;
cqi.m_cqi = (*it).m_cqi;
cqiFeedbacks.push_back (cqi);
}
record->SetCqiFeedbacks (cqiFeedbacks);
}
void
EnbMacEntity::SendPdcchMapIdealControlMessage (PdcchMapIdealControlMessage* msg)
{
NS_LOG_FUNCTION (this << msg);
std::vector< Ptr<UeRecord> >* ues = GetDevice ()->GetObject<EnbNetDevice> ()->GetUeManager ()->GetUeRecords ();
std::vector< Ptr<UeRecord> >::iterator it;
Ptr<UeNetDevice> ue;
for (it = ues->begin (); it != ues->end (); it++)
{
ue = (*it)->GetUe ()->GetObject<UeNetDevice> ();
ue->GetPhy ()->ReceiveIdealControlMessage (msg);
}
}
} // namespacens3

86
src/devices/lte/model/enb-mac-entity.h

@ -0,0 +1,86 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Giuseppe Piro <g.piro@poliba.it>
*/
#ifndef ENB_MAC_ENTITY_H
#define ENB_MAC_ENTITY_H
#include "ns3/object.h"
#include <list>
#include "mac-entity.h"
namespace ns3 {
class PacketScheduler;
class CqiIdealControlMessage;
class PdcchMapIdealControlMessage;
/**
* This class implements the MAC layer of the eNodeB device
*/
class EnbMacEntity : public MacEntity
{
public:
static TypeId GetTypeId (void);
EnbMacEntity (void);
virtual ~EnbMacEntity (void);
/**
* \brief Set the uplink packet scheduler
* \param s the packet scheduler for the uplink
*/
void SetUplinkPacketScheduler (Ptr<PacketScheduler> s);
/**
* \brief Set the downlink packet scheduler
* \param s the packet scheduler for the downlink
*/
void SetDownlinkPacketScheduler (Ptr<PacketScheduler> s);
/**
* \brief Get the uplink packet scheduler
* \return the pointer to the uplink packet scheduler
*/
Ptr<PacketScheduler> GetUplinkPacketScheduler (void);
/**
* \brief Get the downlink packet scheduler
* \return the pointer to the downlink packet scheduler
*/
Ptr<PacketScheduler> GetDownlinkPacketScheduler (void);
/**
* \brief Receive a CQI ideal control message
* \param msg the message
*/
void ReceiveCqiIdealControlMessage (CqiIdealControlMessage* msg);
/**
* \brief Send the PDCCH control message
* \param msg the message
*/
void SendPdcchMapIdealControlMessage (PdcchMapIdealControlMessage* msg);
private:
Ptr<PacketScheduler> m_uplinkScheduler;
Ptr<PacketScheduler> m_downlinkScheduler;
};
} // namespace ns3
#endif /* ENB_MAC_ENTITY_H */

225
src/devices/lte/model/enb-net-device.cc

@ -0,0 +1,225 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Giuseppe Piro <g.piro@poliba.it>
*/
#include "ns3/llc-snap-header.h"
#include "ns3/simulator.h"
#include "ns3/callback.h"
#include "ns3/node.h"
#include "ns3/packet.h"
#include "lte-net-device.h"
#include "ns3/packet-burst.h"
#include "ns3/uinteger.h"
#include "ns3/trace-source-accessor.h"
#include "ns3/pointer.h"
#include "ns3/enum.h"
#include "radio-bearer-instance.h"
#include "amc-module.h"
#include "ue-record.h"
#include "ue-manager.h"
#include "enb-mac-entity.h"
#include "enb-net-device.h"
#include "packet-scheduler.h"
#include "rlc-entity.h"
#include "rrc-entity.h"
#include "lte-mac-header.h"
#include "ue-net-device.h"
#include "enb-phy.h"
NS_LOG_COMPONENT_DEFINE ("EnbNetDevice");
namespace ns3 {
NS_OBJECT_ENSURE_REGISTERED ( EnbNetDevice);
TypeId EnbNetDevice::GetTypeId (void)
{
static TypeId
tid =
TypeId ("ns3::EnbNetDevice")
.SetParent<LteNetDevice> ()
/*
.AddAttribute ("UeManager",
"The UE manager attached to this device.",
PointerValue (),
MakePointerAccessor (&EnbNetDevice::GetUeManager,
&EnbNetDevice::SetUeManager),
MakePointerChecker<UeManager> ())*/;
return tid;
}
EnbNetDevice::EnbNetDevice (void)
{
NS_LOG_FUNCTION (this);
InitEnbNetDevice ();
}
EnbNetDevice::EnbNetDevice (Ptr<Node> node, Ptr<LtePhy> phy)
{
NS_LOG_FUNCTION (this);
InitEnbNetDevice ();
SetNode (node);
SetPhy (phy);
}
EnbNetDevice::~EnbNetDevice (void)
{
NS_LOG_FUNCTION (this);
m_ueManager = 0;
m_macEntity = 0;
}
void
EnbNetDevice::InitEnbNetDevice (void)
{
NS_LOG_FUNCTION (this);
SetRrcEntity (CreateObject<RrcEntity> ());
m_ueManager = CreateObject<UeManager> ();
m_macEntity = CreateObject<EnbMacEntity> ();
m_macEntity->SetDevice (this->GetObject<LteNetDevice> ());
SetNode (0);
SetPhy (0);
}
void
EnbNetDevice::DoDispose (void)
{
NS_LOG_FUNCTION (this);
LteNetDevice::DoDispose ();
m_ueManager = 0;
m_macEntity = 0;
}
void
EnbNetDevice::Start (void)
{
NS_LOG_FUNCTION (this);
Simulator::ScheduleNow (&EnbLtePhy::StartFrame, GetPhy ()->GetObject<EnbLtePhy> ());
}
void
EnbNetDevice::Stop (void)
{
NS_LOG_FUNCTION (this);
}
void
EnbNetDevice::SetUeManager (Ptr<UeManager> m)
{
NS_LOG_FUNCTION (this);
m_ueManager = m;
}
Ptr<UeManager>
EnbNetDevice::GetUeManager (void)
{
NS_LOG_FUNCTION (this);
return m_ueManager;
}
void
EnbNetDevice::SetMacEntity (Ptr<EnbMacEntity> m)
{
NS_LOG_FUNCTION (this);
m_macEntity = m;
}
Ptr<EnbMacEntity>
EnbNetDevice::GetMacEntity (void)
{
NS_LOG_FUNCTION (this);
return m_macEntity;
}
bool
EnbNetDevice::DoSend (Ptr<Packet> packet, const Mac48Address& source,
const Mac48Address& dest, uint16_t protocolNumber)
{
NS_LOG_FUNCTION (this << source << dest << protocolNumber);
/*
* The classification of traffic in DL is done by the PGW (not
* by the eNB).
* Hovever, the core network is not implemented yet.
* For now the classification is managed by the eNB.
*/
//Ptr<RadioBearerInstance> bearer = GetRrcEntity ()->GetDefaultBearer ();
Ptr<RadioBearerInstance> bearer;
if (protocolNumber == 2048)
{
// it is an IP packet
bearer = GetRrcEntity ()->Classify (packet);
}
if (protocolNumber != 2048 || bearer == 0)
{
bearer = GetRrcEntity ()->GetDefaultBearer ();
}
return bearer->Enqueue (packet);
}
void
EnbNetDevice::DoReceive (Ptr<Packet> p)
{
NS_LOG_FUNCTION (this << p);
ForwardUp (p->Copy ());
}
void
EnbNetDevice::StartTransmission (void)
{
NS_LOG_FUNCTION (this);
GetPhy ()->SendPacket (GetPacketToSend ());
}
bool
EnbNetDevice::SendPacket (Ptr<PacketBurst> p)
{
NS_LOG_FUNCTION (this);
return GetPhy ()->GetDownlinkSpectrumPhy ()->StartTx (p);
}
void
EnbNetDevice::SendIdealPdcchMessage (void)
{
NS_LOG_FUNCTION (this);
/*
* Get both PDCCH ideal message for UL and DL and
* set assigned resources to UEs using
* SendAssignedDLResources and SendAssignedULResources
*/
}
} // namespace ns3

139
src/devices/lte/model/enb-net-device.h

@ -0,0 +1,139 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Giuseppe Piro <g.piro@poliba.it>
*/
#ifndef ENB_NET_DEVICE_H
#define ENB_NET_DEVICE_H
#include "lte-net-device.h"
#include "ns3/event-id.h"
#include "ns3/mac48-address.h"
#include "ns3/traced-callback.h"
#include "ns3/nstime.h"
#include "ns3/log.h"
#include "lte-phy.h"
#include <vector>
namespace ns3 {
class Packet;
class PacketBurst;
class Node;
class LtePhy;
class UeManager;
class UeNetDevice;
class EnbMacEntity;
/**
* The eNodeB device implementation
*/
class EnbNetDevice : public LteNetDevice
{
public:
static TypeId GetTypeId (void);
EnbNetDevice (void);
/**
* \brief Create eNB net device
* \param node the network node
* \param phy the physical object attache dto it
*/
EnbNetDevice (Ptr<Node> node, Ptr<LtePhy> phy);
virtual ~EnbNetDevice (void);
void DoDispose (void);
/**
* \brief Initialize all parameters of this device
*/
void InitEnbNetDevice (void);
/**
* \brief Starts the run of this device
*/
void Start (void);
/**
* \brief Stops the run of this device
*/
void Stop (void);
/**
* \brief Set the UE manager
* \param m the UE manager
*/
void SetUeManager (Ptr<UeManager> m);
/**
* \brief Get the UE manager
* \return the pointer to the UE manager
*/
Ptr<UeManager> GetUeManager (void);
/**
* \brief Set the MAC entity
* \param m the MAC entity
*/
void SetMacEntity (Ptr<EnbMacEntity> m);
/**
* \brief Get the MAC entity
* \return the pointer to the MAC entity
*/
Ptr<EnbMacEntity> GetMacEntity (void);
/**
* \brief Start packet transmission.
* This functipon will called at the end of downlink scheduling
* to start the transmission of the burst of packet created by the
* packet-scheduler.
*/
void StartTransmission (void);
/**
* \brief Send a pachet burst to the physical layer
* \param p the packet burst
* \return
*/
bool SendPacket (Ptr<PacketBurst> p);
/**
* \brief Send the PDCCH ideal mesages under an
* ideal control channel
*/
void SendIdealPdcchMessage (void);
private:
bool DoSend (Ptr<Packet> packet,
const Mac48Address& source,
const Mac48Address& dest,
uint16_t protocolNumber);
void DoReceive (Ptr<Packet> p);
Ptr<UeManager> m_ueManager;
Ptr<EnbMacEntity> m_macEntity;
};
} // namespace ns3
#endif /* ENB_NET_DEVICE_H */

208
src/devices/lte/model/enb-phy.cc

@ -0,0 +1,208 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Giuseppe Piro <g.piro@poliba.it>
*/
#include <ns3/waveform-generator.h>
#include <ns3/object-factory.h>
#include <ns3/log.h>
#include <math.h>
#include <ns3/simulator.h>
#include "ns3/spectrum-error-model.h"
#include "enb-phy.h"
#include "lte-net-device.h"
#include "lte-spectrum-value-helper.h"
#include "ideal-control-messages.h"
#include "enb-net-device.h"
#include "enb-mac-entity.h"
#include "packet-scheduler.h"
NS_LOG_COMPONENT_DEFINE ("EnbLtePhy");
namespace ns3 {
NS_OBJECT_ENSURE_REGISTERED (EnbLtePhy);
EnbLtePhy::EnbLtePhy ()
{
SetDevice (0);
SetDownlinkSpectrumPhy (0);
SetUplinkSpectrumPhy (0);
SetTxPower (43); // dBm
SetTti (0.001);
SetNrFrames (0);
SetNrSubFrames (0);
}
EnbLtePhy::EnbLtePhy (Ptr<LteNetDevice> d)
{
SetDevice (d);
SetDownlinkSpectrumPhy (0);
SetUplinkSpectrumPhy (0);
SetTxPower (43); // dBm
SetTti (0.001);
SetNrFrames (0);
SetNrSubFrames (0);
}
TypeId
EnbLtePhy::GetTypeId (void)
{
static TypeId tid = TypeId ("ns3::EnbLtePhy")
.SetParent<Object> ()
.AddConstructor<EnbLtePhy> ()
;
return tid;
}
EnbLtePhy::~EnbLtePhy ()
{
}
bool
EnbLtePhy::SendPacket (Ptr<PacketBurst> pb)
{
NS_LOG_FUNCTION (this << pb->GetNPackets () << pb->GetSize ());
return GetDownlinkSpectrumPhy ()->StartTx (pb);
}
void
EnbLtePhy::DoSetDownlinkSubChannels ()
{
NS_LOG_FUNCTION (this);
Ptr<SpectrumValue> txPsd = CreateTxPowerSpectralDensity ();
GetDownlinkSpectrumPhy ()->SetTxPowerSpectralDensity (txPsd);
}
Ptr<SpectrumValue>
EnbLtePhy::CreateTxPowerSpectralDensity ()
{
NS_LOG_FUNCTION (this);
LteSpectrumValueHelper psdHelper;
Ptr<SpectrumValue> psd = psdHelper.CreateDownlinkTxPowerSpectralDensity (GetTxPower (), GetDownlinkSubChannels ());
return psd;
}
void
EnbLtePhy::CalcChannelQualityForUe (std::vector <double> sinr, Ptr<LteSpectrumPhy> ue)
{
NS_LOG_FUNCTION (this);
}
void
EnbLtePhy::SendIdealControlMessage (IdealControlMessage* msg)
{
NS_LOG_FUNCTION (this << msg);
}
void
EnbLtePhy::ReceiveIdealControlMessage (IdealControlMessage* msg)
{
NS_LOG_FUNCTION (this << msg);
if (msg->GetMessageType () == IdealControlMessage::CQI_FEEDBACKS)
{
CqiIdealControlMessage* msg2 = dynamic_cast<CqiIdealControlMessage*> (msg);
Ptr<EnbMacEntity> macEntity = GetDevice ()->GetObject<EnbNetDevice> ()->GetMacEntity ();
macEntity->ReceiveCqiIdealControlMessage (msg2);
}
else
{
// XXX at this time, the eNB must receive only CQI feedbacks!
}
}
void
EnbLtePhy::StartFrame (void)
{
NS_LOG_FUNCTION (this << Simulator::Now ().GetSeconds ());
NS_LOG_INFO ("-----frame " << GetNrFrames () + 1 << "-----");
SetNrFrames (GetNrFrames () + 1);
SetNrSubFrames (0);
StartSubFrame ();
}
void
EnbLtePhy::StartSubFrame (void)
{
NS_LOG_FUNCTION (this << Simulator::Now ().GetSeconds ());
NS_LOG_INFO ("-----sub frame " << GetNrSubFrames () + 1 << "-----");
SetNrSubFrames (GetNrSubFrames () + 1);
/*
XXX: the packet scheduler is not implemented yet!
The enb take the fist packet from the default bearer
and send it.
*/
Ptr<EnbMacEntity> macEntity = GetDevice ()->GetObject<EnbNetDevice> ()->GetMacEntity ();
// macEntity->GetUplinkPacketScheduler ()->RunPacketScheduler ();
macEntity->GetDownlinkPacketScheduler ()->RunPacketScheduler ();
Simulator::Schedule (Seconds (GetTti ()),
&EnbLtePhy::EndSubFrame,
this);
}
void
EnbLtePhy::EndSubFrame (void)
{
NS_LOG_FUNCTION (this << Simulator::Now ().GetSeconds ());
if (GetNrSubFrames () == 10)
{
Simulator::ScheduleNow (&EnbLtePhy::EndFrame, this);
}
else
{
Simulator::ScheduleNow (&EnbLtePhy::StartSubFrame, this);
}
}
void
EnbLtePhy::EndFrame (void)
{
NS_LOG_FUNCTION (this << Simulator::Now ().GetSeconds ());
Simulator::ScheduleNow (&EnbLtePhy::StartFrame, this);
}
};

105
src/devices/lte/model/enb-phy.h

@ -0,0 +1,105 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Giuseppe Piro <g.piro@poliba.it>
*/
#ifndef ENB_LTE_PHY_H
#define ENB_LTE_PHY_H
#include "lte-phy.h"
namespace ns3 {
class PacketBurst;
class LteNetDevice;
/**
* EnbLtePhy models the physical layer for the eNodeB
*/
class EnbLtePhy : public LtePhy
{
public:
EnbLtePhy ();
/**
* \brief Create the eNB phy layer
* \param d the device where the phy layer is attached
*/
EnbLtePhy (Ptr<LteNetDevice> d);
virtual ~EnbLtePhy ();
static TypeId GetTypeId (void);
/**
* \brief Send a burst of packet to the channel
* \param pb a burst of packet to the channel
*/
virtual bool SendPacket (Ptr<PacketBurst> pb);
void DoSetDownlinkSubChannels ();
/**
* \brief Create the PSD for TX
*/
virtual Ptr<SpectrumValue> CreateTxPowerSpectralDensity ();
/**
* \brief Calculate the channel quality for a given UE
* \param sinr a list of computed SINR
* \param ue the UE
*/
void CalcChannelQualityForUe (std::vector <double> sinr, Ptr<LteSpectrumPhy> ue);
/**
* \brief Send the control message
* \param msg the message to send
*/
virtual void SendIdealControlMessage (IdealControlMessage* msg);
/**
* \brief Receive the control message
* \param msg the received message
*/
virtual void ReceiveIdealControlMessage (IdealControlMessage* msg);
/**
* \brief Start a LTE frame
*/
void StartFrame (void);
/**
* \brief Start a LTE sub frame
*/
void StartSubFrame (void);
/**
* \brief End a LTE sub frame
*/
void EndSubFrame (void);
/**
* \brief End a LTE frame
*/
void EndFrame (void);
private:
};
}
#endif /* ENB_PHY_H */

188
src/devices/lte/model/ideal-control-messages.cc

@ -0,0 +1,188 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Giuseppe Piro <g.piro@poliba.it>
*/
#include "ideal-control-messages.h"
#include "ns3/address-utils.h"
#include "ns3/uinteger.h"
#include "ns3/log.h"
#include "lte-net-device.h"
#include "ue-net-device.h"
NS_LOG_COMPONENT_DEFINE ("IdealControlMessage");
namespace ns3 {
NS_OBJECT_ENSURE_REGISTERED ( IdealControlMessage);
IdealControlMessage::IdealControlMessage (void)
: m_source (0),
m_destination (0)
{
}
IdealControlMessage::~IdealControlMessage (void)
{
}
TypeId
IdealControlMessage::GetTypeId (void)
{
static TypeId tid = TypeId ("ns3::IdealControlMessage")
.SetParent<Object> ()
;
return tid;
}
void
IdealControlMessage::SetSourceDevice (Ptr<LteNetDevice> src)
{
m_source = src;
}
void
IdealControlMessage::SetDestinationDevice (Ptr<LteNetDevice> dst)
{
m_destination = dst;
}
Ptr<LteNetDevice>
IdealControlMessage::GetSourceDevice (void)
{
return m_source;
}
Ptr<LteNetDevice>
IdealControlMessage::GetDestinationDevice (void)
{
return m_destination;
}
void
IdealControlMessage::SetMessageType (IdealControlMessage::MessageType type)
{
m_type = type;
}
IdealControlMessage::MessageType
IdealControlMessage::GetMessageType (void)
{
return m_type;
}
// ----------------------------------------------------------------------------------------------------------
NS_OBJECT_ENSURE_REGISTERED ( PdcchMapIdealControlMessage);
PdcchMapIdealControlMessage::PdcchMapIdealControlMessage (void)
{
m_idealPdcchMessage = new IdealPdcchMessage ();
SetMessageType (IdealControlMessage::ALLOCATION_MAP);
}
PdcchMapIdealControlMessage::~PdcchMapIdealControlMessage (void)
{
m_idealPdcchMessage = 0;
}
TypeId
PdcchMapIdealControlMessage::GetTypeId (void)
{
static TypeId tid = TypeId ("ns3::PdcchMapIdealControlMessage")
.SetParent<IdealControlMessage> ()
;
return tid;
}
void
PdcchMapIdealControlMessage::AddNewRecord (Direction direction,
int subChannel, Ptr<LteNetDevice> ue, double mcs)
{
}
PdcchMapIdealControlMessage::IdealPdcchMessage*
PdcchMapIdealControlMessage::GetMessage (void)
{
return m_idealPdcchMessage;
}
// ----------------------------------------------------------------------------------------------------------
NS_OBJECT_ENSURE_REGISTERED ( CqiIdealControlMessage);
CqiIdealControlMessage::CqiIdealControlMessage (void)
{
m_cqiFeedbacks = new CqiFeedbacks ();
SetMessageType (IdealControlMessage::CQI_FEEDBACKS);
}
CqiIdealControlMessage::~CqiIdealControlMessage (void)
{
m_cqiFeedbacks = 0;
}
TypeId
CqiIdealControlMessage::GetTypeId (void)
{
static TypeId tid = TypeId ("ns3::CqiIdealControlMessage")
.SetParent<IdealControlMessage> ()
;
return tid;
}
void
CqiIdealControlMessage::AddNewRecord (int subChannel, double cqi)
{
CqiFeedback c;
c.m_idSubChannel = subChannel;
c.m_cqi = cqi;
m_cqiFeedbacks->push_back (c);
}
CqiIdealControlMessage::CqiFeedbacks*
CqiIdealControlMessage::GetMessage (void)
{
return m_cqiFeedbacks;
}
} // namespace ns3

248
src/devices/lte/model/ideal-control-messages.h

@ -0,0 +1,248 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Giuseppe Piro <g.piro@poliba.it>
*/
#ifndef IDEAL_CONTROL_MESSAGES_H
#define IDEAL_CONTROL_MESSAGES_H
#include "ns3/object.h"
#include "ns3/simple-ref-count.h"
#include <list>
namespace ns3 {
class LteNetDevice;
/**
* The IdealControlMessage provides a basic implementations for
* control messages (such as PDCCH allocation map, CQI feedbacks)
* that are exchanged among eNodeB and UEs.
*/
class IdealControlMessage : public SimpleRefCount<IdealControlMessage>
{
public:
static TypeId GetTypeId (void);
/**
* The type of the message
*/
enum MessageType
{
CQI_FEEDBACKS, ALLOCATION_MAP
};
IdealControlMessage (void);
virtual ~IdealControlMessage (void);
/**
* \brief Set the source device of the message
* \param src the device that sends the message
*/
void SetSourceDevice (Ptr<LteNetDevice> src);
/**
* \brief Set the destination device of the message
* \param dst the device that receives the message
*/
void SetDestinationDevice (Ptr<LteNetDevice> dst);
/**
* \brief Get the source device of the message
* \return the pointer to the device that sends the message
*/
Ptr<LteNetDevice> GetSourceDevice (void);
/**
* \brief Get the destination device of the message
* \return the pointer to the device that receives the message
*/
Ptr<LteNetDevice> GetDestinationDevice (void);
/**
* \brief Set the type of the message
* \param type the type of the message
*/
void SetMessageType (MessageType type);
/**
* \brief Get the type of the message
* \return the type of the message
*/
MessageType GetMessageType (void);
private:
Ptr<LteNetDevice> m_source;
Ptr<LteNetDevice> m_destination;
MessageType m_type;
};
} // namespace ns3
#endif /* IDEAL_CONTROL_MESSAGES_H */
// ----------------------------------------------------------------------------------------------------------
#ifndef PDCCH_MAP_IDEAL_CONTROL_MESSAGES_H
#define PDCCH_MAP_IDEAL_CONTROL_MESSAGES_H
#include "ns3/object.h"
#include <list>
namespace ns3 {
class LteNetDevice;
/**
* \brief The PdcchMapIdealControlMessage defines an ideal allocation map
* for both UL and DL sends by the eNodeB to all UE,
* using an ideal PDCCH control channel.
* IdealPdcchMessage is composed by a list of IdealPdcchRecord
* where is indicated the UE that can use a particular sub channel
* with a proper MCS scheme.
* This records are the same for both UL and DL, and are created by the
* packet scheduler at the beginning of each sub frame.
* When the IdealPdcchMessage is sent under an ideal control channel,
* all UE stores into a proper variables the informations about
* the resource mapping.
*/
class PdcchMapIdealControlMessage : public IdealControlMessage
{
public:
static TypeId GetTypeId (void);
PdcchMapIdealControlMessage (void);
virtual ~PdcchMapIdealControlMessage (void);
/**
* Direction for which the message is created
*/
enum Direction
{
DOWNLINK, UPLINK
};
/**
* The PDCCH ideal record
*/
struct IdealPdcchRecord
{
/** the direction */
Direction m_direction;
/** the sub channel */
int m_idSubChannel;
/** the ue that receive the mapping */
Ptr<LteNetDevice> m_ue;
/** the selected msc */
double m_mcsIndex;
};
/**
* The PDCCH ideal message
*/
typedef std::list<struct IdealPdcchRecord> IdealPdcchMessage;
/**
* \brief add a PDCCH record into the message.
* \param direction the direction of the map
* \param subChannel the scheduled sub channel
* \param ue the ue the can use the sub channel for transmission
* \param mcs the selected MCS scheme
*/
void AddNewRecord (Direction direction,
int subChannel, Ptr<LteNetDevice> ue, double mcs);
/**
* \brief Get the message
* \return the pointer to the message
*/
IdealPdcchMessage* GetMessage (void);
private:
IdealPdcchMessage *m_idealPdcchMessage;
};
} // namespace ns3
#endif /* PDCCH_MAP_IDEAL_CONTROL_MESSAGES_H */
// ----------------------------------------------------------------------------------------------------------
#ifndef CQI_IDEAL_CONTROL_MESSAGES_H
#define CQI_IDEAL_CONTROL_MESSAGES_H
#include "ns3/object.h"
#include <list>
namespace ns3 {
class LteNetDevice;
/**
* The CqiIdealControlMessage defines an ideal list of feedback about
* the channel quality sent by the UE to the eNodeB.
*/
class CqiIdealControlMessage : public IdealControlMessage
{
public:
static TypeId GetTypeId (void);
CqiIdealControlMessage (void);
virtual ~CqiIdealControlMessage (void);
/**
* The CQI feedback ideal record
*/
struct CqiFeedback
{
/** the sub channel */
int m_idSubChannel;
/** the cqi feedback */
double m_cqi;
};
/**
* The ideal CQI feedback message
*/
typedef std::list<struct CqiFeedback> CqiFeedbacks;
/**
* \brief add a CQI feedback record into the message.
* \param subChannel the scheduled sub channel
* \param cqi the cqi feedback
*/
void AddNewRecord (int subChannel, double cqi);
/**
* \brief Get cqi informations
* \return cqi messages
*/
CqiFeedbacks* GetMessage (void);
private:
CqiFeedbacks *m_cqiFeedbacks;
};
} // namespace ns3
#endif /* CQI_IDEAL_CONTROL_MESSAGES_H */

100
src/devices/lte/model/loss-model.cc

@ -0,0 +1,100 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Giuseppe Piro <g.piro@poliba.it>
*/
#include <ns3/log.h>
#include <ns3/simulator.h>
#include "loss-model.h"
NS_LOG_COMPONENT_DEFINE ("DiscreteTimeLossModel");
namespace ns3 {
NS_OBJECT_ENSURE_REGISTERED (DiscreteTimeLossModel);
DiscreteTimeLossModel::DiscreteTimeLossModel ()
{
}
TypeId
DiscreteTimeLossModel::GetTypeId (void)
{
static TypeId tid = TypeId ("ns3::DiscreteTimeLossModel")
.SetParent<Object> ()
.AddConstructor<DiscreteTimeLossModel> ()
;
return tid;
}
DiscreteTimeLossModel::~DiscreteTimeLossModel ()
{
}
void
DiscreteTimeLossModel::SetLastUpdate (void)
{
NS_LOG_FUNCTION (this);
m_lastUpdate = Simulator::Now () ;
}
Time
DiscreteTimeLossModel::GetLastUpdate (void)
{
NS_LOG_FUNCTION (this);
return m_lastUpdate;
}
void
DiscreteTimeLossModel::SetSamplingPeriod (double sp)
{
NS_LOG_FUNCTION (this << sp);
m_samplingPeriod = sp;
}
double
DiscreteTimeLossModel::GetSamplingPeriod (void)
{
NS_LOG_FUNCTION (this);
return m_samplingPeriod;
}
bool
DiscreteTimeLossModel::NeedForUpdate (void)
{
NS_LOG_FUNCTION (this);
if (Simulator::Now ().GetSeconds () >= (GetLastUpdate ().GetSeconds () + GetSamplingPeriod ()))
{
return true;
}
else
{
return false;
}
}
} // namespace ns3

92
src/devices/lte/model/loss-model.h

@ -0,0 +1,92 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Giuseppe Piro <g.piro@poliba.it>
*/
#ifndef DISCRETE_TIME_LOSS_MODEL_H
#define DISCRETE_TIME_LOSS_MODEL_H
#include <ns3/nstime.h>
#include "ns3/object.h"
namespace ns3 {
/**
* \brief The DiscreteTimeLossModel class offers a basic implementation
* for all propagation loss models used for LTE networks
*/
class DiscreteTimeLossModel : public Object
{
public:
DiscreteTimeLossModel ();
virtual ~DiscreteTimeLossModel ();
static TypeId GetTypeId (void);
/**
* \brief Set the time in which the model has been
* updated.
* Each model can be updated every Sampling interval. Every time
* the model is updated, the variable m_lastUpdate will be set to
* the current simulation time.
*/
void SetLastUpdate (void);
/**
* \brief Get the time in which the model has been
* updated
*
* \return the time instant in which the model have been updated
*/
Time GetLastUpdate (void);
/**
* \brief Set the time interval every time the model
* should be updated
*
* \param sp the time interval
*/
void SetSamplingPeriod (double sp);
/**
* \brief Get the time interval every time the model
* should be updated
*
* \return the time interval
*/
double GetSamplingPeriod (void);
/**
* \brief Check if the model should be updated
*/
bool NeedForUpdate (void);
private:
Time m_lastUpdate;
double m_samplingPeriod;
};
}
#endif /* DISCRETE_TIME_LOSS_MODEL_H */

109
src/devices/lte/model/lte-mac-header.cc

@ -0,0 +1,109 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Giuseppe Piro <g.piro@poliba.it>
*/
#include <ns3/log.h>
#include "lte-mac-header.h"
NS_LOG_COMPONENT_DEFINE ("LteMacHeader");
namespace ns3 {
TypeId
LteMacHeader::GetTypeId (void)
{
static TypeId tid = TypeId ("LteMacHeader")
.SetParent<Header> ()
.AddConstructor<LteMacHeader> ()
;
return tid;
}
TypeId
LteMacHeader::GetInstanceTypeId (void) const
{
return GetTypeId ();
}
uint32_t
LteMacHeader::GetSerializedSize (void) const
{
return 13;
}
void
LteMacHeader::Serialize (Buffer::Iterator start) const
{
WriteTo (start, m_destination);
WriteTo (start, m_source);
}
uint32_t
LteMacHeader::Deserialize (Buffer::Iterator start)
{
ReadFrom (start, m_destination);
ReadFrom (start, m_source);
return GetSerializedSize ();
}
void
LteMacHeader::Print (std::ostream &os) const
{
os << "src=" << m_source
<< "dst=" << m_destination;
}
void
LteMacHeader::SetSource (Mac48Address source)
{
m_source = source;
}
Mac48Address
LteMacHeader::GetSource () const
{
return m_source;
}
void
LteMacHeader::SetDestination (Mac48Address dst)
{
m_destination = dst;
}
Mac48Address
LteMacHeader::GetDestination () const
{
return m_destination;
}
} // namespace ns3

74
src/devices/lte/model/lte-mac-header.h

@ -0,0 +1,74 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Giuseppe Piro <g.piro@poliba.it>
*/
#ifndef LTE_MAC_HEADER_H
#define LTE_MAC_HEADER_H
#include <ns3/header.h>
#include <ns3/mac48-address.h>
#include <ns3/address-utils.h>
namespace ns3 {
/**
* This class implements the LTE MAC header
*/
class LteMacHeader : public Header
{
public:
static TypeId GetTypeId (void);
virtual TypeId GetInstanceTypeId (void) const;
virtual uint32_t GetSerializedSize (void) const;
virtual void Serialize (Buffer::Iterator start) const;
virtual uint32_t Deserialize (Buffer::Iterator start);
virtual void Print (std::ostream &os) const;
/**
* \brief set the source MAC address
* \param source the source mac address
*/
void SetSource (Mac48Address source);
/**
* \brief set the the destination MAC address
* \param destination the destination MAC address
*/
void SetDestination (Mac48Address destination);
/**
* \brief get the the source MAC address
* \return the source MAC address
*/
Mac48Address GetSource () const;
/**
* \brief get the the destination MAC address
* \return the destination MAC address
*/
Mac48Address GetDestination () const;
private:
Mac48Address m_source;
Mac48Address m_destination;
};
} // namespace ns3
#endif /* LTE_MAC_HEADER_H */

247
src/devices/lte/model/lte-mac-queue.cc

@ -0,0 +1,247 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Giuseppe Piro <g.piro@poliba.it>
*/
#include "lte-mac-queue.h"
#include "ns3/packet.h"
#include "ns3/trace-source-accessor.h"
#include "ns3/uinteger.h"
#include "ns3/simulator.h"
#include "ns3/log.h"
NS_LOG_COMPONENT_DEFINE ("LteMacQueue");
namespace ns3 {
NS_OBJECT_ENSURE_REGISTERED (LteMacQueue);
LteMacQueue::QueueElement::QueueElement (void)
: m_packet (Create<Packet> ()),
m_timeStamp (Seconds (0))
{
}
LteMacQueue::QueueElement::QueueElement (Ptr<Packet> packet, Time timeStamp)
: m_packet (packet),
m_timeStamp (timeStamp)
{
}
uint32_t
LteMacQueue::QueueElement::GetSize (void) const
{
NS_LOG_FUNCTION (this);
// XXX: ADD mac/RLC/CRC OVERHEADs ?!?
uint32_t size = m_packet->GetSize ();
return size;
}
TypeId
LteMacQueue::GetTypeId (void)
{
static TypeId tid = TypeId ("ns3::LteMacQueue")
.SetParent<Object> ()
.AddAttribute (
"MaxSize",
"Maximum size",
UintegerValue (1024),
MakeUintegerAccessor (&LteMacQueue::GetMaxSize,
&LteMacQueue::SetMaxSize),
MakeUintegerChecker<uint32_t> ())
.AddTraceSource ("Enqueue",
"Enqueue trace",
MakeTraceSourceAccessor (&LteMacQueue::m_traceEnqueue))
.AddTraceSource ("Dequeue",
"Dequeue trace",
MakeTraceSourceAccessor (&LteMacQueue::m_traceDequeue))
.AddTraceSource ("Drop",
"Drop trace",
MakeTraceSourceAccessor (&LteMacQueue::m_traceDrop))
;
return tid;
}
LteMacQueue::LteMacQueue (void)
: m_maxSize (0),
m_bytes (0),
m_nrDataPackets (0)
{
}
LteMacQueue::LteMacQueue (uint32_t maxSize)
: m_maxSize (maxSize),
m_bytes (0),
m_nrDataPackets (0)
{
}
LteMacQueue::~LteMacQueue (void)
{
}
void
LteMacQueue::SetMaxSize (uint32_t maxSize)
{
NS_LOG_FUNCTION (this);
m_maxSize = maxSize;
}
uint32_t
LteMacQueue::GetMaxSize (void) const
{
NS_LOG_FUNCTION (this);
return m_maxSize;
}
bool
LteMacQueue::Enqueue (Ptr<Packet> packet)
{
NS_LOG_FUNCTION (this << "queue size: " << m_queue.size ());
NS_LOG_FUNCTION (this << "packet size: " << packet->GetSize ());
if (m_queue.size () == m_maxSize)
{
m_traceDrop (packet);
return false;
}
m_traceEnqueue (packet);
QueueElement element (packet, Simulator::Now ());
m_queue.push_back (element);
m_nrDataPackets++;
m_bytes += element.GetSize ();
NS_LOG_FUNCTION (this << "queue size: " << m_queue.size ());
return true;
}
Ptr<Packet>
LteMacQueue::Dequeue (void)
{
NS_LOG_FUNCTION (this);
if (!IsEmpty ())
{
QueueElement element = Front ();
Pop ();
m_nrDataPackets--;
Ptr<Packet> packet = element.m_packet;
return packet;
}
return 0;
}
Ptr<Packet>
LteMacQueue::Dequeue (uint32_t availableByte)
{
NS_LOG_FUNCTION (this << availableByte);
/*
This functiopn can be called when the UM of AM RLC mode are abilited.
*/
return 0;
}
Ptr<Packet>
LteMacQueue::Peek (void) const
{
NS_LOG_FUNCTION (this);
if (!IsEmpty ())
{
QueueElement element = m_queue.front ();
Ptr<Packet> packet = element.m_packet->Copy ();
return packet;
}
return 0;
}
uint32_t
LteMacQueue::GetSize (void) const
{
NS_LOG_FUNCTION (this);
return m_queue.size ();
}
uint32_t
LteMacQueue::GetNBytes (void) const
{
NS_LOG_FUNCTION (this);
return m_bytes;
}
uint32_t
LteMacQueue::GetQueueLengthWithMACOverhead (void)
{
NS_LOG_FUNCTION (this);
uint32_t queueSize = GetNBytes ();
// Add MAC/RLC/CRC Overhead
queueSize += GetSize () * 0; // XXX
return queueSize;
}
LteMacQueue::QueueElement
LteMacQueue::Front (void) const
{
NS_LOG_FUNCTION (this);
QueueElement element = m_queue.front ();
return element;
}
void
LteMacQueue::Pop (void)
{
NS_LOG_FUNCTION (this);
m_queue.pop_front ();
}
bool
LteMacQueue::IsEmpty (void) const
{
NS_LOG_FUNCTION (this);
return m_queue.empty ();
}
const LteMacQueue::PacketQueue &
LteMacQueue::GetPacketQueue (void) const
{
NS_LOG_FUNCTION (this);
return m_queue;
}
} // namespace ns3

156
src/devices/lte/model/lte-mac-queue.h

@ -0,0 +1,156 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Giuseppe Piro <g.piro@poliba.it>
*/
#ifndef LTE_MAC_QUEUE_H
#define LTE_MAC_QUEUE_H
#include <queue>
#include <stdint.h>
#include "ns3/packet.h"
#include "ns3/object.h"
#include "ns3/traced-callback.h"
#include "ns3/nstime.h"
namespace ns3 {
/**
* The MAC queue for each bearer
*/
class LteMacQueue : public Object
{
public:
static TypeId GetTypeId (void);
LteMacQueue (void);
/**
* Create the Mac queue defining its maximum size
* \param maxSize the maximum size of the queue
*/
LteMacQueue (uint32_t maxSize);
~LteMacQueue (void);
/**
* \brief set the maximum queue size
* \param maxSize the max queue size
*/
void SetMaxSize (uint32_t maxSize);
/**
* \return the maximum queue size
*/
uint32_t GetMaxSize (void) const;
/**
* \brief Enqueue a packet
* \param packet the packet to enqueue
*/
bool Enqueue (Ptr<Packet> packet);
/**
* \brief Dequeue a packet from the queue
* \return the first packet in the queue
*/
Ptr<Packet> Dequeue (void);
/**
* \brief Dequeue a fragment of size availableByte from the queue
* \param availableByte the size of the fragment
* \return the first packet in the queue if its size is lower than availableByte, the first availableByte of the
* first packet otherwise
*/
Ptr<Packet> Dequeue (uint32_t availableByte);
/**
* \brief Same as Dequeue but does not pop from queue
*/
Ptr<Packet> Peek (void) const;
/**
* \brief Check if there are packets into the queue
*/
bool IsEmpty (void) const;
/**
* \brief Get the size of the queue
* \return the size of the queue
*/
uint32_t GetSize (void) const;
/**
* \brief Get the number of bytes into the queue
* \return the number of bytes into the queue
*/
uint32_t GetNBytes (void) const;
/**
* \brief Get the length of the queue with MAC + RLC + CRC overheads
* \return the length of the queue with MAC + RLC + CRC overheads
*/
uint32_t GetQueueLengthWithMACOverhead (void);
private:
struct QueueElement
{
QueueElement (void);
QueueElement (Ptr<Packet> packet,
Time timeStamp);
uint32_t GetSize (void) const;
Ptr<Packet> m_packet;
Time m_timeStamp;
};
/**
* \brief Get the first element og the queue
* \return the first element og the queue
*/
LteMacQueue::QueueElement Front () const;
/**
* \brief erase the first element og the queue
*/
void Pop (void);
typedef std::deque<QueueElement> PacketQueue;
PacketQueue m_queue;
uint32_t m_maxSize;
uint32_t m_bytes;
uint32_t m_nrDataPackets;
TracedCallback<Ptr<const Packet> > m_traceEnqueue;
TracedCallback<Ptr<const Packet> > m_traceDequeue;
TracedCallback<Ptr<const Packet> > m_traceDrop;
public:
/**
* \brief Get the packet queue
* \return the apcket queue
*/
const LteMacQueue::PacketQueue & GetPacketQueue (void) const;
};
} // namespace ns3
#endif /* LTE_MAC_QUEUE_H */

411
src/devices/lte/model/lte-net-device.cc

@ -0,0 +1,411 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Giuseppe Piro <g.piro@poliba.it>
*/
#include "ns3/llc-snap-header.h"
#include "ns3/simulator.h"
#include "ns3/callback.h"
#include "ns3/node.h"
#include "ns3/packet.h"
#include "lte-net-device.h"
#include "ns3/packet-burst.h"
#include "ns3/uinteger.h"
#include "ns3/trace-source-accessor.h"
#include "ns3/pointer.h"
#include "ns3/enum.h"
#include "radio-bearer-instance.h"
#include "amc-module.h"
#include "rrc-entity.h"
#include "rlc-entity.h"
#include "lte-mac-header.h"
#include "ns3/ipv4-header.h"
NS_LOG_COMPONENT_DEFINE ("LteNetDevice");
namespace ns3 {
NS_OBJECT_ENSURE_REGISTERED ( LteNetDevice);
TypeId LteNetDevice::GetTypeId (void)
{
static TypeId
tid =
TypeId ("ns3::LteNetDevice")
.SetParent<NetDevice> ()
.AddAttribute ("Mtu", "The MAC-level Maximum Transmission Unit",
UintegerValue (1500),
MakeUintegerAccessor (&LteNetDevice::SetMtu,
&LteNetDevice::GetMtu),
MakeUintegerChecker<uint16_t> (0,MAX_MSDU_SIZE))
.AddAttribute ("Phy",
"The PHY layer attached to this device.",
PointerValue (),
MakePointerAccessor (&LteNetDevice::GetPhy, &LteNetDevice::SetPhy),
MakePointerChecker<LtePhy> ())
;
return tid;
}
LteNetDevice::LteNetDevice (void)
{
NS_LOG_FUNCTION (this);
m_rrcEntity = CreateObject<RrcEntity> ();
//m_rlcEntity = CreateObject<RlcEntity> ();
}
LteNetDevice::~LteNetDevice (void)
{
NS_LOG_FUNCTION (this);
m_rrcEntity = 0;
//m_rlcEntity = 0;
}
void
LteNetDevice::DoDispose (void)
{
NS_LOG_FUNCTION (this);
m_phy->DoDispose ();
m_phy = 0;
m_node = 0;
m_rrcEntity = 0;
//m_rlcEntity = 0;
m_phyMacTxStartCallback = MakeNullCallback< bool, Ptr<Packet> > ();
NetDevice::DoDispose ();
}
Ptr<Channel>
LteNetDevice::GetChannel (void) const
{
NS_LOG_FUNCTION (this);
return GetPhy ()->GetDownlinkSpectrumPhy ()->GetChannel ();
}
void
LteNetDevice::SetPhy (Ptr<LtePhy> phy)
{
NS_LOG_FUNCTION (this << phy);
m_phy = phy;
}
Ptr<LtePhy>
LteNetDevice::GetPhy (void) const
{
NS_LOG_FUNCTION (this);
return m_phy;
}
void
LteNetDevice::SetRrcEntity (Ptr<RrcEntity> rrc)
{
NS_LOG_FUNCTION (this << rrc);
m_rrcEntity = rrc;
}
Ptr<RrcEntity>
LteNetDevice::GetRrcEntity (void)
{
NS_LOG_FUNCTION (this);
return m_rrcEntity;
}
void
LteNetDevice::SetAddress (Address address)
{
NS_LOG_FUNCTION (this << address);
m_address = Mac48Address::ConvertFrom (address);
}
Address
LteNetDevice::GetAddress (void) const
{
NS_LOG_FUNCTION (this);
return m_address;
}
void
LteNetDevice::SetNode (Ptr<Node> node)
{
NS_LOG_FUNCTION (this << node);
m_node = node;
}
Ptr<Node>
LteNetDevice::GetNode (void) const
{
NS_LOG_FUNCTION (this);
return m_node;
}
void
LteNetDevice::SetReceiveCallback (ReceiveCallback cb)
{
NS_LOG_FUNCTION (this);
m_rxCallback = cb;
}
void
LteNetDevice::ForwardUp (Ptr<Packet> packet, const Mac48Address &source, const Mac48Address &dest)
{
}
void
LteNetDevice::ForwardUp (Ptr<Packet> packet)
{
NS_LOG_FUNCTION (this << packet);
m_macRxTrace (packet);
LteMacHeader header;
packet->RemoveHeader (header);
NS_LOG_LOGIC ("packet " << header.GetSource () << " --> " << header.GetDestination () << " (here: " << m_address << ")");
LlcSnapHeader llc;
packet->RemoveHeader (llc);
m_rxCallback (this, packet, llc.GetType (), header.GetSource ());
}
bool
LteNetDevice::Send (Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber)
{
NS_LOG_FUNCTION (packet << dest << protocolNumber);
return SendFrom (packet, m_address, dest, protocolNumber);
}
bool
LteNetDevice::SendFrom (Ptr<Packet> packet, const Address& source, const Address& dest, uint16_t protocolNumber)
{
NS_LOG_FUNCTION (packet << source << dest << protocolNumber);
LlcSnapHeader llcHdr;
llcHdr.SetType (protocolNumber);
packet->AddHeader (llcHdr);
Mac48Address from = Mac48Address::ConvertFrom (source);
Mac48Address to = Mac48Address::ConvertFrom (dest);
LteMacHeader header;
header.SetSource (from);
header.SetDestination (to);
packet->AddHeader (header);
// m_macTxTrace (packet);
return DoSend (packet, from, to, protocolNumber);
}
bool
LteNetDevice::SupportsSendFrom (void) const
{
NS_LOG_FUNCTION (this);
return false;
}
void
LteNetDevice::SetPhyMacTxStartCallback (PhyMacTxStartCallback c)
{
NS_LOG_FUNCTION (this);
m_phyMacTxStartCallback = c;
}
void
LteNetDevice::Receive (Ptr<Packet> p)
{
NS_LOG_FUNCTION (this << p);
Ptr<Packet> packet = p->Copy ();
DoReceive (packet);
}
bool
LteNetDevice::SetMtu (const uint16_t mtu)
{
NS_LOG_FUNCTION (this << mtu);
if (mtu > MAX_MSDU_SIZE)
{
return false;
}
m_mtu = mtu;
return true;
}
uint16_t
LteNetDevice::GetMtu (void) const
{
NS_LOG_FUNCTION (this);
return m_mtu;
}
void
LteNetDevice::SetIfIndex (const uint32_t index)
{
NS_LOG_FUNCTION (this << index);
m_ifIndex = index;
}
uint32_t
LteNetDevice::GetIfIndex (void) const
{
NS_LOG_FUNCTION (this);
return m_ifIndex;
}
bool
LteNetDevice::IsLinkUp (void) const
{
NS_LOG_FUNCTION (this);
return m_phy != 0 && m_linkUp;
}
bool
LteNetDevice::IsBroadcast (void) const
{
NS_LOG_FUNCTION (this);
return true;
}
Address
LteNetDevice::GetBroadcast (void) const
{
NS_LOG_FUNCTION (this);
return Mac48Address::GetBroadcast ();
}
bool
LteNetDevice::IsMulticast (void) const
{
NS_LOG_FUNCTION (this);
return false;
}
bool
LteNetDevice::IsPointToPoint (void) const
{
NS_LOG_FUNCTION (this);
return false;
}
bool
LteNetDevice::NeedsArp (void) const
{
NS_LOG_FUNCTION (this);
return true;
}
bool
LteNetDevice::IsBridge (void) const
{
NS_LOG_FUNCTION (this);
return false;
}
Address
LteNetDevice::GetMulticast (Ipv4Address multicastGroup) const
{
NS_LOG_FUNCTION (this);
NS_LOG_FUNCTION (multicastGroup);
Mac48Address ad = Mac48Address::GetMulticast (multicastGroup);
//
// Implicit conversion (operator Address ()) is defined for Mac48Address, so
// use it by just returning the EUI-48 address which is automagically converted
// to an Address.
//
NS_LOG_LOGIC ("multicast address is " << ad);
return ad;
}
Address
LteNetDevice::GetMulticast (Ipv6Address addr) const
{
NS_LOG_FUNCTION (this << addr);
Mac48Address ad = Mac48Address::GetMulticast (addr);
NS_LOG_LOGIC ("MAC IPv6 multicast address is " << ad);
return ad;
}
void
LteNetDevice::AddLinkChangeCallback (Callback<void> callback)
{
NS_LOG_FUNCTION (this);
m_linkChangeCallbacks.ConnectWithoutContext (callback);
}
void
LteNetDevice::SetPromiscReceiveCallback (PromiscReceiveCallback cb)
{
NS_LOG_FUNCTION (this);
m_promiscRxCallback = cb;
}
void
LteNetDevice::SetPacketToSend (Ptr<PacketBurst> p)
{
m_packetToSend = p;
}
Ptr<PacketBurst>
LteNetDevice::GetPacketToSend (void)
{
return m_packetToSend;
}
}

203
src/devices/lte/model/lte-net-device.h

@ -0,0 +1,203 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Giuseppe Piro <g.piro@poliba.it>
*/
#ifndef LTE_NET_DEVICE_H
#define LTE_NET_DEVICE_H
#include "ns3/net-device.h"
#include "ns3/event-id.h"
#include "ns3/mac48-address.h"
#include "ns3/traced-callback.h"
#include "ns3/nstime.h"
#include "ns3/log.h"
#include "lte-phy.h"
#include "ideal-control-messages.h"
namespace ns3 {
class Node;
class Packet;
class PacketBurst;
class RadioBearerInstance;
class RrcEntity;
/**
* LteNetDevice provides basic implementation for all LTE network devices
*/
class LteNetDevice : public NetDevice
{
public:
static TypeId GetTypeId (void);
LteNetDevice (void);
virtual ~LteNetDevice (void);
virtual void DoDispose (void);
/**
* \brief set the callback used to instruct the lower layer to start a TX
* \param c
*/
void SetPhyMacTxStartCallback (PhyMacTxStartCallback c);
/**
* \param phy the phy layer to use.
*/
void SetPhy (Ptr<LtePhy> phy);
/**
* \returns a pointer to the physical layer.
*/
Ptr<LtePhy> GetPhy (void) const;
/**
* \brief Set the RRC entity
* \param rrc the RRC entity
*/
void SetRrcEntity (Ptr<RrcEntity> rrc);
/**
* \brief Get the RRC entity
* \return the pointer to the RRC entity
*/
Ptr<RrcEntity> GetRrcEntity (void);
// inherited from NetDevice
virtual void SetIfIndex (const uint32_t index);
virtual uint32_t GetIfIndex (void) const;
virtual Ptr<Channel> GetChannel (void) const;
virtual bool SetMtu (const uint16_t mtu);
virtual uint16_t GetMtu (void) const;
virtual void SetAddress (Address address);
virtual Address GetAddress (void) const;
virtual bool IsLinkUp (void) const;
virtual void AddLinkChangeCallback (Callback<void> callback);
virtual bool IsBroadcast (void) const;
virtual Address GetBroadcast (void) const;
virtual bool IsMulticast (void) const;
virtual bool IsPointToPoint (void) const;
virtual bool IsBridge (void) const;
virtual Ptr<Node> GetNode (void) const;
virtual void SetNode (Ptr<Node> node);
virtual bool NeedsArp (void) const;
virtual void SetReceiveCallback (NetDevice::ReceiveCallback cb);
virtual Address GetMulticast (Ipv4Address addr) const;
virtual Address GetMulticast (Ipv6Address addr) const;
virtual void SetPromiscReceiveCallback (PromiscReceiveCallback cb);
/**
* \brief This method is called as soon as the net device is created.
* It can be used to start some functionalities of the considered device. For example,
* for the eNB device it starts the schedule of LTE Frames.
*/
virtual void Start (void) = 0;
/**
* Ends the run of this device
*/
virtual void Stop (void) = 0;
virtual bool Send (Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber);
virtual bool SendFrom (Ptr<Packet> packet, const Address& source, const Address& dest, uint16_t protocolNumber);
virtual bool SupportsSendFrom (void) const;
/**
* \brief Receive the packet from the phy layer
* \param p the received packet
*/
void Receive (Ptr<Packet> p);
/**
* \brief Forward packet to the uppar layer.
* If is called by DoReceive method
* \param packet packet sent from Network Device to the upper layer
* \param source source mac address
* \param dest mac address of the destination
*/
void ForwardUp (Ptr<Packet> packet, const Mac48Address &source, const Mac48Address &dest);
/**
* \brief Forward packet to the uppar layer.
* If is called by DoReceive method
* \param packet packet sent from Network Device to the upper layer
*/
void ForwardUp (Ptr<Packet> packet);
/**
* \brief Set packets to send
* \param p the burst of packets to send
*/
void SetPacketToSend (Ptr<PacketBurst> p);
/**
* \brief Get packets to send
* \return the pointer to the burst of packets to send
*/
Ptr<PacketBurst> GetPacketToSend (void);
/**
* \brief Start packet transmission.
*/
virtual void StartTransmission (void) = 0;
/**
* \brief Send packet/packets to the physical layer
* \param p packet/packets to be sent
*/
virtual bool SendPacket (Ptr<PacketBurst> p) = 0;
private:
LteNetDevice (const LteNetDevice &);
LteNetDevice & operator= (const LteNetDevice &);
static const uint16_t MAX_MSDU_SIZE = 1500;
virtual bool DoSend (Ptr<Packet> packet,
const Mac48Address& source,
const Mac48Address& dest,
uint16_t protocolNumber) = 0;
virtual void DoReceive (Ptr<Packet> p) = 0;
Ptr<Node> m_node;
Ptr<LtePhy> m_phy;
Ptr<RrcEntity> m_rrcEntity;
TracedCallback<Ptr<const Packet> > m_macTxTrace;
TracedCallback<Ptr<const Packet> > m_macTxDropTrace;
TracedCallback<Ptr<const Packet> > m_macPromiscRxTrace;
TracedCallback<Ptr<const Packet> > m_macRxTrace;
NetDevice::ReceiveCallback m_rxCallback;
NetDevice::PromiscReceiveCallback m_promiscRxCallback;
PhyMacTxStartCallback m_phyMacTxStartCallback;
TracedCallback<> m_linkChangeCallbacks;
uint32_t m_ifIndex;
bool m_linkUp;
mutable uint16_t m_mtu;
Mac48Address m_address;
Ptr<PacketBurst> m_packetToSend;
};
} // namespace ns3
#endif /* LTE_NET_DEVICE_H */

263
src/devices/lte/model/lte-phy.cc

@ -0,0 +1,263 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Giuseppe Piro <g.piro@poliba.it>
*/
#include <ns3/waveform-generator.h>
#include <ns3/object-factory.h>
#include <ns3/log.h>
#include <math.h>
#include <ns3/simulator.h>
#include "ns3/spectrum-error-model.h"
#include "lte-phy.h"
#include "lte-net-device.h"
NS_LOG_COMPONENT_DEFINE ("LtePhy");
namespace ns3 {
NS_OBJECT_ENSURE_REGISTERED (LtePhy);
uint32_t LtePhy::m_nrFrames = 0;
uint32_t LtePhy::m_nrSubFrames = 0;
LtePhy::LtePhy ()
: m_netDevice (0),
m_downlinkSpectrumPhy (0),
m_uplinkSpectrumPhy (0)
{
SetTti (0.001);
}
TypeId
LtePhy::GetTypeId (void)
{
static TypeId tid = TypeId ("ns3::LtePhy")
.SetParent<Object> ()
// .AddConstructor<LtePhy> ()
;
return tid;
}
LtePhy::~LtePhy ()
{
}
void
LtePhy::SetDevice (Ptr<LteNetDevice> d)
{
NS_LOG_FUNCTION (this << d);
m_netDevice = d;
}
Ptr<LteNetDevice>
LtePhy::GetDevice ()
{
NS_LOG_FUNCTION (this);
return m_netDevice;
}
void
LtePhy::SetDownlinkSpectrumPhy (Ptr<LteSpectrumPhy> s)
{
NS_LOG_FUNCTION (this << s);
m_downlinkSpectrumPhy = s;
}
void
LtePhy::SetUplinkSpectrumPhy (Ptr<LteSpectrumPhy> s)
{
NS_LOG_FUNCTION (this << s);
m_uplinkSpectrumPhy = s;
}
Ptr<LteSpectrumPhy>
LtePhy::GetDownlinkSpectrumPhy ()
{
NS_LOG_FUNCTION (this);
return m_downlinkSpectrumPhy;
}
Ptr<LteSpectrumPhy>
LtePhy::GetUplinkSpectrumPhy ()
{
NS_LOG_FUNCTION (this);
return m_uplinkSpectrumPhy;
}
void
LtePhy::SetDownlinkChannel (Ptr<SpectrumChannel> c)
{
NS_LOG_FUNCTION (this << c);
m_downlinkSpectrumPhy->SetChannel (c);
}
Ptr<SpectrumChannel>
LtePhy::GetDownlinkChannel ()
{
NS_LOG_FUNCTION (this);
return m_downlinkSpectrumPhy->GetChannel ();
}
void
LtePhy::SetUplinkChannel (Ptr<SpectrumChannel> c)
{
NS_LOG_FUNCTION (this << c);
m_uplinkSpectrumPhy->SetChannel (c);
}
Ptr<SpectrumChannel>
LtePhy::GetUplinkChannel ()
{
NS_LOG_FUNCTION (this);
return m_uplinkSpectrumPhy->GetChannel ();
}
void
LtePhy::SetDownlinkSubChannels (std::vector<int> mask )
{
NS_LOG_FUNCTION (this);
m_listOfDownlinkSubchannel = mask;
DoSetDownlinkSubChannels ();
}
void
LtePhy::DoSetDownlinkSubChannels ()
{
NS_LOG_FUNCTION (this);
}
void
LtePhy::SetUplinkSubChannels (std::vector<int> mask )
{
NS_LOG_FUNCTION (this);
m_listOfUplinkSubchannel = mask;
DoSetUplinkSubChannels ();
}
void
LtePhy::DoSetUplinkSubChannels ()
{
NS_LOG_FUNCTION (this);
}
std::vector<int>
LtePhy::GetDownlinkSubChannels (void)
{
NS_LOG_FUNCTION (this);
return m_listOfDownlinkSubchannel;
}
std::vector<int>
LtePhy::GetUplinkSubChannels (void)
{
NS_LOG_FUNCTION (this);
return m_listOfUplinkSubchannel;
}
void
LtePhy::SetTxPower (double pw)
{
NS_LOG_FUNCTION (this << pw);
m_txPower = pw;
}
double
LtePhy::GetTxPower (void)
{
NS_LOG_FUNCTION (this);
return m_txPower;
}
void
LtePhy::DoDispose ()
{
NS_LOG_FUNCTION (this);
m_downlinkSpectrumPhy = 0;
m_uplinkSpectrumPhy = 0;
}
void
LtePhy::SetTti (double tti)
{
NS_LOG_FUNCTION (this << tti);
m_tti = tti;
}
double
LtePhy::GetTti (void) const
{
NS_LOG_FUNCTION (this << m_tti);
return m_tti;
}
void
LtePhy::SetNrFrames (uint32_t nrFrames)
{
NS_LOG_FUNCTION (this << nrFrames);
m_nrFrames = nrFrames;
}
uint32_t
LtePhy::GetNrFrames (void) const
{
NS_LOG_FUNCTION (this);
return m_nrFrames;
}
void
LtePhy::SetNrSubFrames (uint32_t nrSubFrames)
{
NS_LOG_FUNCTION (this << nrSubFrames);
m_nrSubFrames = nrSubFrames;
}
uint32_t
LtePhy::GetNrSubFrames (void) const
{
NS_LOG_FUNCTION (this);
return m_nrSubFrames;
}
} // namespace ns3

236
src/devices/lte/model/lte-phy.h

@ -0,0 +1,236 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Giuseppe Piro <g.piro@poliba.it>
*/
#ifndef LTE_PHY_H
#define LTE_PHY_H
#include <ns3/spectrum-value.h>
#include <ns3/mobility-model.h>
#include <ns3/packet.h>
#include <ns3/nstime.h>
#include <ns3/spectrum-phy.h>
#include <ns3/spectrum-channel.h>
#include <ns3/spectrum-type.h>
#include <ns3/spectrum-interference.h>
#include <ns3/phy-mac.h>
#include "lte-spectrum-phy.h"
namespace ns3 {
class PacketBurst;
class LteNetDevice;
class IdealControlMessage;
/**
* The LtePhy models the physical layer of LTE. It is composed by two
* LteSpectrumPhy, one for the downlink and one for the uplink.
*/
class LtePhy : public Object
{
public:
LtePhy ();
virtual ~LtePhy ();
static TypeId GetTypeId (void);
/**
* \brief Set the device where the phy layer is attached
* \param d the device
*/
void SetDevice (Ptr<LteNetDevice> d);
/**
* \brief Get the device where the phy layer is attached
* \return the pointer to the device
*/
Ptr<LteNetDevice> GetDevice ();
/**
* \brief Start a transmission. StartTx is called by the LTE device to start packet transmission.
* \param pb the packet of packets to be transmitted
* \return true if an error occurred and the transmission was not started, false otherwise.
*/
virtual bool SendPacket (Ptr<PacketBurst> pb) = 0;
/**
* Set the LTE SpectrumPhy for the downlink
* \param s the LTE SpectrumPhy
*/
void SetDownlinkSpectrumPhy (Ptr<LteSpectrumPhy> s);
/**
* Set the LTE SpectrumPhy for the uplink
* \param s the LTE SpectrumPhy
*/
void SetUplinkSpectrumPhy (Ptr<LteSpectrumPhy> s);
/**
* Get the LTE SpectrumPhy for the downlink
* \return a Ptr to the LTE SpectrumPhy for the downlink
*/
Ptr<LteSpectrumPhy> GetDownlinkSpectrumPhy ();
/**
* Get the LTE SpectrumPhy for the uplink
* \return a Ptr to the LTE SpectrumPhy for the
*/
Ptr<LteSpectrumPhy> GetUplinkSpectrumPhy ();
/**
* Set the downlink channel
* \param c the downlink channel
*/
void SetDownlinkChannel (Ptr<SpectrumChannel> c);
/**
* Get the downlink channel
* \return a Ptr to the downlink SpectrumChannel
*/
Ptr<SpectrumChannel> GetDownlinkChannel ();
/**
* Set the uplink channel
* \param c the uplink channel
*/
void SetUplinkChannel (Ptr<SpectrumChannel> c);
/**
* Get the uplink channel
* \return a Ptr to the uplink SpectrumChannel
*/
Ptr<SpectrumChannel> GetUplinkChannel ();
/**
* \brief set a list of sub channel to use in the downlink.
* A sub channel is composed by a couple of resource bloks (180KHz x 1 ms)
* \param mask a vector of intefer values. Each elements of this vector carries information about
* the corresponding DL sub channel. If the i-th value of mask is equal to 1 (0) it means that the corresponding sub channel is used (not used) for the downlink.
*/
void SetDownlinkSubChannels (std::vector<int> mask );
/**
* \brief do some operation after the set of a list of DL sub channels
*/
virtual void DoSetDownlinkSubChannels ();
/**
* \brief set a list of sub channel to use in the uplink.
* A sub channel is composed by a couple of resource bloks (180KHz x 1 ms)
* \param mask a vector of intefer values. Each elements of this vector carries information about
* the corresponding UL sub channel. If the i-th value of mask is equal to 1 (0) it means that the corresponding sub channel is used (not used) for the uplink.
*/
void SetUplinkSubChannels (std::vector<int> mask);
/**
* \brief do some operation after the set of a list of UL sub channels
*/
virtual void DoSetUplinkSubChannels ();
/**
* \brief get a list of sub channel to use in the downlink
* \return
*/
std::vector<int> GetDownlinkSubChannels (void);
/**
* \brief get a list of sub channel to use in the downlink
* \return
*/
std::vector<int> GetUplinkSubChannels (void);
/**
* \brief Compute the TX Power Spectral Density
* \return a Ptr to a created SpectrumValue
*/
virtual Ptr<SpectrumValue> CreateTxPowerSpectralDensity () = 0;
/**
* \brief Set the power transmisison, expressed in dBm
* \param pw the power transmission
*/
void SetTxPower (double pw);
/**
* \brief Get the power transmission, expressed in dBm
* \return the power transmission
*/
double GetTxPower (void);
void DoDispose ();
/**
* \brief Send SendIdealControlMessage (PDCCH map, CQI feedbacks) using the ideal control channel
* \param msg the Ideal Control Message to send
*/
virtual void SendIdealControlMessage (IdealControlMessage* msg) = 0;
/**
* \brief Receive SendIdealControlMessage (PDCCH map, CQI feedbacks) using the ideal control channel
* \param msg the Ideal Control Message to receive
*/
virtual void ReceiveIdealControlMessage (IdealControlMessage* msg) = 0;
/**
* \param tti transmission time interval
*/
void SetTti (double tti);
/**
* \returns transmission time interval
*/
double GetTti (void) const;
/**
* \param nrFrames the number of the current LTE frame.
*/
void SetNrFrames (uint32_t nrFrames);
/**
* \returns the number of the current LTE frame.
*/
uint32_t GetNrFrames (void) const;
/**
* \param nrSubFrames the number of the current LTE sub-frame.
*/
void SetNrSubFrames (uint32_t nrSubFrames);
/**
* \returns the number of the current LTE sub-frame.
*/
uint32_t GetNrSubFrames (void) const;
private:
Ptr<LteNetDevice> m_netDevice;
Ptr<LteSpectrumPhy> m_downlinkSpectrumPhy;
Ptr<LteSpectrumPhy> m_uplinkSpectrumPhy;
std::vector <int> m_listOfDownlinkSubchannel;
std::vector <int> m_listOfUplinkSubchannel;
double m_txPower;
static uint32_t m_nrFrames;
static uint32_t m_nrSubFrames;
double m_tti;
};
}
#endif /* LTE_PHY_H */

157
src/devices/lte/model/lte-propagation-loss-model.cc

@ -0,0 +1,157 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Giuseppe Piro <g.piro@poliba.it>
*/
#include "lte-propagation-loss-model.h"
#include <ns3/mobility-model.h>
#include <ns3/spectrum-value.h>
#include <ns3/log.h>
NS_LOG_COMPONENT_DEFINE ("LtePropagationLossModel");
namespace ns3 {
NS_OBJECT_ENSURE_REGISTERED (LtePropagationLossModel);
LtePropagationLossModel::LtePropagationLossModel ()
{
SetNext (NULL);
}
LtePropagationLossModel::~LtePropagationLossModel ()
{
}
TypeId
LtePropagationLossModel::GetTypeId (void)
{
static TypeId tid = TypeId ("ns3::LtePropagationLossModel")
.SetParent<Object> ()
;
return tid;
}
Ptr<SpectrumValue>
LtePropagationLossModel::DoCalcRxPowerSpectralDensity (Ptr<const SpectrumValue> txPsd,
Ptr<const MobilityModel> a,
Ptr<const MobilityModel> b) const
{
NS_LOG_FUNCTION (this << *txPsd << a << b);
/*
* The loss propagation model for LTE networks is based on
* a on a combination of four different models:
* - the path loss
* - the penetration loss
* - the shadowind
* - the multipath
*
* The rxPsd will be obtained considering, for each sub channel, the following
* relations:
* rxPsd (i) = txPsd (i) + m(i,t) - sh(i,t) - pnl(i,t) - pl (a,b);
* where i is the i-th sub-channel and t is the current time (Simulator::Now()).
*/
Ptr<ChannelRealization> c = GetChannelRealization (a,b);
double multipath; // its value is different for each sub channels
double pathLoss = c->GetPathLossModel ()->GetValue (a,b);
double shadowind = c->GetShadowingLossModel ()->GetValue ();
double penetration = c->GetPenetrationLossModel ()->GetValue ();
Ptr<SpectrumValue> rxPsd = Copy<SpectrumValue> (txPsd);
Values::iterator vit = rxPsd->ValuesBegin ();
NS_LOG_FUNCTION (this << *rxPsd);
int subChannel = 0;
while (vit != rxPsd->ValuesEnd ())
{
NS_ASSERT (subChannel < 100);
if (*vit != 0.)
{
multipath = c->GetJakesFadingLossModel ()->GetValue (subChannel);
// computei PROPRAGATION LOSS:
double loss = multipath - pathLoss - shadowind - penetration; // in dB
double power = *vit; // in Watt/Hz
power = 10 * log10 (180000 * power); // in dB
NS_LOG_FUNCTION (this << subChannel << *vit << power << multipath
<< pathLoss << shadowind << penetration);
*vit = pow (10., ((power + loss) / 10)) / 180000; // in Watt
NS_LOG_FUNCTION (this << subChannel << *vit);
}
++vit;
++subChannel;
}
NS_LOG_FUNCTION (this << *rxPsd);
return rxPsd;
}
void
LtePropagationLossModel::CreateChannelRealization (Ptr<const MobilityModel> enbMobility, Ptr<const MobilityModel> ueMobility)
{
NS_LOG_FUNCTION (this << enbMobility << ueMobility);
Ptr<ChannelRealization> c = CreateObject<ChannelRealization> ();
ChannelRealizationId_t mobilities = std::make_pair (enbMobility, ueMobility);
NS_LOG_FUNCTION (this <<
"insert new channel realization, m_channelRealizationMap.size () = "
<< m_channelRealizationMap.size ());
m_channelRealizationMap.insert ( std::pair<ChannelRealizationId_t,Ptr<ChannelRealization> > (mobilities, c) );
NS_LOG_FUNCTION (this <<
"m_channelRealizationMap.size () = "
<< m_channelRealizationMap.size ());
}
Ptr<ChannelRealization>
LtePropagationLossModel::GetChannelRealization (Ptr<const MobilityModel> a, Ptr<const MobilityModel> b) const
{
NS_LOG_FUNCTION (this << a << b);
std::map <ChannelRealizationId_t, Ptr<ChannelRealization> >::const_iterator it;
ChannelRealizationId_t mobilities = std::make_pair (a,b);
it = m_channelRealizationMap.find (mobilities);
return it->second;
}
} // namespace ns3

91
src/devices/lte/model/lte-propagation-loss-model.h

@ -0,0 +1,91 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Giuseppe Piro <g.piro@poliba.it>
*/
#ifndef LTE_SPECTRUM_PROPAGATION_LOSS_MODEL_H
#define LTE_SPECTRUM_PROPAGATION_LOSS_MODEL_H
#include <ns3/object.h>
#include <ns3/spectrum-propagation-loss-model.h>
#include <map>
#include "channel-realization.h"
namespace ns3 {
class MobilityModel;
/**
* \brief propagation loss model for LTE
*/
class LtePropagationLossModel : public SpectrumPropagationLossModel
{
public:
LtePropagationLossModel ();
virtual ~LtePropagationLossModel ();
static TypeId GetTypeId ();
/**
* \brief The couple of mobility mnode that form a channel realization
*/
typedef std::pair<Ptr<const MobilityModel>, Ptr<const MobilityModel> > ChannelRealizationId_t;
/**
* \brief Create a channel realization among two device
* \param enbMobility mobility object of the enb
* \param ueMobility mobility object of the ue
*/
void CreateChannelRealization (Ptr<const MobilityModel> enbMobility, Ptr<const MobilityModel> ueMobility);
/**
* \brief Get a channel realization among two device
* \param a the mobility object of the enb
* \param b the mobility object of the ue
* \return the pointer to the channel realization
*/
Ptr<ChannelRealization> GetChannelRealization (Ptr<const MobilityModel> a, Ptr<const MobilityModel> b) const;
private:
/**
* @param txPower set of values vs frequency representing the
* transmission power. See SpectrumChannel for details.
*
* @param a sender mobility
* @param b receiver mobility
*
* @return set of values vs frequency representing the received
* power in the same units used for the txPower parameter.
*/
Ptr<SpectrumValue> DoCalcRxPowerSpectralDensity (Ptr<const SpectrumValue> txPsd,
Ptr<const MobilityModel> a,
Ptr<const MobilityModel> b) const;
std::map <ChannelRealizationId_t, Ptr<ChannelRealization> > m_channelRealizationMap;
};
} // namespace ns3
#endif /* LTE_SPECTRUM_PROPAGATION_LOSS_MODEL_H */

503
src/devices/lte/model/lte-spectrum-phy.cc

@ -0,0 +1,503 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2009 CTTC
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Nicola Baldo <nbaldo@cttc.es>
* Giuseppe Piro <g.piro@poliba.it>
*/
#include <ns3/waveform-generator.h>
#include <ns3/object-factory.h>
#include <ns3/log.h>
#include <math.h>
#include <ns3/simulator.h>
#include <ns3/trace-source-accessor.h>
#include "ns3/spectrum-error-model.h"
#include "lte-spectrum-phy.h"
#include "lte-net-device.h"
NS_LOG_COMPONENT_DEFINE ("LteSpectrumPhy");
namespace ns3 {
NS_OBJECT_ENSURE_REGISTERED (LteSpectrumPhy);
LteSpectrumPhy::LteSpectrumPhy ()
: m_mobility (0),
m_device (0),
m_channel (0),
m_txPsd (0),
m_state (IDLE)
{
//m_interference = CreateObject<SpectrumInterference> ();
//m_interference->SetErrorModel (CreateObject<LteSpectrumErrorModel> ());
}
LteSpectrumPhy::~LteSpectrumPhy ()
{
}
std::ostream& operator<< (std::ostream& os, LteSpectrumPhy::State s)
{
switch (s)
{
case LteSpectrumPhy::IDLE:
os << "IDLE";
break;
case LteSpectrumPhy::RX:
os << "RX";
break;
case LteSpectrumPhy::TX:
os << "TX";
break;
default:
os << "UNKNOWN";
break;
}
return os;
}
TypeId
LteSpectrumPhy::GetTypeId (void)
{
static TypeId tid = TypeId ("ns3::LteSpectrumPhy")
.SetParent<SpectrumPhy> ()
.AddTraceSource ("TxStart",
"Trace fired when a new transmission is started",
MakeTraceSourceAccessor (&LteSpectrumPhy::m_phyTxStartTrace))
.AddTraceSource ("TxEnd",
"Trace fired when a previosuly started transmission is finished",
MakeTraceSourceAccessor (&LteSpectrumPhy::m_phyTxEndTrace))
.AddTraceSource ("RxStart",
"Trace fired when the start of a signal is detected",
MakeTraceSourceAccessor (&LteSpectrumPhy::m_phyRxStartTrace))
.AddTraceSource ("RxAbort",
"Trace fired when a previously started RX is aborted before time",
MakeTraceSourceAccessor (&LteSpectrumPhy::m_phyRxAbortTrace))
.AddTraceSource ("RxEndOk",
"Trace fired when a previosuly started RX terminates successfully",
MakeTraceSourceAccessor (&LteSpectrumPhy::m_phyRxEndOkTrace))
.AddTraceSource ("RxEndError",
"Trace fired when a previosuly started RX terminates with an error (packet is corrupted)",
MakeTraceSourceAccessor (&LteSpectrumPhy::m_phyRxEndErrorTrace))
;
return tid;
}
Ptr<Object>
LteSpectrumPhy::GetDevice ()
{
NS_LOG_FUNCTION (this);
return m_device;
}
Ptr<Object>
LteSpectrumPhy::GetMobility ()
{
NS_LOG_FUNCTION (this);
return m_mobility;
}
void
LteSpectrumPhy::SetDevice (Ptr<Object> d)
{
NS_LOG_FUNCTION (this << d);
m_device = d;
}
void
LteSpectrumPhy::SetMobility (Ptr<Object> m)
{
NS_LOG_FUNCTION (this << m);
m_mobility = m;
}
void
LteSpectrumPhy::SetChannel (Ptr<SpectrumChannel> c)
{
NS_LOG_FUNCTION (this << c);
m_channel = c;
}
Ptr<SpectrumChannel>
LteSpectrumPhy::GetChannel (void)
{
return m_channel;
}
Ptr<const SpectrumModel>
LteSpectrumPhy::GetRxSpectrumModel () const
{
if (m_txPsd)
{
return m_txPsd->GetSpectrumModel ();
}
else
{
return 0;
}
}
SpectrumType
LteSpectrumPhy::GetSpectrumType ()
{
NS_LOG_FUNCTION (this);
static SpectrumType st = SpectrumTypeFactory::Create ("IdealOfdm");
return st;
}
void
LteSpectrumPhy::SetTxPowerSpectralDensity (Ptr<SpectrumValue> txPsd)
{
NS_LOG_FUNCTION (this << txPsd);
NS_ASSERT (txPsd);
m_txPsd = txPsd;
NS_LOG_INFO ("\t computed tx_psd: " << *txPsd << "\t stored tx_psd: " << *m_txPsd);
}
void
LteSpectrumPhy::SetNoisePowerSpectralDensity (Ptr<const SpectrumValue> noisePsd)
{
NS_LOG_FUNCTION (this << noisePsd);
NS_LOG_INFO ("\t computed noise_psd: " << *noisePsd );
NS_ASSERT (noisePsd);
m_noise = noisePsd;
}
Ptr<const SpectrumValue>
LteSpectrumPhy::GetNoisePowerSpectralDensity (void)
{
NS_LOG_FUNCTION (this);
return m_noise;
}
void
LteSpectrumPhy::SetPhyMacTxEndCallback (PhyMacTxEndCallback c)
{
NS_LOG_FUNCTION (this);
m_phyMacTxEndCallback = c;
}
void
LteSpectrumPhy::SetPhyMacRxStartCallback (PhyMacRxStartCallback c)
{
NS_LOG_FUNCTION (this);
m_phyMacRxStartCallback = c;
}
void
LteSpectrumPhy::SetPhyMacRxEndErrorCallback (PhyMacRxEndErrorCallback c)
{
NS_LOG_FUNCTION (this);
m_phyMacRxEndErrorCallback = c;
}
void
LteSpectrumPhy::SetPhyMacRxEndOkCallback (PhyMacRxEndOkCallback c)
{
NS_LOG_FUNCTION (this);
m_phyMacRxEndOkCallback = c;
}
void
LteSpectrumPhy::SetState (State newState)
{
ChangeState (newState);
}
void
LteSpectrumPhy::ChangeState (State newState)
{
NS_LOG_LOGIC (this << " state: " << m_state << " -> " << newState);
m_state = newState;
}
bool
LteSpectrumPhy::StartTx (Ptr<PacketBurst> pb)
{
NS_LOG_FUNCTION (this << pb);
NS_LOG_LOGIC (this << "state: " << m_state);
for (std::list<Ptr<Packet> >::const_iterator iter = pb->Begin (); iter
!= pb->End (); ++iter)
{
Ptr<Packet> packet = (*iter)->Copy ();
m_phyTxStartTrace (packet);
}
if (m_state == LteSpectrumPhy::RX)
{
/*
* NS FATAL ERROR: according to FDD channel acces,
* the physical layer for transmission cannot be used for reception.
*/
NS_FATAL_ERROR ("FDD ERROR: R State while sending packet");
}
if (m_state == LteSpectrumPhy::IDLE)
{
/*
m_txPsd must be setted by the device, according to
(i) the available subchannel for transmission
(ii) the power transmission
*/
NS_ASSERT (m_txPsd);
m_txPacket = pb;
ChangeState (TX);
NS_ASSERT (m_channel);
double tti = 0.001;
m_channel->StartTx (pb, m_txPsd, GetSpectrumType (), Seconds (tti), GetObject<SpectrumPhy> ());
Simulator::Schedule (Seconds (tti), &LteSpectrumPhy::EndTx, this);
return false;
}
else
{
// The device have already started the transmission.
return true;
}
}
void
LteSpectrumPhy::EndTx ()
{
NS_LOG_FUNCTION (this);
NS_LOG_LOGIC (this << "state: " << m_state);
NS_ASSERT (m_state == TX);
for (std::list<Ptr<Packet> >::const_iterator iter = m_txPacket->Begin (); iter
!= m_txPacket->End (); ++iter)
{
Ptr<Packet> packet = (*iter)->Copy ();
m_phyTxEndTrace (packet);
}
if (!m_phyMacTxEndCallback.IsNull ())
{
for (std::list<Ptr<Packet> >::const_iterator iter = m_txPacket->Begin (); iter
!= m_txPacket->End (); ++iter)
{
Ptr<Packet> packet = (*iter)->Copy ();
m_phyMacTxEndCallback (packet);
}
}
m_txPacket = 0;
ChangeState (IDLE);
}
void
LteSpectrumPhy::StartRx (Ptr<PacketBurst> pb, Ptr <const SpectrumValue> rxPsd, SpectrumType st, Time duration)
{
NS_LOG_FUNCTION (this << pb << rxPsd << st << duration);
NS_LOG_LOGIC (this << "state: " << m_state);
// interference will happen regardless of the state of the receiver
// m_interference->AddSignal (rxPsd, duration);
// the device might start RX only if the signal is of a type understood by this device
// this corresponds in real device to preamble detection
if (st == GetSpectrumType ())
{
switch (m_state)
{
case TX:
/*
* NS FATAL ERROR: according to FDD channel acces,
* the physical layer for reception cannot be used for transmission.
*/
NS_FATAL_ERROR ("FDD ERROR: TX State while receiving packet");
break;
case RX:
break;
case IDLE:
// preamble detection and synchronization is supposed to be always successful.
NS_LOG_LOGIC (this << " receiving new packet");
for (std::list<Ptr<Packet> >::const_iterator iter = pb->Begin (); iter
!= pb->End (); ++iter)
{
Ptr<Packet> packet = (*iter)->Copy ();
m_phyRxStartTrace (packet);
}
m_rxPacket = pb;
m_rxPsd = rxPsd;
ChangeState (RX);
if (!m_phyMacRxStartCallback.IsNull ())
{
NS_LOG_LOGIC (this << " calling m_phyMacRxStartCallback");
m_phyMacRxStartCallback ();
}
else
{
NS_LOG_LOGIC (this << " m_phyMacRxStartCallback is NULL");
}
// XXX: modify SpectrumInterference in order to compute
// the correct/erroneus reception of PacketBurst!!!
/*
for (std::list<Ptr<Packet> >::const_iterator iter = pb->Begin (); iter
!= pb->End (); ++iter)
{
Ptr<Packet> packet = (*iter)->Copy ();
m_interference->StartRx (packet, rxPsd);
}
*/
NS_LOG_LOGIC (this << " scheduling EndRx with delay " << duration);
m_endRxEventId = Simulator::Schedule (duration, &LteSpectrumPhy::EndRx, this);
break;
}
}
NS_LOG_LOGIC (this << "state: " << m_state);
}
void
LteSpectrumPhy::AbortRx ()
{
NS_LOG_FUNCTION (this);
NS_LOG_LOGIC (this << "state: " << m_state);
NS_ASSERT (m_state == RX);
for (std::list<Ptr<Packet> >::const_iterator iter = m_rxPacket->Begin (); iter
!= m_rxPacket->End (); ++iter)
{
Ptr<Packet> packet = (*iter)->Copy ();
m_phyRxAbortTrace (packet);
}
m_endRxEventId.Cancel ();
m_rxPacket = 0;
ChangeState (IDLE);
}
void
LteSpectrumPhy::EndRx ()
{
NS_LOG_FUNCTION (this);
NS_LOG_LOGIC (this << "state: " << m_state);
NS_ASSERT (m_state == RX);
CalcSinrValues (m_rxPsd, GetNoisePowerSpectralDensity ());
bool rxOk = true; //m_interference->EndRx ();
NS_LOG_FUNCTION (rxOk);
if (rxOk)
{
for (std::list<Ptr<Packet> >::const_iterator iter = m_rxPacket->Begin (); iter
!= m_rxPacket->End (); ++iter)
{
Ptr<Packet> packet = (*iter)->Copy ();
m_phyRxEndOkTrace (packet);
}
if (!m_phyMacRxEndOkCallback.IsNull ())
{
NS_LOG_LOGIC (this << " calling m_phyMacRxEndOkCallback");
for (std::list<Ptr<Packet> >::const_iterator iter = m_rxPacket->Begin (); iter
!= m_rxPacket->End (); ++iter)
{
Ptr<Packet> packet = (*iter)->Copy ();
m_phyMacRxEndOkCallback (packet);
}
}
else
{
NS_LOG_LOGIC (this << " m_phyMacRxEndOkCallback is NULL");
}
}
else
{
for (std::list<Ptr<Packet> >::const_iterator iter = m_rxPacket->Begin (); iter
!= m_rxPacket->End (); ++iter)
{
Ptr<Packet> packet = (*iter)->Copy ();
m_phyRxEndErrorTrace (packet);
}
if (!m_phyMacRxEndErrorCallback.IsNull ())
{
NS_LOG_LOGIC (this << " calling m_phyMacRxEndErrorCallback");
for (std::list<Ptr<Packet> >::const_iterator iter = m_rxPacket->Begin (); iter
!= m_rxPacket->End (); ++iter)
{
Ptr<Packet> packet = (*iter)->Copy ();
m_phyMacRxEndOkCallback (packet);
}
}
else
{
NS_LOG_LOGIC (this << " m_phyMacRxEndErrorCallback is NULL");
}
}
ChangeState (IDLE);
m_rxPacket = 0;
m_rxPsd = 0;
}
} // namespace ns3

218
src/devices/lte/model/lte-spectrum-phy.h

@ -0,0 +1,218 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2009 CTTC
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Nicola Baldo <nbaldo@cttc.es>
* Giuseppe Piro <g.piro@poliba.it>
*/
#ifndef LTE_SPECTRUM_PHY_H
#define LTE_SPECTRUM_PHY_H
#include <ns3/spectrum-value.h>
#include <ns3/mobility-model.h>
#include <ns3/packet.h>
#include <ns3/nstime.h>
#include <ns3/net-device.h>
#include <ns3/spectrum-phy.h>
#include <ns3/spectrum-channel.h>
#include <ns3/spectrum-type.h>
#include <ns3/spectrum-interference.h>
#include <ns3/data-rate.h>
#include <ns3/phy-mac.h>
#include <ns3/packet-burst.h>
namespace ns3 {
class LteNetDevice;
/**
* The LteSpectrumPhy models the physical layer of LTE
*/
class LteSpectrumPhy : public SpectrumPhy
{
public:
LteSpectrumPhy ();
virtual ~LteSpectrumPhy ();
/**
* PHY states
*/
enum State
{
IDLE, TX, RX
};
static TypeId GetTypeId (void);
// inherited from SpectrumPhy
void SetChannel (Ptr<SpectrumChannel> c);
void SetMobility (Ptr<Object> m);
void SetDevice (Ptr<Object> d);
Ptr<Object> GetMobility ();
Ptr<Object> GetDevice ();
Ptr<const SpectrumModel> GetRxSpectrumModel () const;
/**
* \brief Get the channel where the physical layer is attached
* \return a pointer to the channel
*/
Ptr<SpectrumChannel> GetChannel (void);
/**
* Get the SpectrumType used by this PHY
*
* @return
*/
SpectrumType GetSpectrumType ();
/**
* set the Power Spectral Density of outgoing signals in W/Hz.
*
* @param txPsd
*/
void SetTxPowerSpectralDensity (Ptr<SpectrumValue> txPsd);
/**
* \brief set the noise power spectral density
* @param noisePsd the Noise Power Spectral Density in power units
* (Watt, Pascal...) per Hz.
*/
void SetNoisePowerSpectralDensity (Ptr<const SpectrumValue> noisePsd);
/**
* \brief get the noise power spectral density
* @return the Noise Power Spectral Density
*/
Ptr<const SpectrumValue> GetNoisePowerSpectralDensity (void);
/**
* Start a transmission
*
*
* @param pb the burst of packets to be transmitted
*
* @return true if an error occurred and the transmission was not
* started, false otherwise.
*/
bool StartTx (Ptr<PacketBurst> pb);
/**
* \brief Notify the SpectrumPhy instance of an incoming waveform
* \param pb the burst of packet associated with the incoming waveform
* \param rxPsd the Power Spectral Density of the incoming waveform.
* The units of the SPD are the same specified for SpectrumChannel::StartTx().
* \param st the spectrum type
* \param duration the duration of the incoming waveform
*/
void StartRx (Ptr<PacketBurst> pb, Ptr <const SpectrumValue> rxPsd, SpectrumType st, Time duration);
/**
* set the callback for the end of a TX, as part of the
* interconnections betweenthe PHY and the MAC
*
* @param c the callback
*/
void SetPhyMacTxEndCallback (PhyMacTxEndCallback c);
/**
* set the callback for the start of RX, as part of the
* interconnections betweenthe PHY and the MAC
*
* @param c the callback
*/
void SetPhyMacRxStartCallback (PhyMacRxStartCallback c);
/**
* set the callback for the end of a RX in error, as part of the
* interconnections betweenthe PHY and the MAC
*
* @param c the callback
*/
void SetPhyMacRxEndErrorCallback (PhyMacRxEndErrorCallback c);
/**
* set the callback for the successful end of a RX, as part of the
* interconnections betweenthe PHY and the MAC
*
* @param c the callback
*/
void SetPhyMacRxEndOkCallback (PhyMacRxEndOkCallback c);
/**
* \brief Calculate the SINR estimated during the reception of the
* packet.
* \param rxPsd the Power Spectral Density of the incoming waveform.
* \param noise the Power Spectral Density of the noise.
*/
virtual void CalcSinrValues (Ptr <const SpectrumValue> rxPsd, Ptr <const SpectrumValue> noise) = 0;
/**
* \brief Set the state of the phy layer
* \param newState the state
*/
void SetState (State newState);
private:
void ChangeState (State newState);
void EndTx ();
void AbortRx ();
virtual void EndRx ();
EventId m_endRxEventId;
Ptr<Object> m_mobility;
Ptr<Object> m_device;
Ptr<SpectrumChannel> m_channel;
Ptr<SpectrumValue> m_txPsd;
Ptr<const SpectrumValue> m_rxPsd;
Ptr<PacketBurst> m_txPacket;
Ptr<PacketBurst> m_rxPacket;
State m_state;
TracedCallback<Ptr<const Packet> > m_phyTxStartTrace;
TracedCallback<Ptr<const Packet> > m_phyTxEndTrace;
TracedCallback<Ptr<const Packet> > m_phyRxStartTrace;
TracedCallback<Ptr<const Packet> > m_phyRxAbortTrace;
TracedCallback<Ptr<const Packet> > m_phyRxEndOkTrace;
TracedCallback<Ptr<const Packet> > m_phyRxEndErrorTrace;
PhyMacTxEndCallback m_phyMacTxEndCallback;
PhyMacRxStartCallback m_phyMacRxStartCallback;
PhyMacRxEndErrorCallback m_phyMacRxEndErrorCallback;
PhyMacRxEndOkCallback m_phyMacRxEndOkCallback;
Ptr<const SpectrumValue> m_noise;
};
}
#endif /* LTE_SPECTRUM_PHY_H */

152
src/devices/lte/model/lte-spectrum-value-helper.cc

@ -0,0 +1,152 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Giuseppe Piro <g.piro@poliba.it>
*/
#include "lte-spectrum-value-helper.h"
#include <cmath>
namespace ns3 {
Ptr<SpectrumModel> LteDownlinkSpectrumModel;
Ptr<SpectrumModel> LteUplinkSpectrumModel;
class static_LteDownlinkSpectrumModel_initializer
{
public:
static_LteDownlinkSpectrumModel_initializer ()
{
/*
* Operating Bands for the UL: 1920 MHz 1980 MHz
* see for details TR.36.101 - Tab 5.5-1
*
*/
std::vector<double> freqs;
for (int i = 0; i < 100; ++i)
{
double centralFrequencyOfPRB = 1.920 + (i * 0.00018);
freqs.push_back (centralFrequencyOfPRB * 1e9);
}
LteDownlinkSpectrumModel = Create<SpectrumModel> (freqs);
}
} static_LteDownlinkSpectrumModel_initializer_instance;
class static_LteUplinkSpectrumModel_initializer
{
public:
static_LteUplinkSpectrumModel_initializer ()
{
/*
* Operating Bands for the DL: 2110 MHz 2170 MHz
* see for details TR.36.101 - Tab 5.5-1
*
*/
std::vector<double> freqs;
for (int i = 0; i < 100; ++i)
{
double centralFrequencyOfPRB = 2.110 + (i * 0.00018);
freqs.push_back (centralFrequencyOfPRB * 1e9);
}
LteUplinkSpectrumModel = Create<SpectrumModel> (freqs);
}
} static_LteUplinkSpectrumModel_initializer_instance;
Ptr<SpectrumValue>
LteSpectrumValueHelper::CreateDownlinkTxPowerSpectralDensity (double powerTx, std::vector<int> channels)
{
Ptr<SpectrumValue> txPsd = Create <SpectrumValue> (LteDownlinkSpectrumModel);
// powerTx is expressed in dBm. We must convert it into natural unit.
powerTx = pow (10., (powerTx - 30) / 10);
double txPowerDensity = (powerTx / channels.size ()) / 180000;
for (std::vector <int>::iterator it = channels.begin (); it != channels.end (); it++)
{
int idSubChannel = (*it);
(*txPsd)[idSubChannel] = txPowerDensity;
}
return txPsd;
}
Ptr<SpectrumValue>
LteSpectrumValueHelper::CreateUplinkTxPowerSpectralDensity (double powerTx, std::vector<int> channels)
{
Ptr<SpectrumValue> txPsd = Create <SpectrumValue> (LteUplinkSpectrumModel);
// powerTx is expressed in dBm. We must convert it into natural unit.
powerTx = pow (10., (powerTx - 30) / 10);
double txPowerDensity = (powerTx / channels.size ()) / 180000;
for (std::vector <int>::iterator it = channels.begin (); it != channels.end (); it++)
{
int idSubChannel = (*it);
(*txPsd)[idSubChannel] = txPowerDensity;
}
return txPsd;
}
Ptr<SpectrumValue>
LteSpectrumValueHelper::CreateDownlinkNoisePowerSpectralDensity (void)
{
Ptr<SpectrumValue> txPsd = Create <SpectrumValue> (LteDownlinkSpectrumModel);
double noise_db = 2.5 + (-174) + (10. * log10 (180000)) - 30;
double noisePowerDensity = (pow (10.,noise_db / 10)) / 180000;
(*txPsd) = noisePowerDensity;
return txPsd;
}
Ptr<SpectrumValue>
LteSpectrumValueHelper::CreateUplinkNoisePowerSpectralDensity (void)
{
Ptr<SpectrumValue> txPsd = Create <SpectrumValue> (LteUplinkSpectrumModel);
double noise_db = 2.5 + (-174) + (10. * log10 (180000)) - 30;
double noisePowerDensity = (pow (10.,noise_db / 10)) / 180000;
(*txPsd) = noisePowerDensity;
return txPsd;
}
} // namespace ns3

74
src/devices/lte/model/lte-spectrum-value-helper.h

@ -0,0 +1,74 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Giuseppe Piro <g.piro@poliba.it>
*/
#ifndef LTE_SPECTRUM_VALUE_HELPER_H
#define LTE_SPECTRUM_VALUE_HELPER_H
#include <ns3/spectrum-value.h>
#include <vector>
namespace ns3 {
/**
* \brief This class defines all functions to create spectrum model for lte
*/
class LteSpectrumValueHelper
{
public:
/**
* \brief create spectrum value
* \param powerTx the power transmission in dBm
* \param channels the list of sub channels where the signal will be sent
* \return a Ptr to a newly created SpectrumValue instance
*/
Ptr<SpectrumValue> CreateDownlinkTxPowerSpectralDensity (double powerTx, std::vector <int> channels);
/**
* \brief create spectrum value
* \param powerTx the power transmission in dBm
* \param channels the list of sub channels where the signal will be sent
* \return a Ptr to a newly created SpectrumValue instance
*/
Ptr<SpectrumValue> CreateUplinkTxPowerSpectralDensity (double powerTx, std::vector <int> channels);
/**
* \brief create spectrum value for noise
* \return a Ptr to a newly created SpectrumValue instance
*/
Ptr<SpectrumValue> CreateDownlinkNoisePowerSpectralDensity (void);
/**
* \brief create spectrum value for noise
* \return a Ptr to a newly created SpectrumValue instance
*/
Ptr<SpectrumValue> CreateUplinkNoisePowerSpectralDensity (void);
};
} // namespace ns3
#endif /* LTE_SPECTRUM_VALUE_HELPER_H */

89
src/devices/lte/model/mac-entity.cc

@ -0,0 +1,89 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Giuseppe Piro <g.piro@poliba.it>
*/
#include "mac-entity.h"
#include <ns3/log.h>
#include <ns3/pointer.h>
#include <ns3/packet.h>
#include "amc-module.h"
#include "lte-net-device.h"
NS_LOG_COMPONENT_DEFINE ("MacEntity");
namespace ns3 {
NS_OBJECT_ENSURE_REGISTERED (MacEntity);
TypeId MacEntity::GetTypeId (void)
{
static TypeId tid = TypeId ("ns3::MacEntity")
.SetParent<Object> ();
return tid;
}
MacEntity::MacEntity ()
{
m_amcModule = CreateObject<AmcModule> ();
m_device = 0;
}
MacEntity::~MacEntity ()
{
m_amcModule = 0;
m_device = 0;
}
void
MacEntity::SetDevice (Ptr<LteNetDevice> d)
{
NS_LOG_FUNCTION (this << d);
m_device = d;
}
Ptr<LteNetDevice>
MacEntity::GetDevice ()
{
NS_LOG_FUNCTION (this);
return m_device;
}
void
MacEntity::SetAmcModule (Ptr<AmcModule> amc)
{
NS_LOG_FUNCTION (this << amc);
m_amcModule = amc;
}
Ptr<AmcModule>
MacEntity::GetAmcModule (void) const
{
NS_LOG_FUNCTION (this);
return m_amcModule;
}
} // namespace ns3

77
src/devices/lte/model/mac-entity.h

@ -0,0 +1,77 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Giuseppe Piro <g.piro@poliba.it>
*/
#ifndef MAC_ENTITY_H
#define MAC_ENTITY_H
#include "ns3/object.h"
#include <list>
namespace ns3 {
class Packet;
class LteNetDevice;
class AmcModule;
/**
* This class provides a basi implementation of the MAC
* layer
*/
class MacEntity : public Object
{
public:
static TypeId GetTypeId (void);
MacEntity (void);
virtual ~MacEntity (void);
/**
* \brief Set the device where the mac entity is attached
* \param d the device
*/
void SetDevice (Ptr<LteNetDevice> d);
/**
* \brief Get the device where the mac entity is attached
* \return the pointer to the device
*/
Ptr<LteNetDevice> GetDevice ();
/**
* \brief Set the AMC module
* \param amcModule the AMC Module.
*/
void SetAmcModule (Ptr<AmcModule> amcModule);
/**
* \brief Get the AMC module
* \returns a pointer to the AMC Module.
*/
Ptr<AmcModule> GetAmcModule (void) const;
private:
Ptr<LteNetDevice> m_device;
Ptr<AmcModule> m_amcModule;
};
} // namespace ns3
#endif /* MAC_ENTITY_H */

333
src/devices/lte/model/multipath-loss-model.cc

@ -0,0 +1,333 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Giuseppe Piro <g.piro@poliba.it>
*/
#include <cmath>
#include <ns3/log.h>
#include "multipath-loss-model.h"
#include <ns3/simulator.h>
#include <stdint.h>
#include "stdlib.h"
#include "lte-phy.h"
#include <ns3/mobility-model.h>
#include "JakesTraces/multipath_v0_M6.h"
#include "JakesTraces/multipath_v0_M8.h"
#include "JakesTraces/multipath_v0_M10.h"
#include "JakesTraces/multipath_v0_M12.h"
#include "JakesTraces/multipath_v3_M6.h"
#include "JakesTraces/multipath_v3_M8.h"
#include "JakesTraces/multipath_v3_M10.h"
#include "JakesTraces/multipath_v3_M12.h"
#include "JakesTraces/multipath_v30_M6.h"
#include "JakesTraces/multipath_v30_M8.h"
#include "JakesTraces/multipath_v30_M10.h"
#include "JakesTraces/multipath_v30_M12.h"
#include "JakesTraces/multipath_v120_M6.h"
#include "JakesTraces/multipath_v120_M8.h"
#include "JakesTraces/multipath_v120_M10.h"
#include "JakesTraces/multipath_v120_M12.h"
NS_LOG_COMPONENT_DEFINE ("JakesFadingLossModel");
namespace ns3 {
NS_OBJECT_ENSURE_REGISTERED (JakesFadingLossModel);
JakesFadingLossModel::JakesFadingLossModel ()
{
NS_LOG_FUNCTION (this);
SetSamplingPeriod (0.5); // default value
m_multipath = new MultipathForFrequencyDomain ();
m_nbOfPaths = new UniformVariable (1, 4);
m_startJakes = new UniformVariable (1, 2000);
m_phy = 0;
}
TypeId
JakesFadingLossModel::GetTypeId (void)
{
static TypeId tid = TypeId ("ns3::JakesFadingLossModel")
.SetParent<DiscreteTimeLossModel> ()
.AddConstructor<JakesFadingLossModel> ()
;
return tid;
}
JakesFadingLossModel::~JakesFadingLossModel ()
{
m_multipath = 0;
m_nbOfPaths = 0;
m_startJakes = 0;
}
void
JakesFadingLossModel::SetPhy (Ptr<LtePhy> phy)
{
NS_LOG_FUNCTION (this);
m_phy = phy;
SetValue ();
}
Ptr<LtePhy>
JakesFadingLossModel::GetPhy (void)
{
NS_LOG_FUNCTION (this);
return m_phy;
}
void
JakesFadingLossModel::SetValue (void)
{
NS_LOG_FUNCTION (this);
m_multipath->clear ();
int downlinkSubChannels = GetPhy ()->GetDownlinkSubChannels ().size ();
Ptr<MobilityModel> mobility = GetPhy ()->GetDownlinkSpectrumPhy ()->GetMobility ()->GetObject<MobilityModel> ();
Vector speedVector = mobility->GetVelocity ();
double speed = sqrt (pow (speedVector.x,2) + pow (speedVector.y,2));
NS_LOG_FUNCTION (this << mobility << speedVector << speed);
/*
* Several 3GPP standards propose a simulation scenario to use duirng the
* LTE performance evaluation. In particular they suggest to consider these
* user speeds: 0, 3, 30, 120 km/h. To this aim, we should map user speed
* into one of the suggested values.
*/
if (speed < 3.)
{
speed = 0;
}
else if (speed < 30.)
{
speed = 3.;
}
else if (speed < 120.)
{
speed = 30.;
}
else
{
speed = 120;
}
NS_LOG_FUNCTION (this << mobility << speedVector << speed);
/*
* Jackes Model.
* Jakes popularised a model for Rayleigh fading based on summing sinusoids
* William C. Jakes, Editor (February 1, 1975).
* Microwave Mobile Communications.
* New York: John Wiley & Sons Inc. ISBN 0-471-43720-4
*/
// number of path = M
// x = 1 -> M=6, x = 2 -> M=8, x = 3 -> M=10, x = 4 -> M=12
int x = m_nbOfPaths->GetValue ();
for (int i = 0; i < downlinkSubChannels; i++)
{
// StartJakes allow us to select a window of 0.5ms into the Jakes realization lasting 3s.
int startJakes = m_startJakes->GetValue ();
MultipathForTimeDomain multipathForTimeDomain;
if (x == 1)
{
// SELECTED 6 MULTIPLE PATH FOR JAKES MODEL
if (speed == 0)
{
for (int j = 0; j < 500; j++)
{
multipathForTimeDomain.push_back (multipath_M6_v_0 [j + startJakes]);
}
}
if (speed == 3)
{
for (int j = 0; j < 500; j++)
{
multipathForTimeDomain.push_back (multipath_M6_v_3 [j + startJakes]);
}
}
if (speed == 30)
{
for (int j = 0; j < 500; j++)
{
multipathForTimeDomain.push_back (multipath_M6_v_30 [j + startJakes]);
}
}
if (speed == 120)
{
for (int j = 0; j < 500; j++)
{
multipathForTimeDomain.push_back (multipath_M6_v_120 [j + startJakes]);
}
}
}
else if (x == 2)
{
// SELECTED 6 MULTIPLE PATH FOR JAKES MODEL
if (speed == 0)
{
for (int j = 0; j < 500; j++)
{
multipathForTimeDomain.push_back (multipath_M8_v_0 [j + startJakes]);
}
}
if (speed == 3)
{
for (int j = 0; j < 500; j++)
{
multipathForTimeDomain.push_back (multipath_M8_v_3 [j + startJakes]);
}
}
if (speed == 30)
{
for (int j = 0; j < 500; j++)
{
multipathForTimeDomain.push_back (multipath_M8_v_30 [j + startJakes]);
}
}
if (speed == 120)
{
for (int j = 0; j < 500; j++)
{
multipathForTimeDomain.push_back (multipath_M8_v_120 [j + startJakes]);
}
}
}
else if (x == 3)
{
// SELECTED 6 MULTIPLE PATH FOR JAKES MODEL
if (speed == 0)
{
for (int j = 0; j < 500; j++)
{
multipathForTimeDomain.push_back (multipath_M10_v_0 [j + startJakes]);
}
}
if (speed == 3)
{
for (int j = 0; j < 500; j++)
{
multipathForTimeDomain.push_back (multipath_M10_v_3 [j + startJakes]);
}
}
if (speed == 30)
{
for (int j = 0; j < 500; j++)
{
multipathForTimeDomain.push_back (multipath_M10_v_30 [j + startJakes]);
}
}
if (speed == 120)
{
for (int j = 0; j < 500; j++)
{
multipathForTimeDomain.push_back (multipath_M10_v_120 [j + startJakes]);
}
}
}
else if (x == 4)
{
// SELECTED 6 MULTIPLE PATH FOR JAKES MODEL
if (speed == 0)
{
for (int j = 0; j < 500; j++)
{
multipathForTimeDomain.push_back (multipath_M12_v_0 [j + startJakes]);
}
}
if (speed == 3)
{
for (int j = 0; j < 500; j++)
{
multipathForTimeDomain.push_back (multipath_M12_v_3 [j + startJakes]);
}
}
if (speed == 30)
{
for (int j = 0; j < 500; j++)
{
multipathForTimeDomain.push_back (multipath_M12_v_30 [j + startJakes]);
}
}
if (speed == 120)
{
for (int j = 0; j < 500; j++)
{
multipathForTimeDomain.push_back (multipath_M12_v_120 [j + startJakes]);
}
}
}
else
{
std::cout << " ERROR: Jaks's Model, incorrect M value" << std::endl;
}
m_multipath->push_back (multipathForTimeDomain);
}
SetLastUpdate ();
}
double
JakesFadingLossModel::GetValue (int subChannel)
{
NS_LOG_FUNCTION (this);
if (NeedForUpdate ())
{
SetValue ();
SetLastUpdate ();
}
int now_ms = Simulator::Now ().GetSeconds () * 1000;
int lastUpdate_ms = GetLastUpdate ().GetSeconds () * 1000;
int index = now_ms - lastUpdate_ms;
NS_LOG_FUNCTION (this << subChannel << now_ms
<< lastUpdate_ms << index << m_multipath->at (subChannel).at (index));
return m_multipath->at (subChannel).at (index);
}
} // namespace ns3

100
src/devices/lte/model/multipath-loss-model.h

@ -0,0 +1,100 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Giuseppe Piro <g.piro@poliba.it>
*/
#ifndef MULTIPATH_LOSS_MODEL_H
#define MULTIPATH_LOSS_MODEL_H
#include "loss-model.h"
#include <list>
#include <ns3/random-variable.h>
namespace ns3 {
class LtePhy;
/**
* \brief JakesFadingLossModel class implements a loss model due to the fast fading.
* In particular, the fast fading is modeled using a Jakes Model
*/
class JakesFadingLossModel : public DiscreteTimeLossModel
{
public:
JakesFadingLossModel ();
virtual ~JakesFadingLossModel ();
static TypeId GetTypeId (void);
/**
* \brief Set the value of the considered loss model
*/
void SetValue (void);
/**
* \brief Get the value for a particular sub channel
* \param subChannel the sub channel for which a value is requested
* \return the loss for a particular sub channel
*/
double GetValue (int subChannel);
/**
* \brief Set the physical layer
* \param phy the physical layer
*/
void SetPhy (Ptr<LtePhy> phy);
/**
* \brief Get the physical layer
* \return the pointer to the physical layer
*/
Ptr<LtePhy> GetPhy (void);
/*
* In order to avoid to execute every TTI the Jakes Model, the value
* of the multipath loss is stored into a matrix (MultipathForFrequencyDomain)
* frequency x time.
*
* A MultipathForFrequencyDomain element is build in a way that
* m_multipath.at(i).at(j) represents the loss at the frequency i and time j.
*
* The model is udated every samplingInterval (the default value is 0.5 ms)
*/
/**
* brief a list of multipath values for the time domain
*/
typedef std::vector<double> MultipathForTimeDomain;
/**
* brief a list of multipath values for the frequency domain
*/
typedef std::vector<MultipathForTimeDomain> MultipathForFrequencyDomain;
private:
MultipathForFrequencyDomain *m_multipath;
UniformVariable *m_nbOfPaths;
UniformVariable *m_startJakes;
Ptr<LtePhy> m_phy;
};
}
#endif /* MULTIPATH_LOSS_MODEL_H */

47
src/devices/lte/model/multipath.h

@ -0,0 +1,47 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Giuseppe Piro <g.piro@poliba.it>
*/
#ifndef MULTIPATH_H_
#define MULTIPATH_H_
#include "JakesTraces/multipath_v0_M6.h"
#include "JakesTraces/multipath_v0_M8.h"
#include "JakesTraces/multipath_v0_M10.h"
#include "JakesTraces/multipath_v0_M12.h"
#include "JakesTraces/multipath_v3_M6.h"
#include "JakesTraces/multipath_v3_M8.h"
#include "JakesTraces/multipath_v3_M10.h"
#include "JakesTraces/multipath_v3_M12.h"
#include "JakesTraces/multipath_v30_M6.h"
#include "JakesTraces/multipath_v30_M8.h"
#include "JakesTraces/multipath_v30_M10.h"
#include "JakesTraces/multipath_v30_M12.h"
#include "JakesTraces/multipath_v120_M6.h"
#include "JakesTraces/multipath_v120_M8.h"
#include "JakesTraces/multipath_v120_M10.h"
#include "JakesTraces/multipath_v120_M12.h"
#endif /* MULTIPATH_H_ */

112
src/devices/lte/model/packet-scheduler.cc

@ -0,0 +1,112 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Giuseppe Piro <g.piro@poliba.it>
*/
#include <ns3/log.h>
#include <ns3/pointer.h>
#include "ue-net-device.h"
#include "enb-net-device.h"
#include "packet-scheduler.h"
#include "enb-mac-entity.h"
NS_LOG_COMPONENT_DEFINE ("PacketScheduler");
namespace ns3 {
NS_OBJECT_ENSURE_REGISTERED (PacketScheduler);
PacketScheduler::PacketScheduler ()
: m_enb (0),
m_macEntity (0)
{
NS_LOG_FUNCTION (this);
}
PacketScheduler::PacketScheduler (Ptr<EnbNetDevice> enb)
: m_enb (enb),
m_macEntity (0)
{
NS_LOG_FUNCTION (this);
}
/*
TypeId
PacketScheduler::GetTypeId (void)
{
static TypeId tid = TypeId ("ns3::PacketScheduler")
.SetParent<Object> ()
.AddConstructor<PacketScheduler> ()
;
return tid;
}
*/
PacketScheduler::~PacketScheduler ()
{
NS_LOG_FUNCTION (this);
}
void
PacketScheduler::SetDevice (Ptr<EnbNetDevice> enb)
{
NS_LOG_FUNCTION (this << enb);
m_enb = enb;
}
Ptr<EnbNetDevice>
PacketScheduler::GetDevice ()
{
NS_LOG_FUNCTION (this);
return m_enb;
}
void
PacketScheduler::SetMacEntity (Ptr<MacEntity> mac)
{
NS_LOG_FUNCTION (this);
m_macEntity = mac;
}
Ptr<MacEntity>
PacketScheduler::GetMacEntity (void)
{
NS_LOG_FUNCTION (this);
return m_macEntity;
}
void
PacketScheduler::RunPacketScheduler (void)
{
NS_LOG_FUNCTION (this);
DoRunPacketScheduler ();
}
} // namespace ns3

96
src/devices/lte/model/packet-scheduler.h

@ -0,0 +1,96 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Giuseppe Piro <g.piro@poliba.it>
*/
#ifndef PACKET_SCHEDULER_H
#define PACKET_SCHEDULER_H
#include <ns3/nstime.h>
#include <ns3/object.h>
#include <list>
#include <ns3/ptr.h>
namespace ns3 {
class EnbNetDevice;
class UeNetDevice;
class MacEntity;
/**
* This class represents the basic implementation of the LTE packet scheduler
*/
class PacketScheduler : public Object
{
public:
PacketScheduler ();
/**
* Create a packet scheduler
* \param enb the device where the packet scheduler works
*/
PacketScheduler (Ptr<EnbNetDevice> enb);
virtual ~PacketScheduler ();
// static TypeId GetTypeId (void);
/**
* \brief Set the device where the scheduler works
* \param enb the device where the scheduler works
*/
void SetDevice (Ptr<EnbNetDevice> enb);
/**
* \brief Get the device where the scheduler works
* \return the pointer to the device where the scheduler works
*/
Ptr<EnbNetDevice> GetDevice ();
/**
* \brief Set the MAC entity of the device where the scheduler works
* \param mac the mac entity
*/
void SetMacEntity (Ptr<MacEntity> mac);
/**
* \brief Get the MAC entity of the device where the scheduler works
* \return the pointer to the mac the mac entity
*/
Ptr<MacEntity> GetMacEntity (void);
/**
* \brief run the scheduling algorithm
*/
void RunPacketScheduler (void);
/**
* \brief run a particular scheduling strategy for both uplink and downlink
*/
virtual void DoRunPacketScheduler (void) = 0;
private:
Ptr<EnbNetDevice> m_enb;
Ptr<MacEntity> m_macEntity;
};
}
#endif /* PACKET_SCHEDULER_H */

86
src/devices/lte/model/path-loss-model.cc

@ -0,0 +1,86 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Giuseppe Piro <g.piro@poliba.it>
*/
#include <ns3/log.h>
#include <cmath>
#include "path-loss-model.h"
#include <ns3/mobility-model.h>
#include <ns3/vector.h>
NS_LOG_COMPONENT_DEFINE ("PathLossModel");
namespace ns3 {
NS_OBJECT_ENSURE_REGISTERED (PathLossModel);
PathLossModel::PathLossModel ()
{
NS_LOG_FUNCTION (this);
SetLastUpdate ();
SetSamplingPeriod (0.5); // defauld value
m_pl = 0;
}
TypeId
PathLossModel::GetTypeId (void)
{
static TypeId tid = TypeId ("ns3::PathLossModel")
.SetParent<DiscreteTimeLossModel> ()
.AddConstructor<PathLossModel> ()
;
return tid;
}
PathLossModel::~PathLossModel ()
{
}
void
PathLossModel::SetValue (double pl)
{
NS_LOG_FUNCTION (this << pl);
m_pl = pl;
}
double
PathLossModel::GetValue (Ptr<const MobilityModel> a, Ptr<const MobilityModel> b)
{
NS_LOG_FUNCTION (this << a << b);
/*
* According to --- insert standard 3gpp ---
* the Path Loss Model For Urban Environment is
* L = I + 37.6log10(R)
* R, in kilometers, is the distance between two nodes
* I = 128.1 at 2GHz
*/
double distance = CalculateDistance (a->GetPosition (), b->GetPosition ());
SetValue (128.1 + (37.6 * log10 (distance * 0.001)));
return m_pl;
}
} // namespace ns3

65
src/devices/lte/model/path-loss-model.h

@ -0,0 +1,65 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Giuseppe Piro <g.piro@poliba.it>
*/
#ifndef PATH_LOSS_MODEL_H
#define PATH_LOSS_MODEL_H
#include "loss-model.h"
namespace ns3 {
class MobilityModel;
/**
* \brief This class models the propagation loss model due to the path loss
*/
class PathLossModel : public DiscreteTimeLossModel
{
public:
PathLossModel ();
virtual ~PathLossModel ();
static TypeId GetTypeId (void);
/**
* Set the value of the path loss model, expressed in dB
* \param pl the path loss value
*/
void SetValue (double pl);
/**
* Get the value of the path loss model, expressed in dB
* \param a sender mobility
* \param b receiver mobility
* \return the value of the path loss
*/
double GetValue (Ptr<const MobilityModel> a, Ptr<const MobilityModel> b);
private:
double m_pl;
};
}
#endif /* PATH_LOSS_MODEL_H */

74
src/devices/lte/model/penetration-loss-model.cc

@ -0,0 +1,74 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Giuseppe Piro <g.piro@poliba.it>
*/
#include <ns3/log.h>
#include "penetration-loss-model.h"
#include <ns3/simulator.h>
NS_LOG_COMPONENT_DEFINE ("PenetrationLossModel");
namespace ns3 {
NS_OBJECT_ENSURE_REGISTERED (PenetrationLossModel);
PenetrationLossModel::PenetrationLossModel ()
{
NS_LOG_FUNCTION (this);
SetLastUpdate ();
SetSamplingPeriod (0.5); // defauld value
m_pnl = 10;
}
TypeId
PenetrationLossModel::GetTypeId (void)
{
static TypeId tid = TypeId ("ns3::PenetrationLossModel")
.SetParent<DiscreteTimeLossModel> ()
.AddConstructor<PenetrationLossModel> ()
;
return tid;
}
PenetrationLossModel::~PenetrationLossModel ()
{
}
void
PenetrationLossModel::SetValue (double pnl)
{
NS_LOG_FUNCTION (this << pnl);
m_pnl = pnl;
}
double
PenetrationLossModel::GetValue (void)
{
NS_LOG_FUNCTION (this);
return m_pnl;
}
} // namespace ns3

60
src/devices/lte/model/penetration-loss-model.h

@ -0,0 +1,60 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Giuseppe Piro <g.piro@poliba.it>
*/
#ifndef PENETRATION_LOSS_MODEL_H
#define PENETRATION_LOSS_MODEL_H
#include "loss-model.h"
namespace ns3 {
/**
* \brief This class models the propagation loss model due to the penetration loss
*/
class PenetrationLossModel : public DiscreteTimeLossModel
{
public:
PenetrationLossModel ();
virtual ~PenetrationLossModel ();
static TypeId GetTypeId (void);
/**
* Set the value of the penetration loss model, expressed in dB
* \param pnl the penetration loss value
*/
void SetValue (double pnl);
/**
* Get the value of the penetration loss model, expressed in dB
* \return the value of the penetration loss model
*/
double GetValue (void);
private:
double m_pnl;
};
}
#endif /* PENETRATION_LOSS_MODEL_H */

188
src/devices/lte/model/radio-bearer-instance.cc

@ -0,0 +1,188 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Giuseppe Piro <g.piro@poliba.it>
*/
#include "radio-bearer-instance.h"
#include "bearer-qos-parameters.h"
#include "ns3/ipcs-classifier-record.h"
#include "rlc-entity.h"
#include <ns3/log.h>
#include <ns3/pointer.h>
NS_LOG_COMPONENT_DEFINE ("RadioBearerInstance");
namespace ns3 {
NS_OBJECT_ENSURE_REGISTERED (RadioBearerInstance);
TypeId RadioBearerInstance::GetTypeId (void)
{
static TypeId tid = TypeId ("ns3::RadioBearerInstance")
.SetParent<Object> ()
.AddAttribute ("TxQueue",
"Transmit queue",
PointerValue (),
MakePointerAccessor (&RadioBearerInstance::GetQueue),
MakePointerChecker<LteMacQueue> ());
return tid;
}
RadioBearerInstance::RadioBearerInstance ()
: m_queue (CreateObject<LteMacQueue> (1024)),
m_qosParameters (0),
m_rlcEntity (CreateObject<RlcEntity> ()),
m_ipcsClassifierRecord (0)
{
m_rlcEntity->SetRadioBearer (this);
}
RadioBearerInstance::~RadioBearerInstance ()
{
}
void
RadioBearerInstance::SetBearerDirection (BearerDirection direction)
{
m_direction = direction;
}
RadioBearerInstance::BearerDirection
RadioBearerInstance::GetBearerDirection (void) const
{
return m_direction;
}
void
RadioBearerInstance::SetBearerType (BearerType type)
{
m_bearerType = type;
}
RadioBearerInstance::BearerType
RadioBearerInstance::GetBearerType (void) const
{
return m_bearerType;
}
void
RadioBearerInstance::SetQosParameters (Ptr<BearerQosParameters> qosParameters)
{
m_qosParameters = qosParameters;
}
Ptr<BearerQosParameters>
RadioBearerInstance::GetQosParameters (void)
{
return m_qosParameters;
}
void
RadioBearerInstance::DoDispose (void)
{
NS_LOG_FUNCTION (this);
m_queue = 0;
}
Ptr<LteMacQueue>
RadioBearerInstance::GetQueue (void) const
{
NS_LOG_FUNCTION (this);
return m_queue;
}
bool
RadioBearerInstance::Enqueue (Ptr<Packet> packet)
{
NS_LOG_FUNCTION (this);
return m_queue->Enqueue (packet);
}
Ptr<Packet>
RadioBearerInstance::Dequeue (void)
{
NS_LOG_FUNCTION (this);
return m_queue->Dequeue ();
}
Ptr<Packet>
RadioBearerInstance::Dequeue (uint32_t availableByte)
{
NS_LOG_FUNCTION (this);
/*
This function can be caled when the UM or AM RLC mode is abilited.
The bearer gives packets to rlc-entiry until all available byte will be used.
*/
// return m_queue->Dequeue (availableByte);
return 0;
}
bool
RadioBearerInstance::HasPackets (void) const
{
NS_LOG_FUNCTION (this);
return !m_queue->IsEmpty ();
}
void
RadioBearerInstance::SetRlcEntity (Ptr<RlcEntity> rlc)
{
NS_LOG_FUNCTION (this);
m_rlcEntity = rlc;
}
Ptr<RlcEntity>
RadioBearerInstance::GetRlcEntity (void)
{
NS_LOG_FUNCTION (this);
return m_rlcEntity;
}
void
RadioBearerInstance::SetIpcsClassifierRecord (IpcsClassifierRecord* c)
{
NS_LOG_FUNCTION (this << c);
m_ipcsClassifierRecord = c;
}
IpcsClassifierRecord*
RadioBearerInstance::GetIpcsClassifierRecord (void)
{
NS_LOG_FUNCTION (this);
return m_ipcsClassifierRecord;
}
} // namespace ns3

170
src/devices/lte/model/radio-bearer-instance.h

@ -0,0 +1,170 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Giuseppe Piro <g.piro@poliba.it>
*/
#ifndef RADIO_BEARER_INSTANCE_H
#define RADIO_BEARER_INSTANCE_H
#include "ns3/object.h"
#include "lte-mac-queue.h"
#include "ns3/ipcs-classifier-record.h"
namespace ns3 {
class BearerQosParameters;
class RlcEntity;
/**
* This class implements the LTE radio bearer in which
* a data flow between UE and eNB will be mapped.
*/
class RadioBearerInstance : public Object
{
public:
static TypeId GetTypeId (void);
RadioBearerInstance (void);
virtual ~RadioBearerInstance (void);
/**
* The direction of the bearer
*/
enum BearerDirection
{
DIRECTION_TYPE_UL, DIRECTION_TYPE_DL
};
/**
* The bearer type
*/
enum BearerType
{
/*
As the mobile device is already known in the core network
the following radio bearers are now established automatically:
- A low priority signaling (message) bearer (SRB1)
- A high priority signaling (message) bearer (SRB2)
- A data radio bearer (DRB), i.e. a bearer for IP packets
*/
BEARER_TYPE_SRB1, BEARER_TYPE_SRB2, BEARER_TYPE_DRB
};
/**
* \brief Set direction of the bearer
* \param direction the direction of the bearer
*/
void SetBearerDirection (BearerDirection direction);
/**
* \brief Get direction of the bearer
* \return the direction of the bearer
*/
BearerDirection GetBearerDirection (void) const;
/**
* \brief Set the type of bearer
* \param type the QoS type
*/
void SetBearerType (BearerType type);
/**
* \brief Get the type of bearer
* \return the type the bearer
*/
BearerType GetBearerType (void) const;
/**
* \return the queue of the bearer
*/
Ptr<LteMacQueue> GetQueue (void) const;
/**
* \brief enqueue a packet in the queue of the bearer
* \param packet the packet to be enqueued
*/
bool Enqueue (Ptr<Packet> packet);
/**
* \brief dequeue a packet from the queue of the bearer
*/
Ptr<Packet> Dequeue (void);
/**
* \brief dequeue a packet from the queue of the bearer
* \param availableByte number of bytes can be dequeued
*/
Ptr<Packet> Dequeue (uint32_t availableByte);
/**
* \return true if the bearer has at least one packet in its queue, false otherwise
*/
bool HasPackets (void) const;
/**
* \brief Set a list of QoS parameters of the Bearer
* \param qosParameters the list of QoS parameters
*/
void SetQosParameters (Ptr<BearerQosParameters> qosParameters);
/**
* \brief Get a list of QoS parameters of the Bearer
* \return the pointer to the list of QoS parameters
*/
Ptr<BearerQosParameters> GetQosParameters (void);
/**
* \brief Set the RLC entity of this bearer
* \param rlc the RLC entity
*/
void SetRlcEntity (Ptr<RlcEntity> rlc);
/**
* \brief Get the RLC entity if this bearer
* \return the pointer to the RLC entity
*/
Ptr<RlcEntity> GetRlcEntity (void);
/**
* \brief Set the ip classifier record
* \return p the pointer to the ip classifier record
*/
void SetIpcsClassifierRecord (IpcsClassifierRecord* c);
/**
* \brief Get the ip classifier record
* \return the pointer to the ip classifier record
*/
IpcsClassifierRecord* GetIpcsClassifierRecord (void);
private:
virtual void DoDispose (void);
Ptr<LteMacQueue> m_queue;
Ptr<BearerQosParameters> m_qosParameters;
BearerDirection m_direction;
BearerType m_bearerType;
Ptr<RlcEntity> m_rlcEntity;
IpcsClassifierRecord* m_ipcsClassifierRecord;
};
} // namespace ns3
#endif /* RADIO_BEARER_INSTANCE_H */

109
src/devices/lte/model/rlc-entity.cc

@ -0,0 +1,109 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Giuseppe Piro <g.piro@poliba.it>
*/
#include "rlc-entity.h"
#include <ns3/log.h>
#include <ns3/pointer.h>
#include <ns3/packet.h>
#include "ue-net-device.h"
#include "enb-net-device.h"
#include "rrc-entity.h"
#include "radio-bearer-instance.h"
NS_LOG_COMPONENT_DEFINE ("RlcEntity");
namespace ns3 {
NS_OBJECT_ENSURE_REGISTERED (RlcEntity);
TypeId RlcEntity::GetTypeId (void)
{
static TypeId tid = TypeId ("ns3::RlcEntity")
.SetParent<Object> ();
return tid;
}
RlcEntity::RlcEntity ()
: m_device (0)
{
NS_LOG_FUNCTION (this);
}
RlcEntity::RlcEntity (Ptr<LteNetDevice> d)
: m_device (d)
{
NS_LOG_FUNCTION (this << d);
}
RlcEntity::~RlcEntity ()
{
NS_LOG_FUNCTION (this);
}
void
RlcEntity::SetDevice (Ptr<LteNetDevice> d)
{
NS_LOG_FUNCTION (this << d);
m_device = d;
}
Ptr<LteNetDevice>
RlcEntity::GetDevice (void)
{
NS_LOG_FUNCTION (this);
return m_device;
}
Ptr<Packet>
RlcEntity::Dequeue ()
{
NS_LOG_FUNCTION (this);
Ptr<Packet> p = GetRadioBearer ()->Dequeue ();
return p;
}
void
RlcEntity::SetRadioBearer (Ptr<RadioBearerInstance> b)
{
NS_LOG_FUNCTION (this << b);
m_bearer = b;
}
Ptr<RadioBearerInstance>
RlcEntity::GetRadioBearer (void)
{
NS_LOG_FUNCTION (this);
return m_bearer;
}
} // namespace ns3

90
src/devices/lte/model/rlc-entity.h

@ -0,0 +1,90 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Giuseppe Piro <g.piro@poliba.it>
*/
#ifndef RLC_ENTITY_H
#define RLC_ENTITY_H
#include "ns3/object.h"
#include <list>
namespace ns3 {
class Packet;
class LteNetDevice;
class RadioBearerInstance;
/**
* This class implements the RLC entity
*/
class RlcEntity : public Object
{
public:
static TypeId GetTypeId (void);
RlcEntity (void);
/**
* \brief Create the RLC entity
* \param d the device where the RLC entity is created
*/
RlcEntity (Ptr<LteNetDevice> d);
virtual ~RlcEntity (void);
/**
* \brief Set the device where the RLC entity is attached
* \param d the device
*/
void SetDevice (Ptr<LteNetDevice> d);
/**
* \brief Get the device where the RLC entity is attached
* \return the pointer to the device
*/
Ptr<LteNetDevice> GetDevice ();
/**
* \brief Get A packet form the queue
* \return a pointer to the packet
*/
Ptr<Packet> Dequeue ();
/**
* \brief Set the bearer where the rlc entity is attached
* \paramm b the radio bearer
*/
void SetRadioBearer (Ptr<RadioBearerInstance> b);
/**
* \brief Get the bearer where the rlc entity is attached
* \return the pointer to the radio bearer
*/
Ptr<RadioBearerInstance> GetRadioBearer (void);
private:
Ptr<LteNetDevice> m_device;
Ptr<RadioBearerInstance> m_bearer;
};
} // namespace ns3
#endif /* RLC_ENTITY_H */

250
src/devices/lte/model/rrc-entity.cc

@ -0,0 +1,250 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Giuseppe Piro <g.piro@poliba.it>
*/
#include "rrc-entity.h"
#include <ns3/log.h>
#include <ns3/pointer.h>
#include <ns3/packet.h>
#include "ns3/ipcs-classifier-record.h"
#include "radio-bearer-instance.h"
#include "ns3/packet.h"
#include "ns3/ipv4-header.h"
#include "ns3/udp-header.h"
#include "ns3/tcp-header.h"
#include "ns3/llc-snap-header.h"
#include "ns3/udp-l4-protocol.h"
#include "ns3/tcp-l4-protocol.h"
#include "lte-mac-header.h"
NS_LOG_COMPONENT_DEFINE ("RrcEntity");
namespace ns3 {
NS_OBJECT_ENSURE_REGISTERED (RrcEntity);
TypeId RrcEntity::GetTypeId (void)
{
static TypeId tid = TypeId ("ns3::RrcEntity")
.SetParent<Object> ()
;
return tid;
}
RrcEntity::RrcEntity ()
{
NS_LOG_FUNCTION (this);
CreateBearersContainer ();
}
RrcEntity::~RrcEntity ()
{
NS_LOG_FUNCTION (this);
delete m_downlinkGbrBearersContainer;
delete m_downlinkNgbrBearersContainer;
delete m_uplinkGbrBearersContainer;
delete m_uplinkNgbrBearersContainer;
}
void
RrcEntity::CreateBearersContainer ()
{
NS_LOG_FUNCTION (this);
m_downlinkGbrBearersContainer = new BearersContainer ();
m_downlinkNgbrBearersContainer = new BearersContainer ();
m_uplinkGbrBearersContainer = new BearersContainer ();
m_uplinkNgbrBearersContainer = new BearersContainer ();
m_defaultBearer = CreateObject<RadioBearerInstance> ();
}
RrcEntity::BearersContainer*
RrcEntity::GetDownlinkGbrBearers (void) const
{
NS_LOG_FUNCTION (this);
return m_downlinkGbrBearersContainer;
}
RrcEntity::BearersContainer*
RrcEntity::GetDownlinkNgbrBearers (void) const
{
NS_LOG_FUNCTION (this);
return m_downlinkNgbrBearersContainer;
}
RrcEntity::BearersContainer*
RrcEntity::GetUplinkGbrBearers (void) const
{
NS_LOG_FUNCTION (this);
return m_uplinkGbrBearersContainer;
}
RrcEntity::BearersContainer*
RrcEntity::GetUplinkNgbrBearers (void) const
{
NS_LOG_FUNCTION (this);
return m_uplinkNgbrBearersContainer;
}
void
RrcEntity::AddDownlinkGbrBearer (Ptr<RadioBearerInstance> bearer)
{
NS_LOG_FUNCTION (this);
m_downlinkGbrBearersContainer->push_back (bearer);
}
void
RrcEntity::AddDownlinkNgbrBearer (Ptr<RadioBearerInstance> bearer)
{
NS_LOG_FUNCTION (this);
m_downlinkNgbrBearersContainer->push_back (bearer);
}
void
RrcEntity::AddUplinkGbrBearer (Ptr<RadioBearerInstance> bearer)
{
NS_LOG_FUNCTION (this);
m_uplinkGbrBearersContainer->push_back (bearer);
}
void
RrcEntity::AddUplinkNgbrBearer (Ptr<RadioBearerInstance> bearer)
{
NS_LOG_FUNCTION (this);
m_uplinkNgbrBearersContainer->push_back (bearer);
}
Ptr<RadioBearerInstance>
RrcEntity::Classify (Ptr<Packet> p) const
{
NS_LOG_FUNCTION (this);
Ptr<Packet> C_Packet = p->Copy ();
LteMacHeader header;
C_Packet->RemoveHeader (header);
NS_LOG_LOGIC ("packet " << header.GetSource () << " --> " << header.GetDestination ());
LlcSnapHeader llc;
C_Packet->RemoveHeader (llc);
Ipv4Header ipv4Header;
C_Packet->RemoveHeader (ipv4Header);
Ipv4Address source_address = ipv4Header.GetSource ();
Ipv4Address dest_address = ipv4Header.GetDestination ();
uint8_t protocol = ipv4Header.GetProtocol ();
uint16_t sourcePort = 0;
uint16_t destPort = 0;
if (protocol == UdpL4Protocol::PROT_NUMBER)
{
UdpHeader udpHeader;
C_Packet->RemoveHeader (udpHeader);
sourcePort = udpHeader.GetSourcePort ();
destPort = udpHeader.GetDestinationPort ();
}
else if (protocol == TcpL4Protocol::PROT_NUMBER)
{
TcpHeader tcpHeader;
C_Packet->RemoveHeader (tcpHeader);
sourcePort = tcpHeader.GetSourcePort ();
destPort = tcpHeader.GetDestinationPort ();
}
else
{
NS_LOG_INFO ("\t\t\tUnknown protocol: " << protocol);
return 0;
return 0;
}
NS_LOG_INFO ("Classifing packet: src_addr=" << source_address << " dst_addr="
<< dest_address << " src_port=" << sourcePort << " dst_port="
<< destPort << " proto=" << (uint16_t) protocol);
//now it is possible to classify the packet!
std::vector< Ptr<RadioBearerInstance> >::iterator it;
for (it = m_downlinkGbrBearersContainer->begin (); it != m_downlinkGbrBearersContainer->end (); it++)
{
NS_LOG_INFO ("Check for downlinkGbrBearersContainer");
Ptr<RadioBearerInstance> bearer = (*it);
if (bearer->GetIpcsClassifierRecord ()->CheckMatch (source_address, dest_address, sourcePort, destPort, protocol))
{
return bearer;
}
}
for (it = m_downlinkNgbrBearersContainer->begin (); it != m_downlinkNgbrBearersContainer->end (); it++)
{
NS_LOG_INFO ("Check for downlinkNGbrBearersContainer");
Ptr<RadioBearerInstance> bearer = (*it);
if (bearer->GetIpcsClassifierRecord ()->CheckMatch (source_address, dest_address, sourcePort, destPort, protocol))
{
return bearer;
}
}
for (it = m_uplinkGbrBearersContainer->begin (); it != m_uplinkGbrBearersContainer->end (); it++)
{
NS_LOG_INFO ("Check for ullinkGbrBearersContainer");
Ptr<RadioBearerInstance> bearer = (*it);
if (bearer->GetIpcsClassifierRecord ()->CheckMatch (source_address, dest_address, sourcePort, destPort, protocol))
{
return bearer;
}
}
for (it = m_uplinkNgbrBearersContainer->begin (); it != m_uplinkNgbrBearersContainer->end (); it++)
{
NS_LOG_INFO ("Check for ullinkNgbrBearersContainer");
Ptr<RadioBearerInstance> bearer = (*it);
if (bearer->GetIpcsClassifierRecord ()->CheckMatch (source_address, dest_address, sourcePort, destPort, protocol))
{
return bearer;
}
}
NS_LOG_INFO ("\t\t\tError during the packet classification");
return 0;
}
Ptr<RadioBearerInstance>
RrcEntity::GetDefaultBearer (void)
{
NS_LOG_FUNCTION (this);
return m_defaultBearer;
}
} // namespace ns3

133
src/devices/lte/model/rrc-entity.h

@ -0,0 +1,133 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Giuseppe Piro <g.piro@poliba.it>
*/
#ifndef RRC_ENTITY_H
#define RRC_ENTITY_H
#include "ns3/object.h"
#include <list>
#include "radio-bearer-instance.h"
#include <vector>
namespace ns3 {
class IpcsClassifierRecord;
class BearerManager;
class Bearer;
/**
* \brief This class implements the RRC entity
*/
class RrcEntity : public Object
{
public:
static TypeId GetTypeId (void);
RrcEntity (void);
virtual ~RrcEntity (void);
/**
* \brief A cointainer of bearer with the same QoS requirements
*/
typedef std::vector< Ptr<RadioBearerInstance> > BearersContainer;
/**
* \brief Creates all bearer containers for this node
*/
void CreateBearersContainer (void);
/**
* \brief Get all GBR downlink bearers of this node
* \return a pointer to the BearersContainer of downlink GBR bearers
*/
BearersContainer* GetDownlinkGbrBearers (void) const;
/**
* \brief Get all NGBR downlink bearers of this node
* \return a pointer to the BearersContainer of downlink NGBR bearers
*/
BearersContainer* GetDownlinkNgbrBearers (void) const;
/**
* \brief Get all GBR uplink bearers of this node
* \return a pointer to the BearersContainer of uplink GBR bearers
*/
BearersContainer* GetUplinkGbrBearers (void) const;
/**
* \brief Get all NGBR uplink bearers of this node
* \return a pointer to the BearersContainer of uplink NGBR bearers
*/
BearersContainer* GetUplinkNgbrBearers (void) const;
/**
* \brief Add a bearer
* \param bearer tyhe bearer to be added
*/
void AddDownlinkGbrBearer (Ptr<RadioBearerInstance> bearer);
/**
* \brief Add a bearer
* \param bearer tyhe bearer to be added
*/
void AddDownlinkNgbrBearer (Ptr<RadioBearerInstance> bearer);
/**
* \brief Add a bearer
* \param bearer tyhe bearer to be added
*/
void AddUplinkGbrBearer (Ptr<RadioBearerInstance> bearer);
/**
* \brief Add a bearer
* \param bearer tyhe bearer to be added
*/
void AddUplinkNgbrBearer (Ptr<RadioBearerInstance> bearer);
/**
* \brief Classify an incoming packet into a proper bearer
* \param p the packet to classify
* \return a pointer to the selected bearer
*/
Ptr<RadioBearerInstance> Classify (Ptr<Packet> p) const;
/**
* \brief Get a default bearer
* \return a pointer to the defoult bearer
*/
Ptr<RadioBearerInstance> GetDefaultBearer (void);
private:
BearersContainer* m_downlinkGbrBearersContainer;
BearersContainer* m_downlinkNgbrBearersContainer;
BearersContainer* m_uplinkGbrBearersContainer;
BearersContainer* m_uplinkNgbrBearersContainer;
Ptr<RadioBearerInstance> m_defaultBearer;
};
} // namespace ns3
#endif /* RRC_ENTITY_H */

89
src/devices/lte/model/shadowing-loss-model.cc

@ -0,0 +1,89 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Giuseppe Piro <g.piro@poliba.it>
*/
#include <ns3/log.h>
#include "shadowing-loss-model.h"
NS_LOG_COMPONENT_DEFINE ("ShadowingLossModel");
namespace ns3 {
NS_OBJECT_ENSURE_REGISTERED (ShadowingLossModel);
ShadowingLossModel::ShadowingLossModel ()
{
m_randVariable = new LogNormalVariable (.0, 8.);
SetValue (m_randVariable->GetValue ());
SetLastUpdate ();
SetSamplingPeriod (0.5); // defauld value
}
ShadowingLossModel::ShadowingLossModel (double mu, double sigma, double samplingPeriod)
{
m_randVariable = new LogNormalVariable (mu, sigma);
SetValue (m_randVariable->GetValue ());
SetLastUpdate ();
SetSamplingPeriod (samplingPeriod); // defauld value
}
TypeId
ShadowingLossModel::GetTypeId (void)
{
static TypeId tid = TypeId ("ns3::ShadowingLossModel")
.SetParent<DiscreteTimeLossModel> ()
.AddConstructor<ShadowingLossModel> ()
;
return tid;
}
ShadowingLossModel::~ShadowingLossModel ()
{
}
void
ShadowingLossModel::SetValue (double sh)
{
NS_LOG_FUNCTION (this << sh);
m_shadowingValue = sh;
}
double
ShadowingLossModel::GetValue (void)
{
NS_LOG_FUNCTION (this);
if (NeedForUpdate ())
{
double sh = m_randVariable->GetValue ();
SetValue (sh);
SetLastUpdate ();
}
return 0; // m_shadowingValue; XXX: LogNormalVariable doeas not work correctly
}
} // namespace ns3

71
src/devices/lte/model/shadowing-loss-model.h

@ -0,0 +1,71 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Giuseppe Piro <g.piro@poliba.it>
*/
#ifndef SHADOWING_LOSS_MODEL_H
#define SHADOWING_LOSS_MODEL_H
#include "loss-model.h"
#include <ns3/random-variable.h>
namespace ns3 {
/**
* \brief This class models the propagation loss model due to the shadowing
*/
class ShadowingLossModel : public DiscreteTimeLossModel
{
public:
ShadowingLossModel ();
/**
* \param mu mu parameter of the lognormal distribution
* \param sigma sigma parameter of the lognormal distribution
* \param samplingPeriod the interval every time the model should be updated
*/
ShadowingLossModel (double mu, double sigma, double samplingPeriod);
virtual ~ShadowingLossModel ();
static TypeId GetTypeId (void);
/**
* Set the value of the shadowing loss model, expressed in dB
* \param sh the shadowing loss value
*/
void SetValue (double sh);
/**
* Get the value of the shadowing loss model, expressed in dB
* \return the value of the shadowing loss model
*/
double GetValue (void);
private:
LogNormalVariable* m_randVariable;
double m_shadowingValue;
};
}
#endif /* SHADOWING_LOSS_MODEL_H */

148
src/devices/lte/model/simple-packet-scheduler.cc

@ -0,0 +1,148 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Giuseppe Piro <g.piro@poliba.it>
*/
#include <ns3/log.h>
#include <ns3/pointer.h>
#include "ue-net-device.h"
#include "enb-net-device.h"
#include "simple-packet-scheduler.h"
#include "enb-net-device.h"
#include "rlc-entity.h"
#include "rrc-entity.h"
#include "lte-mac-header.h"
#include "ns3/mac48-address.h"
#include "enb-mac-entity.h"
#include "ue-manager.h"
#include "ue-record.h"
#include "amc-module.h"
NS_LOG_COMPONENT_DEFINE ("SimplePacketScheduler");
namespace ns3 {
NS_OBJECT_ENSURE_REGISTERED (SimplePacketScheduler);
SimplePacketScheduler::SimplePacketScheduler ()
{
NS_LOG_FUNCTION (this);
SetDevice (0);
}
SimplePacketScheduler::SimplePacketScheduler (Ptr<EnbNetDevice> enb)
{
NS_LOG_FUNCTION (this << enb);
SetDevice (enb);
}
TypeId
SimplePacketScheduler::GetTypeId (void)
{
static TypeId tid = TypeId ("ns3::SimplePacketScheduler")
.SetParent<PacketScheduler> ()
.AddConstructor<SimplePacketScheduler> ()
;
return tid;
}
SimplePacketScheduler::~SimplePacketScheduler ()
{
NS_LOG_FUNCTION (this);
}
void
SimplePacketScheduler::DoRunPacketScheduler (void)
{
NS_LOG_FUNCTION (this);
Ptr<EnbNetDevice> enb = GetMacEntity ()->GetDevice ()->GetObject<EnbNetDevice> ();
Ptr<PacketBurst> pb = CreateObject<PacketBurst> ();
PdcchMapIdealControlMessage* msg = new PdcchMapIdealControlMessage ();
//This scheduler takes one packet from each bearer
std::vector< Ptr<RadioBearerInstance> >::iterator it;
//default bearer
if (!enb->GetRrcEntity ()->GetDefaultBearer ()->GetQueue ()->IsEmpty ())
{
Ptr<Packet> p = enb->GetRrcEntity ()->GetDefaultBearer ()->GetRlcEntity ()->Dequeue ();
pb->AddPacket (p);
}
// GBR bearers
for (it = enb->GetRrcEntity ()->GetDownlinkGbrBearers ()->begin ();
it != enb->GetRrcEntity ()->GetDownlinkGbrBearers ()->end (); it++)
{
if ((*it)->GetQueue ()->IsEmpty ())
{
// Get the first packet form the queue.
Ptr<Packet> p = enb->GetRrcEntity ()->GetDownlinkNgbrBearers ()->at(0)->GetRlcEntity ()->Dequeue ();
pb->AddPacket (p);
}
}
// NGBR bearers
for (it = enb->GetRrcEntity ()->GetDownlinkNgbrBearers ()->begin ();
it != enb->GetRrcEntity ()->GetDownlinkNgbrBearers ()->end (); it++)
{
if ((*it)->GetQueue ()->IsEmpty ())
{
// Get the first packet form the queue.
Ptr<Packet> p = enb->GetRrcEntity ()->GetDownlinkNgbrBearers ()->at(0)->GetRlcEntity ()->Dequeue ();
pb->AddPacket (p);
}
}
if (pb->GetNPackets () == 0)
{
// The eNB Sends a virtual packet in order to allow UEs to compute SINR
Ptr<PacketBurst> pb = CreateObject<PacketBurst> ();
Ptr<Packet> p = Create<Packet> (1);
Mac48Address from = Mac48Address::ConvertFrom (enb->GetAddress ());
Mac48Address to = Mac48Address::ConvertFrom (enb->GetAddress ());
LteMacHeader header;
header.SetSource (from);
header.SetDestination (to);
p->AddHeader (header);
pb->AddPacket (p);
}
enb->SetPacketToSend (pb);
GetMacEntity ()->GetObject<EnbMacEntity> ()->SendPdcchMapIdealControlMessage (msg);
enb->StartTransmission ();
}
} // namespace ns3

63
src/devices/lte/model/simple-packet-scheduler.h

@ -0,0 +1,63 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Giuseppe Piro <g.piro@poliba.it>
*/
#ifndef SIMPLE_PACKET_SCHEDULER_H
#define SIMPLE_PACKET_SCHEDULER_H
#include <ns3/nstime.h>
#include <ns3/object.h>
#include <list>
#include <ns3/ptr.h>
#include "packet-scheduler.h"
namespace ns3 {
/**
* This class implements a simple packet scheduler
*/
class SimplePacketScheduler : public PacketScheduler
{
public:
SimplePacketScheduler ();
/**
* \brief Create a simple packet scheduler
* \param enb the enb where the packet scheduler works
*/
SimplePacketScheduler (Ptr<EnbNetDevice> enb);
virtual ~SimplePacketScheduler ();
static TypeId GetTypeId (void);
virtual void DoRunPacketScheduler (void);
private:
};
}
#endif /* SIMPLE_PACKET_SCHEDULER_H */

138
src/devices/lte/model/ue-lte-spectrum-phy.cc

@ -0,0 +1,138 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Giuseppe Piro <g.piro@poliba.it>
*/
#include <ns3/waveform-generator.h>
#include <ns3/object-factory.h>
#include <ns3/log.h>
#include <math.h>
#include <ns3/simulator.h>
#include <ns3/trace-source-accessor.h>
#include "ns3/spectrum-error-model.h"
#include "lte-spectrum-phy.h"
#include "lte-net-device.h"
#include "ue-lte-spectrum-phy.h"
#include "lte-spectrum-value-helper.h"
#include "ue-net-device.h"
#include "ue-phy.h"
NS_LOG_COMPONENT_DEFINE ("UeLteSpectrumPhy");
namespace ns3 {
NS_OBJECT_ENSURE_REGISTERED (UeLteSpectrumPhy);
UeLteSpectrumPhy::UeLteSpectrumPhy ()
{
SetMobility (0);
SetDevice (0);
SetChannel (0);
SetState (LteSpectrumPhy::IDLE);
//GetSpectrumInterference ()->SetErrorModel (CreateObject<LteSpectrumErrorModel> ());
LteSpectrumValueHelper psdHelper;
Ptr<SpectrumValue> noisePsd = psdHelper.CreateDownlinkNoisePowerSpectralDensity ();
SetNoisePowerSpectralDensity (noisePsd);
}
UeLteSpectrumPhy::~UeLteSpectrumPhy ()
{
}
TypeId
UeLteSpectrumPhy::GetTypeId (void)
{
static TypeId tid = TypeId ("ns3::UeLteSpectrumPhy")
.SetParent<LteSpectrumPhy> ()
.AddConstructor<UeLteSpectrumPhy> ()
;
return tid;
}
void
UeLteSpectrumPhy::CalcSinrValues (Ptr <const SpectrumValue> rxPsd, Ptr <const SpectrumValue> noise)
{
/*
* TO DO:
* Compute the SINR of the incoming signal, using the rxPsd and the Noise Psd.
* Transfer this value to the device that will compute the CQI value.
*
* the UE receives the signal from the eNB. It computes the SINR and tranfers
* it to the UeNetDevice. The UeNetDevice, receiving SINR values, uses the AMC module to convert
* SINR to CQI. Then, it will send CQI feedback to the eNB.
*
*/
NS_LOG_FUNCTION (this << *rxPsd << *noise);
std::vector<double> sinr, rx, n;
for (Values::const_iterator it = rxPsd->ConstValuesBegin ();
it != rxPsd->ConstValuesEnd (); it++ )
{
double power; // power transmission for the current sub channel [dB]
if ((*it) != 0.)
{
power = (*it);
power = 10 * log10 (180000. * power);
}
else
{
power = 0.;
}
rx.push_back (power);
}
for (Values::const_iterator it = noise->ConstValuesBegin ();
it != noise->ConstValuesEnd (); it++ )
{
double noise = (*it);
noise = 10 * log10 (180000. * noise);
n.push_back (noise);
}
// compute sinr
int subChannels = rx.size ();
NS_LOG_INFO (this << "sinr: ");
for (int i = 0; i < subChannels; i++)
{
if (rx.at (i) != 0)
{
double sinr_ = rx.at (i) - n.at (i);
sinr.push_back (sinr_);
NS_LOG_INFO (this << rx.at (i) << n.at (i) << sinr_);
}
}
// forward computed SINRs to the device that will use the AMC Module to compute CQI feedbacks
Ptr<UeLtePhy> phy = GetDevice ()->GetObject<UeNetDevice> ()->GetPhy ()->GetObject<UeLtePhy> ();
phy->CreateCqiFeedbacks (sinr);
}
} // namespace ns3

56
src/devices/lte/model/ue-lte-spectrum-phy.h

@ -0,0 +1,56 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Giuseppe Piro <g.piro@poliba.it>
*/
#ifndef UE_LTE_SPECTRUM_PHY_H
#define UE_LTE_SPECTRUM_PHY_H
#include "lte-spectrum-phy.h"
namespace ns3 {
class LteNetDevice;
class EnbNetDevice;
/**
* The UeLteSpectrumPhy models the UL/DL physical layer for the UE
*/
class UeLteSpectrumPhy : public LteSpectrumPhy
{
public:
UeLteSpectrumPhy ();
virtual ~UeLteSpectrumPhy ();
static TypeId GetTypeId (void);
void CalcSinrValues (Ptr <const SpectrumValue> rxPsd, Ptr <const SpectrumValue> noise);
private:
};
}
#endif /* UE_LTE_SPECTRUM_PHY_H */

88
src/devices/lte/model/ue-mac-entity.cc

@ -0,0 +1,88 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Giuseppe Piro <g.piro@poliba.it>
*/
#include "ue-mac-entity.h"
#include <ns3/log.h>
#include <ns3/pointer.h>
#include <ns3/packet.h>
#include "packet-scheduler.h"
#include "amc-module.h"
#include "ideal-control-messages.h"
#include "lte-net-device.h"
#include "ue-net-device.h"
#include "enb-net-device.h"
#include "ue-phy.h"
NS_LOG_COMPONENT_DEFINE ("UeMacEntity");
namespace ns3 {
NS_OBJECT_ENSURE_REGISTERED (UeMacEntity);
TypeId UeMacEntity::GetTypeId (void)
{
static TypeId tid = TypeId ("ns3::UeMacEntity")
.SetParent<Object> ();
return tid;
}
UeMacEntity::UeMacEntity ()
{
SetAmcModule (CreateObject<AmcModule> ());
}
UeMacEntity::~UeMacEntity ()
{
}
CqiIdealControlMessage*
UeMacEntity::CreateCqiFeedbacks (std::vector<double> sinr)
{
NS_LOG_FUNCTION (this);
Ptr<UeNetDevice> thisDevice = GetDevice ()->GetObject<UeNetDevice> ();
Ptr<EnbNetDevice> remoteDevice = thisDevice->GetTargetEnb ();
Ptr<UeLtePhy> phy = thisDevice->GetPhy ()->GetObject<UeLtePhy> ();
Ptr<AmcModule> amc = GetAmcModule ();
std::vector<int> cqi = amc->CreateCqiFeedbacks (sinr);
// CREATE CqiIdealControlMessage
CqiIdealControlMessage* msg = new CqiIdealControlMessage ();
msg->SetSourceDevice (thisDevice);
msg->SetDestinationDevice (remoteDevice);
int nbSubChannels = cqi.size ();
for (int i = 0; i < nbSubChannels; i++)
{
msg->AddNewRecord (phy->GetDownlinkSubChannels ().at (i), cqi.at (i));
}
return msg;
}
} // namespace ns3

58
src/devices/lte/model/ue-mac-entity.h

@ -0,0 +1,58 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Giuseppe Piro <g.piro@poliba.it>
*/
#ifndef UE_MAC_ENTITY_H
#define UE_MAC_ENTITY_H
#include "ns3/object.h"
#include <list>
#include <vector>
#include "mac-entity.h"
namespace ns3 {
class CqiIdealControlMessage;
/**
* This class implements the MAC layer of the UE device
*/
class UeMacEntity : public MacEntity
{
public:
static TypeId GetTypeId (void);
UeMacEntity (void);
virtual ~UeMacEntity (void);
/**
* \brief Create CQI feedbacks from SINR values. SINR values are
* computed at the physical layer when is received a signal from the eNB
* \param sinr list of SINR values
*/
CqiIdealControlMessage* CreateCqiFeedbacks (std::vector<double> sinr);
private:
};
}
#endif /* UE_MAC_ENTITY_H */

174
src/devices/lte/model/ue-manager.cc

@ -0,0 +1,174 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Giuseppe Piro <g.piro@poliba.it>
*/
#include <stdint.h>
#include "ue-manager.h"
#include "ns3/log.h"
#include "ue-net-device.h"
#include "enb-net-device.h"
NS_LOG_COMPONENT_DEFINE ("UeManager");
namespace ns3 {
NS_OBJECT_ENSURE_REGISTERED ( UeManager);
UeManager::UeManager (void)
{
NS_LOG_FUNCTION (this);
m_ueRecords = new std::vector<Ptr<UeRecord> > ();
}
UeManager::~UeManager (void)
{
m_ueRecords = 0;
}
void
UeManager::CreateUeRecord (Ptr<UeNetDevice> ue, Ptr<EnbNetDevice> enb)
{
NS_LOG_FUNCTION (this << ue << enb);
Ptr<UeRecord> ueRecord = CreateObject<UeRecord> (ue, enb);
m_ueRecords->push_back (ueRecord);
}
Ptr<UeRecord>
UeManager::GetUeRecord (Ptr<UeNetDevice> ue)
{
NS_LOG_FUNCTION (this << ue);
for (std::vector<Ptr<UeRecord> >::iterator iter = m_ueRecords->begin (); iter != m_ueRecords->end (); ++iter)
{
if ((*iter)->GetUe ()->GetAddress () == ue->GetAddress ())
{
return *iter;
}
}
NS_LOG_DEBUG ("GetUeRecord: UeRecord not found!");
return 0;
}
Ptr<UeRecord>
UeManager::GetUeRecord (const Mac48Address macAddress)
{
NS_LOG_FUNCTION (this);
for (std::vector<Ptr<UeRecord> >::iterator iter = m_ueRecords->begin (); iter != m_ueRecords->end (); ++iter)
{
NS_LOG_LOGIC ("find " << macAddress << ", here:" << (*iter)->GetUe ()->GetAddress ());
if ((*iter)->GetUe ()->GetAddress () == macAddress)
{
return *iter;
}
}
NS_LOG_DEBUG ("GetUeRecord: UeRecord not found!");
return 0;
}
bool
UeManager::IsRegistered (Ptr<UeNetDevice> ue) const
{
NS_LOG_FUNCTION (this << ue);
for (std::vector<Ptr<UeRecord> >::iterator iter = m_ueRecords->begin (); iter != m_ueRecords->end (); ++iter)
{
if ((*iter)->GetUe ()->GetAddress () == ue->GetAddress ())
{
return true;
}
}
return false;
}
bool
UeManager::IsRegistered (const Mac48Address &macAddress) const
{
NS_LOG_FUNCTION (this);
/*
for (std::vector<UeRecord*>::iterator iter = m_ueRecords->begin (); iter != m_ueRecords->end (); ++iter)
{
if ((*iter)->GetUe ()->GetAddress () == macAddress)
{
return true;
}
}
*/
return false;
}
void
UeManager::DeleteUeRecord (Ptr<UeNetDevice> ue)
{
NS_LOG_FUNCTION (this << ue);
for (std::vector<Ptr<UeRecord> >::iterator iter = m_ueRecords->begin (); iter != m_ueRecords->end (); ++iter)
{
if ((*iter)->GetUe ()->GetAddress () == ue->GetAddress ())
{
m_ueRecords->erase (iter);
return;
}
}
}
void
UeManager::DeleteUeRecord (const Mac48Address &macAddress)
{
NS_LOG_FUNCTION (this);
/*
for (std::vector<UeRecord*>::iterator iter = m_ueRecords->begin (); iter != m_ueRecords->end (); ++iter)
{
if ((*iter)->GetUe ()->GetAddress () == macAddress)
{
m_ueRecords->erase (iter);
return;
}
}
*/
}
std::vector<Ptr<UeRecord> >*
UeManager::GetUeRecords (void)
{
NS_LOG_FUNCTION (this);
return m_ueRecords;
}
uint32_t
UeManager::GetNRegisteredUes (void) const
{
NS_LOG_FUNCTION (this);
return m_ueRecords->size ();
}
} // namespace ns3

108
src/devices/lte/model/ue-manager.h

@ -0,0 +1,108 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Giuseppe Piro <g.piro@poliba.it>
*/
#ifndef UE_MANAGER_H
#define UE_MANAGER_H
#include <stdint.h>
#include "ue-record.h"
namespace ns3 {
class UeNetDevice;
class EnbNetDevice;
/**
* \brief this class allow the eNodeb to manage in a very simple way all registered UE.
* In particular, to each registered UE, a new UeRecord is created.
* \see UeRecord
*/
class UeManager : public Object
{
public:
UeManager (void);
~UeManager (void);
/**
* \brief Create a new UE Record to store into the eNB
* \param ue the pointer of the UE device
* \param enb the pointer of the enb device
*/
void CreateUeRecord (Ptr<UeNetDevice> ue, Ptr<EnbNetDevice> enb);
/**
* \brief Get a UE Record stored into the eNB
* \param ue the pointer of the UE device
* \return a pointer ot the UE record
*/
Ptr<UeRecord> GetUeRecord (Ptr<UeNetDevice> ue);
/**
* \brief Get a UE Record stored into the eNB
* \param macAddress the mac address of the UE device
* \return a pointer ot the UE record
*/
Ptr<UeRecord> GetUeRecord (const Mac48Address macAddress);
/**
* \brief Verify if the UE is registered into this eNB
* \param ue the pointer of the UE device
* \return true if the UE is registered, false otherwise
*/
bool IsRegistered (Ptr<UeNetDevice> ue) const;
/**
* \brief Verify if the UE is registered into this eNB
* \param macAddress the mac address of the UE device
* \return true if the UE is registered, false otherwise
*/
bool IsRegistered (const Mac48Address &macAddress) const;
/**
* \brief Delete an UE Record stored into the eNB
* \param ue the pointer of the ue device
*/
void DeleteUeRecord (Ptr<UeNetDevice> ue);
/**
* \brief Delete an UE Record stored into the eNB
* \param macAddress the mac address of the UE device
*/
void DeleteUeRecord (const Mac48Address &macAddress);
/**
* \brief Get a list of UE records
* \return a list of UE records
*/
std::vector< Ptr<UeRecord> >* GetUeRecords (void);
/**
* \brief Get the number of registered UE
* \return the number of registered UE
*/
uint32_t GetNRegisteredUes (void) const;
private:
std::vector< Ptr<UeRecord> > *m_ueRecords;
};
} // namespace ns3
#endif /* UE_MANAGER_H */

223
src/devices/lte/model/ue-net-device.cc

@ -0,0 +1,223 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Giuseppe Piro <g.piro@poliba.it>
*/
#include "ns3/llc-snap-header.h"
#include "ns3/simulator.h"
#include "ns3/callback.h"
#include "ns3/node.h"
#include "ns3/packet.h"
#include "lte-net-device.h"
#include "ns3/packet-burst.h"
#include "ns3/uinteger.h"
#include "ns3/trace-source-accessor.h"
#include "ns3/pointer.h"
#include "ns3/enum.h"
#include "radio-bearer-instance.h"
#include "ue-record.h"
#include "ue-manager.h"
#include "enb-net-device.h"
#include "ue-net-device.h"
#include "ue-mac-entity.h"
#include "rlc-entity.h"
#include "rrc-entity.h"
#include "lte-mac-header.h"
#include "ns3/ipv4-header.h"
#include "ns3/ipv4.h"
#include "amc-module.h"
// #include "ideal-control-messages.h"
NS_LOG_COMPONENT_DEFINE ("UeNetDevice");
namespace ns3 {
NS_OBJECT_ENSURE_REGISTERED ( UeNetDevice);
TypeId UeNetDevice::GetTypeId (void)
{
static TypeId
tid =
TypeId ("ns3::UeNetDevice")
.SetParent<LteNetDevice> ();
return tid;
}
UeNetDevice::UeNetDevice (void)
{
NS_LOG_FUNCTION (this);
InitUeNetDevice ();
}
UeNetDevice::UeNetDevice (Ptr<Node> node, Ptr<LtePhy> phy)
{
NS_LOG_FUNCTION (this);
InitUeNetDevice ();
SetNode (node);
SetPhy (phy);
}
UeNetDevice::UeNetDevice (Ptr<Node> node, Ptr<LtePhy> phy, Ptr<EnbNetDevice> targetEnb)
{
NS_LOG_FUNCTION (this << node << phy << targetEnb);
InitUeNetDevice ();
SetNode (node);
SetPhy (phy);
m_targetEnb = targetEnb;
}
UeNetDevice::~UeNetDevice (void)
{
NS_LOG_FUNCTION (this);
m_macEntity = 0;
}
void
UeNetDevice::InitUeNetDevice (void)
{
NS_LOG_FUNCTION (this);
m_targetEnb = 0;
SetNode (0);
SetPhy (0);
m_macEntity = CreateObject<UeMacEntity> ();
m_macEntity->SetDevice (this);
SetRrcEntity (CreateObject<RrcEntity> ());
}
void
UeNetDevice::SetMacEntity (Ptr<UeMacEntity> m)
{
NS_LOG_FUNCTION (this);
m_macEntity = m;
}
Ptr<UeMacEntity>
UeNetDevice::GetMacEntity (void)
{
NS_LOG_FUNCTION (this);
return m_macEntity;
}
void
UeNetDevice::DoDispose (void)
{
NS_LOG_FUNCTION (this);
LteNetDevice::DoDispose ();
}
void
UeNetDevice::Start (void)
{
NS_LOG_FUNCTION (this);
}
void
UeNetDevice::Stop (void)
{
NS_LOG_FUNCTION (this);
}
void
UeNetDevice::SetTargetEnb (Ptr<EnbNetDevice> enb)
{
NS_LOG_FUNCTION (this << enb);
m_targetEnb = enb;
}
Ptr<EnbNetDevice>
UeNetDevice::GetTargetEnb (void)
{
NS_LOG_FUNCTION (this);
return m_targetEnb;
}
bool
UeNetDevice::DoSend (Ptr<Packet> packet, const Mac48Address& source,
const Mac48Address& dest, uint16_t protocolNumber)
{
NS_LOG_FUNCTION (this);
// Ptr<RadioBearerInstance> bearer = GetIpClassifier ()->Classify (packet);
// return Enqueue (packet, bearer);
/*
* XXX: the uplink is not implemented yet.
* For now the UE send the packet as soon as
* it arrives from the upper layer
*
* For any question, please contact me at g.piro@poliba.it
*/
Ptr<PacketBurst> pb = CreateObject<PacketBurst> ();
pb->AddPacket (packet);
return SendPacket (pb);
}
void
UeNetDevice::DoReceive (Ptr<Packet> p)
{
NS_LOG_FUNCTION (this << p);
Ptr<Packet> packet = p->Copy ();
LteMacHeader header;
packet->RemoveHeader (header);
NS_LOG_LOGIC ("packet " << header.GetSource () << " --> " << header.GetDestination () <<
" (here: " << Mac48Address::ConvertFrom (GetAddress ()) << ")");
if (header.GetDestination () == GetAddress () || header.GetDestination () == GetBroadcast ())
{
LlcSnapHeader llcHdr;
packet->RemoveHeader (llcHdr);
NS_LOG_FUNCTION (this << llcHdr);
ForwardUp (p->Copy ());
}
else
{
// not for me
}
}
void
UeNetDevice::StartTransmission (void)
{
NS_LOG_FUNCTION (this);
GetPhy ()->SendPacket (GetPacketToSend ());
}
bool
UeNetDevice::SendPacket (Ptr<PacketBurst> p)
{
return GetPhy ()->GetUplinkSpectrumPhy ()->StartTx (p);
}
} // namespace ns3

128
src/devices/lte/model/ue-net-device.h

@ -0,0 +1,128 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Giuseppe Piro <g.piro@poliba.it>
*/
#ifndef UE_NET_DEVICE_H
#define UE_NET_DEVICE_H
#include "lte-net-device.h"
#include "ns3/event-id.h"
#include "ns3/mac48-address.h"
#include "ns3/traced-callback.h"
#include "ns3/nstime.h"
#include "ns3/log.h"
#include "lte-phy.h"
#include "lte-phy.h"
namespace ns3 {
class Packet;
class PacketBurst;
class Node;
class LtePhy;
class EnbNetDevice;
class UeMacEntity;
/**
* The UeNetDevice class implements the UE net device
*/
class UeNetDevice : public LteNetDevice
{
public:
static TypeId GetTypeId (void);
UeNetDevice (void);
/**
* \brief Create an UE net device
* \param node
* \param phy
*/
UeNetDevice (Ptr<Node> node, Ptr<LtePhy> phy);
/**
* \brief Create an UE net device
* \param node
* \param phy
* \param targetEnb the enb where the UE is registered
*/
UeNetDevice (Ptr<Node> node, Ptr<LtePhy> phy, Ptr<EnbNetDevice> targetEnb);
virtual ~UeNetDevice (void);
/**
* \brief Set the MAC entity
* \param m the MAC entity
*/
void SetMacEntity (Ptr<UeMacEntity> m);
/**
* \brief Get the MAC entity
* \return the pointer to the MAC entity
*/
Ptr<UeMacEntity> GetMacEntity (void);
void DoDispose (void);
/**
* \brief Initialize the UE
*/
void InitUeNetDevice (void);
void Start (void);
void Stop (void);
/**
* \brief Set the targer eNB where the UE is registered
* \param enb
*/
void SetTargetEnb (Ptr<EnbNetDevice> enb);
/**
* \brief Get the targer eNB where the UE is registered
* \return the pointer to the enb
*/
Ptr<EnbNetDevice> GetTargetEnb (void);
/**
* \brief Start packet transmission.
* This functipon will called when a PDCCH messages is received
* According to the allocated resources in the uplink
* the UE create a packet burst and send it to the phy layer
*/
void StartTransmission (void);
bool SendPacket (Ptr<PacketBurst> p);
private:
bool DoSend (Ptr<Packet> packet,
const Mac48Address& source,
const Mac48Address& dest,
uint16_t protocolNumber);
void DoReceive (Ptr<Packet> p);
Ptr<EnbNetDevice> m_targetEnb;
Ptr<UeMacEntity> m_macEntity;
};
} // namespace ns3
#endif /* UE_NET_DEVICE_H */

224
src/devices/lte/model/ue-phy.cc

@ -0,0 +1,224 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Giuseppe Piro <g.piro@poliba.it>
*/
#include <ns3/waveform-generator.h>
#include <ns3/object-factory.h>
#include <ns3/log.h>
#include <math.h>
#include <ns3/simulator.h>
#include "ns3/spectrum-error-model.h"
#include "ue-phy.h"
#include "lte-net-device.h"
#include "ue-net-device.h"
#include "enb-net-device.h"
#include "lte-spectrum-value-helper.h"
#include "amc-module.h"
#include "ue-mac-entity.h"
NS_LOG_COMPONENT_DEFINE ("UeLtePhy");
namespace ns3 {
NS_OBJECT_ENSURE_REGISTERED (UeLtePhy);
UeLtePhy::UeLtePhy ()
{
SetDevice (0);
SetDownlinkSpectrumPhy (0);
SetUplinkSpectrumPhy (0);
SetTxPower (43); // XXX
SetTti (0.001);
SetNrFrames (0);
SetNrSubFrames (0);
}
UeLtePhy::UeLtePhy (Ptr<LteNetDevice> d)
{
SetDevice (0);
SetDownlinkSpectrumPhy (0);
SetUplinkSpectrumPhy (0);
SetTxPower (43); // XXX
SetTti (0.001);
SetNrFrames (0);
SetNrSubFrames (0);
}
TypeId
UeLtePhy::GetTypeId (void)
{
static TypeId tid = TypeId ("ns3::UeLtePhy")
.SetParent<Object> ()
.AddConstructor<UeLtePhy> ()
;
return tid;
}
UeLtePhy::~UeLtePhy ()
{
}
bool
UeLtePhy::SendPacket (Ptr<PacketBurst> pb)
{
NS_LOG_FUNCTION (this);
return GetUplinkSpectrumPhy ()->StartTx (pb);
}
void
UeLtePhy::DoSetUplinkSubChannels ()
{
NS_LOG_FUNCTION (this);
/*
* XXX: the uplink scheduler is not implemented yet!
* Now, all uplink sub channels can be used for uplink transmission
*/
SetSubChannelsForTransmission (GetUplinkSubChannels ());
}
void
UeLtePhy::SetSubChannelsForTransmission (std::vector <int> mask)
{
NS_LOG_FUNCTION (this);
m_subChannelsForTransmission = mask;
Ptr<SpectrumValue> txPsd = CreateTxPowerSpectralDensity ();
GetUplinkSpectrumPhy ()->SetTxPowerSpectralDensity (txPsd);
}
void
UeLtePhy::SetSubChannelsForReception (std::vector <int> mask)
{
NS_LOG_FUNCTION (this);
m_subChannelsForReception = mask;
}
std::vector <int>
UeLtePhy::GetSubChannelsForTransmission ()
{
NS_LOG_FUNCTION (this);
return m_subChannelsForTransmission;
}
std::vector <int>
UeLtePhy::GetSubChannelsForReception ()
{
NS_LOG_FUNCTION (this);
return m_subChannelsForReception;
}
Ptr<SpectrumValue>
UeLtePhy::CreateTxPowerSpectralDensity ()
{
NS_LOG_FUNCTION (this);
LteSpectrumValueHelper psdHelper;
Ptr<SpectrumValue> psd = psdHelper.CreateUplinkTxPowerSpectralDensity (GetTxPower (), GetSubChannelsForTransmission ());
return psd;
}
void
UeLtePhy::CreateCqiFeedbacks (std::vector<double> sinr)
{
NS_LOG_FUNCTION (this);
Ptr<UeNetDevice> thisDevice = GetDevice ()->GetObject<UeNetDevice> ();
Ptr<UeMacEntity> mac = thisDevice->GetMacEntity ()->GetObject<UeMacEntity> ();
CqiIdealControlMessage* msg = mac->CreateCqiFeedbacks (sinr);
SendIdealControlMessage (msg);
}
void
UeLtePhy::SendIdealControlMessage (IdealControlMessage* msg)
{
NS_LOG_FUNCTION (this << msg);
Ptr<LtePhy> phy = msg->GetDestinationDevice ()->GetPhy ();
phy->ReceiveIdealControlMessage (msg);
}
void
UeLtePhy::ReceiveIdealControlMessage (IdealControlMessage* msg)
{
NS_LOG_FUNCTION (this << msg);
if (msg->GetMessageType () == IdealControlMessage::ALLOCATION_MAP)
{
PdcchMapIdealControlMessage* msg2 = dynamic_cast<PdcchMapIdealControlMessage*> (msg);
std::vector <int> ulSubChennels;
std::vector <int> dlSubChennels;
// store information about UL and DL sub channel assigned to this device
PdcchMapIdealControlMessage::IdealPdcchMessage* message = msg2->GetMessage ();
for (PdcchMapIdealControlMessage::IdealPdcchMessage::iterator it = message->begin ();
it != message->end (); it++)
{
PdcchMapIdealControlMessage::IdealPdcchRecord record = *it;
if (record.m_ue == GetDevice ())
{
if (record.m_direction == PdcchMapIdealControlMessage::DOWNLINK)
{
dlSubChennels.push_back (record.m_idSubChannel);
}
else
{
ulSubChennels.push_back (record.m_idSubChannel);
}
}
else
{
// not for me!
}
}
// UPDATE ASSIGNED UL and DL sub channels
/*
* XXX: do not update the UL sub channels. Since no uplink packet scheduler
* is implemented yet, ulSubChennels is empty.
*/
// SetSubChannelsForTransmission (ulSubChennels);
SetSubChannelsForReception (dlSubChennels);
}
else
{
// XXX at this time, the UE must receive only Allocation Map messages!
}
}
} // namespace ns3

109
src/devices/lte/model/ue-phy.h

@ -0,0 +1,109 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Giuseppe Piro <g.piro@poliba.it>
*/
#ifndef UE_PHY_H
#define UE_PHY_H
#include "lte-phy.h"
namespace ns3 {
class PacketBurst;
class LteNetDevice;
/**
* The LteSpectrumPhy models the physical layer of LTE
*/
class UeLtePhy : public LtePhy
{
public:
UeLtePhy ();
/**
* \brief Create the physical layer
* \param d the device where the physical layer is attached
*/
UeLtePhy (Ptr<LteNetDevice> d);
virtual ~UeLtePhy ();
static TypeId GetTypeId (void);
/**
* \brief Send the packet to the channel
* \param pb the burst of packet to send
* \return true if
*/
virtual bool SendPacket (Ptr<PacketBurst> pb);
/**
* \brief Create the PSD for the TX
* \return the pointer to the PSD
*/
virtual Ptr<SpectrumValue> CreateTxPowerSpectralDensity ();
/**
* \brief Update available channel for TX
*/
virtual void DoSetUplinkSubChannels ();
/**
* \brief Set a list of sub channels to use in TX
* \param mask a list of sub channels
*/
void SetSubChannelsForTransmission (std::vector <int> mask);
/**
* \brief Get a list of sub channels to use in RX
* \return a list of sub channels
*/
std::vector <int> GetSubChannelsForTransmission (void);
/**
* \brief Get a list of sub channels to use in RX
* \param mask list of sub channels
*/
void SetSubChannelsForReception (std::vector <int> mask);
/**
* \brief Get a list of sub channels to use in RX
* \return a list of sub channels
*/
std::vector <int> GetSubChannelsForReception (void);
/**
* \brief Create CQI feedbacks from SINR values. SINR values are
* computed at the physical layer when is received a signal from the eNB
* \param sinr list of SINR values
*/
void CreateCqiFeedbacks (std::vector<double> sinr);
virtual void SendIdealControlMessage (IdealControlMessage* msg);
virtual void ReceiveIdealControlMessage (IdealControlMessage* msg);
private:
std::vector <int> m_subChannelsForTransmission;
std::vector <int> m_subChannelsForReception;
};
}
#endif /* UE_PHY_H */

96
src/devices/lte/model/ue-record.cc

@ -0,0 +1,96 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Giuseppe Piro <g.piro@poliba.it>
*/
#include "ue-record.h"
NS_LOG_COMPONENT_DEFINE ("UeRecord");
namespace ns3 {
UeRecord::UeRecord (void)
: m_ue (0),
m_enb (0)
{
NS_LOG_FUNCTION (this);
}
UeRecord::~UeRecord (void)
{
}
UeRecord::UeRecord (Ptr<NetDevice> ue, Ptr<NetDevice> enb)
: m_ue (ue),
m_enb (enb)
{
NS_LOG_FUNCTION (this << ue << enb);
}
void
UeRecord::SetUe (Ptr<NetDevice> ue)
{
NS_LOG_FUNCTION (this << ue);
m_ue = ue;
}
Ptr<NetDevice>
UeRecord::GetUe (void)
{
NS_LOG_FUNCTION (this);
return m_ue;
}
void
UeRecord::SetEnb (Ptr<NetDevice> enb)
{
NS_LOG_FUNCTION (this << enb);
m_enb = enb;
}
Ptr<NetDevice>
UeRecord::GetEnb (void)
{
NS_LOG_FUNCTION (this);
return m_enb;
}
void
UeRecord::SetCqiFeedbacks (UeRecord::CqiFeedbacks cqiFeedbacks)
{
NS_LOG_FUNCTION (this);
// XXX: copy all value of the list!
m_cqiFeedbacks = cqiFeedbacks;
}
UeRecord::CqiFeedbacks
UeRecord::GetCqiFeedbacks (void)
{
NS_LOG_FUNCTION (this);
return m_cqiFeedbacks;
}
}
; // namespace ns3

119
src/devices/lte/model/ue-record.h

@ -0,0 +1,119 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Giuseppe Piro <g.piro@poliba.it>
*/
#ifndef UE_RECORD_H_
#define UE_RECORD_H_
#include "ns3/net-device.h"
#include "ns3/object.h"
#include "ns3/log.h"
#include <vector>
#include <stdint.h>
namespace ns3 {
/**
* \brief The UeRecord class is developerd in order to store at the eNodeB
* all information (such as feedback cqi, mac address etc...) of a UE registered
* into that eNodeB. All UE records are managed by the UeManager class
*/
class UeRecord : public Object
{
public:
UeRecord ();
~UeRecord ();
/**
* \brief CqiFeedbacks represents a list of CQI feedbacks
* sent by the UE. The downlink packet scheduler of
* the eNB uses these values to assign accordingly
* radio resources.
*/
struct CqiFeedback
{
/** the sub channel */
int m_subChannelId;
/** the cqi feedback */
int m_cqi;
};
/**
* \brief a list of CQI feedbacks
*/
typedef std::vector<struct CqiFeedback> CqiFeedbacks;
/**
* \brief Creates a ue record of the UE registered into the eNB
* \param ue the pointer of the ue device
* \param enb the pointer of the enb device
*/
UeRecord (Ptr<NetDevice> ue, Ptr<NetDevice> enb);
/**
* \brief Set the UE of the record
* \param ue the pointer of the ue device
*/
void SetUe (Ptr<NetDevice> ue);
/**
* \brief Get the UE of the record
* \returns the pointer of the UE
*/
Ptr<NetDevice> GetUe (void);
/**
* \brief Set the eNB of the record
* \param enb the pointer of the enb device
*/
void SetEnb (Ptr<NetDevice> enb);
/**
* \brief Get the eNB of the record
* \returns the pointer of the eNB
*/
Ptr<NetDevice> GetEnb (void);
/**
* \brief Set CQI feedbacks of the registered UE
* \param cqiFeedbacks a list of CQI feedback
*/
void SetCqiFeedbacks (CqiFeedbacks cqiFeedbacks);
/**
* \brief Get CQI feedbacks of the registered UE
* \returns a list of CQI feedback
*/
CqiFeedbacks GetCqiFeedbacks (void);
private:
Ptr<NetDevice> m_ue;
Ptr<NetDevice> m_enb;
CqiFeedbacks m_cqiFeedbacks;
};
}
; // namespace ns3
#endif /* UE_RECORD_H_ */

123
src/devices/lte/test/lte-bearer-test.cc

@ -0,0 +1,123 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Giuseppe Piro <g.piro@poliba.it>
*/
#include <iostream>
#include <ns3/single-model-spectrum-channel.h>
#include <ns3/log.h>
#include <string>
#include <ns3/spectrum-helper.h>
#include <ns3/lte-helper.h>
#include <ns3/enb-phy.h>
#include <ns3/ue-phy.h>
#include <ns3/packet-burst.h>
#include <ns3/constant-position-mobility-model.h>
#include <ns3/constant-velocity-mobility-model.h>
#include <vector>
#include "ns3/log.h"
#include "ns3/abort.h"
#include "ns3/test.h"
#include "ns3/uinteger.h"
#include <ns3/simulator.h>
#include "ns3/internet-stack-helper.h"
#include "ns3/ipv4-address-helper.h"
#include "ns3/ue-manager.h"
#include "ns3/ue-record.h"
#include "ns3/lte-mac-header.h"
#include "ns3/bearer-qos-parameters.h"
#include "ns3/radio-bearer-instance.h"
using namespace ns3;
/*
* Test for LTE Bearers.
*/
class Ns3LteBearerTestCase : public TestCase
{
public:
Ns3LteBearerTestCase ();
virtual ~Ns3LteBearerTestCase ();
private:
virtual bool DoRun (void);
};
Ns3LteBearerTestCase::Ns3LteBearerTestCase ()
: TestCase ("Test the LTE Bearer.")
{
}
Ns3LteBearerTestCase::~Ns3LteBearerTestCase ()
{
}
bool
Ns3LteBearerTestCase::DoRun (void)
{
bool testResult = false;
// create downlink data radio bearer and its qos parameters
Ptr<RadioBearerInstance> bearer = CreateObject<RadioBearerInstance> ();
bearer->SetBearerDirection (RadioBearerInstance::DIRECTION_TYPE_DL);
bearer->SetBearerType (RadioBearerInstance::BEARER_TYPE_DRB);
Ptr<BearerQosParameters> qos = CreateObject<BearerQosParameters> (1, false, false, 28000., 28000.);
qos->SetBearerQosType (BearerQosParameters::BEARER_TYPE_GBR);
bearer->SetQosParameters (qos);
Ptr<Packet> p = Create<Packet> ();
bearer->Enqueue (p);
if (!bearer->HasPackets ())
{
return true; // the queue should have 1 packet
}
bearer->Dequeue ();
if (bearer->HasPackets ())
{
return true; // the queue should be empty
}
return (testResult);
}
// ==============================================================================
class Ns3LteBearerTestTestSuite : public TestSuite
{
public:
Ns3LteBearerTestTestSuite ();
};
Ns3LteBearerTestTestSuite::Ns3LteBearerTestTestSuite ()
: TestSuite ("lte-bearer", UNIT)
{
AddTestCase (new Ns3LteBearerTestCase);
}
Ns3LteBearerTestTestSuite ns3LteBearerTestTestSuite;

199
src/devices/lte/test/lte-device-test.cc

@ -0,0 +1,199 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Giuseppe Piro <g.piro@poliba.it>
*/
#include <iostream>
#include <ns3/single-model-spectrum-channel.h>
#include <ns3/log.h>
#include <string>
#include <ns3/spectrum-helper.h>
#include <ns3/lte-helper.h>
#include <ns3/enb-phy.h>
#include <ns3/ue-phy.h>
#include <ns3/packet-burst.h>
#include <ns3/constant-position-mobility-model.h>
#include <ns3/constant-velocity-mobility-model.h>
#include <vector>
#include "ns3/log.h"
#include "ns3/abort.h"
#include "ns3/test.h"
#include "ns3/uinteger.h"
#include <ns3/simulator.h>
#include "ns3/internet-stack-helper.h"
#include "ns3/ipv4-address-helper.h"
#include "ns3/ue-manager.h"
#include "ns3/ue-record.h"
#include "ns3/lte-mac-header.h"
using namespace ns3;
/*
* Test the LTE physical layer.
*/
class Ns3LteDeviceTestCase : public TestCase
{
public:
Ns3LteDeviceTestCase ();
virtual ~Ns3LteDeviceTestCase ();
private:
virtual bool DoRun (void);
};
Ns3LteDeviceTestCase::Ns3LteDeviceTestCase ()
: TestCase ("Test the LTE Device.")
{
}
Ns3LteDeviceTestCase::~Ns3LteDeviceTestCase ()
{
}
bool
Ns3LteDeviceTestCase::DoRun (void)
{
bool testResult = false;
LteHelper lte;
lte.EnableLogComponents ();
// CREATE NODE CONTAINER AND CREATE LTE NODES
NodeContainer ueNodes;
NodeContainer enbNodes;
ueNodes.Create (1);
enbNodes.Create (1);
// CREATE DEVICE CONTAINER, INSTALL DEVICE TO NODE
NetDeviceContainer ueDevs, enbDevs;
ueDevs = lte.Install (ueNodes, LteHelper::DEVICE_TYPE_USER_EQUIPMENT);
enbDevs = lte.Install (enbNodes, LteHelper::DEVICE_TYPE_ENODEB);
// INSTALL INTERNET STACKS
InternetStackHelper stack;
stack.Install (ueNodes);
stack.Install (enbNodes);
Ipv4AddressHelper address;
address.SetBase ("10.1.1.0", "255.255.255.0");
Ipv4InterfaceContainer UEinterfaces = address.Assign (ueDevs);
Ipv4InterfaceContainer ENBinterface = address.Assign (enbDevs);
// MANAGE LTE NET DEVICES
Ptr<EnbNetDevice> enb;
enb = enbDevs.Get (0)->GetObject<EnbNetDevice> ();
Ptr<UeNetDevice> ue = ueDevs.Get (0)->GetObject<UeNetDevice> ();
lte.RegisterUeToTheEnb (ue, enb);
// CONFIGURE DL and UL SUB CHANNELS
// Define a list of sub channels for the downlink
std::vector<int> dlSubChannels;
for (int i = 0; i < 25; i++)
{
dlSubChannels.push_back (i);
}
// Define a list of sub channels for the uplink
std::vector<int> ulSubChannels;
for (int i = 50; i < 100; i++)
{
ulSubChannels.push_back (i);
}
enb->GetPhy ()->SetDownlinkSubChannels (dlSubChannels);
enb->GetPhy ()->SetUplinkSubChannels (ulSubChannels);
ue->GetPhy ()->SetDownlinkSubChannels (dlSubChannels);
ue->GetPhy ()->SetUplinkSubChannels (ulSubChannels);
// CONFIGURE MOBILITY
Ptr<ConstantPositionMobilityModel> enbMobility = CreateObject<ConstantPositionMobilityModel> ();
enbMobility->SetPosition (Vector (0.0, 0.0, 0.0));
lte.AddMobility (enb->GetPhy (), enbMobility);
Ptr<ConstantVelocityMobilityModel> ueMobility = CreateObject<ConstantVelocityMobilityModel> ();
ueMobility->SetPosition (Vector (50.0, 50.0, 0.0));
ueMobility->SetVelocity (Vector (50.0, 50.0, 0.0));
lte.AddMobility (ue->GetPhy (), ueMobility);
lte.AddDownlinkChannelRealization (enbMobility, ueMobility, ue->GetPhy ());
// ****** test if the ue is registered with the eNB ******
if (!enb->GetUeManager ()->IsRegistered (ue))
{
return true;
}
// ****** test packet transmission******
Ptr<PacketBurst> pb = Create<PacketBurst> ();
Ptr<Packet> p = Create<Packet> (1);
Mac48Address from = Mac48Address::ConvertFrom (enb->GetAddress ());
Mac48Address to = Mac48Address::ConvertFrom (enb->GetAddress ());
LteMacHeader header;
header.SetSource (from);
header.SetDestination (to);
p->AddHeader (header);
pb->AddPacket (p);
enb->SetPacketToSend (pb);
enb->GetPhy ()->SendPacket (enb->GetPacketToSend ());
Simulator::Stop (Seconds (.01));
Simulator::Run ();
Simulator::Destroy ();
return (testResult);
}
// ==============================================================================
class Ns3LteDeviceTestTestSuite : public TestSuite
{
public:
Ns3LteDeviceTestTestSuite ();
};
Ns3LteDeviceTestTestSuite::Ns3LteDeviceTestTestSuite ()
: TestSuite ("lte-device", UNIT)
{
AddTestCase (new Ns3LteDeviceTestCase);
}
Ns3LteDeviceTestTestSuite ns3LteDeviceTestTestSuite;

189
src/devices/lte/test/lte-phy-test.cc

@ -0,0 +1,189 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Giuseppe Piro <g.piro@poliba.it>
*/
#include <iostream>
#include <ns3/single-model-spectrum-channel.h>
#include <ns3/log.h>
#include <string>
#include <ns3/spectrum-helper.h>
#include <ns3/lte-helper.h>
#include <ns3/enb-phy.h>
#include <ns3/ue-phy.h>
#include <ns3/packet-burst.h>
#include <ns3/constant-position-mobility-model.h>
#include <ns3/constant-velocity-mobility-model.h>
#include <vector>
#include "ns3/log.h"
#include "ns3/abort.h"
#include "ns3/test.h"
#include "ns3/uinteger.h"
#include <ns3/simulator.h>
using namespace ns3;
/*
* Test the LTE physical layer.
*/
class Ns3LtePhyTestCase : public TestCase
{
public:
Ns3LtePhyTestCase ();
virtual ~Ns3LtePhyTestCase ();
private:
virtual bool DoRun (void);
};
Ns3LtePhyTestCase::Ns3LtePhyTestCase ()
: TestCase ("Test the LTE physical layer.")
{
}
Ns3LtePhyTestCase::~Ns3LtePhyTestCase ()
{
}
bool
Ns3LtePhyTestCase::DoRun (void)
{
bool testResult = false;
LteHelper lte;
lte.EnableLogComponents ();
// CREATE NODE CONTAINER AND CREATE LTE NODES
NodeContainer ueNodes;
NodeContainer enbNodes;
ueNodes.Create (1);
enbNodes.Create (1);
// CREATE DEVICE CONTAINER, INSTALL DEVICE TO NODE
NetDeviceContainer ueDevs, enbDevs;
ueDevs = lte.Install (ueNodes, LteHelper::DEVICE_TYPE_USER_EQUIPMENT);
enbDevs = lte.Install (enbNodes, LteHelper::DEVICE_TYPE_ENODEB);
/*
//INSTALL INTERNET STACKS
InternetStackHelper stack;
stack.Install (ueNodes);
stack.Install (enbNodes);
Ipv4AddressHelper address;
address.SetBase ("10.1.1.0", "255.255.255.0");
Ipv4InterfaceContainer UEinterfaces = address.Assign (ueDevs);
Ipv4InterfaceContainer ENBinterface = address.Assign (enbDevs);
*/
// MANAGE LTE NET DEVICES
Ptr<EnbNetDevice> enb;
enb = enbDevs.Get (0)->GetObject<EnbNetDevice> ();
Ptr<UeNetDevice> ue = ueDevs.Get (0)->GetObject<UeNetDevice> ();
lte.RegisterUeToTheEnb (ue, enb);
// CONFIGURE DL and UL SUB CHANNELS
// Define a list of sub channels for the downlink
std::vector<int> dlSubChannels;
for (int i = 0; i < 25; i++)
{
dlSubChannels.push_back (i);
}
// Define a list of sub channels for the uplink
std::vector<int> ulSubChannels;
for (int i = 50; i < 100; i++)
{
ulSubChannels.push_back (i);
}
enb->GetPhy ()->SetDownlinkSubChannels (dlSubChannels);
enb->GetPhy ()->SetUplinkSubChannels (ulSubChannels);
ue->GetPhy ()->SetDownlinkSubChannels (dlSubChannels);
ue->GetPhy ()->SetUplinkSubChannels (ulSubChannels);
// CONFIGURE MOBILITY
Ptr<ConstantPositionMobilityModel> enbMobility = CreateObject<ConstantPositionMobilityModel> ();
enbMobility->SetPosition (Vector (0.0, 0.0, 0.0));
lte.AddMobility (enb->GetPhy (), enbMobility);
Ptr<ConstantVelocityMobilityModel> ueMobility = CreateObject<ConstantVelocityMobilityModel> ();
ueMobility->SetPosition (Vector (50.0, 50.0, 0.0));
ueMobility->SetVelocity (Vector (50.0, 50.0, 0.0));
lte.AddMobility (ue->GetPhy (), ueMobility);
lte.AddDownlinkChannelRealization (enbMobility, ueMobility, ue->GetPhy ());
// ****** simulate a packet transmission in the downlink ******
Ptr<PacketBurst> pb = Create<PacketBurst> ();
Ptr<Packet> p1 = Create<Packet> (500);
Ptr<Packet> p2 = Create<Packet> (500);
pb->AddPacket (p1);
pb->AddPacket (p2);
if (enb->GetPhy ()->SendPacket (pb))
{
testResult = true;
}
if (ue->GetPhy ()->SendPacket (pb))
{
testResult = true;
}
Simulator::Destroy ();
return (testResult);
}
// ==============================================================================
class Ns3LtePhyTestTestSuite : public TestSuite
{
public:
Ns3LtePhyTestTestSuite ();
};
Ns3LtePhyTestTestSuite::Ns3LtePhyTestTestSuite ()
: TestSuite ("lte-phy", UNIT)
{
AddTestCase (new Ns3LtePhyTestCase);
}
Ns3LtePhyTestTestSuite ns3LtePhyTestTestSuite;

221
src/devices/lte/test/lte-propagation-loss-model-test.cc

@ -0,0 +1,221 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Giuseppe Piro <g.piro@poliba.it>
*/
#include <iostream>
#include <ns3/log.h>
#include <string>
#include <vector>
#include "ns3/log.h"
#include "ns3/abort.h"
#include "ns3/test.h"
#include "ns3/uinteger.h"
#include <ns3/simulator.h>
#include <ns3/lte-helper.h>
#include <ns3/enb-phy.h>
#include <ns3/ue-phy.h>
#include <ns3/packet-burst.h>
#include <ns3/constant-position-mobility-model.h>
#include <ns3/constant-velocity-mobility-model.h>
#include "ns3/single-model-spectrum-channel.h"
#include "ns3/lte-spectrum-phy.h"
#include "ns3/enb-lte-spectrum-phy.h"
#include "ns3/ue-lte-spectrum-phy.h"
#include "ns3/ue-net-device.h"
#include "ns3/enb-net-device.h"
#include "ns3/ue-manager.h"
#include "ns3/spectrum-propagation-loss-model.h"
#include "ns3/lte-propagation-loss-model.h"
using namespace ns3;
/*
* Test the LTE physical layer.
*/
class Ns3LtePropagationLossModelTestCase : public TestCase
{
public:
Ns3LtePropagationLossModelTestCase ();
virtual ~Ns3LtePropagationLossModelTestCase ();
private:
virtual bool DoRun (void);
};
Ns3LtePropagationLossModelTestCase::Ns3LtePropagationLossModelTestCase ()
: TestCase ("Test the LTE propagation loss model")
{
}
Ns3LtePropagationLossModelTestCase::~Ns3LtePropagationLossModelTestCase ()
{
}
bool
Ns3LtePropagationLossModelTestCase::DoRun (void)
{
bool testResult = false;
// CREATE PHY LAYER FOR BOTH UE AND ENB
Ptr<EnbLtePhy> phyEnb = CreateObject<EnbLtePhy> ();
Ptr<EnbLteSpectrumPhy> dlEnb = CreateObject<EnbLteSpectrumPhy> ();
Ptr<EnbLteSpectrumPhy> ulEnb = CreateObject<EnbLteSpectrumPhy> ();
phyEnb->SetDownlinkSpectrumPhy (dlEnb);
phyEnb->SetUplinkSpectrumPhy (ulEnb);
phyEnb->SetTxPower (43);
Ptr<UeLtePhy> phyUe = CreateObject<UeLtePhy> ();
Ptr<UeLteSpectrumPhy> dlUe = CreateObject<UeLteSpectrumPhy> ();
Ptr<UeLteSpectrumPhy> ulUe = CreateObject<UeLteSpectrumPhy> ();
phyUe->SetDownlinkSpectrumPhy (dlUe);
phyUe->SetUplinkSpectrumPhy (ulUe);
// CONFIGURE DL and UL SUB CHANNELS
// Define a list of sub channels for the downlink
std::vector<int> dlSubChannels;
for (int i = 0; i < 25; i++)
{
dlSubChannels.push_back (i);
}
// Define a list of sub channels for the uplink
std::vector<int> ulSubChannels;
for (int i = 50; i < 100; i++)
{
ulSubChannels.push_back (i);
}
phyEnb->SetDownlinkSubChannels (dlSubChannels);
phyEnb->SetUplinkSubChannels (ulSubChannels);
phyUe->SetDownlinkSubChannels (dlSubChannels);
phyUe->SetUplinkSubChannels (ulSubChannels);
// CONFIGURE MOBILITY
Ptr<ConstantPositionMobilityModel> enbMobility = CreateObject<ConstantPositionMobilityModel> ();
enbMobility->SetPosition (Vector (0.0, 0.0, 0.0));
phyEnb->GetDownlinkSpectrumPhy ()->SetMobility (enbMobility);
phyEnb->GetUplinkSpectrumPhy ()->SetMobility (enbMobility);
Ptr<ConstantVelocityMobilityModel> ueMobility = CreateObject<ConstantVelocityMobilityModel> ();
ueMobility->SetPosition (Vector (50.0, 50.0, 0.0));
ueMobility->SetVelocity (Vector (50.0, 50.0, 0.0));
phyUe->GetDownlinkSpectrumPhy ()->SetMobility (ueMobility);
phyUe->GetUplinkSpectrumPhy ()->SetMobility (ueMobility);
// CREATE CHANNEL AND ATTACH DEVICE BY ITS, create also PROPAGATION LOSS MODEL
Ptr<SingleModelSpectrumChannel> downlinkChannel = CreateObject<SingleModelSpectrumChannel> ();
Ptr<SingleModelSpectrumChannel> uplinkChannel = CreateObject<SingleModelSpectrumChannel> ();
dlUe->SetChannel (downlinkChannel);
ulUe->SetChannel (uplinkChannel);
downlinkChannel->AddRx (dlUe);
dlEnb->SetChannel (downlinkChannel);
ulEnb->SetChannel (uplinkChannel);
downlinkChannel->AddRx (dlEnb);
uplinkChannel->AddRx (ulEnb);
Ptr<LtePropagationLossModel> mobility = CreateObject<LtePropagationLossModel> ();
downlinkChannel->AddSpectrumPropagationLossModel (mobility->GetObject<SpectrumPropagationLossModel> ());
mobility->CreateChannelRealization (enbMobility, ueMobility);
// initialize multipath model
Ptr<JakesFadingLossModel> m = mobility->GetChannelRealization (enbMobility, ueMobility)->GetJakesFadingLossModel ();
m->SetPhy (phyUe);
/*
* ******************
* analyze the propagation loss model
* ******************
*/
Ptr<SpectrumValue> txPsd = phyEnb->CreateTxPowerSpectralDensity ();
Ptr<SpectrumValue> rxPsd = mobility->CalcRxPowerSpectralDensity (txPsd,enbMobility, ueMobility);
// test:
std::vector<double> tx, rx;
for (Values::const_iterator it = txPsd->ConstValuesBegin ();
it != txPsd->ConstValuesEnd (); it++ )
{
double tx_ = (*it);
tx.push_back (tx_);
}
for (Values::const_iterator it = rxPsd->ConstValuesBegin ();
it != rxPsd->ConstValuesEnd (); it++ )
{
double rx_ = (*it);
rx.push_back (rx_);
}
if (tx.size () != rx.size ())
{
return true;
}
int nbOfValues = tx.size ();
for (int i = 0; i < nbOfValues; i++)
{
if (tx.at (i) == 0 && rx.at (i) != 0 )
{
return true;
}
if (tx.at (i) != 0 && (tx.at (i) <= rx.at (i)))
{
return true;
}
}
Simulator::Destroy ();
return (testResult);
}
// ==============================================================================
class Ns3LtePropagationLossModelTestTestSuite : public TestSuite
{
public:
Ns3LtePropagationLossModelTestTestSuite ();
};
Ns3LtePropagationLossModelTestTestSuite::Ns3LtePropagationLossModelTestTestSuite ()
: TestSuite ("lte-propagation-loss-model", UNIT)
{
AddTestCase (new Ns3LtePropagationLossModelTestCase);
}
Ns3LtePropagationLossModelTestTestSuite ns3LtePropagationLossModelTestTestSuite;

85
src/devices/lte/wscript

@ -0,0 +1,85 @@
## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
def build(bld):
module = bld.create_ns3_module('lte', ['core'])
module.source = [
'model/lte-spectrum-phy.cc',
'model/enb-lte-spectrum-phy.cc',
'model/ue-lte-spectrum-phy.cc',
'model/lte-phy.cc',
'model/enb-phy.cc',
'model/ue-phy.cc',
'model/lte-spectrum-value-helper.cc',
'model/lte-propagation-loss-model.cc',
'model/loss-model.cc',
'model/penetration-loss-model.cc',
'model/shadowing-loss-model.cc',
'model/path-loss-model.cc',
'model/multipath-loss-model.cc',
'model/channel-realization.cc',
'model/amc-module.cc',
'model/lte-mac-queue.cc',
'model/rrc-entity.cc',
'model/rlc-entity.cc',
'model/mac-entity.cc',
'model/lte-mac-header.cc',
'model/enb-mac-entity.cc',
'model/ue-mac-entity.cc',
'model/radio-bearer-instance.cc',
'model/bearer-qos-parameters.cc',
'model/lte-net-device.cc',
'model/ue-record.cc',
'model/ue-manager.cc',
'model/enb-net-device.cc',
'model/ue-net-device.cc',
'model/packet-scheduler.cc',
'model/simple-packet-scheduler.cc',
'model/ideal-control-messages.cc',
'test/lte-phy-test.cc',
'test/lte-device-test.cc',
'test/lte-bearer-test.cc',
'test/lte-propagation-loss-model-test.cc',
'helper/lte-helper.cc',
]
headers = bld.new_task_gen('ns3header')
headers.module = 'lte'
headers.source = [
'model/lte-spectrum-phy.h',
'model/enb-lte-spectrum-phy.h',
'model/ue-lte-spectrum-phy.h',
'model/lte-phy.h',
'model/enb-phy.h',
'model/ue-phy.h',
'model/lte-spectrum-value-helper.h',
'model/lte-propagation-loss-model.h',
'model/loss-model.h',
'model/penetration-loss-model.h',
'model/shadowing-loss-model.h',
'model/path-loss-model.h',
'model/multipath-loss-model.h',
'model/channel-realization.h',
'model/amc-module.h',
'model/lte-mac-queue.h',
'model/rrc-entity.h',
'model/rlc-entity.h',
'model/mac-entity.h',
'model/lte-mac-header.h',
'model/enb-mac-entity.h',
'model/ue-mac-entity.h',
'model/radio-bearer-instance.h',
'model/bearer-qos-parameters.h',
'model/lte-net-device.h',
'model/ue-record.h',
'model/ue-manager.h',
'model/enb-net-device.h',
'model/ue-net-device.h',
'model/packet-scheduler.h',
'model/simple-packet-scheduler.h',
'model/ideal-control-messages.h',
'helper/lte-helper.h',
]
if (bld.env['ENABLE_EXAMPLES']):
bld.add_subdirs('examples')
Loading…
Cancel
Save