5G-LENA nr-v3.1-69-g2dd513a7
The 5G/NR module for the ns-3 simulator
Loading...
Searching...
No Matches
nr-point-to-point-epc-helper.cc
1// Copyright (c) 2011-2019 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
2//
3// SPDX-License-Identifier: GPL-2.0-only
4//
5// Authors:
6// Jaume Nin <jnin@cttc.es>
7// Nicola Baldo <nbaldo@cttc.es>
8// Manuel Requena <manuel.requena@cttc.es>
9// (most of the code refactored to no-backhaul-epc-helper.cc)
10
11#include "nr-point-to-point-epc-helper.h"
12
13#include "ns3/boolean.h"
14#include "ns3/log.h"
15#include "ns3/point-to-point-helper.h"
16#include "ns3/string.h"
17
18namespace ns3
19{
20
21NS_LOG_COMPONENT_DEFINE("NrPointToPointEpcHelper");
22
23NS_OBJECT_ENSURE_REGISTERED(NrPointToPointEpcHelper);
24
27{
28 NS_LOG_FUNCTION(this);
29 // To access the attribute value within the constructor
30 ObjectBase::ConstructSelf(AttributeConstructionList());
31
32 // since we use point-to-point links for the backhaul links,
33 // we use a /30 subnet which can hold exactly two addresses
34 // (remember that net broadcast and null address are not valid)
35 m_s1uIpv4AddressHelper.SetBase("10.0.0.0", "255.255.255.252");
36 m_s1apIpv4AddressHelper.SetBase("11.0.0.0", "255.255.255.252");
37}
38
40{
41 NS_LOG_FUNCTION(this);
42}
43
44TypeId
46{
47 NS_LOG_FUNCTION_NOARGS();
48 static TypeId tid =
49 TypeId("ns3::NrPointToPointEpcHelper")
50 .SetParent<NrNoBackhaulEpcHelper>()
51 .SetGroupName("Nr")
52 .AddConstructor<NrPointToPointEpcHelper>()
53 .AddAttribute("S1uLinkDataRate",
54 "The data rate to be used for the next S1-U link to be created",
55 DataRateValue(DataRate("10Gb/s")),
56 MakeDataRateAccessor(&NrPointToPointEpcHelper::m_s1uLinkDataRate),
57 MakeDataRateChecker())
58 .AddAttribute("S1uLinkDelay",
59 "The delay to be used for the next S1-U link to be created",
60 TimeValue(Seconds(0)),
61 MakeTimeAccessor(&NrPointToPointEpcHelper::m_s1uLinkDelay),
62 MakeTimeChecker())
63 .AddAttribute("S1uLinkMtu",
64 "The MTU of the next S1-U link to be created. Note that, because of the "
65 "additional GTP/UDP/IP tunneling overhead, you need a MTU larger than "
66 "the end-to-end MTU that you want to support.",
67 UintegerValue(2000),
68 MakeUintegerAccessor(&NrPointToPointEpcHelper::m_s1uLinkMtu),
69 MakeUintegerChecker<uint16_t>())
70 .AddAttribute("S1uLinkPcapPrefix",
71 "Prefix for Pcap generated by S1-U link",
72 StringValue("s1u"),
73 MakeStringAccessor(&NrPointToPointEpcHelper::m_s1uLinkPcapPrefix),
74 MakeStringChecker())
75 .AddAttribute("S1uLinkEnablePcap",
76 "Enable Pcap for X2 link",
77 BooleanValue(false),
78 MakeBooleanAccessor(&NrPointToPointEpcHelper::m_s1uLinkEnablePcap),
79 MakeBooleanChecker());
80 return tid;
81}
82
83TypeId
84NrPointToPointEpcHelper::GetInstanceTypeId() const
85{
86 return GetTypeId();
87}
88
89void
90NrPointToPointEpcHelper::DoDispose()
91{
92 NS_LOG_FUNCTION(this);
93 NrNoBackhaulEpcHelper::DoDispose();
94}
95
96void
98 Ptr<NetDevice> nrGnbNetDevice,
99 std::vector<uint16_t> cellIds)
100{
101 NS_LOG_FUNCTION(this << gnb << nrGnbNetDevice << cellIds.size());
102
103 NrNoBackhaulEpcHelper::AddGnb(gnb, nrGnbNetDevice, cellIds);
104
105 // create a point to point link between the gNB and the SGW with
106 // the corresponding new NetDevices on each side
107 Ptr<Node> sgw = GetSgwNode();
108
109 PointToPointHelper p2ph;
110 p2ph.SetDeviceAttribute("DataRate", DataRateValue(m_s1uLinkDataRate));
111 p2ph.SetDeviceAttribute("Mtu", UintegerValue(m_s1uLinkMtu));
112 p2ph.SetChannelAttribute("Delay", TimeValue(m_s1uLinkDelay));
113 NetDeviceContainer gnbSgwDevices = p2ph.Install(gnb, sgw);
114 NS_LOG_LOGIC("Ipv4 ifaces of the gNB after installing p2p dev: "
115 << gnb->GetObject<Ipv4>()->GetNInterfaces());
116
117 if (m_s1uLinkEnablePcap)
118 {
119 p2ph.EnablePcapAll(m_s1uLinkPcapPrefix);
120 }
121
122 m_s1uIpv4AddressHelper.NewNetwork();
123 Ipv4InterfaceContainer gnbSgwIpIfaces = m_s1uIpv4AddressHelper.Assign(gnbSgwDevices);
124 NS_LOG_LOGIC("number of Ipv4 ifaces of the gNB after assigning Ipv4 addr to S1 dev: "
125 << gnb->GetObject<Ipv4>()->GetNInterfaces());
126
127 Ipv4Address gnbS1uAddress = gnbSgwIpIfaces.GetAddress(0);
128 Ipv4Address sgwS1uAddress = gnbSgwIpIfaces.GetAddress(1);
129
130 NrNoBackhaulEpcHelper::AddS1Interface(gnb, gnbS1uAddress, sgwS1uAddress, cellIds);
131}
132
133} // namespace ns3
Create an EPC network with PointToPoint links between the core network nodes.
void AddGnb(Ptr< Node > gnbNode, Ptr< NetDevice > nrGnbNetDevice, std::vector< uint16_t > cellIds) override
void AddS1Interface(Ptr< Node > gnb, Ipv4Address gnbAddress, Ipv4Address sgwAddress, std::vector< uint16_t > cellIds) override
Ptr< Node > GetSgwNode() const override
Create an EPC network with PointToPoint links.
static TypeId GetTypeId()
Register this type.
void AddGnb(Ptr< Node > gnbNode, Ptr< NetDevice > nrGnbNetDevice, std::vector< uint16_t > cellIds) override