A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
lte-enb-rrc.h
Go to the documentation of this file.
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2011, 2012 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  * Authors: Nicola Baldo <nbaldo@cttc.es>
19  * Marco Miozzo <mmiozzo@cttc.es>
20  * Manuel Requena <manuel.requena@cttc.es>
21  */
22 
23 #ifndef LTE_ENB_RRC_H
24 #define LTE_ENB_RRC_H
25 
26 #include <ns3/nstime.h>
27 #include <ns3/object.h>
28 #include <ns3/packet.h>
29 #include <ns3/lte-enb-cmac-sap.h>
30 #include <ns3/lte-mac-sap.h>
31 #include <ns3/ff-mac-sched-sap.h>
32 #include <ns3/lte-pdcp-sap.h>
33 #include <ns3/epc-x2-sap.h>
34 #include <ns3/epc-enb-s1-sap.h>
35 #include <ns3/lte-enb-cphy-sap.h>
36 #include <ns3/lte-rrc-sap.h>
37 #include <ns3/traced-callback.h>
38 #include <ns3/event-id.h>
39 
40 #include <map>
41 #include <set>
42 
43 namespace ns3 {
44 
45 class LteRadioBearerInfo;
46 class LteSignalingRadioBearerInfo;
47 class LteDataRadioBearerInfo;
48 class EpcEnbS1SapUser;
49 class EpcEnbS1SapProvider;
50 class LteUeRrc;
51 class LteEnbRrc;
52 
57 class UeManager : public Object
58 {
60 
61 public:
62 
63 
68  enum State
69  {
81  };
82 
83  UeManager ();
84 
94  UeManager (Ptr<LteEnbRrc> rrc, uint16_t rnti, State s);
95 
96  virtual ~UeManager (void);
97 
98  // inherited from Object
99 protected:
100  virtual void DoInitialize ();
101  virtual void DoDispose ();
102 public:
103  static TypeId GetTypeId (void);
104 
112  void SetSource (uint16_t sourceCellId, uint16_t sourceX2apId);
113 
119  void SetImsi (uint64_t imsi);
120 
131  void SetupDataRadioBearer (EpsBearer bearer, uint8_t bearerId, uint32_t gtpTeid, Ipv4Address transportLayerAddress);
132 
139 
145  void StartDataRadioBearers ();
146 
153  void ReleaseDataRadioBearer (uint8_t drbid);
154 
160 
166  void PrepareHandover (uint16_t cellId);
167 
174 
181 
192 
199  void SendData (uint8_t bid, Ptr<Packet> p);
200 
205  std::vector<EpcX2Sap::ErabToBeSetupItem> GetErabList ();
206 
212  void SendUeContextRelease ();
213 
219  void RecvHandoverPreparationFailure (uint16_t cellId);
220 
227 
228 
229  // methods forwarded from RRC SAP
237 
238 
239  // methods forwarded from CMAC SAP
241 
242 
243  // methods forwarded from PDCP SAP
245 
251  uint16_t GetRnti (void);
252 
257  uint64_t GetImsi (void);
258 
263  uint16_t GetSrsConfigurationIndex (void);
264 
270  void SetSrsConfigurationIndex (uint16_t srsConfIndex);
271 
276  State GetState ();
277 
278 
279 private:
280 
288  uint8_t AddDataRadioBearerInfo (Ptr<LteDataRadioBearerInfo> radioBearerInfo);
289 
296 
302  void RemoveDataRadioBearerInfo (uint8_t drbid);
303 
310 
317 
318 
324 
330  uint8_t Lcid2Drbid (uint8_t lcid);
331 
337  uint8_t Drbid2Lcid (uint8_t drbid);
338 
344  uint8_t Lcid2Bid (uint8_t lcid);
345 
351  uint8_t Bid2Lcid (uint8_t bid);
352 
358  uint8_t Drbid2Bid (uint8_t drbid);
359 
365  uint8_t Bid2Drbid (uint8_t bid);
366 
372  void SwitchToState (State s);
373 
374 
375  std::map <uint8_t, Ptr<LteDataRadioBearerInfo> > m_drbMap;
379  uint16_t m_rnti;
380  uint64_t m_imsi;
387  // imsi cellid rnti old new
389  uint16_t m_sourceX2apId;
390  uint16_t m_sourceCellId;
391  uint16_t m_targetCellId;
392  std::list<uint8_t> m_drbsToBeStarted;
395 };
396 
397 
403 class LteEnbRrc : public Object
404 {
405 
410  friend class UeManager;
411 
412 public:
417  LteEnbRrc ();
418 
422  virtual ~LteEnbRrc ();
423 
424 
425  // inherited from Object
426 protected:
427  virtual void DoDispose (void);
428 public:
429  static TypeId GetTypeId (void);
430 
431 
437 
443 
444 
451 
457 
458 
465 
472 
481 
482 
489 
495 
496 
503 
510 
518  Ptr<UeManager> GetUeManager (uint16_t rnti);
519 
529  void ConfigureCell (uint8_t ulBandwidth,
530  uint8_t dlBandwidth,
531  uint16_t ulEarfcn,
532  uint16_t dlEarfcn,
533  uint16_t cellId);
534 
540  void SetCellId (uint16_t m_cellId);
541 
551  bool SendData (Ptr<Packet> p);
552 
559  void SetForwardUpCallback (Callback <void, Ptr<Packet> > cb);
560 
567  void ConnectionTimeout (uint16_t rnti);
568 
579  void SendHandoverRequest (uint16_t rnti, uint16_t cellId);
580 
588  PER_BASED = 4};
589 
590 private:
591 
592 
593  // methods forwarded from RRC SAP
594 
601  void DoRecvMeasurementReport (uint16_t rnti, LteRrcSap::MeasurementReport msg);
602 
603 
604  // S1 SAP methods
607  // X2 SAP methods
616 
617 
618  // CMAC SAP methods
619  uint16_t DoAllocateTemporaryCellRnti ();
620  void DoNotifyLcConfigResult (uint16_t rnti, uint8_t lcid, bool success);
622 
623 
624  // Internal methods
625 
635  uint16_t AddUe (UeManager::State state);
636 
642  void RemoveUe (uint16_t rnti);
643 
644 
651  TypeId GetRlcType (EpsBearer bearer);
652 
653 
654 public:
655 
660  void SetSrsPeriodicity (uint32_t p);
661 
666  uint32_t GetSrsPeriodicity () const;
667 
668 private:
669 
678  uint16_t GetNewSrsConfigurationIndex (void);
679 
688  void RemoveSrsConfigurationIndex (uint16_t srcCi);
689 
690 
691 
699  uint8_t GetLogicalChannelGroup (EpsBearer bearer);
700 
709  uint8_t GetLogicalChannelPriority (EpsBearer bearer);
710 
711 
716  void SendSystemInformation ();
717 
719 
722 
725 
728 
730 
733 
736 
738  uint16_t m_cellId;
739  uint16_t m_dlEarfcn;
740  uint16_t m_ulEarfcn;
741  uint16_t m_dlBandwidth;
742  uint16_t m_ulBandwidth;
744 
745  std::map<uint16_t, Ptr<UeManager> > m_ueMap;
746 
747  struct X2uTeidInfo
748  {
749  uint16_t rnti;
750  uint8_t drbid;
751  };
752 
753  // TEID RNTI, DRBID
754  std::map<uint32_t, X2uTeidInfo> m_x2uTeidInfoMap;
755 
757 
759 
761 
762  // SRS related attributes
764  std::set<uint16_t> m_ueSrsConfigurationIndexSet;
767 
770 
771  // cellid rnti
773  // imsi cellid rnti
775  // imsi cellid rnti
777  // imsi cellid rnti targetCellId
779  // imsi cellid rnti
781 
782 };
783 
784 
785 } // namespace ns3
786 
787 #endif // LTE_ENB_RRC_H