|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
22 #include "ns3/boolean.h"
23 #include "ns3/string.h"
25 #include "ns3/packet-socket-address.h"
26 #include "ns3/point-to-point-helper.h"
27 #include "ns3/internet-stack-helper.h"
28 #include "ns3/ipv6-static-routing-helper.h"
29 #include "ns3/icmpv6-l4-protocol.h"
30 #include "ns3/epc-enb-application.h"
31 #include "ns3/epc-pgw-application.h"
32 #include "ns3/epc-sgw-application.h"
33 #include "ns3/epc-mme-application.h"
34 #include "ns3/epc-x2.h"
35 #include "ns3/lte-enb-rrc.h"
36 #include "ns3/epc-ue-nas.h"
37 #include "ns3/lte-enb-net-device.h"
38 #include "ns3/lte-ue-net-device.h"
40 #include "ns3/no-backhaul-epc-helper.h"
50 : m_gtpuUdpPort (2152),
51 m_s11LinkDataRate (
DataRate (
"10Gb/s")),
55 m_s5LinkDataRate (
DataRate (
"10Gb/s")),
79 m_pgw = CreateObject<Node> ();
80 m_sgw = CreateObject<Node> ();
81 m_mme = CreateObject<Node> ();
151 m_pgwApp = CreateObject<EpcPgwApplication> (
m_tunDevice, pgwS5Address, pgwS5uSocket, pgwS5cSocket);
174 m_sgwApp = CreateObject<EpcSgwApplication> (sgwS1uSocket, sgwS5Address, sgwS5uSocket, sgwS5cSocket);
210 m_mmeApp = CreateObject<EpcMmeApplication> ();
212 m_mmeApp->AddSgw (sgwS11Address, mmeS11Address, mmeS11Socket);
213 m_sgwApp->AddMme (mmeS11Address, sgwS11Socket);
229 .AddAttribute (
"S5LinkDataRate",
230 "The data rate to be used for the next S5 link to be created",
234 .AddAttribute (
"S5LinkDelay",
235 "The delay to be used for the next S5 link to be created",
239 .AddAttribute (
"S5LinkMtu",
240 "The MTU of the next S5 link to be created",
243 MakeUintegerChecker<uint16_t> ())
244 .AddAttribute (
"S11LinkDataRate",
245 "The data rate to be used for the next S11 link to be created",
249 .AddAttribute (
"S11LinkDelay",
250 "The delay to be used for the next S11 link to be created",
254 .AddAttribute (
"S11LinkMtu",
255 "The MTU of the next S11 link to be created.",
258 MakeUintegerChecker<uint16_t> ())
259 .AddAttribute (
"X2LinkDataRate",
260 "The data rate to be used for the next X2 link to be created",
264 .AddAttribute (
"X2LinkDelay",
265 "The delay to be used for the next X2 link to be created",
269 .AddAttribute (
"X2LinkMtu",
270 "The MTU of the next X2 link to be created. Note that, because of some big X2 messages, you need a big MTU.",
273 MakeUintegerChecker<uint16_t> ())
274 .AddAttribute (
"X2LinkPcapPrefix",
275 "Prefix for Pcap generated by X2 link",
279 .AddAttribute (
"X2LinkEnablePcap",
280 "Enable Pcap for X2 link",
327 retval = enbLteSocket->
Bind (enbLteSocketBindAddress);
333 retval = enbLteSocket->
Connect (enbLteSocketConnectAddress);
341 retval = enbLteSocket6->
Bind (enbLteSocketBindAddress6);
347 retval = enbLteSocket6->
Connect (enbLteSocketConnectAddress6);
398 DoAddX2Interface (enb1X2, enb1LteDev, enb1X2Address, enb2X2, enb2LteDev, enb2X2Address);
412 NS_ABORT_MSG_IF (enb1LteDevice ==
nullptr ,
"Unable to find LteEnbNetDevice for the first eNB");
413 NS_ABORT_MSG_IF (enb2LteDevice ==
nullptr ,
"Unable to find LteEnbNetDevice for the second eNB");
415 uint16_t enb1CellId = enb1LteDevice->
GetCellId ();
416 uint16_t enb2CellId = enb2LteDevice->GetCellId ();
418 NS_LOG_LOGIC (
"LteEnbNetDevice #1 = " << enb1LteDev <<
" - CellId = " << enb1CellId);
419 NS_LOG_LOGIC (
"LteEnbNetDevice #2 = " << enb2LteDev <<
" - CellId = " << enb2CellId);
421 enb1X2->AddX2Interface (enb1CellId, enb1X2Address, enb2CellId, enb2X2Address);
422 enb2X2->AddX2Interface (enb2CellId, enb2X2Address, enb1CellId, enb1X2Address);
424 enb1LteDevice->
GetRrc ()->AddX2Neighbour (enb2CellId);
425 enb2LteDevice->GetRrc ()->AddX2Neighbour (enb1CellId);
450 NS_ASSERT_MSG (ueIpv4 != 0 || ueIpv6 != 0,
"UEs need to have IPv4/IPv6 installed before EPS bearers can be activated");
454 int32_t
interface = ueIpv4->GetInterfaceForDevice (ueDevice);
455 if (interface >= 0 && ueIpv4->GetNAddresses (interface) == 1)
457 Ipv4Address ueAddr = ueIpv4->GetAddress (interface, 0).GetLocal ();
459 m_pgwApp->SetUeAddress (imsi, ueAddr);
464 int32_t interface6 = ueIpv6->GetInterfaceForDevice (ueDevice);
465 if (interface6 >= 0 && ueIpv6->GetNAddresses (interface6) == 2)
467 Ipv6Address ueAddr6 = ueIpv6->GetAddress (interface6, 1).GetAddress ();
469 m_pgwApp->SetUeAddress6 (imsi, ueAddr6);
472 uint8_t bearerId =
m_mmeApp->AddBearer (imsi, tft, bearer);
485 if (ueLteDevice ==
nullptr)
489 NS_LOG_WARN (
"Unable to find LteUeNetDevice while activating the EPS bearer");
513 iter != ueDevices.
End ();
555 NS_ASSERT_MSG (enbApp != 0,
"EpcEnbApplication not available");
556 enbApp->AddS1Interface (enbS1uSocket, enbAddress, sgwAddress);
565 m_mmeApp->AddEnb (cellId, enbAddress, enbApp->GetS1apSapEnb ());
566 m_sgwApp->AddEnb (cellId, enbAddress, sgwAddress);
567 enbApp->SetS1apSapMme (
m_mmeApp->GetS1apSapMme ());
holds a vector of ns3::NetDevice pointers
a unique identifier for an interface.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
AttributeValue implementation for DataRate.
Ptr< Application > GetApplication(uint32_t index) const
Retrieve the index-th Application associated to this node.
void Dispose(void)
Dispose of this Object.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Ipv4AddressHelper m_x2Ipv4AddressHelper
helper to assign addresses to X2 NetDevices
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
AttributeValue implementation for Boolean.
This application is installed inside eNBs and provides the bridge functionality for user data plane p...
virtual int Bind(const Address &address)=0
Allocate a local endpoint for this socket.
virtual Ptr< Node > GetPgwNode() const
Get the PGW node.
uint16_t GetCellId() const
Ipv4Address NewNetwork(void)
Increment the network number and reset the IP address counter to the base value provided in the SetBa...
DataRate m_s5LinkDataRate
The data rate to be used for the next S5 link to be created.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
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.
This entity is installed inside an eNB and provides the functionality for the X2 interface.
Ptr< const AttributeAccessor > MakeDataRateAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
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.
virtual void AddEnb(Ptr< Node > enbNode, Ptr< NetDevice > lteEnbNetDevice, uint16_t cellId)
Add an eNB to the EPC.
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 ...
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
virtual void SetAddress(Address address)
Set the address of this interface.
Ipv4AddressHelper m_uePgwAddressHelper
helper to assign IPv4 addresses to UE devices as well as to the TUN device of the SGW/PGW
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
NoBackhaulEpcHelper()
Constructor.
void SetSendCallback(SendCallback transmitCb)
Set the user callback to be called when a L2 packet is to be transmitted.
NetDeviceContainer Install(NodeContainer c)
Ipv4 addresses are stored in host order in this class.
Ipv6AddressHelper m_uePgwAddressHelper6
helper to assign IPv6 addresses to UE devices as well as to the TUN device of the SGW/PGW
Describes an IPv6 address.
an address for a packet socket
uint16_t m_gtpcUdpPort
UDP port where the GTPv2-C Socket is bound, fixed by the standard as 2123.
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Time m_s11LinkDelay
The delay to be used for the next S11 link to be created.
void SetBase(Ipv6Address network, Ipv6Prefix prefix, Ipv6Address base=Ipv6Address("::1"))
Set the base network number, network prefix, and base interface ID.
void SetDefaultRouteInAllNodes(uint32_t router)
Set the default route for all the devices (except the router itself).
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
void ConstructSelf(const AttributeConstructionList &attributes)
Complete construction of ObjectBase; invoked by derived classes.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Callback< R, Ts... > MakeNullCallback(void)
Ptr< VirtualNetDevice > m_tunDevice
TUN device implementing tunneling of user data over GTP-U/UDP/IP.
virtual Ipv4Address GetUeDefaultGatewayAddress()
virtual uint8_t ActivateEpsBearer(Ptr< NetDevice > ueLteDevice, uint64_t imsi, Ptr< EpcTft > tft, EpsBearer bearer)
Activate an EPS bearer, setting up the corresponding S1-U tunnel.
Ptr< LteEnbRrc > GetRrc() const
Ptr< Node > m_pgw
PGW network element.
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
Access to the IPv4 forwarding table, interfaces, and configuration.
Ipv6InterfaceContainer Assign(const NetDeviceContainer &c)
Allocate an Ipv6InterfaceContainer with auto-assigned addresses.
Smart pointer class similar to boost::intrusive_ptr.
Time m_s5LinkDelay
The delay to be used for the next S5 link to be created.
Class for representing data rates.
static Mac48Address GetBroadcast(void)
virtual void DoDispose()
Destructor implementation.
virtual void AddX2Interface(Ptr< Node > enbNode1, Ptr< Node > enbNode2)
Add an X2 interface between two eNB.
Iterator Begin(void) const
Get an iterator which refers to the first NetDevice in the container.
Ptr< EpcMmeApplication > m_mmeApp
MME application.
uint16_t m_x2LinkMtu
The MTU of the next X2 link to be created.
a polymophic address class
Ptr< Node > m_mme
MME network element.
Ptr< Node > m_sgw
SGW network element.
virtual void AddS1Interface(Ptr< Node > enb, Ipv4Address enbAddress, Ipv4Address sgwAddress, uint16_t cellId=0)
Add an S1 interface between an eNB and a SGW.
void Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
virtual Ipv4InterfaceContainer AssignUeIpv4Address(NetDeviceContainer ueDevices)
Assign IPv4 addresses to UE devices.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
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.
static Mac48Address Allocate(void)
Allocate a new Mac48Address.
virtual Ptr< Node > GetNode(void) const =0
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 AggregateObject(Ptr< Object > other)
Aggregate two Objects together.
holds a vector of std::pair of Ptr<Ipv4> and interface index.
Keep track of a set of IPv6 interfaces.
Ptr< const AttributeChecker > MakeBooleanChecker(void)
Ipv4AddressHelper m_s11Ipv4AddressHelper
Helper to assign addresses to S11 NetDevices.
Ptr< EpcSgwApplication > m_sgwApp
SGW application.
void ActivateEpsBearer(EpsBearer bearer, Ptr< EpcTft > tft)
Activate an EPS bearer.
Helper class that adds ns3::Ipv6StaticRouting objects.
Create an EPC network with PointToPoint links between the core network nodes.
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
void SetSingleDevice(uint32_t device)
Set the address to match only a specified NetDevice.
virtual Ipv6InterfaceContainer AssignUeIpv6Address(NetDeviceContainer ueDevices)
Assign IPv6 addresses to UE devices.
static const uint16_t PROT_NUMBER
The protocol number for IPv6 (0x86DD).
Iterator End(void) const
Get an iterator which indicates past-the-last NetDevice in the container.
TypeId GetInstanceTypeId() const
Get the most derived TypeId for this Object.
static TypeId GetTypeId(void)
Register this type.
virtual void AddUe(Ptr< NetDevice > ueLteDevice, uint64_t imsi)
Notify the EPC of the existence of a new UE which might attach at a later time.
static const uint16_t PROT_NUMBER
Protocol number (0x0800)
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Ipv4AddressHelper m_s5Ipv4AddressHelper
S5 interfaces.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
virtual ~NoBackhaulEpcHelper()
Destructor.
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.
std::string m_x2LinkPcapPrefix
Prefix for the PCAP file for the X2 link.
Hold variables of type string.
std::vector< Ptr< NetDevice > >::const_iterator Iterator
NetDevice container iterator.
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
uint16_t m_gtpuUdpPort
UDP port where the GTP-U Socket is bound, fixed by the standard as 2152.
uint16_t m_s5LinkMtu
The MTU of the next S5 link to be created.
This class contains the specification of EPS Bearers.
static Ipv4Address GetAny(void)
DataRate m_x2LinkDataRate
The data rate to be used for the next X2 link to be created.
DataRate m_s11LinkDataRate
The data rate to be used for the next S11 link to be created.
virtual int Connect(const Address &address)=0
Initiate a connection to a remote host.
uint16_t m_s11LinkMtu
The MTU of the next S11 link to be created.
Time m_x2LinkDelay
The delay to be used for the next X2 link to be created.
Time Seconds(double value)
Construct a Time in the indicated unit.
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
void SetPhysicalAddress(const Address address)
Set the destination address.
AttributeValue implementation for Time.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Build a set of PointToPointNetDevice objects.
Access to the IPv6 forwarding table, interfaces, and configuration.
Base helper class to handle the creation of the EPC entities.
void SetProtocol(uint16_t protocol)
Set the protocol.
Ptr< const AttributeChecker > MakeStringChecker(void)
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
Hold an unsigned integer type.
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...
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
uint32_t GetNApplications(void) const
virtual uint32_t GetNInterfaces(void) const =0
Ptr< EpcPgwApplication > m_pgwApp
PGW application.
Describes an IPv6 prefix.
aggregate IP/TCP/UDP functionality to existing Nodes.
static TypeId LookupByName(std::string name)
Get a TypeId by name.
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
Ptr< Ipv6StaticRouting > GetStaticRouting(Ptr< Ipv6 > ipv6) const
Get Ipv6StaticRouting pointer from IPv6 stack.
virtual uint32_t GetIfIndex(void) const =0
List of Attribute name, value and checker triples used to construct Objects.
An implementation of the ICMPv6 protocol.
static EventId ScheduleNow(FUNC f, Ts &&... args)
Schedule an event to expire Now.
void Add(NetDeviceContainer other)
Append the contents of another NetDeviceContainer to the end of this container.
bool m_x2LinkEnablePcap
Enable PCAP generation for X2 link.
virtual void DoActivateEpsBearerForUe(const Ptr< NetDevice > &ueDevice, const Ptr< EpcTft > &tft, const EpsBearer &bearer) const
DoActivateEpsBearerForUe: Schedule ActivateEpsBearer on the UE.
The eNodeB device implementation.
Ptr< const AttributeAccessor > MakeStringAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeChecker > MakeDataRateChecker(void)
virtual Ptr< Node > GetSgwNode() const
Get the SGW node.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
virtual Ipv6Address GetUeDefaultGatewayAddress6()
virtual Ipv6InterfaceAddress GetAddress(uint32_t interface, uint32_t addressIndex) const =0
Get IPv6 address on specified IPv6 interface.