Removed inheritance from Header in WifiInformationElement. TODO: restore unit

tests and Print capability (operator "<<").
This commit is contained in:
Kirill Andreev
2009-08-25 12:52:51 +04:00
parent 1b6137af25
commit 009d9f8f4e
19 changed files with 133 additions and 294 deletions

View File

@@ -406,7 +406,7 @@ HwmpProtocol::ReceivePreq (IePreq preq, Mac48Address from, uint32_t interface, M
m_lastHwmpSeqno[preq.GetOriginatorAddress ()] = preq.GetOriginatorSeqNumber ();
m_lastHwmpMetric[preq.GetOriginatorAddress ()] = preq.GetMetric ();
}
NS_LOG_DEBUG("I am " << GetAddress () << "Accepted preq from address" << from << ", preq:" << preq);
//NS_LOG_DEBUG("I am " << GetAddress () << "Accepted preq from address" << from << ", preq:" << preq);
std::vector<Ptr<DestinationAddressUnit> > destinations = preq.GetDestinationList ();
//Add reactive path to originator:
if (
@@ -537,7 +537,7 @@ HwmpProtocol::ReceivePreq (IePreq preq, Mac48Address from, uint32_t interface, M
return;
}
//Forward PREQ to all interfaces:
NS_LOG_DEBUG("I am " << GetAddress () << "retransmitting PREQ:" << preq);
//NS_LOG_DEBUG("I am " << GetAddress () << "retransmitting PREQ:" << preq);
for (HwmpProtocolMacMap::const_iterator i = m_interfaces.begin (); i != m_interfaces.end (); i ++)
{
i->second->SendPreq (preq);
@@ -566,7 +566,7 @@ HwmpProtocol::ReceivePrep (IePrep prep, Mac48Address from, uint32_t interface, M
}
//update routing info
//Now add a path to destination and add precursor to source
NS_LOG_DEBUG("I am " << GetAddress () << ", received prep from " << prep.GetOriginatorAddress () << ", receiver was:" << from);
//NS_LOG_DEBUG("I am " << GetAddress () << ", received prep from " << prep.GetOriginatorAddress () << ", receiver was:" << from);
HwmpRtable::LookupResult result = m_rtable->LookupReactive (prep.GetDestinationAddress ());
//Add a reactive path only if it is better than existing:
if (
@@ -604,7 +604,7 @@ HwmpProtocol::ReceivePrep (IePrep prep, Mac48Address from, uint32_t interface, M
}
if (prep.GetDestinationAddress () == GetAddress ())
{
NS_LOG_DEBUG("I am "<<GetAddress ()<<", resolved "<<prep.GetOriginatorAddress ());
//NS_LOG_DEBUG("I am "<<GetAddress ()<<", resolved "<<prep.GetOriginatorAddress ());
return;
}
if (result.retransmitter == Mac48Address::GetBroadcast ())

View File

@@ -83,12 +83,17 @@ public:
Time beacon_interval
);
void ClearTimingElement ();
private:
/**
* \name Inherited from WifiInformationElement
* \{
*/
virtual WifiElementId ElementId () const;
virtual uint8_t GetInformationSize () const;
virtual void SerializeInformation (Buffer::Iterator i) const;
virtual uint8_t DeserializeInformation (Buffer::Iterator i, uint8_t length);
virtual void PrintInformation (std::ostream& os) const;
///\}
private:
/**
* Converters:
*/

View File

@@ -108,14 +108,17 @@ public:
bool IsAirtime ();
void SetNeighborCount (uint8_t neighbors);
uint8_t GetNeighborCount ();
Dot11sMeshCapability const& MeshCapability ();
private:
/**
* \name Inherited from WifiInformationElement
* \{
*/
virtual WifiElementId ElementId () const;
virtual uint8_t GetInformationSize () const;
virtual void SerializeInformation (Buffer::Iterator i) const;
virtual uint8_t DeserializeInformation (Buffer::Iterator i, uint8_t length);
virtual void PrintInformation (std::ostream& os) const;
///\}
private:
/** Active Path Selection Protocol ID */
dot11sPathSelectionProtocol m_APSPId;

View File

@@ -40,15 +40,18 @@ public:
bool IsEqual (IeMeshId const &o) const;
bool IsBroadcast (void) const;
uint32_t GetLength (void) const;
char *PeekString (void) const;
private:
/**
* \name Inherited from WifiInformationElement
* \{
*/
virtual WifiElementId ElementId () const;
virtual void SerializeInformation (Buffer::Iterator i) const;
virtual uint8_t DeserializeInformation (Buffer::Iterator start, uint8_t length);
virtual void PrintInformation (std::ostream& os) const;
virtual uint8_t GetInformationSize () const;
///\}
private:
uint8_t m_meshId[33];
friend bool operator== (const IeMeshId & a, const IeMeshId & b);

View File

@@ -38,12 +38,16 @@ public:
IeLinkMetricReport (uint32_t metric);
void SetMetric (uint32_t metric);
uint32_t GetMetric ();
private:
/**
* \name Inherited from WifiInformationElement
* \{
*/
virtual WifiElementId ElementId () const;
virtual void SerializeInformation (Buffer::Iterator i) const;
virtual uint8_t DeserializeInformation (Buffer::Iterator start, uint8_t length);
virtual void PrintInformation (std::ostream& os) const;
virtual uint8_t GetInformationSize () const;
///\}
private:
uint32_t m_metric;
friend bool operator== (const IeLinkMetricReport & a, const IeLinkMetricReport & b);

View File

@@ -85,7 +85,11 @@ IePeerManagement::GetInformationSize (void) const
{
return m_length;
}
uint8_t
IePeerManagement::GetSubtype () const
{
return m_subtype;
}
bool
IePeerManagement::SubtypeIsOpen () const
{

View File

@@ -69,13 +69,17 @@ public:
bool SubtypeIsOpen () const;
bool SubtypeIsClose () const;
bool SubtypeIsConfirm () const ;
uint8_t GetSubtype () const { return m_subtype;};
private:
uint8_t GetSubtype () const;
/**
* \name Inherited from WifiInformationElement
* \{
*/
virtual WifiElementId ElementId () const;
virtual uint8_t GetInformationSize (void) const;
virtual void SerializeInformation (Buffer::Iterator i) const;
virtual uint8_t DeserializeInformation (Buffer::Iterator i, uint8_t length);
virtual void PrintInformation (std::ostream& os) const;
///\}
private:
uint8_t m_length;
uint8_t m_subtype;

View File

@@ -31,12 +31,16 @@ class IePeeringProtocol : public WifiInformationElement
{
public:
IePeeringProtocol ();
private:
/**
* \name Inherited from WifiInformationElement
* \{
*/
virtual WifiElementId ElementId () const;
virtual uint8_t GetInformationSize () const;
virtual void SerializeInformation (Buffer::Iterator i) const;
virtual uint8_t DeserializeInformation (Buffer::Iterator i, uint8_t length);
virtual void PrintInformation (std::ostream& os) const;
///\}
private:
uint8_t m_protocol;
};

View File

@@ -109,7 +109,7 @@ IePerr::AddAddressUnit (FailedDestination unit)
bool
IePerr::IsFull () const
{
return (GetSerializedSize () + 10 > 255);
return (GetInformationSize () + 2 /* ID + LENGTH*/+ 10 /* Sie of Mac48Address + uint32_t (one unit)*/> 255);
}
std::vector<IePerr::FailedDestination>
IePerr::GetAddressUnitVector () const

View File

@@ -47,12 +47,16 @@ public:
std::vector<FailedDestination> GetAddressUnitVector () const;
void DeleteAddressUnit (Mac48Address address);
void ResetPerr ();
private:
/**
* \name Inherited from WifiInformationElement
* \{
*/
WifiElementId ElementId () const;
void SerializeInformation (Buffer::Iterator i) const;
uint8_t DeserializeInformation (Buffer::Iterator start, uint8_t length);
void PrintInformation (std::ostream& os) const;
uint8_t GetInformationSize () const;
///\}
private:
std::vector<FailedDestination> m_addressUnits;
friend bool operator== (const IePerr & a, const IePerr & b);

View File

@@ -57,12 +57,16 @@ public:
void DecrementTtl ();
void IncrementMetric (uint32_t metric);
private:
/**
* \name Inherited from WifiInformationElement
* \{
*/
WifiElementId ElementId () const;
void SerializeInformation (Buffer::Iterator i) const;
uint8_t DeserializeInformation (Buffer::Iterator start, uint8_t length);
uint8_t GetInformationSize () const;
void PrintInformation (std::ostream& os) const;
///\}
private:
uint8_t m_flags;
uint8_t m_hopcount;

View File

@@ -118,12 +118,17 @@ public:
*/
bool MayAddAddress (Mac48Address originator);
bool IsFull () const;
private:
/**
* \name Inherited from WifiInformationElement
* \{
*/
WifiElementId ElementId () const;
void SerializeInformation (Buffer::Iterator i) const;
uint8_t DeserializeInformation (Buffer::Iterator i, uint8_t length);
uint8_t GetInformationSize () const;
void PrintInformation (std::ostream& os) const;
///\}
private:
/**
* how many destinations we support
*/

View File

@@ -49,14 +49,17 @@ public:
uint32_t GetMetric ();
void DecrementTtl ();
void IncrementMetric (uint32_t metric);
private:
/**
* \name Inherited from WifiInformationElement
* \{
*/
WifiElementId ElementId () const;
void SerializeInformation (Buffer::Iterator i) const;
uint8_t DeserializeInformation (Buffer::Iterator start, uint8_t length);
uint8_t GetInformationSize () const;
void PrintInformation (std::ostream &os) const;
///\}
private:
uint8_t m_flags;
uint8_t m_hopcount;
uint8_t m_ttl;

View File

@@ -97,9 +97,12 @@ PeerLinkFrameStart::GetInstanceTypeId () const
void
PeerLinkFrameStart::Print (std::ostream &os) const
{
os << "subtype = " << (uint16_t) m_subtype << "std::endlcapability = " << m_capability << "std::endlaid = "
<< (uint16_t) m_aid << "std::endlrates = " << m_rates << "std::endlmeshId = " << m_meshId << "std::endlconfiguration = "
<< m_config << "std::endlreason code = " << m_reasonCode;
os << "subtype = " << (uint16_t) m_subtype << std::endl << "capability = " << m_capability << std::endl << "laid = "
<< (uint16_t) m_aid << std::endl << "rates = " << m_rates << std::endl << "meshId = ";
m_meshId.Print (os);
os << std::endl << "configuration = ";
m_config.Print (os);
os << std::endl << "reason code = " << m_reasonCode;
}
uint32_t
PeerLinkFrameStart::GetSerializedSize () const
@@ -120,11 +123,11 @@ PeerLinkFrameStart::GetSerializedSize () const
}
if ((uint8_t) (WifiMeshActionHeader::PEER_LINK_CONFIRM) != m_subtype)
{
size += m_meshId.GetSerializedSize ();
size += m_meshId.GetInformationSize () + 2;
}
if ((uint8_t) (WifiMeshActionHeader::PEER_LINK_CLOSE) != m_subtype)
{
size += m_config.GetSerializedSize ();
size += m_config.GetInformationSize () + 2;
}
else
{
@@ -137,8 +140,10 @@ PeerLinkFrameStart::Serialize (Buffer::Iterator start) const
{
Buffer::Iterator i = start;
NS_ASSERT (m_subtype < 3);
m_protocol.Serialize (i);
i.Next (m_protocol.GetSerializedSize ());
i.WriteU8 (IE11S_MESH_PEERING_PROTOCOL_VERSION);
i.WriteU8 (m_protocol.GetInformationSize ());
m_protocol.SerializeInformation (i);
i.Next (m_protocol.GetInformationSize ());
if ((uint8_t) (WifiMeshActionHeader::PEER_LINK_CLOSE) != m_subtype)
{
i.WriteHtolsbU16 (m_capability);
@@ -153,13 +158,17 @@ PeerLinkFrameStart::Serialize (Buffer::Iterator start) const
}
if ((uint8_t) (WifiMeshActionHeader::PEER_LINK_CONFIRM) != m_subtype)
{
m_meshId.Serialize (i);
i.Next (m_meshId.GetSerializedSize ());
i.WriteU8 (IE11S_MESH_ID);
i.WriteU8 (m_meshId.GetInformationSize ());
m_meshId.SerializeInformation (i);
i.Next (m_meshId.GetInformationSize ());
}
if ((uint8_t) (WifiMeshActionHeader::PEER_LINK_CLOSE) != m_subtype)
{
m_config.Serialize (i);
i.Next (m_config.GetSerializedSize ());
i.WriteU8 (IE11S_MESH_CONFIGURATION);
i.WriteU8 (m_config.GetInformationSize ());
m_config.SerializeInformation (i);
i.Next (m_config.GetInformationSize ());
}
else
{
@@ -171,8 +180,16 @@ PeerLinkFrameStart::Deserialize (Buffer::Iterator start)
{
Buffer::Iterator i = start;
NS_ASSERT (m_subtype < 3);
m_protocol.Deserialize (i);
i.Next (m_protocol.GetSerializedSize ());
{
uint8_t id = i.ReadU8 ();
uint8_t length = i.ReadU8 ();
m_protocol.DeserializeInformation (i, length);
if ((m_protocol.ElementId () != (WifiElementId) id) || (m_protocol.GetInformationSize () != length))
{
NS_FATAL_ERROR ("Broken frame: Element ID does not match IE itself!");
}
i.Next (m_protocol.GetInformationSize ());
}
if ((uint8_t) (WifiMeshActionHeader::PEER_LINK_CLOSE) != m_subtype)
{
m_capability = i.ReadLsbtohU16 ();
@@ -187,13 +204,25 @@ PeerLinkFrameStart::Deserialize (Buffer::Iterator start)
}
if ((uint8_t) (WifiMeshActionHeader::PEER_LINK_CONFIRM) != m_subtype)
{
m_meshId.Deserialize (i);
i.Next (m_meshId.GetSerializedSize ());
uint8_t id = i.ReadU8 ();
uint8_t length = i.ReadU8 ();
m_meshId.DeserializeInformation (i, length);
if ((m_meshId.ElementId () != (WifiElementId) id) || (m_meshId.GetInformationSize () != length))
{
NS_FATAL_ERROR ("Broken frame: Element ID does not match IE itself!");
}
i.Next (m_meshId.GetInformationSize ());
}
if ((uint8_t) (WifiMeshActionHeader::PEER_LINK_CLOSE) != m_subtype)
{
m_config.Deserialize (i);
i.Next (m_config.GetSerializedSize ());
uint8_t id = i.ReadU8 ();
uint8_t length = i.ReadU8 ();
m_config. DeserializeInformation (i, length);
if ((m_config.ElementId () != (WifiElementId) id) || (m_config.GetInformationSize () != length))
{
NS_FATAL_ERROR ("Broken frame: Element ID does not match IE itself!");
}
i.Next (m_config.GetInformationSize ());
}
else
{

View File

@@ -126,26 +126,30 @@ PeerManagementProtocolMac::Receive (Ptr<Packet> const_packet, const WifiMacHeade
m_stats.brokenMgt++;
return false;
}
IePeerManagement peerElement;
packet->RemoveHeader (peerElement);
Ptr<IePeerManagement> peerElement;
//Peer Management element is the last element in this frame - so, we can use WifiInformationElementVector
WifiInformationElementVector elements;
packet->RemoveHeader (elements);
peerElement = DynamicCast<IePeerManagement>(elements.FindFirst(IE11S_PEERING_MANAGEMENT));
NS_ASSERT (peerElement != 0);
//Check taht frame subtype corresponds peer link subtype
if (peerElement.SubtypeIsOpen ())
if (peerElement->SubtypeIsOpen ())
{
m_stats.rxOpen++;
NS_ASSERT (actionValue.peerLink == WifiMeshActionHeader::PEER_LINK_OPEN);
}
if (peerElement.SubtypeIsConfirm ())
if (peerElement->SubtypeIsConfirm ())
{
m_stats.rxConfirm++;
NS_ASSERT (actionValue.peerLink == WifiMeshActionHeader::PEER_LINK_CONFIRM);
}
if (peerElement.SubtypeIsClose ())
if (peerElement->SubtypeIsClose ())
{
m_stats.rxClose++;
NS_ASSERT (actionValue.peerLink == WifiMeshActionHeader::PEER_LINK_CLOSE);
}
//Deliver Peer link management frame to protocol:
m_protocol->ReceivePeerLinkFrame (m_ifIndex, peerAddress, peerMpAddress, fields.aid, peerElement,
m_protocol->ReceivePeerLinkFrame (m_ifIndex, peerAddress, peerMpAddress, fields.aid, *peerElement,
fields.config);
// if we can handle a frame - drop it
return false;
@@ -198,7 +202,9 @@ PeerManagementProtocolMac::SendPeerLinkManagementFrame (Mac48Address peerAddress
//Create a packet:
meshConfig.SetNeighborCount (m_protocol->GetNumberOfLinks ());
Ptr<Packet> packet = Create<Packet> ();
packet->AddHeader (peerElement);
WifiInformationElementVector elements;
elements.AddInformationElement(Ptr<IePeerManagement> (&peerElement));
packet->AddHeader (elements);
PeerLinkFrameStart::PlinkFrameStartFields fields;
fields.rates = m_parent->GetSupportedRates ();
fields.capability = 0;

View File

@@ -75,7 +75,6 @@ WifiInformationElementVector::Deserialize (Buffer::Iterator start)
{
Buffer::Iterator i = start;
uint32_t size = start.GetSize();
std::cerr << "Size = " << size << "\n";
while (size > 0)
{
uint32_t deserialized = DeserializeSingleIe(i);
@@ -159,7 +158,7 @@ WifiInformationElementVector::End ()
bool
WifiInformationElementVector::AddInformationElement (Ptr<WifiInformationElement> element)
{
if (element->GetSerializedSize () + GetSize () > m_maxSize)
if (element->GetInformationSize () + 2 + GetSize () > m_maxSize)
{
return false;
}
@@ -178,62 +177,6 @@ WifiInformationElementVector::FindFirst (enum WifiElementId id) const
}
return 0;
}
WifiInformationElementVector
WifiInformationElementVector::DeserializePacket (Ptr<Packet> packet)
{
WifiInformationElementVector retval;
EmptyIe ie;
while (packet->PeekHeader (ie))
{
Ptr<WifiInformationElement> newElement;
switch (ie.GetElementId ())
{
case IE11S_MESH_CONFIGURATION:
newElement = Create<dot11s::IeConfiguration> ();
break;
case IE11S_MESH_ID:
newElement = Create<dot11s::IeMeshId> ();
break;
case IE11S_LINK_METRIC_REPORT:
newElement = Create<dot11s::IeLinkMetricReport> ();
break;
case IE11S_PEERING_MANAGEMENT:
newElement = Create<dot11s::IePeerManagement> ();
break;
case IE11S_BEACON_TIMING:
newElement = Create<dot11s::IeBeaconTiming> ();
break;
case IE11S_RANN:
newElement = Create<dot11s::IeRann> ();
break;
case IE11S_PREQ:
newElement = Create<dot11s::IePreq> ();
break;
case IE11S_PREP:
newElement = Create<dot11s::IePrep> ();
break;
case IE11S_PERR:
newElement = Create<dot11s::IePerr> ();
break;
case IE11S_MESH_PEERING_PROTOCOL_VERSION:
newElement = Create<dot11s::IePeeringProtocol> ();
break;
default:
NS_FATAL_ERROR ("Information element " << (uint16_t) ie.GetElementId () << " is not implemented");
return retval;
}
packet->RemoveHeader (*newElement);
if (!retval.AddInformationElement (newElement))
{
NS_FATAL_ERROR ("Check max size for information element!");
}
if (packet->GetSize () == 0)
{
return retval;
}
}
return retval;
}
namespace {
struct PIEComparator
{
@@ -244,83 +187,16 @@ struct PIEComparator
}
};
}
Ptr<Packet>
WifiInformationElementVector::CreatePacket (bool sortByElementId)
{
if (sortByElementId)
{
std::sort (m_elements.begin (), m_elements.end (), PIEComparator ());
}
Ptr<Packet> packet = Create<Packet> ();
std::vector<Ptr<WifiInformationElement> >::const_reverse_iterator i;
for (i = m_elements.rbegin (); i != m_elements.rend (); ++i)
{
packet->AddHeader (**i);
}
return packet;
}
uint32_t
WifiInformationElementVector::GetSize () const
{
uint32_t size = 0;
for (IE_VECTOR::const_iterator i = m_elements.begin (); i != m_elements.end (); i++)
{
size += (*i)->GetSerializedSize ();
size += ((*i)->GetInformationSize () + 2);
}
return size;
}
WifiInformationElementVector::EmptyIe::~EmptyIe ()
{
}
WifiInformationElementVector::EmptyIe::EmptyIe () :
m_elementId (0), m_length (0)
{
}
TypeId
WifiInformationElementVector::EmptyIe::GetTypeId ()
{
static TypeId tid = TypeId ("ns3::WifiInformationElementVector::EmptyIe")
.SetParent<Header> ();
return tid;
}
TypeId
WifiInformationElementVector::EmptyIe::GetInstanceTypeId () const
{
return GetTypeId ();
}
uint8_t
WifiInformationElementVector::EmptyIe::GetLength ()
{
return m_length;
}
uint8_t
WifiInformationElementVector::EmptyIe::GetElementId ()
{
return m_elementId;
}
uint32_t
WifiInformationElementVector::EmptyIe::GetSerializedSize () const
{
return 2;
}
void
WifiInformationElementVector::EmptyIe::Serialize (Buffer::Iterator start) const
{
start.WriteU8 (m_elementId);
start.WriteU8 (m_length);
}
uint32_t
WifiInformationElementVector::EmptyIe::Deserialize (Buffer::Iterator start)
{
Buffer::Iterator i = start;
m_elementId = i.ReadU8 ();
m_length = i.ReadU8 ();
return i.GetDistanceFrom (start);
}
void
WifiInformationElementVector::EmptyIe::Print (std::ostream &os) const
{
}
bool
operator== (const WifiInformationElementVector & a, const WifiInformationElementVector & b)
{
@@ -337,7 +213,7 @@ operator== (const WifiInformationElementVector & a, const WifiInformationElement
{
return false;
}
if ((*i)->GetSerializedSize () != (*j)->GetSerializedSize ())
if ((*i)->GetInformationSize () != (*j)->GetInformationSize ())
{
return false;
}
@@ -374,8 +250,10 @@ WifiInformationElementVectorBist::RunTests ()
vector.AddInformationElement (Create<dot11s::IePreq> ());
vector.AddInformationElement (Create<dot11s::IePrep> ());
vector.AddInformationElement (Create<dot11s::IePerr> ());
Ptr<Packet> packet = vector.CreatePacket (false);
WifiInformationElementVector resultVector = WifiInformationElementVector::DeserializePacket (packet);
Ptr<Packet> packet = Create<Packet> ();
packet->AddHeader (vector);
WifiInformationElementVector resultVector;
packet->RemoveHeader (resultVector);
NS_TEST_ASSERT (vector == resultVector);
return result;

View File

@@ -59,31 +59,8 @@ public:
Iterator End ();
bool AddInformationElement (Ptr<WifiInformationElement> element);
Ptr<WifiInformationElement> FindFirst (enum WifiElementId id) const;
static WifiInformationElementVector DeserializePacket (Ptr<Packet> packet);
Ptr<Packet> CreatePacket (bool sortByElementId = true);
private:
uint32_t GetSize () const;
/**
* \brief Implements an empty information element: just elementId and length.
* \details Needed to understand, which information element we need to deserialize now
*/
class EmptyIe : public Header
{
public:
EmptyIe ();
virtual ~EmptyIe ();
static TypeId GetTypeId ();
TypeId GetInstanceTypeId () const;
uint8_t GetLength ();
uint8_t GetElementId ();
virtual uint32_t GetSerializedSize () const;
virtual void Serialize (Buffer::Iterator start) const;
virtual uint32_t Deserialize (Buffer::Iterator start);
virtual void Print (std::ostream &os) const;
private:
uint8_t m_elementId;
uint8_t m_length;
};
typedef std::vector<Ptr<WifiInformationElement> > IE_VECTOR;
IE_VECTOR m_elements;
/// Size in bytes (actually, max packet length)

View File

@@ -24,45 +24,6 @@
namespace ns3
{
TypeId
WifiInformationElement::GetTypeId ()
{
static TypeId tid = TypeId ("ns3::WifiInformationElement")
.SetParent<Header> ();
return tid;
}
TypeId
WifiInformationElement::GetInstanceTypeId () const
{
return GetTypeId ();
}
uint32_t
WifiInformationElement::GetSerializedSize () const
{
return (GetInformationSize () + 2);
}
void
WifiInformationElement::Serialize (Buffer::Iterator i) const
{
i.WriteU8 (ElementId ());
i.WriteU8 (GetInformationSize ());
SerializeInformation (i);
}
uint32_t
WifiInformationElement::Deserialize (Buffer::Iterator i)
{
if (i.ReadU8 () != ElementId ())
{
return 0;
}
uint8_t length = i.ReadU8 ();
return (DeserializeInformation (i, length) + 2);
}
void
WifiInformationElement::Print (std::ostream &os) const
{

View File

@@ -81,70 +81,15 @@ enum WifiElementId {
* Element ID as defined in this standard. The Length field specifies the number of octets in the Information
* field.
*/
class WifiInformationElement : public Header,
public RefCountBase // need this to use Ptr<WifiInformationElement>
class WifiInformationElement : public RefCountBase
{
public:
/// Support object system
static TypeId GetTypeId ();
TypeId GetInstanceTypeId () const;
/// virtual d-tor for subclasses
virtual ~WifiInformationElement () {}
///\name Inherited from Header
//\{
/**
* \return the expected size of the header.
*
* This method is used by Packet::AddHeader
* to store a header into the byte buffer of a packet. This method
* should return the number of bytes which are needed to store
* the full header data by Serialize.
*/
virtual uint32_t GetSerializedSize () const;
/**
* \param start an iterator which points to where the header should
* be written.
*
* This method is used by Packet::AddHeader to
* store a header into the byte buffer of a packet.
* The data written
* is expected to match bit-for-bit the representation of this
* header in a real network.
*/
virtual void Serialize (Buffer::Iterator start) const;
/**
* \param start an iterator which points to where the header should
* written.
* \return the number of bytes read.
*
* This method is used by Packet::RemoveHeader to
* re-create a header from the byte buffer of a packet.
* The data read is expected to
* match bit-for-bit the representation of this header in real
* networks.
*/
virtual uint32_t Deserialize (Buffer::Iterator start);
/**
* This method is used by Packet::Print to print the
* content of a trailer as ascii data to a c++ output stream.
* Although the trailer is free to format its output as it
* wishes, it is recommended to follow a few rules to integrate
* with the packet pretty printer: start with flags, small field
* values located between a pair of parens. Values should be separated
* by whitespace. Follow the parens with the important fields,
* separated by whitespace.
* i.e.: (field1 val1 field2 val2 field3 val3) field4 val4 field5 val5
*/
virtual void Print (std::ostream &os) const;
//\}
///\name Each subclass must implement
//\{
/// Own unique Element ID
virtual WifiElementId ElementId () const = 0;
/// Length of serialized information
//private:
virtual uint8_t GetInformationSize () const = 0;
/// Serialize information
virtual void SerializeInformation (Buffer::Iterator start) const = 0;
@@ -175,7 +120,7 @@ template <typename IE> bool
IeTest::TestRoundtripSerialization (IE a)
{
bool result (true);
#if 0
Ptr<Packet> packet = Create<Packet> ();
packet->AddHeader (a);
IE b;
@@ -186,7 +131,7 @@ IeTest::TestRoundtripSerialization (IE a)
bool ok = packet->RemoveHeader (c);
NS_TEST_ASSERT (ok);
NS_TEST_ASSERT_EQUAL (a, c);
#endif
return result;
}
#endif