5G-LENA nr-v3.0-33-g7aea1e4
The 5G/NR module for the ns-3 simulator
Loading...
Searching...
No Matches
nr-point-to-point-epc-helper.cc
1/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2
3// Copyright (c) 2019 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
4//
5// SPDX-License-Identifier: GPL-2.0-only
6
7#include "nr-point-to-point-epc-helper.h"
8
9#include <ns3/epc-x2.h>
10#include <ns3/log.h>
11#include <ns3/lte-enb-rrc.h>
12#include <ns3/net-device-container.h>
13#include <ns3/node-container.h>
14#include <ns3/nr-gnb-net-device.h>
15#include <ns3/nr-ue-net-device.h>
16#include <ns3/object.h>
17// clang-format off
18#include <ns3/epc-ue-nas.h>
19
20// clang-format on
21
22namespace ns3
23{
24
25NS_LOG_COMPONENT_DEFINE("NrPointToPointEpcHelper");
26
27NS_OBJECT_ENSURE_REGISTERED(NrPointToPointEpcHelper);
28
30 : PointToPointEpcHelper()
31{
32 NS_LOG_FUNCTION(this);
33}
34
36{
37 NS_LOG_FUNCTION(this);
38}
39
40TypeId
42{
43 static TypeId tid = TypeId("ns3::NrPointToPointEpcHelper")
44 .SetParent<PointToPointEpcHelper>()
45 .SetGroupName("nr")
46 .AddConstructor<NrPointToPointEpcHelper>();
47 return tid;
48}
49
50void
51NrPointToPointEpcHelper::DoAddX2Interface(const Ptr<EpcX2>& gnb1X2,
52 const Ptr<NetDevice>& gnb1NetDev,
53 const Ipv4Address& gnb1X2Address,
54 const Ptr<EpcX2>& gnb2X2,
55 const Ptr<NetDevice>& gnb2NetDev,
56 const Ipv4Address& gnb2X2Address) const
57{
58 NS_LOG_FUNCTION(this);
59
60 Ptr<NrGnbNetDevice> gnb1NetDevice = gnb1NetDev->GetObject<NrGnbNetDevice>();
61 Ptr<NrGnbNetDevice> gnb2NetDevice = gnb2NetDev->GetObject<NrGnbNetDevice>();
62 std::vector<uint16_t> gnb1CellIds = gnb1NetDevice->GetCellIds();
63 std::vector<uint16_t> gnb2CellIds = gnb2NetDevice->GetCellIds();
64
65 NS_ABORT_IF(gnb1NetDevice == nullptr);
66 NS_ABORT_IF(gnb2NetDevice == nullptr);
67
68 uint16_t gnb1CellId = gnb1CellIds.at(0);
69 uint16_t gnb2CellId = gnb2CellIds.at(0);
70
71 NS_LOG_LOGIC("NrGnbNetDevice #1 = " << gnb1NetDev << " - CellId = " << gnb1CellId);
72 NS_LOG_LOGIC("NrGnbNetDevice #2 = " << gnb2NetDev << " - CellId = " << gnb2CellId);
73
74 gnb1X2->AddX2Interface(gnb1CellId, gnb1X2Address, gnb2CellIds, gnb2X2Address);
75 gnb2X2->AddX2Interface(gnb2CellId, gnb2X2Address, gnb1CellIds, gnb1X2Address);
76
77 gnb1NetDevice->GetRrc()->AddX2Neighbour(gnb2CellId);
78 gnb2NetDevice->GetRrc()->AddX2Neighbour(gnb1CellId);
79}
80
81void
82NrPointToPointEpcHelper::DoActivateEpsBearerForUe(const Ptr<NetDevice>& ueDevice,
83 const Ptr<EpcTft>& tft,
84 const EpsBearer& bearer) const
85{
86 Ptr<NrUeNetDevice> ueNetDevice = ueDevice->GetObject<NrUeNetDevice>();
87 if (ueNetDevice)
88 {
89 Simulator::ScheduleNow(&EpcUeNas::ActivateEpsBearer, ueNetDevice->GetNas(), bearer, tft);
90 }
91 else
92 {
93 NS_FATAL_ERROR("What kind of device are you trying to pass to the NR helper?");
94 }
95}
96
97} // namespace ns3
The NrGnbNetDevice class.
std::vector< uint16_t > GetCellIds() const
Create an EPC network with PointToPoint links.
static TypeId GetTypeId()
Register this type.