32 {
"BPSK/DSSS", 1000, -82, },
33 {
"QPSK/DSSS", 2000, -82, },
34 {
"CCK55", 5500, -82, },
35 {
"CCK11", 11000, -82, },
38 {
"BPSK 1/2", 6000, -81, },
39 {
"BPSK 3/4", 9000, -81, },
40 {
"QPSK 1/2", 12000, -79, },
41 {
"QPSK 3/4", 18000, -77, },
42 {
"16QAM 1/2", 24000, -74, },
43 {
"16QAM 3/4", 36000, -70, },
44 {
"64QAM 2/3", 48000, -66, },
45 {
"64QAM 3/4", 54000, -65, },
49 prefix_ std::vector<senf::emu::WLANModulationParameterRegistry::LegacyModulationInfo>
52 return std::vector<LegacyModulationInfo>(legacyInfos11b, legacyInfos11b +
sizeof(legacyInfos11b) /
sizeof(
LegacyModulationInfo));
55 prefix_ std::vector<senf::emu::WLANModulationParameterRegistry::LegacyModulationInfo>
58 return std::vector<LegacyModulationInfo>(legacyInfosOFDM, legacyInfosOFDM +
sizeof(legacyInfosOFDM) /
sizeof(
LegacyModulationInfo));
61 prefix_ senf::emu::WLANModulationParameterRegistry::WLANModulationParameterRegistry()
67 for (
unsigned i=0; i<4; ++i) {
68 if (info.rate[i] == 0)
74 registerModulation( p);
81 for (
unsigned i=0; i<8; ++i) {
82 if (info.rate[i] == 0)
87 registerModulation( p);
93 registerModulation( p);
99 registerModulation( p);
104 parameterIdAuto_ = registerModulation( p);
107 parameterIdUnknown_ = registerModulation( p);
114 modulations_.insert(std::make_pair(
id, p));
123 Modulations::const_iterator it (modulations_.find(
id));
124 if (it == modulations_.end())
137 return parameterIdUnknown_;
149 return parameterIdUnknown_;
161 return parameterIdUnknown_;
168 Modulations::const_iterator it (modulations_.find(
id));
169 if (it == modulations_.end() or (
id == parameterIdUnknown_))
170 return std::set<senf::emu::ModulationParameter::id_t> ();
172 std::set<ModulationParameter::id_t> res;
173 for (
auto const & m : modulations_) {
174 if ((m.second.type == it->second.type) and (m.second.rate > 0) and (m.second.bandwidth == it->second.bandwidth) and (m.second.streams <= it->second.streams)) {
177 res.emplace(m.first);
180 if (m.second.shortGI == it->second.shortGI)
181 res.emplace(m.first);
184 if (m.second.shortGI)
185 res.emplace(m.first);
188 if (!m.second.shortGI)
189 res.emplace(m.first);
200 Modulations::const_iterator it (modulations_.find(
id));
201 if (it == modulations_.end())
202 return parameterIdUnknown_;
204 for (
auto const & m : modulations_) {
205 if ((m.second.type == it->second.type) and (m.second.rate > 0) and (m.second.bandwidth == it->second.bandwidth)
206 and (m.second.streams == it->second.streams) and (m.second.index == it->second.index)) {
207 if (m.second.shortGI)
212 return parameterIdUnknown_;
218 Modulations::const_iterator it (modulations_.find(
id));
219 if (it == modulations_.end())
220 return parameterIdUnknown_;
222 for (
auto const & m : modulations_) {
223 if ((m.second.type == it->second.type) and (m.second.rate > 0) and (m.second.bandwidth == it->second.bandwidth)
224 and (m.second.streams == it->second.streams) and (m.second.index == it->second.index)) {
225 if (!m.second.shortGI)
230 return parameterIdUnknown_;
236 Modulations::const_iterator it (modulations_.find(
id));
237 if (it == modulations_.end() or (
id == parameterIdUnknown_))
238 return parameterIdUnknown_;
240 if (it->second.index < diff)
241 diff = it->second.index;
244 for (
auto const & m : modulations_) {
245 if ((m.second.type == it->second.type) and (m.second.rate > 0) and (m.second.bandwidth == it->second.bandwidth) and (m.second.shortGI == it->second.shortGI)
246 and (m.second.streams == it->second.streams) and (m.second.index == it->second.index - diff)) {
260 return parameterIdAuto_;
266 return parameterIdUnknown_;
269 prefix_ senf::emu::WLANModulationParameter::WLANModulationParameter(std::string
const & _label,
short _minRssi,
270 unsigned _rate,
unsigned _bandwidth, Type _type,
unsigned _streams,
unsigned _index,
bool _shortGI)
272 type(_type), index(_index), streams(_streams), shortGI(_shortGI)
275 prefix_ boost::uint16_t senf::emu::WLANModulationParameter::v_modulationId()
278 return modulationId(
type, rate, bandwidth, index, streams, shortGI);
282 unsigned _bandwidth,
unsigned _index,
unsigned _streams,
bool _shortGI)
305 prefix_ void senf::emu::WLANModulationParameter::v_dump(std::ostream & os)
308 static const char * types[] = {
"Legacy",
"MCS",
"Automatic",
"Unknown" };
309 os <<
" type: " << (
type <= Unknown ? types[
type] :
"?") << std::endl
310 <<
"MCS Index: " << ((type==HT or type == VHT) ? senf::str(index) :
"-") << std::endl
311 <<
"# streams: " << streams << std::endl
312 <<
" short GI: " << (shortGI ?
"true" :
"false") << std::endl;
315 prefix_ void senf::emu::WLANModulationParameter::v_dumpTableHeader(std::ostream & os)
318 boost::format fmt (
"%5d %7d %8s");
319 os << fmt %
"index" %
"streams" %
"short GI";
322 prefix_ void senf::emu::WLANModulationParameter::v_dumpTableRow(std::ostream & os)
325 boost::format fmt (
"%5d %7d %8s");
326 os << fmt % ((
type==HT or
type == VHT) ? senf::str(index) :
" - ") % streams % (shortGI ?
"true" :
"false");
338 namespace fty = console::factory;
341 .arg(
"type",
"'mcs' or 'legacy'")
342 .arg(
"value",
"modulation value; mcs index or legacy rate")
343 .doc(
"set modulation") );
346 .arg(
"type",
"must be 'auto'")
347 .doc(
"set modulation to auto") );
355 index, streams, bandwidth(),
false));
367 value, bandwidth(),
false));
394 prefix_ boost::uint8_t senf::emu::WLANInterface::v_linkTypeId()
404 for (
auto const & m : modulationParameterIds()) {
407 maxNSS =
std::max(maxNSS,
id.streams);
unsigned registerModulation(ModulationParameter ¶meter)
#define SENF_MEMBINDFNP(ret, cls, fn, args)
static boost::uint16_t modulationId(Type _type, unsigned _rate, unsigned _bandwidth, unsigned _index, unsigned _streams, bool _shortGI)
ModulationParameter::id_t parameterIdByMCS_HT(unsigned htMcsIndex, unsigned bandwidth, bool shortGI) const
ModulationParameter::id_t parameterIdAuto() const
ModulationParameter::id_t parameterIdByLegacyRate(unsigned rate) const
unsigned bandwidth
Bandwidth in KHz.
ModulationParameter::id_t parameterIdLower(ModulationParameter::id_t id, unsigned diff) const
boost::uint8_t linkTypeId() const
static constexpr unsigned NUM_HT_INDEX
Wireless modulation parameter.
static constexpr unsigned MAX_INDEX
std::set< ModulationParameter::id_t > parameterIdsByType(ModulationParameter::id_t id, GIMatch giMatch=Any) const
static std::vector< LegacyModulationInfo > getLegacyModulationInfosOFDM()
unsigned rate
Bitrate in kbit/s.
ModulationParameter::id_t parameterIdByMCS_VHT(unsigned vhtMcsIndex, unsigned streams, unsigned bandwidth, bool shortGI) const
console::ScopedDirectory & consoleDir()
static std::vector< LegacyModulationInfo > getLegacyModulationInfos11b()
ModulationParameter::id_t parameterIdUnknown() const
static std::uint8_t toHTIndex(std::uint8_t index, std::uint8_t streams)
WLANInterface public header.
WLANModulationParameter const & findModulationById(ModulationParameter::id_t id) const
static std::vector< Info > getInfos()
static constexpr unsigned NUM_VHT_INDEX
ModulationParameter::id_t parameterIdAsSGI(ModulationParameter::id_t id) const
static ModulationParameterRegistry & instance()
static WLANModulationParameterRegistry & instance()
ModulationParameter::id_t parameterIdAsLGI(ModulationParameter::id_t id) const
static std::uint8_t toBandwidthIndex(unsigned bandwidth, bool shortGI=false)
ModulationParameter::id_t modulation() const
Get current modulation parameter configuration id.
static unsigned fromBandwidthIndex(std::uint8_t bandwidthIndex)