Add info in LteSpectrumPhy on TB from DCI elaborated by LteEnbPhy and LteUePhy
authorMarco Miozzo <marco.miozzo@cttc.es>
Wed, 23 Nov 2011 17:45:54 +0100
changeset 8511 46046bbb2a5c
parent 8510 fcb4cb81fec2
child 8512 3b33e0855d77
Add info in LteSpectrumPhy on TB from DCI elaborated by LteEnbPhy and LteUePhy
src/lte/examples/lena-first-sim.cc
src/lte/model/lte-enb-phy.cc
src/lte/model/lte-spectrum-phy.cc
src/lte/model/lte-spectrum-phy.h
src/lte/model/lte-ue-phy.cc
--- a/src/lte/examples/lena-first-sim.cc	Wed Nov 23 14:54:43 2011 +0100
+++ b/src/lte/examples/lena-first-sim.cc	Wed Nov 23 17:45:54 2011 +0100
@@ -48,10 +48,11 @@
 
   //lena->EnableLogComponents ();
 
-  //   LogComponentEnable ("LtePhy", LOG_LEVEL_ALL);
+  LogComponentEnable ("LteSpectrumPhy", LOG_LEVEL_ALL);
   LogComponentEnable ("LteEnbPhy", LOG_LEVEL_ALL);
   //   LogComponentEnable ("LteUePhy", LOG_LEVEL_ALL);
-//   LogComponentEnable ("PfFfMacScheduler", LOG_LEVEL_ALL);
+  LogComponentEnable ("PfFfMacScheduler", LOG_LEVEL_ALL);
+  LogComponentEnable ("RrFfMacScheduler", LOG_LEVEL_ALL);
   LogComponentEnable ("LenaHelper", LOG_LEVEL_ALL);
   LogComponentEnable ("BuildingsPropagationLossModel", LOG_LEVEL_ALL);
   LogComponentEnable ("BuildingsPropagationLossModel", LOG_LEVEL_ALL);
@@ -60,7 +61,7 @@
   NodeContainer enbNodes;
   NodeContainer ueNodes;
   enbNodes.Create (1);
-  ueNodes.Create (1);
+  ueNodes.Create (3);
 
   // Install Mobility Model
   MobilityHelper mobility;
@@ -72,8 +73,8 @@
   // Create Devices and install them in the Nodes (eNB and UE)
   NetDeviceContainer enbDevs;
   NetDeviceContainer ueDevs;
-  //lena->SetSchedulerType ("ns3::RrFfMacScheduler");
-  lena->SetSchedulerType ("ns3::PfFfMacScheduler");
+  lena->SetSchedulerType ("ns3::RrFfMacScheduler");
+//   lena->SetSchedulerType ("ns3::PfFfMacScheduler");
   enbDevs = lena->InstallEnbDevice (enbNodes);
   ueDevs = lena->InstallUeDevice (ueNodes);
 
@@ -83,7 +84,11 @@
   // Activate an EPS bearer
   enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE;
   EpsBearer bearer (q);
+  EpsBearer bearer1 (q);
+  EpsBearer bearer2 (q);
   lena->ActivateEpsBearer (ueDevs, bearer);
+  lena->ActivateEpsBearer (ueDevs, bearer1);
+  lena->ActivateEpsBearer (ueDevs, bearer2);
 
 
   Simulator::Stop (Seconds (0.005));
@@ -96,3 +101,4 @@
   Simulator::Destroy ();
   return 0;
 }
+
--- a/src/lte/model/lte-enb-phy.cc	Wed Nov 23 14:54:43 2011 +0100
+++ b/src/lte/model/lte-enb-phy.cc	Wed Nov 23 17:45:54 2011 +0100
@@ -381,6 +381,14 @@
               else
                 {
                   (*it2).second->ReceiveIdealControlMessage (msg);
+                  // send info of TB to LteSpectrumPhy 
+                  // translate to allocation map
+                  std::vector <int> rbMap;
+                  for (int i = dci->GetDci ().m_rbStart; i < dci->GetDci ().m_rbStart + dci->GetDci ().m_rbLen; i++)
+                    {
+                      rbMap.push_back (i);
+                    }
+                  m_uplinkSpectrumPhy->AddExpectedTb (dci->GetDci ().m_rnti, dci->GetDci ().m_tbSize, dci->GetDci ().m_mcs, rbMap);
                 }
             }
           ctrlMsg.pop_front ();
