A Discrete-Event Network Simulator
API
wifi-psdu.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2019 Universita' degli Studi di Napoli Federico II
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: Stefano Avallone <stavallo@unina.it>
19  */
20 
21 #ifndef WIFI_PSDU_H
22 #define WIFI_PSDU_H
23 
24 #include "ns3/nstime.h"
25 #include "wifi-mac-header.h"
26 #include "wifi-mac-queue-item.h"
27 #include <vector>
28 #include <set>
29 
30 namespace ns3 {
31 
32 class Packet;
33 
40 class WifiPsdu : public SimpleRefCount<WifiPsdu>
41 {
42 public:
51  WifiPsdu (Ptr<const Packet> p, const WifiMacHeader & header);
52 
60  WifiPsdu (Ptr<WifiMacQueueItem> mpdu, bool isSingle);
61 
69  WifiPsdu (Ptr<const WifiMacQueueItem> mpdu, bool isSingle);
70 
76  WifiPsdu (std::vector<Ptr<WifiMacQueueItem>> mpduList);
77 
78  virtual ~WifiPsdu ();
79 
84  bool IsSingle (void) const;
85 
90  bool IsAggregate (void) const;
91 
96  Ptr<const Packet> GetPacket (void) const;
97 
103  const WifiMacHeader & GetHeader (std::size_t i) const;
104 
110  WifiMacHeader & GetHeader (std::size_t i);
111 
117  Ptr<const Packet> GetPayload (std::size_t i) const;
118 
124  Time GetTimeStamp (std::size_t i) const;
125 
130  Ptr<Packet> GetAmpduSubframe (std::size_t i) const;
131 
137  std::size_t GetAmpduSubframeSize (std::size_t i) const;
138 
143  Mac48Address GetAddr1 (void) const;
144 
149  Mac48Address GetAddr2 (void) const;
150 
155  Time GetDuration (void) const;
156 
161  void SetDuration (Time duration);
162 
170  std::set<uint8_t> GetTids (void) const;
171 
182 
190  void SetAckPolicyForTid (uint8_t tid, WifiMacHeader::QosAckPolicy policy);
191 
202  uint16_t GetMaxDistFromStartingSeq (uint16_t startingSeq) const;
203 
209  uint32_t GetSize (void) const;
210 
216  std::size_t GetNMpdus (void) const;
217 
223  std::vector<Ptr<WifiMacQueueItem>>::const_iterator begin (void) const;
224 
230  std::vector<Ptr<WifiMacQueueItem>>::iterator begin (void);
231 
237  std::vector<Ptr<WifiMacQueueItem>>::const_iterator end (void) const;
238 
244  std::vector<Ptr<WifiMacQueueItem>>::iterator end (void);
245 
250  void Print (std::ostream &os) const;
251 
252 private:
253  bool m_isSingle;
254  std::vector<Ptr<WifiMacQueueItem>> m_mpduList;
255  uint32_t m_size;
256 };
257 
265 std::ostream& operator<< (std::ostream& os, const WifiPsdu &psdu);
266 
267 
268 } //namespace ns3
269 
270 #endif /* WIFI_PSDU_H */
bool IsSingle(void) const
Return true if the PSDU is an S-MPDU.
Definition: wifi-psdu.cc:75
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
Ptr< Packet > GetAmpduSubframe(std::size_t i) const
Get a copy of the i-th A-MPDU subframe (includes subframe header, MPDU, and possibly padding) ...
Definition: wifi-psdu.cc:290
WifiPsdu(Ptr< const Packet > p, const WifiMacHeader &header)
Create a PSDU storing an MPDU.
Definition: wifi-psdu.cc:33
void SetDuration(Time duration)
Set the Duration/ID field on all the MPDUs.
Definition: wifi-psdu.cc:156
std::size_t GetAmpduSubframeSize(std::size_t i) const
Return the size of the i-th A-MPDU subframe.
Definition: wifi-psdu.cc:306
Time GetTimeStamp(std::size_t i) const
Get the timestamp of the i-th MPDU.
Definition: wifi-psdu.cc:284
void Print(std::ostream &os) const
Print the PSDU contents.
Definition: wifi-psdu.cc:349
std::vector< Ptr< WifiMacQueueItem > >::const_iterator end(void) const
Return a const iterator to past-the-last MPDU.
Definition: wifi-psdu.cc:337
bool m_isSingle
true for an S-MPDU
Definition: wifi-psdu.h:253
uint32_t GetSize(void) const
Return the size of the PSDU in bytes.
Definition: wifi-psdu.cc:260
Ptr< const Packet > GetPacket(void) const
Get the PSDU as a single packet.
Definition: wifi-psdu.cc:87
void SetAckPolicyForTid(uint8_t tid, WifiMacHeader::QosAckPolicy policy)
Set the QoS Ack Policy of the QoS Data frames included in the PSDU that have the given TID to the giv...
Definition: wifi-psdu.cc:214
Time GetDuration(void) const
Get the duration from the Duration/ID field, which is common to all the MPDUs.
Definition: wifi-psdu.cc:141
Mac48Address GetAddr2(void) const
Get the Transmitter Address (TA), which is common to all the MPDUs.
Definition: wifi-psdu.cc:126
const WifiMacHeader & GetHeader(std::size_t i) const
Get the header of the i-th MPDU.
Definition: wifi-psdu.cc:266
std::ostream & operator<<(std::ostream &os, const Angles &a)
print a struct Angles to output
Definition: angles.cc:42
WifiPsdu stores an MPDU, S-MPDU or A-MPDU, by keeping header(s) and payload(s) separate for each cons...
Definition: wifi-psdu.h:40
std::size_t GetNMpdus(void) const
Return the number of MPDUs constituting the PSDU.
Definition: wifi-psdu.cc:319
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::set< uint8_t > GetTids(void) const
Get the set of TIDs of the QoS Data frames included in the PSDU.
Definition: wifi-psdu.cc:166
an EUI-48 address
Definition: mac48-address.h:43
QosAckPolicy
Ack policy for QoS frames.
uint32_t m_size
the size of the PSDU in bytes
Definition: wifi-psdu.h:255
std::vector< Ptr< WifiMacQueueItem > >::const_iterator begin(void) const
Return a const iterator to the first MPDU.
Definition: wifi-psdu.cc:325
virtual ~WifiPsdu()
Definition: wifi-psdu.cc:70
Mac48Address GetAddr1(void) const
Get the Receiver Address (RA), which is common to all the MPDUs.
Definition: wifi-psdu.cc:111
std::vector< Ptr< WifiMacQueueItem > > m_mpduList
list of constituent MPDUs
Definition: wifi-psdu.h:254
Ptr< const Packet > GetPayload(std::size_t i) const
Get the payload of the i-th MPDU.
Definition: wifi-psdu.cc:278
A template-based reference counting class.
WifiMacHeader::QosAckPolicy GetAckPolicyForTid(uint8_t tid) const
Get the QoS Ack Policy of the QoS Data frames included in the PSDU that have the given TID...
Definition: wifi-psdu.cc:180
Implements the IEEE 802.11 MAC header.
uint16_t GetMaxDistFromStartingSeq(uint16_t startingSeq) const
Get the maximum distance between the sequence number of any QoS Data frame included in this PSDU that...
Definition: wifi-psdu.cc:227
bool IsAggregate(void) const
Return true if the PSDU is an S-MPDU or A-MPDU.
Definition: wifi-psdu.cc:81