Flame review

This commit is contained in:
Pavel Boyko
2009-06-22 14:39:25 +04:00
parent 6a3fcbce7c
commit 9941bfd7af
4 changed files with 42 additions and 29 deletions

View File

@@ -23,6 +23,11 @@
#define FLAME_STACK_INSTALLER_H
#include "ns3/mesh-stack-installer.h"
namespace ns3 {
/**
* \ingroup flame
*
* \brief FLAME mesh stack (actually single protocol in this stack)
*/
class FlameStack : public MeshStack
{
public:
@@ -31,7 +36,7 @@ class FlameStack : public MeshStack
~FlameStack ();
void DoDispose ();
///\brief Installs 802.11s stack. needed by helper only
/// Installs flame stack on given mesh point device.
bool InstallStack (Ptr<MeshPointDevice> mp);
void Report (const Ptr<MeshPointDevice> mp, std::ostream&);
void ResetStats (const Ptr<MeshPointDevice> mp);

View File

@@ -30,13 +30,14 @@
#include "ns3/mesh-wifi-interface-mac.h"
#include "ns3/random-variable.h"
NS_LOG_COMPONENT_DEFINE ("FlameProtocol");
namespace ns3 {
namespace flame {
//-----------------------------------------------------------------------------
// FlameTag
//-----------------------------------------------------------------------------
NS_OBJECT_ENSURE_REGISTERED (FlameTag);
NS_LOG_COMPONENT_DEFINE ("FlameProtocol");
TypeId
FlameTag::GetTypeId ()
@@ -92,7 +93,7 @@ FlameTag::Print (std::ostream &os) const
}
//-----------------------------------------------------------------------------
// FlameTag
// FlameProtocol
//-----------------------------------------------------------------------------
TypeId
FlameProtocol::GetTypeId ()
@@ -160,7 +161,7 @@ FlameProtocol::RequestRoute (uint32_t sourceIface, const Mac48Address source, c
tag.receiver = result.retransmitter;
NS_LOG_DEBUG("Source: send packet with RA = " << tag.receiver);
packet->AddPacketTag (tag);
routeReply (true, packet, source, destination, FLAME_PORT, result.ifIndex);
routeReply (true, packet, source, destination, FLAME_PROTOCOL, result.ifIndex);
}
else
{
@@ -188,7 +189,7 @@ FlameProtocol::RequestRoute (uint32_t sourceIface, const Mac48Address source, c
flameHdr.AddCost (1);
packet->AddHeader (flameHdr);
packet->AddPacketTag (tag);
routeReply (true, packet, source, destination, FLAME_PORT, FlameRtable::INTERFACE_ANY);
routeReply (true, packet, source, destination, FLAME_PROTOCOL, FlameRtable::INTERFACE_ANY);
return true;
}
else
@@ -210,7 +211,7 @@ FlameProtocol::RequestRoute (uint32_t sourceIface, const Mac48Address source, c
flameHdr.AddCost (1);
packet->AddHeader (flameHdr);
packet->AddPacketTag (tag);
routeReply (true, packet, source, destination, FLAME_PORT, result.ifIndex);
routeReply (true, packet, source, destination, FLAME_PROTOCOL, result.ifIndex);
return true;
}
return true;
@@ -235,7 +236,7 @@ FlameProtocol::RemoveRoutingStuff (uint32_t fromIface, const Mac48Address source
//TODO: send path update
FlameHeader flameHdr;
packet->RemoveHeader (flameHdr);
NS_ASSERT(protocolType == FLAME_PORT);
NS_ASSERT(protocolType == FLAME_PROTOCOL);
protocolType = flameHdr.GetProtocol ();
return (!HandleDataFrame(flameHdr.GetSeqno (), source, flameHdr, tag.transmitter, fromIface));
}

View File

@@ -28,18 +28,27 @@
#include "ns3/mesh-l2-routing-protocol.h"
#include "ns3/tag.h"
#include <map>
/**
* \ingroup mesh
* \defgroup flame FLAME
*
* \brief Forwarding LAyer for Meshing protocol
*
* TODO add relevant references
*/
namespace ns3 {
namespace flame {
/**
* \brief Seqno and TTL tag
* \ingroup flame
* \brief Transmitter and receiver addresses
*/
class FlameTag : public Tag
{
public:
//transmitter for incoming:
/// transmitter for incoming:
Mac48Address transmitter;
// Receiver of the packet:
/// Receiver of the packet:
Mac48Address receiver;
FlameTag (Mac48Address a = Mac48Address ()) :
@@ -58,10 +67,8 @@ public:
/**
* \ingroup flame
*
* \brief FLAME = Forwarding Layer for Meshing
* \brief FLAME routing protocol
*/
class FlameProtocol : public MeshL2RoutingProtocol
{
public:
@@ -82,41 +89,42 @@ public:
* Installing protocol cause installing its interface MAC plugins.
*
* Also MP aggregates all installed protocols, FLAME protocol can be accessed
* via MeshPointDevice::GetObject<dot11s::FlameProtocol>();
* via MeshPointDevice::GetObject<flame::FlameProtocol>();
*/
bool Install (Ptr<MeshPointDevice>);
Mac48Address GetAddress ();
///\brief Statistics:
/// Statistics
void Report (std::ostream &) const;
void ResetStats ();
private:
/// LLC protocol number reserved by flame
static const uint16_t FLAME_PROTOCOL = 0x4040;
/**
* \brif Handles a packet: adds a routing information and drops
* packets by TTL or Seqno
* \returns true if packet shall be dropeed
* \brief Handles a packet: adds a routing information and drops packets by TTL or Seqno
*
* \return true if packet shall be dropped
*/
bool HandleDataFrame (uint16_t seqno, Mac48Address source, const FlameHeader flameHdr, Mac48Address receiver, uint32_t fromIface);
static const uint16_t FLAME_PORT = 0x4040;
/**
* \name Information about MeshPointDeviceaddress , plugins
* \name Information about MeshPointDeviceaddress, plugins
* \{
*/
typedef std::map<uint32_t, Ptr<FlameProtocolMac> > FlamePluginMap;
FlamePluginMap m_interfaces;
Mac48Address m_address;
///\}
//\}
/**
* \name Broadcast timers:
* \{
*/
Time m_broadcastInterval;
Time m_lastBroadcast;
///\}
//\}
/// Max Cost value (or TTL, because cost is actually hopcount)
uint8_t m_maxCost;
/// Sequence number:
uint16_t m_myLastSeqno;
/// Routng table:
/// Routing table:
Ptr<FlameRtable> m_rtable;
};
} //namespace flame

View File

@@ -69,8 +69,7 @@ public:
~FlameRtable ();
void DoDispose ();
///\name Add/delete paths
//\{
/// Add path
void AddPath (
const Mac48Address destination,
const Mac48Address retransmitter,
@@ -79,8 +78,8 @@ public:
const uint16_t seqnum
);
/**
* Lookup path to destination
* \returns Broadcast if not found
* \brief Lookup path to destination
* \return Broadcast if not found
*/
LookupResult Lookup (Mac48Address destination);
private:
@@ -93,7 +92,7 @@ private:
Time whenExpire;
uint32_t seqnum;
};
/// Lifetime parameter:
/// Lifetime parameter
Time m_lifetime;
/// List of routes
std::map<Mac48Address, Route> m_routes;