uint8_t
PointToPointEpcHelper::ActivateEpsBearer (Ptr<NetDevice> ueDevice, uint64_t imsi, Ptr<EpcTft> tft, EpsBearer bearer)
{
NS_LOG_FUNCTION (this << ueDevice << imsi);
// we now retrieve the IPv4/IPv6 address of the UE and notify it to the SGW;
// we couldn't do it before since address assignment is triggered by
// the user simulation program, rather than done by the EPC
Ptr<Node> ueNode = ueDevice->GetNode ();
Ptr<Ipv4> ueIpv4 = ueNode->GetObject<Ipv4> ();
Ptr<Ipv6> ueIpv6 = ueNode->GetObject<Ipv6> ();
NS_ASSERT_MSG (ueIpv4 != 0 || ueIpv6 != 0, "UEs need to have IPv4/IPv6 installed before EPS bearers can be activated");
if (ueIpv4)
{
int32_t interface = ueIpv4->GetInterfaceForDevice (ueDevice);
if (interface >= 0 && ueIpv4->GetNAddresses (interface) == 1)
{
Ipv4Address ueAddr = ueIpv4->GetAddress (interface, 0).GetLocal ();
NS_LOG_LOGIC (" UE IPv4 address: " << ueAddr);
m_sgwPgwApp->SetUeAddress (imsi, ueAddr);
}
}
if (ueIpv6)
{
int32_t interface6 = ueIpv6->GetInterfaceForDevice (ueDevice);
if (interface6 >= 0 && ueIpv6->GetNAddresses (interface6) == 2)
{
Ipv6Address ueAddr6 = ueIpv6->GetAddress (interface6, 1).GetAddress ();
NS_LOG_LOGIC (" UE IPv6 address: " << ueAddr6);
m_sgwPgwApp->SetUeAddress6 (imsi, ueAddr6);
}
}
uint8_t bearerId = 0;
uint8_t bearerId = 0;
if(imsi == 2 || imsi == 3)
{
NS_LOG_INFO("Bearers for IMSI 2 and 3 not activated");
}
else
{
bearerId = m_mme->AddBearer (imsi, tft, bearer);
}
Ptr<LteUeNetDevice> ueLteDevice = ueDevice->GetObject<LteUeNetDevice> ();
if (ueLteDevice)
{
Simulator::ScheduleNow (&EpcUeNas::ActivateEpsBearer, ueLteDevice->GetNas (), bearer, tft);
}
return bearerId;
}