A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 NS_LOG_COMPONENT_DEFINE ("EpcMme");
30 
31 namespace ns3 {
32 
33 
34 
35 
37 
39  : m_s11SapSgw (0)
40 {
41  NS_LOG_FUNCTION (this);
44 }
45 
46 
48 {
49  NS_LOG_FUNCTION (this);
50 }
51 
52 void
54 {
55  NS_LOG_FUNCTION (this);
56  delete m_s1apSapMme;
57  delete m_s11SapMme;
58 }
59 
60 TypeId
62 {
63  static TypeId tid = TypeId ("ns3::EpcMme")
64  .SetParent<Object> ()
65  .AddConstructor<EpcMme> ()
66  ;
67  return tid;
68 }
69 
72 {
73  return m_s1apSapMme;
74 }
75 
76 void
78 {
79  m_s11SapSgw = s;
80 }
81 
84 {
85  return m_s11SapMme;
86 }
87 
88 void
89 EpcMme::AddEnb (uint16_t gci, Ipv4Address enbS1uAddr, EpcS1apSapEnb* enbS1apSap)
90 {
91  NS_LOG_FUNCTION (this << gci << enbS1uAddr);
92  Ptr<EnbInfo> enbInfo = Create<EnbInfo> ();
93  enbInfo->gci = gci;
94  enbInfo->s1uAddr = enbS1uAddr;
95  enbInfo->s1apSapEnb = enbS1apSap;
96  m_enbInfoMap[gci] = enbInfo;
97 }
98 
99 void
100 EpcMme::AddUe (uint64_t imsi)
101 {
102  NS_LOG_FUNCTION (this << imsi);
103  Ptr<UeInfo> ueInfo = Create<UeInfo> ();
104  ueInfo->imsi = imsi;
105  ueInfo->mmeUeS1Id = imsi;
106  m_ueInfoMap[imsi] = ueInfo;
107  ueInfo->bearerCounter = 0;
108 }
109 
110 void
111 EpcMme::AddBearer (uint64_t imsi, Ptr<EpcTft> tft, EpsBearer bearer)
112 {
113  NS_LOG_FUNCTION (this << imsi);
114  std::map<uint64_t, Ptr<UeInfo> >::iterator it = m_ueInfoMap.find (imsi);
115  NS_ASSERT_MSG (it != m_ueInfoMap.end (), "could not find any UE with IMSI " << imsi);
116  NS_ASSERT_MSG (it->second->bearerCounter < 11, "too many bearers already! " << it->second->bearerCounter);
117  BearerInfo bearerInfo;
118  bearerInfo.bearerId = ++(it->second->bearerCounter);
119  bearerInfo.tft = tft;
120  bearerInfo.bearer = bearer;
121  it->second->bearersToBeActivated.push_back (bearerInfo);
122 }
123 
124 
125 // S1-AP SAP MME forwarded methods
126 
127 void
128 EpcMme::DoInitialUeMessage (uint64_t mmeUeS1Id, uint16_t enbUeS1Id, uint64_t imsi, uint16_t gci)
129 {
130  NS_LOG_FUNCTION (this << mmeUeS1Id << enbUeS1Id << imsi << gci);
131  std::map<uint64_t, Ptr<UeInfo> >::iterator it = m_ueInfoMap.find (imsi);
132  NS_ASSERT_MSG (it != m_ueInfoMap.end (), "could not find any UE with IMSI " << imsi);
133  it->second->cellId = gci;
135  msg.imsi = imsi;
136  msg. uli.gci = gci;
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 } // namespace ns3
void AddUe(uint64_t imsi)
Add a new UE to the MME.
Definition: epc-mme.cc:100
enum ns3::EpcS11SapMme::ModifyBearerResponseMessage::Cause cause
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:60
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
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:48
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:72
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register the class in the ns-3 factory.
Definition: object-base.h:38
void DoModifyBearerResponse(EpcS11SapMme::ModifyBearerResponseMessage msg)
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:61
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:170
std::map< uint16_t, Ptr< EnbInfo > > m_enbInfoMap
EnbInfo stored by EGCI.
Definition: epc-mme.h:170
EpcS1apSapMme * GetS1apSapMme()
Definition: epc-mme.cc:71
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:223
#define NS_FATAL_ERROR(msg)
fatal error handling
Definition: fatal-error.h:95
void 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:111
EpcS11SapSgw * m_s11SapSgw
Definition: epc-mme.h:178
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:113
EpcS11SapMme * GetS11SapMme()
Definition: epc-mme.cc:83
uint64_t mmeUeS1Id
Definition: epc-mme.h:141
Ptr< SampleEmitter > s
virtual void ModifyBearerRequest(ModifyBearerRequestMessage msg)=0
send a Modify Bearer Request message
virtual ~EpcMme()
Destructor.
Definition: epc-mme.cc:47
Modify Bearer Request message, see 3GPP TS 29.274 7.2.7.
Definition: epc-s11-sap.h:169
Ptr< EpcTft > tft
Definition: epc-mme.h:130
std::list< BearerContextCreated > bearerContextsCreated
Definition: epc-s11-sap.h:95
virtual void CreateSessionRequest(CreateSessionRequestMessage msg)=0
send a Create Session Request message
virtual void DoDispose()
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
Definition: epc-mme.cc:53
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition: assert.h:84
void DoInitialUeMessage(uint64_t mmeUeS1Id, uint16_t enbUeS1Id, uint64_t imsi, uint16_t ecgi)
Definition: epc-mme.cc:128
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:38
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:135
std::list< BearerContextToBeCreated > bearerContextsToBeCreated
Definition: epc-s11-sap.h:155
std::map< uint64_t, Ptr< UeInfo > > m_ueInfoMap
UeInfo stored by IMSI.
Definition: epc-mme.h:153
void DoInitialContextSetupResponse(uint64_t mmeUeS1Id, uint16_t enbUeS1Id, std::list< EpcS1apSapMme::ErabSetupItem > erabSetupList)
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:89
void DoPathSwitchRequest(uint64_t enbUeS1Id, uint64_t mmeUeS1Id, uint16_t cgi, std::list< EpcS1apSapMme::ErabSwitchedInDownlinkItem > erabToBeSwitchedInDownlinkList)
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:170
a base class which provides memory management and object aggregation
Definition: object.h:64
Modify Bearer Response message, see 3GPP TS 29.274 7.2.7.
Definition: epc-s11-sap.h:110
EpcMme()
Constructor.
Definition: epc-mme.cc:38
EpcS1apSapMme * m_s1apSapMme
Definition: epc-mme.h:175
void SetS11SapSgw(EpcS11SapSgw *s)
Set the SGW side of the S11 SAP.
Definition: epc-mme.cc:77
a unique identifier for an interface.
Definition: type-id.h:49
Template for the implementation of the EpcS11SapMme as a member of an owner class of type C to which ...
Definition: epc-s11-sap.h:195
TypeId SetParent(TypeId tid)
Definition: type-id.cc:610
EpcS11SapMme * m_s11SapMme
Definition: epc-mme.h:177
uint16_t bearerCounter
Definition: epc-mme.h:146
Ipv4Address s1uAddr
Definition: epc-mme.h:162
void DoCreateSessionResponse(EpcS11SapMme::CreateSessionResponseMessage msg)
Definition: epc-mme.cc:180
static TypeId GetTypeId(void)
Definition: epc-mme.cc:61
Hold info on an EPS bearer to be activated.
Definition: epc-mme.h:128
Create Session Request message, see 3GPP TS 29.274 7.2.1.
Definition: epc-s11-sap.h:151
EpcS1apSapEnb * s1apSapEnb
Definition: epc-mme.h:163
Create Session Response message, see 3GPP TS 29.274 7.2.2.
Definition: epc-s11-sap.h:93