A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
dsss-ppdu.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020 Orange Labs
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Rediet <getachew.redieteab@orange.com>
7 * Muhammad Iqbal Rochman <muhiqbalcr@uchicago.edu>
8 * Sébastien Deronne <sebastien.deronne@gmail.com> (DsssSigHeader)
9 */
10
11#include "dsss-ppdu.h"
12
13#include "dsss-phy.h"
14
15#include "ns3/log.h"
16#include "ns3/wifi-phy-operating-channel.h"
17#include "ns3/wifi-phy.h"
18#include "ns3/wifi-psdu.h"
19
20namespace ns3
21{
22
23NS_LOG_COMPONENT_DEFINE("DsssPpdu");
24
26 const WifiTxVector& txVector,
27 const WifiPhyOperatingChannel& channel,
28 Time ppduDuration,
29 uint64_t uid)
30 : WifiPpdu(psdu, txVector, channel, uid)
31{
32 NS_LOG_FUNCTION(this << psdu << txVector << channel << ppduDuration << uid);
33 SetPhyHeaders(txVector, ppduDuration);
34}
35
36void
37DsssPpdu::SetPhyHeaders(const WifiTxVector& txVector, Time ppduDuration)
38{
39 NS_LOG_FUNCTION(this << txVector);
40 SetDsssHeader(m_dsssSig, txVector, ppduDuration);
41}
42
43void
45 const WifiTxVector& txVector,
46 Time ppduDuration) const
47{
48 dsssSig.SetRate(txVector.GetMode().GetDataRate(22));
49 Time psduDuration = ppduDuration - WifiPhy::CalculatePhyPreambleAndHeaderDuration(txVector);
50 dsssSig.SetLength(psduDuration.GetMicroSeconds());
51}
52
55{
56 WifiTxVector txVector;
58 txVector.SetChannelWidth(22);
60 return txVector;
61}
62
63void
65{
66 txVector.SetMode(DsssPhy::GetDsssRate(dsssSig.GetRate()));
67}
68
69Time
71{
72 const auto& txVector = GetTxVector();
73 const auto length = m_dsssSig.GetLength();
75}
76
79{
80 return Ptr<WifiPpdu>(new DsssPpdu(*this), false);
81}
82
84 : m_rate(0b00001010),
85 m_length(0)
86{
87}
88
89void
91{
92 /* Here is the binary representation for a given rate:
93 * 1 Mbit/s: 00001010
94 * 2 Mbit/s: 00010100
95 * 5.5 Mbit/s: 00110111
96 * 11 Mbit/s: 01101110
97 */
98 switch (rate)
99 {
100 case 1000000:
101 m_rate = 0b00001010;
102 break;
103 case 2000000:
104 m_rate = 0b00010100;
105 break;
106 case 5500000:
107 m_rate = 0b00110111;
108 break;
109 case 11000000:
110 m_rate = 0b01101110;
111 break;
112 default:
113 NS_ASSERT_MSG(false, "Invalid rate");
114 break;
115 }
116}
117
118uint64_t
120{
121 uint64_t rate = 0;
122 switch (m_rate)
123 {
124 case 0b00001010:
125 rate = 1000000;
126 break;
127 case 0b00010100:
128 rate = 2000000;
129 break;
130 case 0b00110111:
131 rate = 5500000;
132 break;
133 case 0b01101110:
134 rate = 11000000;
135 break;
136 default:
137 NS_ASSERT_MSG(false, "Invalid rate");
138 break;
139 }
140 return rate;
141}
142
143void
145{
146 m_length = length;
147}
148
149uint16_t
151{
152 return m_length;
153}
154
155} // namespace ns3
static WifiMode GetDsssRate(uint64_t rate)
Return a WifiMode for HR/DSSS corresponding to the provided rate.
Definition dsss-phy.cc:284
DSSS SIG PHY header.
Definition dsss-ppdu.h:41
void SetLength(uint16_t length)
Fill the LENGTH field of L-SIG (in bytes).
Definition dsss-ppdu.cc:144
uint64_t GetRate() const
Return the RATE field of L-SIG (in bit/s).
Definition dsss-ppdu.cc:119
void SetRate(uint64_t rate)
Fill the RATE field of L-SIG (in bit/s).
Definition dsss-ppdu.cc:90
uint16_t GetLength() const
Return the LENGTH field of L-SIG (in bytes).
Definition dsss-ppdu.cc:150
Time GetTxDuration() const override
Get the total transmission duration of the PPDU.
Definition dsss-ppdu.cc:70
WifiTxVector DoGetTxVector() const override
Get the TXVECTOR used to send the PPDU.
Definition dsss-ppdu.cc:54
DsssSigHeader m_dsssSig
the DSSS SIG PHY header
Definition dsss-ppdu.h:124
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:25
Ptr< WifiPpdu > Copy() const override
Copy this instance.
Definition dsss-ppdu.cc:78
virtual void SetTxVectorFromDsssHeader(WifiTxVector &txVector, const DsssSigHeader &dsssSig) const
Fill in the TXVECTOR from DSSS header.
Definition dsss-ppdu.cc:64
void SetPhyHeaders(const WifiTxVector &txVector, Time ppduDuration)
Fill in the PHY headers.
Definition dsss-ppdu.cc:37
void SetDsssHeader(DsssSigHeader &dsssSig, const WifiTxVector &txVector, Time ppduDuration) const
Fill in the DSSS header.
Definition dsss-ppdu.cc:44
Smart pointer class similar to boost::intrusive_ptr.
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
int64_t GetMicroSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
Definition nstime.h:402
uint64_t GetDataRate(MHz_u channelWidth, Time guardInterval, uint8_t nss) const
Definition wifi-mode.cc:111
static Time CalculatePhyPreambleAndHeaderDuration(const WifiTxVector &txVector)
Definition wifi-phy.cc:1565
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:47
WifiPreamble m_preamble
the PHY preamble
Definition wifi-ppdu.h:192
const WifiTxVector & GetTxVector() const
Get the TXVECTOR used to send the PPDU.
Definition wifi-ppdu.cc:113
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
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 SetChannelWidth(MHz_u channelWidth)
Sets the selected channelWidth.
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:75
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#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:1332
Every class exported by the ns3 library is enclosed in the ns3 namespace.