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 
53 
58 class NeighbourRelation : public Object
59 {
60 public:
61  uint16_t m_physCellId;
62  bool m_noRemove;
63  bool m_noHo;
64  bool m_noX2;
66 };
67 
72 class UeMeasure : public Object
73 {
74 public:
75  uint16_t m_cellId;
76  uint8_t m_rsrp;
77  uint8_t m_rsrq;
78 };
79 
80 
85 class UeManager : public Object
86 {
88 
89 public:
90 
91 
96  enum State
97  {
109  };
110 
111  UeManager ();
112 
122  UeManager (Ptr<LteEnbRrc> rrc, uint16_t rnti, State s);
123 
124  virtual ~UeManager (void);
125 
126  // inherited from Object
127 protected:
128  virtual void DoInitialize ();
129  virtual void DoDispose ();
130 public:
131  static TypeId GetTypeId (void);
132 
140  void SetSource (uint16_t sourceCellId, uint16_t sourceX2apId);
141 
147  void SetImsi (uint64_t imsi);
148 
159  void SetupDataRadioBearer (EpsBearer bearer, uint8_t bearerId, uint32_t gtpTeid, Ipv4Address transportLayerAddress);
160 
167 
173  void StartDataRadioBearers ();
174 
181  void ReleaseDataRadioBearer (uint8_t drbid);
182 
188 
194  void PrepareHandover (uint16_t cellId);
195 
202 
209 
220 
227  void SendData (uint8_t bid, Ptr<Packet> p);
228 
233  std::vector<EpcX2Sap::ErabToBeSetupItem> GetErabList ();
234 
240  void SendUeContextRelease ();
241 
247  void RecvHandoverPreparationFailure (uint16_t cellId);
248 
255 
262 
263  // methods forwarded from RRC SAP
271 
272 
273  // methods forwarded from CMAC SAP
275 
276 
277  // methods forwarded from PDCP SAP
279 
285  uint16_t GetRnti (void);
286 
291  uint64_t GetImsi (void);
292 
297  uint16_t GetSrsConfigurationIndex (void);
298 
304  void SetSrsConfigurationIndex (uint16_t srsConfIndex);
305 
310  State GetState ();
311 
312 
313 private:
314 
322  uint8_t AddDataRadioBearerInfo (Ptr<LteDataRadioBearerInfo> radioBearerInfo);
323 
330 
336  void RemoveDataRadioBearerInfo (uint8_t drbid);
337 
344 
351 
358 
359 
365 
371  uint8_t Lcid2Drbid (uint8_t lcid);
372 
378  uint8_t Drbid2Lcid (uint8_t drbid);
379 
385  uint8_t Lcid2Bid (uint8_t lcid);
386 
392  uint8_t Bid2Lcid (uint8_t bid);
393 
399  uint8_t Drbid2Bid (uint8_t drbid);
400 
406  uint8_t Bid2Drbid (uint8_t bid);
407 
413  void SwitchToState (State s);
414 
415 
416  std::map <uint8_t, Ptr<LteDataRadioBearerInfo> > m_drbMap;
420  uint16_t m_rnti;
421  uint64_t m_imsi;
428  // imsi cellid rnti old new
430  uint16_t m_sourceX2apId;
431  uint16_t m_sourceCellId;
432  uint16_t m_targetCellId;
433  std::list<uint8_t> m_drbsToBeStarted;
435 
440 
442  // cellid
443  std::map<uint16_t, Ptr<UeMeasure> > m_neighbourCellMeasures;
444 
445 };
446 
447 
453 class LteEnbRrc : public Object
454 {
455 
460  friend class UeManager;
461 
462 public:
467  LteEnbRrc ();
468 
472  virtual ~LteEnbRrc ();
473 
474 
475  // inherited from Object
476 protected:
477  virtual void DoDispose (void);
478 public:
479  static TypeId GetTypeId (void);
480 
481 
487 
493 
494 
501 
507 
508 
515 
522 
531 
532 
539 
545 
546 
553 
560 
568  Ptr<UeManager> GetUeManager (uint16_t rnti);
569 
579  void ConfigureCell (uint8_t ulBandwidth,
580  uint8_t dlBandwidth,
581  uint16_t ulEarfcn,
582  uint16_t dlEarfcn,
583  uint16_t cellId);
584 
590  void SetCellId (uint16_t m_cellId);
591 
601  bool SendData (Ptr<Packet> p);
602 
609  void SetForwardUpCallback (Callback <void, Ptr<Packet> > cb);
610 
617  void ConnectionTimeout (uint16_t rnti);
618 
624  void ConnectionRejectedTimeout (uint16_t rnti);
625 
632  void HandoverJoiningTimeout (uint16_t rnti);
633 
640  void HandoverLeavingTimeout (uint16_t rnti);
641 
652  void SendHandoverRequest (uint16_t rnti, uint16_t cellId);
653 
661  PER_BASED = 4};
662 
663 private:
664 
665 
666  // methods forwarded from RRC SAP
667 
674  void DoRecvMeasurementReport (uint16_t rnti, LteRrcSap::MeasurementReport msg);
675 
676 
677  // S1 SAP methods
680  // X2 SAP methods
689 
690 
691  // CMAC SAP methods
692  uint16_t DoAllocateTemporaryCellRnti ();
693  void DoNotifyLcConfigResult (uint16_t rnti, uint8_t lcid, bool success);
695 
696 
697  // Internal methods
698 
708  uint16_t AddUe (UeManager::State state);
709 
715  void RemoveUe (uint16_t rnti);
716 
717 
724  TypeId GetRlcType (EpsBearer bearer);
725 
726 
727 
728 public:
729 
735  void AddX2Neighbour (uint16_t cellId);
736 
741  void SetSrsPeriodicity (uint32_t p);
742 
747  uint32_t GetSrsPeriodicity () const;
748 
749 private:
750 
759  uint16_t GetNewSrsConfigurationIndex (void);
760 
769  void RemoveSrsConfigurationIndex (uint16_t srcCi);
770 
771 
772 
780  uint8_t GetLogicalChannelGroup (EpsBearer bearer);
781 
790  uint8_t GetLogicalChannelPriority (EpsBearer bearer);
791 
792 
797  void SendSystemInformation ();
798 
800 
803 
806 
809 
811 
814 
817 
819  uint16_t m_cellId;
820  uint16_t m_dlEarfcn;
821  uint16_t m_ulEarfcn;
822  uint16_t m_dlBandwidth;
823  uint16_t m_ulBandwidth;
825 
826  std::map<uint16_t, Ptr<UeManager> > m_ueMap;
827 
828  struct X2uTeidInfo
829  {
830  uint16_t rnti;
831  uint8_t drbid;
832  };
833 
834  // TEID RNTI, DRBID
835  std::map<uint32_t, X2uTeidInfo> m_x2uTeidInfoMap;
836 
838 
840 
842 
843  // SRS related attributes
845  std::set<uint16_t> m_ueSrsConfigurationIndexSet;
848 
849  // Handover related attributes
856 
857  // timeouts
862 
863  // cellid
864  std::map<uint16_t, Ptr<NeighbourRelation> > m_neighbourRelationTable;
865 
866 
867  // cellid rnti
869  // imsi cellid rnti
871  // imsi cellid rnti
873  // imsi cellid rnti targetCellId
875  // imsi cellid rnti
877 
878  // imsi cellid rnti
880 
881 };
882 
883 
884 } // namespace ns3
885 
886 #endif // LTE_ENB_RRC_H