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 
149 std::ostream &
150 operator << (std::ostream &os, const CfParameterSet &cfParameterSet)
151 {
152  os << (uint16_t)cfParameterSet.GetCFPCount ()
153  << "|" << (uint16_t)cfParameterSet.GetCFPPeriod ()
154  << "|" << cfParameterSet.GetCFPMaxDurationUs ()
155  << "|" << cfParameterSet.GetCFPDurRemainingUs ();
156 
157  return os;
158 }
159 
160 } //namespace ns3
Buffer::Iterator Serialize(Buffer::Iterator i) const
Serialize entire IE including Element ID and length fields.
def start()
Definition: core.py:1855
uint16_t GetSerializedSize() const
#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
#define IE_CF_PARAMETER_SET
uint8_t GetCFPCount(void) const
Return the CFP Count in DTIM frames unit.
WifiInformationElementId ElementId() const
void SetCFPDurRemainingUs(uint64_t durRemaining)
Set the remaining CFP duration in microseconds.
iterator in a Buffer instance
Definition: buffer.h:98
void SetCFPPeriod(uint8_t period)
Set the CFP Period in DTIM frames unit.
uint64_t m_CFPDurRemaining
CFP remaining duration in microseconds.
uint64_t GetCFPMaxDurationUs(void) const
Return the maximum CFP duration 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.
void SetCFPMaxDurationUs(uint64_t maxDuration)
Set the maximum CFP duration in microseconds.
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.
uint16_t GetSerializedSize() const
Get the size of the serialized IE including Element ID and length fields.
uint64_t m_CFPMaxDuration
CFP maximum duration in microseconds.
uint64_t GetCFPDurRemainingUs(void) const
Return the remaining CFP duration in microseconds.
void SerializeInformationField(Buffer::Iterator start) const
Serialize information (i.e., the body of the IE, not including the Element ID and length octets) ...
void SetCFPCount(uint8_t count)
Set the CFP Count in DTIM frames unit.
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 (i.e., the body of the IE, not including the Element ID and length octets) ...
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
uint8_t GetInformationFieldSize() const
Length of serialized information (i.e., the length of the body of the IE, not including the Element I...