wifi: Make WifiMacQueueItem more useful
This commit is contained in:
@@ -25,15 +25,21 @@
|
||||
#include "ns3/packet.h"
|
||||
#include "ns3/log.h"
|
||||
#include "wifi-mac-queue-item.h"
|
||||
#include "wifi-mac-trailer.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
NS_LOG_COMPONENT_DEFINE ("WifiMacQueueItem");
|
||||
|
||||
WifiMacQueueItem::WifiMacQueueItem (Ptr<const Packet> p, const WifiMacHeader & header)
|
||||
: WifiMacQueueItem (p, header, Simulator::Now ())
|
||||
{
|
||||
}
|
||||
|
||||
WifiMacQueueItem::WifiMacQueueItem (Ptr<const Packet> p, const WifiMacHeader & header, Time tstamp)
|
||||
: m_packet (p),
|
||||
m_header (header),
|
||||
m_tstamp (Simulator::Now ())
|
||||
m_tstamp (tstamp)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -53,6 +59,12 @@ WifiMacQueueItem::GetHeader (void) const
|
||||
return m_header;
|
||||
}
|
||||
|
||||
WifiMacHeader&
|
||||
WifiMacQueueItem::GetHeader (void)
|
||||
{
|
||||
return m_header;
|
||||
}
|
||||
|
||||
Mac48Address
|
||||
WifiMacQueueItem::GetDestinationAddress (void) const
|
||||
{
|
||||
@@ -68,7 +80,38 @@ WifiMacQueueItem::GetTimeStamp (void) const
|
||||
uint32_t
|
||||
WifiMacQueueItem::GetSize (void) const
|
||||
{
|
||||
return m_packet->GetSize () + m_header.GetSerializedSize ();
|
||||
return m_packet->GetSize () + m_header.GetSerializedSize () + WIFI_MAC_FCS_LENGTH;
|
||||
}
|
||||
|
||||
void
|
||||
WifiMacQueueItem::Print (std::ostream& os) const
|
||||
{
|
||||
os << "size=" << m_packet->GetSize ()
|
||||
<< ", to=" << m_header.GetAddr1 ()
|
||||
<< ", seqN=" << m_header.GetSequenceNumber ()
|
||||
<< ", lifetime=" << (Simulator::Now () - m_tstamp).GetMicroSeconds () << "us";
|
||||
if (m_header.IsQosData ())
|
||||
{
|
||||
os << ", tid=" << +m_header.GetQosTid ();
|
||||
if (m_header.IsQosNoAck ())
|
||||
{
|
||||
os << ", ack=NoAck";
|
||||
}
|
||||
else if (m_header.IsQosAck ())
|
||||
{
|
||||
os << ", ack=NormalAck";
|
||||
}
|
||||
else if (m_header.IsQosBlockAck ())
|
||||
{
|
||||
os << ", ack=BlockAck";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::ostream & operator << (std::ostream &os, const WifiMacQueueItem &item)
|
||||
{
|
||||
item.Print (os);
|
||||
return os;
|
||||
}
|
||||
|
||||
} //namespace ns3
|
||||
|
||||
@@ -48,6 +48,14 @@ public:
|
||||
*/
|
||||
WifiMacQueueItem (Ptr<const Packet> p, const WifiMacHeader & header);
|
||||
|
||||
/**
|
||||
* \brief Create a Wifi MAC queue item containing a packet and a Wifi MAC header.
|
||||
* \param p the const packet included in the created item.
|
||||
* \param header the Wifi Mac header included in the created item.
|
||||
* \param tstamp the timestamp associated with the created item.
|
||||
*/
|
||||
WifiMacQueueItem (Ptr<const Packet> p, const WifiMacHeader & header, Time tstamp);
|
||||
|
||||
virtual ~WifiMacQueueItem ();
|
||||
|
||||
/**
|
||||
@@ -62,6 +70,12 @@ public:
|
||||
*/
|
||||
const WifiMacHeader & GetHeader (void) const;
|
||||
|
||||
/**
|
||||
* \brief Get the header stored in this item
|
||||
* \return the header stored in this item.
|
||||
*/
|
||||
WifiMacHeader & GetHeader (void);
|
||||
|
||||
/**
|
||||
* \brief Return the destination address present in the header
|
||||
* \return the destination address
|
||||
@@ -75,38 +89,33 @@ public:
|
||||
Time GetTimeStamp (void) const;
|
||||
|
||||
/**
|
||||
* \brief Return the size of the packet included in this item
|
||||
* \brief Return the size of the packet stored by this item, including header
|
||||
* size and trailer size
|
||||
*
|
||||
* \return the size of the packet included in this item.
|
||||
* \return the size of the packet stored by this item.
|
||||
*/
|
||||
uint32_t GetSize (void) const;
|
||||
|
||||
private:
|
||||
/**
|
||||
* \brief Default constructor
|
||||
*
|
||||
* Defined and unimplemented to avoid misuse
|
||||
* \brief Print the item contents.
|
||||
* \param os output stream in which the data should be printed.
|
||||
*/
|
||||
WifiMacQueueItem ();
|
||||
/**
|
||||
* \brief Copy constructor
|
||||
*
|
||||
* Defined and unimplemented to avoid misuse
|
||||
*/
|
||||
WifiMacQueueItem (const WifiMacQueueItem &);
|
||||
/**
|
||||
* \brief Assignment operator
|
||||
*
|
||||
* Defined and unimplemented to avoid misuse
|
||||
* \returns
|
||||
*/
|
||||
WifiMacQueueItem &operator = (const WifiMacQueueItem &);
|
||||
virtual void Print (std::ostream &os) const;
|
||||
|
||||
private:
|
||||
Ptr<const Packet> m_packet; //!< The packet contained in this queue item
|
||||
WifiMacHeader m_header; //!< Wifi MAC header associated with the packet
|
||||
Time m_tstamp; //!< timestamp when the packet arrived at the queue
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Stream insertion operator.
|
||||
*
|
||||
* \param os the stream
|
||||
* \param item the item
|
||||
* \returns a reference to the stream
|
||||
*/
|
||||
std::ostream& operator<< (std::ostream& os, const WifiMacQueueItem &item);
|
||||
|
||||
} //namespace ns3
|
||||
|
||||
|
||||
Reference in New Issue
Block a user