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
33DsssPpdu::DsssPpdu (Ptr<const WifiPsdu> psdu, const WifiTxVector& txVector, Time ppduDuration, uint64_t uid)
34 : WifiPpdu (psdu, txVector, uid)
35{
36 NS_LOG_FUNCTION (this << psdu << txVector << ppduDuration << uid);
37 m_dsssSig.SetRate (txVector.GetMode ().GetDataRate (22));
38 Time psduDuration = ppduDuration - WifiPhy::CalculatePhyPreambleAndHeaderDuration (txVector);
39 m_dsssSig.SetLength (psduDuration.GetMicroSeconds ());
40}
41
43{
44}
45
48{
49 WifiTxVector txVector;
50 txVector.SetPreambleType (m_preamble);
52 txVector.SetChannelWidth (22);
53 return txVector;
54}
55
56Time
58{
59 Time ppduDuration = Seconds (0);
60 const WifiTxVector& txVector = GetTxVector ();
62 return ppduDuration;
63}
64
66DsssPpdu::Copy (void) const
67{
68 return Create<DsssPpdu> (GetPsdu (), GetTxVector (), GetTxDuration (), m_uid);
69}
70
72 : m_rate (0b00001010),
73 m_length (0)
74{
75}
76
78{
79}
80
83{
84 static TypeId tid = TypeId ("ns3::DsssSigHeader")
85 .SetParent<Header> ()
86 .SetGroupName ("Wifi")
87 .AddConstructor<DsssSigHeader> ()
88 ;
89 return tid;
90}
91
94{
95 return GetTypeId ();
96}
97
98void
99DsssPpdu::DsssSigHeader::Print (std::ostream &os) const
100{
101 os << "SIGNAL=" << GetRate ()
102 << " LENGTH=" << m_length;
103}
104
107{
108 return 6;
109}
110
111void
113{
114 /* Here is the binary representation for a given rate:
115 * 1 Mbit/s: 00001010
116 * 2 Mbit/s: 00010100
117 * 5.5 Mbit/s: 00110111
118 * 11 Mbit/s: 01101110
119 */
120 switch (rate)
121 {
122 case 1000000:
123 m_rate = 0b00001010;
124 break;
125 case 2000000:
126 m_rate = 0b00010100;
127 break;
128 case 5500000:
129 m_rate = 0b00110111;
130 break;
131 case 11000000:
132 m_rate = 0b01101110;
133 break;
134 default:
135 NS_ASSERT_MSG (false, "Invalid rate");
136 break;
137 }
138}
139
140uint64_t
142{
143 uint64_t rate = 0;
144 switch (m_rate)
145 {
146 case 0b00001010:
147 rate = 1000000;
148 break;
149 case 0b00010100:
150 rate = 2000000;
151 break;
152 case 0b00110111:
153 rate = 5500000;
154 break;
155 case 0b01101110:
156 rate = 11000000;
157 break;
158 default:
159 NS_ASSERT_MSG (false, "Invalid rate");
160 break;
161 }
162 return rate;
163}
164
165void
167{
168 m_length = length;
169}
170
171uint16_t
173{
174 return m_length;
175}
176
177void
179{
180 start.WriteU8 (m_rate);
181 start.WriteU8 (0); /* SERVICE */
182 start.WriteU16 (m_length);
183 start.WriteU16 (0); /* CRC */
184}
185
188{
190 m_rate = i.ReadU8 ();
191 i.ReadU8 (); /* SERVICE */
192 m_length = i.ReadU16 ();
193 i.ReadU16 (); /* CRC */
194 return i.GetDistanceFrom (start);
195}
196
197} //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:261
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:141
void SetLength(uint16_t length)
Fill the LENGTH field of L-SIG (in bytes).
Definition: dsss-ppdu.cc:166
void Print(std::ostream &os) const override
Definition: dsss-ppdu.cc:99
void Serialize(Buffer::Iterator start) const override
Definition: dsss-ppdu.cc:178
TypeId GetInstanceTypeId(void) const override
Get the most derived TypeId for this Object.
Definition: dsss-ppdu.cc:93
uint32_t GetSerializedSize(void) const override
Definition: dsss-ppdu.cc:106
static TypeId GetTypeId(void)
Get the type ID.
Definition: dsss-ppdu.cc:82
uint16_t GetLength(void) const
Return the LENGTH field of L-SIG (in bytes).
Definition: dsss-ppdu.cc:172
void SetRate(uint64_t rate)
Fill the RATE field of L-SIG (in bit/s).
Definition: dsss-ppdu.cc:112
uint32_t Deserialize(Buffer::Iterator start) override
Definition: dsss-ppdu.cc:187
Ptr< WifiPpdu > Copy(void) const override
Copy this instance.
Definition: dsss-ppdu.cc:66
DsssSigHeader m_dsssSig
the DSSS SIG PHY header
Definition: dsss-ppdu.h:121
WifiTxVector DoGetTxVector(void) const override
Get the TXVECTOR used to send the PPDU.
Definition: dsss-ppdu.cc:47
virtual ~DsssPpdu()
Destructor for DsssPpdu.
Definition: dsss-ppdu.cc:42
DsssPpdu(Ptr< const WifiPsdu > psdu, const WifiTxVector &txVector, 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:57
Protocol header serialization and deserialization.
Definition: header.h:43
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
int64_t GetMicroSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:387
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:1300
WifiPpdu stores a preamble, a modulation class, PHY headers and a PSDU.
Definition: wifi-ppdu.h:52
WifiTxVector GetTxVector(void) const
Get the TXVECTOR used to send the PPDU.
Definition: wifi-ppdu.cc:63
WifiPreamble m_preamble
the PHY preamble
Definition: wifi-ppdu.h:177
uint64_t m_uid
the unique ID of this PPDU
Definition: wifi-ppdu.h:180
Ptr< const WifiPsdu > GetPsdu(void) const
Get the payload of the PPDU.
Definition: wifi-ppdu.cc:79
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:1260
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.
def start()
Definition: core.py:1853