src/lte/model/lte-ue-mac.cc
author Manuel Requena <manuel.requena@cttc.es>
Tue, 26 Mar 2013 10:41:49 +0100
changeset 10019 6efd95740e39
parent 9632 09dac25f1230
child 9870 6543f3876ff5
child 10024 07b1d791701f
permissions -rw-r--r--
Add automatic triger of the HO based on the RSRQ measures
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7886
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
     1
/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
     2
/*
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
     3
 * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
     4
 *
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License version 2 as
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
     7
 * published by the Free Software Foundation;
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
     8
 *
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
    12
 * GNU General Public License for more details.
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
    13
 *
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
    17
 *
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
    18
 * Author: Nicola Baldo  <nbaldo@cttc.es>
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
    19
 * Author: Marco Miozzo <mmiozzo@cttc.es>
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
    20
 */
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
    21
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
    22
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
    23
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
    24
#include <ns3/log.h>
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
    25
#include <ns3/pointer.h>
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
    26
#include <ns3/packet.h>
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
    27
#include <ns3/packet-burst.h>
9414
7b0db3dbf19b merged lena-dev and lena-epc
Nicola Baldo <nbaldo@cttc.es>
parents: 9413 9351
diff changeset
    28
#include <ns3/random-variable.h>
7886
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
    29
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
    30
#include "lte-ue-mac.h"
7887
78911c978517 renamed several LTE files and classes
CTTC
parents: 7886
diff changeset
    31
#include "lte-ue-net-device.h"
8462
cf6a48994db5 renamed LteMacTag --> LteRadioBearerTag
Nicola Baldo <nbaldo@cttc.es>
parents: 8436
diff changeset
    32
#include "lte-radio-bearer-tag.h"
7886
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
    33
#include <ns3/ff-mac-common.h>
9035
e40974228d94 Update Phy Layer for managing different frames for different set of channels (data vs. ctrl and srs)
Marco Miozzo <marco.miozzo@cttc.es>
parents: 8763
diff changeset
    34
#include <ns3/lte-control-messages.h>
8415
e9a27a8c6331 Uplink scheduler with multiple bearers (LCs) allocates in a Round Robin fashion the active ones
mmiozzo
parents: 8148
diff changeset
    35
#include <ns3/simulator.h>
8435
6b0542a91970 Transmission queue head-of-line delay and queue size at MAC Scheduler
mmiozzo
parents: 8416
diff changeset
    36
#include <ns3/lte-common.h>
7886
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
    37
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
    38
9414
7b0db3dbf19b merged lena-dev and lena-epc
Nicola Baldo <nbaldo@cttc.es>
parents: 9413 9351
diff changeset
    39
7886
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
    40
NS_LOG_COMPONENT_DEFINE ("LteUeMac");
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
    41
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
    42
