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  ;
38 
40  : m_s11SapSgw (0)
41 {
42  NS_LOG_FUNCTION (this);
45 }
46 
47 
49 {
50  NS_LOG_FUNCTION (this);
51 }
52 
53 void
55 {
56  NS_LOG_FUNCTION (this);
57  delete m_s1apSapMme;
58  delete m_s11SapMme;
59 }
60 
61 TypeId
63 {
64  static TypeId tid = TypeId ("ns3::EpcMme")
65  .SetParent<Object> ()
66  .AddConstructor<EpcMme> ()
67  ;
68  return tid;
69 }
70 
73 {
74  return m_s1apSapMme;
75 }
76 
77 void
79 {
80  m_s11SapSgw = s;
81 }
82 
85 {
86  return m_s11SapMme;
87 }
88 
89 void
90 EpcMme::AddEnb (uint16_t gci, Ipv4Address enbS1uAddr, EpcS1apSapEnb* enbS1apSap)
91 {
92  NS_LOG_FUNCTION (this << gci << enbS1uAddr);
93  Ptr<EnbInfo> enbInfo = Create<EnbInfo> ();
94  enbInfo->gci = gci;
95  enbInfo->s1uAddr = enbS1uAddr;
96  enbInfo->s1apSapEnb = enbS1apSap;
97  m_enbInfoMap[gci] = enbInfo;
98 }
99 
100 void
101 EpcMme::AddUe (uint64_t imsi)
102 {
103  NS_LOG_FUNCTION (this << imsi);
104  Ptr<UeInfo> ueInfo = Create<UeInfo> ();
105  ueInfo->imsi = imsi;
106  ueInfo->mmeUeS1Id = imsi;
107  m_ueInfoMap[imsi] = ueInfo;
108  ueInfo->bearerCounter = 0;
109 }
110 
111 void
112 EpcMme::AddBearer (uint64_t imsi, Ptr<EpcTft> tft, EpsBearer bearer)
113 {
114  NS_LOG_FUNCTION (this << imsi);
115  std::map<uint64_t, Ptr<UeInfo> >::iterator it = m_ueInfoMap.find (imsi);
116  NS_ASSERT_MSG (it != m_ueInfoMap.end (), "could not find any UE with IMSI " << imsi);
117  NS_ASSERT_MSG (it->second->bearerCounter < 11, "too many bearers already! " << it->second->bearerCounter);
118  BearerInfo bearerInfo;
119  bearerInfo.bearerId = ++(it->second->bearerCounter);
120  bearerInfo.tft = tft;
121  bearerInfo.bearer = bearer;
122  it->second->bearersToBeActivated.push_back (bearerInfo);
123 }
124 
125 
126 // S1-AP SAP MME forwarded methods
127 
128 void
129 EpcMme::DoInitialUeMessage (uint64_t mmeUeS1Id, uint16_t enbUeS1Id, uint64_t imsi, uint16_t gci)
130 {
131  NS_LOG_FUNCTION (this << mmeUeS1Id << enbUeS1Id << imsi << gci);
132  std::map<uint64_t, Ptr<UeInfo> >::iterator it = m_ueInfoMap.find (imsi);
133  NS_ASSERT_MSG (it != m_ueInfoMap.end (), "could not find any UE with IMSI " << imsi);
134  it->second->cellId = gci;
136  msg.imsi = imsi;
137  msg. uli.gci = gci;
138  for (std::list<BearerInfo>::iterator bit = it->second->bearersToBeActivated.begin ();
139  bit != it->second->bearersToBeActivated.end ();
140  ++bit)
141  {
143  bearerContext.epsBearerId = bit->bearerId;
144  bearerContext.bearerLevelQos = bit->bearer;
145  bearerContext.tft = bit->tft;
146  msg.bearerContextsToBeCreated.push_back (bearerContext);
147  }
149 }
150 
151 void
152 EpcMme::DoInitialContextSetupResponse (uint64_t mmeUeS1Id, uint16_t enbUeS1Id, std::list<EpcS1apSapMme::ErabSetupItem> erabSetupList)
153 {
154  NS_LOG_FUNCTION (this << mmeUeS1Id << enbUeS1Id);
155  NS_FATAL_ERROR ("unimplemented");
156 }
157 
158 void
159 EpcMme::DoPathSwitchRequest (uint64_t enbUeS1Id, uint64_t mmeUeS1Id, uint16_t gci, std::list<EpcS1apSapMme::ErabSwitchedInDownlinkItem> erabToBeSwitchedInDownlinkList)
160 {
161  NS_LOG_FUNCTION (this << mmeUeS1Id << enbUeS1Id << gci);
162 
163  uint64_t imsi = mmeUeS1Id;
164  std::map<uint64_t, Ptr<UeInfo> >::iterator it = m_ueInfoMap.find (imsi);
165  NS_ASSERT_MSG (it != m_ueInfoMap.end (), "could not find any UE with IMSI " << imsi);
166  NS_LOG_INFO ("IMSI " << imsi << " old eNB: " << it->second->cellId << ", new eNB: " << gci);
167  it->second->cellId = gci;
168  it->second->enbUeS1Id = enbUeS1Id;
169 
171  msg.teid = imsi; // trick to avoid the need for allocating TEIDs on the S11 interface
172  msg.uli.gci = gci;
173  // bearer modification is not supported for now
175 }
176 
177 
178 // S11 SAP MME forwarded methods
179 
180 void
182 {
183  NS_LOG_FUNCTION (this << msg.teid);
184  uint64_t imsi = msg.teid;
185  std::list<EpcS1apSapEnb::ErabToBeSetupItem> erabToBeSetupList;
186  for (std::list<EpcS11SapMme::BearerContextCreated>::iterator bit = msg.bearerContextsCreated.begin ();
187  bit != msg.bearerContextsCreated.end ();
188  ++bit)
189  {
191  erab.erabId = bit->epsBearerId;
192  erab.erabLevelQosParameters = bit->bearerLevelQos;
193  erab.transportLayerAddress = bit->sgwFteid.address;
194  erab.sgwTeid = bit->sgwFteid.teid;
195  erabToBeSetupList.push_back (erab);
196  }
197  std::map<uint64_t, Ptr<UeInfo> >::iterator it = m_ueInfoMap.find (imsi);
198  NS_ASSERT_MSG (it != m_ueInfoMap.end (), "could not find any UE with IMSI " << imsi);
199  uint16_t cellId = it->second->cellId;
200  uint16_t enbUeS1Id = it->second->enbUeS1Id;
201  uint64_t mmeUeS1Id = it->second->mmeUeS1Id;
202  std::map<uint16_t, Ptr<EnbInfo> >::iterator jt = m_enbInfoMap.find (cellId);
203  NS_ASSERT_MSG (jt != m_enbInfoMap.end (), "could not find any eNB with CellId " << cellId);
204  jt->second->s1apSapEnb->InitialContextSetupRequest (mmeUeS1Id, enbUeS1Id, erabToBeSetupList);
205 }
206 
207 
208 void
210 {
211  NS_LOG_FUNCTION (this << msg.teid);
213  uint64_t imsi = msg.teid;
214  std::map<uint64_t, Ptr<UeInfo> >::iterator it = m_ueInfoMap.find (imsi);
215  NS_ASSERT_MSG (it != m_ueInfoMap.end (), "could not find any UE with IMSI " << imsi);
216  uint64_t enbUeS1Id = it->second->enbUeS1Id;
217  uint64_t mmeUeS1Id = it->second->mmeUeS1Id;
218  uint16_t cgi = it->second->cellId;
219  std::list<EpcS1apSapEnb::ErabSwitchedInUplinkItem> erabToBeSwitchedInUplinkList; // unused for now
220  std::map<uint16_t, Ptr<EnbInfo> >::iterator jt = m_enbInfoMap.find (it->second->cellId);
221  NS_ASSERT_MSG (jt != m_enbInfoMap.end (), "could not find any eNB with CellId " << it->second->cellId);
222  jt->second->s1apSapEnb->PathSwitchRequestAcknowledge (enbUeS1Id, mmeUeS1Id, cgi, erabToBeSwitchedInUplinkList);
223 }
224 
225 } // namespace ns3
void AddUe(uint64_t imsi)
Add a new UE to the MME.
Definition: epc-mme.cc:101
enum ns3::EpcS11SapMme::ModifyBearerResponseMessage::Cause cause
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:59
#define NS_LOG_FUNCTION(parameters)
Definition: log.h:345
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
void DoModifyBearerResponse(EpcS11SapMme::ModifyBearerResponseMessage msg)
Definition: epc-mme.cc:209
NS_LOG_COMPONENT_DEFINE("EpcMme")
#define NS_ASSERT(condition)
Definition: assert.h:64
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
std::map< uint16_t, Ptr< EnbInfo > > m_enbInfoMap
EnbInfo stored by EGCI.
Definition: epc-mme.h:170
EpcS1apSapMme * GetS1apSapMme()
Definition: epc-mme.cc:72
#define NS_LOG_INFO(msg)
Definition: log.h:298
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:112
EpcS11SapSgw * m_s11SapSgw
Definition: epc-mme.h:178
#define NS_FATAL_ERROR(msg)
fatal error handling
Definition: fatal-error.h:72
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:84
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:48
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:54
#define NS_ASSERT_MSG(condition, message)
Definition: assert.h:86
void DoInitialUeMessage(uint64_t mmeUeS1Id, uint16_t enbUeS1Id, uint64_t imsi, uint16_t ecgi)
Definition: epc-mme.cc:129
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:152
void AddEnb(uint16_t ecgi, Ipv4Address enbS1UAddr, EpcS1apSapEnb *enbS1apSap)
Add a new ENB to the MME.
Definition: epc-mme.cc:90
void DoPathSwitchRequest(uint64_t enbUeS1Id, uint64_t mmeUeS1Id, uint16_t cgi, std::list< EpcS1apSapMme::ErabSwitchedInDownlinkItem > erabToBeSwitchedInDownlinkList)
Definition: epc-mme.cc:159
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:63
Modify Bearer Response message, see 3GPP TS 29.274 7.2.7.
Definition: epc-s11-sap.h:110
EpcMme()
Constructor.
Definition: epc-mme.cc:39
EpcS1apSapMme * m_s1apSapMme
Definition: epc-mme.h:175
void SetS11SapSgw(EpcS11SapSgw *s)
Set the SGW side of the S11 SAP.
Definition: epc-mme.cc:78
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:611
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:181
static TypeId GetTypeId(void)
Definition: epc-mme.cc:62
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