23 #include <ns3/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/internet-stack-helper.h>
30 #include <ns3/point-to-point-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>
36 #include <ns3/lte-enb-rrc.h>
37 #include <ns3/epc-x2.h>
38 #include <ns3/lte-enb-net-device.h>
39 #include <ns3/lte-ue-net-device.h>
40 #include <ns3/epc-mme.h>
41 #include <ns3/epc-ue-nas.h>
47 NS_OBJECT_ENSURE_REGISTERED (EpcHelper);
51 : m_gtpuUdpPort (2152)
66 m_sgwPgw = CreateObject<Node> ();
76 m_tunDevice = CreateObject<VirtualNetDevice> ();
85 tunDeviceContainer.
Add (m_tunDevice);
93 m_sgwPgwApp = CreateObject<EpcSgwPgwApplication> (m_tunDevice, sgwPgwS1uSocket);
100 m_mme = CreateObject<EpcMme> ();
101 m_mme->SetS11SapSgw (m_sgwPgwApp->GetS11SapSgw ());
102 m_sgwPgwApp->SetS11SapMme (m_mme->GetS11SapMme ());
111 EpcHelper::GetTypeId (
void)
115 .AddConstructor<EpcHelper> ()
116 .AddAttribute (
"S1uLinkDataRate",
117 "The data rate to be used for the next S1-U link to be created",
119 MakeDataRateAccessor (&EpcHelper::m_s1uLinkDataRate),
120 MakeDataRateChecker ())
121 .AddAttribute (
"S1uLinkDelay",
122 "The delay to be used for the next S1-U link to be created",
124 MakeTimeAccessor (&EpcHelper::m_s1uLinkDelay),
126 .AddAttribute (
"S1uLinkMtu",
127 "The MTU of the next S1-U link to be created. Note that, because of the additional GTP/UDP/IP tunneling overhead, you need a MTU larger than the end-to-end MTU that you want to support.",
129 MakeUintegerAccessor (&EpcHelper::m_s1uLinkMtu),
130 MakeUintegerChecker<uint16_t> ())
131 .AddAttribute (
"X2LinkDataRate",
132 "The data rate to be used for the next X2 link to be created",
134 MakeDataRateAccessor (&EpcHelper::m_x2LinkDataRate),
135 MakeDataRateChecker ())
136 .AddAttribute (
"X2LinkDelay",
137 "The delay to be used for the next X2 link to be created",
139 MakeTimeAccessor (&EpcHelper::m_x2LinkDelay),
141 .AddAttribute (
"X2LinkMtu",
142 "The MTU of the next X2 link to be created. Note that, because of some big X2 messages, you need a big MTU.",
144 MakeUintegerAccessor (&EpcHelper::m_x2LinkMtu),
145 MakeUintegerChecker<uint16_t> ())
166 NS_ASSERT (enb == lteEnbNetDevice->GetNode ());
176 enbSgwNodes.
Add (m_sgwPgw);
177 enbSgwNodes.Add (enb);
206 enbLteSocketBindAddress.SetSingleDevice (lteEnbNetDevice->GetIfIndex ());
207 enbLteSocketBindAddress.SetProtocol (Ipv4L3Protocol::PROT_NUMBER);
208 retval = enbLteSocket->
Bind (enbLteSocketBindAddress);
212 enbLteSocketConnectAddress.SetSingleDevice (lteEnbNetDevice->GetIfIndex ());
213 enbLteSocketConnectAddress.SetProtocol (Ipv4L3Protocol::PROT_NUMBER);
214 retval = enbLteSocket->
Connect (enbLteSocketConnectAddress);
219 Ptr<EpcEnbApplication> enbApp = CreateObject<EpcEnbApplication> (enbLteSocket, enbS1uSocket, enbAddress, sgwAddress, cellId);
231 m_mme->AddEnb (cellId, enbAddress, enbApp->GetS1apSapEnb ());
232 m_sgwPgwApp->AddEnb (cellId, enbAddress, sgwAddress);
233 enbApp->SetS1apSapMme (m_mme->GetS1apSapMme ());
268 uint16_t enb1CellId = enb1LteDev->
GetCellId ();
269 NS_LOG_LOGIC (
"LteEnbNetDevice #1 = " << enb1LteDev <<
" - CellId = " << enb1CellId);
273 uint16_t enb2CellId = enb2LteDev->
GetCellId ();
274 NS_LOG_LOGIC (
"LteEnbNetDevice #2 = " << enb2LteDev <<
" - CellId = " << enb2CellId);
276 enb1X2->AddX2Interface (enb1CellId, enb1X2Address, enb2CellId, enb2X2Address);
277 enb2X2->AddX2Interface (enb2CellId, enb2X2Address, enb1CellId, enb1X2Address);
287 m_sgwPgwApp->AddUe (imsi);
302 NS_ASSERT_MSG (ueIpv4 != 0,
"UEs need to have IPv4 installed before EPS bearers can be activated");
303 int32_t
interface = ueIpv4->GetInterfaceForDevice (ueDevice);
305 NS_ASSERT (ueIpv4->GetNAddresses (interface) == 1);
306 Ipv4Address ueAddr = ueIpv4->GetAddress (interface, 0).GetLocal ();
307 NS_LOG_LOGIC (
" UE IP address: " << ueAddr); m_sgwPgwApp->SetUeAddress (imsi, ueAddr);
309 m_mme->AddBearer (imsi, tft, bearer);
313 ueLteDevice->GetNas ()->ActivateEpsBearer (bearer, tft);
337 return m_sgwPgw->
GetObject<
Ipv4> ()->GetAddress (1, 0).GetLocal ();
Ipv4AddressHelper m_x2Ipv4AddressHelper
uint32_t AddApplication(Ptr< Application > application)
static Ipv4Address GetAny(void)
#define NS_LOG_FUNCTION(parameters)
uint32_t GetNApplications(void) const
holds a vector of std::pair of Ptr<Ipv4> and interface index.
uint16_t GetCellId() const
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
NetDeviceContainer Install(NodeContainer c)
an address for a packet socket
#define NS_ASSERT(condition)
#define NS_LOG_COMPONENT_DEFINE(name)
aggregate IP/TCP/UDP functionality to existing Nodes.
Build a set of PointToPointNetDevice objects.
void SetDeviceAttribute(std::string name, const AttributeValue &value)
a polymophic address class
Class for representing data rates.
Ptr< Application > GetApplication(uint32_t index) const
static Mac48Address Allocate(void)
hold objects of type ns3::Time
bool RecvFromTunDevice(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)
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)
holds a vector of ns3::NetDevice pointers
Ptr< NetDevice > GetDevice(uint32_t index) const
static Mac48Address GetBroadcast(void)
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
static Ptr< Socket > CreateSocket(Ptr< Node > node, TypeId tid)
void AggregateObject(Ptr< Object > other)
#define NS_LOG_LOGIC(msg)
virtual int Connect(const Address &address)=0
Initiate a connection to a remote host.
Access to the Ipv4 forwarding table, interfaces, and configuration.
void AddUe(Ptr< NetDevice > ueLteDevice, uint64_t imsi)
virtual int Bind(const Address &address)=0
Allocate a local endpoint for this socket.
keep track of a set of node pointers.
Callback< R > MakeNullCallback(void)
void Install(std::string nodeName) const
void SetChannelAttribute(std::string name, const AttributeValue &value)
#define NS_ASSERT_MSG(condition, message)
Ipv4InterfaceContainer AssignUeIpv4Address(NetDeviceContainer ueDevices)
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...
Time Seconds(double seconds)
create ns3::Time instances in units of seconds.
void Add(NodeContainer other)
Append the contents of another NodeContainer to the end of this container.
uint32_t AddDevice(Ptr< NetDevice > device)
hold objects of type ns3::DataRate
Ipv4Address NewNetwork(void)
Increment the network number and reset the IP address counter to the base value provided in the SetBa...
void ActivateEpsBearer(Ptr< NetDevice > ueLteDevice, uint64_t imsi, Ptr< EpcTft > tft, EpsBearer bearer)
a base class which provides memory management and object aggregation
Ipv4AddressHelper m_s1uIpv4AddressHelper
void SetSendCallback(SendCallback transmitCb)
Set the user callback to be called when a L2 packet is to be transmitted.
void AddEnb(Ptr< Node > enbNode, Ptr< NetDevice > lteEnbNetDevice, uint16_t cellId)
void SetAttribute(std::string name, const AttributeValue &value)
Ptr< T > GetObject(void) const
void AddX2Interface(Ptr< Node > enbNode1, Ptr< Node > enbNode2)
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Ipv4Address GetUeDefaultGatewayAddress()
virtual uint32_t GetNInterfaces(void) const =0
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
Ipv4AddressHelper m_ueAddressHelper
static TypeId LookupByName(std::string name)
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const