HWMP rolled to "initial position"

This commit is contained in:
Kirill Andreev
2009-03-25 23:19:27 +03:00
parent 1037c32158
commit 74747fc24e
5 changed files with 149 additions and 291 deletions

View File

@@ -19,25 +19,26 @@
*/
#include "ns3/hwmp-state.h"
#include "hwmp-mac-plugin.h"
#include "ns3/simulator.h"
#include "ns3/nstime.h"
#include "ns3/log.h"
namespace ns3 {
namespace dot11s {
NS_LOG_COMPONENT_DEFINE ("HwmpState");
NS_LOG_COMPONENT_DEFINE ("HwmpMacPlugin");
TypeId
HwmpState::GetTypeId ()
HwmpMacPlugin::GetTypeId ()
{
static TypeId tid = TypeId ("ns3::HwmpState")
static TypeId tid = TypeId ("ns3::HwmpMacPlugin")
.SetParent<Object> ()
.AddConstructor<HwmpState> ()
.AddConstructor<HwmpMacPlugin> ()
;
return tid;
}
HwmpState::HwmpState ():
HwmpMacPlugin::HwmpMacPlugin ():
m_myPreq (m_preqQueue.end()),
m_preqId (1),
m_myDsn (1),
@@ -46,14 +47,14 @@ HwmpState::HwmpState ():
{
}
void
HwmpState::SetRequestRouteCallback (
HwmpMacPlugin::SetRequestRouteCallback (
Callback<HwmpRtable::LookupResult, const Mac48Address&> cb)
{
m_requestRouteCallback = cb;
}
void
HwmpState::SetRequestRootPathCallback (
HwmpMacPlugin::SetRequestRootPathCallback (
Callback<HwmpRtable::LookupResult, uint32_t> cb)
{
m_requestRootPathCallback = cb;
@@ -61,24 +62,24 @@ HwmpState::SetRequestRootPathCallback (
//Setting MAC
void
HwmpState::SetMac (Ptr<MeshWifiMac> mac)
HwmpMacPlugin::SetMac (Ptr<MeshWifiMac> mac)
{
mac->SetPeerStatusCallback (MakeCallback(&HwmpState::PeerStatus, this));
mac->SetPreqReceivedCallback (MakeCallback(&HwmpState::ReceivePreq, this));
mac->SetPrepReceivedCallback (MakeCallback(&HwmpState::ReceivePrep, this));
mac->SetPerrReceivedCallback (MakeCallback(&HwmpState::ReceivePerr, this));
mac->SetPeerStatusCallback (MakeCallback(&HwmpMacPlugin::PeerStatus, this));
mac->SetPreqReceivedCallback (MakeCallback(&HwmpMacPlugin::ReceivePreq, this));
mac->SetPrepReceivedCallback (MakeCallback(&HwmpMacPlugin::ReceivePrep, this));
mac->SetPerrReceivedCallback (MakeCallback(&HwmpMacPlugin::ReceivePerr, this));
m_address = mac->GetAddress ();
m_preqCallback = MakeCallback (&MeshWifiMac::SendPreq, mac);
m_prepCallback = MakeCallback (&MeshWifiMac::SendPrep, mac);
m_perrCallback = MakeCallback (&MeshWifiMac::SendPerr, mac);
}
HwmpState::~HwmpState ()
HwmpMacPlugin::~HwmpMacPlugin ()
{
m_preqQueue.clear ();
}
//Interaction with HWMP:
void
HwmpState::SetRoutingInfoCallback (
HwmpMacPlugin::SetRoutingInfoCallback (
Callback<void, INFO> cb
)
{
@@ -86,14 +87,14 @@ HwmpState::SetRoutingInfoCallback (
}
void
HwmpState::SetRetransmittersOfPerrCallback (
HwmpMacPlugin::SetRetransmittersOfPerrCallback (
Callback<std::vector<Mac48Address>, std::vector<HwmpRtable::FailedDestination>, uint32_t> cb)
{
m_retransmittersOfPerrCallback = cb;
}
void
HwmpState::RequestDestination (Mac48Address dst)
HwmpMacPlugin::RequestDestination (Mac48Address dst)
{
if (m_preqQueue.end () == m_myPreq)
{
@@ -122,7 +123,7 @@ HwmpState::RequestDestination (Mac48Address dst)
NS_LOG_DEBUG ("Send PREQ now, "<<preq.GetPreqID()<<" destinations, now is "<<Simulator::Now());
m_preqCallback (preq);
NS_ASSERT (!m_preqTimer.IsRunning());
m_preqTimer = Simulator::Schedule (dot11sParameters::dot11MeshHWMPpreqMinInterval, &HwmpState::SendOnePreq, this);
m_preqTimer = Simulator::Schedule (dot11sParameters::dot11MeshHWMPpreqMinInterval, &HwmpMacPlugin::SendOnePreq, this);
}
}
else
@@ -133,7 +134,7 @@ HwmpState::RequestDestination (Mac48Address dst)
}
}
void
HwmpState::SendPathError (std::vector<HwmpRtable::FailedDestination> destinations)
HwmpMacPlugin::SendPathError (std::vector<HwmpRtable::FailedDestination> destinations)
{
std::vector<Mac48Address> receivers = m_retransmittersOfPerrCallback (destinations, m_ifIndex);
NS_LOG_DEBUG ("SendPathError started");
@@ -155,25 +156,25 @@ HwmpState::SendPathError (std::vector<HwmpRtable::FailedDestination> destination
{
m_perrCallback (m_myPerr,m_myPerrReceivers);
m_myPerr.ResetPerr ();
m_perrTimer = Simulator::Schedule (dot11sParameters::dot11MeshHWMPperrMinInterval,&HwmpState::SendOnePerr,this);
m_perrTimer = Simulator::Schedule (dot11sParameters::dot11MeshHWMPperrMinInterval,&HwmpMacPlugin::SendOnePerr,this);
}
}
//needed to fill routing information structure
void
HwmpState::SetAssociatedIfaceId (uint32_t interface)
HwmpMacPlugin::SetAssociatedIfaceId (uint32_t interface)
{
m_ifIndex = interface;
}
uint32_t
HwmpState::GetAssociatedIfaceId ()
HwmpMacPlugin::GetAssociatedIfaceId ()
{
return m_ifIndex;
}
//Interaction with MAC:
void
HwmpState::ReceivePreq (IeDot11sPreq& preq, const Mac48Address& from, const uint32_t& metric)
HwmpMacPlugin::ReceivePreq (IeDot11sPreq& preq, const Mac48Address& from, const uint32_t& metric)
{
if (m_disabled)
return;
@@ -307,12 +308,12 @@ HwmpState::ReceivePreq (IeDot11sPreq& preq, const Mac48Address& from, const uin
{
m_preqCallback (preq);
NS_ASSERT (!m_preqTimer.IsRunning());
m_preqTimer = Simulator::Schedule (dot11sParameters::dot11MeshHWMPpreqMinInterval, &HwmpState::SendOnePreq, this);
m_preqTimer = Simulator::Schedule (dot11sParameters::dot11MeshHWMPpreqMinInterval, &HwmpMacPlugin::SendOnePreq, this);
}
}
void
HwmpState::ReceivePrep (IeDot11sPrep& prep, const Mac48Address& from, const uint32_t& metric)
HwmpMacPlugin::ReceivePrep (IeDot11sPrep& prep, const Mac48Address& from, const uint32_t& metric)
{
if (m_disabled)
return;
@@ -357,7 +358,7 @@ HwmpState::ReceivePrep (IeDot11sPrep& prep, const Mac48Address& from, const uint
}
void
HwmpState::ReceivePerr (IeDot11sPerr& perr, const Mac48Address& from)
HwmpMacPlugin::ReceivePerr (IeDot11sPerr& perr, const Mac48Address& from)
{
if (m_disabled)
return;
@@ -387,7 +388,7 @@ HwmpState::ReceivePerr (IeDot11sPerr& perr, const Mac48Address& from)
}
void
HwmpState::PeerStatus (const Mac48Address peerAddress, const bool status, const uint32_t metric)
HwmpMacPlugin::PeerStatus (const Mac48Address peerAddress, const bool status, const uint32_t metric)
{
INFO newInfo;
newInfo.me = m_address;
@@ -404,7 +405,7 @@ HwmpState::PeerStatus (const Mac48Address peerAddress, const bool status, const
}
bool
HwmpState::SetRoot ()
HwmpMacPlugin::SetRoot ()
{
#if 0
//TODO:: delete this lines!!!!!!!
@@ -412,12 +413,12 @@ HwmpState::SetRoot ()
return false;
//TODO
#endif
Simulator::Schedule (dot11sParameters::dot11MeshHWMPactiveRootTimeout, &HwmpState::SendProactivePreq, this);
Simulator::Schedule (dot11sParameters::dot11MeshHWMPactiveRootTimeout, &HwmpMacPlugin::SendProactivePreq, this);
return true;
}
void
HwmpState::SendProactivePreq ()
HwmpMacPlugin::SendProactivePreq ()
{
NS_LOG_DEBUG ("Sending proactive PREQ");
IeDot11sPreq preq;
@@ -444,13 +445,13 @@ HwmpState::SendProactivePreq ()
NS_LOG_DEBUG ("Send now "<<preq.GetPreqID());
m_preqCallback (preq);
NS_ASSERT (!m_preqTimer.IsRunning());
m_preqTimer = Simulator::Schedule (dot11sParameters::dot11MeshHWMPpreqMinInterval, &HwmpState::SendOnePreq, this);
m_preqTimer = Simulator::Schedule (dot11sParameters::dot11MeshHWMPpreqMinInterval, &HwmpMacPlugin::SendOnePreq, this);
}
Simulator::Schedule (dot11sParameters::dot11MeshHWMPactiveRootTimeout, &HwmpState::SendProactivePreq, this);
Simulator::Schedule (dot11sParameters::dot11MeshHWMPactiveRootTimeout, &HwmpMacPlugin::SendProactivePreq, this);
}
void
HwmpState::AddPerrReceiver (Mac48Address receiver)
HwmpMacPlugin::AddPerrReceiver (Mac48Address receiver)
{
/**
* add new vector of addresses to m_perrReceiversand check
@@ -463,30 +464,30 @@ HwmpState::AddPerrReceiver (Mac48Address receiver)
}
void
HwmpState::UnSetRoot ()
HwmpMacPlugin::UnSetRoot ()
{
}
void
HwmpState::Disable ()
HwmpMacPlugin::Disable ()
{
m_disabled = true;
}
void
HwmpState::Enable ()
HwmpMacPlugin::Enable ()
{
m_disabled = false;
}
Mac48Address
HwmpState::GetAddress ()
HwmpMacPlugin::GetAddress ()
{
return m_address;
}
void
HwmpState::SendOnePreq ()
HwmpMacPlugin::SendOnePreq ()
{
if (m_preqQueue.size () == 0)
return;
@@ -504,11 +505,11 @@ HwmpState::SendOnePreq ()
m_preqQueue.erase (m_preqQueue.begin());
//reschedule sending PREQ
NS_ASSERT (!m_preqTimer.IsRunning());
m_preqTimer = Simulator::Schedule (dot11sParameters::dot11MeshHWMPpreqMinInterval, &HwmpState::SendOnePreq, this);
m_preqTimer = Simulator::Schedule (dot11sParameters::dot11MeshHWMPpreqMinInterval, &HwmpMacPlugin::SendOnePreq, this);
}
void
HwmpState::SendPrep (Mac48Address dst,
HwmpMacPlugin::SendPrep (Mac48Address dst,
Mac48Address src,
Mac48Address retransmitter,
uint32_t initMetric,
@@ -529,11 +530,12 @@ HwmpState::SendPrep (Mac48Address dst,
}
void
HwmpState::SendOnePerr ()
HwmpMacPlugin::SendOnePerr ()
{
if (m_myPerr.GetNumOfDest () == 0)
return;
m_perrCallback (m_myPerr, m_myPerrReceivers);
m_myPerr.ResetPerr ();
}
} //namespace dot11s
}//namespace ns3

View File

@@ -22,15 +22,18 @@
#ifndef HWMP_STATE_H
#define HWMP_STATE_H
#include <map>
#include "ns3/hwmp-rtable.h"
#include "ns3/mesh-wifi-interface-mac-plugin.h"
#include "hwmp-rtable.h"
#include "ns3/packet.h"
#include "ns3/mesh-wifi-mac.h"
#include "ns3/ie-dot11s-preq.h"
#include "ns3/ie-dot11s-prep.h"
#include "ns3/ie-dot11s-perr.h"
#include "ie-dot11s-preq.h"
#include "ie-dot11s-prep.h"
#include "ie-dot11s-perr.h"
#include "ns3/dot11s-parameters.h"
#include "ns3/wifi-net-device.h"
namespace ns3 {
namespace dot11s {
/**
* \ingroup mesh
*
@@ -43,11 +46,11 @@ namespace ns3 {
* 3. Deliver routing information to Hwmp main class
* 4. Notify about broken peers
*/
class HwmpState : public Object {
class HwmpMacPlugin : public MeshWifiInterfaceMacPlugin {
public:
static TypeId GetTypeId ();
HwmpState ();
~HwmpState ();
HwmpMacPlugin ();
~HwmpMacPlugin ();
/**
* \brief Interface with HWMP - Hwmp can only
@@ -175,5 +178,6 @@ private:
//Configurable parameters:
uint8_t m_maxTtl;
};
} //namespace dot11s
} //namespace ns3
#endif

View File

@@ -16,162 +16,44 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Authors: Kirill Andreev <andreev@iitp.ru>
* Aleksey Kovalenko <kovalenko@iitp.ru>
* Pavel Boyko <boyko@iitp.ru>
*/
#include "ns3/hwmp.h"
#include "hwmp-protocol.h"
#include "ns3/log.h"
#include "ns3/simulator.h"
#include "ns3/mesh-point-device.h"
NS_LOG_COMPONENT_DEFINE ("Hwmp");
NS_LOG_COMPONENT_DEFINE ("HwmpProtocol");
namespace ns3 {
namespace dot11s {
NS_OBJECT_ENSURE_REGISTERED (Hwmp);
NS_OBJECT_ENSURE_REGISTERED (HwmpTag);
//Class HwmpTag:
HwmpTag::HwmpTag ()
{
}
HwmpTag::~HwmpTag ()
{
}
void
HwmpTag::SetAddress (Mac48Address retransmitter)
{
m_address = retransmitter;
}
Mac48Address
HwmpTag::GetAddress ()
{
return m_address;
}
void
HwmpTag::SetTtl (uint8_t ttl)
{
m_ttl = ttl;
}
uint8_t
HwmpTag::GetTtl ()
{
return m_ttl;
}
void
HwmpTag::SetMetric (uint32_t metric)
{
m_metric = metric;
}
uint32_t
HwmpTag::GetMetric ()
{
return m_metric;
}
void
HwmpTag::SetSeqno (uint32_t seqno)
{
m_seqno = seqno;
}
uint32_t
HwmpTag::GetSeqno ()
{
return m_seqno;
}
TypeId
HwmpTag::GetTypeId ()
{
static TypeId tid = TypeId ("ns3::HwmpTag")
.SetParent<Tag> ()
.AddConstructor<HwmpTag> ()
;
return tid;
}
TypeId
HwmpTag::GetInstanceTypeId () const
{
return GetTypeId ();
}
uint32_t
HwmpTag::GetSerializedSize () const
{
return 6 //address
+1 //ttl
+4; //metric
}
void
HwmpTag::Serialize (TagBuffer i) const
{
uint8_t address[6];
int j;
m_address.CopyTo (address);
i.WriteU8 (m_ttl);
i.WriteU32 (m_metric);
for (j = 0; j < 6; j ++)
i.WriteU8 (address[j]);
}
void
HwmpTag::Deserialize (TagBuffer i)
{
uint8_t address[6];
int j;
m_ttl = i.ReadU8 ();
m_metric = i.ReadU32 ();
for (j = 0; j < 6; j ++)
address[j] = i.ReadU8 ();
m_address.CopyFrom (address);
}
void
HwmpTag::Print (std::ostream &os) const
{
os << "address=" << m_address;
os << "ttl=" << m_ttl;
os << "metrc=" << m_metric;
}
void
HwmpTag::DecrementTtl ()
{
m_ttl --;
}
NS_OBJECT_ENSURE_REGISTERED (HwmpProtocol);
//Class HWMP:
TypeId
Hwmp::GetTypeId ()
HwmpProtocol::GetTypeId ()
{
static TypeId tid = TypeId ("ns3::Hwmp")
static TypeId tid = TypeId ("ns3::HwmpProtocol")
.SetParent<MeshL2RoutingProtocol> ()
.AddConstructor<Hwmp> ();
.AddConstructor<HwmpProtocol> ();
return tid;
}
Hwmp::Hwmp ():
m_rtable (CreateObject<HwmpRtable> ()),
m_maxTtl (32),
m_broadcastPerr (false)
HwmpProtocol::HwmpProtocol ()//:
// m_rtable (CreateObject<HwmpRtable> ()),
// m_maxTtl (32),
// m_broadcastPerr (false)
{
}
Hwmp::~Hwmp ()
HwmpProtocol::~HwmpProtocol ()
{
}
void
Hwmp::DoDispose ()
HwmpProtocol::DoDispose ()
{
#if 0
for (std::map<Mac48Address, EventId>::iterator i = m_timeoutDatabase.begin (); i != m_timeoutDatabase.end(); i ++)
i->second.Cancel ();
m_timeoutDatabase.clear ();
@@ -201,10 +83,11 @@ Hwmp::DoDispose ()
for (unsigned int i = 0; i < m_hwmpStates.size (); i ++)
m_hwmpStates[i] = 0;
m_hwmpStates.clear ();
#endif
}
bool
Hwmp::RequestRoute (
HwmpProtocol::RequestRoute (
uint32_t sourceIface,
const Mac48Address source,
const Mac48Address destination,
@@ -213,8 +96,9 @@ Hwmp::RequestRoute (
MeshL2RoutingProtocol::RouteReplyCallback routeReply
)
{
#if 0
HwmpRtable::LookupResult result;
HwmpTag tag;
HwmpProtocolTag tag;
if (sourceIface == GetMeshPoint ()->GetIfIndex())
// packet from level 3
{
@@ -343,11 +227,13 @@ Hwmp::RequestRoute (
result.ifIndex
);
}
#endif
return true;
}
bool
Hwmp::AttachPorts (std::vector<Ptr<NetDevice> > ports)
HwmpProtocol::AttachPorts (std::vector<Ptr<NetDevice> > ports)
{
#if 0
for (std::vector<Ptr<NetDevice> >::iterator i = ports.begin (); i != ports.end(); i++)
{
//Checking netdevice:
@@ -358,30 +244,31 @@ Hwmp::AttachPorts (std::vector<Ptr<NetDevice> > ports)
if (meshWifiMac == NULL)
return false;
//Adding HWMP-state
Ptr<HwmpState> hwmpState = CreateObject<HwmpState> ();
hwmpState->SetRoutingInfoCallback (MakeCallback(&Hwmp::ObtainRoutingInformation, this));
Ptr<HwmpProtocolState> hwmpState = CreateObject<HwmpProtocolState> ();
hwmpState->SetRoutingInfoCallback (MakeCallback(&HwmpProtocol::ObtainRoutingInformation, this));
hwmpState->SetMac (meshWifiMac);
hwmpState->SetRequestRouteCallback (MakeCallback(&Hwmp::RequestRouteForAddress, this));
hwmpState->SetRequestRootPathCallback (MakeCallback(&Hwmp::RequestRootPathForPort, this));
hwmpState->SetRequestRouteCallback (MakeCallback(&HwmpProtocol::RequestRouteForAddress, this));
hwmpState->SetRequestRootPathCallback (MakeCallback(&HwmpProtocol::RequestRootPathForPort, this));
hwmpState->SetAssociatedIfaceId (wifiNetDev->GetIfIndex());
hwmpState->SetRetransmittersOfPerrCallback (MakeCallback(&Hwmp::GetRetransmittersForFailedDestinations,this));
hwmpState->SetRetransmittersOfPerrCallback (MakeCallback(&HwmpProtocol::GetRetransmittersForFailedDestinations,this));
m_hwmpStates.push_back (hwmpState);
m_requestCallback.push_back (MakeCallback(&HwmpState::RequestDestination, hwmpState));
m_pathErrorCallback.push_back (MakeCallback(&HwmpState::SendPathError, hwmpState));
m_requestCallback.push_back (MakeCallback(&HwmpProtocolState::RequestDestination, hwmpState));
m_pathErrorCallback.push_back (MakeCallback(&HwmpProtocolState::SendPathError, hwmpState));
//Default mode is reactive, default state is enabled
enum DeviceState state = ENABLED;
enum DeviceMode mode = REACTIVE;
m_states.push_back (state);
m_modes.push_back (mode);
}
#endif
return true;
}
#if 0
void
Hwmp::DisablePort (uint32_t port)
HwmpProtocol::DisablePort (uint32_t port)
{
int position = 0;
for (std::vector<Ptr<HwmpState> >::iterator i = m_hwmpStates.begin (); i != m_hwmpStates.end(); i++)
for (std::vector<Ptr<HwmpProtocolState> >::iterator i = m_hwmpStates.begin (); i != m_hwmpStates.end(); i++)
{
if ((*i)->GetAssociatedIfaceId () == port)
{
@@ -394,10 +281,10 @@ Hwmp::DisablePort (uint32_t port)
}
void
Hwmp::EnablePort (uint32_t port)
HwmpProtocol::EnablePort (uint32_t port)
{
int position = 0;
for (std::vector<Ptr<HwmpState> >::iterator i = m_hwmpStates.begin (); i != m_hwmpStates.end(); i++)
for (std::vector<Ptr<HwmpProtocolState> >::iterator i = m_hwmpStates.begin (); i != m_hwmpStates.end(); i++)
{
if ((*i)->GetAssociatedIfaceId () == port)
{
@@ -410,10 +297,10 @@ Hwmp::EnablePort (uint32_t port)
}
void
Hwmp::SetRoot (uint32_t port)
HwmpProtocol::SetRoot (uint32_t port)
{
int position = 0;
for (std::vector<Ptr<HwmpState> >::iterator i = m_hwmpStates.begin (); i != m_hwmpStates.end(); i++)
for (std::vector<Ptr<HwmpProtocolState> >::iterator i = m_hwmpStates.begin (); i != m_hwmpStates.end(); i++)
{
if (((*i)->GetAssociatedIfaceId () == port)||(port == HwmpRtable::PORT_ANY))
{
@@ -427,10 +314,10 @@ Hwmp::SetRoot (uint32_t port)
}
}
void
Hwmp::SetProactive (uint32_t port)
HwmpProtocol::SetProactive (uint32_t port)
{
int position = 0;
for (std::vector<Ptr<HwmpState> >::iterator i = m_hwmpStates.begin (); i != m_hwmpStates.end(); i++)
for (std::vector<Ptr<HwmpProtocolState> >::iterator i = m_hwmpStates.begin (); i != m_hwmpStates.end(); i++)
{
if ((*i)->GetAssociatedIfaceId () == port)
{
@@ -441,10 +328,10 @@ Hwmp::SetProactive (uint32_t port)
}
}
bool
Hwmp::IsRoot (uint32_t port)
HwmpProtocol::IsRoot (uint32_t port)
{
int position = 0;
for (std::vector<Ptr<HwmpState> >::iterator i = m_hwmpStates.begin (); i != m_hwmpStates.end(); i++)
for (std::vector<Ptr<HwmpProtocolState> >::iterator i = m_hwmpStates.begin (); i != m_hwmpStates.end(); i++)
{
if ((*i)->GetAssociatedIfaceId () == port)
if (m_modes[position] == ROOT)
@@ -454,10 +341,10 @@ Hwmp::IsRoot (uint32_t port)
return false;
}
void
Hwmp::UnSetRoot (uint32_t port)
HwmpProtocol::UnSetRoot (uint32_t port)
{
int position = 0;
for (std::vector<Ptr<HwmpState> >::iterator i = m_hwmpStates.begin (); i != m_hwmpStates.end(); i++)
for (std::vector<Ptr<HwmpProtocolState> >::iterator i = m_hwmpStates.begin (); i != m_hwmpStates.end(); i++)
{
if (((*i)->GetAssociatedIfaceId () == port)||(port == HwmpRtable::PORT_ANY))
{
@@ -469,13 +356,13 @@ Hwmp::UnSetRoot (uint32_t port)
}
void
Hwmp::ObtainRoutingInformation (
HwmpState::INFO info
HwmpProtocol::ObtainRoutingInformation (
HwmpProtocolState::INFO info
)
{
switch (info.type)
{
case HwmpState::INFO_PREP:
case HwmpProtocolState::INFO_PREP:
if (info.me != info.source)
{
m_rtable->AddPrecursor (info.source, info.outPort, info.nextHop);
@@ -483,7 +370,7 @@ Hwmp::ObtainRoutingInformation (
NS_LOG_DEBUG ("path to "<<info.source<<" precursor is "<<info.nextHop);
NS_LOG_DEBUG ("path to "<<info.destination<<" precursor is "<<info.prevHop);
}
case HwmpState::INFO_PREQ:
case HwmpProtocolState::INFO_PREQ:
m_rtable->AddReactivePath (
info.destination,
info.nextHop,
@@ -493,9 +380,9 @@ Hwmp::ObtainRoutingInformation (
info.dsn);
SendAllPossiblePackets (info.destination);
break;
case HwmpState::INFO_PERR:
case HwmpProtocolState::INFO_PERR:
//delete first subentry
case HwmpState::INFO_PROACTIVE:
case HwmpProtocolState::INFO_PROACTIVE:
//add information to the root MP.
m_rtable->AddProactivePath (
info.metric,
@@ -507,7 +394,7 @@ Hwmp::ObtainRoutingInformation (
//Set mode as PROACTIVE:
SetProactive (info.outPort);
break;
case HwmpState::INFO_NEW_PEER:
case HwmpProtocolState::INFO_NEW_PEER:
#if 0
m_rtable->AddReactivePath (
info.destination,
@@ -518,7 +405,7 @@ Hwmp::ObtainRoutingInformation (
0);
#endif
break;
case HwmpState::INFO_FAILED_PEER:
case HwmpProtocolState::INFO_FAILED_PEER:
/**
* Conditions for generating PERR
*/
@@ -542,19 +429,19 @@ Hwmp::ObtainRoutingInformation (
}
HwmpRtable::LookupResult
Hwmp::RequestRouteForAddress (const Mac48Address& dst)
HwmpProtocol::RequestRouteForAddress (const Mac48Address& dst)
{
return m_rtable->LookupReactive (dst);
}
HwmpRtable::LookupResult
Hwmp::RequestRootPathForPort (uint32_t port)
HwmpProtocol::RequestRootPathForPort (uint32_t port)
{
return m_rtable->LookupProactive (port);
}
void
Hwmp::StartPathErrorProcedure (std::vector<HwmpRtable::FailedDestination> destinations, uint32_t port)
HwmpProtocol::StartPathErrorProcedure (std::vector<HwmpRtable::FailedDestination> destinations, uint32_t port)
{
NS_LOG_DEBUG ("START PERR");
for (unsigned int i = 0; i < m_hwmpStates.size (); i++)
@@ -562,7 +449,7 @@ Hwmp::StartPathErrorProcedure (std::vector<HwmpRtable::FailedDestination> destin
m_pathErrorCallback[i] (destinations);
}
std::vector<Mac48Address>
Hwmp::GetRetransmittersForFailedDestinations (std::vector<HwmpRtable::FailedDestination> failedDest, uint32_t port)
HwmpProtocol::GetRetransmittersForFailedDestinations (std::vector<HwmpRtable::FailedDestination> failedDest, uint32_t port)
{
std::vector<Mac48Address> retransmitters;
if (m_broadcastPerr)
@@ -587,25 +474,27 @@ Hwmp::GetRetransmittersForFailedDestinations (std::vector<HwmpRtable::FailedDest
}
return retransmitters;
}
#endif
void
Hwmp::SetMaxQueueSize (int maxPacketsPerDestination)
HwmpProtocol::SetMaxQueueSize (int maxPacketsPerDestination)
{
m_maxQueueSize = maxPacketsPerDestination;
}
bool
Hwmp::QueuePacket (MeshL2RoutingProtocol::QueuedPacket packet)
HwmpProtocol::QueuePacket (MeshL2RoutingProtocol::QueuedPacket packet)
{
#if 0
if ((int)m_rqueue[packet.dst].size () > m_maxQueueSize)
return false;
m_rqueue[packet.dst].push (packet);
#endif
return true;
}
MeshL2RoutingProtocol::QueuedPacket
Hwmp::DequeuePacket (Mac48Address dst)
HwmpProtocol::DequeuePacket (Mac48Address dst)
{
MeshL2RoutingProtocol::QueuedPacket retval;
#if 0
retval.pkt = NULL;
//Ptr<Packet> in this structure is NULL when queue is empty
std::map<Mac48Address, std::queue<QueuedPacket> >:: iterator i = m_rqueue.find (dst);
@@ -620,12 +509,13 @@ Hwmp::DequeuePacket (Mac48Address dst)
}
retval = m_rqueue[dst].front ();
m_rqueue[dst].pop ();
#endif
return retval;
}
void
Hwmp::SendAllPossiblePackets (Mac48Address dst)
HwmpProtocol::SendAllPossiblePackets (Mac48Address dst)
{
#if 0
HwmpRtable::LookupResult result = m_rtable->LookupReactive (dst);
MeshL2RoutingProtocol::QueuedPacket packet;
while (1)
@@ -635,7 +525,7 @@ Hwmp::SendAllPossiblePackets (Mac48Address dst)
if (packet.pkt == NULL)
return;
//set RA tag for retransmitter:
HwmpTag tag;
HwmpProtocolTag tag;
NS_ASSERT (packet.pkt->FindFirstMatchingTag(tag));
tag.SetAddress (result.retransmitter);
NS_ASSERT (result.retransmitter != Mac48Address::GetBroadcast());
@@ -643,23 +533,24 @@ Hwmp::SendAllPossiblePackets (Mac48Address dst)
packet.pkt->AddTag (tag);
packet.reply (true, packet.pkt, packet.src, packet.dst, packet.protocol, result.ifIndex);
}
#endif
}
#if 0
bool
Hwmp::ShouldSendPreq (Mac48Address dst)
HwmpProtocol::ShouldSendPreq (Mac48Address dst)
{
std::map<Mac48Address, EventId>::iterator i = m_timeoutDatabase.find (dst);
if (i == m_timeoutDatabase.end ())
{
m_timeoutDatabase[dst] = Simulator::Schedule (
MilliSeconds (2*(dot11sParameters::dot11MeshHWMPnetDiameterTraversalTime.GetMilliSeconds())),
&Hwmp::RetryPathDiscovery, this, dst, 0);
&HwmpProtocol::RetryPathDiscovery, this, dst, 0);
return true;
}
return false;
}
void
Hwmp::RetryPathDiscovery (Mac48Address dst, uint8_t numOfRetry)
HwmpProtocol::RetryPathDiscovery (Mac48Address dst, uint8_t numOfRetry)
{
HwmpRtable::LookupResult result = m_rtable->LookupReactive (dst);
if (result.retransmitter != Mac48Address::GetBroadcast ())
@@ -691,6 +582,8 @@ Hwmp::RetryPathDiscovery (Mac48Address dst, uint8_t numOfRetry)
m_requestCallback[i] (dst);
m_timeoutDatabase[dst] = Simulator::Schedule (
MilliSeconds (2*(dot11sParameters::dot11MeshHWMPnetDiameterTraversalTime.GetMilliSeconds())),
&Hwmp::RetryPathDiscovery, this, dst, numOfRetry);
&HwmpProtocol::RetryPathDiscovery, this, dst, numOfRetry);
}
#endif
} //namespace dot11s
} //namespace ns3

View File

@@ -16,8 +16,6 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Authors: Kirill Andreev <andreev@iitp.ru>
* Aleksey Kovalenko <kovalenko@iitp.ru>
* Pavel Boyko <boyko@iitp.ru>
*/
@@ -27,66 +25,21 @@
#include <map>
#include <queue>
#include "ns3/tag.h"
#include "ns3/object.h"
#include "ns3/mac48-address.h"
#include "ns3/mesh-l2-routing-protocol.h"
#include "ns3/packet.h"
#include "ns3/hwmp-state.h"
namespace ns3 {
class HwmpState;
/**
* \ingroup mesh
*
* \brief Hwmp tag implements interaction between HWMP
* protocol and MeshWifiMac
*
* \details Hwmp tag keeps the following:
* 1. When packet is passed from Hwmp to 11sMAC:
* - retransmitter address,
* - TTL value,
* 2. When packet is passed to Hwmp from 11sMAC:
* - lasthop address,
* - TTL value,
* - metric value (metric of link is recalculated
* at each packet, but routing table stores metric
* obtained during path discovery procedure)
*/
class HwmpTag : public Tag
{
public:
HwmpTag ();
~HwmpTag ();
void SetAddress (Mac48Address retransmitter);
Mac48Address GetAddress ();
void SetTtl (uint8_t ttl);
uint8_t GetTtl ();
void SetMetric (uint32_t metric);
uint32_t GetMetric ();
void SetSeqno (uint32_t seqno);
uint32_t GetSeqno ();
void DecrementTtl ();
static TypeId GetTypeId ();
virtual TypeId GetInstanceTypeId () const;
virtual uint32_t GetSerializedSize () const;
virtual void Serialize (TagBuffer i) const;
virtual void Deserialize (TagBuffer i);
virtual void Print (std::ostream &os) const;
private:
Mac48Address m_address;
uint8_t m_ttl;
uint32_t m_metric;
uint32_t m_seqno;
};
class NetDevice;
namespace dot11s {
/**
* \ingroup mesh
*/
class Hwmp : public MeshL2RoutingProtocol
class HwmpProtocol : public MeshL2RoutingProtocol
{
public:
static TypeId GetTypeId ();
Hwmp ();
~Hwmp ();
HwmpProtocol ();
~HwmpProtocol ();
void DoDispose ();
//intheritedfrom L2RoutingProtocol
/**
@@ -115,6 +68,7 @@ public:
MeshL2RoutingProtocol::RouteReplyCallback routeReply
);
bool AttachPorts (std::vector<Ptr<NetDevice> >);
#if 0
/**
* \brief Disables port by index.
* \details Needed for external modules like
@@ -150,30 +104,32 @@ public:
*/
void UnSetRoot (uint32_t port);
/**
* \brief HwmpState retrns to Hwmp class all
* \brief HwmpProtocolState retrns to HwmpProtocol class all
* routing information obtained from all HWMP
* action frames
*/
void ObtainRoutingInformation (
HwmpState::INFO info
HwmpProtocolState::INFO info
);
/**
* \brief Hwmp state noyifyes that neighbour
* is dissapeared. Hwmp state knows about peer
* \brief HwmpProtocol state noyifyes that neighbour
* is dissapeared. HwmpProtocol state knows about peer
* failure from MAC
*/
void PeerFailure (Mac48Address peerAddress);
void SetMaxTtl (uint8_t ttl);
uint8_t GetMaxTtl ();
private:
static const uint32_t MAX_SEQNO = 0xffffffff;
#endif
//candidate queue is implemented inside the
//protocol:
private:
void SetMaxQueueSize (int maxPacketsPerDestination);
int m_maxQueueSize;
bool QueuePacket (MeshL2RoutingProtocol::QueuedPacket packet);
MeshL2RoutingProtocol::QueuedPacket DequeuePacket (Mac48Address dst);
void SendAllPossiblePackets (Mac48Address dst);
#if 0
std::map<Mac48Address, std::queue<QueuedPacket> > m_rqueue;
//devices and HWMP states:
enum DeviceState {
@@ -187,7 +143,7 @@ private:
};
std::vector<enum DeviceState> m_states;
std::vector<enum DeviceMode> m_modes;
std::vector<Ptr<HwmpState> > m_hwmpStates;
std::vector<Ptr<HwmpProtocolState> > m_hwmpStates;
//Routing table:
Ptr<HwmpRtable> m_rtable;
//Proactive routines:
@@ -205,7 +161,7 @@ private:
*/
bool IsRoot (uint32_t port);
/**
* \brief Interaction with HwmpState class -
* \brief Interaction with HwmpProtocolState class -
* request for starting routing discover
* procedure (reactive route discovery!)
* \param Mac48Address is destination to be
@@ -225,7 +181,7 @@ private:
std::vector<HwmpRtable::FailedDestination> destinations,
uint32_t port);
/**
* \brief HwmpState need to know where to
* \brief HwmpProtocolState need to know where to
* retransmit PERR, only HWMP knows how to
* retransmit it (broadcast/unicast) and only
* HWMP has accessto routing table
@@ -234,7 +190,7 @@ private:
std::vector<HwmpRtable::FailedDestination> failedDest,
uint32_t port);
/**
* \brief Needed by HwmpState to find routes in case
* \brief Needed by HwmpProtocolState to find routes in case
* of intermediate reply and choosing the
* better route
*
@@ -271,6 +227,8 @@ private:
*/
uint8_t m_maxTtl;
bool m_broadcastPerr;
#endif
};
} //namespace dot11s
} //namespace ns3
#endif

View File

@@ -16,7 +16,8 @@ def build(bld):
'peer-management-protocol.cc',
'hwmp-tag.cc',
'hwmp-rtable.cc',
#'hwmp-protocol.cc',
#'hwmp-mac-plugin.cc',
'hwmp-protocol.cc',
'dot11s-helper.cc',
]
headers = bld.new_task_gen('ns3header')