namespace ns3 {
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
    43
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
    44
NS_OBJECT_ENSURE_REGISTERED (LteUeMac);
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
    45
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
    46
8436
c5b3b5ba81be Remove BufferSizeLevelBsr table in LteUeMac, moved to lte-common
mmiozzo
parents: 8435
diff changeset
    47
///////////////////////////////////////////////////////////
7886
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
    48
// SAP forwarders
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
    49
///////////////////////////////////////////////////////////
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
    50
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
    51
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
    52
class UeMemberLteUeCmacSapProvider : public LteUeCmacSapProvider
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
    53
{
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
    54
public:
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
    55
  UeMemberLteUeCmacSapProvider (LteUeMac* mac);
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
    56
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
    57
  // inherited from LteUeCmacSapProvider
9413
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
    58
  virtual void ConfigureRach (RachConfig rc);
9406
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
    59
  virtual void StartContentionBasedRandomAccessProcedure ();
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
    60
  virtual void StartNonContentionBasedRandomAccessProcedure (uint16_t rnti, uint8_t preambleId, uint8_t prachMask);
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
    61
  virtual void AddLc (uint8_t lcId, LteUeCmacSapProvider::LogicalChannelConfig lcConfig, LteMacSapUser* msu);
7886
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
    62
  virtual void RemoveLc (uint8_t lcId);
9406
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
    63
  virtual void Reset ();
7886
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
    64
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
    65
private:
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
    66
  LteUeMac* m_mac;
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
    67
};
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
    68
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
    69
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
    70
UeMemberLteUeCmacSapProvider::UeMemberLteUeCmacSapProvider (LteUeMac* mac)
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
    71
  : m_mac (mac)
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
    72
{
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
    73
}
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
    74
9413
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
    75
void 
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
    76
UeMemberLteUeCmacSapProvider::ConfigureRach (RachConfig rc)
7886
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
    77
{
9413
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
    78
  m_mac->DoConfigureRach (rc);
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
    79
}
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
    80
9406
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
    81
  void 
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
    82
UeMemberLteUeCmacSapProvider::StartContentionBasedRandomAccessProcedure ()
7886
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
    83
{
9406
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
    84
  m_mac->DoStartContentionBasedRandomAccessProcedure ();
7886
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
    85
}
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
    86
9406
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
    87
 void 
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
    88
UeMemberLteUeCmacSapProvider::StartNonContentionBasedRandomAccessProcedure (uint16_t rnti, uint8_t preambleId, uint8_t prachMask)
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
    89
{
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
    90
  m_mac->DoStartNonContentionBasedRandomAccessProcedure (rnti, preambleId, prachMask);
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
    91
}
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
    92
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
    93
7886
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
    94
void
9406
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
    95
UeMemberLteUeCmacSapProvider::AddLc (uint8_t lcId, LogicalChannelConfig lcConfig, LteMacSapUser* msu)
7886
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
    96
{
9406
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
    97
  m_mac->DoAddLc (lcId, lcConfig, msu);
7886
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
    98
}
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
    99
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   100
void
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   101
UeMemberLteUeCmacSapProvider::RemoveLc (uint8_t lcid)
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   102
{
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   103
  m_mac->DoRemoveLc (lcid);
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   104
}
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   105
9406
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   106
void
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   107
UeMemberLteUeCmacSapProvider::Reset ()
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   108
{
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   109
  m_mac->DoReset ();
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   110
}
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   111
7886
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   112
class UeMemberLteMacSapProvider : public LteMacSapProvider
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   113
{
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   114
public:
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   115
  UeMemberLteMacSapProvider (LteUeMac* mac);
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   116
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   117
  // inherited from LteMacSapProvider
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   118
  virtual void TransmitPdu (TransmitPduParameters params);
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   119
  virtual void ReportBufferStatus (ReportBufferStatusParameters params);
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   120
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   121
private:
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   122
  LteUeMac* m_mac;
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   123
};
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   124
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   125
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   126
UeMemberLteMacSapProvider::UeMemberLteMacSapProvider (LteUeMac* mac)
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   127
  : m_mac (mac)
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   128
{
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   129
}
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   130
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   131
void
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   132
UeMemberLteMacSapProvider::TransmitPdu (TransmitPduParameters params)
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   133
{
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   134
  m_mac->DoTransmitPdu (params);
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   135
}
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   136
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   137
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   138
void
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   139
UeMemberLteMacSapProvider::ReportBufferStatus (ReportBufferStatusParameters params)
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   140
{
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   141
  m_mac->DoReportBufferStatus (params);
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   142
}
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   143
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   144
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   145
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   146
7887
78911c978517 renamed several LTE files and classes
CTTC
parents: 7886
diff changeset
   147
class UeMemberLteUePhySapUser : public LteUePhySapUser
7886
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   148
{
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   149
public:
7887
78911c978517 renamed several LTE files and classes
CTTC
parents: 7886
diff changeset
   150
  UeMemberLteUePhySapUser (LteUeMac* mac);
7886
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   151
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   152
  // inherited from LtePhySapUser
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   153
  virtual void ReceivePhyPdu (Ptr<Packet> p);
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   154
  virtual void SubframeIndication (uint32_t frameNo, uint32_t subframeNo);
9035
e40974228d94 Update Phy Layer for managing different frames for different set of channels (data vs. ctrl and srs)
Marco Miozzo <marco.miozzo@cttc.es>
parents: 8763
diff changeset
   155
  virtual void ReceiveLteControlMessage (Ptr<LteControlMessage> msg);
7886
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   156
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   157
private:
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   158
  LteUeMac* m_mac;
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   159
};
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   160
7887
78911c978517 renamed several LTE files and classes
CTTC
parents: 7886
diff changeset
   161
UeMemberLteUePhySapUser::UeMemberLteUePhySapUser (LteUeMac* mac) : m_mac (mac)
7886
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   162
{
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   163
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   164
}
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   165
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   166
void
7887
78911c978517 renamed several LTE files and classes
CTTC
parents: 7886
diff changeset
   167
UeMemberLteUePhySapUser::ReceivePhyPdu (Ptr<Packet> p)
7886
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   168
{
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   169
  m_mac->DoReceivePhyPdu (p);
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   170
}
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   171
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   172
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   173
void
7887
78911c978517 renamed several LTE files and classes
CTTC
parents: 7886
diff changeset
   174
UeMemberLteUePhySapUser::SubframeIndication (uint32_t frameNo, uint32_t subframeNo)
7886
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   175
{
8415
e9a27a8c6331 Uplink scheduler with multiple bearers (LCs) allocates in a Round Robin fashion the active ones
mmiozzo
parents: 8148
diff changeset
   176
  m_mac->DoSubframeIndication (frameNo, subframeNo);
7886
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   177
}
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   178
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   179
void
9035
e40974228d94 Update Phy Layer for managing different frames for different set of channels (data vs. ctrl and srs)
Marco Miozzo <marco.miozzo@cttc.es>
parents: 8763
diff changeset
   180
UeMemberLteUePhySapUser::ReceiveLteControlMessage (Ptr<LteControlMessage> msg)
7886
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   181
{
9035
e40974228d94 Update Phy Layer for managing different frames for different set of channels (data vs. ctrl and srs)
Marco Miozzo <marco.miozzo@cttc.es>
parents: 8763
diff changeset
   182
  m_mac->DoReceiveLteControlMessage (msg);
7886
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   183
}
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   184
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   185
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   186
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   187
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   188
//////////////////////////////////////////////////////////
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   189
// LteUeMac methods
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   190
///////////////////////////////////////////////////////////
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   191
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   192
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   193
TypeId
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   194
LteUeMac::GetTypeId (void)
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   195
{
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   196
  static TypeId tid = TypeId ("ns3::LteUeMac")
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   197
    .SetParent<Object> ()
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   198
    .AddConstructor<LteUeMac> ();
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   199
  return tid;
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   200
}
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   201
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   202
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   203
LteUeMac::LteUeMac ()
8415
e9a27a8c6331 Uplink scheduler with multiple bearers (LCs) allocates in a Round Robin fashion the active ones
mmiozzo
parents: 8148
diff changeset
   204
  :  m_bsrPeriodicity (MilliSeconds (1)), // ideal behavior
9406
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   205
     m_bsrLast (MilliSeconds (0)),
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   206
     m_freshUlBsr (false),
9414
7b0db3dbf19b merged lena-dev and lena-epc
Nicola Baldo <nbaldo@cttc.es>
parents: 9413 9351
diff changeset
   207
     m_harqProcessId (0),
9413
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   208
     m_rnti (0),
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   209
     m_rachConfigured (false),
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   210
     m_waitingForRaResponse (false)
8415
e9a27a8c6331 Uplink scheduler with multiple bearers (LCs) allocates in a Round Robin fashion the active ones
mmiozzo
parents: 8148
diff changeset
   211
  
7886
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   212
{
7920
dd522ac64b64 added more logging to LteUeMac
Nicola Baldo <nbaldo@cttc.es>
parents: 7887
diff changeset
   213
  NS_LOG_FUNCTION (this);
9351
6e074e67a1ad HARQ first draft version: RR works, PF todo, LteMiErrorModel on-going
mmiozzo
parents: 9346
diff changeset
   214
  m_miUlHarqProcessesPacket.resize (HARQ_PERIOD);
9535
999521532532 Bug-fix LteEnbMac and LteUeMac on HARQ packets buffer in managing several LCs
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9505
diff changeset
   215
  for (uint8_t i = 0; i < m_miUlHarqProcessesPacket.size (); i++)
999521532532 Bug-fix LteEnbMac and LteUeMac on HARQ packets buffer in managing several LCs
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9505
diff changeset
   216
    {
999521532532 Bug-fix LteEnbMac and LteUeMac on HARQ packets buffer in managing several LCs
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9505
diff changeset
   217
      Ptr<PacketBurst> pb = CreateObject <PacketBurst> ();
999521532532 Bug-fix LteEnbMac and LteUeMac on HARQ packets buffer in managing several LCs
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9505
diff changeset
   218
      m_miUlHarqProcessesPacket.at (i) = pb;
999521532532 Bug-fix LteEnbMac and LteUeMac on HARQ packets buffer in managing several LCs
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9505
diff changeset
   219
    }
999521532532 Bug-fix LteEnbMac and LteUeMac on HARQ packets buffer in managing several LCs
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9505
diff changeset
   220
  m_miUlHarqProcessesPacketTimer.resize (HARQ_PERIOD, 0);
999521532532 Bug-fix LteEnbMac and LteUeMac on HARQ packets buffer in managing several LCs
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9505
diff changeset
   221
   
7886
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   222
  m_macSapProvider = new UeMemberLteMacSapProvider (this);
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   223
  m_cmacSapProvider = new UeMemberLteUeCmacSapProvider (this);
7887
78911c978517 renamed several LTE files and classes
CTTC
parents: 7886
diff changeset
   224
  m_uePhySapUser = new UeMemberLteUePhySapUser (this);
9414
7b0db3dbf19b merged lena-dev and lena-epc
Nicola Baldo <nbaldo@cttc.es>
parents: 9413 9351
diff changeset
   225
  m_raPreambleUniformVariable = CreateObject<UniformRandomVariable> ();
7886
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   226
}
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   227
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   228
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   229
LteUeMac::~LteUeMac ()
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   230
{
7920
dd522ac64b64 added more logging to LteUeMac
Nicola Baldo <nbaldo@cttc.es>
parents: 7887
diff changeset
   231
  NS_LOG_FUNCTION (this);
7886
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   232
}
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   233
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   234
void
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   235
LteUeMac::DoDispose ()
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   236
{
7920
dd522ac64b64 added more logging to LteUeMac
Nicola Baldo <nbaldo@cttc.es>
parents: 7887
diff changeset
   237
  NS_LOG_FUNCTION (this);
9351
6e074e67a1ad HARQ first draft version: RR works, PF todo, LteMiErrorModel on-going
mmiozzo
parents: 9346
diff changeset
   238
  m_miUlHarqProcessesPacket.clear ();
7886
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   239
  delete m_macSapProvider;
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   240
  delete m_cmacSapProvider;
7930
ccb40542ae88 fixed memory leak in PHY SAP usage
Nicola Baldo <nbaldo@cttc.es>
parents: 7920
diff changeset
   241
  delete m_uePhySapUser;
7886
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   242
  Object::DoDispose ();
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   243
}
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   244
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   245
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   246
LteUePhySapUser*
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   247
LteUeMac::GetLteUePhySapUser (void)
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   248
{
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   249
  return m_uePhySapUser;
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   250
}
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   251
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   252
void
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   253
LteUeMac::SetLteUePhySapProvider (LteUePhySapProvider* s)
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   254
{
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   255
  m_uePhySapProvider = s;
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   256
}
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   257
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   258
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   259
LteMacSapProvider*
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   260
LteUeMac::GetLteMacSapProvider (void)
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   261
{
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   262
  return m_macSapProvider;
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   263
}
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   264
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   265
void
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   266
LteUeMac::SetLteUeCmacSapUser (LteUeCmacSapUser* s)
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   267
{
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   268
  m_cmacSapUser = s;
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   269
}
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   270
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   271
LteUeCmacSapProvider*
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   272
LteUeMac::GetLteUeCmacSapProvider (void)
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   273
{
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   274
  return m_cmacSapProvider;
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   275
}
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   276
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   277
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   278
void
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   279
LteUeMac::DoTransmitPdu (LteMacSapProvider::TransmitPduParameters params)
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   280
{
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   281
  NS_LOG_FUNCTION (this);
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   282
  NS_ASSERT_MSG (m_rnti == params.rnti, "RNTI mismatch between RLC and MAC");
8714
398bbcbb3f42 Add MIMO model, test and documentation
Marco Miozzo <marco.miozzo@cttc.es>
parents: 8496
diff changeset
   283
  LteRadioBearerTag tag (params.rnti, params.lcid, 0 /* UE works in SISO mode*/);
7886
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   284
  params.pdu->AddPacketTag (tag);
9351
6e074e67a1ad HARQ first draft version: RR works, PF todo, LteMiErrorModel on-going
mmiozzo
parents: 9346
diff changeset
   285
  // store pdu in HARQ buffer
9535
999521532532 Bug-fix LteEnbMac and LteUeMac on HARQ packets buffer in managing several LCs
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9505
diff changeset
   286
  m_miUlHarqProcessesPacket.at (m_harqProcessId)->AddPacket (params.pdu);
999521532532 Bug-fix LteEnbMac and LteUeMac on HARQ packets buffer in managing several LCs
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9505
diff changeset
   287
  m_miUlHarqProcessesPacketTimer.at (m_harqProcessId) = HARQ_PERIOD;
7886
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   288
  m_uePhySapProvider->SendMacPdu (params.pdu);
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   289
}
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   290
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   291
void
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   292
LteUeMac::DoReportBufferStatus (LteMacSapProvider::ReportBufferStatusParameters params)
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   293
{
9475
fd37f7e77d9e reestablish DRBs at UE upon handover
Nicola Baldo <nbaldo@cttc.es>
parents: 9473
diff changeset
   294
  NS_LOG_FUNCTION (this << (uint32_t) params.lcid);
8415
e9a27a8c6331 Uplink scheduler with multiple bearers (LCs) allocates in a Round Robin fashion the active ones
mmiozzo
parents: 8148
diff changeset
   295
  
9505
77a16713540b Split Tx Opportunities in LteUeMac for status, retx and tx buffers
mmiozzo
parents: 9475
diff changeset
   296
  std::map <uint8_t, LteMacSapProvider::ReportBufferStatusParameters>::iterator it;
8415
e9a27a8c6331 Uplink scheduler with multiple bearers (LCs) allocates in a Round Robin fashion the active ones
mmiozzo
parents: 8148
diff changeset
   297
  
e9a27a8c6331 Uplink scheduler with multiple bearers (LCs) allocates in a Round Robin fashion the active ones
mmiozzo
parents: 8148
diff changeset
   298
  
e9a27a8c6331 Uplink scheduler with multiple bearers (LCs) allocates in a Round Robin fashion the active ones
mmiozzo
parents: 8148
diff changeset
   299
  it = m_ulBsrReceived.find (params.lcid);
e9a27a8c6331 Uplink scheduler with multiple bearers (LCs) allocates in a Round Robin fashion the active ones
mmiozzo
parents: 8148
diff changeset
   300
  if (it!=m_ulBsrReceived.end ())
e9a27a8c6331 Uplink scheduler with multiple bearers (LCs) allocates in a Round Robin fashion the active ones
mmiozzo
parents: 8148
diff changeset
   301
    {
e9a27a8c6331 Uplink scheduler with multiple bearers (LCs) allocates in a Round Robin fashion the active ones
mmiozzo
parents: 8148
diff changeset
   302
      // update entry
9505
77a16713540b Split Tx Opportunities in LteUeMac for status, retx and tx buffers
mmiozzo
parents: 9475
diff changeset
   303
      (*it).second = params;
8415
e9a27a8c6331 Uplink scheduler with multiple bearers (LCs) allocates in a Round Robin fashion the active ones
mmiozzo
parents: 8148
diff changeset
   304
    }
e9a27a8c6331 Uplink scheduler with multiple bearers (LCs) allocates in a Round Robin fashion the active ones
mmiozzo
parents: 8148
diff changeset
   305
  else
e9a27a8c6331 Uplink scheduler with multiple bearers (LCs) allocates in a Round Robin fashion the active ones
mmiozzo
parents: 8148
diff changeset
   306
    {
9505
77a16713540b Split Tx Opportunities in LteUeMac for status, retx and tx buffers
mmiozzo
parents: 9475
diff changeset
   307
      m_ulBsrReceived.insert (std::pair<uint8_t, LteMacSapProvider::ReportBufferStatusParameters> (params.lcid, params));
8415
e9a27a8c6331 Uplink scheduler with multiple bearers (LCs) allocates in a Round Robin fashion the active ones
mmiozzo
parents: 8148
diff changeset
   308
    }
8496
8d1759a15c2e Update LteUeMac for sending BSR only when new BSR are received from RLC
Marco Miozzo <marco.miozzo@cttc.es>
parents: 8462
diff changeset
   309
  m_freshUlBsr = true;
8415
e9a27a8c6331 Uplink scheduler with multiple bearers (LCs) allocates in a Round Robin fashion the active ones
mmiozzo
parents: 8148
diff changeset
   310
}
e9a27a8c6331 Uplink scheduler with multiple bearers (LCs) allocates in a Round Robin fashion the active ones
mmiozzo
parents: 8148
diff changeset
   311
e9a27a8c6331 Uplink scheduler with multiple bearers (LCs) allocates in a Round Robin fashion the active ones
mmiozzo
parents: 8148
diff changeset
   312
e9a27a8c6331 Uplink scheduler with multiple bearers (LCs) allocates in a Round Robin fashion the active ones
mmiozzo
parents: 8148
diff changeset
   313
void
e9a27a8c6331 Uplink scheduler with multiple bearers (LCs) allocates in a Round Robin fashion the active ones
mmiozzo
parents: 8148
diff changeset
   314
LteUeMac::SendReportBufferStatus (void)
e9a27a8c6331 Uplink scheduler with multiple bearers (LCs) allocates in a Round Robin fashion the active ones
mmiozzo
parents: 8148
diff changeset
   315
{
e9a27a8c6331 Uplink scheduler with multiple bearers (LCs) allocates in a Round Robin fashion the active ones
mmiozzo
parents: 8148
diff changeset
   316
  NS_LOG_FUNCTION (this);
9406
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   317
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   318
  if (m_rnti == 0)
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   319
    {
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   320
      NS_LOG_INFO ("MAC not initialized, BSR deferred");
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   321
      return; 
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   322
    }
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   323
8496
8d1759a15c2e Update LteUeMac for sending BSR only when new BSR are received from RLC
Marco Miozzo <marco.miozzo@cttc.es>
parents: 8462
diff changeset
   324
  if (m_ulBsrReceived.size () == 0)
8d1759a15c2e Update LteUeMac for sending BSR only when new BSR are received from RLC
Marco Miozzo <marco.miozzo@cttc.es>
parents: 8462
diff changeset
   325
    {
9406
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   326
      NS_LOG_INFO ("No BSR report to transmit");
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   327
      return; 
8496
8d1759a15c2e Update LteUeMac for sending BSR only when new BSR are received from RLC
Marco Miozzo <marco.miozzo@cttc.es>
parents: 8462
diff changeset
   328
    }
7886
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   329
  MacCeListElement_s bsr;
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   330
  bsr.m_rnti = m_rnti;
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   331
  bsr.m_macCeType = MacCeListElement_s::BSR;
8887
90cbd09c8ff6 fixed bug with multiple LCs in UL BSR
Nicola Baldo <nbaldo@cttc.es>
parents: 8763
diff changeset
   332
9406
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   333
  // BSR is reported for each LCG
9505
77a16713540b Split Tx Opportunities in LteUeMac for status, retx and tx buffers
mmiozzo
parents: 9475
diff changeset
   334
  std::map <uint8_t, LteMacSapProvider::ReportBufferStatusParameters>::iterator it;  
9406
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   335
  std::vector<uint32_t> queue (4, 0); // one value per each of the 4 LCGs, initialized to 0
8415
e9a27a8c6331 Uplink scheduler with multiple bearers (LCs) allocates in a Round Robin fashion the active ones
mmiozzo
parents: 8148
diff changeset
   336
  for (it = m_ulBsrReceived.begin (); it != m_ulBsrReceived.end (); it++)
7886
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   337
    {
9406
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   338
      uint8_t lcid = it->first;
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   339
      std::map <uint8_t, LcInfo>::iterator lcInfoMapIt;
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   340
      lcInfoMapIt = m_lcInfoMap.find (lcid);
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   341
      NS_ASSERT (lcInfoMapIt !=  m_lcInfoMap.end ());
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   342
      uint8_t lcg = lcInfoMapIt->second.lcConfig.logicalChannelGroup;
9505
77a16713540b Split Tx Opportunities in LteUeMac for status, retx and tx buffers
mmiozzo
parents: 9475
diff changeset
   343
      queue.at (lcg) += ((*it).second.txQueueSize + (*it).second.retxQueueSize + (*it).second.statusPduSize);
7886
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   344
    }
9406
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   345
8887
90cbd09c8ff6 fixed bug with multiple LCs in UL BSR
Nicola Baldo <nbaldo@cttc.es>
parents: 8763
diff changeset
   346
  // FF API says that all 4 LCGs are always present
9406
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   347
  bsr.m_macCeValue.m_bufferStatus.push_back (BufferSizeLevelBsr::BufferSize2BsrId (queue.at (0)));
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   348
  bsr.m_macCeValue.m_bufferStatus.push_back (BufferSizeLevelBsr::BufferSize2BsrId (queue.at (1)));
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   349
  bsr.m_macCeValue.m_bufferStatus.push_back (BufferSizeLevelBsr::BufferSize2BsrId (queue.at (2)));
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   350
  bsr.m_macCeValue.m_bufferStatus.push_back (BufferSizeLevelBsr::BufferSize2BsrId (queue.at (3)));
7886
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   351
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   352
  // create the feedback to eNB
9035
e40974228d94 Update Phy Layer for managing different frames for different set of channels (data vs. ctrl and srs)
Marco Miozzo <marco.miozzo@cttc.es>
parents: 8763
diff changeset
   353
  Ptr<BsrLteControlMessage> msg = Create<BsrLteControlMessage> ();
7886
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   354
  msg->SetBsr (bsr);
9035
e40974228d94 Update Phy Layer for managing different frames for different set of channels (data vs. ctrl and srs)
Marco Miozzo <marco.miozzo@cttc.es>
parents: 8763
diff changeset
   355
  m_uePhySapProvider->SendLteControlMessage (msg);
7886
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   356
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   357
}
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   358
9406
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   359
void 
9413
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   360
LteUeMac::RandomlySelectAndSendRaPreamble ()
9406
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   361
{
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   362
  NS_LOG_FUNCTION (this);
9413
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   363
  // 3GPP 36.321 5.1.1  
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   364
  NS_ASSERT_MSG (m_rachConfigured, "RACH not configured");
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   365
  // assume that there is no Random Access Preambles group B
9414
7b0db3dbf19b merged lena-dev and lena-epc
Nicola Baldo <nbaldo@cttc.es>
parents: 9413 9351
diff changeset
   366
  m_raPreambleId = m_raPreambleUniformVariable->GetInteger (0, m_rachConfig.numberOfRaPreambles - 1);
9413
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   367
  bool contention = true;
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   368
  SendRaPreamble (contention);
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   369
}
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   370
   
7886
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   371
void
9413
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   372
LteUeMac::SendRaPreamble (bool contention)
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   373
{
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   374
  NS_LOG_FUNCTION (this << (uint32_t) m_raPreambleId << contention);
9406
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   375
  // Since regular UL LteControlMessages need m_ulConfigured = true in
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   376
  // order to be sent by the UE, the rach preamble needs to be sent
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   377
  // with a dedicated primitive (not
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   378
  // m_uePhySapProvider->SendLteControlMessage (msg)) so that it can
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   379
  // bypass the m_ulConfigured flag. This is reasonable, since In fact
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   380
  // the RACH preamble is sent on 6RB bandwidth so the uplink
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   381
  // bandwidth does not need to be configured. 
9413
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   382
  NS_ASSERT (m_subframeNo > 0); // sanity check for subframe starting at 1
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   383
  m_raRnti = m_subframeNo - 1;
9460
0674e66ee483 Introduces RACH procedures in the schedulers and UL grant at PHY layer
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9414
diff changeset
   384
  m_uePhySapProvider->SendRachPreamble (m_raPreambleId, m_raRnti);
9413
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   385
  NS_LOG_INFO (this << " sent preamble id " << (uint32_t) m_raPreambleId << ", RA-RNTI " << (uint32_t) m_raRnti);
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   386
  // 3GPP 36.321 5.1.4 
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   387
  Time raWindowBegin = MilliSeconds (3); 
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   388
  Time raWindowEnd = MilliSeconds (3 + m_rachConfig.raResponseWindowSize);
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   389
  Simulator::Schedule (raWindowBegin, &LteUeMac::StartWaitingForRaResponse, this);
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   390
  m_noRaResponseReceivedEvent = Simulator::Schedule (raWindowEnd, &LteUeMac::RaResponseTimeout, this, contention);
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   391
}
9406
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   392
9413
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   393
void 
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   394
LteUeMac::StartWaitingForRaResponse ()
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   395
{
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   396
   NS_LOG_FUNCTION (this);
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   397
   m_waitingForRaResponse = true;
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   398
}
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   399
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   400
void 
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   401
LteUeMac::RecvRaResponse (BuildRarListElement_s raResponse)
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   402
{
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   403
  NS_LOG_FUNCTION (this);
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   404
  m_waitingForRaResponse = false;
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   405
  m_noRaResponseReceivedEvent.Cancel ();
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   406
  NS_LOG_INFO ("got RAR for RAPID " << (uint32_t) m_raPreambleId << ", setting T-C-RNTI = " << raResponse.m_rnti);
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   407
  m_rnti = raResponse.m_rnti;
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   408
  m_cmacSapUser->SetTemporaryCellRnti (m_rnti);
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   409
  // in principle we should wait for contention resolution,
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   410
  // but in the current LTE model when two or more identical
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   411
  // preambles are sent no one is received, so there is no need
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   412
  // for contention resolution
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   413
  m_cmacSapUser->NotifyRandomAccessSuccessful ();
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   414
}
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   415
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   416
void 
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   417
LteUeMac::RaResponseTimeout (bool contention)
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   418
{
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   419
  NS_LOG_FUNCTION (this << contention);
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   420
  m_waitingForRaResponse = false;
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   421
  // 3GPP 36.321 5.1.4
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   422
  ++m_preambleTransmissionCounter;
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   423
  if (m_preambleTransmissionCounter == m_rachConfig.preambleTransMax + 1)
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   424
    {
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   425
      NS_LOG_INFO ("RAR timeout, preambleTransMax reached => giving up");
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   426
      m_cmacSapUser->NotifyRandomAccessFailed ();
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   427
    }
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   428
  else
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   429
    {
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   430
      NS_LOG_INFO ("RAR timeout, re-send preamble");
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   431
      if (contention)
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   432
        {
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   433
          RandomlySelectAndSendRaPreamble ();
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   434
        }
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   435
      else
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   436
        {
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   437
          SendRaPreamble (contention);
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   438
        }
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   439
    }
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   440
}
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   441
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   442
void 
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   443
LteUeMac::DoConfigureRach (LteUeCmacSapProvider::RachConfig rc)
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   444
{
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   445
  NS_LOG_FUNCTION (this);
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   446
  m_rachConfig = rc;
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   447
  m_rachConfigured = true;
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   448
}
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   449
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   450
void 
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   451
LteUeMac::DoStartContentionBasedRandomAccessProcedure ()
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   452
{
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   453
  NS_LOG_FUNCTION (this);
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   454
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   455
  // 3GPP 36.321 5.1.1
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   456
  NS_ASSERT_MSG (m_rachConfigured, "RACH not configured");
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   457
  m_preambleTransmissionCounter = 0;
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   458
  m_backoffParameter = 0;
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   459
  RandomlySelectAndSendRaPreamble ();
9406
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   460
}
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   461
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   462
void 
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   463
LteUeMac::DoStartNonContentionBasedRandomAccessProcedure (uint16_t rnti, uint8_t preambleId, uint8_t prachMask)
7886
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   464
{
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   465
  NS_LOG_FUNCTION (this << " rnti" << rnti);
9413
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   466
  NS_ASSERT_MSG (prachMask == 0, "requested PRACH MASK = " << (uint32_t) prachMask << ", but only PRACH MASK = 0 is supported");
7886
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   467
  m_rnti = rnti;
9413
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   468
  m_raPreambleId = preambleId;
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   469
  bool contention = false;
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   470
  SendRaPreamble (contention);
7886
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   471
}
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   472
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   473
void
9406
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   474
LteUeMac::DoAddLc (uint8_t lcId,  LteUeCmacSapProvider::LogicalChannelConfig lcConfig, LteMacSapUser* msu)
7886
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   475
{
9413
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   476
  NS_LOG_FUNCTION (this << " lcId" << (uint32_t) lcId);
9406
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   477
  NS_ASSERT_MSG (m_lcInfoMap.find (lcId) == m_lcInfoMap.end (), "cannot add channel because LCID " << lcId << " is already present");
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   478
  
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   479
  LcInfo lcInfo;
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   480
  lcInfo.lcConfig = lcConfig;
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   481
  lcInfo.macSapUser = msu;
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   482
  m_lcInfoMap[lcId] = lcInfo;
7886
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   483
}
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   484
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   485
void
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   486
LteUeMac::DoRemoveLc (uint8_t lcId)
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   487
{
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   488
  NS_LOG_FUNCTION (this << " lcId" << lcId);
9406
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   489
  NS_ASSERT_MSG (m_lcInfoMap.find (lcId) == m_lcInfoMap.end (), "could not find LCID " << lcId);
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   490
  m_lcInfoMap.erase (lcId);
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   491
}
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   492
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   493
void
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   494
LteUeMac::DoReset ()
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   495
{
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   496
  NS_LOG_FUNCTION (this);
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   497
  std::map <uint8_t, LcInfo>::iterator it = m_lcInfoMap.begin ();
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   498
  while (it != m_lcInfoMap.end ())
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   499
    {
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   500
      // don't delete CCCH)
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   501
      if (it->first == 0)
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   502
        {          
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   503
          ++it;
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   504
        }
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   505
      else
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   506
        {
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   507
          // note: use of postfix operator preserves validity of iterator
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   508
          m_lcInfoMap.erase (it++);
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   509
        }
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   510
    }
9413
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   511
  m_rachConfigured = false;
9473
8b420bd32318 reset MAC and reinitialize SRBs upon handover
Nicola Baldo <nbaldo@cttc.es>
parents: 9460
diff changeset
   512
  m_freshUlBsr = false;
8b420bd32318 reset MAC and reinitialize SRBs upon handover
Nicola Baldo <nbaldo@cttc.es>
parents: 9460
diff changeset
   513
  m_ulBsrReceived.clear ();
7886
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   514
}
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   515
8714
398bbcbb3f42 Add MIMO model, test and documentation
Marco Miozzo <marco.miozzo@cttc.es>
parents: 8496
diff changeset
   516
void
7886
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   517
LteUeMac::DoReceivePhyPdu (Ptr<Packet> p)
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   518
{
8462
cf6a48994db5 renamed LteMacTag --> LteRadioBearerTag
Nicola Baldo <nbaldo@cttc.es>
parents: 8436
diff changeset
   519
  LteRadioBearerTag tag;
7886
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   520
  p->RemovePacketTag (tag);
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   521
  if (tag.GetRnti () == m_rnti)
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   522
    {
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   523
      // packet is for the current user
9406
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   524
      std::map <uint8_t, LcInfo>::const_iterator it = m_lcInfoMap.find (tag.GetLcid ());
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   525
      NS_ASSERT_MSG (it != m_lcInfoMap.end (), "received packet with unknown lcid");
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   526
      it->second.macSapUser->ReceivePdu (p);
7886
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   527
    }
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   528
}
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   529
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   530
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   531
void
9035
e40974228d94 Update Phy Layer for managing different frames for different set of channels (data vs. ctrl and srs)
Marco Miozzo <marco.miozzo@cttc.es>
parents: 8763
diff changeset
   532
LteUeMac::DoReceiveLteControlMessage (Ptr<LteControlMessage> msg)
7886
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   533
{
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   534
  NS_LOG_FUNCTION (this);
9035
e40974228d94 Update Phy Layer for managing different frames for different set of channels (data vs. ctrl and srs)
Marco Miozzo <marco.miozzo@cttc.es>
parents: 8763
diff changeset
   535
  if (msg->GetMessageType () == LteControlMessage::UL_DCI)
7886
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   536
    {
9035
e40974228d94 Update Phy Layer for managing different frames for different set of channels (data vs. ctrl and srs)
Marco Miozzo <marco.miozzo@cttc.es>
parents: 8763
diff changeset
   537
      Ptr<UlDciLteControlMessage> msg2 = DynamicCast<UlDciLteControlMessage> (msg);
7886
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   538
      UlDciListElement_s dci = msg2->GetDci ();
9351
6e074e67a1ad HARQ first draft version: RR works, PF todo, LteMiErrorModel on-going
mmiozzo
parents: 9346
diff changeset
   539
      if (dci.m_ndi==1)
8415
e9a27a8c6331 Uplink scheduler with multiple bearers (LCs) allocates in a Round Robin fashion the active ones
mmiozzo
parents: 8148
diff changeset
   540
        {
9632
09dac25f1230 Introduced forced HARQ pkt buffer emtying in UL for inhibiting PDUs duplication when harq feedback has been lost for channel errors
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9624
diff changeset
   541
          // New transmission -> emtpy pkt buffer queue (for deleting eventual pkts not acked )
09dac25f1230 Introduced forced HARQ pkt buffer emtying in UL for inhibiting PDUs duplication when harq feedback has been lost for channel errors
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9624
diff changeset
   542
          Ptr<PacketBurst> pb = CreateObject <PacketBurst> ();
09dac25f1230 Introduced forced HARQ pkt buffer emtying in UL for inhibiting PDUs duplication when harq feedback has been lost for channel errors
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9624
diff changeset
   543
          m_miUlHarqProcessesPacket.at (m_harqProcessId) = pb;
09dac25f1230 Introduced forced HARQ pkt buffer emtying in UL for inhibiting PDUs duplication when harq feedback has been lost for channel errors
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9624
diff changeset
   544
          // Retrieve data from RLC
9505
77a16713540b Split Tx Opportunities in LteUeMac for status, retx and tx buffers
mmiozzo
parents: 9475
diff changeset
   545
          std::map <uint8_t, LteMacSapProvider::ReportBufferStatusParameters>::iterator itBsr;
9351
6e074e67a1ad HARQ first draft version: RR works, PF todo, LteMiErrorModel on-going
mmiozzo
parents: 9346
diff changeset
   546
          uint16_t activeLcs = 0;
9571
2840bae9607f Introduced high priority to status PDU trasmission in case of reduced resource at LteUeMac
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9536
diff changeset
   547
          uint32_t statusPduMinSize = 0;
9351
6e074e67a1ad HARQ first draft version: RR works, PF todo, LteMiErrorModel on-going
mmiozzo
parents: 9346
diff changeset
   548
          for (itBsr = m_ulBsrReceived.begin (); itBsr != m_ulBsrReceived.end (); itBsr++)
6e074e67a1ad HARQ first draft version: RR works, PF todo, LteMiErrorModel on-going
mmiozzo
parents: 9346
diff changeset
   549
            {
9505
77a16713540b Split Tx Opportunities in LteUeMac for status, retx and tx buffers
mmiozzo
parents: 9475
diff changeset
   550
              if (((*itBsr).second.statusPduSize > 0) || ((*itBsr).second.retxQueueSize > 0) || ((*itBsr).second.txQueueSize > 0))
9351
6e074e67a1ad HARQ first draft version: RR works, PF todo, LteMiErrorModel on-going
mmiozzo
parents: 9346
diff changeset
   551
                {
6e074e67a1ad HARQ first draft version: RR works, PF todo, LteMiErrorModel on-going
mmiozzo
parents: 9346
diff changeset
   552
                  activeLcs++;
9571
2840bae9607f Introduced high priority to status PDU trasmission in case of reduced resource at LteUeMac
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9536
diff changeset
   553
                  if (((*itBsr).second.statusPduSize!=0)&&((*itBsr).second.statusPduSize < statusPduMinSize))
2840bae9607f Introduced high priority to status PDU trasmission in case of reduced resource at LteUeMac
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9536
diff changeset
   554
                    {
2840bae9607f Introduced high priority to status PDU trasmission in case of reduced resource at LteUeMac
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9536
diff changeset
   555
                      statusPduMinSize = (*itBsr).second.statusPduSize;
2840bae9607f Introduced high priority to status PDU trasmission in case of reduced resource at LteUeMac
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9536
diff changeset
   556
                    }
2840bae9607f Introduced high priority to status PDU trasmission in case of reduced resource at LteUeMac
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9536
diff changeset
   557
                  if (((*itBsr).second.statusPduSize!=0)&&(statusPduMinSize == 0))
2840bae9607f Introduced high priority to status PDU trasmission in case of reduced resource at LteUeMac
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9536
diff changeset
   558
                    {
2840bae9607f Introduced high priority to status PDU trasmission in case of reduced resource at LteUeMac
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9536
diff changeset
   559
                      statusPduMinSize = (*itBsr).second.statusPduSize;
2840bae9607f Introduced high priority to status PDU trasmission in case of reduced resource at LteUeMac
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9536
diff changeset
   560
                    }
9351
6e074e67a1ad HARQ first draft version: RR works, PF todo, LteMiErrorModel on-going
mmiozzo
parents: 9346
diff changeset
   561
                }
6e074e67a1ad HARQ first draft version: RR works, PF todo, LteMiErrorModel on-going
mmiozzo
parents: 9346
diff changeset
   562
            }
6e074e67a1ad HARQ first draft version: RR works, PF todo, LteMiErrorModel on-going
mmiozzo
parents: 9346
diff changeset
   563
          if (activeLcs == 0)
8415
e9a27a8c6331 Uplink scheduler with multiple bearers (LCs) allocates in a Round Robin fashion the active ones
mmiozzo
parents: 8148
diff changeset
   564
            {
9351
6e074e67a1ad HARQ first draft version: RR works, PF todo, LteMiErrorModel on-going
mmiozzo
parents: 9346
diff changeset
   565
              NS_LOG_ERROR (this << " No active flows for this UL-DCI");
6e074e67a1ad HARQ first draft version: RR works, PF todo, LteMiErrorModel on-going
mmiozzo
parents: 9346
diff changeset
   566
              return;
6e074e67a1ad HARQ first draft version: RR works, PF todo, LteMiErrorModel on-going
mmiozzo
parents: 9346
diff changeset
   567
            }
9414
7b0db3dbf19b merged lena-dev and lena-epc
Nicola Baldo <nbaldo@cttc.es>
parents: 9413 9351
diff changeset
   568
          std::map <uint8_t, LcInfo>::iterator it;
7b0db3dbf19b merged lena-dev and lena-epc
Nicola Baldo <nbaldo@cttc.es>
parents: 9413 9351
diff changeset
   569
          uint32_t bytesPerActiveLc = dci.m_tbSize / activeLcs;
9571
2840bae9607f Introduced high priority to status PDU trasmission in case of reduced resource at LteUeMac
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9536
diff changeset
   570
          bool statusPduPriority = false;
2840bae9607f Introduced high priority to status PDU trasmission in case of reduced resource at LteUeMac
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9536
diff changeset
   571
          if ((statusPduMinSize != 0)&&(bytesPerActiveLc < statusPduMinSize))
2840bae9607f Introduced high priority to status PDU trasmission in case of reduced resource at LteUeMac
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9536
diff changeset
   572
            {
2840bae9607f Introduced high priority to status PDU trasmission in case of reduced resource at LteUeMac
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9536
diff changeset
   573
              // send only the status PDU which has highest priority
2840bae9607f Introduced high priority to status PDU trasmission in case of reduced resource at LteUeMac
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9536
diff changeset
   574
              statusPduPriority = true;
2840bae9607f Introduced high priority to status PDU trasmission in case of reduced resource at LteUeMac
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9536
diff changeset
   575
              NS_LOG_DEBUG (this << " Reduced resource -> send only Status, b ytes " << statusPduMinSize);
2840bae9607f Introduced high priority to status PDU trasmission in case of reduced resource at LteUeMac
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9536
diff changeset
   576
              if (dci.m_tbSize < statusPduMinSize)
2840bae9607f Introduced high priority to status PDU trasmission in case of reduced resource at LteUeMac
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9536
diff changeset
   577
                {
2840bae9607f Introduced high priority to status PDU trasmission in case of reduced resource at LteUeMac
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9536
diff changeset
   578
                  NS_FATAL_ERROR ("Insufficient Tx Opportunity for sending a status message");
2840bae9607f Introduced high priority to status PDU trasmission in case of reduced resource at LteUeMac
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9536
diff changeset
   579
                }
2840bae9607f Introduced high priority to status PDU trasmission in case of reduced resource at LteUeMac
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9536
diff changeset
   580
            }
9624
2a61baf2956c Update LteUeMac scheduler for avoiding data blocks of less than 7 bytes according to RLC constraints
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9571
diff changeset
   581
          NS_LOG_LOGIC (this << " UE " << m_rnti << ": UL-CQI notified TxOpportunity of " << dci.m_tbSize << " => " << bytesPerActiveLc << " bytes per active LC" << " statusPduMinSize " << statusPduMinSize);
9414
7b0db3dbf19b merged lena-dev and lena-epc
Nicola Baldo <nbaldo@cttc.es>
parents: 9413 9351
diff changeset
   582
          for (it = m_lcInfoMap.begin (); it!=m_lcInfoMap.end (); it++)
9351
6e074e67a1ad HARQ first draft version: RR works, PF todo, LteMiErrorModel on-going
mmiozzo
parents: 9346
diff changeset
   583
            {
6e074e67a1ad HARQ first draft version: RR works, PF todo, LteMiErrorModel on-going
mmiozzo
parents: 9346
diff changeset
   584
              itBsr = m_ulBsrReceived.find ((*it).first);
9624
2a61baf2956c Update LteUeMac scheduler for avoiding data blocks of less than 7 bytes according to RLC constraints
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9571
diff changeset
   585
              NS_LOG_DEBUG (this << " Processing LC " << (uint32_t)(*it).first << " bytesPerActiveLc " << bytesPerActiveLc);
9505
77a16713540b Split Tx Opportunities in LteUeMac for status, retx and tx buffers
mmiozzo
parents: 9475
diff changeset
   586
              if ( (itBsr!=m_ulBsrReceived.end ()) &&
77a16713540b Split Tx Opportunities in LteUeMac for status, retx and tx buffers
mmiozzo
parents: 9475
diff changeset
   587
                  ( ((*itBsr).second.statusPduSize > 0) ||
77a16713540b Split Tx Opportunities in LteUeMac for status, retx and tx buffers
mmiozzo
parents: 9475
diff changeset
   588
                  ((*itBsr).second.retxQueueSize > 0) ||
77a16713540b Split Tx Opportunities in LteUeMac for status, retx and tx buffers
mmiozzo
parents: 9475
diff changeset
   589
                  ((*itBsr).second.txQueueSize > 0)) )
9351
6e074e67a1ad HARQ first draft version: RR works, PF todo, LteMiErrorModel on-going
mmiozzo
parents: 9346
diff changeset
   590
                {
9571
2840bae9607f Introduced high priority to status PDU trasmission in case of reduced resource at LteUeMac
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9536
diff changeset
   591
                  if ((statusPduPriority) && ((*itBsr).second.statusPduSize == statusPduMinSize))
9505
77a16713540b Split Tx Opportunities in LteUeMac for status, retx and tx buffers
mmiozzo
parents: 9475
diff changeset
   592
                    {
77a16713540b Split Tx Opportunities in LteUeMac for status, retx and tx buffers
mmiozzo
parents: 9475
diff changeset
   593
                      (*it).second.macSapUser->NotifyTxOpportunity ((*itBsr).second.statusPduSize, 0, 0);
9571
2840bae9607f Introduced high priority to status PDU trasmission in case of reduced resource at LteUeMac
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9536
diff changeset
   594
                      NS_LOG_LOGIC (this << "\t" << bytesPerActiveLc << " send  " << (*itBsr).second.statusPduSize << " status bytes to LC " << (uint32_t)(*it).first << " statusQueue " << (*itBsr).second.statusPduSize << " retxQueue" << (*itBsr).second.retxQueueSize << " txQueue" <<  (*itBsr).second.txQueueSize);
9505
77a16713540b Split Tx Opportunities in LteUeMac for status, retx and tx buffers
mmiozzo
parents: 9475
diff changeset
   595
                      (*itBsr).second.statusPduSize = 0;
9571
2840bae9607f Introduced high priority to status PDU trasmission in case of reduced resource at LteUeMac
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9536
diff changeset
   596
                      break;
9505
77a16713540b Split Tx Opportunities in LteUeMac for status, retx and tx buffers
mmiozzo
parents: 9475
diff changeset
   597
                    }
9571
2840bae9607f Introduced high priority to status PDU trasmission in case of reduced resource at LteUeMac
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9536
diff changeset
   598
                  else
9351
6e074e67a1ad HARQ first draft version: RR works, PF todo, LteMiErrorModel on-going
mmiozzo
parents: 9346
diff changeset
   599
                    {
9571
2840bae9607f Introduced high priority to status PDU trasmission in case of reduced resource at LteUeMac
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9536
diff changeset
   600
                      uint32_t bytesForThisLc = bytesPerActiveLc;
2840bae9607f Introduced high priority to status PDU trasmission in case of reduced resource at LteUeMac
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9536
diff changeset
   601
                      NS_LOG_LOGIC (this << "\t" << bytesPerActiveLc << " bytes to LC " << (uint32_t)(*it).first << " statusQueue " << (*itBsr).second.statusPduSize << " retxQueue" << (*itBsr).second.retxQueueSize << " txQueue" <<  (*itBsr).second.txQueueSize);
2840bae9607f Introduced high priority to status PDU trasmission in case of reduced resource at LteUeMac
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9536
diff changeset
   602
                      if (((*itBsr).second.statusPduSize > 0) && (bytesForThisLc > (*itBsr).second.statusPduSize))
9505
77a16713540b Split Tx Opportunities in LteUeMac for status, retx and tx buffers
mmiozzo
parents: 9475
diff changeset
   603
                        {
9571
2840bae9607f Introduced high priority to status PDU trasmission in case of reduced resource at LteUeMac
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9536
diff changeset
   604
                          (*it).second.macSapUser->NotifyTxOpportunity ((*itBsr).second.statusPduSize, 0, 0);
2840bae9607f Introduced high priority to status PDU trasmission in case of reduced resource at LteUeMac
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9536
diff changeset
   605
                          bytesForThisLc -= (*itBsr).second.statusPduSize;
9624
2a61baf2956c Update LteUeMac scheduler for avoiding data blocks of less than 7 bytes according to RLC constraints
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9571
diff changeset
   606
                          NS_LOG_DEBUG (this << " serve STATUS " << (*itBsr).second.statusPduSize);
9571
2840bae9607f Introduced high priority to status PDU trasmission in case of reduced resource at LteUeMac
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9536
diff changeset
   607
                          (*itBsr).second.statusPduSize = 0;
2840bae9607f Introduced high priority to status PDU trasmission in case of reduced resource at LteUeMac
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9536
diff changeset
   608
                        }
2840bae9607f Introduced high priority to status PDU trasmission in case of reduced resource at LteUeMac
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9536
diff changeset
   609
                      else
2840bae9607f Introduced high priority to status PDU trasmission in case of reduced resource at LteUeMac
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9536
diff changeset
   610
                        {
2840bae9607f Introduced high priority to status PDU trasmission in case of reduced resource at LteUeMac
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9536
diff changeset
   611
                          if ((*itBsr).second.statusPduSize>bytesForThisLc)
9505
77a16713540b Split Tx Opportunities in LteUeMac for status, retx and tx buffers
mmiozzo
parents: 9475
diff changeset
   612
                            {
9571
2840bae9607f Introduced high priority to status PDU trasmission in case of reduced resource at LteUeMac
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9536
diff changeset
   613
                              NS_FATAL_ERROR ("Insufficient Tx Opportunity for sending a status message");
9505
77a16713540b Split Tx Opportunities in LteUeMac for status, retx and tx buffers
mmiozzo
parents: 9475
diff changeset
   614
                            }
77a16713540b Split Tx Opportunities in LteUeMac for status, retx and tx buffers
mmiozzo
parents: 9475
diff changeset
   615
                        }
9624
2a61baf2956c Update LteUeMac scheduler for avoiding data blocks of less than 7 bytes according to RLC constraints
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9571
diff changeset
   616
                        
2a61baf2956c Update LteUeMac scheduler for avoiding data blocks of less than 7 bytes according to RLC constraints
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9571
diff changeset
   617
                      if ((bytesForThisLc > 7) && // 7 is the min TxOpportunity useful for Rlc
2a61baf2956c Update LteUeMac scheduler for avoiding data blocks of less than 7 bytes according to RLC constraints
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9571
diff changeset
   618
                         (((*itBsr).second.retxQueueSize > 0) ||
2a61baf2956c Update LteUeMac scheduler for avoiding data blocks of less than 7 bytes according to RLC constraints
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9571
diff changeset
   619
                         ((*itBsr).second.txQueueSize > 0)))
9505
77a16713540b Split Tx Opportunities in LteUeMac for status, retx and tx buffers
mmiozzo
parents: 9475
diff changeset
   620
                        {
9571
2840bae9607f Introduced high priority to status PDU trasmission in case of reduced resource at LteUeMac
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9536
diff changeset
   621
                          if ((*itBsr).second.retxQueueSize > 0)
9505
77a16713540b Split Tx Opportunities in LteUeMac for status, retx and tx buffers
mmiozzo
parents: 9475
diff changeset
   622
                            {
9624
2a61baf2956c Update LteUeMac scheduler for avoiding data blocks of less than 7 bytes according to RLC constraints
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9571
diff changeset
   623
                              NS_LOG_DEBUG (this << " serve retx DATA, bytes " << bytesForThisLc);
9571
2840bae9607f Introduced high priority to status PDU trasmission in case of reduced resource at LteUeMac
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9536
diff changeset
   624
                              (*it).second.macSapUser->NotifyTxOpportunity (bytesForThisLc, 0, 0);
2840bae9607f Introduced high priority to status PDU trasmission in case of reduced resource at LteUeMac
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9536
diff changeset
   625
                              if ((*itBsr).second.retxQueueSize >= bytesForThisLc)
2840bae9607f Introduced high priority to status PDU trasmission in case of reduced resource at LteUeMac
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9536
diff changeset
   626
                                {
2840bae9607f Introduced high priority to status PDU trasmission in case of reduced resource at LteUeMac
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9536
diff changeset
   627
                                  (*itBsr).second.retxQueueSize -= bytesForThisLc;
2840bae9607f Introduced high priority to status PDU trasmission in case of reduced resource at LteUeMac
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9536
diff changeset
   628
                                }
2840bae9607f Introduced high priority to status PDU trasmission in case of reduced resource at LteUeMac
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9536
diff changeset
   629
                              else
2840bae9607f Introduced high priority to status PDU trasmission in case of reduced resource at LteUeMac
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9536
diff changeset
   630
                                {
2840bae9607f Introduced high priority to status PDU trasmission in case of reduced resource at LteUeMac
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9536
diff changeset
   631
                                  (*itBsr).second.retxQueueSize = 0;
2840bae9607f Introduced high priority to status PDU trasmission in case of reduced resource at LteUeMac
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9536
diff changeset
   632
                                }
9505
77a16713540b Split Tx Opportunities in LteUeMac for status, retx and tx buffers
mmiozzo
parents: 9475
diff changeset
   633
                            }
9571
2840bae9607f Introduced high priority to status PDU trasmission in case of reduced resource at LteUeMac
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9536
diff changeset
   634
                          else if ((*itBsr).second.txQueueSize > 0)
9505
77a16713540b Split Tx Opportunities in LteUeMac for status, retx and tx buffers
mmiozzo
parents: 9475
diff changeset
   635
                            {
9624
2a61baf2956c Update LteUeMac scheduler for avoiding data blocks of less than 7 bytes according to RLC constraints
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9571
diff changeset
   636
                              NS_LOG_DEBUG (this << " serve tx DATA, bytes " << bytesForThisLc);
9571
2840bae9607f Introduced high priority to status PDU trasmission in case of reduced resource at LteUeMac
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9536
diff changeset
   637
                              (*it).second.macSapUser->NotifyTxOpportunity (bytesForThisLc, 0, 0);
2840bae9607f Introduced high priority to status PDU trasmission in case of reduced resource at LteUeMac
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9536
diff changeset
   638
                              if ((*itBsr).second.txQueueSize >= bytesForThisLc - 2)
2840bae9607f Introduced high priority to status PDU trasmission in case of reduced resource at LteUeMac
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9536
diff changeset
   639
                                {
2840bae9607f Introduced high priority to status PDU trasmission in case of reduced resource at LteUeMac
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9536
diff changeset
   640
                                  (*itBsr).second.txQueueSize -= bytesForThisLc - 2;
2840bae9607f Introduced high priority to status PDU trasmission in case of reduced resource at LteUeMac
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9536
diff changeset
   641
                                }
2840bae9607f Introduced high priority to status PDU trasmission in case of reduced resource at LteUeMac
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9536
diff changeset
   642
                              else
2840bae9607f Introduced high priority to status PDU trasmission in case of reduced resource at LteUeMac
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9536
diff changeset
   643
                                {
2840bae9607f Introduced high priority to status PDU trasmission in case of reduced resource at LteUeMac
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9536
diff changeset
   644
                                  (*itBsr).second.txQueueSize = 0;
2840bae9607f Introduced high priority to status PDU trasmission in case of reduced resource at LteUeMac
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9536
diff changeset
   645
                                }
9505
77a16713540b Split Tx Opportunities in LteUeMac for status, retx and tx buffers
mmiozzo
parents: 9475
diff changeset
   646
                            }
77a16713540b Split Tx Opportunities in LteUeMac for status, retx and tx buffers
mmiozzo
parents: 9475
diff changeset
   647
                        }
9624
2a61baf2956c Update LteUeMac scheduler for avoiding data blocks of less than 7 bytes according to RLC constraints
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9571
diff changeset
   648
                      else
2a61baf2956c Update LteUeMac scheduler for avoiding data blocks of less than 7 bytes according to RLC constraints
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9571
diff changeset
   649
                        {
2a61baf2956c Update LteUeMac scheduler for avoiding data blocks of less than 7 bytes according to RLC constraints
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9571
diff changeset
   650
                          if ( ((*itBsr).second.retxQueueSize > 0) || ((*itBsr).second.txQueueSize > 0)) 
2a61baf2956c Update LteUeMac scheduler for avoiding data blocks of less than 7 bytes according to RLC constraints
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9571
diff changeset
   651
                            {
2a61baf2956c Update LteUeMac scheduler for avoiding data blocks of less than 7 bytes according to RLC constraints
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9571
diff changeset
   652
                              // resend BSR info for updating eNB peer MAC
2a61baf2956c Update LteUeMac scheduler for avoiding data blocks of less than 7 bytes according to RLC constraints
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9571
diff changeset
   653
                              m_freshUlBsr = true;
2a61baf2956c Update LteUeMac scheduler for avoiding data blocks of less than 7 bytes according to RLC constraints
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9571
diff changeset
   654
                            }
2a61baf2956c Update LteUeMac scheduler for avoiding data blocks of less than 7 bytes according to RLC constraints
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9571
diff changeset
   655
                        }
9571
2840bae9607f Introduced high priority to status PDU trasmission in case of reduced resource at LteUeMac
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9536
diff changeset
   656
                      NS_LOG_LOGIC (this << "\t" << bytesPerActiveLc << "\t new queues " << (uint32_t)(*it).first << " statusQueue " << (*itBsr).second.statusPduSize << " retxQueue" << (*itBsr).second.retxQueueSize << " txQueue" <<  (*itBsr).second.txQueueSize);
9351
6e074e67a1ad HARQ first draft version: RR works, PF todo, LteMiErrorModel on-going
mmiozzo
parents: 9346
diff changeset
   657
                    }
9505
77a16713540b Split Tx Opportunities in LteUeMac for status, retx and tx buffers
mmiozzo
parents: 9475
diff changeset
   658
9351
6e074e67a1ad HARQ first draft version: RR works, PF todo, LteMiErrorModel on-going
mmiozzo
parents: 9346
diff changeset
   659
                }
8415
e9a27a8c6331 Uplink scheduler with multiple bearers (LCs) allocates in a Round Robin fashion the active ones
mmiozzo
parents: 8148
diff changeset
   660
            }
e9a27a8c6331 Uplink scheduler with multiple bearers (LCs) allocates in a Round Robin fashion the active ones
mmiozzo
parents: 8148
diff changeset
   661
        }
9351
6e074e67a1ad HARQ first draft version: RR works, PF todo, LteMiErrorModel on-going
mmiozzo
parents: 9346
diff changeset
   662
      else
8415
e9a27a8c6331 Uplink scheduler with multiple bearers (LCs) allocates in a Round Robin fashion the active ones
mmiozzo
parents: 8148
diff changeset
   663
        {
9351
6e074e67a1ad HARQ first draft version: RR works, PF todo, LteMiErrorModel on-going
mmiozzo
parents: 9346
diff changeset
   664
          // HARQ retransmission -> retrieve data from HARQ buffer
6e074e67a1ad HARQ first draft version: RR works, PF todo, LteMiErrorModel on-going
mmiozzo
parents: 9346
diff changeset
   665
          NS_LOG_DEBUG (this << " UE MAC RETX HARQ " << (uint16_t)m_harqProcessId);
9535
999521532532 Bug-fix LteEnbMac and LteUeMac on HARQ packets buffer in managing several LCs
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9505
diff changeset
   666
          Ptr<PacketBurst> pb = m_miUlHarqProcessesPacket.at (m_harqProcessId);
999521532532 Bug-fix LteEnbMac and LteUeMac on HARQ packets buffer in managing several LCs
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9505
diff changeset
   667
          for (std::list<Ptr<Packet> >::const_iterator j = pb->Begin (); j != pb->End (); ++j)
999521532532 Bug-fix LteEnbMac and LteUeMac on HARQ packets buffer in managing several LCs
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9505
diff changeset
   668
            {
999521532532 Bug-fix LteEnbMac and LteUeMac on HARQ packets buffer in managing several LCs
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9505
diff changeset
   669
              Ptr<Packet> pkt = (*j)->Copy ();
999521532532 Bug-fix LteEnbMac and LteUeMac on HARQ packets buffer in managing several LCs
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9505
diff changeset
   670
              m_uePhySapProvider->SendMacPdu (pkt);
999521532532 Bug-fix LteEnbMac and LteUeMac on HARQ packets buffer in managing several LCs
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9505
diff changeset
   671
            }
999521532532 Bug-fix LteEnbMac and LteUeMac on HARQ packets buffer in managing several LCs
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9505
diff changeset
   672
          m_miUlHarqProcessesPacketTimer.at (m_harqProcessId) = HARQ_PERIOD;          
8415
e9a27a8c6331 Uplink scheduler with multiple bearers (LCs) allocates in a Round Robin fashion the active ones
mmiozzo
parents: 8148
diff changeset
   673
        }
8148
09e2d03022a2 run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents: 7930
diff changeset
   674
7886
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   675
    }
9406
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   676
  else if (msg->GetMessageType () == LteControlMessage::RAR)
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   677
    {
9413
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   678
      if (m_waitingForRaResponse)
9406
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   679
        {
9413
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   680
          Ptr<RarLteControlMessage> rarMsg = DynamicCast<RarLteControlMessage> (msg);
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   681
          uint16_t raRnti = rarMsg->GetRaRnti ();
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   682
          NS_LOG_LOGIC (this << "got RAR with RA-RNTI " << (uint32_t) raRnti << ", expecting " << (uint32_t) m_raRnti);
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   683
          if (raRnti == m_raRnti) // RAR corresponds to TX subframe of preamble
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   684
            {
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   685
              for (std::list<RarLteControlMessage::Rar>::const_iterator it = rarMsg->RarListBegin ();
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   686
                   it != rarMsg->RarListEnd ();
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   687
                   ++it)
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   688
                {
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   689
                  if (it->rapId == m_raPreambleId) // RAR is for me
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   690
                    {
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   691
                      RecvRaResponse (it->rarPayload);
9460
0674e66ee483 Introduces RACH procedures in the schedulers and UL grant at PHY layer
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9414
diff changeset
   692
                      // TODO:: RRC generates the RecvRaResponse messaged
0674e66ee483 Introduces RACH procedures in the schedulers and UL grant at PHY layer
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9414
diff changeset
   693
                      // for avoiding holes in transmission at PHY layer
0674e66ee483 Introduces RACH procedures in the schedulers and UL grant at PHY layer
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9414
diff changeset
   694
                      // (which produce erroneous UL CQI evaluation)
9413
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   695
                    }
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   696
                }
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   697
            }
9406
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   698
        }
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   699
    }
7886
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   700
  else
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   701
    {
9406
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9346
diff changeset
   702
      NS_LOG_WARN (this << " LteControlMessage not recognized");
7886
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   703
    }
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   704
}
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   705
9535
999521532532 Bug-fix LteEnbMac and LteUeMac on HARQ packets buffer in managing several LCs
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9505
diff changeset
   706
void
999521532532 Bug-fix LteEnbMac and LteUeMac on HARQ packets buffer in managing several LCs
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9505
diff changeset
   707
LteUeMac::RefreshHarqProcessesPacketBuffer (void)
999521532532 Bug-fix LteEnbMac and LteUeMac on HARQ packets buffer in managing several LCs
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9505
diff changeset
   708
{
999521532532 Bug-fix LteEnbMac and LteUeMac on HARQ packets buffer in managing several LCs
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9505
diff changeset
   709
  NS_LOG_FUNCTION (this);
999521532532 Bug-fix LteEnbMac and LteUeMac on HARQ packets buffer in managing several LCs
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9505
diff changeset
   710
999521532532 Bug-fix LteEnbMac and LteUeMac on HARQ packets buffer in managing several LCs
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9505
diff changeset
   711
  for (uint16_t i = 0; i < m_miUlHarqProcessesPacketTimer.size (); i++)
999521532532 Bug-fix LteEnbMac and LteUeMac on HARQ packets buffer in managing several LCs
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9505
diff changeset
   712
    {
999521532532 Bug-fix LteEnbMac and LteUeMac on HARQ packets buffer in managing several LCs
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9505
diff changeset
   713
      if (m_miUlHarqProcessesPacketTimer.at (i) == 0)
999521532532 Bug-fix LteEnbMac and LteUeMac on HARQ packets buffer in managing several LCs
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9505
diff changeset
   714
        {
999521532532 Bug-fix LteEnbMac and LteUeMac on HARQ packets buffer in managing several LCs
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9505
diff changeset
   715
          if (m_miUlHarqProcessesPacket.at (i)->GetSize () > 0)
999521532532 Bug-fix LteEnbMac and LteUeMac on HARQ packets buffer in managing several LCs
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9505
diff changeset
   716
            {
999521532532 Bug-fix LteEnbMac and LteUeMac on HARQ packets buffer in managing several LCs
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9505
diff changeset
   717
              // timer expired: drop packets in buffer for this process
999521532532 Bug-fix LteEnbMac and LteUeMac on HARQ packets buffer in managing several LCs
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9505
diff changeset
   718
              NS_LOG_INFO (this << " HARQ Proc Id " << i << " packets buffer expired");
999521532532 Bug-fix LteEnbMac and LteUeMac on HARQ packets buffer in managing several LCs
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9505
diff changeset
   719
              Ptr<PacketBurst> emptyPb = CreateObject <PacketBurst> ();
999521532532 Bug-fix LteEnbMac and LteUeMac on HARQ packets buffer in managing several LCs
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9505
diff changeset
   720
              m_miUlHarqProcessesPacket.at (i) = emptyPb;
999521532532 Bug-fix LteEnbMac and LteUeMac on HARQ packets buffer in managing several LCs
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9505
diff changeset
   721
            }
999521532532 Bug-fix LteEnbMac and LteUeMac on HARQ packets buffer in managing several LCs
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9505
diff changeset
   722
        }
999521532532 Bug-fix LteEnbMac and LteUeMac on HARQ packets buffer in managing several LCs
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9505
diff changeset
   723
      else
999521532532 Bug-fix LteEnbMac and LteUeMac on HARQ packets buffer in managing several LCs
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9505
diff changeset
   724
        {
999521532532 Bug-fix LteEnbMac and LteUeMac on HARQ packets buffer in managing several LCs
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9505
diff changeset
   725
          m_miUlHarqProcessesPacketTimer.at (i)--;
999521532532 Bug-fix LteEnbMac and LteUeMac on HARQ packets buffer in managing several LCs
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9505
diff changeset
   726
        }
999521532532 Bug-fix LteEnbMac and LteUeMac on HARQ packets buffer in managing several LCs
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9505
diff changeset
   727
    }
999521532532 Bug-fix LteEnbMac and LteUeMac on HARQ packets buffer in managing several LCs
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9505
diff changeset
   728
}
999521532532 Bug-fix LteEnbMac and LteUeMac on HARQ packets buffer in managing several LCs
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9505
diff changeset
   729
7886
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   730
8415
e9a27a8c6331 Uplink scheduler with multiple bearers (LCs) allocates in a Round Robin fashion the active ones
mmiozzo
parents: 8148
diff changeset
   731
void
e9a27a8c6331 Uplink scheduler with multiple bearers (LCs) allocates in a Round Robin fashion the active ones
mmiozzo
parents: 8148
diff changeset
   732
LteUeMac::DoSubframeIndication (uint32_t frameNo, uint32_t subframeNo)
e9a27a8c6331 Uplink scheduler with multiple bearers (LCs) allocates in a Round Robin fashion the active ones
mmiozzo
parents: 8148
diff changeset
   733
{
e9a27a8c6331 Uplink scheduler with multiple bearers (LCs) allocates in a Round Robin fashion the active ones
mmiozzo
parents: 8148
diff changeset
   734
  NS_LOG_FUNCTION (this);
9413
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   735
  m_frameNo = frameNo;
20f1c6678ee2 improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   736
  m_subframeNo = subframeNo;
9535
999521532532 Bug-fix LteEnbMac and LteUeMac on HARQ packets buffer in managing several LCs
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9505
diff changeset
   737
  RefreshHarqProcessesPacketBuffer ();
8496
8d1759a15c2e Update LteUeMac for sending BSR only when new BSR are received from RLC
Marco Miozzo <marco.miozzo@cttc.es>
parents: 8462
diff changeset
   738
  if ((Simulator::Now () >= m_bsrLast + m_bsrPeriodicity) && (m_freshUlBsr==true))
8415
e9a27a8c6331 Uplink scheduler with multiple bearers (LCs) allocates in a Round Robin fashion the active ones
mmiozzo
parents: 8148
diff changeset
   739
    {
e9a27a8c6331 Uplink scheduler with multiple bearers (LCs) allocates in a Round Robin fashion the active ones
mmiozzo
parents: 8148
diff changeset
   740
      SendReportBufferStatus ();
e9a27a8c6331 Uplink scheduler with multiple bearers (LCs) allocates in a Round Robin fashion the active ones
mmiozzo
parents: 8148
diff changeset
   741
      m_bsrLast = Simulator::Now ();
8496
8d1759a15c2e Update LteUeMac for sending BSR only when new BSR are received from RLC
Marco Miozzo <marco.miozzo@cttc.es>
parents: 8462
diff changeset
   742
      m_freshUlBsr = false;
9351
6e074e67a1ad HARQ first draft version: RR works, PF todo, LteMiErrorModel on-going
mmiozzo
parents: 9346
diff changeset
   743
      m_harqProcessId = (m_harqProcessId + 1) % HARQ_PERIOD;
8415
e9a27a8c6331 Uplink scheduler with multiple bearers (LCs) allocates in a Round Robin fashion the active ones
mmiozzo
parents: 8148
diff changeset
   744
    }
e9a27a8c6331 Uplink scheduler with multiple bearers (LCs) allocates in a Round Robin fashion the active ones
mmiozzo
parents: 8148
diff changeset
   745
}
e9a27a8c6331 Uplink scheduler with multiple bearers (LCs) allocates in a Round Robin fashion the active ones
mmiozzo
parents: 8148
diff changeset
   746
9414
7b0db3dbf19b merged lena-dev and lena-epc
Nicola Baldo <nbaldo@cttc.es>
parents: 9413 9351
diff changeset
   747
int64_t
7b0db3dbf19b merged lena-dev and lena-epc
Nicola Baldo <nbaldo@cttc.es>
parents: 9413 9351
diff changeset
   748
LteUeMac::AssignStreams (int64_t stream)
7b0db3dbf19b merged lena-dev and lena-epc
Nicola Baldo <nbaldo@cttc.es>
parents: 9413 9351
diff changeset
   749
{
7b0db3dbf19b merged lena-dev and lena-epc
Nicola Baldo <nbaldo@cttc.es>
parents: 9413 9351
diff changeset
   750
  NS_LOG_FUNCTION (this << stream);
7b0db3dbf19b merged lena-dev and lena-epc
Nicola Baldo <nbaldo@cttc.es>
parents: 9413 9351
diff changeset
   751
  m_raPreambleUniformVariable->SetStream (stream);
7b0db3dbf19b merged lena-dev and lena-epc
Nicola Baldo <nbaldo@cttc.es>
parents: 9413 9351
diff changeset
   752
  return 1;
7b0db3dbf19b merged lena-dev and lena-epc
Nicola Baldo <nbaldo@cttc.es>
parents: 9413 9351
diff changeset
   753
}
8415
e9a27a8c6331 Uplink scheduler with multiple bearers (LCs) allocates in a Round Robin fashion the active ones
mmiozzo
parents: 8148
diff changeset
   754
7886
b65c16d4da83 LENA project first public release
CTTC
parents:
diff changeset
   755
} // namespace ns3