A Discrete-Event Network Simulator
API
cf-parameter-set.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2015
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: Sébastien Deronne <sebastien.deronne@gmail.com>
19  */
20 
21 #include "cf-parameter-set.h"
22 
23 namespace ns3 {
24 
26  : m_CFPCount (0),
27  m_CFPPeriod (0),
28  m_CFPMaxDuration (0),
29  m_CFPDurRemaining (0),
30  m_pcfSupported (0)
31 {
32 }
33 
36 {
37  return IE_CF_PARAMETER_SET;
38 }
39 
40 void
41 CfParameterSet::SetPcfSupported (uint8_t pcfsupported)
42 {
43  m_pcfSupported = pcfsupported;
44 }
45 
46 uint8_t
48 {
49  //we should not be here if pcf is not supported
51  return 6;
52 }
53 
56 {
57  if (m_pcfSupported < 1)
58  {
59  return i;
60  }
62 }
63 
64 uint16_t
66 {
67  if (m_pcfSupported < 1)
68  {
69  return 0;
70  }
72 }
73 
74 void
76 {
77  if (m_pcfSupported == 1)
78  {
79  start.WriteU8 (m_CFPCount);
80  start.WriteU8 (m_CFPPeriod);
81  start.WriteHtolsbU16 (m_CFPMaxDuration / 1024);
82  start.WriteHtolsbU16 (m_CFPDurRemaining / 1024);
83  }
84 }
85 
86 uint8_t
88  uint8_t length)
89 {
90  NS_ASSERT (length == 6);
92  m_CFPCount = i.ReadU8 ();
93  m_CFPPeriod = i.ReadU8 ();
95  m_CFPMaxDuration *= 1024;
97  m_CFPDurRemaining *= 1024;
98  return length;
99 }
100 
101 uint8_t
103 {
104  return m_CFPCount;
105 }
106 
107 uint8_t
109 {
110  return m_CFPPeriod;
111 }
112 
113 uint64_t
115 {
116  return m_CFPMaxDuration;
117 }
118 
119 uint64_t
121 {
122  return m_CFPDurRemaining;
123 }
124 
125 void
127 {
128  m_CFPCount = count;
129 }
130 
131 void
133 {
134  m_CFPPeriod = period;
135 }
136 
137 void
139 {
140  m_CFPMaxDuration = maxDuration;
141 }
142 
143 void
145 {
146  m_CFPDurRemaining = durRemaining;
147 }
148 
157 std::ostream &
158 operator << (std::ostream &os, const CfParameterSet &cfParameterSet)
159 {
160  os << (uint16_t)cfParameterSet.GetCFPCount ()
161  << "|" << (uint16_t)cfParameterSet.GetCFPPeriod ()
162  << "|" << cfParameterSet.GetCFPMaxDurationUs ()
163  << "|" << cfParameterSet.GetCFPDurRemainingUs ();
164 
165  return os;
166 }
167 
168 } //namespace ns3
Buffer::Iterator Serialize(Buffer::Iterator i) const
Serialize entire IE including Element ID and length fields.
def start()
Definition: core.py:1844
uint16_t GetSerializedSize() const
Return the serialized size of this EDCA Parameter Set.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
Definition: assert.h:67
void SetCFPDurRemainingUs(uint64_t cfpdurremaining)
Set the CFP MaxDuration in microseconds.
#define IE_CF_PARAMETER_SET
uint8_t GetCFPCount(void) const
Return the CFP Count in DTIM frames unit.
WifiInformationElementId ElementId() const
Element ID function.
void SetCFPCount(uint8_t cfpcount)
Set the CFP Count in DTIM frames unit.
iterator in a Buffer instance
Definition: buffer.h:98
uint64_t m_CFPDurRemaining
CFP DurRemaining.
uint64_t GetCFPMaxDurationUs(void) const
Return the CFP MaxDuration in microseconds.
uint8_t m_CFPPeriod
CFP Period.
uint8_t GetCFPPeriod(void) const
Return the CFP Period in DTIM frames unit.
The CF Parameter SetThis class knows how to serialise and deserialise the CF Parameter Set...
void SetPcfSupported(uint8_t pcfSupported)
Set PCF supported function.
std::ostream & operator<<(std::ostream &os, const Angles &a)
print a struct Angles to output
Definition: angles.cc:42
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint8_t m_pcfSupported
This is used to decide if this element should be added to the frame or not.
void SetCFPPeriod(uint8_t cfpperiod)
Set the CFP Period in DTIM frames unit.
void SetCFPMaxDurationUs(uint64_t cfpmaxduration)
Set the CFP MaxDuration in microseconds.
uint16_t GetSerializedSize() const
Get the size of the serialized IE including Element ID and length fields.
uint64_t m_CFPMaxDuration
CFP MaxDuration.
uint64_t GetCFPDurRemainingUs(void) const
Return the CFP DurRemaining in microseconds.
void SerializeInformationField(Buffer::Iterator start) const
Serialize information field function.
uint8_t ReadU8(void)
Definition: buffer.h:1021
uint16_t ReadLsbtohU16(void)
Definition: buffer.cc:1065
uint8_t DeserializeInformationField(Buffer::Iterator start, uint8_t length)
Deserialize information field function.
uint8_t WifiInformationElementId
This type is used to represent an Information Element ID.
uint8_t m_CFPCount
CFP Count.
Buffer::Iterator Serialize(Buffer::Iterator start) const
This information element is a bit special in that it is only included if the STA is a QoS STA...
uint8_t GetInformationFieldSize() const
Get information field size function.