A Discrete-Event Network Simulator
API
wifi-protection.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2020 Universita' degli Studi di Napoli Federico II
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Stefano Avallone <stavallo@unina.it>
19  */
20 
21 #include "wifi-protection.h"
22 #include "wifi-utils.h"
23 
24 namespace ns3 {
25 
26 /*
27  * WifiProtection
28  */
29 
31  : method (m),
32  protectionTime (Time::Min ()) // uninitialized
33 {
34 }
35 
37 {
38 }
39 
40 
41 /*
42  * WifiNoProtection
43  */
44 
47 {
48  protectionTime = Seconds (0);
49 }
50 
51 std::unique_ptr<WifiProtection>
53 {
54  return std::unique_ptr<WifiProtection> (new WifiNoProtection (*this));
55 }
56 
57 void
58 WifiNoProtection::Print (std::ostream &os) const
59 {
60  os << "NONE";
61 }
62 
63 
64 /*
65  * WifiRtsCtsProtection
66  */
67 
69  : WifiProtection (RTS_CTS)
70 {
71 }
72 
73 std::unique_ptr<WifiProtection>
75 {
76  return std::unique_ptr<WifiProtection> (new WifiRtsCtsProtection (*this));
77 }
78 
79 void
80 WifiRtsCtsProtection::Print (std::ostream &os) const
81 {
82  os << "RTS_CTS";
83 }
84 
85 
86 /*
87  * WifiCtsToSelfProtection
88  */
89 
91  : WifiProtection (CTS_TO_SELF)
92 {
93 }
94 
95 std::unique_ptr<WifiProtection>
97 {
98  return std::unique_ptr<WifiProtection> (new WifiCtsToSelfProtection (*this));
99 }
100 
101 void
102 WifiCtsToSelfProtection::Print (std::ostream &os) const
103 {
104  os << "CTS_TO_SELF";
105 }
106 
107 
108 std::ostream & operator << (std::ostream &os, const WifiProtection* protection)
109 {
110  protection->Print (os);
111  return os;
112 }
113 
114 } //namespace ns3
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
int64x64_t Min(const int64x64_t &a, const int64x64_t &b)
Minimum.
Definition: int64x64.h:218
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1244
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:139
WifiCtsToSelfProtection specifies that CTS-to-self protection method is used.
std::unique_ptr< WifiProtection > Copy(void) const override
Clone this object.
void Print(std::ostream &os) const override
Print the object contents.
WifiNoProtection specifies that no protection method is used.
void Print(std::ostream &os) const override
Print the object contents.
std::unique_ptr< WifiProtection > Copy(void) 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.
WifiRtsCtsProtection specifies that RTS/CTS protection method is used.
void Print(std::ostream &os) const override
Print the object contents.
std::unique_ptr< WifiProtection > Copy(void) const override
Clone this object.