22 #include "ns3/simulator.h"
23 #include "ns3/assert.h"
26 #include "ns3/boolean.h"
27 #include "ns3/double.h"
28 #include "ns3/uinteger.h"
29 #include "ns3/wifi-phy.h"
30 #include "ns3/trace-source-accessor.h"
55 virtual void Print (std::ostream &os)
const;
64 : m_dataTxVector (dataTxVector)
76 static TypeId tid =
TypeId (
"ns3::HighLatencyDataTxVectorTag")
78 .AddConstructor<HighLatencyDataTxVectorTag> ()
120 virtual void Print (std::ostream &os)
const;
129 : m_rtsTxVector (rtsTxVector)
141 static TypeId tid =
TypeId (
"ns3::HighLatencyRtsTxVectorTag")
143 .AddConstructor<HighLatencyRtsTxVectorTag> ()
185 virtual void Print (std::ostream &os)
const;
194 : m_ctsToSelfTxVector (ctsToSelfTxVector)
206 static TypeId tid =
TypeId (
"ns3::HighLatencyCtsToSelfTxVectorTag")
208 .AddConstructor<HighLatencyCtsToSelfTxVectorTag> ()
247 static TypeId tid =
TypeId (
"ns3::WifiRemoteStationManager")
249 .AddAttribute (
"IsLowLatency",
"If true, we attempt to modelize a so-called low-latency device: a device"
250 " where decisions about tx parameters can be made on a per-packet basis and feedback about the"
251 " transmission of each packet is obtained before sending the next. Otherwise, we modelize a "
252 " high-latency device, that is a device where we cannot update our decision about tx parameters"
253 " after every packet transmission.",
256 MakeBooleanChecker ())
257 .AddAttribute (
"MaxSsrc",
"The maximum number of retransmission attempts for an RTS. This value"
258 " will not have any effect on some rate control algorithms.",
261 MakeUintegerChecker<uint32_t> ())
262 .AddAttribute (
"MaxSlrc",
"The maximum number of retransmission attempts for a DATA packet. This value"
263 " will not have any effect on some rate control algorithms.",
266 MakeUintegerChecker<uint32_t> ())
267 .AddAttribute (
"RtsCtsThreshold",
"If the size of the data packet + LLC header + MAC header + FCS trailer is bigger than "
268 "this value, we use an RTS/CTS handshake before sending the data, as per IEEE Std. 802.11-2007, Section 9.2.6. "
269 "This value will not have any effect on some rate control algorithms.",
272 MakeUintegerChecker<uint32_t> ())
273 .AddAttribute (
"FragmentationThreshold",
"If the size of the data packet + LLC header + MAC header + FCS trailer is bigger"
274 "than this value, we fragment it such that the size of the fragments are equal or smaller "
275 "than this value, as per IEEE Std. 802.11-2007, Section 9.4. "
276 "This value will not have any effect on some rate control algorithms.",
280 MakeUintegerChecker<uint32_t> ())
281 .AddAttribute (
"NonUnicastMode",
"Wifi mode used for non-unicast transmissions.",
284 MakeWifiModeChecker ())
285 .AddAttribute (
"DefaultTxPowerLevel",
"Default power level to be used for transmissions. "
286 "This is the power level that is used by all those WifiManagers that do not"
287 "implement TX power control.",
290 MakeUintegerChecker<uint8_t> ())
291 .AddTraceSource (
"MacTxRtsFailed",
292 "The transmission of a RTS by the MAC layer has failed",
294 .AddTraceSource (
"MacTxDataFailed",
295 "The transmission of a data packet by the MAC layer has failed",
297 .AddTraceSource (
"MacTxFinalRtsFailed",
298 "The transmission of a RTS has exceeded the maximum number of attempts",
300 .AddTraceSource (
"MacTxFinalDataFailed",
301 "The transmission of a data packet has exceeded the maximum number of attempts",
317 for (StationStates::const_iterator i =
m_states.begin (); i !=
m_states.end (); i++)
405 state->m_operationalRateSet.clear ();
406 state->m_operationalMcsSet.clear ();
415 for (
WifiModeListIterator i = state->m_operationalRateSet.begin (); i != state->m_operationalRateSet.end (); i++)
423 state->m_operationalRateSet.push_back (mode);
451 for (
WifiMcsListIterator i = state->m_operationalMcsSet.begin (); i != state->m_operationalMcsSet.end (); i++)
459 state->m_operationalMcsSet.push_back (mcs);
528 ConstCast<Packet> (packet)->RemovePacketTag (datatag);
529 ConstCast<Packet> (packet)->RemovePacketTag (rtstag);
530 ConstCast<Packet> (packet)->RemovePacketTag (ctstoselftag);
558 found = ConstCast<Packet> (packet)->PeekPacketTag (datatag);
576 found = ConstCast<Packet> (packet)->PeekPacketTag (ctstoselftag);
601 found = ConstCast<Packet> (packet)->PeekPacketTag (rtstag);
630 double ctsSnr,
WifiMode ctsMode,
double rtsSnr)
634 station->m_state->m_info.NotifyTxSuccess (station->m_ssrc);
640 double ackSnr,
WifiMode ackMode,
double dataSnr)
644 station->m_state->m_info.NotifyTxSuccess (station->m_slrc);
653 station->m_state->m_info.NotifyTxFailed ();
663 station->m_state->m_info.NotifyTxFailed ();
724 bool normally = station->m_ssrc <
GetMaxSsrc ();
733 bool normally = station->m_slrc <
GetMaxSlrc ();
757 NS_LOG_WARN (
"Fragmentation threshold should be larger than 256. Setting to 256.");
766 if (threshold % 2 != 0)
768 NS_LOG_WARN (
"Fragmentation threshold should be an even number. Setting to " << threshold - 1);
804 if (fragmentNumber >= nFragment)
809 if (fragmentNumber == nFragment - 1)
812 return lastFragmentSize;
827 return fragmentOffset;
834 bool isLast = fragmentNumber == (
GetNFragments (header, packet) - 1);
861 if ((!found || i->GetPhyRate () > mode.
GetPhyRate ())
980 <<
". Check standard and selected rates match.");
1128 for (StationStates::const_iterator i =
m_states.begin (); i !=
m_states.end (); i++)
1130 if ((*i)->m_address == address)
1160 return Lookup (address, tid);
1167 if ((*i)->m_tid == tid
1168 && (*i)->m_state->m_address == address)
1177 station->
m_tid = tid;
1383 : m_memoryTime (Seconds (1.0)),
1384 m_lastUpdate (Seconds (0.0)),
1402 m_failAvg = (double)retryCounter / (1 + (
double) retryCounter) * (1.0 - coefficient) + coefficient *
m_failAvg;
virtual void Deserialize(TagBuffer i)
virtual uint8_t DoGetAckTxNss(Mac48Address address, WifiMode ackMode)
uint32_t GetNSupported(const WifiRemoteStation *station) const
WifiMcsList m_bssBasicMcsSet
virtual uint32_t GetNumberOfTransmitAntennas(void) const =0
void Write(const uint8_t *buffer, uint32_t size)
virtual uint8_t DoGetAckTxNess(Mac48Address address, WifiMode ackMode)
uint32_t GetNFragments(const WifiMacHeader *header, Ptr< const Packet > packet)
void SetDefaultTxPowerLevel(uint8_t txPower)
void SetShortGuardInterval(bool guardinterval)
virtual void Print(std::ostream &os) const
WifiTxVector GetRtsTxVector(void) const
bool GetGreenfieldSupported(Mac48Address address) const
bool m_shortGuardInterval
uint32_t m_rtsCtsThreshold
bool NeedDataRetransmission(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet)
uint8_t GetDefaultMcs(void) const
void RecordWaitAssocTxOk(Mac48Address address)
virtual void DoReportRtsFailed(WifiRemoteStation *station)=0
WifiMode m_nonUnicastMode
void ReportDataFailed(Mac48Address address, const WifiMacHeader *header)
virtual uint32_t GetNModes(void) const =0
virtual uint8_t DoGetBlockAckTxNss(Mac48Address address, WifiMode blockAckMode)
void AddPacketTag(const Tag &tag) const
uint32_t GetMaxSsrc(void) const
enum WifiModulationClass GetModulationClass() const
virtual uint8_t GetNMcs(void) const =0
virtual bool DoGetAckTxGuardInterval(Mac48Address address, WifiMode ackMode)
WifiTxVector GetDataTxVector(void) const
WifiTxVector GetCtsTxVector(Mac48Address address, WifiMode rtsMode)
virtual uint8_t DoGetBlockAckTxNess(Mac48Address address, WifiMode blockAckMode)
enum ns3::WifiRemoteStationState::@90 m_state
#define NS_ASSERT(condition)
WifiMode GetNonUnicastMode(void) const
static const uint16_t WIFI_MAC_FCS_LENGTH
uint32_t m_fragmentationThreshold
WifiTxVector m_rtsTxVector
The Ht Capabilities Information ElementThis class knows how to serialise and deserialise the Ht Capab...
uint8_t m_defaultTxPowerLevel
uint32_t GetSize(void) const
HighLatencyRtsTxVectorTag()
uint8_t GetMcsSupported(const WifiRemoteStation *station, uint32_t i) const
bool GetGreenfield(const WifiRemoteStation *station) const
HighLatencyDataTxVectorTag()
virtual uint8_t GetMcs(uint8_t mcs) const =0
Time m_memoryTime
averaging coefficient depends on the memory time
bool IsLastFragment(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet, uint32_t fragmentNumber)
WifiMcsList::const_iterator WifiMcsListIterator
TracedCallback< Mac48Address > m_macTxFinalRtsFailed
bool IsBrandNew(Mac48Address address) const
virtual void Serialize(TagBuffer i) const
WifiTxVector m_ctsToSelfTxVector
virtual void SetupPhy(Ptr< WifiPhy > phy)
virtual uint32_t WifiModeToMcs(WifiMode mode)=0
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
bool IsMandatory(void) const
virtual bool DoNeedRts(WifiRemoteStation *station, Ptr< const Packet > packet, bool normally)
uint32_t GetNumberOfReceiveAntennas(const WifiRemoteStation *station) const
Tid independent remote station statistics.
WifiMode GetSupported(const WifiRemoteStation *station, uint32_t i) const
#define NS_FATAL_ERROR(msg)
fatal error handling
WifiRemoteStationState * LookupState(Mac48Address address) const
WifiRemoteStationState * m_state
double m_failAvg
moving percentage of failed frames
WifiTxVector GetCtsToSelfTxVector(const WifiMacHeader *header, Ptr< const Packet > packet)
void RecordDisassociated(Mac48Address address)
TracedCallback< Mac48Address > m_macTxFinalDataFailed
WifiRemoteStationManager()
bool GetStbc(const WifiRemoteStation *station) const
virtual bool DoNeedDataRetransmission(WifiRemoteStation *station, Ptr< const Packet > packet, bool normally)
static TypeId GetTypeId(void)
virtual bool DoGetAckTxStbc(Mac48Address address, WifiMode ackMode)
virtual bool GetStbc(void) const =0
WifiTxVector GetCtsToSelfTxVector(void) const
virtual WifiTxVector DoGetDataTxVector(WifiRemoteStation *station, uint32_t size)=0
Time m_lastUpdate
when last update has occured
void ReportFinalDataFailed(Mac48Address address, const WifiMacHeader *header)
void SetRtsCtsThreshold(uint32_t threshold)
virtual void DoReportRtsOk(WifiRemoteStation *station, double ctsSnr, WifiMode ctsMode, double rtsSnr)=0
WifiRemoteStation * Lookup(Mac48Address address, uint8_t tid) const
int64_t GetMicroSeconds(void) const
double CalculateAveragingCoefficient()
Calculate averaging coefficient for frame error rate. Depends on time of the last update...
virtual bool DoGetCtsTxGuardInterval(Mac48Address address, WifiMode ctsMode)
uint8_t GetGreenfield(void) const
WifiTxVector m_dataTxVector
HighLatencyCtsToSelfTxVectorTag()
virtual void DoReportRxOk(WifiRemoteStation *station, double rxSnr, WifiMode txMode)=0
void ReportRtsFailed(Mac48Address address, const WifiMacHeader *header)
virtual bool DoNeedRtsRetransmission(WifiRemoteStation *station, Ptr< const Packet > packet, bool normally)
virtual TypeId GetInstanceTypeId(void) const
Hold an unsigned integer type.
virtual void DoReportDataFailed(WifiRemoteStation *station)=0
void RecordGotAssocTxFailed(Mac48Address address)
NS_OBJECT_ENSURE_REGISTERED(AntennaModel)
WifiMode GetBasicMode(uint32_t i) const
uint32_t GetFragmentationThreshold(void) const
void AddStationHtCapabilities(Mac48Address from, HtCapabilities htcapabilities)
WifiRemoteStationInfo GetInfo(Mac48Address address)
void SetMaxSsrc(uint32_t maxSsrc)
uint32_t GetRtsCtsThreshold(void) const
uint8_t GetShortGuardInterval20(void) const
void NotifyTxSuccess(uint32_t retryCounter)
Updates average frame error rate when data or RTS was transmitted successfully.
uint32_t DoGetFragmentationThreshold(void) const
virtual bool GetGuardInterval(void) const =0
WifiMcsList m_operationalMcsSet
hold a list of per-remote-station state.
virtual void Print(std::ostream &os) const
WifiMode GetControlAnswerMode(Mac48Address address, WifiMode reqMode)
uint32_t GetNBasicMcs(void) const
virtual uint8_t DoGetCtsTxNss(Mac48Address address, WifiMode ctsMode)
WifiModeList m_bssBasicRateSet
void ReportDataOk(Mac48Address address, const WifiMacHeader *header, double ackSnr, WifiMode ackMode, double dataSnr)
void SetHtSupported(bool enable)
virtual uint8_t DoGetAckTxPowerLevel(Mac48Address address, WifiMode ackMode)
tag a set of bytes in a packet
uint32_t GetFragmentOffset(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet, uint32_t fragmentNumber)
bool IsWaitAssocTxOk(Mac48Address address) const
void PrepareForQueue(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet, uint32_t fullPacketSize)
WifiTxVector DoGetCtsToSelfTxVector(void)
void AddSupportedMode(Mac48Address address, WifiMode mode)
WifiModeList m_operationalRateSet
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
uint64_t GetPhyRate(void) const
uint32_t GetFragmentSize(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet, uint32_t fragmentNumber)
void DoSetFragmentationThreshold(uint32_t threshold)
virtual TypeId GetInstanceTypeId(void) const
void AddBasicMode(WifiMode mode)
WifiModeList::const_iterator WifiModeListIterator
virtual uint32_t GetSerializedSize(void) const
TracedCallback< Mac48Address > m_macTxRtsFailed
bool IsAssociated(Mac48Address address) const
virtual bool IsLowLatency(void) const =0
virtual WifiMode GetMode(uint32_t mode) const =0
void SetTxPowerLevel(uint8_t powerlevel)
bool GetShortGuardInterval(const WifiRemoteStation *station) const
void ReportRtsOk(Mac48Address address, const WifiMacHeader *header, double ctsSnr, WifiMode ctsMode, double rtsSnr)
TracedCallback< Mac48Address > m_macTxDataFailed
static TypeId GetTypeId(void)
double GetFrameErrorRate() const
Returns frame error rate (probability that frame is corrupted due to transmission error)...
virtual TypeId GetInstanceTypeId(void) const
virtual void Serialize(TagBuffer i) const
bool HasHtSupported(void) const
void SetMode(WifiMode mode)
virtual bool DoNeedFragmentation(WifiRemoteStation *station, Ptr< const Packet > packet, bool normally)
void NotifyTxFailed()
Updates average frame error rate when final data or RTS has failed.
bool NeedCtsToSelf(WifiTxVector txVector)
virtual uint32_t GetSerializedSize(void) const
static TypeId GetTypeId(void)
uint8_t GetDefaultTxPowerLevel(void) const
virtual void Deserialize(TagBuffer i)
void SetMaxSlrc(uint32_t maxSlrc)
uint32_t GetNBasicModes(void) const
uint32_t GetLongRetryCount(const WifiRemoteStation *station) const
void AddSupportedMcs(Mac48Address address, uint8_t mcs)
static TypeId GetTypeId(void)
virtual bool DoGetCtsTxStbc(Mac48Address address, WifiMode ctsMode)
uint32_t GetNMcsSupported(const WifiRemoteStation *station) const
WifiMode GetDefaultMode(void) const
virtual ~WifiRemoteStationManager()
uint8_t GetBasicMcs(uint32_t i) const
void SetFragmentationThreshold(uint32_t threshold)
virtual bool DoGetBlockAckTxGuardInterval(Mac48Address address, WifiMode blockAckMode)
virtual void Serialize(TagBuffer i) const
virtual void DoDispose(void)
WifiTxVector GetDataTxVector(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet, uint32_t fullPacketSize)
void ReportRxOk(Mac48Address address, const WifiMacHeader *header, double rxSnr, WifiMode txMode)
bool NeedFragmentation(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet)
NS_LOG_COMPONENT_DEFINE("WifiRemoteStationManager")
void SetNess(uint8_t ness)
void Read(uint8_t *buffer, uint32_t size)
void AddBasicMcs(uint8_t mcs)
virtual bool DoGetBlockAckTxStbc(Mac48Address address, WifiMode blockAckMode)
void SetStbc(bool stbcsatuts)
bool NeedRtsRetransmission(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet)
uint32_t GetShortRetryCount(const WifiRemoteStation *station) const
uint32_t GetNumberOfTransmitAntennas(void)
virtual uint8_t DoGetCtsTxNess(Mac48Address address, WifiMode ctsMode)
WifiTxVector GetRtsTxVector(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet)
a base class which provides memory management and object aggregation
virtual uint32_t GetSerializedSize(void) const
hold objects of type ns3::WifiMode
virtual void Deserialize(TagBuffer i)
WifiMode GetMode(void) const
bool NeedRts(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet)
WifiTxVector GetBlockAckTxVector(Mac48Address address, WifiMode dataMode)
virtual uint8_t DoGetCtsTxPowerLevel(Mac48Address address, WifiMode ctsMode)
virtual void Print(std::ostream &os) const
uint32_t GetMaxSlrc(void) const
virtual void DoReportFinalDataFailed(WifiRemoteStation *station)=0
virtual WifiTxVector DoGetRtsTxVector(WifiRemoteStation *station)=0
a unique identifier for an interface.
void ReportFinalRtsFailed(Mac48Address address, const WifiMacHeader *header)
WifiTxVector GetAckTxVector(Mac48Address address, WifiMode dataMode)
virtual WifiMode McsToWifiMode(uint8_t mcs)=0
TypeId SetParent(TypeId tid)
WifiRemoteStationInfo m_info
virtual void DoReportFinalRtsFailed(WifiRemoteStation *station)=0
virtual bool GetGreenfield(void) const =0
hold per-remote-station state.
virtual WifiRemoteStation * DoCreateStation(void) const =0
void RecordGotAssocTxOk(Mac48Address address)
virtual uint8_t DoGetBlockAckTxPowerLevel(Mac48Address address, WifiMode blockAckMode)
virtual void DoReportDataOk(WifiRemoteStation *station, double ackSnr, WifiMode ackMode, double dataSnr)=0