23 #include <ns3/emu-epc-helper.h> 
   25 #include <ns3/inet-socket-address.h> 
   26 #include <ns3/mac48-address.h> 
   27 #include <ns3/eps-bearer.h> 
   28 #include <ns3/ipv4-address.h> 
   29 #include <ns3/ipv6-address.h> 
   30 #include <ns3/internet-stack-helper.h> 
   31 #include <ns3/packet-socket-helper.h> 
   32 #include <ns3/packet-socket-address.h> 
   33 #include <ns3/epc-enb-application.h> 
   34 #include <ns3/epc-sgw-pgw-application.h> 
   35 #include <ns3/emu-fd-net-device-helper.h> 
   36 #include "ns3/ipv6-static-routing.h" 
   37 #include "ns3/ipv6-static-routing-helper.h" 
   38 #include <ns3/lte-enb-rrc.h> 
   39 #include <ns3/epc-x2.h> 
   40 #include <ns3/lte-enb-net-device.h> 
   41 #include <ns3/lte-ue-net-device.h> 
   42 #include <ns3/epc-mme.h> 
   43 #include <ns3/epc-ue-nas.h> 
   44 #include <ns3/string.h> 
   45 #include <ns3/abort.h> 
   46 #include <ns3/ipv4-address-generator.h> 
   47 #include <ns3/ipv6-address-generator.h> 
   48 #include <ns3/icmpv6-l4-protocol.h> 
   61   : m_gtpuUdpPort (2152)  
 
   80     .AddAttribute (
"sgwDeviceName", 
 
   81                    "The name of the device used for the S1-U interface of the SGW",
 
   85     .AddAttribute (
"enbDeviceName", 
 
   86                    "The name of the device used for the S1-U interface of the eNB",
 
   90     .AddAttribute (
"SgwMacAddress", 
 
   91                    "MAC address used for the SGW ",
 
   95     .AddAttribute (
"EnbMacAddressBase", 
 
   96                    "First 5 bytes of the Enb MAC address base",
 
  176   m_mme = CreateObject<EpcMme> ();
 
  216   NS_ASSERT (enb == lteEnbNetDevice->GetNode ());  
 
  232   std::ostringstream enbMacAddress;
 
  233   enbMacAddress << 
m_enbMacAddressBase << 
":" << std::hex << std::setfill (
'0') << std::setw (2) << cellId;
 
  234   NS_LOG_LOGIC (
"MAC address of enB with cellId " << cellId << 
" : " << enbMacAddress.str ());
 
  236   enbDev->SetAttribute (
"Address", 
Mac48AddressValue (enbMacAddress.str ().c_str ()));
 
  244   Ipv4Address enbAddress = enbIpIfaces.GetAddress (0);
 
  255   enbLteSocketBindAddress.
SetSingleDevice (lteEnbNetDevice->GetIfIndex ());
 
  257   retval = enbLteSocket->
Bind (enbLteSocketBindAddress);
 
  261   enbLteSocketConnectAddress.
SetSingleDevice (lteEnbNetDevice->GetIfIndex ());
 
  263   retval = enbLteSocket->
Connect (enbLteSocketConnectAddress);
 
  269   enbLteSocketBindAddress6.
SetSingleDevice (lteEnbNetDevice->GetIfIndex ());
 
  271   retval = enbLteSocket6->
Bind (enbLteSocketBindAddress6);
 
  275   enbLteSocketConnectAddress6.
SetSingleDevice (lteEnbNetDevice->GetIfIndex ());
 
  277   retval = enbLteSocket6->
Connect (enbLteSocketConnectAddress6);
 
  281   Ptr<EpcEnbApplication> enbApp = CreateObject<EpcEnbApplication> (enbLteSocket, enbLteSocket6, enbS1uSocket, enbAddress, sgwAddress, cellId);
 
  293   m_mme->AddEnb (cellId, enbAddress, enbApp->GetS1apSapEnb ());
 
  294   m_sgwPgwApp->AddEnb (cellId, enbAddress, sgwAddress);
 
  295   enbApp->SetS1apSapMme (
m_mme->GetS1apSapMme ());
 
  310   NS_LOG_LOGIC (
"number of Ipv4 ifaces of the eNB #1: " << enb1Ipv4->GetNInterfaces ());
 
  311   NS_LOG_LOGIC (
"number of Ipv4 ifaces of the eNB #2: " << enb2Ipv4->GetNInterfaces ());
 
  319   int32_t enb1Interface =  enb1Ipv4->GetInterfaceForDevice (enb1EpcDev);
 
  320   int32_t enb2Interface =  enb2Ipv4->GetInterfaceForDevice (enb2EpcDev);
 
  323   NS_ASSERT (enb1Ipv4->GetNAddresses (enb1Interface) == 1);
 
  324   NS_ASSERT (enb2Ipv4->GetNAddresses (enb2Interface) == 1);
 
  325   Ipv4Address enb1Addr = enb1Ipv4->GetAddress (enb1Interface, 0).GetLocal (); 
 
  326   Ipv4Address enb2Addr = enb2Ipv4->GetAddress (enb2Interface, 0).GetLocal (); 
 
  333   uint16_t enb1CellId = enb1LteDev->
GetCellId ();
 
  334   NS_LOG_LOGIC (
"LteEnbNetDevice #1 = " << enb1LteDev << 
" - CellId = " << enb1CellId);
 
  338   uint16_t enb2CellId = enb2LteDev->
GetCellId ();
 
  339   NS_LOG_LOGIC (
"LteEnbNetDevice #2 = " << enb2LteDev << 
" - CellId = " << enb2CellId);
 
  341   enb1X2->AddX2Interface (enb1CellId, enb1Addr, enb2CellId, enb2Addr);
 
  342   enb2X2->AddX2Interface (enb2CellId, enb2Addr, enb1CellId, enb1Addr);
 
  344   enb1LteDev->GetRrc ()->AddX2Neighbour (enb2LteDev->GetCellId ());
 
  345   enb2LteDev->GetRrc ()->AddX2Neighbour (enb1LteDev->GetCellId ());
 
  371   NS_ASSERT_MSG (ueIpv4 != 0 || ueIpv6 != 0, 
"UEs need to have IPv4/IPv6 installed before EPS bearers can be activated");
 
  375       int32_t 
interface =  ueIpv4->GetInterfaceForDevice (ueDevice);
 
  376       if (interface >= 0 && ueIpv4->GetNAddresses (interface) == 1)
 
  378           Ipv4Address ueAddr = ueIpv4->GetAddress (interface, 0).GetLocal ();
 
  385       int32_t interface6 =  ueIpv6->GetInterfaceForDevice (ueDevice);
 
  386       if (interface6 >= 0 && ueIpv6->GetNAddresses (interface6) == 2)
 
  388           Ipv6Address ueAddr6 = ueIpv6->GetAddress (interface6, 1).GetAddress ();
 
  394   uint8_t bearerId = 
m_mme->AddBearer (imsi, tft, bearer);
 
  421       iter != ueDevices.
End ();
 
void Dispose(void)
Dispose of this Object. 
 
Ptr< const AttributeChecker > MakeStringChecker(void)
 
uint32_t AddApplication(Ptr< Application > application)
Associate an Application to this Node. 
 
static TypeId GetTypeId(void)
Register this type. 
 
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. 
 
Iterator Begin(void) const 
Get an iterator which refers to the first NetDevice in the container. 
 
virtual void DoInitialize(void)
Initialize() implementation. 
 
virtual NetDeviceContainer Install(Ptr< Node > node) const 
This method creates a FdNetDevice and associates it to a node. 
 
void ActivateEpsBearer(EpsBearer bearer, Ptr< EpcTft > tft)
Activate an EPS bearer. 
 
static Ipv4Address GetAny(void)
 
Smart pointer class similar to boost::intrusive_ptr. 
 
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
 
AttributeValue implementation for Boolean. 
 
uint32_t GetNApplications(void) const 
 
Keep track of a set of IPv6 interfaces. 
 
holds a vector of std::pair of Ptr and interface index. 
 
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system. 
 
uint16_t GetCellId() const 
 
Ptr< T > GetObject(void) const 
Get a pointer to the requested aggregated Object. 
 
Access to the IPv6 forwarding table, interfaces, and configuration. 
 
Hold variables of type string. 
 
void SetDefaultRouteInAllNodes(uint32_t router)
Set the default route for all the devices (except the router itself). 
 
Ptr< NetDevice > Get(uint32_t i) const 
Get the Ptr stored in this container at a given index. 
 
uint16_t m_gtpuUdpPort
UDP port where the GTP-U Socket is bound, fixed by the standard as 2152. 
 
std::string m_sgwDeviceName
The name of the device used for the S1-U interface of the SGW. 
 
void AggregateObject(Ptr< Object > other)
Aggregate two Objects together. 
 
Ipv4InterfaceContainer m_sgwIpIfaces
Container for Ipv4Interfaces of the SGW/PGW. 
 
EmuEpcHelper()
Constructor. 
 
an address for a packet socket 
 
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
 
Ptr< Ipv6StaticRouting > GetStaticRouting(Ptr< Ipv6 > ipv6) const 
Get Ipv6StaticRouting pointer from IPv6 stack. 
 
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name. 
 
aggregate IP/TCP/UDP functionality to existing Nodes. 
 
void SetBase(Ipv6Address network, Ipv6Prefix prefix, Ipv6Address base=Ipv6Address("::1"))
Set the base network number, network prefix, and base interface ID. 
 
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO. 
 
Callback< R > MakeNullCallback(void)
 
Ipv4AddressHelper m_uePgwAddressHelper
helper to assign IPv4 addresses to UE devices as well as to the TUN device of the SGW/PGW ...
 
void SetSingleDevice(uint32_t device)
Set the address to match only a specified NetDevice. 
 
virtual void AddUe(Ptr< NetDevice > ueLteDevice, uint64_t imsi)
Notify the EPC of the existance of a new UE which might attach at a later time. 
 
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. 
 
a polymophic address class 
 
Ipv6InterfaceContainer Assign(const NetDeviceContainer &c)
Allocate an Ipv6InterfaceContainer with auto-assigned addresses. 
 
Ipv6Address GetUeDefaultGatewayAddress6()
 
virtual void DoInitialize()
Initialize() implementation. 
 
This class contains the specification of EPS Bearers. 
 
Ptr< Application > GetApplication(uint32_t index) const 
Retrieve the index-th Application associated to this node. 
 
NS_ASSERT_MSG(false,"Ipv4AddressGenerator::MaskToIndex(): Impossible")
 
static Mac48Address Allocate(void)
Allocate a new Mac48Address. 
 
Ipv6InterfaceContainer AssignUeIpv6Address(NetDeviceContainer ueDevices)
 
bool RecvFromTunDevice(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)
Method to be assigned to the callback of the Gi TUN VirtualNetDevice. 
 
virtual Ipv6InterfaceAddress GetAddress(uint32_t interface, uint32_t addressIndex) const =0
Get IPv6 address on specified IPv6 interface. 
 
void Add(NetDeviceContainer other)
Append the contents of another NetDeviceContainer to the end of this container. 
 
Hold an unsigned integer type. 
 
virtual void SetAddress(Address address)
Set the address of this interface. 
 
List of Attribute name, value and checker triples used to construct Objects. 
 
holds a vector of ns3::NetDevice pointers 
 
virtual void AddX2Interface(Ptr< Node > enbNode1, Ptr< Node > enbNode2)
Add an X2 interface between two eNB. 
 
Ptr< NetDevice > GetDevice(uint32_t index) const 
Retrieve the index-th NetDevice associated to this node. 
 
TypeId GetInstanceTypeId() const 
Get the most derived TypeId for this Object. 
 
static Mac48Address GetBroadcast(void)
 
An implementation of the ICMPv6 protocol. 
 
virtual void AddEnb(Ptr< Node > enbNode, Ptr< NetDevice > lteEnbNetDevice, uint16_t cellId)
Add an eNB to the EPC. 
 
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
 
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...
 
Create an EPC network using EmuFdNetDevice. 
 
virtual int Connect(const Address &address)=0
Initiate a connection to a remote host. 
 
Access to the IPv4 forwarding table, interfaces, and configuration. 
 
uint32_t GetNDevices(void) const 
 
void SetDeviceName(std::string deviceName)
Set the device name of this device. 
 
std::string m_enbMacAddressBase
First 5 bytes of the Enb MAC address base. 
 
std::string m_sgwMacAddress
MAC address used for the SGW. 
 
Base helper class to handle the creation of the EPC entities. 
 
virtual int Bind(const Address &address)=0
Allocate a local endpoint for this socket. 
 
Every class exported by the ns3 library is enclosed in the ns3 namespace. 
 
virtual Ipv4Address GetUeDefaultGatewayAddress()
 
void SetPhysicalAddress(const Address address)
Set the destination address. 
 
This entity is installed inside an eNB and provides the functionality for the X2 interface. 
 
Helper class that adds ns3::Ipv6StaticRouting objects. 
 
virtual Ipv4InterfaceContainer AssignUeIpv4Address(NetDeviceContainer ueDevices)
Assign IPv4 addresses to UE devices. 
 
void ConstructSelf(const AttributeConstructionList &attributes)
Complete construction of ObjectBase; invoked by derived classes. 
 
void Install(std::string nodeName) const 
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
 
virtual ~EmuEpcHelper()
Destructor. 
 
static EventId ScheduleNow(MEM mem_ptr, OBJ obj)
Schedule an event to expire Now. 
 
Ptr< EpcSgwPgwApplication > m_sgwPgwApp
SGW-PGW application. 
 
NS_LOG_LOGIC("Net device "<< nd<< " is not bridged")
 
#define NS_ABORT_IF(cond)
Abnormal program termination if a condition is true. 
 
Describes an IPv6 address. 
 
Ipv4 addresses are stored in host order in this class. 
 
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
 
This application is installed inside eNBs and provides the bridge functionality for user data plane p...
 
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node. 
 
virtual Ptr< Node > GetPgwNode()
 
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN. 
 
AttributeValue implementation for Mac48Address. 
 
std::string m_enbDeviceName
The name of the device used for the S1-U interface of the eNB. 
 
std::vector< Ptr< NetDevice > >::const_iterator Iterator
NetDevice container iterator. 
 
void SetProtocol(uint16_t protocol)
Set the protocol. 
 
Describes an IPv6 prefix. 
 
Ipv6AddressHelper m_uePgwAddressHelper6
helper to assign IPv6 addresses to UE devices as well as to the TUN device of the SGW/PGW ...
 
Ptr< const AttributeAccessor > MakeStringAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
 
void SetSendCallback(SendCallback transmitCb)
Set the user callback to be called when a L2 packet is to be transmitted. 
 
Iterator End(void) const 
Get an iterator which indicates past-the-last NetDevice in the container. 
 
Ipv4AddressHelper m_epcIpv4AddressHelper
helper to assign addresses to S1-U NetDevices 
 
virtual void DoDispose()
Destructor implementation. 
 
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful. 
 
The eNodeB device implementation. 
 
build a set of FdNetDevice objects attached to a physical network interface 
 
Ptr< VirtualNetDevice > m_tunDevice
TUN device containing IPv4 address and implementing tunneling of user data over GTP-U/UDP/IP. 
 
a unique identifier for an interface. 
 
TypeId SetParent(TypeId tid)
Set the parent TypeId. 
 
static const uint16_t PROT_NUMBER
The protocol number for IPv6 (0x86DD). 
 
Ptr< Node > m_sgwPgw
SGW-PGW network element. 
 
void Initialize(void)
Invoke DoInitialize on all Objects aggregated to this one. 
 
virtual uint32_t GetNInterfaces(void) const =0
 
static const uint16_t PROT_NUMBER
Protocol number (0x0800) 
 
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address. 
 
static TypeId LookupByName(std::string name)
Get a TypeId by name. 
 
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const 
 
Ptr< EpcMme > m_mme
MME network element. 
 
The LteUeNetDevice class implements the UE net device.