A Discrete-Event Network Simulator
API
dsss-ppdu.cc
Go to the documentation of this file.
1/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2020 Orange Labs
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: Rediet <getachew.redieteab@orange.com>
19 * Muhammad Iqbal Rochman <muhiqbalcr@uchicago.edu>
20 * S├ębastien Deronne <sebastien.deronne@gmail.com> (DsssSigHeader)
21 */
22
23#include "ns3/wifi-phy.h"
24#include "ns3/wifi-psdu.h"
25#include "dsss-phy.h"
26#include "dsss-ppdu.h"
27#include "ns3/log.h"
28
29namespace ns3 {
30
31NS_LOG_COMPONENT_DEFINE ("DsssPpdu");
32
34 uint16_t txCenterFreq, Time ppduDuration, uint64_t uid)
35 : WifiPpdu (psdu, txVector, txCenterFreq, uid)
36{
37 NS_LOG_FUNCTION (this << psdu << txVector << txCenterFreq << ppduDuration << uid);
38 m_dsssSig.SetRate (txVector.GetMode ().GetDataRate (22));
39 Time psduDuration = ppduDuration - WifiPhy::CalculatePhyPreambleAndHeaderDuration (txVector);
40 m_dsssSig.SetLength (psduDuration.GetMicroSeconds ());
41}
42
44{
45}
46
49{
50 WifiTxVector txVector;
51 txVector.SetPreambleType (m_preamble);
53 txVector.SetChannelWidth (22);
54 return txVector;
55}
56
57Time
59{
60 Time ppduDuration = Seconds (0);
61 const WifiTxVector& txVector = GetTxVector ();
63 return ppduDuration;
64}
65
67DsssPpdu::Copy (void) const
68{
69 return Create<DsssPpdu> (GetPsdu (), GetTxVector (), m_txCenterFreq, GetTxDuration (), m_uid);
70}
71
73 : m_rate (0b00001010),
74 m_length (0)
75{
76}
77
79{
80}
81
84{
85 static TypeId tid = TypeId ("ns3::DsssSigHeader")
86 .SetParent<Header> ()
87 .SetGroupName ("Wifi")
88 .AddConstructor<DsssSigHeader> ()
89 ;
90 return tid;
91}
92
95{
96 return GetTypeId ();
97}
98
99void
100DsssPpdu::DsssSigHeader::Print (std::ostream &os) const
101{
102 os << "SIGNAL=" << GetRate ()
103 << " LENGTH=" << m_length;
104}
105
108{
109 return 6;
110}
111
112void
114{
115 /* Here is the binary representation for a given rate:
116 * 1 Mbit/s: 00001010
117 * 2 Mbit/s: 00010100
118 * 5.5 Mbit/s: 00110111
119 * 11 Mbit/s: 01101110
120 */
121 switch (rate)
122 {
123 case 1000000:
124 m_rate = 0b00001010;
125 break;
126 case 2000000:
127 m_rate = 0b00010100;
128 break;
129 case 5500000:
130 m_rate = 0b00110111;
131 break;
132 case 11000000:
133 m_rate = 0b01101110;
134 break;
135 default:
136 NS_ASSERT_MSG (false, "Invalid rate");
137 break;
138 }
139}
140
141uint64_t
143{
144 uint64_t rate = 0;
145 switch (m_rate)
146 {
147 case 0b00001010:
148 rate = 1000000;
149 break;
150 case 0b00010100:
151 rate = 2000000;
152 break;
153 case 0b00110111:
154 rate = 5500000;
155 break;
156 case 0b01101110:
157 rate = 11000000;
158 break;
159 default:
160 NS_ASSERT_MSG (false, "Invalid rate");
161 break;
162 }
163 return rate;
164}
165
166void
168{
169 m_length = length;
170}
171
172uint16_t
174{
175 return m_length;
176}
177
178void
180{
181 start.WriteU8 (m_rate);
182 start.WriteU8 (0); /* SERVICE */
183 start.WriteU16 (m_length);
184 start.WriteU16 (0); /* CRC */
185}
186
189{
191 m_rate = i.ReadU8 ();
192 i.ReadU8 (); /* SERVICE */
193 m_length = i.ReadU16 ();
194 i.ReadU16 (); /* CRC */
195 return i.GetDistanceFrom (start);
196}
197
198} //namespace ns3
iterator in a Buffer instance
Definition: buffer.h:99
uint16_t ReadU16(void)
Definition: buffer.h:1029
uint8_t ReadU8(void)
Definition: buffer.h:1021
uint32_t GetDistanceFrom(Iterator const &o) const
Definition: buffer.cc:788
static WifiMode GetDsssRate(uint64_t rate)
Return a WifiMode for HR/DSSS corresponding to the provided rate.
Definition: dsss-phy.cc:268
DSSS SIG PHY header.
Definition: dsss-ppdu.h:54
uint64_t GetRate(void) const
Return the RATE field of L-SIG (in bit/s).
Definition: dsss-ppdu.cc:142
void SetLength(uint16_t length)
Fill the LENGTH field of L-SIG (in bytes).
Definition: dsss-ppdu.cc:167
void Print(std::ostream &os) const override
Definition: dsss-ppdu.cc:100
void Serialize(Buffer::Iterator start) const override
Definition: dsss-ppdu.cc:179
TypeId GetInstanceTypeId(void) const override
Get the most derived TypeId for this Object.
Definition: dsss-ppdu.cc:94
uint32_t GetSerializedSize(void) const override
Definition: dsss-ppdu.cc:107
static TypeId GetTypeId(void)
Get the type ID.
Definition: dsss-ppdu.cc:83
uint16_t GetLength(void) const
Return the LENGTH field of L-SIG (in bytes).
Definition: dsss-ppdu.cc:173
void SetRate(uint64_t rate)
Fill the RATE field of L-SIG (in bit/s).
Definition: dsss-ppdu.cc:113
uint32_t Deserialize(Buffer::Iterator start) override
Definition: dsss-ppdu.cc:188
Ptr< WifiPpdu > Copy(void) const override
Copy this instance.
Definition: dsss-ppdu.cc:67
DsssSigHeader m_dsssSig
the DSSS SIG PHY header
Definition: dsss-ppdu.h:123
WifiTxVector DoGetTxVector(void) const override
Get the TXVECTOR used to send the PPDU.
Definition: dsss-ppdu.cc:48
virtual ~DsssPpdu()
Destructor for DsssPpdu.
Definition: dsss-ppdu.cc:43
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:33
Time GetTxDuration(void) const override
Get the total transmission duration of the PPDU.
Definition: dsss-ppdu.cc:58
Protocol header serialization and deserialization.
Definition: header.h:43
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:104
int64_t GetMicroSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:388
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:922
uint64_t GetDataRate(uint16_t channelWidth, uint16_t guardInterval, uint8_t nss) const
Definition: wifi-mode.cc:114
static Time CalculatePhyPreambleAndHeaderDuration(const WifiTxVector &txVector)
Definition: wifi-phy.cc:1383
WifiPpdu stores a preamble, a modulation class, PHY headers and a PSDU.
Definition: wifi-ppdu.h:52
uint16_t m_txCenterFreq
the center frequency (MHz) used for the transmission of this PPDU
Definition: wifi-ppdu.h:188
WifiTxVector GetTxVector(void) const
Get the TXVECTOR used to send the PPDU.
Definition: wifi-ppdu.cc:65
WifiPreamble m_preamble
the PHY preamble
Definition: wifi-ppdu.h:185
uint64_t m_uid
the unique ID of this PPDU
Definition: wifi-ppdu.h:189
Ptr< const WifiPsdu > GetPsdu(void) const
Get the payload of the PPDU.
Definition: wifi-ppdu.cc:81
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:88
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
#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:1261
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1245
Every class exported by the ns3 library is enclosed in the ns3 namespace.
def start()
Definition: core.py:1852