23 #include "ns3/boolean.h"
24 #include "ns3/epc-enb-application.h"
25 #include "ns3/epc-mme-application.h"
26 #include "ns3/epc-pgw-application.h"
27 #include "ns3/epc-sgw-application.h"
28 #include "ns3/epc-ue-nas.h"
29 #include "ns3/epc-x2.h"
30 #include "ns3/icmpv6-l4-protocol.h"
31 #include "ns3/internet-stack-helper.h"
32 #include "ns3/ipv6-static-routing-helper.h"
34 #include "ns3/lte-enb-net-device.h"
35 #include "ns3/lte-enb-rrc.h"
36 #include "ns3/lte-ue-net-device.h"
37 #include "ns3/packet-socket-address.h"
38 #include "ns3/point-to-point-helper.h"
39 #include "ns3/string.h"
49 : m_gtpuUdpPort(2152),
50 m_s11LinkDataRate(
DataRate(
"10Gb/s")),
54 m_s5LinkDataRate(
DataRate(
"10Gb/s")),
78 m_pgw = CreateObject<Node>();
79 m_sgw = CreateObject<Node>();
80 m_mme = CreateObject<Node>();
127 NS_LOG_LOGIC(
"IPv4 ifaces of the PGW after installing p2p dev: "
129 NS_LOG_LOGIC(
"IPv4 ifaces of the SGW after installing p2p dev: "
135 NS_LOG_LOGIC(
"IPv4 ifaces of the PGW after assigning Ipv4 addr to S5 dev: "
137 NS_LOG_LOGIC(
"IPv4 ifaces of the SGW after assigning Ipv4 addr to S5 dev: "
157 CreateObject<EpcPgwApplication>(
m_tunDevice, pgwS5Address, pgwS5uSocket, pgwS5cSocket);
183 CreateObject<EpcSgwApplication>(sgwS1uSocket, sgwS5Address, sgwS5uSocket, sgwS5cSocket);
194 NS_LOG_LOGIC(
"MME's IPv4 ifaces after installing p2p dev: "
196 NS_LOG_LOGIC(
"SGW's IPv4 ifaces after installing p2p dev: "
202 NS_LOG_LOGIC(
"MME's IPv4 ifaces after assigning Ipv4 addr to S11 dev: "
204 NS_LOG_LOGIC(
"SGW's IPv4 ifaces after assigning Ipv4 addr to S11 dev: "
223 m_mmeApp = CreateObject<EpcMmeApplication>();
225 m_mmeApp->AddSgw(sgwS11Address, mmeS11Address, mmeS11Socket);
226 m_sgwApp->AddMme(mmeS11Address, sgwS11Socket);
239 TypeId(
"ns3::NoBackhaulEpcHelper")
243 .AddAttribute(
"S5LinkDataRate",
244 "The data rate to be used for the next S5 link to be created",
247 MakeDataRateChecker())
248 .AddAttribute(
"S5LinkDelay",
249 "The delay to be used for the next S5 link to be created",
253 .AddAttribute(
"S5LinkMtu",
254 "The MTU of the next S5 link to be created",
257 MakeUintegerChecker<uint16_t>())
258 .AddAttribute(
"S11LinkDataRate",
259 "The data rate to be used for the next S11 link to be created",
262 MakeDataRateChecker())
263 .AddAttribute(
"S11LinkDelay",
264 "The delay to be used for the next S11 link to be created",
268 .AddAttribute(
"S11LinkMtu",
269 "The MTU of the next S11 link to be created.",
272 MakeUintegerChecker<uint16_t>())
273 .AddAttribute(
"X2LinkDataRate",
274 "The data rate to be used for the next X2 link to be created",
277 MakeDataRateChecker())
278 .AddAttribute(
"X2LinkDelay",
279 "The delay to be used for the next X2 link to be created",
283 .AddAttribute(
"X2LinkMtu",
284 "The MTU of the next X2 link to be created. Note that, because of some "
285 "big X2 messages, you need a big MTU.",
288 MakeUintegerChecker<uint16_t>())
289 .AddAttribute(
"X2LinkPcapPrefix",
290 "Prefix for Pcap generated by X2 link",
294 .AddAttribute(
"X2LinkEnablePcap",
295 "Enable Pcap for X2 link",
326 std::vector<uint16_t> cellIds)
329 NS_ASSERT(enb == lteEnbNetDevice->GetNode());
336 NS_LOG_LOGIC(
"number of Ipv4 ifaces of the eNB after node creation: "
343 enbLteSocketBindAddress.
SetSingleDevice(lteEnbNetDevice->GetIfIndex());
345 retval = enbLteSocket->
Bind(enbLteSocketBindAddress);
349 enbLteSocketConnectAddress.
SetSingleDevice(lteEnbNetDevice->GetIfIndex());
351 retval = enbLteSocket->
Connect(enbLteSocketConnectAddress);
358 enbLteSocketBindAddress6.
SetSingleDevice(lteEnbNetDevice->GetIfIndex());
360 retval = enbLteSocket6->
Bind(enbLteSocketBindAddress6);
364 enbLteSocketConnectAddress6.
SetSingleDevice(lteEnbNetDevice->GetIfIndex());
366 retval = enbLteSocket6->
Connect(enbLteSocketConnectAddress6);
369 NS_LOG_INFO(
"Create EpcEnbApplication for cell ID " << cellIds.at(0));
371 CreateObject<EpcEnbApplication>(enbLteSocket, enbLteSocket6, cellIds.at(0));
375 "cannot retrieve EpcEnbApplication");
395 NS_LOG_LOGIC(
"number of Ipv4 ifaces of the eNB #1 after installing p2p dev: "
397 NS_LOG_LOGIC(
"number of Ipv4 ifaces of the eNB #2 after installing p2p dev: "
407 NS_LOG_LOGIC(
"number of Ipv4 ifaces of the eNB #1 after assigning Ipv4 addr to X2 dev: "
409 NS_LOG_LOGIC(
"number of Ipv4 ifaces of the eNB #2 after assigning Ipv4 addr to X2 dev: "
422 DoAddX2Interface(enb1X2, enb1LteDev, enb1X2Address, enb2X2, enb2LteDev, enb2X2Address);
438 NS_ABORT_MSG_IF(!enb1LteDevice,
"Unable to find LteEnbNetDevice for the first eNB");
439 NS_ABORT_MSG_IF(!enb2LteDevice,
"Unable to find LteEnbNetDevice for the second eNB");
441 std::vector<uint16_t> enb1CellIds = enb1LteDevice->
GetCellIds();
442 std::vector<uint16_t> enb2CellIds = enb2LteDevice->GetCellIds();
444 uint16_t enb1CellId = enb1CellIds.at(0);
445 uint16_t enb2CellId = enb2CellIds.at(0);
447 NS_LOG_LOGIC(
"LteEnbNetDevice #1 = " << enb1LteDev <<
" - CellId = " << enb1CellId);
448 NS_LOG_LOGIC(
"LteEnbNetDevice #2 = " << enb2LteDev <<
" - CellId = " << enb2CellId);
450 enb1X2->AddX2Interface(enb1CellId, enb1X2Address, enb2CellIds, enb2X2Address);
451 enb2X2->AddX2Interface(enb2CellId, enb2X2Address, enb1CellIds, enb1X2Address);
453 enb1LteDevice->
GetRrc()->AddX2Neighbour(enb2CellId);
454 enb2LteDevice->GetRrc()->AddX2Neighbour(enb1CellId);
481 "UEs need to have IPv4/IPv6 installed before EPS bearers can be activated");
485 int32_t
interface = ueIpv4->GetInterfaceForDevice(ueDevice);
486 if (interface >= 0 && ueIpv4->GetNAddresses(interface) == 1)
488 Ipv4Address ueAddr = ueIpv4->GetAddress(interface, 0).GetLocal();
490 m_pgwApp->SetUeAddress(imsi, ueAddr);
495 int32_t interface6 = ueIpv6->GetInterfaceForDevice(ueDevice);
496 if (interface6 >= 0 && ueIpv6->GetNAddresses(interface6) == 2)
498 Ipv6Address ueAddr6 = ueIpv6->GetAddress(interface6, 1).GetAddress();
500 m_pgwApp->SetUeAddress6(imsi, ueAddr6);
503 uint8_t bearerId =
m_mmeApp->AddBearer(imsi, tft, bearer);
520 NS_LOG_WARN(
"Unable to find LteUeNetDevice while activating the EPS bearer");
543 for (
auto iter = ueDevices.
Begin(); iter != ueDevices.
End(); iter++)
575 std::vector<uint16_t> cellIds)
577 NS_LOG_FUNCTION(
this << enb << enbAddress << sgwAddress << cellIds.size());
587 enbApp->AddS1Interface(enbS1uSocket, enbAddress, sgwAddress);
590 for (uint16_t cellId : cellIds)
592 NS_LOG_DEBUG(
"Adding MME and SGW for cell ID " << cellId);
593 m_mmeApp->AddEnb(cellId, enbAddress, enbApp->GetS1apSapEnb());
594 m_sgwApp->AddEnb(cellId, enbAddress, sgwAddress);
596 enbApp->SetS1apSapMme(
m_mmeApp->GetS1apSapMme());
602 int64_t currentStream = stream;
609 currentStream +=
internet.AssignStreams(nc, currentStream);
610 return (currentStream - stream);
a polymophic address class
List of Attribute name, value and checker triples used to construct Objects.
Class for representing data rates.
This application is installed inside eNBs and provides the bridge functionality for user data plane p...
Base helper class to handle the creation of the EPC entities.
bool RecvFromTunDevice(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)
Method to be assigned to the callback of the SGi TUN VirtualNetDevice.
void ActivateEpsBearer(EpsBearer bearer, Ptr< EpcTft > tft)
Activate an EPS bearer.
This entity is installed inside an eNB and provides the functionality for the X2 interface.
This class contains the specification of EPS Bearers.
An implementation of the ICMPv6 protocol.
aggregate IP/TCP/UDP functionality to existing Nodes.
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
Ipv4Address NewNetwork()
Increment the network number and reset the IP address counter to the base value provided in the SetBa...
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
Ipv4 addresses are stored in host order in this class.
static Ipv4Address GetAny()
Access to the IPv4 forwarding table, interfaces, and configuration.
virtual uint32_t GetNInterfaces() const =0
holds a vector of std::pair of Ptr<Ipv4> and interface index.
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
static const uint16_t PROT_NUMBER
Protocol number (0x0800)
void SetBase(Ipv6Address network, Ipv6Prefix prefix, Ipv6Address base=Ipv6Address("::1"))
Set the base network number, network prefix, and base interface ID.
Ipv6InterfaceContainer Assign(const NetDeviceContainer &c)
Allocate an Ipv6InterfaceContainer with auto-assigned addresses.
Describes an IPv6 address.
Access to the IPv6 forwarding table, interfaces, and configuration.
virtual Ipv6InterfaceAddress GetAddress(uint32_t interface, uint32_t addressIndex) const =0
Get IPv6 address on specified IPv6 interface.
Keep track of a set of IPv6 interfaces.
void SetForwarding(uint32_t i, bool state)
Set the state of the stack (act as a router or as an host) for the specified index.
void SetDefaultRouteInAllNodes(uint32_t router)
Set the default route for all the devices (except the router itself).
static const uint16_t PROT_NUMBER
The protocol number for IPv6 (0x86DD).
Describes an IPv6 prefix.
Helper class that adds ns3::Ipv6StaticRouting objects.
Ptr< Ipv6StaticRouting > GetStaticRouting(Ptr< Ipv6 > ipv6) const
Get Ipv6StaticRouting pointer from IPv6 stack.
The eNodeB device implementation.
Ptr< LteEnbRrc > GetRrc() const
std::vector< uint16_t > GetCellIds() const
static Mac48Address GetBroadcast()
static Mac48Address Allocate()
Allocate a new Mac48Address.
holds a vector of ns3::NetDevice pointers
Iterator Begin() const
Get an iterator which refers to the first NetDevice in the container.
void Add(NetDeviceContainer other)
Append the contents of another NetDeviceContainer to the end of this container.
Iterator End() const
Get an iterator which indicates past-the-last NetDevice in the container.
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
Create an EPC network with PointToPoint links between the core network nodes.
uint16_t m_s5LinkMtu
The MTU of the next S5 link to be created.
static TypeId GetTypeId()
Register this type.
Ptr< VirtualNetDevice > m_tunDevice
TUN device implementing tunneling of user data over GTP-U/UDP/IP.
Time m_s5LinkDelay
The delay to be used for the next S5 link to be created.
Ipv4AddressHelper m_x2Ipv4AddressHelper
helper to assign addresses to X2 NetDevices
Ptr< Node > m_sgw
SGW network element.
~NoBackhaulEpcHelper() override
Destructor.
Ptr< EpcSgwApplication > m_sgwApp
SGW application.
DataRate m_x2LinkDataRate
The data rate to be used for the next X2 link to be created.
Ptr< Node > m_mme
MME network element.
Ipv4AddressHelper m_uePgwAddressHelper
helper to assign IPv4 addresses to UE devices as well as to the TUN device of the SGW/PGW
Ptr< Node > GetSgwNode() const override
Get the SGW node.
Ptr< EpcMmeApplication > m_mmeApp
MME application.
void AddUe(Ptr< NetDevice > ueLteDevice, uint64_t imsi) override
Notify the EPC of the existence of a new UE which might attach at a later time.
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
uint16_t m_s11LinkMtu
The MTU of the next S11 link to be created.
std::string m_x2LinkPcapPrefix
Prefix for the PCAP file for the X2 link.
bool m_x2LinkEnablePcap
Enable PCAP generation for X2 link.
Ipv6Address GetUeDefaultGatewayAddress6() override
uint8_t ActivateEpsBearer(Ptr< NetDevice > ueLteDevice, uint64_t imsi, Ptr< EpcTft > tft, EpsBearer bearer) override
Activate an EPS bearer, setting up the corresponding S1-U tunnel.
Ptr< Node > GetPgwNode() const override
Get the PGW node.
void DoDispose() override
Destructor implementation.
NoBackhaulEpcHelper()
Constructor.
Ipv4AddressHelper m_s5Ipv4AddressHelper
S5 interfaces.
uint16_t m_x2LinkMtu
The MTU of the next X2 link to be created.
Ipv6InterfaceContainer AssignUeIpv6Address(NetDeviceContainer ueDevices) override
Assign IPv6 addresses to UE devices.
uint16_t m_gtpcUdpPort
UDP port where the GTPv2-C Socket is bound, fixed by the standard as 2123.
void AddS1Interface(Ptr< Node > enb, Ipv4Address enbAddress, Ipv4Address sgwAddress, std::vector< uint16_t > cellIds) override
Add an S1 interface between an eNB and a SGW.
void AddX2Interface(Ptr< Node > enbNode1, Ptr< Node > enbNode2) override
Add an X2 interface between two eNB.
Ptr< EpcPgwApplication > m_pgwApp
PGW application.
uint16_t m_gtpuUdpPort
UDP port where the GTP-U Socket is bound, fixed by the standard as 2152.
virtual void DoAddX2Interface(const Ptr< EpcX2 > &enb1X2, const Ptr< NetDevice > &enb1LteDev, const Ipv4Address &enb1X2Address, const Ptr< EpcX2 > &enb2X2, const Ptr< NetDevice > &enb2LteDev, const Ipv4Address &enb2X2Address) const
DoAddX2Interface: Call AddX2Interface on top of the Enb device pointers.
Time m_x2LinkDelay
The delay to be used for the next X2 link to be created.
Ipv4AddressHelper m_s11Ipv4AddressHelper
Helper to assign addresses to S11 NetDevices.
int64_t AssignStreams(int64_t stream) override
Assign a fixed random variable stream number to the random variables used.
Ipv4Address GetUeDefaultGatewayAddress() override
Ipv4InterfaceContainer AssignUeIpv4Address(NetDeviceContainer ueDevices) override
Assign IPv4 addresses to UE devices.
Time m_s11LinkDelay
The delay to be used for the next S11 link to be created.
Ptr< Node > m_pgw
PGW network element.
DataRate m_s11LinkDataRate
The data rate to be used for the next S11 link to be created.
Ipv6AddressHelper m_uePgwAddressHelper6
helper to assign IPv6 addresses to UE devices as well as to the TUN device of the SGW/PGW
void AddEnb(Ptr< Node > enbNode, Ptr< NetDevice > lteEnbNetDevice, std::vector< uint16_t > cellIds) override
Add an eNB to the EPC.
virtual void DoActivateEpsBearerForUe(const Ptr< NetDevice > &ueDevice, const Ptr< EpcTft > &tft, const EpsBearer &bearer) const
DoActivateEpsBearerForUe: Schedule ActivateEpsBearer on the UE.
DataRate m_s5LinkDataRate
The data rate to be used for the next S5 link to be created.
keep track of a set of node pointers.
void Add(const NodeContainer &nc)
Append the contents of another NodeContainer to the end of this container.
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
uint32_t GetNApplications() const
Ptr< Application > GetApplication(uint32_t index) const
Retrieve the index-th Application associated to this node.
uint32_t AddApplication(Ptr< Application > application)
Associate an Application to this Node.
Ptr< NetDevice > GetDevice(uint32_t index) const
Retrieve the index-th NetDevice associated to this node.
void ConstructSelf(const AttributeConstructionList &attributes)
Complete construction of ObjectBase; invoked by derived classes.
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
void AggregateObject(Ptr< Object > other)
Aggregate two Objects together.
void Dispose()
Dispose of this Object.
an address for a packet socket
void SetProtocol(uint16_t protocol)
Set the protocol.
void SetPhysicalAddress(const Address address)
Set the destination address.
void SetSingleDevice(uint32_t device)
Set the address to match only a specified NetDevice.
void EnablePcapAll(std::string prefix, bool promiscuous=false)
Enable pcap output on each device (which is of the appropriate type) in the set of all nodes created ...
Build a set of PointToPointNetDevice objects.
void SetDeviceAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each NetDevice created by the helper.
void SetChannelAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each Channel created by the helper.
NetDeviceContainer Install(NodeContainer c)
Smart pointer class similar to boost::intrusive_ptr.
static EventId ScheduleNow(FUNC f, Ts &&... args)
Schedule an event to expire Now.
virtual int Connect(const Address &address)=0
Initiate a connection to a remote host.
static Ptr< Socket > CreateSocket(Ptr< Node > node, TypeId tid)
This method wraps the creation of sockets that is performed on a given node by a SocketFactory specif...
virtual int Bind(const Address &address)=0
Allocate a local endpoint for this socket.
Hold variables of type string.
a unique identifier for an interface.
static TypeId LookupByName(std::string name)
Get a TypeId by name.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Hold an unsigned integer type.
void SetAddress(Address address) override
Set the address of this interface.
void SetSendCallback(SendCallback transmitCb)
Set the user callback to be called when a L2 packet is to be transmitted.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Callback< R, Args... > MakeNullCallback()
#define NS_ABORT_MSG_UNLESS(cond, msg)
Abnormal program termination if a condition is false, with a message.
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
void(* DataRate)(DataRate oldValue, DataRate newValue)
TracedValue callback signature for DataRate.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Time Seconds(double value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeBooleanChecker()
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Ptr< const AttributeChecker > MakeStringChecker()
Ptr< const AttributeAccessor > MakeStringAccessor(T1 a1)