# HG changeset patch # User Manoj Kumar Rana # Date 1512865164 -3600 # Parent f916e5a9f8bfa866eb57a8aae243c2c3e560fc61 lte: add support for multiple EPC diff --git a/src/lte/examples/lena-deactivate-bearer.cc b/src/lte/examples/lena-deactivate-bearer.cc --- a/src/lte/examples/lena-deactivate-bearer.cc +++ b/src/lte/examples/lena-deactivate-bearer.cc @@ -102,7 +102,7 @@ Ipv4StaticRoutingHelper ipv4RoutingHelper; Ptr remoteHostStaticRouting = ipv4RoutingHelper.GetStaticRouting (remoteHost->GetObject ()); - remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.0.0.0"), 1); + remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.255.0.0"), 1); NodeContainer ueNodes; NodeContainer enbNodes; diff --git a/src/lte/examples/lena-distributed-ffr.cc b/src/lte/examples/lena-distributed-ffr.cc --- a/src/lte/examples/lena-distributed-ffr.cc +++ b/src/lte/examples/lena-distributed-ffr.cc @@ -158,7 +158,7 @@ Ipv4StaticRoutingHelper ipv4RoutingHelper; Ptr remoteHostStaticRouting = ipv4RoutingHelper.GetStaticRouting (remoteHost->GetObject ()); // interface 0 is localhost, 1 is the p2p device - remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.0.0.0"), 1); + remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.255.0.0"), 1); // Create Nodes: eNodeB and UE NodeContainer enbNodes; diff --git a/src/lte/examples/lena-dual-stripe.cc b/src/lte/examples/lena-dual-stripe.cc --- a/src/lte/examples/lena-dual-stripe.cc +++ b/src/lte/examples/lena-dual-stripe.cc @@ -671,7 +671,7 @@ Ipv4StaticRoutingHelper ipv4RoutingHelper; Ptr remoteHostStaticRouting = ipv4RoutingHelper.GetStaticRouting (remoteHost->GetObject ()); - remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.0.0.0"), 1); + remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.255.0.0"), 1); // for internetworking purposes, consider together home UEs and macro UEs ues.Add (homeUes); diff --git a/src/lte/examples/lena-simple-epc-emu.cc b/src/lte/examples/lena-simple-epc-emu.cc --- a/src/lte/examples/lena-simple-epc-emu.cc +++ b/src/lte/examples/lena-simple-epc-emu.cc @@ -113,7 +113,7 @@ Ipv4StaticRoutingHelper ipv4RoutingHelper; Ptr remoteHostStaticRouting = ipv4RoutingHelper.GetStaticRouting (remoteHost->GetObject ()); - remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.0.0.0"), 1); + remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.255.0.0"), 1); NodeContainer ueNodes; NodeContainer enbNodes; diff --git a/src/lte/examples/lena-simple-epc.cc b/src/lte/examples/lena-simple-epc.cc --- a/src/lte/examples/lena-simple-epc.cc +++ b/src/lte/examples/lena-simple-epc.cc @@ -100,7 +100,7 @@ Ipv4StaticRoutingHelper ipv4RoutingHelper; Ptr remoteHostStaticRouting = ipv4RoutingHelper.GetStaticRouting (remoteHost->GetObject ()); - remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.0.0.0"), 1); + remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.255.0.0"), 1); NodeContainer ueNodes; NodeContainer enbNodes; diff --git a/src/lte/examples/lena-simple-two-epc.cc b/src/lte/examples/lena-simple-two-epc.cc new file mode 100644 --- /dev/null +++ b/src/lte/examples/lena-simple-two-epc.cc @@ -0,0 +1,297 @@ +/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (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: Jaume Nin + * Tommaso Pecorella + */ + +#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/csma-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 = 2; + double simTime = 1.1; + double distance = 60.0; + double interPacketInterval = 100; + bool useCa = false; + +// LogComponentEnable ("PointToPointEpcHelper", LOG_LEVEL_ALL); + + // 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); + + ConfigStore inputConfig; + inputConfig.ConfigureDefaults(); + + // parse again so you can override default values from the command line + 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")); + } + + InternetStackHelper internet; + Ipv4StaticRoutingHelper ipv4RoutingHelper; + + // Network A + Ptr lteAHelper = CreateObject (); + Ptr epcAHelper = CreateObject (); + lteAHelper->SetEpcHelper (epcAHelper); + + Ptr pgwA = epcAHelper->GetPgwNode (); + + // Network A + NodeContainer ueNodesA; + NodeContainer enbNodesA; + enbNodesA.Create(numberOfNodes); + ueNodesA.Create(numberOfNodes); + + // Install Mobility Model + Ptr positionAlloc = CreateObject (); + for (uint16_t i = 0; i < numberOfNodes; i++) + { + positionAlloc->Add (Vector(distance * i, 0, 0)); + } + MobilityHelper mobilityA; + mobilityA.SetMobilityModel("ns3::ConstantPositionMobilityModel"); + mobilityA.SetPositionAllocator(positionAlloc); + mobilityA.Install(enbNodesA); + mobilityA.Install(ueNodesA); + + // Install LTE Devices to the nodes + NetDeviceContainer enbLteADevs = lteAHelper->InstallEnbDevice (enbNodesA); + NetDeviceContainer ueLteADevs = lteAHelper->InstallUeDevice (ueNodesA); + + // Install the IP stack on the UEs + internet.Install (ueNodesA); + Ipv4InterfaceContainer ueAIpIface; + ueAIpIface = epcAHelper->AssignUeIpv4Address (NetDeviceContainer (ueLteADevs)); + // Assign IP address to UEs, and install applications + for (uint32_t u = 0; u < ueNodesA.GetN (); ++u) + { + Ptr ueNode = ueNodesA.Get (u); + // Set the default gateway for the UE + Ptr ueStaticRouting = ipv4RoutingHelper.GetStaticRouting (ueNode->GetObject ()); + ueStaticRouting->SetDefaultRoute (epcAHelper->GetUeDefaultGatewayAddress (), 1); + } + + // Attach one UE per eNodeB + for (uint16_t i = 0; i < numberOfNodes; i++) + { + lteAHelper->Attach (ueLteADevs.Get(i), enbLteADevs.Get(i)); + // side effect: the default EPS bearer will be activated + } + + // Network B + Ptr lteBHelper = CreateObject (); + Ptr epcBHelper = CreateObject (); + lteBHelper->SetEpcHelper (epcBHelper); + + Ptr pgwB = epcBHelper->GetPgwNode (); + + NodeContainer ueNodesB; + NodeContainer enbNodesB; + enbNodesB.Create(numberOfNodes); + ueNodesB.Create(numberOfNodes); + + // Install Mobility Model + Ptr positionAllocB = CreateObject (); + for (uint16_t i = 0; i < numberOfNodes; i++) + { + positionAllocB->Add (Vector(distance * i, 500, 0)); + } + MobilityHelper mobilityB; + mobilityB.SetMobilityModel("ns3::ConstantPositionMobilityModel"); + mobilityB.SetPositionAllocator(positionAllocB); + mobilityB.Install(enbNodesB); + mobilityB.Install(ueNodesB); + + // Install LTE Devices to the nodes + NetDeviceContainer enbLteBDevs = lteBHelper->InstallEnbDevice (enbNodesB); + NetDeviceContainer ueLteBDevs = lteBHelper->InstallUeDevice (ueNodesB); + + // Install the IP stack on the UEs + internet.Install (ueNodesB); + Ipv4InterfaceContainer ueBIpIface; + ueBIpIface = epcBHelper->AssignUeIpv4Address (NetDeviceContainer (ueLteBDevs)); + // Assign IP address to UEs, and install applications + for (uint32_t u = 0; u < ueNodesB.GetN (); ++u) + { + Ptr ueNode = ueNodesB.Get (u); + // Set the default gateway for the UE + Ptr ueStaticRouting = ipv4RoutingHelper.GetStaticRouting (ueNode->GetObject ()); + ueStaticRouting->SetDefaultRoute (epcBHelper->GetUeDefaultGatewayAddress (), 1); + } + + // Attach one UE per eNodeB + for (uint16_t i = 0; i < numberOfNodes; i++) + { + lteBHelper->Attach (ueLteBDevs.Get(i), enbLteBDevs.Get(i)); + // side effect: the default EPS bearer will be activated + } + + // Create a single RemoteHost + NodeContainer remoteHostContainer; + remoteHostContainer.Create (1); + Ptr remoteHost = remoteHostContainer.Get (0); + internet.Install (remoteHostContainer); + + // Create the Internet + CsmaHelper csma; + NodeContainer internetNodes; + internetNodes.Add (remoteHost); + internetNodes.Add (pgwA); + internetNodes.Add (pgwB); + + csma.SetDeviceAttribute ("Mtu", UintegerValue (1500)); + csma.SetChannelAttribute ("DataRate", DataRateValue (DataRate ("100Gb/s"))); + csma.SetChannelAttribute ("Delay", TimeValue (Seconds (0.010))); + NetDeviceContainer internetDevices = csma.Install (internetNodes); + Ipv4AddressHelper ipv4h; + ipv4h.SetBase ("1.0.0.0", "255.0.0.0"); + Ipv4InterfaceContainer internetIpIfaces = ipv4h.Assign (internetDevices); + // interface 0 is localhost, 1 is the csma device + Ipv4Address remoteHostAddr = internetIpIfaces.GetAddress (1); + + Ptr remoteHostStaticRouting = ipv4RoutingHelper.GetStaticRouting (remoteHost->GetObject ()); + remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.255.0.0"), 1); + + + // 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 < ueNodesA.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 (ueNodesA.Get(u))); + serverApps.Add (ulPacketSinkHelper.Install (remoteHost)); + serverApps.Add (packetSinkHelper.Install (ueNodesA.Get(u))); + + UdpClientHelper dlClient (ueAIpIface.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 (ueAIpIface.GetAddress (u), otherPort); + client.SetAttribute ("Interval", TimeValue (MilliSeconds(interPacketInterval))); + client.SetAttribute ("MaxPackets", UintegerValue(1000000)); + + clientApps.Add (dlClient.Install (remoteHost)); + clientApps.Add (ulClient.Install (ueNodesA.Get(u))); + if (u+1 < ueNodesA.GetN ()) + { + clientApps.Add (client.Install (ueNodesA.Get(u+1))); + } + else + { + clientApps.Add (client.Install (ueNodesA.Get(0))); + } + } + for (uint32_t u = 0; u < ueNodesB.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 (ueNodesB.Get(u))); + serverApps.Add (ulPacketSinkHelper.Install (remoteHost)); + serverApps.Add (packetSinkHelper.Install (ueNodesB.Get(u))); + + UdpClientHelper dlClient (ueBIpIface.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 (ueBIpIface.GetAddress (u), otherPort); + client.SetAttribute ("Interval", TimeValue (MilliSeconds(interPacketInterval))); + client.SetAttribute ("MaxPackets", UintegerValue(1000000)); + + clientApps.Add (dlClient.Install (remoteHost)); + clientApps.Add (ulClient.Install (ueNodesB.Get(u))); + if (u+1 < ueNodesA.GetN ()) + { + clientApps.Add (client.Install (ueNodesB.Get(u+1))); + } + else + { + clientApps.Add (client.Install (ueNodesB.Get(0))); + } + } + serverApps.Start (Seconds (0.01)); + clientApps.Start (Seconds (0.01)); + lteAHelper->EnableTraces (); + lteBHelper->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; + +} + diff --git a/src/lte/examples/lena-x2-handover-measures.cc b/src/lte/examples/lena-x2-handover-measures.cc --- a/src/lte/examples/lena-x2-handover-measures.cc +++ b/src/lte/examples/lena-x2-handover-measures.cc @@ -206,7 +206,7 @@ Ipv4StaticRoutingHelper ipv4RoutingHelper; Ptr remoteHostStaticRouting = ipv4RoutingHelper.GetStaticRouting (remoteHost->GetObject ()); // interface 0 is localhost, 1 is the p2p device - remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.0.0.0"), 1); + remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.255.0.0"), 1); /* * Network topology: diff --git a/src/lte/examples/lena-x2-handover.cc b/src/lte/examples/lena-x2-handover.cc --- a/src/lte/examples/lena-x2-handover.cc +++ b/src/lte/examples/lena-x2-handover.cc @@ -187,7 +187,7 @@ Ipv4StaticRoutingHelper ipv4RoutingHelper; Ptr remoteHostStaticRouting = ipv4RoutingHelper.GetStaticRouting (remoteHost->GetObject ()); // interface 0 is localhost, 1 is the p2p device - remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.0.0.0"), 1); + remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.255.0.0"), 1); NodeContainer ueNodes; NodeContainer enbNodes; diff --git a/src/lte/examples/wscript b/src/lte/examples/wscript --- a/src/lte/examples/wscript +++ b/src/lte/examples/wscript @@ -34,6 +34,9 @@ obj = bld.create_ns3_program('lena-simple-epc', ['lte']) obj.source = 'lena-simple-epc.cc' + obj = bld.create_ns3_program('lena-simple-two-epc', + ['lte']) + obj.source = 'lena-simple-two-epc.cc' obj = bld.create_ns3_program('lena-deactivate-bearer', ['lte']) obj.source = 'lena-deactivate-bearer.cc' diff --git a/src/lte/helper/emu-epc-helper.cc b/src/lte/helper/emu-epc-helper.cc --- a/src/lte/helper/emu-epc-helper.cc +++ b/src/lte/helper/emu-epc-helper.cc @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -91,20 +92,38 @@ StringValue ("00:00:00:eb:00"), MakeStringAccessor (&EmuEpcHelper::m_enbMacAddressBase), MakeStringChecker ()) + .AddAttribute ("BaseIpv4Prefix", + "The 8 bit IPv4 prefix to be used for the assignment of IPv4 addresses to PGW and UE.", + Ipv4AddressValue (Ipv4Address ("7.0.0.0")), + MakeIpv4AddressAccessor (&EmuEpcHelper::m_uePgwBaseIpv4Prefix), + MakeIpv4AddressChecker ()) ; return tid; } +TypeId +EmuEpcHelper::GetInstanceTypeId () const +{ + return GetTypeId (); +} + + void EmuEpcHelper::DoInitialize () { NS_LOG_LOGIC (this); + // we use a /16 bit IPv4 net for an EPC network + m_uePgwCurrentIpv4Prefix = m_uePgwBaseIpv4Prefix.CombineMask (Ipv4Mask ("255.0.0.0")); //Initialize + Ipv4AddressGenerator::Init (m_uePgwCurrentIpv4Prefix, Ipv4Mask ("255.255.0.0")); - // we use a /8 net for all UEs - m_ueAddressHelper.SetBase ("7.0.0.0", "255.0.0.0"); + while (!Ipv4AddressGenerator::IsNetworkAllocated (m_uePgwCurrentIpv4Prefix, Ipv4Mask ("255.255.0.0"))) + { + m_uePgwCurrentIpv4Prefix = Ipv4AddressGenerator::NextNetwork (Ipv4Mask ("255.255.0.0")); + } - + m_ueAddressHelper.SetBase (m_uePgwCurrentIpv4Prefix, "255.255.0.0"); //The helper will assign IPv4 addresses using this 16 bit prefix + //Now we get an unique 16 bit IPv4 prefix for this EPC, which not used by any other EPC // create SgwPgwNode m_sgwPgw = CreateObject (); diff --git a/src/lte/helper/emu-epc-helper.h b/src/lte/helper/emu-epc-helper.h --- a/src/lte/helper/emu-epc-helper.h +++ b/src/lte/helper/emu-epc-helper.h @@ -70,9 +70,18 @@ * \return The object TypeId. */ static TypeId GetTypeId (void); + TypeId GetInstanceTypeId () const; virtual void DoInitialize (); virtual void DoDispose (); + /** + * Get the IPv4 network address used by the EPC. + * The EPC will use a /16 network address. + * + * \returns The EPC IPv4 network address. + */ + Ipv4Address GetEpcIpv4NetworkAddress (); + // inherited from EpcHelper virtual void AddEnb (Ptr enbNode, Ptr lteEnbNetDevice, uint16_t cellId); virtual void AddUe (Ptr ueLteDevice, uint64_t imsi); @@ -92,6 +101,19 @@ Ipv4AddressHelper m_ueAddressHelper; /** + * The common 8 bit prefix used for the IPv4 address assignment of + * all the EPC networks + */ + Ipv4Address m_uePgwBaseIpv4Prefix; + + /** + * The 16 bit prefix used for the IPv4 address assignment of + * the UE and PGW. + * The current IPv4 prefix will be the first available one in the /8 pool. + */ + Ipv4Address m_uePgwCurrentIpv4Prefix; + + /** * SGW-PGW network element */ Ptr m_sgwPgw; diff --git a/src/lte/helper/point-to-point-epc-helper.cc b/src/lte/helper/point-to-point-epc-helper.cc --- a/src/lte/helper/point-to-point-epc-helper.cc +++ b/src/lte/helper/point-to-point-epc-helper.cc @@ -18,6 +18,7 @@ * Author: Jaume Nin * Nicola Baldo * Manuel Requena + * Manoj Kumar Rana */ #include @@ -26,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -52,16 +54,46 @@ { NS_LOG_FUNCTION (this); + // To access the attribute value within the constructor + ObjectBase::ConstructSelf (AttributeConstructionList ()); + // since we use point-to-point links for all S1-U links, // we use a /30 subnet which can hold exactly two addresses // (remember that net broadcast and null address are not valid) - m_s1uIpv4AddressHelper.SetBase ("10.0.0.0", "255.255.255.252"); + Ipv4Address s1uIpv4AddressNet = Ipv4Address ("10.0.0.0"); + Ipv4AddressGenerator::Init (s1uIpv4AddressNet, Ipv4Mask ("255.255.0.0")); + while (!Ipv4AddressGenerator::IsNetworkAllocated (s1uIpv4AddressNet, Ipv4Mask ("255.255.0.0"))) + { + s1uIpv4AddressNet = Ipv4AddressGenerator::NextNetwork (Ipv4Mask ("255.255.0.0")); + } + m_s1uIpv4AddressHelper.SetBase (s1uIpv4AddressNet, "255.255.255.252"); - m_x2Ipv4AddressHelper.SetBase ("12.0.0.0", "255.255.255.252"); + std::cout << "m_s1uIpv4AddressHelper set to " << s1uIpv4AddressNet << std::endl; - // we use a /8 net for all UEs - m_ueAddressHelper.SetBase ("7.0.0.0", "255.0.0.0"); - + Ipv4Address x2Ipv4AddressNet = Ipv4Address ("12.0.0.0"); + Ipv4AddressGenerator::Init (x2Ipv4AddressNet, Ipv4Mask ("255.255.0.0")); + while (!Ipv4AddressGenerator::IsNetworkAllocated (x2Ipv4AddressNet, Ipv4Mask ("255.255.0.0"))) + { + x2Ipv4AddressNet = Ipv4AddressGenerator::NextNetwork (Ipv4Mask ("255.255.0.0")); + } + m_x2Ipv4AddressHelper.SetBase (x2Ipv4AddressNet, "255.255.255.252"); + + std::cout << "m_x2Ipv4AddressHelper set to " << x2Ipv4AddressNet << std::endl; + + // we use a /16 bit IPv4 net for an EPC network + m_uePgwCurrentIpv4Prefix = m_uePgwBaseIpv4Prefix.CombineMask (Ipv4Mask ("255.0.0.0")); //Initialize + Ipv4AddressGenerator::Init (m_uePgwCurrentIpv4Prefix, Ipv4Mask ("255.255.0.0")); + + while (!Ipv4AddressGenerator::IsNetworkAllocated (m_uePgwCurrentIpv4Prefix, Ipv4Mask ("255.255.0.0"))) + { + m_uePgwCurrentIpv4Prefix = Ipv4AddressGenerator::NextNetwork (Ipv4Mask ("255.255.0.0")); + } + + m_ueAddressHelper.SetBase (m_uePgwCurrentIpv4Prefix, "255.255.0.0"); //The helper will assign IPv4 addresses using this 16 bit prefix + //Now we get an unique 16 bit IPv4 prefix for this EPC, which not used by any other EPC + + std::cout << "m_ueAddressHelper set to " << m_uePgwCurrentIpv4Prefix << std::endl; + // create SgwPgwNode m_sgwPgw = CreateObject (); InternetStackHelper internet; @@ -144,10 +176,21 @@ UintegerValue (3000), MakeUintegerAccessor (&PointToPointEpcHelper::m_x2LinkMtu), MakeUintegerChecker ()) - ; + .AddAttribute ("BaseIpv4Prefix", + "The 8 bit IPv4 prefix to be used for the assignment of IPv4 addresses to PGW and UE.", + Ipv4AddressValue (Ipv4Address ("7.0.0.0")), + MakeIpv4AddressAccessor (&PointToPointEpcHelper::m_uePgwBaseIpv4Prefix), + MakeIpv4AddressChecker ()) + ; return tid; } +TypeId +PointToPointEpcHelper::GetInstanceTypeId () const +{ + return GetTypeId (); +} + void PointToPointEpcHelper::DoDispose () { @@ -184,8 +227,8 @@ NS_LOG_LOGIC ("number of Ipv4 ifaces of the eNB after installing p2p dev: " << enb->GetObject ()->GetNInterfaces ()); Ptr enbDev = enbSgwDevices.Get (0); Ptr sgwDev = enbSgwDevices.Get (1); + Ipv4InterfaceContainer enbSgwIpIfaces = m_s1uIpv4AddressHelper.Assign (enbSgwDevices); m_s1uIpv4AddressHelper.NewNetwork (); - Ipv4InterfaceContainer enbSgwIpIfaces = m_s1uIpv4AddressHelper.Assign (enbSgwDevices); NS_LOG_LOGIC ("number of Ipv4 ifaces of the eNB after assigning Ipv4 addr to S1 dev: " << enb->GetObject ()->GetNInterfaces ()); Ipv4Address enbAddress = enbSgwIpIfaces.GetAddress (0); @@ -255,8 +298,8 @@ Ptr enb1Dev = enbDevices.Get (0); Ptr enb2Dev = enbDevices.Get (1); + Ipv4InterfaceContainer enbIpIfaces = m_x2Ipv4AddressHelper.Assign (enbDevices); m_x2Ipv4AddressHelper.NewNetwork (); - Ipv4InterfaceContainer enbIpIfaces = m_x2Ipv4AddressHelper.Assign (enbDevices); NS_LOG_LOGIC ("number of Ipv4 ifaces of the eNB #1 after assigning Ipv4 addr to X2 dev: " << enb1->GetObject ()->GetNInterfaces ()); NS_LOG_LOGIC ("number of Ipv4 ifaces of the eNB #2 after assigning Ipv4 addr to X2 dev: " << enb2->GetObject ()->GetNInterfaces ()); @@ -319,22 +362,18 @@ return bearerId; } - Ptr PointToPointEpcHelper::GetPgwNode () { return m_sgwPgw; } - Ipv4InterfaceContainer PointToPointEpcHelper::AssignUeIpv4Address (NetDeviceContainer ueDevices) { return m_ueAddressHelper.Assign (ueDevices); } - - Ipv4Address PointToPointEpcHelper::GetUeDefaultGatewayAddress () { diff --git a/src/lte/helper/point-to-point-epc-helper.h b/src/lte/helper/point-to-point-epc-helper.h --- a/src/lte/helper/point-to-point-epc-helper.h +++ b/src/lte/helper/point-to-point-epc-helper.h @@ -18,6 +18,7 @@ * Author: Jaume Nin * Nicola Baldo * Manuel Requena + * Manoj Kumar Rana */ #ifndef POINT_TO_POINT_EPC_HELPER_H @@ -68,8 +69,17 @@ * \return The object TypeId. */ static TypeId GetTypeId (void); + TypeId GetInstanceTypeId () const; virtual void DoDispose (); + /** + * Get the IPv4 network address used by the EPC. + * The EPC will use a /16 network address. + * + * \returns The EPC IPv4 network address. + */ + Ipv4Address GetEpcIpv4NetworkAddress (); + // inherited from EpcHelper virtual void AddEnb (Ptr enbNode, Ptr lteEnbNetDevice, uint16_t cellId); virtual void AddUe (Ptr ueLteDevice, uint64_t imsi); @@ -84,11 +94,24 @@ private: /** - * helper to assign addresses to UE devices as well as to the TUN device of the SGW/PGW + * helper to assign IPv4 addresses to UE devices as well as to the TUN device of the SGW/PGW */ Ipv4AddressHelper m_ueAddressHelper; /** + * The common 8 bit prefix used for the IPv4 address assignment of + * all the EPC networks + */ + Ipv4Address m_uePgwBaseIpv4Prefix; + + /** + * The 16 bit prefix used for the IPv4 address assignment of + * the UE and PGW. + * The current IPv4 prefix will be the first available one in the /8 pool. + */ + Ipv4Address m_uePgwCurrentIpv4Prefix; + + /** * SGW-PGW network element */ Ptr m_sgwPgw; diff --git a/src/lte/test/epc-test-s1u-downlink.cc b/src/lte/test/epc-test-s1u-downlink.cc --- a/src/lte/test/epc-test-s1u-downlink.cc +++ b/src/lte/test/epc-test-s1u-downlink.cc @@ -153,7 +153,7 @@ Ptr remoteHostStaticRouting = ipv4RoutingHelper.GetStaticRouting (remoteHost->GetObject ()); // hardcoded UE addresses for now - remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.255.255.0"), 1); + remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.255.0.0"), 1); diff --git a/src/lte/test/epc-test-s1u-uplink.cc b/src/lte/test/epc-test-s1u-uplink.cc --- a/src/lte/test/epc-test-s1u-uplink.cc +++ b/src/lte/test/epc-test-s1u-uplink.cc @@ -370,7 +370,7 @@ Ptr remoteHostStaticRouting = ipv4RoutingHelper.GetStaticRouting (remoteHost->GetObject ()); // hardcoded UE addresses for now - remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.255.255.0"), 1); + remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.255.0.0"), 1); diff --git a/src/lte/test/lte-test-cell-selection.cc b/src/lte/test/lte-test-cell-selection.cc --- a/src/lte/test/lte-test-cell-selection.cc +++ b/src/lte/test/lte-test-cell-selection.cc @@ -308,7 +308,7 @@ // Routing of the Internet Host (towards the LTE network) Ipv4StaticRoutingHelper ipv4RoutingHelper; Ptr remoteHostStaticRouting = ipv4RoutingHelper.GetStaticRouting (remoteHost->GetObject ()); - remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.0.0.0"), 1); + remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.255.0.0"), 1); // Install the IP stack on the UEs internet.Install (ueNodes); diff --git a/src/lte/test/lte-test-cqa-ff-mac-scheduler.cc b/src/lte/test/lte-test-cqa-ff-mac-scheduler.cc --- a/src/lte/test/lte-test-cqa-ff-mac-scheduler.cc +++ b/src/lte/test/lte-test-cqa-ff-mac-scheduler.cc @@ -303,7 +303,7 @@ Ipv4StaticRoutingHelper ipv4RoutingHelper; Ptr remoteHostStaticRouting = ipv4RoutingHelper.GetStaticRouting (remoteHost->GetObject ()); - remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.0.0.0"), 1); + remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.255.0.0"), 1); //Config::SetDefault ("ns3::LteAmc::AmcModel", EnumValue (LteAmc::PiroEW2010)); //Config::SetDefault ("ns3::LteAmc::Ber", DoubleValue (0.00005)); @@ -546,7 +546,7 @@ Ipv4StaticRoutingHelper ipv4RoutingHelper; Ptr remoteHostStaticRouting = ipv4RoutingHelper.GetStaticRouting (remoteHost->GetObject ()); - remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.0.0.0"), 1); + remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.255.0.0"), 1); // LogComponentDisableAll (LOG_LEVEL_ALL); diff --git a/src/lte/test/lte-test-deactivate-bearer.cc b/src/lte/test/lte-test-deactivate-bearer.cc --- a/src/lte/test/lte-test-deactivate-bearer.cc +++ b/src/lte/test/lte-test-deactivate-bearer.cc @@ -164,7 +164,7 @@ Ipv4StaticRoutingHelper ipv4RoutingHelper; Ptr remoteHostStaticRouting = ipv4RoutingHelper.GetStaticRouting (remoteHost->GetObject ()); - remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.0.0.0"), 1); + remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.255.0.0"), 1); // LogLevel logLevel = (LogLevel)(LOG_PREFIX_FUNC | LOG_PREFIX_TIME | LOG_LEVEL_ALL); diff --git a/src/lte/test/lte-test-fdtbfq-ff-mac-scheduler.cc b/src/lte/test/lte-test-fdtbfq-ff-mac-scheduler.cc --- a/src/lte/test/lte-test-fdtbfq-ff-mac-scheduler.cc +++ b/src/lte/test/lte-test-fdtbfq-ff-mac-scheduler.cc @@ -299,7 +299,7 @@ Ipv4StaticRoutingHelper ipv4RoutingHelper; Ptr remoteHostStaticRouting = ipv4RoutingHelper.GetStaticRouting (remoteHost->GetObject ()); - remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.0.0.0"), 1); + remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.255.0.0"), 1); //Config::SetDefault ("ns3::LteAmc::AmcModel", EnumValue (LteAmc::PiroEW2010)); //Config::SetDefault ("ns3::LteAmc::Ber", DoubleValue (0.00005)); @@ -545,7 +545,7 @@ Ipv4StaticRoutingHelper ipv4RoutingHelper; Ptr remoteHostStaticRouting = ipv4RoutingHelper.GetStaticRouting (remoteHost->GetObject ()); - remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.0.0.0"), 1); + remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.255.0.0"), 1); // LogComponentDisableAll (LOG_LEVEL_ALL); diff --git a/src/lte/test/lte-test-frequency-reuse.cc b/src/lte/test/lte-test-frequency-reuse.cc --- a/src/lte/test/lte-test-frequency-reuse.cc +++ b/src/lte/test/lte-test-frequency-reuse.cc @@ -1464,7 +1464,7 @@ Ipv4StaticRoutingHelper ipv4RoutingHelper; Ptr remoteHostStaticRouting = ipv4RoutingHelper.GetStaticRouting (remoteHost->GetObject ()); // interface 0 is localhost, 1 is the p2p device - remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.0.0.0"), 1); + remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.255.0.0"), 1); // Create Nodes: eNodeB and UE NodeContainer enbNodes; diff --git a/src/lte/test/lte-test-pss-ff-mac-scheduler.cc b/src/lte/test/lte-test-pss-ff-mac-scheduler.cc --- a/src/lte/test/lte-test-pss-ff-mac-scheduler.cc +++ b/src/lte/test/lte-test-pss-ff-mac-scheduler.cc @@ -300,7 +300,7 @@ Ipv4StaticRoutingHelper ipv4RoutingHelper; Ptr remoteHostStaticRouting = ipv4RoutingHelper.GetStaticRouting (remoteHost->GetObject ()); - remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.0.0.0"), 1); + remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.255.0.0"), 1); //Config::SetDefault ("ns3::LteAmc::AmcModel", EnumValue (LteAmc::PiroEW2010)); //Config::SetDefault ("ns3::LteAmc::Ber", DoubleValue (0.00005)); @@ -546,7 +546,7 @@ Ipv4StaticRoutingHelper ipv4RoutingHelper; Ptr remoteHostStaticRouting = ipv4RoutingHelper.GetStaticRouting (remoteHost->GetObject ()); - remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.0.0.0"), 1); + remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.255.0.0"), 1); // LogComponentDisableAll (LOG_LEVEL_ALL); diff --git a/src/lte/test/lte-test-tdtbfq-ff-mac-scheduler.cc b/src/lte/test/lte-test-tdtbfq-ff-mac-scheduler.cc --- a/src/lte/test/lte-test-tdtbfq-ff-mac-scheduler.cc +++ b/src/lte/test/lte-test-tdtbfq-ff-mac-scheduler.cc @@ -299,7 +299,7 @@ Ipv4StaticRoutingHelper ipv4RoutingHelper; Ptr remoteHostStaticRouting = ipv4RoutingHelper.GetStaticRouting (remoteHost->GetObject ()); - remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.0.0.0"), 1); + remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.255.0.0"), 1); //Config::SetDefault ("ns3::LteAmc::AmcModel", EnumValue (LteAmc::PiroEW2010)); //Config::SetDefault ("ns3::LteAmc::Ber", DoubleValue (0.00005)); @@ -545,7 +545,7 @@ Ipv4StaticRoutingHelper ipv4RoutingHelper; Ptr remoteHostStaticRouting = ipv4RoutingHelper.GetStaticRouting (remoteHost->GetObject ()); - remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.0.0.0"), 1); + remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.255.0.0"), 1); // LogComponentDisableAll (LOG_LEVEL_ALL); diff --git a/src/lte/test/lte-test-ue-measurements.cc b/src/lte/test/lte-test-ue-measurements.cc --- a/src/lte/test/lte-test-ue-measurements.cc +++ b/src/lte/test/lte-test-ue-measurements.cc @@ -1744,7 +1744,7 @@ // Routing of the Internet Host (towards the LTE network) Ipv4StaticRoutingHelper ipv4RoutingHelper; Ptr remoteHostStaticRouting = ipv4RoutingHelper.GetStaticRouting (remoteHost->GetObject ()); - remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.0.0.0"), 1); + remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.255.0.0"), 1); // Enable layer-3 filtering Config::SetDefault ("ns3::LteEnbRrc::RsrpFilterCoefficient", diff --git a/src/lte/test/test-lte-epc-e2e-data.cc b/src/lte/test/test-lte-epc-e2e-data.cc --- a/src/lte/test/test-lte-epc-e2e-data.cc +++ b/src/lte/test/test-lte-epc-e2e-data.cc @@ -177,7 +177,7 @@ Ptr remoteHostStaticRouting = ipv4RoutingHelper.GetStaticRouting (remoteHost->GetObject ()); // hardcoded UE addresses for now - remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.255.255.0"), 1); + remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.255.0.0"), 1); NodeContainer enbs; diff --git a/src/lte/test/test-lte-handover-target.cc b/src/lte/test/test-lte-handover-target.cc --- a/src/lte/test/test-lte-handover-target.cc +++ b/src/lte/test/test-lte-handover-target.cc @@ -318,7 +318,7 @@ // Routing of the Internet Host (towards the LTE network) Ipv4StaticRoutingHelper ipv4RoutingHelper; Ptr remoteHostStaticRouting = ipv4RoutingHelper.GetStaticRouting (remoteHost->GetObject ()); - remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.0.0.0"), 1); + remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.255.0.0"), 1); // Create Devices and install them in the Nodes (eNB and UE) NetDeviceContainer enbDevs; diff --git a/src/lte/test/test-lte-x2-handover.cc b/src/lte/test/test-lte-x2-handover.cc --- a/src/lte/test/test-lte-x2-handover.cc +++ b/src/lte/test/test-lte-x2-handover.cc @@ -280,7 +280,7 @@ Ipv4StaticRoutingHelper ipv4RoutingHelper; Ptr remoteHostStaticRouting = ipv4RoutingHelper.GetStaticRouting (remoteHost->GetObject ()); - remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.0.0.0"), 1); + remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.255.0.0"), 1); // Install the IP stack on the UEs internet.Install (ueNodes);