A Discrete-Event Network Simulator
API
wifi-protection.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020 Universita' degli Studi di Napoli Federico II
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation;
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  *
17  * Author: Stefano Avallone <stavallo@unina.it>
18  */
19 
20 #include "wifi-protection.h"
21 
22 #include "wifi-utils.h"
23 
24 namespace ns3
25 {
26 
27 /*
28  * WifiProtection
29  */
30 
32  : method(m),
33  protectionTime(Time::Min()) // uninitialized
34 {
35 }
36 
38 {
39 }
40 
41 /*
42  * WifiNoProtection
43  */
44 
47 {
49 }
50 
51 std::unique_ptr<WifiProtection>
53 {
54  return std::make_unique<WifiNoProtection>(*this);
55 }
56 
57 void
58 WifiNoProtection::Print(std::ostream& os) const
59 {
60  os << "NONE";
61 }
62 
63 /*
64  * WifiRtsCtsProtection
65  */
66 
68  : WifiProtection(RTS_CTS)
69 {
70 }
71 
72 std::unique_ptr<WifiProtection>
74 {
75  return std::make_unique<WifiRtsCtsProtection>(*this);
76 }
77 
78 void
79 WifiRtsCtsProtection::Print(std::ostream& os) const
80 {
81  os << "RTS_CTS";
82 }
83 
84 /*
85  * WifiCtsToSelfProtection
86  */
87 
89  : WifiProtection(CTS_TO_SELF)
90 {
91 }
92 
93 std::unique_ptr<WifiProtection>
95 {
96  return std::make_unique<WifiCtsToSelfProtection>(*this);
97 }
98 
99 void
100 WifiCtsToSelfProtection::Print(std::ostream& os) const
101 {
102  os << "CTS_TO_SELF";
103 }
104 
105 /*
106  * WifiMuRtsCtsProtection
107  */
108 
110  : WifiProtection(MU_RTS_CTS)
111 {
112 }
113 
114 std::unique_ptr<WifiProtection>
116 {
117  return std::make_unique<WifiMuRtsCtsProtection>(*this);
118 }
119 
120 void
121 WifiMuRtsCtsProtection::Print(std::ostream& os) const
122 {
123  os << "MU_RTS_CTS";
124 }
125 
126 std::ostream&
127 operator<<(std::ostream& os, const WifiProtection* protection)
128 {
129  protection->Print(os);
130  return os;
131 }
132 
133 } // namespace ns3
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
int64x64_t Min(const int64x64_t &a, const int64x64_t &b)
Minimum.
Definition: int64x64.h:229
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1326
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition: angles.cc:159
std::unique_ptr< WifiProtection > Copy() const override
Clone this object.
void Print(std::ostream &os) const override
Print the object contents.
std::unique_ptr< WifiProtection > Copy() const override
Clone this object.
void Print(std::ostream &os) const override
Print the object contents.
void Print(std::ostream &os) const override
Print the object contents.
std::unique_ptr< WifiProtection > Copy() const override
Clone this object.
WifiProtection is an abstract base struct.
Time protectionTime
time required by the protection method
Method
Available protection methods.
virtual void Print(std::ostream &os) const =0
Print the object contents.
WifiProtection(Method m)
Constructor.
void Print(std::ostream &os) const override
Print the object contents.
std::unique_ptr< WifiProtection > Copy() const override
Clone this object.