src/lte/helper/lena-helper.cc
changeset 8007 845888b95c15
parent 7991 bbd59dacfe0b
child 8010 26c903b3a589
--- a/src/lte/helper/lena-helper.cc	Tue May 03 09:32:21 2011 +0200
+++ b/src/lte/helper/lena-helper.cc	Tue May 03 11:58:15 2011 +0200
@@ -291,9 +291,9 @@
 {
   // setup RRC connection
   Ptr<LteEnbRrc> enbRrc = enbDevice->GetObject<LteEnbNetDevice> ()->GetRrc ();
-  uint16_t rnti = enbRrc->AddUe ();
+  uint16_t rnti = enbRrc->AddUe (ueDevice->GetObject<LteUeNetDevice> ()->GetImsi ());
   Ptr<LteUeRrc> ueRrc = ueDevice->GetObject<LteUeNetDevice> ()->GetRrc ();
-  ueRrc->ConfigureUe (rnti);
+  ueRrc->ConfigureUe (rnti, enbDevice->GetObject<LteEnbNetDevice> ()->GetCellId () );
 
   // attach UE to eNB
   ueDevice->GetObject<LteUeNetDevice> ()->SetTargetEnb (enbDevice->GetObject<LteEnbNetDevice> ());
@@ -411,26 +411,73 @@
 
 }
 
+uint64_t
+FindImsiFromEnbRlcPath (std::string path)
+{
+  // Sample path input:
+  // /NodeList/#NodeId/DeviceList/#DeviceId/LteEnbRrc/UeMap/#C-RNTI/RadioBearerMap/#LCID/LteRlc/RxPDU
+
+  // We retrieve the UeInfo accociated to the C-RNTI and perform the IMSI lookup
+  std::string ueMapPath = path.substr (0, path.find("/RadioBearerMap"));
+  Config::MatchContainer match = Config::LookupMatches (ueMapPath);
+
+  if (match.GetN () != 0)
+    {
+       Ptr<Object> ueInfo = match.Get(0);
+       return ueInfo->GetObject<UeInfo> ()->GetImsi ();
+    }
+  else
+    {
+      NS_FATAL_ERROR ("Lookup " << ueMapPath << " got no matches");
+    }
+}
+
+uint64_t
+FindImsiFromUeRlc (std::string path)
+{
+  // Sample path input:
+  // /NodeList/1/DeviceList/0/LteUeRrc/RlcMap/1/RxPDU
+  // /NodeList/#NodeId/DeviceList/#DeviceId/LteUeRrc/RlcMap/#LCID/RxPDU
+
+  // We retrieve the LteUeNetDevice path
+  std::string lteUeNetDevicePath = path.substr (0, path.find("/LteUeRrc"));
+  Config::MatchContainer match = Config::LookupMatches (lteUeNetDevicePath);
+
+  if (match.GetN () != 0)
+    {
+       Ptr<Object> ueNetDevice = match.Get(0);
+       return ueNetDevice->GetObject<LteUeNetDevice> ()->GetImsi ();
+    }
+  else
+    {
+      NS_FATAL_ERROR ("Lookup " << lteUeNetDevicePath << " got no matches");
+    }
+
+}
+
+
 void
-DlTxPduCallback(Ptr<RlcStatsCalculator> rlcStats, std::string path,
+DlTxPduCallback (Ptr<RlcStatsCalculator> rlcStats, std::string path,
                    uint16_t rnti, uint8_t lcid, uint32_t packetSize)
 {
-  rlcStats->DlTxPdu(rnti, lcid, packetSize);
+  uint64_t imsi = FindImsiFromEnbRlcPath (path);
+  rlcStats->DlTxPdu (imsi, rnti, lcid, packetSize);
 }
 
 void
-DlRxPduCallback(Ptr<RlcStatsCalculator> rlcStats, std::string path,
+DlRxPduCallback (Ptr<RlcStatsCalculator> rlcStats, std::string path,
                    uint16_t rnti, uint8_t lcid, uint32_t packetSize, uint64_t delay)
 {
-  rlcStats->DlRxPdu(rnti, lcid, packetSize, delay);
+  uint64_t imsi = FindImsiFromUeRlc (path);
+  rlcStats->DlRxPdu (imsi, rnti, lcid, packetSize, delay);
 }
 
 void
 LenaHelper::EnableDlRlcTraces (void)
 {
-  Config::Connect("/NodeList/*/DeviceList/*/LteEnbRrc/UeMap/*/RadioBearerMap/*/LteRlc/TxPDU",
+  Config::Connect ("/NodeList/*/DeviceList/*/LteEnbRrc/UeMap/*/RadioBearerMap/*/LteRlc/TxPDU",
                    MakeBoundCallback(&DlTxPduCallback, rlcStats));
-  Config::Connect("/NodeList/*/DeviceList/*/LteUeRrc/RlcMap/*/RxPDU",
+  Config::Connect ("/NodeList/*/DeviceList/*/LteUeRrc/RlcMap/*/RxPDU",
                    MakeBoundCallback(&DlRxPduCallback, rlcStats));
 }
 
@@ -438,17 +485,20 @@
 UlTxPduCallback(Ptr<RlcStatsCalculator> rlcStats, std::string path,
                    uint16_t rnti, uint8_t lcid, uint32_t packetSize)
 {
-  rlcStats->UlTxPdu(rnti, lcid, packetSize);
+  uint64_t imsi = FindImsiFromUeRlc (path);
+  rlcStats->UlTxPdu (imsi, rnti, lcid, packetSize);
 }
 
 void
 UlRxPduCallback(Ptr<RlcStatsCalculator> rlcStats, std::string path,
                    uint16_t rnti, uint8_t lcid, uint32_t packetSize, uint64_t delay)
 {
-  rlcStats->UlRxPdu(rnti, lcid, packetSize, delay);
+  uint64_t imsi = FindImsiFromEnbRlcPath (path);
+  rlcStats->UlRxPdu (imsi, rnti, lcid, packetSize, delay);
 }
 
 
+
 void
 LenaHelper::EnableUlRlcTraces (void)
 {
@@ -458,4 +508,10 @@
                    MakeBoundCallback(&UlRxPduCallback, rlcStats));
 }
 
+Ptr<RlcStatsCalculator>
+LenaHelper::GetRlcStats (void)
+{
+  return rlcStats;
+}
+
 } // namespace ns3