TCP performance evaluation over LTE environment (ns-3)

1,795 views
Skip to first unread message

Lee JooHyung

unread,
Jul 7, 2014, 5:58:59 AM7/7/14
to ns-3-...@googlegroups.com
Hello,

I am ns-3 beginner. And, I just try to simulate the TCP performance over LTE environment in terms of cwnd, delay etc.

(single UE ----eNB------EPC-----remote server)

UE   <--------------------------TCP flow from remote server

To do this, I basically tried to modify  lena-simple-epc by using sixth.cc. (I am using ns3 3.16)

It seems that compile was succeed but does not return any results (pcap and log file).

The source I made as follows. (If you do not mind if help me, please check where i made a mistake)

Thanks.

#include <fstream>
#include "ns3/point-to-point-module.h"
#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");


class MyApp : public Application 
{
public:

  MyApp ();
  virtual ~MyApp();

  void Setup (Ptr<Socket> socket, Address address, uint32_t packetSize, uint32_t nPackets, DataRate dataRate);

private:
  virtual void StartApplication (void);
  virtual void StopApplication (void);

  void ScheduleTx (void);
  void SendPacket (void);

  Ptr<Socket>     m_socket;
  Address         m_peer;
  uint32_t        m_packetSize;
  uint32_t        m_nPackets;
  DataRate        m_dataRate;
  EventId         m_sendEvent;
  bool            m_running;
  uint32_t        m_packetsSent;
};

MyApp::MyApp ()
  : m_socket (0), 
    m_peer (), 
    m_packetSize (0), 
    m_nPackets (0), 
    m_dataRate (0), 
    m_sendEvent (), 
    m_running (false), 
    m_packetsSent (0)
{
}

MyApp::~MyApp()
{
  m_socket = 0;
}

void
MyApp::Setup (Ptr<Socket> socket, Address address, uint32_t packetSize, uint32_t nPackets, DataRate dataRate)
{
  m_socket = socket;
  m_peer = address;
  m_packetSize = packetSize;
  m_nPackets = nPackets;
  m_dataRate = dataRate;
}

void
MyApp::StartApplication (void)
{
  m_running = true;
  m_packetsSent = 0;
  m_socket->Bind ();
  m_socket->Connect (m_peer);
  SendPacket ();
}

void 
MyApp::StopApplication (void)
{
  m_running = false;

  if (m_sendEvent.IsRunning ())
    {
      Simulator::Cancel (m_sendEvent);
    }

  if (m_socket)
    {
      m_socket->Close ();
    }
}

void 
MyApp::SendPacket (void)
{
  Ptr<Packet> packet = Create<Packet> (m_packetSize);
  m_socket->Send (packet);

  if (++m_packetsSent < m_nPackets)
    {
      ScheduleTx ();
    }
}

void 
MyApp::ScheduleTx (void)
{
  if (m_running)
    {
      Time tNext (Seconds (m_packetSize * 8 / static_cast<double> (m_dataRate.GetBitRate ())));
      m_sendEvent = Simulator::Schedule (tNext, &MyApp::SendPacket, this);
    }
}

static void
CwndChange (Ptr<OutputStreamWrapper> stream, uint32_t oldCwnd, uint32_t newCwnd)
{
  NS_LOG_UNCOND (Simulator::Now ().GetSeconds () << "\t" << newCwnd);
  *stream->GetStream () << Simulator::Now ().GetSeconds () << "\t" << oldCwnd << "\t" << newCwnd << std::endl;
}

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

  LogComponentEnable ("TcpClient", LOG_LEVEL_INFO);
  LogComponentEnable ("PacketSink", LOG_LEVEL_INFO);

  uint16_t numberOfNodes = 1;
  double simTime = 5.0;
  double distance = 60.0;
  double interPacketInterval = 100;

  // 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.Parse(argc, argv);

  Ptr<LteHelper> lteHelper = CreateObject<LteHelper> ();
  Ptr<EpcHelper> epcHelper = CreateObject<EpcHelper> ();
  lteHelper->SetEpcHelper (epcHelper);
  lteHelper->SetSchedulerType("ns3::PfFfMacScheduler");

  ConfigStore inputConfig;
  inputConfig.ConfigureDefaults();

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

  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(numberOfNodes);
  ueNodes.Create(numberOfNodes);

  // Install Mobility Model
  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();

  positionAlloc->Add (Vector(0, 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);

  // Attach one UE per eNodeB
   lteHelper->Attach (ueLteDevs.Get(0), enbLteDevs.Get(0));

  // 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

      Ptr<Node> ueNode = ueNodes.Get (0);
      // Set the default gateway for the UE
      Ptr<Ipv4StaticRouting> ueStaticRouting = ipv4RoutingHelper.GetStaticRouting (ueNode->GetObject<Ipv4> ());
      ueStaticRouting->SetDefaultRoute (epcHelper->GetUeDefaultGatewayAddress (), 1);

  lteHelper->ActivateEpsBearer (ueLteDevs, EpsBearer (EpsBearer::NGBR_VIDEO_TCP_DEFAULT), EpcTft::Default ());

  uint16_t sinkPort = 8080;
  Address sinkAddress (InetSocketAddress (ueIpIface.GetAddress (0), sinkPort));
  PacketSinkHelper packetSinkHelper ("ns3::TcpSocketFactory", InetSocketAddress (Ipv4Address::GetAny (), sinkPort));
  ApplicationContainer sinkApps = packetSinkHelper.Install (ueNodes.Get (0));
  sinkApps.Start (Seconds (0.));
  sinkApps.Stop (Seconds (20.));

  Ptr<Socket> ns3TcpSocket = Socket::CreateSocket (remoteHostContainer.Get (0), TcpSocketFactory::GetTypeId ());

  Ptr<MyApp> app = CreateObject<MyApp> ();
  app->Setup (ns3TcpSocket, sinkAddress, 1040, 1000, DataRate ("1Mbps"));
  remoteHostContainer.Get (0)->AddApplication (app);
  app->SetStartTime (Seconds (1.));
  app->SetStopTime (Seconds (20.));
      
  AsciiTraceHelper asciiTraceHelper;
  Ptr<OutputStreamWrapper> stream = asciiTraceHelper.CreateFileStream ("lte-tcp.cwnd");
  ns3TcpSocket->TraceConnectWithoutContext ("CongestionWindow", MakeBoundCallback (&CwndChange, stream));

  PcapHelper pcapHelper;
  Ptr<PcapFileWrapper> file = pcapHelper.CreateFile ("lte-tcp.pcap", std::ios::out, PcapHelper::DLT_PPP);

  Simulator::Stop (Seconds (20));
  Simulator::Run ();
  Simulator::Destroy ();
     
   return 0;

}

