OLD | NEW |
(Empty) | |
| 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: Jaume Nin <jnin@cttc.cat> |
| 19 * Nicola Baldo <nbaldo@cttc.cat> |
| 20 */ |
| 21 |
| 22 #ifndef NIST_EPC_ENB_APPLICATION_H |
| 23 #define NIST_EPC_ENB_APPLICATION_H |
| 24 |
| 25 #include <ns3/address.h> |
| 26 #include <ns3/socket.h> |
| 27 #include <ns3/virtual-net-device.h> |
| 28 #include <ns3/traced-callback.h> |
| 29 #include <ns3/callback.h> |
| 30 #include <ns3/ptr.h> |
| 31 #include <ns3/object.h> |
| 32 #include <ns3/nist-lte-common.h> |
| 33 #include <ns3/application.h> |
| 34 #include <ns3/nist-eps-bearer.h> |
| 35 #include <ns3/nist-epc-enb-s1-sap.h> |
| 36 #include <ns3/nist-epc-s1ap-sap.h> |
| 37 #include <map> |
| 38 |
| 39 namespace ns3 { |
| 40 class NistEpcEnbS1SapUser; |
| 41 class NistEpcEnbS1SapProvider; |
| 42 |
| 43 |
| 44 /** |
| 45 * \ingroup lte |
| 46 * |
| 47 * This application is installed inside eNBs and provides the bridge functionali
ty for user data plane packets between the radio interface and the S1-U interfac
e. |
| 48 */ |
| 49 class NistEpcEnbApplication : public Application |
| 50 { |
| 51 |
| 52 friend class MemberNistEpcEnbS1SapProvider<NistEpcEnbApplication>; |
| 53 friend class MemberNistEpcS1apSapEnb<NistEpcEnbApplication>; |
| 54 |
| 55 |
| 56 // inherited from Object |
| 57 public: |
| 58 static TypeId GetTypeId (void); |
| 59 protected: |
| 60 void DoDispose (void); |
| 61 |
| 62 public: |
| 63 ·· |
| 64 ·· |
| 65 |
| 66 /**· |
| 67 * Constructor |
| 68 *· |
| 69 * \param lteSocket the socket to be used to send/receive packets to/from the
LTE radio interface |
| 70 * \param s1uSocket the socket to be used to send/receive packets |
| 71 * to/from the S1-U interface connected with the SGW· |
| 72 * \param enbS1uAddress the IPv4 address of the S1-U interface of this eNB |
| 73 * \param sgwS1uAddress the IPv4 address at which this eNB will be able to rea
ch its SGW for S1-U communications |
| 74 * \param cellId the identifier of the enb |
| 75 */ |
| 76 NistEpcEnbApplication (Ptr<Socket> lteSocket, Ptr<Socket> s1uSocket, Ipv4Addre
ss enbS1uAddress, Ipv4Address sgwS1uAddress, uint16_t cellId); |
| 77 |
| 78 /** |
| 79 * Destructor |
| 80 *· |
| 81 */ |
| 82 virtual ~NistEpcEnbApplication (void); |
| 83 |
| 84 |
| 85 /**· |
| 86 * Set the S1 SAP User |
| 87 *· |
| 88 * \param s the S1 SAP User |
| 89 */ |
| 90 void SetS1SapUser (NistEpcEnbS1SapUser * s); |
| 91 |
| 92 /**· |
| 93 *· |
| 94 * \return the S1 SAP Provider |
| 95 */ |
| 96 NistEpcEnbS1SapProvider* GetS1SapProvider (); |
| 97 |
| 98 /**· |
| 99 * Set the MME side of the S1-AP SAP· |
| 100 *· |
| 101 * \param s the MME side of the S1-AP SAP· |
| 102 */ |
| 103 void SetS1apSapMme (NistEpcS1apSapMme * s); |
| 104 |
| 105 /**· |
| 106 *· |
| 107 * \return the ENB side of the S1-AP SAP· |
| 108 */ |
| 109 NistEpcS1apSapEnb* GetS1apSapEnb (); |
| 110 · |
| 111 /**· |
| 112 * Method to be assigned to the recv callback of the LTE socket. It is called
when the eNB receives a data packet from the radio interface that is to be forwa
rded to the SGW. |
| 113 *· |
| 114 * \param socket pointer to the LTE socket |
| 115 */ |
| 116 void RecvFromLteSocket (Ptr<Socket> socket); |
| 117 |
| 118 |
| 119 /**· |
| 120 * Method to be assigned to the recv callback of the S1-U socket. It is called
when the eNB receives a data packet from the SGW that is to be forwarded to the
UE. |
| 121 *· |
| 122 * \param socket pointer to the S1-U socket |
| 123 */ |
| 124 void RecvFromS1uSocket (Ptr<Socket> socket); |
| 125 |
| 126 |
| 127 struct NistEpsFlowId_t |
| 128 { |
| 129 uint16_t m_rnti; |
| 130 uint8_t m_bid; |
| 131 |
| 132 public: |
| 133 NistEpsFlowId_t (); |
| 134 NistEpsFlowId_t (const uint16_t a, const uint8_t b); |
| 135 |
| 136 friend bool operator == (const NistEpsFlowId_t &a, const NistEpsFlowId_t &b)
; |
| 137 friend bool operator < (const NistEpsFlowId_t &a, const NistEpsFlowId_t &b); |
| 138 }; |
| 139 |
| 140 |
| 141 private: |
| 142 |
| 143 // ENB S1 SAP provider methods |
| 144 void DoInitialUeMessage (uint64_t imsi, uint16_t rnti); |
| 145 void DoPathSwitchRequest (NistEpcEnbS1SapProvider::NistPathSwitchRequestParame
ters params); |
| 146 void DoUeContextRelease (uint16_t rnti); |
| 147 ·· |
| 148 // S1-AP SAP ENB methods |
| 149 void DoInitialContextSetupRequest (uint64_t mmeUeS1Id, uint16_t enbUeS1Id, std
::list<NistEpcS1apSapEnb::NistErabToBeSetupItem> erabToBeSetupList); |
| 150 void DoPathSwitchRequestAcknowledge (uint64_t enbUeS1Id, uint64_t mmeUeS1Id, u
int16_t cgi, std::list<NistEpcS1apSapEnb::NistErabSwitchedInUplinkItem> erabToBe
SwitchedInUplinkList); |
| 151 |
| 152 /**· |
| 153 * \brief This function accepts bearer id corresponding to a particular UE and
schedules indication of bearer release towards MME |
| 154 * \param imsi maps to mmeUeS1Id |
| 155 * \param rnti maps to enbUeS1Id |
| 156 * \param bearerId Bearer Identity which is to be de-activated |
| 157 */ |
| 158 void DoReleaseIndication (uint64_t imsi, uint16_t rnti, uint8_t bearerId); |
| 159 |
| 160 |
| 161 /** |
| 162 * Send a packet to the UE via the LTE radio interface of the eNB |
| 163 *· |
| 164 * \param packet t |
| 165 * \param bid the EPS Bearer IDentifier |
| 166 */ |
| 167 void SendToLteSocket (Ptr<Packet> packet, uint16_t rnti, uint8_t bid); |
| 168 |
| 169 |
| 170 /**· |
| 171 * Send a packet to the SGW via the S1-U interface |
| 172 *· |
| 173 * \param packet packet to be sent |
| 174 * \param teid the Tunnel Enpoint IDentifier |
| 175 */ |
| 176 void SendToS1uSocket (Ptr<Packet> packet, uint32_t teid); |
| 177 |
| 178 |
| 179 ·· |
| 180 /**· |
| 181 * internal method used for the actual setup of the S1 Bearer |
| 182 *· |
| 183 * \param teid· |
| 184 * \param rnti· |
| 185 * \param bid· |
| 186 */ |
| 187 void SetupS1Bearer (uint32_t teid, uint16_t rnti, uint8_t bid); |
| 188 |
| 189 /** |
| 190 * raw packet socket to send and receive the packets to and from the LTE radio
interface |
| 191 */ |
| 192 Ptr<Socket> m_lteSocket; |
| 193 |
| 194 /** |
| 195 * UDP socket to send and receive GTP-U the packets to and from the S1-U inter
face |
| 196 */ |
| 197 Ptr<Socket> m_s1uSocket; |
| 198 |
| 199 /** |
| 200 * address of the eNB for S1-U communications |
| 201 */ |
| 202 Ipv4Address m_enbS1uAddress; |
| 203 |
| 204 /** |
| 205 * address of the SGW which terminates all S1-U tunnels |
| 206 */ |
| 207 Ipv4Address m_sgwS1uAddress; |
| 208 |
| 209 /** |
| 210 * map of maps telling for each RNTI and BID the corresponding S1-U TEID |
| 211 *· |
| 212 */ |
| 213 std::map<uint16_t, std::map<uint8_t, uint32_t> > m_rbidTeidMap;·· |
| 214 |
| 215 /** |
| 216 * map telling for each S1-U TEID the corresponding RNTI,BID |
| 217 *· |
| 218 */ |
| 219 std::map<uint32_t, NistEpsFlowId_t> m_teidRbidMap; |
| 220 · |
| 221 /** |
| 222 * UDP port to be used for GTP |
| 223 */ |
| 224 uint16_t m_gtpuUdpPort; |
| 225 |
| 226 /** |
| 227 * Provider for the S1 SAP· |
| 228 */ |
| 229 NistEpcEnbS1SapProvider* m_s1SapProvider; |
| 230 |
| 231 /** |
| 232 * User for the S1 SAP· |
| 233 */ |
| 234 NistEpcEnbS1SapUser* m_s1SapUser; |
| 235 |
| 236 /** |
| 237 * MME side of the S1-AP SAP |
| 238 *· |
| 239 */ |
| 240 NistEpcS1apSapMme* m_s1apSapMme; |
| 241 |
| 242 /** |
| 243 * ENB side of the S1-AP SAP |
| 244 *· |
| 245 */ |
| 246 NistEpcS1apSapEnb* m_s1apSapEnb; |
| 247 |
| 248 /** |
| 249 * UE context info |
| 250 *· |
| 251 */ |
| 252 std::map<uint64_t, uint16_t> m_imsiRntiMap; |
| 253 |
| 254 uint16_t m_cellId; |
| 255 |
| 256 }; |
| 257 |
| 258 } //namespace ns3 |
| 259 |
| 260 #endif /* NIST_EPC_ENB_APPLICATION_H */ |
| 261 |
OLD | NEW |