wifi: Add an SnrTag for responses to MU frames

This commit is contained in:
Stefano Avallone
2021-04-27 23:39:35 +02:00
parent f929fa6b38
commit b04bb017d9
3 changed files with 202 additions and 0 deletions

View File

@@ -0,0 +1,113 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2021 Universita' degli Studi di Napoli Federico II
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Stefano Avallone <stavallo@unina.it>
*/
#include "mu-snr-tag.h"
namespace ns3 {
NS_OBJECT_ENSURE_REGISTERED (MuSnrTag);
TypeId
MuSnrTag::GetTypeId (void)
{
static TypeId tid = TypeId ("ns3::MuSnrTag")
.SetParent<Tag> ()
.SetGroupName ("Wifi")
.AddConstructor<MuSnrTag> ()
;
return tid;
}
TypeId
MuSnrTag::GetInstanceTypeId (void) const
{
return GetTypeId ();
}
MuSnrTag::MuSnrTag ()
{
}
void
MuSnrTag::Reset (void)
{
m_snrMap.clear ();
}
void
MuSnrTag::Set (uint16_t staId, double snr)
{
m_snrMap[staId] = snr;
}
bool
MuSnrTag::IsPresent (uint16_t staId) const
{
return (m_snrMap.find (staId) != m_snrMap.end ());
}
double
MuSnrTag::Get (uint16_t staId) const
{
NS_ASSERT (IsPresent (staId));
return m_snrMap.at (staId);
}
uint32_t
MuSnrTag::GetSerializedSize (void) const
{
return (sizeof (uint16_t) + sizeof (double)) * m_snrMap.size () + 1;
}
void
MuSnrTag::Serialize (TagBuffer i) const
{
i.WriteU8 (m_snrMap.size ());
for (const auto& staIdSnrPair : m_snrMap)
{
i.WriteU16 (staIdSnrPair.first);
i.WriteDouble (staIdSnrPair.second);
}
}
void
MuSnrTag::Deserialize (TagBuffer i)
{
uint8_t n = i.ReadU8 ();
for (uint8_t j = 0; j < n; j++)
{
uint16_t staId = i.ReadU16 ();
double snr = i.ReadDouble ();
m_snrMap.insert ({staId, snr});
}
}
void
MuSnrTag::Print (std::ostream &os) const
{
for (const auto& staIdSnrPair : m_snrMap)
{
os << "{STA-ID=" << staIdSnrPair.first << " Snr=" << staIdSnrPair.second << "} ";
}
os << std::endl;
}
}

View File

@@ -0,0 +1,87 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2021 Universita' degli Studi di Napoli Federico II
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Stefano Avallone <stavallo@unina.it>
*/
#ifndef MU_SNR_TAG_H
#define MU_SNR_TAG_H
#include "ns3/tag.h"
#include <map>
namespace ns3 {
/**
* \ingroup wifi
*
* A tag to be attached to a response to a multi-user UL frame, that carries the SNR
* values with which the individual frames have been received.
*/
class MuSnrTag : public Tag
{
public:
/**
* \brief Get the type ID.
* \return the object TypeId
*/
static TypeId GetTypeId (void);
TypeId GetInstanceTypeId (void) const override;
/**
* Create an empty MuSnrTag
*/
MuSnrTag ();
uint32_t GetSerializedSize (void) const override;
void Serialize (TagBuffer i) const override;
void Deserialize (TagBuffer i) override;
void Print (std::ostream &os) const override;
/**
* Reset the content of the tag.
*/
void Reset (void);
/**
* Set the SNR for the given sender to the given value.
*
* \param staId the STA-ID of the given sender
* \param snr the value of the SNR to set in linear scale
*/
void Set (uint16_t staId, double snr);
/**
* Return true if the SNR value for the given STA-ID is present
*
* \return true if the SNR value for the given STA-ID is present
*/
bool IsPresent (uint16_t staId) const;
/**
* Return the SNR value for the given sender.
*
* \param staId the STA-ID of the given sender
* \return the SNR value in linear scale
*/
double Get (uint16_t staId) const;
private:
std::map<uint16_t, double> m_snrMap; //!< Map containing (STA-ID, SNR) pairs
};
}
#endif /* MU_SNR_TAG_H */

View File

@@ -79,6 +79,7 @@ def build(bld):
'model/block-ack-window.cc',
'model/block-ack-type.cc',
'model/snr-tag.cc',
'model/he/mu-snr-tag.cc',
'model/ht/ht-capabilities.cc',
'model/wifi-tx-vector.cc',
'model/rate-control/parf-wifi-manager.cc',
@@ -240,6 +241,7 @@ def build(bld):
'model/block-ack-manager.h',
'model/block-ack-window.h',
'model/snr-tag.h',
'model/he/mu-snr-tag.h',
'model/ht/ht-capabilities.h',
'model/rate-control/parf-wifi-manager.h',
'model/rate-control/aparf-wifi-manager.h',