HWMP is attached to mesh point device and MAC layer with zero functionality

This commit is contained in:
Kirill Andreev
2009-03-26 14:00:46 +03:00
parent 74747fc24e
commit 3023b41449
14 changed files with 199 additions and 113 deletions

View File

@@ -70,7 +70,7 @@ main (int argc, char *argv[])
"Ssid", SsidValue (ssid),
"RandomStart", TimeValue (Seconds (randomStart))
);
//wifi.SetPeerManager("ns3::WifiPeerManager");
wifi.SetRouting("ns3::HwmpProtocol");
wifi.SetPeerManager("ns3::PeerManagerProtocol");
wifi.SetL2RoutingNetDevice ("ns3::MeshPointDevice");
meshDevices = wifi.Install (wifiPhy,nodes);

View File

@@ -107,8 +107,29 @@ MeshWifiHelper::SetPeerManager (std::string type,
m_peerMan.Set (n6, v6);
m_peerMan.Set (n7, v7);
}
void
void
MeshWifiHelper::SetRouting (std::string type,
std::string n0, const AttributeValue &v0,
std::string n1, const AttributeValue &v1,
std::string n2, const AttributeValue &v2,
std::string n3, const AttributeValue &v3,
std::string n4, const AttributeValue &v4,
std::string n5, const AttributeValue &v5,
std::string n6, const AttributeValue &v6,
std::string n7, const AttributeValue &v7)
{
m_routing = ObjectFactory ();
m_routing.SetTypeId (type);
m_routing.Set (n0, v0);
m_routing.Set (n1, v1);
m_routing.Set (n2, v2);
m_routing.Set (n3, v3);
m_routing.Set (n4, v4);
m_routing.Set (n5, v5);
m_routing.Set (n6, v6);
m_routing.Set (n7, v7);
}
void
MeshWifiHelper::SetL2RoutingNetDevice (std::string type,
std::string n0, const AttributeValue &v0,
std::string n1, const AttributeValue &v1,
@@ -138,23 +159,30 @@ MeshWifiHelper::Install (const WifiPhyHelper &phyHelper, NodeContainer c) const
for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
{
Ptr<Node> node = *i;
// Create a mesh point device:
Ptr<MeshPointDevice> mp = m_deviceFactory.Create<MeshPointDevice> ();
std::vector<Ptr<WifiNetDevice> >ports;
std::vector<Ptr<NetDevice> >interfaces;
devices.Add (mp);
// Creating interface:
std::vector<Ptr<WifiNetDevice> > nodeDevices;
Ptr<WifiNetDevice> device = CreateObject<WifiNetDevice> ();
ports.push_back(device);
interfaces.push_back(device);
//Creating MAC for this interface
Ptr<MeshWifiInterfaceMac> mac = m_meshMac.Create<MeshWifiInterfaceMac> ();
// Ptr<Dot11sPeerManagerMacPlugin> peer_plugin = Create<Dot11sPeerManagerMacPlugin>();
// mac->InstallPlugin(peer_plugin);
Ptr<WifiRemoteStationManager> manager = m_stationManager.Create<WifiRemoteStationManager> ();
Ptr<WifiPhy> phy = phyHelper.Create (node, device);
mac->SetAddress (Mac48Address::Allocate ());
device->SetMac (mac);
device->SetPhy (phy);
Ptr<PeerManagerProtocol> peerMan = m_peerMan.Create<PeerManagerProtocol> ();
NS_ASSERT(peerMan->AttachInterfaces(ports));
device->SetRemoteStationManager (manager);
//Attaching peer manager:
Ptr<PeerManagerProtocol> peerMan = m_peerMan.Create<PeerManagerProtocol> ();
NS_ASSERT(peerMan->AttachInterfaces(interfaces));
//Creating Hwmp:
////TODO: make it using object factory
Ptr<HwmpProtocol> hwmp = m_routing.Create<HwmpProtocol> ();
NS_ASSERT(hwmp->AttachInterfaces(interfaces));
//Attaching interfaces to node:
node->AddDevice (device);
nodeDevices.push_back (device);
node -> AddDevice (mp);

View File

@@ -23,6 +23,7 @@
#define _MESHWIFIHELPER_H
#include "ns3/wifi-helper.h"
#include "ns3/peer-management-protocol.h"
#include "ns3/hwmp-protocol.h"
namespace ns3 {
namespace dot11s {
@@ -85,6 +86,17 @@ class MeshWifiHelper
std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (),
std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue ()
);
void SetRouting (std::string type,
std::string n0 = "", const AttributeValue &v0 = EmptyAttributeValue (),
std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (),
std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (),
std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (),
std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (),
std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (),
std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (),
std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue ()
);
void SetL2RoutingNetDevice (std::string type,
std::string n0 = "", const AttributeValue &v0 = EmptyAttributeValue (),
@@ -102,6 +114,7 @@ class MeshWifiHelper
ObjectFactory m_stationManager;
ObjectFactory m_meshMac;
ObjectFactory m_peerMan;
ObjectFactory m_routing;
ObjectFactory m_deviceFactory;
};
} // namespace dot11s

View File

@@ -18,16 +18,49 @@
* Author: Kirill Andreev <andreev@iitp.ru>
*/
#include "hwmp-mac-plugin.h"
#include "ns3/mesh-wifi-interface-mac.h"
#include "ns3/packet.h"
#include "ns3/simulator.h"
#include "ns3/nstime.h"
#include "ns3/log.h"
#include "ns3/dot11s-parameters.h"
#include "hwmp-mac-plugin.h"
#include "hwmp-protocol.h"
#include "ie-dot11s-preq.h"
#include "ie-dot11s-prep.h"
#include "ie-dot11s-perr.h"
namespace ns3 {
namespace dot11s {
NS_LOG_COMPONENT_DEFINE ("HwmpMacPlugin");
HwmpMacPlugin::HwmpMacPlugin (uint32_t ifIndex, Ptr<HwmpProtocol> protocol)
{
m_ifIndex = ifIndex;
m_protocol = protocol;
}
HwmpMacPlugin::~HwmpMacPlugin ()
{
}
void
HwmpMacPlugin::SetParent (Ptr<MeshWifiInterfaceMac> parent)
{
m_parent = parent;
}
bool
HwmpMacPlugin::Receive (Ptr<Packet> packet, const WifiMacHeader & header)
{
//TODO: here we fix only mesh header
return true;
}
bool
HwmpMacPlugin::UpdateOutcomingFrame (Ptr<Packet> packet, WifiMacHeader & header, Mac48Address from, Mac48Address to) const
{
//TODO: add a mesh header and remove a TAG
return true;
}
#if 0
TypeId
HwmpMacPlugin::GetTypeId ()
{
@@ -537,5 +570,6 @@ HwmpMacPlugin::SendOnePerr ()
m_perrCallback (m_myPerr, m_myPerrReceivers);
m_myPerr.ResetPerr ();
}
#endif
} //namespace dot11s
}//namespace ns3

View File

@@ -21,31 +21,45 @@
#ifndef HWMP_STATE_H
#define HWMP_STATE_H
#include <map>
#include "ns3/mesh-wifi-interface-mac-plugin.h"
#include "hwmp-rtable.h"
#include "ns3/packet.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 {
class MeshWifiInterfaceMac;
namespace dot11s {
class HwmpProtocol;
class IePreq;
class IePrep;
class IePerr;
/**
* \ingroup mesh
*
* \brief Handles HWMP state machine at each real interface
*
* \details Implements the following:
* 1. Keep it's own DSN,
* 2. Keep PREQ and PREP timers adn send this frames in
* accordance with HWMP-limitations
* 3. Deliver routing information to Hwmp main class
* 4. Notify about broken peers
*/
class HwmpMacPlugin : public MeshWifiInterfaceMacPlugin
{
public:
HwmpMacPlugin (uint32_t, Ptr<HwmpProtocol>);
~HwmpMacPlugin ();
///\name Inherited from MAC plugin
//\{
void SetParent (Ptr<MeshWifiInterfaceMac> parent);
bool Receive (Ptr<Packet> packet, const WifiMacHeader & header);
bool UpdateOutcomingFrame (Ptr<Packet> packet, WifiMacHeader & header, Mac48Address from, Mac48Address to) const;
///\brief Update beacon is empty, because HWMP does not know
//anything about beacons
void UpdateBeacon (MeshWifiBeacon & beacon) const {};
//\}
private:
friend class HwmpProtocol;
///\brief Interaction with protocol:
void SendPreq(Ptr<IePreq> preq);
void SendPrep(Ptr<IePreq> prep);
void SendPerr(Ptr<IePreq> perr);
private:
Ptr<MeshWifiInterfaceMac> m_parent;
uint32_t m_ifIndex;
Ptr<HwmpProtocol> m_protocol;
};
#if 0
class HwmpMacPlugin : public MeshWifiInterfaceMacPlugin {
public:
static TypeId GetTypeId ();
@@ -178,6 +192,7 @@ private:
//Configurable parameters:
uint8_t m_maxTtl;
};
#endif
} //namespace dot11s
} //namespace ns3
#endif

View File

@@ -20,9 +20,13 @@
#include "hwmp-protocol.h"
#include "hwmp-mac-plugin.h"
#include "ns3/log.h"
#include "ns3/simulator.h"
#include "ns3/packet.h"
#include "ns3/mesh-point-device.h"
#include "ns3/wifi-net-device.h"
#include "ns3/mesh-wifi-interface-mac.h"
NS_LOG_COMPONENT_DEFINE ("HwmpProtocol");
@@ -231,36 +235,22 @@ HwmpProtocol::RequestRoute (
return true;
}
bool
HwmpProtocol::AttachPorts (std::vector<Ptr<NetDevice> > ports)
HwmpProtocol::AttachInterfaces (std::vector<Ptr<NetDevice> > interfaces)
{
#if 0
for (std::vector<Ptr<NetDevice> >::iterator i = ports.begin (); i != ports.end(); i++)
for (std::vector<Ptr<NetDevice> >::iterator i = interfaces.begin (); i != interfaces.end(); i++)
{
//Checking netdevice:
const WifiNetDevice * wifiNetDev = dynamic_cast<const WifiNetDevice *> (PeekPointer (*i));
if (wifiNetDev == NULL)
return false;
MeshWifiMac * meshWifiMac = dynamic_cast<MeshWifiMac *> (PeekPointer (wifiNetDev->GetMac ()));
if (meshWifiMac == NULL)
MeshWifiInterfaceMac * mac = dynamic_cast<MeshWifiInterfaceMac *> (PeekPointer (wifiNetDev->GetMac ()));
if (mac == NULL)
return false;
//Adding HWMP-state
Ptr<HwmpProtocolState> hwmpState = CreateObject<HwmpProtocolState> ();
hwmpState->SetRoutingInfoCallback (MakeCallback(&HwmpProtocol::ObtainRoutingInformation, this));
hwmpState->SetMac (meshWifiMac);
hwmpState->SetRequestRouteCallback (MakeCallback(&HwmpProtocol::RequestRouteForAddress, this));
hwmpState->SetRequestRootPathCallback (MakeCallback(&HwmpProtocol::RequestRootPathForPort, this));
hwmpState->SetAssociatedIfaceId (wifiNetDev->GetIfIndex());
hwmpState->SetRetransmittersOfPerrCallback (MakeCallback(&HwmpProtocol::GetRetransmittersForFailedDestinations,this));
m_hwmpStates.push_back (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);
//Installing plugins:
Ptr<HwmpMacPlugin> hwmpMac = Create<HwmpMacPlugin> (wifiNetDev->GetIfIndex (), this);
m_interfaces[wifiNetDev->GetIfIndex ()] = hwmpMac;
mac->InstallPlugin (hwmpMac);
}
#endif
return true;
}
#if 0

View File

@@ -22,15 +22,18 @@
#ifndef HWMP_H
#define HWMP_H
#include <map>
#include <queue>
#include "ns3/tag.h"
#include "ns3/mac48-address.h"
#include "ns3/mesh-l2-routing-protocol.h"
#include "ns3/packet.h"
#include <map>
namespace ns3 {
class NetDevice;
class Packet;
class Mac48Address;
namespace dot11s {
class HwmpMacPlugin;
class IePreq;
class IePrep;
class IePerr;
/**
* \ingroup mesh
*/
@@ -41,24 +44,6 @@ public:
HwmpProtocol ();
~HwmpProtocol ();
void DoDispose ();
//intheritedfrom L2RoutingProtocol
/**
* \brief L2Routing protocol base class metod
*
* \details Route resolving procedure consits
* of the following steps:
* 1. Find reactive route and send a packet.
* 2. Find all ports which are operate in
* 'Proactive' mode and find a proper default
* routes. and send packet to all proactive
* 'ports'.
* 3. If there are ports which are operate in
* reactive mode - queue packet and start
* route reactive path discovery
*
* \bug Now packet is sent to the 'best root'
* rather than to the best root at each port
*/
bool RequestRoute (
uint32_t sourceIface,
const Mac48Address source,
@@ -67,7 +52,7 @@ public:
uint16_t protocolType,
MeshL2RoutingProtocol::RouteReplyCallback routeReply
);
bool AttachPorts (std::vector<Ptr<NetDevice> >);
bool AttachInterfaces (std::vector<Ptr<NetDevice> >);
#if 0
/**
* \brief Disables port by index.
@@ -123,12 +108,20 @@ public:
#endif
//candidate queue is implemented inside the
//protocol:
private:
///\brief interaction with HWMP MAC plugin
void ReceivePreq(Ptr<IePreq> preq);
void ReceivePrep(Ptr<IePreq> prep);
void ReceivePerr(Ptr<IePreq> perr);
private:
void SetMaxQueueSize (int maxPacketsPerDestination);
int m_maxQueueSize;
bool QueuePacket (MeshL2RoutingProtocol::QueuedPacket packet);
MeshL2RoutingProtocol::QueuedPacket DequeuePacket (Mac48Address dst);
void SendAllPossiblePackets (Mac48Address dst);
private:
//fields:
std::map<uint32_t, Ptr<HwmpMacPlugin> > m_interfaces;
#if 0
std::map<Mac48Address, std::queue<QueuedPacket> > m_rqueue;
//devices and HWMP states:

View File

@@ -23,6 +23,7 @@
#include "peer-link.h"
#include "ns3/log.h"
#include "ns3/simulator.h"
#include "ns3/traced-value.h"
NS_LOG_COMPONENT_DEFINE ("Dot11sPeerManagementProtocol");
@@ -35,33 +36,33 @@ TypeId
PeerLink::GetTypeId()
{
static TypeId tid = TypeId ("ns3::PeerLink")
.SetParent<Object> ()
.AddConstructor<PeerLink> ()
.AddAttribute ("RetryTimeout", "Retry timeout",
TimeValue (TimeValue (MicroSeconds (40 * 1024))),
MakeTimeAccessor (&PeerLink::m_retryTimeout),
MakeTimeChecker ()
)
.AddAttribute ("HoldingTimeout", "Holding timeout",
TimeValue (TimeValue (MicroSeconds (40 * 1024))),
MakeTimeAccessor (&PeerLink::m_holdingTimeout),
MakeTimeChecker ()
)
.AddAttribute ("ConfirmTimeout", "Confirm timeout",
TimeValue (TimeValue (MicroSeconds (40 * 1024))),
MakeTimeAccessor (&PeerLink::m_confirmTimeout),
MakeTimeChecker ()
)
.AddAttribute ("MaxRetries", "Maximum number of retries",
UintegerValue (4),
MakeUintegerAccessor (&PeerLink::m_maxRetries),
MakeUintegerChecker<uint16_t> ()
)
.AddAttribute ("MaxBeaconLoss", "Maximum number of lost beacons before link will be closed",
UintegerValue (3),
MakeUintegerAccessor (&PeerLink::m_maxBeaconLoss),
MakeUintegerChecker<uint16_t> (1)
);
.SetParent<Object> ()
.AddConstructor<PeerLink> ()
.AddAttribute ("RetryTimeout", "Retry timeout",
TimeValue (TimeValue (MicroSeconds (40 * 1024))),
MakeTimeAccessor (&PeerLink::m_retryTimeout),
MakeTimeChecker ()
)
.AddAttribute ("HoldingTimeout", "Holding timeout",
TimeValue (TimeValue (MicroSeconds (40 * 1024))),
MakeTimeAccessor (&PeerLink::m_holdingTimeout),
MakeTimeChecker ()
)
.AddAttribute ("ConfirmTimeout", "Confirm timeout",
TimeValue (TimeValue (MicroSeconds (40 * 1024))),
MakeTimeAccessor (&PeerLink::m_confirmTimeout),
MakeTimeChecker ()
)
.AddAttribute ("MaxRetries", "Maximum number of retries",
UintegerValue (4),
MakeUintegerAccessor (&PeerLink::m_maxRetries),
MakeUintegerChecker<uint16_t> ()
)
.AddAttribute ("MaxBeaconLoss", "Maximum number of lost beacons before link will be closed",
UintegerValue (3),
MakeUintegerAccessor (&PeerLink::m_maxBeaconLoss),
MakeUintegerChecker<uint16_t> (1)
);
return tid;
}

View File

@@ -25,6 +25,7 @@
#include "ns3/nstime.h"
#include "ns3/callback.h"
#include "ns3/mac48-address.h"
#include "ns3/event-id.h"
#include "ie-dot11s-beacon-timing.h"
#include "ie-dot11s-peer-management.h"
#include "ie-dot11s-configuration.h"

View File

@@ -18,11 +18,12 @@
* Author: Kirill Andreev <andreev@iitp.ru>
*/
#include "ns3/mesh-wifi-interface-mac.h"
#include "ie-dot11s-configuration.h"
#include "ie-dot11s-peer-management.h"
#include "peer-management-plugin.h"
#include "peer-management-protocol.h"
#include "peer-link-frame.h"
#include "ns3/mesh-wifi-interface-mac.h"
#include "ns3/mesh-wifi-mac-header.h"
#include "ns3/simulator.h"
#include "ns3/wifi-mac-header.h"

View File

@@ -22,11 +22,11 @@
#define PEER_MANAGER_MAC_PLUGIN_H_
#include "ns3/mesh-wifi-interface-mac-plugin.h"
#include "peer-management-protocol.h"
namespace ns3 {
class MeshWifiInterfaceMac;
namespace dot11s {
class PeerManagementProtocol;
class IeConfiguration;
class IePeerManagement;
class PeerManagerProtocol;

View File

@@ -22,6 +22,9 @@
#include "peer-management-protocol.h"
#include "ie-dot11s-peer-management.h"
#include "ie-dot11s-configuration.h"
#include "ns3/dot11s-parameters.h"
#include "ns3/simulator.h"
#include "ns3/assert.h"
@@ -29,6 +32,7 @@
#include "ns3/random-variable.h"
#include "ns3/mesh-wifi-interface-mac.h"
#include "ns3/mesh-wifi-interface-mac-plugin.h"
#include "ns3/wifi-net-device.h"
#include "peer-link.h"
#include "peer-management-plugin.h"
@@ -96,11 +100,14 @@ PeerManagerProtocol::~PeerManagerProtocol ()
}
bool
PeerManagerProtocol::AttachInterfaces(std::vector<Ptr<WifiNetDevice> > interfaces)
PeerManagerProtocol::AttachInterfaces(std::vector<Ptr<NetDevice> > interfaces)
{
for(std::vector<Ptr<WifiNetDevice> >::iterator i = interfaces.begin(); i != interfaces.end(); i ++)
for(std::vector<Ptr<NetDevice> >::iterator i = interfaces.begin(); i != interfaces.end(); i ++)
{
MeshWifiInterfaceMac * mac = dynamic_cast<MeshWifiInterfaceMac *> (PeekPointer ((*i)->GetMac ()));
const WifiNetDevice * wifiNetDev = dynamic_cast<const WifiNetDevice *> (PeekPointer (*i));
if (wifiNetDev == NULL)
return false;
MeshWifiInterfaceMac * mac = dynamic_cast<MeshWifiInterfaceMac *> (PeekPointer (wifiNetDev->GetMac ()));
if (mac == NULL)
return false;
Ptr<PeerManagerMacPlugin> peerPlugin = Create<PeerManagerMacPlugin> ((*i)->GetIfIndex(), this);

View File

@@ -24,18 +24,19 @@
#define DOT11S_PEER_MAN_H
#include "ns3/mac48-address.h"
#include "ns3/wifi-net-device.h"
#include "ns3/net-device.h"
#include "ns3/event-id.h"
#include "ie-dot11s-peer-management.h"
#include "ns3/nstime.h"
#include "ns3/dot11s-codes.h"
#include "ie-dot11s-beacon-timing.h"
#include "ie-dot11s-configuration.h"
#include <list>
#include <map>
namespace ns3 {
namespace dot11s {
class PeerManagerMacPlugin;
class PeerLink;
class IePeerManagement;
class IeConfiguration;
/**
* \ingroup dot11s
*
@@ -47,7 +48,7 @@ public:
PeerManagerProtocol ();
~PeerManagerProtocol ();
static TypeId GetTypeId ();
bool AttachInterfaces(std::vector<Ptr<WifiNetDevice> >);
bool AttachInterfaces(std::vector<Ptr<NetDevice> >);
/** \brief Methods that handle beacon sending/receiving procedure.
* This methods interact with MAC_layer plug-in
* \{

View File

@@ -16,7 +16,7 @@ def build(bld):
'peer-management-protocol.cc',
'hwmp-tag.cc',
'hwmp-rtable.cc',
#'hwmp-mac-plugin.cc',
'hwmp-mac-plugin.cc',
'hwmp-protocol.cc',
'dot11s-helper.cc',
]
@@ -24,7 +24,7 @@ def build(bld):
headers.module = 'dot11s'
headers.source = [
'ie-dot11s-beacon-timing.h',
'ie-dot11s-configuration.h',
#'ie-dot11s-configuration.h',
'ie-dot11s-peer-management.h',
#'ie-dot11s-preq.h',
#'ie-dot11s-prep.h',
@@ -34,6 +34,8 @@ def build(bld):
#'peer-link.h',
#'peer-management-plugin.h',
'peer-management-protocol.h',
#'hwmp-mac-plugin.h',
'hwmp-protocol.h',
'dot11s-helper.h',
]