A Discrete-Event Network Simulator
API
dsss-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) 2016 Sébastien Deronne
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 "dsss-parameter-set.h"
22 #include "ns3/assert.h"
23 #include "ns3/log.h"
24 #include <cmath>
25 
26 namespace ns3 {
27 
28 NS_LOG_COMPONENT_DEFINE ("DsssParameterSet");
29 
31  : m_currentChannel (0),
32  m_dsssSupported (0)
33 {
34 }
35 
38 {
39  return IE_DS_PARAMETER_SET;
40 }
41 
42 void
43 DsssParameterSet::SetDsssSupported (uint8_t dsssSupported)
44 {
45  m_dsssSupported = dsssSupported;
46 }
47 
48 void
49 DsssParameterSet::SetCurrentChannel (uint8_t currentChannel)
50 {
51  m_currentChannel = currentChannel;
52 }
53 
54 uint8_t
56 {
57  return m_currentChannel;
58 }
59 
60 uint8_t
62 {
64  return 1;
65 }
66 
69 {
70  if (m_dsssSupported < 1)
71  {
72  return i;
73  }
75 }
76 
77 uint16_t
79 {
80  if (m_dsssSupported < 1)
81  {
82  return 0;
83  }
85 }
86 
87 void
89 {
90  if (m_dsssSupported == 1)
91  {
92  start.WriteU8 (m_currentChannel);
93  }
94 }
95 
96 uint8_t
98 {
100  m_currentChannel = i.ReadU8 ();
101  return length;
102 }
103 
105 
106 std::ostream & operator << (std::ostream &os, const DsssParameterSet &DsssParameterSet)
107 {
108  return os;
109 }
110 
111 std::istream &operator >> (std::istream &is, DsssParameterSet &DsssParameterSet)
112 {
113  return is;
114 }
115 
116 } //namespace ns3
std::istream & operator>>(std::istream &is, Angles &a)
initialize a struct Angles from input
Definition: angles.cc:48
uint8_t GetInformationFieldSize() const
Length of serialized information (i.e., the length of the body of the IE, not including the Element I...
#define ATTRIBUTE_HELPER_CPP(type)
Define the attribute value, accessor and checkers for class type.
def start()
Definition: core.py:1482
#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 NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:201
uint8_t GetCurrentChannel(void) const
uint16_t GetSerializedSize() const
Return the serialized size of this DSSS Parameter Set.
uint16_t GetSerializedSize() const
Get the size of the serialized IE including Element ID and length fields.
iterator in a Buffer instance
Definition: buffer.h:98
WifiInformationElementId ElementId() const
Own unique Element ID.
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) ...
void SerializeInformationField(Buffer::Iterator start) const
Serialize information (i.e., the body of the IE, not including the Element ID and length octets) ...
void SetCurrentChannel(uint8_t currentChannel)
Set the Current Channel field in the DsssParameterSet information element.
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.
#define IE_DS_PARAMETER_SET
void SetDsssSupported(uint8_t DsssSupported)
The DSSS Parameter SetThis class knows how to serialise and deserialise the DSSS Parameter Set...
void WriteU8(uint8_t data)
Definition: buffer.h:868
uint8_t ReadU8(void)
Definition: buffer.h:1020
uint8_t WifiInformationElementId
This type is used to represent an Information Element ID.
Buffer::Iterator Serialize(Buffer::Iterator i) const
Serialize entire IE including Element ID and length fields.
Buffer::Iterator Serialize(Buffer::Iterator start) const
This information element is a bit special in that it is only included if the STA does support DSSS...