diff --git a/src/devices/mesh/dot11s/dot11s-installer.h b/src/devices/mesh/dot11s/dot11s-installer.h index 09dfd76f6..62dff1748 100644 --- a/src/devices/mesh/dot11s/dot11s-installer.h +++ b/src/devices/mesh/dot11s/dot11s-installer.h @@ -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 { diff --git a/src/devices/mesh/flame/flame-protocol-mac.cc b/src/devices/mesh/flame/flame-protocol-mac.cc index 5b43b5002..9a9fa42f0 100644 --- a/src/devices/mesh/flame/flame-protocol-mac.cc +++ b/src/devices/mesh/flame/flame-protocol-mac.cc @@ -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 protocol): + m_protocol (protocol), + m_ifIndex (ifIndex) +{ +} +FlameMacPlugin::~FlameMacPlugin () +{ +} +void +FlameMacPlugin::SetParent (Ptr parent) +{ + m_parent = parent; +} + +bool +FlameMacPlugin::Receive (Ptr 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, 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 diff --git a/src/devices/mesh/flame/flame-protocol-mac.h b/src/devices/mesh/flame/flame-protocol-mac.h index a221494e1..fc98bba2f 100644 --- a/src/devices/mesh/flame/flame-protocol-mac.h +++ b/src/devices/mesh/flame/flame-protocol-mac.h @@ -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 m_protocol; + uint32_t m_ifIndex; + Ptr m_parent; + ///\} }; } //namespace flame } //namespace ns3 diff --git a/src/devices/mesh/flame/flame-protocol.cc b/src/devices/mesh/flame/flame-protocol.cc index 34251015b..cccb7d875 100644 --- a/src/devices/mesh/flame/flame-protocol.cc +++ b/src/devices/mesh/flame/flame-protocol.cc @@ -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 () + .AddConstructor (); + 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 diff --git a/src/devices/mesh/flame/flame-protocol.h b/src/devices/mesh/flame/flame-protocol.h index 316346477..0705b83d5 100644 --- a/src/devices/mesh/flame/flame-protocol.h +++ b/src/devices/mesh/flame/flame-protocol.h @@ -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 *