--- a/src/lte/model/lte-spectrum-phy.cc	Wed Nov 23 14:54:43 2011 +0100
+++ b/src/lte/model/lte-spectrum-phy.cc	Wed Nov 23 17:45:54 2011 +0100
@@ -50,6 +50,7 @@
 LteSpectrumPhy::~LteSpectrumPhy ()
 {
   NS_LOG_FUNCTION (this);
+  m_expectedTbs.clear ();
 }
 
 void LteSpectrumPhy::DoDispose ()
@@ -223,6 +224,24 @@
   m_state = newState;
 }
 
+void
+LteSpectrumPhy::AddExpectedTb (uint16_t  rnti, uint16_t size, uint8_t mcs, std::vector<int> map)
+{
+  NS_LOG_LOGIC (this << " rnti: " << rnti << " size " << size << " mcs " << mcs);
+  expectedTbs_t::iterator it;
+  it = m_expectedTbs.find (rnti);
+  if (it == m_expectedTbs.end ())
+    {
+      // insert new entry
+      tbInfo_t tbInfo = {size, mcs, map, false};
+      m_expectedTbs.insert (std::pair<uint16_t, tbInfo_t> (rnti,tbInfo ));
+    }
+  else
+    {
+      NS_FATAL_ERROR ("Expectd two TBs from the same UE");
+    }
+}
+
 
 bool
 LteSpectrumPhy::StartTx (Ptr<PacketBurst> pb)
@@ -404,14 +423,22 @@
   // this will trigger CQI calculation and Error Model evaluation
   // as a side effect, the error model should update the error status of all TBs
   m_interference->EndRx ();
-
+  NS_LOG_INFO (this << " No. of burts " << m_rxPacketBurstList.size ());
+  NS_LOG_DEBUG (this << " Expected TBs " << m_expectedTbs.size ());
+  expectedTbs_t::iterator itTb = m_expectedTbs.begin ();
+  while (itTb!=m_expectedTbs.end ())
+    {
+      NS_LOG_DEBUG (this << "RNTI " << (*itTb).first << " size " << (*itTb).second.size << " mcs " << (*itTb).second.mcs);
+      itTb++;
+    }
+  m_expectedTbs.clear ();  // DEBUG
   for (std::list<Ptr<PacketBurst> >::const_iterator i = m_rxPacketBurstList.begin (); 
        i != m_rxPacketBurstList.end (); ++i)
     {
       // here we should determine whether this TB has been received
       // correctly or not
       bool tbRxOk = true;
-
+      NS_LOG_INFO (this << " Burst of " << (*i)->GetNPackets ());
       if (tbRxOk)
         {
           m_phyRxEndOkTrace (*i);
--- a/src/lte/model/lte-spectrum-phy.h	Wed Nov 23 14:54:43 2011 +0100
+++ b/src/lte/model/lte-spectrum-phy.h	Wed Nov 23 17:45:54 2011 +0100
@@ -35,9 +35,21 @@
 #include <ns3/generic-phy.h>
 #include <ns3/packet-burst.h>
 #include <ns3/lte-interference.h>
+#include <map>
 
 namespace ns3 {
 
+
+struct tbInfo_t
+{
+  uint16_t size;
+  uint8_t mcs;
+  std::vector<int> rbBitmap;
+  bool corrupt;
+};
+
+typedef std::map<uint16_t, tbInfo_t> expectedTbs_t;
+
 class LteNetDevice;
 
 /**
@@ -143,6 +155,16 @@
    * \param p the new LteSinrChunkProcessor to be added to the processing chain
    */
   void AddSinrChunkProcessor (Ptr<LteSinrChunkProcessor> p);
+  
+  /** 
+  * 
+  * 
+  * \param rnti the rnti of the source of the TB
+  * \param size the size of the TB
+  * \param mcs the MCS of the TB
+  * \param map the map of RB(s) used
+  */
+  void AddExpectedTb (uint16_t  rnti, uint16_t size, uint8_t mcs, std::vector<int> map);
 
 private:
   void ChangeState (State newState);
@@ -175,7 +197,9 @@
 
   Ptr<LteInterference> m_interference;
 
-  uint16_t m_cellId; 
+  uint16_t m_cellId;
+  
+  expectedTbs_t m_expectedTbs;
 };
 
 
--- a/src/lte/model/lte-ue-phy.cc	Wed Nov 23 14:54:43 2011 +0100
+++ b/src/lte/model/lte-ue-phy.cc	Wed Nov 23 17:45:54 2011 +0100
@@ -433,6 +433,9 @@
             }
           mask = (mask << 1);
         }
+      
+      // send TB info to LteSpectrumPhy
+      m_downlinkSpectrumPhy->AddExpectedTb (dci.m_rnti, dci.m_tbsSize.at (0), dci.m_mcs.at (0), dlRb);  // SISO mode
 
       SetSubChannelsForReception (dlRb);