Attach UE to eNodeB

1,720 views
Skip to first unread message

Vaison

unread,
Jan 15, 2015, 1:05:38 PM1/15/15
to ns-3-...@googlegroups.com
I have two files, in one of them I can see how UEs are attached to different eNodebs but in the other one is not working well but I don't know why... Could someone shed light on it please?

These one is work well, I can see how 3 UEs are attached to one eNodeb and the rest (2) are attached to the other eNodeB
#include <ns3/core-module.h>
#include <ns3/network-module.h>
#include <ns3/mobility-module.h>
#include <ns3/lte-module.h>
#include <ns3/buildings-helper.h>
#include <ns3/point-to-point-helper.h>

using namespace ns3;

int main (int argc, char *argv[])
{
 
LogComponentEnable ("LteEnbPhy", LOG_LEVEL_INFO);

       
double Time = 0.5;
        uint16_t j
= 0;
        uint16_t h
= 1;
        uint16_t numberOfUEs
= 5;
        uint16_t numberOfeNbs
= 2;

   
Ptr<LteHelper> lteHelper = CreateObject<LteHelper> ();

   
NodeContainer enbNodes;
    enbNodes
.Create (numberOfeNbs);
   
NodeContainer ueNodes;
    ueNodes
.Create (numberOfUEs);

   
MobilityHelper mobility;
    mobility
.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
    mobility
.Install (enbNodes);
    mobility
.Install (ueNodes);
   
   
//Install an LTE protocol stack on the UE and eNBs
   
NetDeviceContainer enbDevs;
    enbDevs
= lteHelper->InstallEnbDevice (enbNodes);
   
NetDeviceContainer ueDevs;
    ueDevs
= lteHelper->InstallUeDevice (ueNodes);

   
// Attach the UEs to an eNB.
     
for (uint16_t i = 0; i < numberOfUEs; i++)
     
{
         
if ( i % 2 != 0 ){
            lteHelper
->Attach (ueDevs.Get(i), enbDevs.Get(j));
       
}
       
else{
            lteHelper
->Attach (ueDevs.Get(i), enbDevs.Get(h));
       
}
     
}

   
// Activate an EPS Bearer including the setup of the Radio Bearer between an eNB and its attached UE
   
enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE;
   
EpsBearer bearer (q);
    lteHelper
->ActivateDataRadioBearer (ueDevs, bearer);
   
   
Simulator::Stop (Seconds (Time));

   
Simulator::Run ();
   
   
Simulator::Destroy ();
   
return 0;
}

But in that one I couldn't see it!!
#include "ns3/lte-helper.h"
#include "ns3/epc-helper.h"
#include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/ipv4-global-routing-helper.h"
#include "ns3/internet-module.h"
#include "ns3/mobility-module.h"
#include "ns3/lte-module.h"
#include "ns3/applications-module.h"
#include "ns3/point-to-point-helper.h"
#include "ns3/config-store.h"

using namespace ns3;

