5G-LENA nr-v3.1-69-g2dd513a7
The 5G/NR module for the ns-3 simulator
Loading...
Searching...
No Matches
nr-ch-access-manager.cc
1// Copyright (c) 2019 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
2//
3// SPDX-License-Identifier: GPL-2.0-only
4
5#include "nr-ch-access-manager.h"
6
7#include <ns3/double.h>
8#include <ns3/log.h>
9
10namespace ns3
11{
12
13NS_LOG_COMPONENT_DEFINE("NrChAccessManager");
14NS_OBJECT_ENSURE_REGISTERED(NrChAccessManager);
15
16TypeId
18{
19 static TypeId tid = TypeId("ns3::NrChAccessManager")
20 .SetParent<Object>()
21 .SetGroupName("nr")
22 .AddAttribute("GrantDuration",
23 "Duration of grant for transmitting.",
24 TimeValue(Minutes(1)),
27 MakeTimeChecker());
28 return tid;
29}
30
32{
33 NS_LOG_FUNCTION(this);
34}
35
37{
38 NS_LOG_FUNCTION(this);
39}
40
41void
43{
44 NS_LOG_FUNCTION(this);
45 m_grantDuration = grantDuration;
46}
47
48Time
50{
51 NS_LOG_FUNCTION(this);
52 return m_grantDuration;
53}
54
55void
56NrChAccessManager::SetNrSpectrumPhy(Ptr<NrSpectrumPhy> spectrumPhy)
57{
58 NS_LOG_FUNCTION(this);
59 m_spectrumPhy = spectrumPhy;
60}
61
62Ptr<NrSpectrumPhy>
64{
65 NS_LOG_FUNCTION(this);
66 return m_spectrumPhy;
67}
68
69void
71{
72 NS_LOG_FUNCTION(this);
73 m_mac = mac;
74}
75
76Ptr<NrGnbMac>
78{
79 NS_LOG_FUNCTION(this);
80 return m_mac;
81}
82
83// -----------------------------------------------------------------
84
85NS_OBJECT_ENSURE_REGISTERED(NrAlwaysOnAccessManager);
86
87TypeId
89{
90 static TypeId tid = TypeId("ns3::NrAlwaysOnAccessManager")
91 .SetParent<NrChAccessManager>()
92 .SetGroupName("nr")
93 .AddConstructor<NrAlwaysOnAccessManager>();
94 return tid;
95}
96
99{
100 NS_LOG_FUNCTION(this);
101}
102
104{
105 NS_LOG_FUNCTION(this);
106}
107
108void
110{
111 NS_LOG_FUNCTION(this);
112 // We are always on!!
113 for (const auto& cb : m_accessGrantedCb)
114 {
115 cb(Time::Max() - Simulator::Now());
116 }
117}
118
119void
121{
122 NS_LOG_FUNCTION(this);
123 m_accessGrantedCb.push_back(cb);
124}
125
126void
128 [[maybe_unused]] const NrChAccessManager::AccessDeniedCallback& cb)
129{
130 NS_LOG_FUNCTION(this);
131 // Don't store it, as we will not call it..
132}
133
134void
136{
137 NS_LOG_FUNCTION(this);
138 // Do nothing, we are always on and we call the callback only when RequestAccess()
139 // is called
140}
141
142} // namespace ns3
A Channel access manager that sees the channel always free for transmitting.
void Cancel() override
Cancel a previously invoked request for accessing the channel.
NrAlwaysOnAccessManager()
NrAlwaysOnAccessManager constructor.
void RequestAccess() override
RequestAccess.
void SetAccessGrantedCallback(const AccessGrantedCallback &cb) override
Set Access-Granted Callback.
~NrAlwaysOnAccessManager() override
destructor
static TypeId GetTypeId()
Get the type ID.
void SetAccessDeniedCallback(const AccessDeniedCallback &cb) override
Set Access-Denied Callback.
The Channel Access Manager class.
Time GetGrantDuration() const
Get grant duration time.
void SetGrantDuration(Time grantDuration)
Set duration of grant for transmission.
~NrChAccessManager() override
~ChannelAccessManager
virtual void SetNrGnbMac(Ptr< NrGnbMac > mac)
Set MAC instance for this channel access manager.
std::function< void(const Time &time)> AccessGrantedCallback
A function that signal that the channel has been earned.
std::function< void()> AccessDeniedCallback
A function that signal that the channel is denied and the request should be retried.
Ptr< NrGnbMac > GetNrGnbMac()
Getter for MAC instance to which is connected this channel access manager.
NrChAccessManager()
ChannelAccessManager constructor.
virtual void SetNrSpectrumPhy(Ptr< NrSpectrumPhy > spectrumPhy)
Set spectrum phy instance for this channel access manager.
static TypeId GetTypeId()
Get the type ID.
Ptr< NrSpectrumPhy > GetNrSpectrumPhy()
Getter for spectrum phy instance to which is connected this channel access manager.