From dd495a9da8cd7b4ffc7071bb43a67be948c2ca96 Mon Sep 17 00:00:00 2001 From: Natale Patriciello Date: Fri, 8 Mar 2019 15:41:59 +0100 Subject: [PATCH 1/2] lte: Make point-to-point-epc-helper inheritable --- src/lte/helper/point-to-point-epc-helper.cc | 47 ++++++++++++++++----- src/lte/helper/point-to-point-epc-helper.h | 25 +++++++++++ 2 files changed, 62 insertions(+), 10 deletions(-) diff --git a/src/lte/helper/point-to-point-epc-helper.cc b/src/lte/helper/point-to-point-epc-helper.cc index fe6304e65..b60c87a10 100644 --- a/src/lte/helper/point-to-point-epc-helper.cc +++ b/src/lte/helper/point-to-point-epc-helper.cc @@ -477,20 +477,35 @@ PointToPointEpcHelper::AddX2Interface (Ptr enb1, Ptr enb2) // Add X2 interface to both eNBs' X2 entities Ptr enb1X2 = enb1->GetObject (); - Ptr enb1LteDev = enb1->GetDevice (0)->GetObject (); - uint16_t enb1CellId = enb1LteDev->GetCellId (); - NS_LOG_LOGIC ("LteEnbNetDevice #1 = " << enb1LteDev << " - CellId = " << enb1CellId); - Ptr enb2X2 = enb2->GetObject (); - Ptr enb2LteDev = enb2->GetDevice (0)->GetObject (); - uint16_t enb2CellId = enb2LteDev->GetCellId (); + + Ptr enb1LteDev = enb1->GetDevice (0); // What if at position 0 we have another device than LTE? + Ptr enb2LteDev = enb2->GetDevice (0); // What if at position 0 we have another device than LTE? + + DoAddX2Interface (enb1X2, enb1LteDev, enb1X2Address, enb2X2, enb2LteDev, enb2X2Address); +} + +void +PointToPointEpcHelper::DoAddX2Interface (const Ptr &enb1X2, const Ptr &enb1LteDev, + const Ipv4Address &enb1X2Address, + const Ptr &enb2X2, const Ptr &enb2LteDev, + const Ipv4Address &enb2X2Address) const +{ + NS_LOG_FUNCTION (this); + + Ptr enb1LteDevice = enb1LteDev->GetObject (); + Ptr enb2LteDevice = enb2LteDev->GetObject (); + uint16_t enb1CellId = enb1LteDevice->GetCellId (); + uint16_t enb2CellId = enb2LteDevice->GetCellId (); + + NS_LOG_LOGIC ("LteEnbNetDevice #1 = " << enb1LteDev << " - CellId = " << enb1CellId); NS_LOG_LOGIC ("LteEnbNetDevice #2 = " << enb2LteDev << " - CellId = " << enb2CellId); enb1X2->AddX2Interface (enb1CellId, enb1X2Address, enb2CellId, enb2X2Address); enb2X2->AddX2Interface (enb2CellId, enb2X2Address, enb1CellId, enb1X2Address); - enb1LteDev->GetRrc ()->AddX2Neighbour (enb2LteDev->GetCellId ()); - enb2LteDev->GetRrc ()->AddX2Neighbour (enb1LteDev->GetCellId ()); + enb1LteDevice->GetRrc ()->AddX2Neighbour (enb2CellId); + enb2LteDevice->GetRrc ()->AddX2Neighbour (enb1CellId); } @@ -504,7 +519,8 @@ PointToPointEpcHelper::AddUe (Ptr ueDevice, uint64_t imsi) } uint8_t -PointToPointEpcHelper::ActivateEpsBearer (Ptr ueDevice, uint64_t imsi, Ptr tft, EpsBearer bearer) +PointToPointEpcHelper::ActivateEpsBearer (Ptr ueDevice, uint64_t imsi, + Ptr tft, EpsBearer bearer) { NS_LOG_FUNCTION (this << ueDevice << imsi); @@ -537,12 +553,23 @@ PointToPointEpcHelper::ActivateEpsBearer (Ptr ueDevice, uint64_t imsi } } uint8_t bearerId = m_mmeApp->AddBearer (imsi, tft, bearer); + + DoActivateEpsBearerForUe (ueDevice, tft, bearer); + + return bearerId; +} + +void +PointToPointEpcHelper::DoActivateEpsBearerForUe (const Ptr &ueDevice, + const Ptr &tft, + const EpsBearer &bearer) const +{ + NS_LOG_FUNCTION (this); Ptr ueLteDevice = ueDevice->GetObject (); if (ueLteDevice) { Simulator::ScheduleNow (&EpcUeNas::ActivateEpsBearer, ueLteDevice->GetNas (), bearer, tft); } - return bearerId; } Ptr diff --git a/src/lte/helper/point-to-point-epc-helper.h b/src/lte/helper/point-to-point-epc-helper.h index b2e252aa5..9d60c2513 100644 --- a/src/lte/helper/point-to-point-epc-helper.h +++ b/src/lte/helper/point-to-point-epc-helper.h @@ -83,6 +83,31 @@ public: virtual Ipv4Address GetUeDefaultGatewayAddress (); virtual Ipv6Address GetUeDefaultGatewayAddress6 (); +protected: + /** + * \brief DoAddX2Interface: Call AddX2Interface on top of the Enb device pointers + * + * \param enb1X2 EPCX2 of ENB1 + * \param enb1LteDev LTE device of ENB1 + * \param enb1X2Address Address for ENB1 + * \param enb2X2 EPCX2 of ENB2 + * \param enb2LteDev LTE device of ENB2 + * \param enb2X2Address Address for ENB2 + */ + virtual void DoAddX2Interface(const Ptr &enb1X2, const Ptr &enb1LteDev, + const Ipv4Address &enb1X2Address, + const Ptr &enb2X2, const Ptr &enb2LteDev, + const Ipv4Address &enb2X2Address) const; + + /** + * \brief DoActivateEpsBearerForUe: Schedule ActivateEpsBearer on the UE + * \param ueDevice LTE device for the UE + * \param tft TFT + * \param bearer Bearer + */ + virtual void DoActivateEpsBearerForUe (const Ptr &ueDevice, + const Ptr &tft, + const EpsBearer &bearer) const; private: From 8cbec725118df81008c326bd6e7dfd62182560fc Mon Sep 17 00:00:00 2001 From: Natale Patriciello Date: Mon, 11 Mar 2019 16:16:11 +0100 Subject: [PATCH 2/2] lte: fixed reviewer comments for p2p helper --- src/lte/helper/point-to-point-epc-helper.cc | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/lte/helper/point-to-point-epc-helper.cc b/src/lte/helper/point-to-point-epc-helper.cc index b60c87a10..a064fb9b7 100644 --- a/src/lte/helper/point-to-point-epc-helper.cc +++ b/src/lte/helper/point-to-point-epc-helper.cc @@ -479,8 +479,8 @@ PointToPointEpcHelper::AddX2Interface (Ptr enb1, Ptr enb2) Ptr enb1X2 = enb1->GetObject (); Ptr enb2X2 = enb2->GetObject (); - Ptr enb1LteDev = enb1->GetDevice (0); // What if at position 0 we have another device than LTE? - Ptr enb2LteDev = enb2->GetDevice (0); // What if at position 0 we have another device than LTE? + Ptr enb1LteDev = enb1->GetDevice (0); + Ptr enb2LteDev = enb2->GetDevice (0); DoAddX2Interface (enb1X2, enb1LteDev, enb1X2Address, enb2X2, enb2LteDev, enb2X2Address); } @@ -495,6 +495,10 @@ PointToPointEpcHelper::DoAddX2Interface (const Ptr &enb1X2, const Ptr enb1LteDevice = enb1LteDev->GetObject (); Ptr enb2LteDevice = enb2LteDev->GetObject (); + + NS_ABORT_MSG_IF (enb1LteDevice == nullptr , "Unable to find LteEnbNetDevice for the first eNB"); + NS_ABORT_MSG_IF (enb2LteDevice == nullptr , "Unable to find LteEnbNetDevice for the second eNB"); + uint16_t enb1CellId = enb1LteDevice->GetCellId (); uint16_t enb2CellId = enb2LteDevice->GetCellId (); @@ -566,10 +570,9 @@ PointToPointEpcHelper::DoActivateEpsBearerForUe (const Ptr &ueDevice, { NS_LOG_FUNCTION (this); Ptr ueLteDevice = ueDevice->GetObject (); - if (ueLteDevice) - { - Simulator::ScheduleNow (&EpcUeNas::ActivateEpsBearer, ueLteDevice->GetNas (), bearer, tft); - } + NS_ABORT_MSG_IF (ueLteDevice == nullptr , "Unable to find LteUeNetDevice while activating the EPS bearer"); + + Simulator::ScheduleNow (&EpcUeNas::ActivateEpsBearer, ueLteDevice->GetNas (), bearer, tft); } Ptr