implementing lte on udp echo client and server

220 views
Skip to first unread message

Narges Zarnaghinaghsh

unread,
Aug 29, 2019, 1:15:50 PM8/29/19
to ns-3-...@googlegroups.com
Hi,

I have written a code for udp echo client and server and it works well. now, I want to implement Lte standard for the client and the server instead of point to point channel. I modified the code as below, but now the client sends a packet to the server, but the server does not reply at all. The server does not print anything and it seems that the server is not receiving any packet from the client. By putting some log comments, I realized that ns3 runs all lines of the code. The code is as below:

#include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/internet-module.h"
#include "ns3/point-to-point-module.h"
#include "ns3/applications-module.h"
#include "ns3/yans-wifi-helper.h"
#include "ns3/packet.h"

#include <ns3/core-module.h>
#include <ns3/network-module.h>
#include <ns3/mobility-module.h>
#include <ns3/lte-module.h>
//#include "mat.h"
#include "sstream"
#include "fstream"
#include "iostream"
#include "string"
#include "vector"
#include "iterator"
#include "algorithm"

using namespace ns3;

NS_LOG_COMPONENT_DEFINE ("FirstScriptExample");

int
main (int argc, char *argv[])
{

  CommandLine cmd;
  cmd.Parse (argc, argv);


  Time::SetResolution (Time::NS);
  LogComponentEnable ("UdpEchoClientApplication", LOG_LEVEL_INFO);
  LogComponentEnable ("UdpEchoServerApplication", LOG_LEVEL_INFO);

  NodeContainer nodes;
  nodes.Create (11); // ue nodes

  // Create an LteHelper object:

  Ptr<LteHelper> lteHelper = CreateObject<LteHelper> ();
  // This will instantiate some common objects (e.g., the Channel object) and provide the methods to add eNBs and UEs and configure them.

  // Create Node objects for the eNB(s) and the UEs:

  NodeContainer enbNodes;
  enbNodes.Create (1);
  NodeContainer ueNodes;
  ueNodes.Create (2);

  // Note that the above Node instances at this point still don’t have an LTE protocol stack installed; they’re just empty nodes.

  // Configure the Mobility model for all the nodes:

  MobilityHelper mobility;
  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
  mobility.Install (enbNodes);
  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
  mobility.Install (ueNodes);

  //The above will place all nodes at the coordinates (0,0,0). Please refer to the documentation of the ns-3 mobility model for how to set your own position or configure node movement

  // Install an LTE protocol stack on the eNB(s):

  NetDeviceContainer enbDevs;
  enbDevs = lteHelper->InstallEnbDevice (enbNodes);
 
  // Install an LTE protocol stack on the UEs:

  NetDeviceContainer ueDevs;
  ueDevs = lteHelper->InstallUeDevice (ueNodes);
 
  // Attach the UEs to an eNB. This will configure each UE according to the eNB configuration, and create an RRC connection between them:

  lteHelper->Attach (ueDevs, enbDevs.Get (0));
 
  // Activate a data radio bearer between each UE and the eNB it is attached to:

  enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE;
  EpsBearer bearer (q);
  lteHelper->ActivateDataRadioBearer (ueDevs, bearer);

  // This method will also activate two saturation traffic generators for that bearer, one in uplink and one in downlink.

  NodeContainer LteNodes(enbNodes.Get (0),ueNodes.Get(0));
 
  NetDeviceContainer LteDevs(enbDevs.Get(0),ueDevs.Get(0));


  // aggregate IP/TCP/UDP functionality to existing Nodes:
  InternetStackHelper stack;
  stack.Install (ueNodes);
 
  // aggregate IP/TCP/UDP functionality to existing Nodes:
  InternetStackHelper enbstack;
  enbstack.Install (enbNodes);


  Ipv4AddressHelper lteaddress;
  lteaddress.SetBase ("10.1.1.0", "255.255.255.0");
 
  Ipv4InterfaceContainer interfaceslte = lteaddress.Assign (LteDevs);

  UdpEchoServerHelper echoServer (1);

  ApplicationContainer serverApps = echoServer.Install (enbNodes.Get (0));
  serverApps.Start (Seconds (1.0));
  serverApps.Stop (Seconds (400.0));

  UdpEchoClientHelper echoClient (interfaceslte.GetAddress (1), 1);
  echoClient.SetAttribute ("MaxPackets", UintegerValue (500));
  echoClient.SetAttribute ("Interval", TimeValue (Seconds (0.2873*2))); //0.02366 //0.05746 // 0.04732 //0.05746
  echoClient.SetAttribute ("PacketSize", UintegerValue (1024));

  ApplicationContainer clientApps = echoClient.Install (ueNodes.Get (0));
  clientApps.Start (Seconds (2.0));
  clientApps.Stop (Seconds (400.0));

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

Can anyone help me to solve this problem?

Thanks,
Narges

Selematsela Neo

unread,
Aug 29, 2019, 5:21:17 PM8/29/19
to ns-3-...@googlegroups.com
Hi Narges,

I have the below concern after looking at your code:
Why are you using enbNode as your server? Bear in mind that Ue(s) do not communicate with the enbNode at IP layer, but instead they communicate at physical layer using Radio Access Technology (in your case LTE).

To implement echo client and server application on LTE i would opt to use "EpcHelper" instead of "LteHelper", then have my server node connected to the PGW node. This way you would have an end-to-end lte architecture connected to the remote server and then install echo application into the Ue to echo the specified server.

Try follow this example in the lte module:
lena-simple-epc.cc


--
Posting to this group should follow these guidelines https://www.nsnam.org/wiki/Ns-3-users-guidelines-for-posting
---
You received this message because you are subscribed to the Google Groups "ns-3-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ns-3-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ns-3-users/CAA364jO1Jdhh3mfW2uMne1zKhcNnctWhLcFKP4pUWmFH1xR6%2Bg%40mail.gmail.com.

ABDULJABBAR ALSHARIF

unread,
Aug 30, 2019, 10:16:07 AM8/30/19
to ns-3-...@googlegroups.com
Check lte platfirm
My system getting hug when it's work I'll check 
example in the lte module:
lena-simple-epc.cc

--

Narges Zarnaghinaghsh

unread,
Aug 31, 2019, 12:36:23 AM8/31/19
to ns-3-...@googlegroups.com
Thank you so much. Your notes was very helpful. I modified my code as below, but it does not print anything related to udp-echo-server and udp-echo-client. It should print something:


#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"
//#include "ns3/gtk-config-store.h"

using namespace ns3;

/**
 * Sample simulation script for LTE+EPC. It instantiates several eNodeB,
 * attaches one UE per eNodeB starts a flow for each UE to  and from a remote host.
 * It also  starts yet another flow between each UE pair.
 */

NS_LOG_COMPONENT_DEFINE ("EpcFirstExample");


int
main (int argc, char *argv[])
{
 
 
  uint16_t numberOfNodes = 1;
  double simTime = 1.1;
  double distance = 60.0;
  double interPacketInterval = 100;
  bool useCa = false;

  // Command line arguments
  CommandLine cmd;
  cmd.AddValue("numberOfNodes", "Number of eNodeBs + UE pairs", numberOfNodes);
  cmd.AddValue("simTime", "Total duration of the simulation [s])", simTime);
  cmd.AddValue("distance", "Distance between eNBs [m]", distance);
  cmd.AddValue("interPacketInterval", "Inter packet interval [ms])", interPacketInterval);
  cmd.AddValue("useCa", "Whether to use carrier aggregation.", useCa);
  cmd.Parse(argc, argv);

  if (useCa)
   {
     Config::SetDefault ("ns3::LteHelper::UseCa", BooleanValue (useCa));
     Config::SetDefault ("ns3::LteHelper::NumberOfComponentCarriers", UintegerValue (2));
     Config::SetDefault ("ns3::LteHelper::EnbComponentCarrierManager", StringValue ("ns3::RrComponentCarrierManager"));
   }

  // EPC in addition to the LTE:
  // The use of EPC allows to use IPv4 and IPv6 networking with LTE devices.
  // We will be able to use the regular ns-3 applications and sockets over IPv4
  // and IPv6 over LTE, and also to connect an LTE network to any other IPv4 and
  // IPv6 network.
 
  // In addition to LteHelper, we need to use an additional EpcHelper class, which
  // will take care of creating the EPC entities and network topology.
  // Note that we can’t use EpcHelper directly, as it is an abstract base class;
  // Instead, we need to use one of its child classes, which provide different
  // EPC topology implementations.
 
  // In this simulation, we will consider PointToPointEpcHelper, which implements
  // an EPC based on point-to-point links.

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

  ConfigStore inputConfig;
  inputConfig.ConfigureDefaults();

  // parse again so you can override default values from the command line
  cmd.Parse(argc, argv);

  // It is to be noted that the EpcHelper will also automatically create the PGW
  // node and configure it so that it can properly handle traffic from/to the LTE
  // radio access network. Still, we need to add some explicit code to connect
  // the PGW to other IPv4/IPv6 networks (e.g., the internet, another EPC). Here
  // we connect a single remote host (IPv4 type) to the PGW via a point-to-point link:

  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)));
 
  // For each of the Nodes, the helper will instantiate a net device, add a MAC
  // address and a queue to the device and install it to the node:
 
  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);

  // Now, we create LTE eNBs and UEs:

  NodeContainer ueNodes;
  NodeContainer enbNodes;
  enbNodes.Create(numberOfNodes);
  ueNodes.Create(numberOfNodes);

  // Install Mobility Model
  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
  for (uint16_t i = 0; i < numberOfNodes; 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 < numberOfNodes; i++)
      {
        lteHelper->Attach (ueLteDevs.Get(i), enbLteDevs.Get(i));
        // side effect: the default EPS bearer will be activated
      }


  // Install and start applications on UEs and remote host
 
 
  UdpEchoServerHelper echoServer (1);
   
  ApplicationContainer serverApps = echoServer.Install (remoteHost);

  serverApps.Start (Seconds (1.0));
  serverApps.Stop (Seconds (400.0));
 
  UdpEchoClientHelper echoClient (ueIpIface.GetAddress (0), 1);

  echoClient.SetAttribute ("MaxPackets", UintegerValue (500));
  echoClient.SetAttribute ("Interval", TimeValue (Seconds (0.2873*2))); //0.02366 //0.05746 // 0.04732 //0.05746
  echoClient.SetAttribute ("PacketSize", UintegerValue (1024));
 
  ApplicationContainer clientApps = echoClient.Install (ueNodes.Get (0));
  clientApps.Start (Seconds (2.0));
  lteHelper->EnableTraces ();
  // Uncomment to enable PCAP tracing
  //p2ph.EnablePcapAll("lena-epc-first");

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

  /*GtkConfigStore config;
  config.ConfigureAttributes();*/

  Simulator::Destroy();
  return 0;

}


Do you know how I can fix  it? Also, I do not know how to assign the ip address for remote host?

Thanks,
Narges

Narges Zarnaghinaghsh

unread,
Sep 1, 2019, 7:16:31 PM9/1/19
to ns-3-...@googlegroups.com
Can anyone help me with this? Also, when I change UdpClientHelper to UdpEchoClientHelper in lena-simple-epc, it does not print the comments for UdpEchoClientHelper.

ABDULJABBAR ALSHARIF

unread,
Sep 1, 2019, 7:23:02 PM9/1/19
to ns-3-...@googlegroups.com
Hello 
 I have questions what's different between LTE-sim Simulation and ns3

Narges Zarnaghinaghsh

unread,
Sep 1, 2019, 7:34:09 PM9/1/19
to ns-3-...@googlegroups.com
Hi,

Thank you so much. In the original lena-simple-epc.cc example in ns3, the clients are created using UdpClientHelper class, but I want to use UdpEchoClientHelper instead and it should print the comment regarding sending packets from the client. In addition, I have only one server and one client, but as I see in the original example, there are 3 servers and clients and I do not know the reason. 

Thanks,
Narges

Reply all
Reply to author
Forward
0 new messages