diff --git a/src/lte/helper/point-to-point-epc-helper.cc b/src/lte/helper/point-to-point-epc-helper.cc index fe6304e65..a064fb9b7 100644 --- a/src/lte/helper/point-to-point-epc-helper.cc +++ b/src/lte/helper/point-to-point-epc-helper.cc @@ -477,20 +477,39 @@ 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); + Ptr enb2LteDev = enb2->GetDevice (0); + + 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 (); + + 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 (); + + 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 +523,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,14 +557,24 @@ PointToPointEpcHelper::ActivateEpsBearer (Ptr ueDevice, uint64_t imsi } } uint8_t bearerId = m_mmeApp->AddBearer (imsi, tft, bearer); - Ptr ueLteDevice = ueDevice->GetObject (); - if (ueLteDevice) - { - Simulator::ScheduleNow (&EpcUeNas::ActivateEpsBearer, ueLteDevice->GetNas (), bearer, tft); - } + + 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 (); + NS_ABORT_MSG_IF (ueLteDevice == nullptr , "Unable to find LteUeNetDevice while activating the EPS bearer"); + + Simulator::ScheduleNow (&EpcUeNas::ActivateEpsBearer, ueLteDevice->GetNas (), bearer, tft); +} + Ptr PointToPointEpcHelper::GetPgwNode () const { 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: