5G-LENA nr-v3.1-14-g738b08bc
The 5G/NR module for the ns-3 simulator
Loading...
Searching...
No Matches
nr-ch-access-manager.h
1// Copyright (c) 2019 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
2//
3// SPDX-License-Identifier: GPL-2.0-only
4
5#include "nr-gnb-mac.h"
6#include "nr-spectrum-phy.h"
7
8#include <ns3/event-id.h>
9#include <ns3/nstime.h>
10#include <ns3/object.h>
11
12#include <functional>
13
14#ifndef NR_CH_ACCESS_MANAGER_H_
15#define NR_CH_ACCESS_MANAGER_H_
16
17namespace ns3
18{
19
46class NrChAccessManager : public Object
47{
48 public:
53 static TypeId GetTypeId();
54
59
63 ~NrChAccessManager() override;
64
69 void SetGrantDuration(Time grantDuration);
70
75 Time GetGrantDuration() const;
76
80 typedef std::function<void(const Time& time)> AccessGrantedCallback;
85 typedef std::function<void()> AccessDeniedCallback;
86
93 virtual void RequestAccess() = 0;
104
108 virtual void Cancel() = 0;
109
114 virtual void SetNrSpectrumPhy(Ptr<NrSpectrumPhy> spectrumPhy);
115
120 Ptr<NrSpectrumPhy> GetNrSpectrumPhy();
121
126 virtual void SetNrGnbMac(Ptr<NrGnbMac> mac);
127
132 Ptr<NrGnbMac> GetNrGnbMac();
133
134 private:
135 Time m_grantDuration;
136 Ptr<NrGnbMac> m_mac;
137 Ptr<NrSpectrumPhy>
138 m_spectrumPhy;
139};
140
170{
171 public:
176 static TypeId GetTypeId();
177
185 ~NrAlwaysOnAccessManager() override;
186
187 // inherited
188 void RequestAccess() override;
189 void SetAccessGrantedCallback(const AccessGrantedCallback& cb) override;
190 void SetAccessDeniedCallback(const AccessDeniedCallback& cb) override;
191 void Cancel() override;
192
193 private:
194 std::vector<AccessGrantedCallback> m_accessGrantedCb;
195};
196
197} // namespace ns3
198
199#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.