src/lte/model/radio-bearer-instance.cc
changeset 8749 4462ac63d4cf
parent 8748 87a141a38088
parent 8747 2aec19a85c73
child 8750 b3db7d51f260
child 8765 b89660102b63
equal deleted inserted replaced
8748:87a141a38088 8749:4462ac63d4cf
     1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
       
     2 /*
       
     3  * Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
       
     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: Giuseppe Piro  <g.piro@poliba.it>
       
    19  */
       
    20 
       
    21 
       
    22 #include "radio-bearer-instance.h"
       
    23 #include "bearer-qos-parameters.h"
       
    24 #include "ns3/ipcs-classifier-record.h"
       
    25 #include "rlc-entity.h"
       
    26 #include <ns3/log.h>
       
    27 #include <ns3/pointer.h>
       
    28 
       
    29 NS_LOG_COMPONENT_DEFINE ("RadioBearerInstance");
       
    30 
       
    31 namespace ns3 {
       
    32 
       
    33 
       
    34 NS_OBJECT_ENSURE_REGISTERED (RadioBearerInstance);
       
    35 
       
    36 TypeId RadioBearerInstance::GetTypeId (void)
       
    37 {
       
    38   static TypeId tid = TypeId ("ns3::RadioBearerInstance")
       
    39     .SetParent<Object> ()
       
    40     .AddAttribute ("TxQueue",
       
    41                    "Transmit queue",
       
    42                    PointerValue (),
       
    43                    MakePointerAccessor (&RadioBearerInstance::GetQueue),
       
    44                    MakePointerChecker<LteMacQueue> ());
       
    45   return tid;
       
    46 }
       
    47 
       
    48 
       
    49 RadioBearerInstance::RadioBearerInstance ()
       
    50   : m_queue (CreateObject<LteMacQueue> (1024)),
       
    51     m_qosParameters (0),
       
    52     m_rlcEntity (CreateObject<RlcEntity> ()),
       
    53     m_ipcsClassifierRecord (0)
       
    54 {
       
    55   NS_LOG_FUNCTION (this);
       
    56   m_rlcEntity->SetRadioBearer (this);
       
    57 }
       
    58 
       
    59 
       
    60 RadioBearerInstance::~RadioBearerInstance ()
       
    61 {
       
    62   NS_LOG_FUNCTION (this);
       
    63   m_rlcEntity = 0;
       
    64   m_queue = 0;
       
    65   m_ipcsClassifierRecord = 0;
       
    66 }
       
    67 
       
    68 
       
    69 void
       
    70 RadioBearerInstance::DoDispose (void)
       
    71 {
       
    72   NS_LOG_FUNCTION (this);
       
    73   m_queue = 0;
       
    74   m_qosParameters = 0;
       
    75   m_rlcEntity->Dispose ();
       
    76   m_rlcEntity = 0;
       
    77 }
       
    78 
       
    79 
       
    80 void
       
    81 RadioBearerInstance::SetBearerDirection (BearerDirection direction)
       
    82 {
       
    83   m_direction = direction;
       
    84 }
       
    85 
       
    86 
       
    87 RadioBearerInstance::BearerDirection
       
    88 RadioBearerInstance::GetBearerDirection (void) const
       
    89 {
       
    90   return m_direction;
       
    91 }
       
    92 
       
    93 
       
    94 void
       
    95 RadioBearerInstance::SetBearerType (BearerType type)
       
    96 {
       
    97   m_bearerType = type;
       
    98 }
       
    99 
       
   100 
       
   101 RadioBearerInstance::BearerType
       
   102 RadioBearerInstance::GetBearerType (void) const
       
   103 {
       
   104   return m_bearerType;
       
   105 }
       
   106 
       
   107 
       
   108 void
       
   109 RadioBearerInstance::SetQosParameters (Ptr<BearerQosParameters> qosParameters)
       
   110 {
       
   111   m_qosParameters = qosParameters;
       
   112 }
       
   113 
       
   114 
       
   115 Ptr<BearerQosParameters>
       
   116 RadioBearerInstance::GetQosParameters (void)
       
   117 {
       
   118   return m_qosParameters;
       
   119 }
       
   120 
       
   121 
       
   122 
       
   123 Ptr<LteMacQueue>
       
   124 RadioBearerInstance::GetQueue (void) const
       
   125 {
       
   126   NS_LOG_FUNCTION (this);
       
   127   return m_queue;
       
   128 }
       
   129 
       
   130 
       
   131 bool
       
   132 RadioBearerInstance::Enqueue (Ptr<Packet> packet)
       
   133 {
       
   134   NS_LOG_FUNCTION (this);
       
   135   return m_queue->Enqueue (packet);
       
   136 }
       
   137 
       
   138 
       
   139 Ptr<Packet>
       
   140 RadioBearerInstance::Dequeue (void)
       
   141 {
       
   142   NS_LOG_FUNCTION (this);
       
   143   return m_queue->Dequeue ();
       
   144 }
       
   145 
       
   146 
       
   147 Ptr<Packet>
       
   148 RadioBearerInstance::Dequeue (uint32_t availableByte)
       
   149 {
       
   150   NS_LOG_FUNCTION (this);
       
   151   /*
       
   152    This function can be caled when the UM or AM RLC mode is abilited.
       
   153    The bearer gives packets to rlc-entiry until all available byte will be used.
       
   154    */
       
   155   // return m_queue->Dequeue (availableByte);
       
   156   return 0;
       
   157 }
       
   158 
       
   159 
       
   160 bool
       
   161 RadioBearerInstance::HasPackets (void) const
       
   162 {
       
   163   NS_LOG_FUNCTION (this);
       
   164   return !m_queue->IsEmpty ();
       
   165 }
       
   166 
       
   167 
       
   168 void
       
   169 RadioBearerInstance::SetRlcEntity (Ptr<RlcEntity> rlc)
       
   170 {
       
   171   NS_LOG_FUNCTION (this);
       
   172   m_rlcEntity = rlc;
       
   173 }
       
   174 
       
   175 
       
   176 Ptr<RlcEntity>
       
   177 RadioBearerInstance::GetRlcEntity (void)
       
   178 {
       
   179   NS_LOG_FUNCTION (this);
       
   180   return m_rlcEntity;
       
   181 }
       
   182 
       
   183 
       
   184 void 
       
   185 RadioBearerInstance::SetIpcsClassifierRecord (IpcsClassifierRecord* c)
       
   186 {
       
   187   NS_LOG_FUNCTION (this << c);
       
   188   NS_ASSERT (m_ipcsClassifierRecord == 0);
       
   189   m_ipcsClassifierRecord = c;
       
   190 }
       
   191 
       
   192 IpcsClassifierRecord* 
       
   193 RadioBearerInstance::GetIpcsClassifierRecord (void)
       
   194 {
       
   195   NS_LOG_FUNCTION (this);
       
   196   return m_ipcsClassifierRecord;
       
   197 }
       
   198 
       
   199 } // namespace ns3