int main (int argc, char *argv[])
{
   
LogComponentEnable ("LteEnbPhy", LOG_LEVEL_INFO);

  uint16_t numberOfUEs
= 5;
  uint16_t numberOfeNbs
= 2;
  uint16_t j
= 0;
  uint16_t h
= 1;
 
double simTime = 0.5;
 
double distance = 60.0;
 
double interPacketInterval = 100;

 
Ptr<LteHelper> lteHelper = CreateObject<LteHelper> ();
 
Ptr<PointToPointEpcHelper>  epcHelper = CreateObject<PointToPointEpcHelper> ();
  lteHelper
->SetEpcHelper (epcHelper);

 
Ptr<Node> pgw = epcHelper->GetPgwNode ();

   
// Create a single RemoteHost
 
NodeContainer remoteHostContainer;
  remoteHostContainer
.Create (1);
 
Ptr<Node> remoteHost = remoteHostContainer.Get (0);
 
InternetStackHelper internet;
  internet
.Install (remoteHostContainer);

 
// Create the Internet
 
PointToPointHelper p2ph;
  p2ph
.SetDeviceAttribute ("DataRate", DataRateValue (DataRate ("100Gb/s")));
  p2ph
.SetDeviceAttribute ("Mtu", UintegerValue (1500));
  p2ph
.SetChannelAttribute ("Delay", TimeValue (Seconds (0.010)));
 
NetDeviceContainer internetDevices = p2ph.Install (pgw, remoteHost);
 
Ipv4AddressHelper ipv4h;
  ipv4h
.SetBase ("1.0.0.0", "255.0.0.0");
 
Ipv4InterfaceContainer internetIpIfaces = ipv4h.Assign (internetDevices);
 
// interface 0 is localhost, 1 is the p2p device
 
Ipv4Address remoteHostAddr = internetIpIfaces.GetAddress (1);

 
Ipv4StaticRoutingHelper ipv4RoutingHelper;
 
Ptr<Ipv4StaticRouting> remoteHostStaticRouting = ipv4RoutingHelper.GetStaticRouting (remoteHost->GetObject<Ipv4> ());
  remoteHostStaticRouting
->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.0.0.0"), 1);

 
NodeContainer ueNodes;
 
NodeContainer enbNodes;
  enbNodes
.Create(numberOfeNbs);
  ueNodes
.Create(numberOfUEs);

 
// Install Mobility Model
 
Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
 
for (uint16_t i = 0; i < numberOfUEs; i++)
   
{
      positionAlloc
->Add (Vector(distance * i, 0, 0));
   
}
 
MobilityHelper mobility;
  mobility
.SetMobilityModel("ns3::ConstantPositionMobilityModel");
  mobility
.SetPositionAllocator(positionAlloc);
  mobility
.Install(enbNodes);
  mobility
.Install(ueNodes);

 
// Install LTE Devices to the nodes
 
NetDeviceContainer enbLteDevs = lteHelper->InstallEnbDevice (enbNodes);
 
NetDeviceContainer ueLteDevs = lteHelper->InstallUeDevice (ueNodes);

 
// Install the IP stack on the UEs
  internet
.Install (ueNodes);
 
Ipv4InterfaceContainer ueIpIface;
  ueIpIface
= epcHelper->AssignUeIpv4Address (NetDeviceContainer (ueLteDevs));
 
// Assign IP address to UEs, and install applications
 
for (uint32_t u = 0; u < ueNodes.GetN (); ++u)
   
{
     
Ptr<Node> ueNode = ueNodes.Get (u);
     
// Set the default gateway for the UE
     
Ptr<Ipv4StaticRouting> ueStaticRouting = ipv4RoutingHelper.GetStaticRouting (ueNode->GetObject<Ipv4> ());
      ueStaticRouting
->SetDefaultRoute (epcHelper->GetUeDefaultGatewayAddress (), 1);
   
}

 
// Attach one UE per eNodeB
 
for (uint16_t i = 0; i < numberOfUEs; i++)
     
{
       
if ( i % 2 != 0 ){
            lteHelper
->Attach (ueLteDevs.Get(i), enbLteDevs.Get(j));
       
}
       
else{
            lteHelper
->Attach (ueLteDevs.Get(i), enbLteDevs.Get(h));
       
}
       
// side effect: the default EPS bearer will be activated
     
}

 
// Install and start applications on UEs and remote host
  uint16_t dlPort
= 1234;
  uint16_t ulPort
= 2000;
  uint16_t otherPort
= 3000;
 
ApplicationContainer clientApps;
 
ApplicationContainer serverApps;
 
for (uint32_t u = 0; u < ueNodes.GetN (); ++u)
   
{
     
++ulPort;
     
++otherPort;
     
PacketSinkHelper dlPacketSinkHelper ("ns3::UdpSocketFactory", InetSocketAddress (Ipv4Address::GetAny (), dlPort));
     
PacketSinkHelper ulPacketSinkHelper ("ns3::UdpSocketFactory", InetSocketAddress (Ipv4Address::GetAny (), ulPort));
     
PacketSinkHelper packetSinkHelper ("ns3::UdpSocketFactory", InetSocketAddress (Ipv4Address::GetAny (), otherPort));
      serverApps
.Add (dlPacketSinkHelper.Install (ueNodes.Get(u)));
      serverApps
.Add (ulPacketSinkHelper.Install (remoteHost));
      serverApps
.Add (packetSinkHelper.Install (ueNodes.Get(u)));

     
UdpClientHelper dlClient (ueIpIface.GetAddress (u), dlPort);
      dlClient
.SetAttribute ("Interval", TimeValue (MilliSeconds(interPacketInterval)));
      dlClient
.SetAttribute ("MaxPackets", UintegerValue(1000000));

     
UdpClientHelper ulClient (remoteHostAddr, ulPort);
      ulClient
.SetAttribute ("Interval", TimeValue (MilliSeconds(interPacketInterval)));
      ulClient
.SetAttribute ("MaxPackets", UintegerValue(1000000));

     
UdpClientHelper client (ueIpIface.GetAddress (u), otherPort);
      client
.SetAttribute ("Interval", TimeValue (MilliSeconds(interPacketInterval)));
      client
.SetAttribute ("MaxPackets", UintegerValue(1000000));

      clientApps
.Add (dlClient.Install (remoteHost));
      clientApps
.Add (ulClient.Install (ueNodes.Get(u)));
     
if (u+1 < ueNodes.GetN ())
       
{
          clientApps
.Add (client.Install (ueNodes.Get(u+1)));
       
}
     
else
       
{
          clientApps
.Add (client.Install (ueNodes.Get(0)));
       
}
   
}
  serverApps
.Start (Seconds (0.01));
  clientApps
.Start (Seconds (0.01));
  lteHelper
->EnableTraces ();

 
Simulator::Stop(Seconds(simTime));
 
Simulator::Run();

 
Simulator::Destroy();
 
return 0;

}

