Flame: added correct seqno filtering, added broadcast timers
This commit is contained in:
@@ -96,7 +96,7 @@ FlameHeader::AddCost (uint8_t cost)
|
||||
m_cost = (((uint16_t)cost+ (uint16_t)m_cost ) > 255) ? 255 : cost + m_cost;
|
||||
}
|
||||
uint8_t
|
||||
FlameHeader::GetCost ()
|
||||
FlameHeader::GetCost () const
|
||||
{
|
||||
return m_cost;
|
||||
}
|
||||
@@ -106,7 +106,7 @@ FlameHeader::SetSeqno (uint16_t seqno)
|
||||
m_seqno = seqno;
|
||||
}
|
||||
uint16_t
|
||||
FlameHeader::GetSeqno ()
|
||||
FlameHeader::GetSeqno () const
|
||||
{
|
||||
return m_seqno;
|
||||
}
|
||||
@@ -116,7 +116,7 @@ FlameHeader::SetOrigDst (Mac48Address dst)
|
||||
m_origDst = dst;
|
||||
}
|
||||
Mac48Address
|
||||
FlameHeader::GetOrigDst ()
|
||||
FlameHeader::GetOrigDst () const
|
||||
{
|
||||
return m_origDst;
|
||||
}
|
||||
@@ -126,7 +126,7 @@ FlameHeader::SetOrigSrc (Mac48Address src)
|
||||
m_origSrc = src;
|
||||
}
|
||||
Mac48Address
|
||||
FlameHeader::GetOrigSrc ()
|
||||
FlameHeader::GetOrigSrc () const
|
||||
{
|
||||
return m_origSrc;
|
||||
}
|
||||
@@ -136,7 +136,7 @@ FlameHeader::SetProtocol (uint16_t protocol)
|
||||
m_protocol = protocol;
|
||||
}
|
||||
uint16_t
|
||||
FlameHeader::GetProtocol ()
|
||||
FlameHeader::GetProtocol () const
|
||||
{
|
||||
return m_protocol;
|
||||
}
|
||||
|
||||
@@ -57,15 +57,15 @@ public:
|
||||
* \{
|
||||
*/
|
||||
void AddCost (uint8_t cost);
|
||||
uint8_t GetCost ();
|
||||
uint8_t GetCost () const;
|
||||
void SetSeqno (uint16_t seqno);
|
||||
uint16_t GetSeqno ();
|
||||
uint16_t GetSeqno () const;
|
||||
void SetOrigDst (Mac48Address dst);
|
||||
Mac48Address GetOrigDst ();
|
||||
Mac48Address GetOrigDst () const;
|
||||
void SetOrigSrc (Mac48Address OrigSrc);
|
||||
Mac48Address GetOrigSrc ();
|
||||
Mac48Address GetOrigSrc () const;
|
||||
void SetProtocol (uint16_t protocol);
|
||||
uint16_t GetProtocol ();
|
||||
uint16_t GetProtocol () const;
|
||||
///\}
|
||||
private:
|
||||
uint8_t m_cost;
|
||||
|
||||
@@ -66,12 +66,6 @@ FlameProtocolMac::UpdateOutcomingFrame (Ptr<Packet> packet, WifiMacHeader & head
|
||||
header.SetAddr1 (tag.address);
|
||||
return true;
|
||||
}
|
||||
uint8_t
|
||||
FlameProtocolMac::GetCost(Mac48Address peerAddress) const
|
||||
{
|
||||
uint32_t metric = m_parent->GetLinkMetric(peerAddress);
|
||||
return (metric > 255 ? 255 : (uint8_t)(metric & 0xff));
|
||||
}
|
||||
uint16_t
|
||||
FlameProtocolMac::GetChannelId () const
|
||||
{
|
||||
|
||||
@@ -44,8 +44,6 @@ 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;
|
||||
|
||||
@@ -42,8 +42,8 @@ TypeId
|
||||
FlameTag::GetTypeId ()
|
||||
{
|
||||
static TypeId tid = TypeId ("ns3::flame::FlameTag")
|
||||
.SetParent<Tag> ()
|
||||
.AddConstructor<FlameTag> ();
|
||||
.SetParent<Tag> ()
|
||||
.AddConstructor<FlameTag> ();
|
||||
return tid;
|
||||
}
|
||||
|
||||
@@ -96,12 +96,18 @@ FlameProtocol::GetTypeId ()
|
||||
TimeValue (Seconds (5)),
|
||||
MakeTimeAccessor (&FlameProtocol::m_broadcastInterval),
|
||||
MakeTimeChecker ()
|
||||
)
|
||||
.AddAttribute ("MaxCost", "Cost threshold after which packet will be dropeed",
|
||||
UintegerValue (32),
|
||||
MakeUintegerAccessor (&FlameProtocol::m_maxCost),
|
||||
MakeUintegerChecker<uint8_t> (3)
|
||||
);
|
||||
return tid;
|
||||
}
|
||||
FlameProtocol::FlameProtocol () :
|
||||
m_broadcastInterval (Seconds (5)),
|
||||
m_lastBroadcast (Simulator::Now ()),
|
||||
m_maxCost (32),
|
||||
m_myLastSeqno (0),
|
||||
m_rtable (CreateObject<FlameRtable> ())
|
||||
{
|
||||
@@ -127,8 +133,11 @@ FlameProtocol::RequestRoute (uint32_t sourceIface, const Mac48Address source, c
|
||||
NS_FATAL_ERROR ("FLAME tag is not supposed to be received from upper layers");
|
||||
}
|
||||
FlameHeader flameHdr;
|
||||
//TODO: check when last broadcast was sent
|
||||
tag.address = m_rtable->Lookup(destination).retransmitter;
|
||||
if(tag.address == Mac48Address::GetBroadcast ())
|
||||
m_lastBroadcast = Simulator::Now ();
|
||||
if(m_lastBroadcast + m_broadcastInterval < Simulator::Now ())
|
||||
tag.address = Mac48Address::GetBroadcast ();
|
||||
flameHdr.AddCost (0);
|
||||
flameHdr.SetSeqno (m_myLastSeqno ++);
|
||||
flameHdr.SetProtocol (protocolType);
|
||||
@@ -150,7 +159,7 @@ FlameProtocol::RequestRoute (uint32_t sourceIface, const Mac48Address source, c
|
||||
if(destination == Mac48Address::GetBroadcast ())
|
||||
{
|
||||
//Broadcast always is forwarded as broadcast!
|
||||
NS_ASSERT (DropDataFrame(flameHdr.GetSeqno (), source));
|
||||
NS_ASSERT (HandleDataFrame(flameHdr.GetSeqno (), source, flameHdr, tag.address, sourceIface));
|
||||
FlameTag tag (Mac48Address::GetBroadcast ());
|
||||
flameHdr.AddCost (1);
|
||||
packet->AddHeader (flameHdr);
|
||||
@@ -160,9 +169,8 @@ FlameProtocol::RequestRoute (uint32_t sourceIface, const Mac48Address source, c
|
||||
}
|
||||
else
|
||||
{
|
||||
if(DropDataFrame(flameHdr.GetSeqno (), source))
|
||||
if(HandleDataFrame(flameHdr.GetSeqno (), source, flameHdr, tag.address, sourceIface))
|
||||
return false;
|
||||
m_rtable->AddPath (source, tag.address, sourceIface, flameHdr.GetCost (), flameHdr.GetSeqno ());
|
||||
FlameRtable::LookupResult result = m_rtable->Lookup(destination);
|
||||
if(tag.address != Mac48Address::GetBroadcast ())
|
||||
{
|
||||
@@ -193,16 +201,14 @@ FlameProtocol::RemoveRoutingStuff (uint32_t fromIface, const Mac48Address source
|
||||
FlameTag tag;
|
||||
if(!packet->RemovePacketTag (tag))
|
||||
{
|
||||
NS_FATAL_ERROR ("FLAME tag is not supposed to be received by network");
|
||||
NS_FATAL_ERROR ("FLAME tag must exist when packet is coming to protocol");
|
||||
}
|
||||
//TODO: send path update
|
||||
FlameHeader flameHdr;
|
||||
packet->RemoveHeader (flameHdr);
|
||||
NS_ASSERT(protocolType == FLAME_PORT);
|
||||
protocolType = flameHdr.GetProtocol ();
|
||||
if(DropDataFrame(flameHdr.GetSeqno (), source))
|
||||
return false;
|
||||
m_rtable->AddPath (source, tag.address, fromIface, flameHdr.GetCost (), flameHdr.GetSeqno ());
|
||||
return true;
|
||||
return (!HandleDataFrame(flameHdr.GetSeqno (), source, flameHdr, tag.address, fromIface));
|
||||
}
|
||||
bool
|
||||
FlameProtocol::Install (Ptr<MeshPointDevice> mp)
|
||||
@@ -235,15 +241,21 @@ FlameProtocol::GetAddress ()
|
||||
return m_address;
|
||||
}
|
||||
bool
|
||||
FlameProtocol::DropDataFrame(uint16_t seqno, Mac48Address source)
|
||||
FlameProtocol::HandleDataFrame (uint16_t seqno, Mac48Address source, const FlameHeader flameHdr, Mac48Address receiver, uint32_t fromInterface)
|
||||
{
|
||||
if(source == GetAddress ())
|
||||
return true;
|
||||
if (flameHdr.GetCost () > m_maxCost)
|
||||
return true;
|
||||
FlameRtable::LookupResult result = m_rtable->Lookup (source);
|
||||
if (result.retransmitter == Mac48Address::GetBroadcast ())
|
||||
{
|
||||
m_rtable->AddPath (source, receiver, fromInterface, flameHdr.GetCost (), flameHdr.GetSeqno ());
|
||||
return false;
|
||||
}
|
||||
if(result.seqnum >= seqno)
|
||||
return true;
|
||||
m_rtable->AddPath (source, receiver, fromInterface, flameHdr.GetCost (), flameHdr.GetSeqno ());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#define FLAME_PROTOCOL_H
|
||||
|
||||
#include "flame-protocol-mac.h"
|
||||
#include "flame-header.h"
|
||||
#include "flame-rtable.h"
|
||||
|
||||
#include "ns3/mesh-l2-routing-protocol.h"
|
||||
@@ -88,12 +89,11 @@ public:
|
||||
void ResetStats ();
|
||||
private:
|
||||
/**
|
||||
* \name Seqno filter:
|
||||
* \{
|
||||
* \brif Handles a packet: adds a routing information and drops
|
||||
* packets by TTL or Seqno
|
||||
* \returns true if packet shall be dropeed
|
||||
*/
|
||||
bool DropDataFrame (uint16_t seqno, Mac48Address source);
|
||||
std::map<Mac48Address, uint16_t> m_lastSeqno;
|
||||
///\}
|
||||
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
|
||||
@@ -110,6 +110,8 @@ private:
|
||||
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:
|
||||
|
||||
@@ -60,11 +60,11 @@ FlameRtable::DoDispose ()
|
||||
|
||||
void
|
||||
FlameRtable::AddPath (
|
||||
Mac48Address destination,
|
||||
Mac48Address retransmitter,
|
||||
uint32_t interface,
|
||||
uint8_t cost,
|
||||
uint16_t seqnum
|
||||
const Mac48Address destination,
|
||||
const Mac48Address retransmitter,
|
||||
const uint32_t interface,
|
||||
const uint8_t cost,
|
||||
const uint16_t seqnum
|
||||
)
|
||||
{
|
||||
std::map<Mac48Address, Route>::iterator i = m_routes.find (destination);
|
||||
@@ -79,6 +79,7 @@ FlameRtable::AddPath (
|
||||
m_routes[destination] = newroute;
|
||||
return;
|
||||
}
|
||||
i->second.seqnum = seqnum;
|
||||
NS_ASSERT (i != m_routes.end());
|
||||
if (i->second.cost < cost)
|
||||
return;
|
||||
@@ -86,7 +87,6 @@ FlameRtable::AddPath (
|
||||
i->second.interface = interface;
|
||||
i->second.cost = cost;
|
||||
i->second.whenExpire = Simulator::Now() + m_lifetime;
|
||||
i->second.seqnum = seqnum;
|
||||
}
|
||||
FlameRtable::LookupResult
|
||||
FlameRtable::Lookup (Mac48Address destination)
|
||||
|
||||
@@ -72,11 +72,11 @@ public:
|
||||
///\name Add/delete paths
|
||||
//\{
|
||||
void AddPath (
|
||||
Mac48Address destination,
|
||||
Mac48Address retransmitter,
|
||||
uint32_t interface,
|
||||
uint8_t cost,
|
||||
uint16_t seqnum
|
||||
const Mac48Address destination,
|
||||
const Mac48Address retransmitter,
|
||||
const uint32_t interface,
|
||||
const uint8_t cost,
|
||||
const uint16_t seqnum
|
||||
);
|
||||
/**
|
||||
* Lookup path to destination
|
||||
|
||||
Reference in New Issue
Block a user