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.h"
28#include "ns3/wifi-psdu.h"
29
30namespace ns3
31{
32
33NS_LOG_COMPONENT_DEFINE("DsssPpdu");
34
36 const WifiTxVector& txVector,
37 uint16_t txCenterFreq,
38 Time ppduDuration,
39 uint64_t uid)
40 : WifiPpdu(psdu, txVector, txCenterFreq, uid)
41{
42 NS_LOG_FUNCTION(this << psdu << txVector << txCenterFreq << ppduDuration << uid);
43 m_dsssSig.SetRate(txVector.GetMode().GetDataRate(22));
44 Time psduDuration = ppduDuration - WifiPhy::CalculatePhyPreambleAndHeaderDuration(txVector);
45 m_dsssSig.SetLength(psduDuration.GetMicroSeconds());
46}
47
49{
50}
51
54{
55 WifiTxVector txVector;
58 txVector.SetChannelWidth(22);
59 return txVector;
60}
61
62Time
64{
65 Time ppduDuration = Seconds(0);
66 const WifiTxVector& txVector = GetTxVector();
67 ppduDuration = MicroSeconds(m_dsssSig.GetLength()) +
69 return ppduDuration;
70}
71
74{
75 return Ptr<WifiPpdu>(new DsssPpdu(*this), false);
76}
77
79 : m_rate(0b00001010),
80 m_length(0)
81{
82}
83
85{
86}
87
90{
91 static TypeId tid = TypeId("ns3::DsssSigHeader")
93 .SetGroupName("Wifi")
94 .AddConstructor<DsssSigHeader>();
95 return tid;
96}
97
100{
101 return GetTypeId();
102}
103
104void
105DsssPpdu::DsssSigHeader::Print(std::ostream& os) const
106{
107 os << "SIGNAL=" << GetRate() << " LENGTH=" << m_length;
108}
109
112{
113 return 6;
114}
115
116void
118{
119 /* Here is the binary representation for a given rate:
120 * 1 Mbit/s: 00001010
121 * 2 Mbit/s: 00010100
122 * 5.5 Mbit/s: 00110111
123 * 11 Mbit/s: 01101110
124 */
125 switch (rate)
126 {
127 case 1000000:
128 m_rate = 0b00001010;
129 break;
130 case 2000000:
131 m_rate = 0b00010100;
132 break;
133 case 5500000:
134 m_rate = 0b00110111;
135 break;
136 case 11000000:
137 m_rate = 0b01101110;
138 break;
139 default:
140 NS_ASSERT_MSG(false, "Invalid rate");
141 break;
142 }
143}
144
145uint64_t
147{
148 uint64_t rate = 0;
149 switch (m_rate)
150 {
151 case 0b00001010:
152 rate = 1000000;
153 break;
154 case 0b00010100:
155 rate = 2000000;
156 break;
157 case 0b00110111:
158 rate = 5500000;
159 break;
160 case 0b01101110:
161 rate = 11000000;
162 break;
163 default:
164 NS_ASSERT_MSG(false, "Invalid rate");
165 break;
166 }
167 return rate;
168}
169
170void
172{
173 m_length = length;
174}
175
176uint16_t
178{
179 return m_length;
180}
181
182void
184{
185 start.WriteU8(m_rate);
186 start.WriteU8(0); /* SERVICE */
187 start.WriteU16(m_length);
188 start.WriteU16(0); /* CRC */
189}
190
193{
195 m_rate = i.ReadU8();
196 i.ReadU8(); /* SERVICE */
197 m_length = i.ReadU16();
198 i.ReadU16(); /* CRC */
199 return i.GetDistanceFrom(start);
200}
201
202} // namespace ns3
iterator in a Buffer instance
Definition: buffer.h:100
uint8_t ReadU8()
Definition: buffer.h:1027
uint32_t GetDistanceFrom(const Iterator &o) const
Definition: buffer.cc:783
uint16_t ReadU16()
Definition: buffer.h:1035
static WifiMode GetDsssRate(uint64_t rate)
Return a WifiMode for HR/DSSS corresponding to the provided rate.
Definition: dsss-phy.cc:292
DSSS SIG PHY header.
Definition: dsss-ppdu.h:53
uint32_t GetSerializedSize() const override
Definition: dsss-ppdu.cc:111
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Definition: dsss-ppdu.cc:99
void SetLength(uint16_t length)
Fill the LENGTH field of L-SIG (in bytes).
Definition: dsss-ppdu.cc:171
void Print(std::ostream &os) const override
Definition: dsss-ppdu.cc:105
void Serialize(Buffer::Iterator start) const override
Definition: dsss-ppdu.cc:183
uint64_t GetRate() const
Return the RATE field of L-SIG (in bit/s).
Definition: dsss-ppdu.cc:146
static TypeId GetTypeId()
Get the type ID.
Definition: dsss-ppdu.cc:89
void SetRate(uint64_t rate)
Fill the RATE field of L-SIG (in bit/s).
Definition: dsss-ppdu.cc:117
uint32_t Deserialize(Buffer::Iterator start) override
Definition: dsss-ppdu.cc:192
uint16_t GetLength() const
Return the LENGTH field of L-SIG (in bytes).
Definition: dsss-ppdu.cc:177
Time GetTxDuration() const override
Get the total transmission duration of the PPDU.
Definition: dsss-ppdu.cc:63
WifiTxVector DoGetTxVector() const override
Get the TXVECTOR used to send the PPDU.
Definition: dsss-ppdu.cc:53
DsssSigHeader m_dsssSig
the DSSS SIG PHY header
Definition: dsss-ppdu.h:125
Ptr< WifiPpdu > Copy() const override
Copy this instance.
Definition: dsss-ppdu.cc:73
~DsssPpdu() override
Destructor for DsssPpdu.
Definition: dsss-ppdu.cc:48
DsssPpdu(Ptr< const WifiPsdu > psdu, const WifiTxVector &txVector, uint16_t txCenterFreq, Time ppduDuration, uint64_t uid)
Create a DSSS (HR/DSSS) PPDU.
Definition: dsss-ppdu.cc:35
Protocol header serialization and deserialization.
Definition: header.h:44
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:412
a unique identifier for an interface.
Definition: type-id.h:60
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:935
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:1451
WifiPpdu stores a preamble, a modulation class, PHY headers and a PSDU.
Definition: wifi-ppdu.h:55
WifiPreamble m_preamble
the PHY preamble
Definition: wifi-ppdu.h:197
const WifiTxVector & GetTxVector() const
Get the TXVECTOR used to send the PPDU.
Definition: wifi-ppdu.cc:76
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:1360
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1336
Every class exported by the ns3 library is enclosed in the ns3 namespace.
def start()
Definition: core.py:1864