Added flame tag

This commit is contained in:
Kirill Andreev
2009-06-17 17:24:34 +04:00
parent 5c20e81c3c
commit 49fe4a8b4f
5 changed files with 159 additions and 4 deletions

View File

@@ -19,8 +19,8 @@
*/
#ifndef MESH_INSTALLATOR_H
#define MESH_INSTALLATOR_H
#ifndef MESH_INSTALLER_H
#define MESH_INSTALLER_H
#include "ns3/mesh-point-device.h"
namespace ns3 {
namespace dot11s {

View File

@@ -19,7 +19,68 @@
*/
#include "flame-protocol-mac.h"
#include "flame-protocol.h"
#include "flame-header.h"
#include "ns3/log.h"
namespace ns3 {
namespace flame {
NS_LOG_COMPONENT_DEFINE ("FlameMacPlugin");
FlameMacPlugin::FlameMacPlugin (uint32_t ifIndex, Ptr<FlameProtocol> protocol):
m_protocol (protocol),
m_ifIndex (ifIndex)
{
}
FlameMacPlugin::~FlameMacPlugin ()
{
}
void
FlameMacPlugin::SetParent (Ptr<MeshWifiInterfaceMac> parent)
{
m_parent = parent;
}
bool
FlameMacPlugin::Receive (Ptr<Packet> packet, const WifiMacHeader & header)
{
if (!header.IsData ())
return true;
FlameHeader flameHdr;
FlameTag tag;
if(packet->PeekPacketTag (tag))
{
NS_FATAL_ERROR ("HWMP tag is not supposed to be received by network");
}
packet->RemoveHeader(flameHdr);
tag.seqno = flameHdr.GetSeqno ();
tag.cost = flameHdr.GetCost ();
return true;
}
bool
FlameMacPlugin::UpdateOutcomingFrame (Ptr<Packet> packet, WifiMacHeader & header, Mac48Address from, Mac48Address to)
{
if(!header.IsData ())
return true;
return true;
}
uint8_t
FlameMacPlugin::GetCost(Mac48Address peerAddress) const
{
uint32_t metric = m_parent->GetLinkMetric(peerAddress);
return (metric > 255 ? 255 : (uint8_t)(metric & 0xff));
}
uint16_t
FlameMacPlugin::GetChannelId () const
{
return m_parent->GetFrequencyChannel ();
}
void
FlameMacPlugin::Report (std::ostream & os) const
{
}
void
FlameMacPlugin::ResetStats ()
{
}
} //namespace flame
} //namespace ns3

View File

@@ -44,9 +44,21 @@ public:
/// Update beacon is empty, because HWMP does not know anything about beacons
void UpdateBeacon (MeshWifiBeacon & beacon) const {};
//\}
/// Returns metric of the link:
uint8_t GetCost (Mac48Address peerAddress) const;
uint16_t GetChannelId () const;
/// Report statistics
void Report (std::ostream &) const;
void ResetStats ();
private:
/**
* \name MeshPointDevice parameters:
* \{
*/
Ptr<FlameProtocol> m_protocol;
uint32_t m_ifIndex;
Ptr<MeshWifiInterfaceMac> m_parent;
///\}
};
} //namespace flame
} //namespace ns3

View File

@@ -21,5 +21,59 @@
#include "flame-protocol.h"
namespace ns3 {
namespace flame {
//-----------------------------------------------------------------------------
// FlameTag
//-----------------------------------------------------------------------------
NS_OBJECT_ENSURE_REGISTERED (FlameTag);
TypeId
FlameTag::GetTypeId ()
{
static TypeId tid = TypeId ("ns3::flame::FlameTag")
.SetParent<Tag> ()
.AddConstructor<FlameTag> ();
return tid;
}
TypeId
FlameTag::GetInstanceTypeId () const
{
return GetTypeId ();
}
uint32_t
FlameTag::GetSerializedSize () const
{
return (sizeof (uint16_t) + sizeof (uint8_t) + 6);
}
void
FlameTag::Serialize (TagBuffer i) const
{
i.WriteU8 (seqno);
i.WriteU16 (seqno);
uint8_t buf[6];
address.CopyTo (buf);
for (int j = 0; j < 6; j ++)
i.WriteU8 (buf[j]);
}
void
FlameTag::Deserialize (TagBuffer i)
{
seqno = i.ReadU8 ();
seqno = i.ReadU16 ();
uint8_t buf[6];
for (int j = 0; j < 6; j ++)
buf[j] = i.ReadU8 ();
address.CopyFrom (buf);
}
void
FlameTag::Print (std::ostream &os) const
{
os << "TTL = " << seqno << ", seqno = " << seqno << "address = " << address;
}
} //namespace flame
} //namespace ns3

View File

@@ -22,8 +22,36 @@
#define FLAME_PROTOCOL_H
#include "ns3/mesh-l2-routing-protocol.h"
#include "ns3/tag.h"
namespace ns3 {
namespace flame {
/**
* \brief Seqno and TTL tag
*/
class FlameTag : public Tag
{
public:
/// Sequence number
uint16_t seqno;
/// Cost:
uint8_t cost;
/// Retransmitter:
Mac48Address address;
FlameTag (uint16_t s = 0, uint8_t c = 0, Mac48Address a = Mac48Address ()) : Tag(), seqno(s), cost(c) , address (a){}
///\name Inherited from Tag
//\{
static TypeId GetTypeId ();
TypeId GetInstanceTypeId () const;
uint32_t GetSerializedSize () const;
void Serialize (TagBuffer i) const;
void Deserialize (TagBuffer i);
void Print (std::ostream &os) const;
//\}
};
/**
* \ingroup flame
*