I don't like to do that because are to many lines but I couldn't find my mistake.

Regards,

~V
BADassign.cc
GOODassign.cc

Konstantinos

unread,
Jan 15, 2015, 1:24:24 PM1/15/15
to ns-3-...@googlegroups.com
Hi,

What do you mean that in the second one it is not working well. Aren't the nodes attached?
Because I run both your scripts without any problem and the generated LTE traces showed that all UEs send/receive packets.


On Thursday, January 15, 2015 at 6:05:38 PM UTC, Vaison wrote:
I have two files, in one of them I can see how UEs are attached to different eNodebs but in the other one is not working well but I don't know why... Could someone shed light on it please?

Vaison

unread,
Jan 15, 2015, 1:31:19 PM1/15/15
to ns-3-...@googlegroups.com
Maybe I'm wrong but...when I execute the script I said is not working well, I have the follow output (just show the last output, I know before is attached):

-----sub frame 6-----
0x1bd5e80 eNB Expected TBs 0
-----sub frame 6-----
0x1bdc910 eNB Expected TBs 0
-----sub frame 7-----
0x1bd5e80 eNB Expected TBs 0
-----sub frame 7-----
0x1bdc910 eNB Expected TBs 0
-----sub frame 8-----
0x1bd5e80 eNB Expected TBs 0
-----sub frame 8-----
0x1bdc910 eNB Expected TBs 0
-----sub frame 9-----
0x1bd5e80 eNB Expected TBs 0
-----sub frame 9-----
0x1bdc910 eNB Expected TBs 0
-----sub frame 10-----
0x1bd5e80 eNB Expected TBs 0
-----sub frame 10-----
0x1bdc910 eNB Expected TBs 0

And now I'm gonna put the output of the "good" script:

