A Discrete-Event Network Simulator
API
epc-mme.cc
Go to the documentation of this file.
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Nicola Baldo <nbaldo@cttc.es>
19  */
20 
21 #include <ns3/fatal-error.h>
22 #include <ns3/log.h>
23 
24 #include "epc-s1ap-sap.h"
25 #include "epc-s11-sap.h"
26 
27 #include "epc-mme.h"
28 
29 namespace ns3 {
30 
31 NS_LOG_COMPONENT_DEFINE ("EpcMme");
32 
34 
36  : m_s11SapSgw (0)
37 {
38  NS_LOG_FUNCTION (this);
41 }
42 
43 
45 {
46  NS_LOG_FUNCTION (this);
47 }
48 
49 void
51 {
52  NS_LOG_FUNCTION (this);
53  delete m_s1apSapMme;
54  delete m_s11SapMme;
55 }
56 
57 TypeId
59 {
60  static TypeId tid = TypeId ("ns3::EpcMme")
61  .SetParent<Object> ()
62  .SetGroupName("Lte")
63  .AddConstructor<EpcMme> ()
64  ;
65  return tid;
66 }
67 
70 {
71  return m_s1apSapMme;
72 }
73 
74 void
76 {
77  m_s11SapSgw = s;
78 }
79 
82 {
83  return m_s11SapMme;
84 }
85 
86 void
87 EpcMme::AddEnb (uint16_t gci, Ipv4Address enbS1uAddr, EpcS1apSapEnb* enbS1apSap)
88 {
89  NS_LOG_FUNCTION (this << gci << enbS1uAddr);
90  Ptr<EnbInfo> enbInfo = Create<EnbInfo> ();
91  enbInfo->gci = gci;
92  enbInfo->s1uAddr = enbS1uAddr;
93  enbInfo->s1apSapEnb = enbS1apSap;
94  m_enbInfoMap[gci] = enbInfo;
95 }
96 
97 void
98 EpcMme::AddUe (uint64_t imsi)
99 {
100  NS_LOG_FUNCTION (this << imsi);
101  Ptr<UeInfo> ueInfo = Create<UeInfo> ();
102  ueInfo->imsi = imsi;
103  ueInfo->mmeUeS1Id = imsi;
104  m_ueInfoMap[imsi] = ueInfo;
105  ueInfo->bearerCounter = 0;
106 }
107 
108 uint8_t
109 EpcMme::AddBearer (uint64_t imsi, Ptr<EpcTft> tft, EpsBearer bearer)
110 {
111  NS_LOG_FUNCTION (this << imsi);
112  std::map<uint64_t, Ptr<UeInfo> >::iterator it = m_ueInfoMap.find (imsi);
113  NS_ASSERT_MSG (it != m_ueInfoMap.end (), "could not find any UE with IMSI " << imsi);
114  NS_ASSERT_MSG (it->second->bearerCounter < 11, "too many bearers already! " << it->second->bearerCounter);
115  BearerInfo bearerInfo;
116  bearerInfo.bearerId = ++(it->second->bearerCounter);
117  bearerInfo.tft = tft;
118  bearerInfo.bearer = bearer;
119  it->second->bearersToBeActivated.push_back (bearerInfo);
120  return bearerInfo.bearerId;
121 }
122 
123 
124 // S1-AP SAP MME forwarded methods
125 
126 void
127 EpcMme::DoInitialUeMessage (uint64_t mmeUeS1Id, uint16_t enbUeS1Id, uint64_t imsi, uint16_t gci)
128 {
129  NS_LOG_FUNCTION (this << mmeUeS1Id << enbUeS1Id << imsi << gci);
130  std::map<uint64_t, Ptr<UeInfo> >::iterator it = m_ueInfoMap.find (imsi);
131  NS_ASSERT_MSG (it != m_ueInfoMap.end (), "could not find any UE with IMSI " << imsi);
132  it->second->cellId = gci;
134  msg.imsi = imsi;
135  msg.uli.gci = gci;
136  msg.teid = 0;
137  for (std::list<BearerInfo>::iterator bit = it->second->bearersToBeActivated.begin ();
138  bit != it->second->bearersToBeActivated.end ();
139  ++bit)
140  {
142  bearerContext.epsBearerId = bit->bearerId;
143  bearerContext.bearerLevelQos = bit->bearer;
144  bearerContext.tft = bit->tft;
145  msg.bearerContextsToBeCreated.push_back (bearerContext);
146  }
148 }
149 
150 void
151 EpcMme::DoInitialContextSetupResponse (uint64_t mmeUeS1Id, uint16_t enbUeS1Id, std::list<EpcS1apSapMme::ErabSetupItem> erabSetupList)
152 {
153  NS_LOG_FUNCTION (this << mmeUeS1Id << enbUeS1Id);
154  NS_FATAL_ERROR ("unimplemented");
155 }
156 
157 void
158 EpcMme::DoPathSwitchRequest (uint64_t enbUeS1Id, uint64_t mmeUeS1Id, uint16_t gci, std::list<EpcS1apSapMme::ErabSwitchedInDownlinkItem> erabToBeSwitchedInDownlinkList)
159 {
160  NS_LOG_FUNCTION (this << mmeUeS1Id << enbUeS1Id << gci);
161 
162  uint64_t imsi = mmeUeS1Id;
163  std::map<uint64_t, Ptr<UeInfo> >::iterator it = m_ueInfoMap.find (imsi);
164  NS_ASSERT_MSG (it != m_ueInfoMap.end (), "could not find any UE with IMSI " << imsi);
165  NS_LOG_INFO ("IMSI " << imsi << " old eNB: " << it->second->cellId << ", new eNB: " << gci);
166  it->second->cellId = gci;
167  it->second->enbUeS1Id = enbUeS1Id;
168 
170  msg.teid = imsi; // trick to avoid the need for allocating TEIDs on the S11 interface
171  msg.uli.gci = gci;
172  // bearer modification is not supported for now
174 }
175 
176 
177 // S11 SAP MME forwarded methods
178 
179 void
181 {
182  NS_LOG_FUNCTION (this << msg.teid);
183  uint64_t imsi = msg.teid;
184  std::list<EpcS1apSapEnb::ErabToBeSetupItem> erabToBeSetupList;
185  for (std::list<EpcS11SapMme::BearerContextCreated>::iterator bit = msg.bearerContextsCreated.begin ();
186  bit != msg.bearerContextsCreated.end ();
187  ++bit)
188  {
190  erab.erabId = bit->epsBearerId;
191  erab.erabLevelQosParameters = bit->bearerLevelQos;
192  erab.transportLayerAddress = bit->sgwFteid.address;
193  erab.sgwTeid = bit->sgwFteid.teid;
194  erabToBeSetupList.push_back (erab);
195  }
196  std::map<uint64_t, Ptr<UeInfo> >::iterator it = m_ueInfoMap.find (imsi);
197  NS_ASSERT_MSG (it != m_ueInfoMap.end (), "could not find any UE with IMSI " << imsi);
198  uint16_t cellId = it->second->cellId;
199  uint16_t enbUeS1Id = it->second->enbUeS1Id;
200  uint64_t mmeUeS1Id = it->second->mmeUeS1Id;
201  std::map<uint16_t, Ptr<EnbInfo> >::iterator jt = m_enbInfoMap.find (cellId);
202  NS_ASSERT_MSG (jt != m_enbInfoMap.end (), "could not find any eNB with CellId " << cellId);
203  jt->second->s1apSapEnb->InitialContextSetupRequest (mmeUeS1Id, enbUeS1Id, erabToBeSetupList);
204 }
205 
206 
207 void
209 {
210  NS_LOG_FUNCTION (this << msg.teid);
212  uint64_t imsi = msg.teid;
213  std::map<uint64_t, Ptr<UeInfo> >::iterator it = m_ueInfoMap.find (imsi);
214  NS_ASSERT_MSG (it != m_ueInfoMap.end (), "could not find any UE with IMSI " << imsi);
215  uint64_t enbUeS1Id = it->second->enbUeS1Id;
216  uint64_t mmeUeS1Id = it->second->mmeUeS1Id;
217  uint16_t cgi = it->second->cellId;
218  std::list<EpcS1apSapEnb::ErabSwitchedInUplinkItem> erabToBeSwitchedInUplinkList; // unused for now
219  std::map<uint16_t, Ptr<EnbInfo> >::iterator jt = m_enbInfoMap.find (it->second->cellId);
220  NS_ASSERT_MSG (jt != m_enbInfoMap.end (), "could not find any eNB with CellId " << it->second->cellId);
221  jt->second->s1apSapEnb->PathSwitchRequestAcknowledge (enbUeS1Id, mmeUeS1Id, cgi, erabToBeSwitchedInUplinkList);
222 }
223 
224 void
225 EpcMme::DoErabReleaseIndication (uint64_t mmeUeS1Id, uint16_t enbUeS1Id, std::list<EpcS1apSapMme::ErabToBeReleasedIndication> erabToBeReleaseIndication)
226 {
227  NS_LOG_FUNCTION (this << mmeUeS1Id << enbUeS1Id);
228  uint64_t imsi = mmeUeS1Id;
229  std::map<uint64_t, Ptr<UeInfo> >::iterator it = m_ueInfoMap.find (imsi);
230  NS_ASSERT_MSG (it != m_ueInfoMap.end (), "could not find any UE with IMSI " << imsi);
231 
233  // trick to avoid the need for allocating TEIDs on the S11 interface
234  msg.teid = imsi;
235 
236  for (std::list<EpcS1apSapMme::ErabToBeReleasedIndication>::iterator bit = erabToBeReleaseIndication.begin (); bit != erabToBeReleaseIndication.end (); ++bit)
237  {
239  bearerContext.epsBearerId = bit->erabId;
240  msg.bearerContextsToBeRemoved.push_back (bearerContext);
241  }
242  //Delete Bearer command towards epc-sgw-pgw-application
244 }
245 
246 void
248 {
249  NS_LOG_FUNCTION (this);
250  uint64_t imsi = msg.teid;
251  std::map<uint64_t, Ptr<UeInfo> >::iterator it = m_ueInfoMap.find (imsi);
252  NS_ASSERT_MSG (it != m_ueInfoMap.end (), "could not find any UE with IMSI " << imsi);
254 
255  res.teid = imsi;
256 
257  for (std::list<EpcS11SapMme::BearerContextRemoved>::iterator bit = msg.bearerContextsRemoved.begin ();
258  bit != msg.bearerContextsRemoved.end ();
259  ++bit)
260  {
262  bearerContext.epsBearerId = bit->epsBearerId;
263  res.bearerContextsRemoved.push_back (bearerContext);
264 
265  RemoveBearer (it->second, bearerContext.epsBearerId); //schedules function to erase, context of de-activated bearer
266  }
267  //schedules Delete Bearer Response towards epc-sgw-pgw-application
269 }
270 
271 void EpcMme::RemoveBearer (Ptr<UeInfo> ueInfo, uint8_t epsBearerId)
272 {
273  NS_LOG_FUNCTION (this << epsBearerId);
274  for (std::list<BearerInfo>::iterator bit = ueInfo->bearersToBeActivated.begin ();
275  bit != ueInfo->bearersToBeActivated.end ();
276  ++bit)
277  {
278  if (bit->bearerId == epsBearerId)
279  {
280  ueInfo->bearersToBeActivated.erase (bit);
281  break;
282  }
283  }
284 }
285 
286 } // namespace ns3
std::list< BearerContextRemoved > bearerContextsRemoved
list of bearer context removed
Definition: epc-s11-sap.h:125
void DoDeleteBearerRequest(EpcS11SapMme::DeleteBearerRequestMessage msg)
Delete Bearer Request function.
Definition: epc-mme.cc:247
void AddUe(uint64_t imsi)
Add a new UE to the MME.
Definition: epc-mme.cc:98
enum ns3::EpcS11SapMme::ModifyBearerResponseMessage::Cause cause
the cause
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
Delete Bearer Command message, see 3GPP TS 29.274 Release 9 V9.3.0 section 7.2.17.1.
Definition: epc-s11-sap.h:206
MME side of the S1-AP Service Access Point (SAP), provides the MME methods to be called when an S1-AP...
Definition: epc-s1ap-sap.h:53
MME side of the S11 Service Access Point (SAP), provides the MME methods to be called when an S11 mes...
Definition: epc-s11-sap.h:78
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
NS_ASSERT_MSG(false, "Ipv4AddressGenerator::MaskToIndex(): Impossible")
void DoModifyBearerResponse(EpcS11SapMme::ModifyBearerResponseMessage msg)
Modify Bearer Response function.
Definition: epc-mme.cc:208
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
Definition: assert.h:67
Delete Bearer Request message, see 3GPP TS 29.274 Release 9 V9.3.0 section 7.2.9.2.
Definition: epc-s11-sap.h:123
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
std::map< uint16_t, Ptr< EnbInfo > > m_enbInfoMap
EnbInfo stored by EGCI.
Definition: epc-mme.h:224
EpcS1apSapMme * GetS1apSapMme()
Definition: epc-mme.cc:69
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:278
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:162
This object implements the MME functionality.
Definition: epc-mme.h:40
uint64_t imsi
UE identifier.
Definition: epc-mme.h:190
void DoErabReleaseIndication(uint64_t mmeUeS1Id, uint16_t enbUeS1Id, std::list< EpcS1apSapMme::ErabToBeReleasedIndication > erabToBeReleaseIndication)
ERAB Release Indication function.
Definition: epc-mme.cc:225
BearerContextToBeCreated structure.
Definition: epc-s11-sap.h:198
EpcS11SapSgw * m_s11SapSgw
EpcS11SapSgw.
Definition: epc-mme.h:232
EpsBearer bearerLevelQos
bearer QOS level
Definition: epc-s11-sap.h:175
Delete Bearer Response message, see 3GPP TS 29.274 Release 9 V9.3.0 section 7.2.10.2.
Definition: epc-s11-sap.h:226
BearerContextToBeCreated structure.
Definition: epc-s11-sap.h:171
This class contains the specification of EPS Bearers.
Definition: eps-bearer.h:71
eNB side of the S1-AP Service Access Point (SAP), provides the eNB methods to be called when an S1-AP...
Definition: epc-s1ap-sap.h:141
EpcS11SapMme * GetS11SapMme()
Definition: epc-mme.cc:81
uint8_t AddBearer(uint64_t imsi, Ptr< EpcTft > tft, EpsBearer bearer)
Add an EPS bearer to the list of bearers to be activated for this UE.
Definition: epc-mme.cc:109
uint64_t mmeUeS1Id
mmeUeS1Id
Definition: epc-mme.h:188
uint16_t gci
GCI.
Definition: epc-s11-sap.h:66
virtual void ModifyBearerRequest(ModifyBearerRequestMessage msg)=0
send a Modify Bearer Request message
Ptr< EpcTft > tft
traffic flow template
Definition: epc-s11-sap.h:176
virtual ~EpcMme()
Destructor.
Definition: epc-mme.cc:44
BearerContextRemovedSgwPgw structure.
Definition: epc-s11-sap.h:218
uint8_t bearerId
bearer ID
Definition: epc-mme.h:179
Modify Bearer Request message, see 3GPP TS 29.274 7.2.7
Definition: epc-s11-sap.h:240
Ipv4Address transportLayerAddress
transport layer address
Definition: epc-s1ap-sap.h:151
Ptr< EpcTft > tft
traffic flow template
Definition: epc-mme.h:177
std::list< BearerInfo > bearersToBeActivated
list of bearers to be activated
Definition: epc-mme.h:192
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::list< BearerContextCreated > bearerContextsCreated
bearer contexts created
Definition: epc-s11-sap.h:101
virtual void CreateSessionRequest(CreateSessionRequestMessage msg)=0
send a Create Session Request message
EpsBearer erabLevelQosParameters
Level QOS parameters.
Definition: epc-s1ap-sap.h:150
virtual void DoDispose()
Destructor implementation.
Definition: epc-mme.cc:50
void DoInitialUeMessage(uint64_t mmeUeS1Id, uint16_t enbUeS1Id, uint64_t imsi, uint16_t ecgi)
Initial UE Message function.
Definition: epc-mme.cc:127
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:40
SGW side of the S11 Service Access Point (SAP), provides the SGW methods to be called when an S11 mes...
Definition: epc-s11-sap.h:166
std::list< BearerContextToBeCreated > bearerContextsToBeCreated
list of bearer contexts to be created
Definition: epc-s11-sap.h:187
uint16_t gci
GCI.
Definition: epc-mme.h:215
std::map< uint64_t, Ptr< UeInfo > > m_ueInfoMap
UeInfo stored by IMSI.
Definition: epc-mme.h:200
void DoInitialContextSetupResponse(uint64_t mmeUeS1Id, uint16_t enbUeS1Id, std::list< EpcS1apSapMme::ErabSetupItem > erabSetupList)
Initial Context Setup Response function.
Definition: epc-mme.cc:151
void AddEnb(uint16_t ecgi, Ipv4Address enbS1UAddr, EpcS1apSapEnb *enbS1apSap)
Add a new ENB to the MME.
Definition: epc-mme.cc:87
void DoPathSwitchRequest(uint64_t enbUeS1Id, uint64_t mmeUeS1Id, uint16_t cgi, std::list< EpcS1apSapMme::ErabSwitchedInDownlinkItem > erabToBeSwitchedInDownlinkList)
Path Switch Request function.
Definition: epc-mme.cc:158
Template for the implementation of the EpcS1apSapMme as a member of an owner class of type C to which...
Definition: epc-s1ap-sap.h:203
A base class which provides memory management and object aggregation.
Definition: object.h:87
Modify Bearer Response message, see 3GPP TS 29.274 7.2.7
Definition: epc-s11-sap.h:140
EpcMme()
Constructor.
Definition: epc-mme.cc:35
EpcS1apSapMme * m_s1apSapMme
EpcS1apSapMme.
Definition: epc-mme.h:229
ErabToBeSetupItem structure.
Definition: epc-s1ap-sap.h:147
EpsBearer bearer
bearer QOS characteristics
Definition: epc-mme.h:178
void RemoveBearer(Ptr< UeInfo > ueInfo, uint8_t epsBearerId)
This Function erases all contexts of bearer from MME side.
Definition: epc-mme.cc:271
void SetS11SapSgw(EpcS11SapSgw *s)
Set the SGW side of the S11 SAP.
Definition: epc-mme.cc:75
a unique identifier for an interface.
Definition: type-id.h:58
Template for the implementation of the EpcS11SapMme as a member of an owner class of type C to which ...
Definition: epc-s11-sap.h:266
virtual void DeleteBearerCommand(DeleteBearerCommandMessage msg)=0
As per 3GPP TS 29.274 Release 9 V9.3.0, a Delete Bearer Command message shall be sent on the S11 inte...
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:915
EpcS11SapMme * m_s11SapMme
EpcS11SapMme.
Definition: epc-mme.h:231
uint16_t bearerCounter
bearer counter
Definition: epc-mme.h:193
Ipv4Address s1uAddr
IP address.
Definition: epc-mme.h:216
void DoCreateSessionResponse(EpcS11SapMme::CreateSessionResponseMessage msg)
Create Session Response function.
Definition: epc-mme.cc:180
virtual void DeleteBearerResponse(DeleteBearerResponseMessage msg)=0
As per 3GPP TS 29.274 Release 9 V9.3.0, a Delete Bearer Command message shall be sent on the S11 inte...
static TypeId GetTypeId(void)
Get the type ID.
Definition: epc-mme.cc:58
Hold info on an EPS bearer to be activated.
Definition: epc-mme.h:175
Create Session Request message, see 3GPP TS 29.274 7.2.1
Definition: epc-s11-sap.h:183
EpcS1apSapEnb * s1apSapEnb
EpcS1apSapEnb.
Definition: epc-mme.h:217
Create Session Response message, see 3GPP TS 29.274 7.2.2
Definition: epc-s11-sap.h:99