A Discrete-Event Network Simulator
API
dsss-ppdu.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020 Orange Labs
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: Rediet <getachew.redieteab@orange.com>
18  * Muhammad Iqbal Rochman <muhiqbalcr@uchicago.edu>
19  * Sébastien Deronne <sebastien.deronne@gmail.com> (DsssSigHeader)
20  */
21 
22 #include "dsss-ppdu.h"
23 
24 #include "dsss-phy.h"
25 
26 #include "ns3/log.h"
27 #include "ns3/wifi-phy-operating-channel.h"
28 #include "ns3/wifi-phy.h"
29 #include "ns3/wifi-psdu.h"
30 
31 namespace ns3
32 {
33 
34 NS_LOG_COMPONENT_DEFINE("DsssPpdu");
35 
37  const WifiTxVector& txVector,
39  Time ppduDuration,
40  uint64_t uid)
41  : WifiPpdu(psdu, txVector, channel, uid)
42 {
43  NS_LOG_FUNCTION(this << psdu << txVector << channel << ppduDuration << uid);
44  SetPhyHeaders(txVector, ppduDuration);
45 }
46 
47 void
48 DsssPpdu::SetPhyHeaders(const WifiTxVector& txVector, Time ppduDuration)
49 {
50  NS_LOG_FUNCTION(this << txVector);
51  SetDsssHeader(m_dsssSig, txVector, ppduDuration);
52 }
53 
54 void
56  const WifiTxVector& txVector,
57  Time ppduDuration) const
58 {
59  dsssSig.SetRate(txVector.GetMode().GetDataRate(22));
60  Time psduDuration = ppduDuration - WifiPhy::CalculatePhyPreambleAndHeaderDuration(txVector);
61  dsssSig.SetLength(psduDuration.GetMicroSeconds());
62 }
63 
66 {
67  WifiTxVector txVector;
68  txVector.SetPreambleType(m_preamble);
69  txVector.SetChannelWidth(22);
71  return txVector;
72 }
73 
74 void
76 {
77  txVector.SetMode(DsssPhy::GetDsssRate(dsssSig.GetRate()));
78 }
79 
80 Time
82 {
83  const auto& txVector = GetTxVector();
84  const auto length = m_dsssSig.GetLength();
86 }
87 
90 {
91  return Ptr<WifiPpdu>(new DsssPpdu(*this), false);
92 }
93 
95  : m_rate(0b00001010),
96  m_length(0)
97 {
98 }
99 
100 void
102 {
103  /* Here is the binary representation for a given rate:
104  * 1 Mbit/s: 00001010
105  * 2 Mbit/s: 00010100
106  * 5.5 Mbit/s: 00110111
107  * 11 Mbit/s: 01101110
108  */
109  switch (rate)
110  {
111  case 1000000:
112  m_rate = 0b00001010;
113  break;
114  case 2000000:
115  m_rate = 0b00010100;
116  break;
117  case 5500000:
118  m_rate = 0b00110111;
119  break;
120  case 11000000:
121  m_rate = 0b01101110;
122  break;
123  default:
124  NS_ASSERT_MSG(false, "Invalid rate");
125  break;
126  }
127 }
128 
129 uint64_t
131 {
132  uint64_t rate = 0;
133  switch (m_rate)
134  {
135  case 0b00001010:
136  rate = 1000000;
137  break;
138  case 0b00010100:
139  rate = 2000000;
140  break;
141  case 0b00110111:
142  rate = 5500000;
143  break;
144  case 0b01101110:
145  rate = 11000000;
146  break;
147  default:
148  NS_ASSERT_MSG(false, "Invalid rate");
149  break;
150  }
151  return rate;
152 }
153 
154 void
156 {
157  m_length = length;
158 }
159 
160 uint16_t
162 {
163  return m_length;
164 }
165 
166 } // namespace ns3
static WifiMode GetDsssRate(uint64_t rate)
Return a WifiMode for HR/DSSS corresponding to the provided rate.
Definition: dsss-phy.cc:291
DSSS SIG PHY header.
Definition: dsss-ppdu.h:52
void SetLength(uint16_t length)
Fill the LENGTH field of L-SIG (in bytes).
Definition: dsss-ppdu.cc:155
uint64_t GetRate() const
Return the RATE field of L-SIG (in bit/s).
Definition: dsss-ppdu.cc:130
void SetRate(uint64_t rate)
Fill the RATE field of L-SIG (in bit/s).
Definition: dsss-ppdu.cc:101
uint16_t GetLength() const
Return the LENGTH field of L-SIG (in bytes).
Definition: dsss-ppdu.cc:161
Time GetTxDuration() const override
Get the total transmission duration of the PPDU.
Definition: dsss-ppdu.cc:81
WifiTxVector DoGetTxVector() const override
Get the TXVECTOR used to send the PPDU.
Definition: dsss-ppdu.cc:65
DsssSigHeader m_dsssSig
the DSSS SIG PHY header
Definition: dsss-ppdu.h:135
DsssPpdu(Ptr< const WifiPsdu > psdu, const WifiTxVector &txVector, const WifiPhyOperatingChannel &channel, Time ppduDuration, uint64_t uid)
Create a DSSS (HR/DSSS) PPDU.
Definition: dsss-ppdu.cc:36
Ptr< WifiPpdu > Copy() const override
Copy this instance.
Definition: dsss-ppdu.cc:89
virtual void SetTxVectorFromDsssHeader(WifiTxVector &txVector, const DsssSigHeader &dsssSig) const
Fill in the TXVECTOR from DSSS header.
Definition: dsss-ppdu.cc:75
void SetPhyHeaders(const WifiTxVector &txVector, Time ppduDuration)
Fill in the PHY headers.
Definition: dsss-ppdu.cc:48
void SetDsssHeader(DsssSigHeader &dsssSig, const WifiTxVector &txVector, Time ppduDuration) const
Fill in the DSSS header.
Definition: dsss-ppdu.cc:55
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
int64_t GetMicroSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:413
uint64_t GetDataRate(uint16_t channelWidth, uint16_t guardInterval, uint8_t nss) const
Definition: wifi-mode.cc:122
static Time CalculatePhyPreambleAndHeaderDuration(const WifiTxVector &txVector)
Definition: wifi-phy.cc:1500
Class that keeps track of all information about the current PHY operating channel.
WifiPpdu stores a preamble, a modulation class, PHY headers and a PSDU.
Definition: wifi-ppdu.h:57
WifiPreamble m_preamble
the PHY preamble
Definition: wifi-ppdu.h:202
const WifiTxVector & GetTxVector() const
Get the TXVECTOR used to send the PPDU.
Definition: wifi-ppdu.cc:85
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
void SetChannelWidth(uint16_t channelWidth)
Sets the selected channelWidth (in MHz)
WifiMode GetMode(uint16_t staId=SU_STA_ID) const
If this TX vector is associated with an SU PPDU, return the selected payload transmission mode.
void SetMode(WifiMode mode)
Sets the selected payload transmission mode.
void SetPreambleType(WifiPreamble preamble)
Sets the preamble type.
Declaration of ns3::DsssPhy class.
Declaration of ns3::DsssPpdu class.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition: assert.h:86
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1350
Every class exported by the ns3 library is enclosed in the ns3 namespace.
channel
Definition: third.py:88