-----sub frame 6-----
0x1b44f20 eNB Expected TBs 2
0x1b44f20 RNTI 1 NEW TB
0x1b44f20 RNTI 2 NEW TB
-----sub frame 6-----
0x1b48050 eNB Expected TBs 3
0x1b48050 RNTI 1 NEW TB
0x1b48050 RNTI 2 NEW TB
0x1b48050 RNTI 3 NEW TB
-----sub frame 7-----
0x1b44f20 eNB Expected TBs 2
0x1b44f20 RNTI 1 NEW TB
0x1b44f20 RNTI 2 NEW TB
-----sub frame 7-----
0x1b48050 eNB Expected TBs 3
0x1b48050 RNTI 3 HARQ RETX
0x1b48050 RNTI 1 NEW TB
0x1b48050 RNTI 2 NEW TB
-----sub frame 8-----
0x1b44f20 eNB Expected TBs 2
0x1b44f20 RNTI 1 NEW TB
0x1b44f20 RNTI 2 NEW TB
-----sub frame 8-----
0x1b48050 eNB Expected TBs 3
0x1b48050 RNTI 1 NEW TB
0x1b48050 RNTI 2 NEW TB
0x1b48050 RNTI 3 NEW TB
-----sub frame 9-----
0x1b44f20 eNB Expected TBs 2
0x1b44f20 RNTI 1 NEW TB
0x1b44f20 RNTI 2 NEW TB
-----sub frame 9-----
0x1b48050 eNB Expected TBs 3
0x1b48050 RNTI 1 NEW TB
0x1b48050 RNTI 2 NEW TB
0x1b48050 RNTI 3 NEW TB
-----sub frame 10-----
0x1b44f20 eNB Expected TBs 2
0x1b44f20 RNTI 1 NEW TB
0x1b44f20 RNTI 2 NEW TB
-----sub frame 10-----
0x1b48050 eNB Expected TBs 3
0x1b48050 RNTI 1 NEW TB
0x1b48050 RNTI 2 NEW TB
0x1b48050 RNTI 3 NEW TB

Why these different results?

I know in both UE are attached but... I don't know why the behavior isn't the same. Why?

Regards,

~V

Konstantinos

unread,
Jan 15, 2015, 1:35:33 PM1/15/15
to ns-3-...@googlegroups.com
They are different scenarios... so the outputs should be different. Some of the obvious differences:
The first has activated a dedicated EPS bearer, no actual traffic though is generated.
The second us based has also EPC, no dedicated EPS bearer and several applications.

Vaison

unread,
Jan 15, 2015, 1:40:03 PM1/15/15
to ns-3-...@googlegroups.com
First of all many thanks for your answer Konstantinos!
Then ok,got it, but... Are there another way to show those info? or the info related to which UE is connected a specific eNB?

Regards,

~V

Konstantinos

unread,
Jan 15, 2015, 2:32:27 PM1/15/15
to ns-3-...@googlegroups.com
You can use the tracing system and connect to a trace source, e.g. LteUeRrc::ConnectionEstablished that can provide the UE and ENB info when a RRC connection is established.
Message has been deleted

Vaison

unread,
Jan 16, 2015, 7:26:37 AM1/16/15
to ns-3-...@googlegroups.com
Many thanks!

I use this line
 
Config::Connect ("/NodeList/*/DeviceList/*/LteEnbRrc/ConnectionEstablished", MakeCallback (&NotifyConnectionEstablishedEnb));


And this function
void NotifyConnectionEstablishedEnb (std::string context,
                                uint64_t imsi
,
                                uint16_t cellid
,
                                uint16_t rnti
)
{
  std
::cout << Simulator::Now ().GetSeconds () << " " << context
           
<< " eNB CellId " << cellid
           
<< ": successful connection of UE with IMSI " << imsi
           
<< " RNTI " << rnti
           
<< std::endl;
}

And I can see thats work perfectly! Maybe I could use something easier....

Regards,

~V

Abida Pervven

unread,
Jun 7, 2018, 5:53:59 AM6/7/18
to ns-3-users

Hi all

I am a new learner of ns3. this group is very helping to understand ns3 basics. can you please tell me where to add these lines as i am adding in the badassign code and having error like
[
1035/2422] Compiling scratch/BADassign1.cc
../scratch/BADassign1.cc: In function ‘int main(int, char**)’:
../scratch/BADassign1.cc:28:93: error: ‘NotifyConnectionEstablishedEnb’ was not declared in this scope

 Config::Connect ("/NodeList/*/DeviceList/*/LteEnbRrc/ConnectionEstablished", MakeCallback (&NotifyConnectionEstablishedEnb));

Abida                                                                                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Reply all
Reply to author
Forward
0 new messages