Konstantinos

unread,
Jul 7, 2014, 6:48:13 AM7/7/14
to ns-3-...@googlegroups.com
Dear JooHyung,

First of all, I would recommend to move to the latest NS-3 release and not use an outdated one for various reasons (bug fixes, added functionality etc).

With respect to your code, You have commented out one important part, which is the routing from the remote-host to the LTE network

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

So any traffic from the remote host can't find its way to the UE.

After fixing this and some minor modifications to build for ns-3.20, I was able to get both CWND trace and PCAPs.

Regards,
Konstantinos

Lee JooHyung

unread,
Jul 7, 2014, 9:07:31 AM7/7/14
to ns-3-...@googlegroups.com
Dear,Konstantinos

Thanks for your kind response.

I will move to the latest NS-3 release and check this code by commenting the part you mentioned out.

Regards,

From Joohyung Lee


--
You received this message because you are subscribed to a topic in the Google Groups "ns-3-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ns-3-users/VNeV7IDumSs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ns-3-users+...@googlegroups.com.
To post to this group, send email to ns-3-...@googlegroups.com.
Visit this group at http://groups.google.com/group/ns-3-users.
For more options, visit https://groups.google.com/d/optout.



--
===================================

Joohyung Lee, Ph. D.

Senior Engineer

Communications Research Team, DMC R&D Center, Samsung Electronics

Maetan dong 129, Samsung-ro, Yeongtong-gu, Suwon-si, Gyeonggi-do 443-742, Korea

Phone) +82-10-2758-1076

===================================

Lee JooHyung

unread,
Jul 8, 2014, 4:08:25 AM7/8/14
to ns-3-...@googlegroups.com, joohy...@kaist.ac.kr
Dear, Konstantinos, I successfully compiled and obtained the TCP cwnd results as follows.

Regarding below TCP results, I have some questions in order to make sure that TCP over LTE works right or not.

1) at the beginning, why significant increasing point exists.

2) during 10Mbps App generation, cwnd goes up and down even though i do not hire any loss model. Is it because the queue size of eNB??? (Where I can check the eNB queue size).

3) In addition, it does not present the slow start and congestion avoidance process of TCP.

I would like to ask your help. Thanks. 

본문 이미지 3
(50 secs simulation and 1 Mbps App generation from remote host)
본문 이미지 1
(10 secs simulation and 10Mbps App generation from remote host) 


 본문 이미지 2

(3 secs simulation and 10Mbps App generation from remote host) 


2014년 7월 7일 월요일 오후 10시 7분 31초 UTC+9, Lee JooHyung 님의 말:

Konstantinos

unread,
Jul 8, 2014, 5:06:39 AM7/8/14
to ns-3-...@googlegroups.com, joohy...@kaist.ac.kr
Hi JooHyung,

Your images are not showing for some reason. 

I am not a TCP/LTE expert. There is a section in NS-3 Wiki about the validation of the TCP model (http://www.nsnam.org/wiki/New_TCP_Socket_Architecture). Study that to identify if any of your questions can be answered.

For further questions regarding particular aspect of an implementation, I would recommend to contact the corresponding maintainers 

Vishnu Prasad H

unread,
Jun 5, 2016, 11:58:59 PM6/5/16
to ns-3-users
Can you share the code? I am working on tcp-lte. It would great help in understanding.

Vishnu Prasad H

unread,
Jun 6, 2016, 12:00:39 AM6/6/16
to ns-3-users, joohy...@kaist.ac.kr
can you share the code? I am working on tcp-lte. It would be great help in understanding.

Tabita Nindya

unread,
Jul 20, 2016, 11:51:35 AM7/20/16
to ns-3-users, joohy...@kaist.ac.kr
hi joo hyung im very interest with your topic about tcp performance in LTE. May u share this code? thankyou

Tommaso Pecorella

unread,
Jul 20, 2016, 12:10:11 PM7/20/16
to ns-3-users
IF shared, the code would be 2 years old, and it would need some (heavy) changes to work properly.
Moreover, it should be easy enough to build a LTE simulation starting from one of the examples and adding one or more TCP sources (again, looking at the examples).

Summarizing: do your own homework, especially if it is extremely simple.

T.
Reply all
Reply to author
Forward
0 new messages