5G-LENA  nr-v3.0-29-g83cc959
The 5G/NR module for the ns-3 simulator
nr-ch-access-manager.h
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-gnb-mac.h"
8 #include "nr-spectrum-phy.h"
9 
10 #include <ns3/event-id.h>
11 #include <ns3/nstime.h>
12 #include <ns3/object.h>
13 
14 #include <functional>
15 
16 #ifndef NR_CH_ACCESS_MANAGER_H_
17 #define NR_CH_ACCESS_MANAGER_H_
18 
19 namespace ns3
20 {
21 
48 class NrChAccessManager : public Object
49 {
50  public:
55  static TypeId GetTypeId();
56 
61 
65  ~NrChAccessManager() override;
66 
71  void SetGrantDuration(Time grantDuration);
72 
77  Time GetGrantDuration() const;
78 
82  typedef std::function<void(const Time& time)> AccessGrantedCallback;
87  typedef std::function<void()> AccessDeniedCallback;
88 
95  virtual void RequestAccess() = 0;
100  virtual void SetAccessGrantedCallback(const AccessGrantedCallback& cb) = 0;
105  virtual void SetAccessDeniedCallback(const AccessDeniedCallback& cb) = 0;
106 
110  virtual void Cancel() = 0;
111 
116  virtual void SetNrSpectrumPhy(Ptr<NrSpectrumPhy> spectrumPhy);
117 
122  Ptr<NrSpectrumPhy> GetNrSpectrumPhy();
123 
128  virtual void SetNrGnbMac(Ptr<NrGnbMac> mac);
129 
134  Ptr<NrGnbMac> GetNrGnbMac();
135 
136  private:
137  Time m_grantDuration;
138  Ptr<NrGnbMac> m_mac;
139  Ptr<NrSpectrumPhy>
140  m_spectrumPhy;
141 };
142 
172 {
173  public:
178  static TypeId GetTypeId();
179 
187  ~NrAlwaysOnAccessManager() override;
188 
189  // inherited
190  void RequestAccess() override;
191  void SetAccessGrantedCallback(const AccessGrantedCallback& cb) override;
192  void SetAccessDeniedCallback(const AccessDeniedCallback& cb) override;
193  void Cancel() override;
194 
195  private:
196  std::vector<AccessGrantedCallback> m_accessGrantedCb;
197 };
198 
199 } // namespace ns3
200 
201 #endif /* NR_CH_ACCESS_MANAGER_H_ */
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.
virtual void SetAccessGrantedCallback(const AccessGrantedCallback &cb)=0
Set Access-Granted Callback.
virtual void SetAccessDeniedCallback(const AccessDeniedCallback &cb)=0
Set Access-Denied Callback.
virtual void Cancel()=0
Cancel a previously invoked request for accessing the channel.
Time GetGrantDuration() const
Get grant duration time.
virtual void RequestAccess()=0
RequestAccess.
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.