Peer manager restructure - unfinished
This commit is contained in:
@@ -67,6 +67,8 @@ main (int argc, char *argv[])
|
||||
"Ssid", SsidValue (ssid),
|
||||
"RandomStart", TimeValue (Seconds (randomStart))
|
||||
);
|
||||
//wifi.SetPeerManager("ns3::WifiPeerManager");
|
||||
wifi.SetPeerManager("ns3::Dot11sPeerManagerProtocol");
|
||||
wifi.SetL2RoutingNetDevice ("ns3::MeshPointDevice");
|
||||
meshDevices = wifi.Install (wifiPhy,nodes);
|
||||
// Installing Mobility.
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
#include "ns3/wifi-channel.h"
|
||||
#include "ns3/wifi-remote-station-manager.h"
|
||||
#include "ns3/mesh-wifi-interface-mac.h"
|
||||
#include "ns3/peer-manager-plugin.h"
|
||||
//#include "ns3/peer-manager-plugin.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
@@ -84,6 +84,29 @@ MeshWifiHelper::SetMac (std::string type,
|
||||
m_meshMac.Set (n6, v6);
|
||||
m_meshMac.Set (n7, v7);
|
||||
}
|
||||
void
|
||||
MeshWifiHelper::SetPeerManager (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_peerMan = ObjectFactory ();
|
||||
m_peerMan.SetTypeId (type);
|
||||
m_peerMan.Set (n0, v0);
|
||||
m_peerMan.Set (n1, v1);
|
||||
m_peerMan.Set (n2, v2);
|
||||
m_peerMan.Set (n3, v3);
|
||||
m_peerMan.Set (n4, v4);
|
||||
m_peerMan.Set (n5, v5);
|
||||
m_peerMan.Set (n6, v6);
|
||||
m_peerMan.Set (n7, v7);
|
||||
}
|
||||
|
||||
void
|
||||
MeshWifiHelper::SetL2RoutingNetDevice (std::string type,
|
||||
std::string n0, const AttributeValue &v0,
|
||||
@@ -115,17 +138,21 @@ MeshWifiHelper::Install (const WifiPhyHelper &phyHelper, NodeContainer c) const
|
||||
{
|
||||
Ptr<Node> node = *i;
|
||||
Ptr<MeshPointDevice> mp = m_deviceFactory.Create<MeshPointDevice> ();
|
||||
std::vector<Ptr<WifiNetDevice> >ports;
|
||||
devices.Add (mp);
|
||||
std::vector<Ptr<WifiNetDevice> > nodeDevices;
|
||||
Ptr<WifiNetDevice> device = CreateObject<WifiNetDevice> ();
|
||||
ports.push_back(device);
|
||||
Ptr<MeshWifiInterfaceMac> mac = m_meshMac.Create<MeshWifiInterfaceMac> ();
|
||||
Ptr<Dot11sPeerManagerMacPlugin> peer_plugin = Create<Dot11sPeerManagerMacPlugin>();
|
||||
mac->InstallPlugin(peer_plugin);
|
||||
// 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<Dot11sPeerManagerProtocol> peerMan = m_peerMan.Create<Dot11sPeerManagerProtocol> ();
|
||||
NS_ASSERT(peerMan->AttachPorts(ports));
|
||||
device->SetRemoteStationManager (manager);
|
||||
node->AddDevice (device);
|
||||
nodeDevices.push_back (device);
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#ifndef _MESHWIFIHELPER_H
|
||||
#define _MESHWIFIHELPER_H
|
||||
#include "wifi-helper.h"
|
||||
#include "ns3/peer-manager-protocol.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
@@ -73,6 +74,17 @@ class MeshWifiHelper
|
||||
std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (),
|
||||
std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue ()
|
||||
);
|
||||
void SetPeerManager (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 (),
|
||||
std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (),
|
||||
@@ -88,6 +100,7 @@ class MeshWifiHelper
|
||||
private:
|
||||
ObjectFactory m_stationManager;
|
||||
ObjectFactory m_meshMac;
|
||||
ObjectFactory m_peerMan;
|
||||
ObjectFactory m_deviceFactory;
|
||||
};
|
||||
}//namespace ns3
|
||||
|
||||
@@ -18,11 +18,11 @@
|
||||
* Author: Kirill Andreev <andreev@iitp.ru>
|
||||
*/
|
||||
|
||||
#include "ns3/peer-manager-plugin.h"
|
||||
#include "ns3/ie-dot11s-configuration.h"
|
||||
#include "ns3/ie-dot11s-peer-management.h"
|
||||
#include "ns3/mesh-wifi-interface-mac.h"
|
||||
|
||||
#include "ns3/peer-manager-plugin.h"
|
||||
#include "ns3/log.h"
|
||||
NS_LOG_COMPONENT_DEFINE("PeerManager");
|
||||
namespace ns3 {
|
||||
@@ -48,8 +48,16 @@ Dot11sPeerManagerMacPlugin::Receive (Ptr<Packet> packet, const WifiMacHeader & h
|
||||
if(header.IsBeacon())
|
||||
{
|
||||
NS_LOG_UNCOND("Beacon recevied by PM from"<<header.GetAddr2 ());
|
||||
IeDot11sBeaconTiming beaconTiming;
|
||||
Mac48Address peerAddress = header.GetAddr2 ();
|
||||
Ptr<Packet> myBeacon = packet->Copy ();
|
||||
Ptr<Packet> myBeacon = packet->Copy();
|
||||
MgtBeaconHeader beacon_hdr;
|
||||
myBeacon->RemoveHeader(beacon_hdr);
|
||||
if(myBeacon->GetSize () == 0)
|
||||
NS_LOG_UNCOND("Empty");
|
||||
if(beaconTiming.FindMyInformationElement(myBeacon))
|
||||
NS_LOG_UNCOND("BEACON TIMING");
|
||||
|
||||
#if 0
|
||||
packet->RemoveHeader (beacon);
|
||||
m_peerManager->SetReceivedBeaconTimers (
|
||||
@@ -74,5 +82,14 @@ void
|
||||
Dot11sPeerManagerMacPlugin::UpdateBeacon (MeshWifiBeacon & beacon) const
|
||||
{
|
||||
NS_LOG_UNCOND("I am sending a beacon");
|
||||
Ptr<IeDot11sPreq> beaconTiming = Create<IeDot11sPreq> ();
|
||||
beacon.AddInformationElement(beaconTiming);
|
||||
}
|
||||
bool
|
||||
Dot11sPeerManagerMacPlugin::BindWithProtocol(Ptr<Dot11sPeerManagerProtocol> protocol)
|
||||
{
|
||||
m_protocol = protocol;
|
||||
return true;
|
||||
}
|
||||
|
||||
}//namespace ns3
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#define PEER_MANAGER_MAC_PLUGIN_H_
|
||||
|
||||
#include "ns3/mesh-wifi-interface-mac-plugin.h"
|
||||
#include "ns3/peer-manager-protocol.h"
|
||||
|
||||
namespace ns3 {
|
||||
class MeshWifiInterfaceMac;
|
||||
@@ -52,6 +53,7 @@ class Dot11sPeerManagerMacPlugin : public MeshWifiInterfaceMacPlugin
|
||||
/**
|
||||
* \}
|
||||
*/
|
||||
bool BindWithProtocol(Ptr<Dot11sPeerManagerProtocol>);
|
||||
void SetPeerManagerProtcol(Ptr<Dot11sPeerManagerProtocol> protocol);
|
||||
/**
|
||||
* Deliver Peer link management information to the protocol-part
|
||||
@@ -78,6 +80,7 @@ class Dot11sPeerManagerMacPlugin : public MeshWifiInterfaceMacPlugin
|
||||
Callback<void, uint32_t, Mac48Address, uint16_t, IeDot11sConfiguration, IeDot11sPeerManagement> m_deliverPeerManFrame;
|
||||
Callback<void> m_beaconCallback;
|
||||
Ptr<MeshWifiInterfaceMac> m_parent;
|
||||
Ptr<Dot11sPeerManagerProtocol> m_protocol;
|
||||
/**
|
||||
* Create peer link management frames:
|
||||
* \{
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "ns3/assert.h"
|
||||
#include "ns3/log.h"
|
||||
#include "ns3/random-variable.h"
|
||||
#include "ns3/mesh-wifi-interface-mac.h"
|
||||
NS_LOG_COMPONENT_DEFINE ("Dot11sPeerManagerProtocol");
|
||||
namespace ns3 {
|
||||
/***************************************************
|
||||
@@ -544,7 +545,7 @@ void WifiPeerLinkDescriptor::ConfirmTimeout ()
|
||||
/***************************************************
|
||||
* PeerManager
|
||||
***************************************************/
|
||||
//NS_OBJECT_ENSURE_REGISTERED (Dot11sPeerManagerProtocol);
|
||||
NS_OBJECT_ENSURE_REGISTERED (Dot11sPeerManagerProtocol);
|
||||
|
||||
TypeId
|
||||
Dot11sPeerManagerProtocol::GetTypeId (void)
|
||||
@@ -609,6 +610,53 @@ Dot11sPeerManagerProtocol::~Dot11sPeerManagerProtocol ()
|
||||
m_peerDescriptors.clear ();
|
||||
#endif
|
||||
}
|
||||
//-----------------------------------------------------
|
||||
// UNFINISHED
|
||||
//-----------------------------------------------------
|
||||
bool
|
||||
Dot11sPeerManagerProtocol::AttachPorts(std::vector<Ptr<WifiNetDevice> > ports)
|
||||
{
|
||||
NS_LOG_UNCOND("Peer manager attach ports started!");
|
||||
for(std::vector<Ptr<WifiNetDevice> >::iterator i = ports.begin(); i != ports.end(); i ++)
|
||||
{
|
||||
MeshWifiInterfaceMac * mac = dynamic_cast<MeshWifiInterfaceMac *> (PeekPointer ((*i)->GetMac ()));
|
||||
if (mac == NULL)
|
||||
return false;
|
||||
Ptr<Dot11sPeerManagerMacPlugin> peerPlugin = Create<Dot11sPeerManagerMacPlugin>();
|
||||
mac->InstallPlugin(peerPlugin);
|
||||
NS_ASSERT(peerPlugin->BindWithProtocol(this));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
IeDot11sBeaconTiming
|
||||
Dot11sPeerManagerProtocol::SendBeacon(uint32_t port, Time currentTbtt, Time beaconInterval)
|
||||
{
|
||||
IeDot11sBeaconTiming retval;
|
||||
return retval;
|
||||
}
|
||||
|
||||
void
|
||||
Dot11sPeerManagerProtocol::ReceiveBeacon(
|
||||
uint32_t port,
|
||||
IeDot11sBeaconTiming timingElement,
|
||||
Mac48Address peerAddress,
|
||||
Time receivingTime,
|
||||
Time beaconInterval)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
Dot11sPeerManagerProtocol::ReceivePeerLinkFrame(
|
||||
uint32_t port,
|
||||
Mac48Address peerAddress,
|
||||
uint16_t aid,
|
||||
IeDot11sConfiguration meshConfig,
|
||||
IeDot11sPeerManagement peerManagementElement
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
#if 0
|
||||
void
|
||||
Dot11sPeerManagerProtocol::SetSentBeaconTimers (
|
||||
|
||||
@@ -20,20 +20,20 @@
|
||||
*/
|
||||
|
||||
|
||||
#ifndef WIFI_PEER_MAN_H
|
||||
#define WIFI_PEER_MAN_H
|
||||
#ifndef DOT11S_PEER_MAN_H
|
||||
#define DOT11S_PEER_MAN_H
|
||||
|
||||
#include "ns3/mac48-address.h"
|
||||
#include "ns3/wifi-net-device.h"
|
||||
#include "ns3/ie-dot11s-peer-management.h"
|
||||
#include "ns3/ie-dot11s-beacon-timing.h"
|
||||
#include "ns3/peer-manager-plugin.h"
|
||||
#include "ns3/ie-dot11s-configuration.h"
|
||||
#include "ns3/event-id.h"
|
||||
#include "ns3/peer-manager-plugin.h"
|
||||
|
||||
#include <list>
|
||||
namespace ns3 {
|
||||
class EventId;
|
||||
class Dot11sPeerManagerMacPlugin;
|
||||
/**
|
||||
* \ingroup mesh
|
||||
*/
|
||||
@@ -189,6 +189,7 @@ public:
|
||||
Dot11sPeerManagerProtocol ();
|
||||
~Dot11sPeerManagerProtocol ();
|
||||
static TypeId GetTypeId ();
|
||||
bool AttachPorts(std::vector<Ptr<WifiNetDevice> >);
|
||||
/** \brief Methods that handle beacon sending/receiving procedure.
|
||||
* This methods interact with MAC_layer plug-in
|
||||
* \{
|
||||
@@ -251,14 +252,15 @@ private:
|
||||
* * pointers to proper plugins
|
||||
* \{
|
||||
*/
|
||||
struct BeaconInfo
|
||||
{
|
||||
Time referenceTbtt; //When one of my station's beacons was put into a beacon queue;
|
||||
Time beaconInterval; //Beacon interval of my station;
|
||||
};
|
||||
typedef std::map<uint32_t, std::vector<Ptr<WifiPeerLinkDescriptor> >, std::less<Mac48Address> > PeerDescriptorsMap;
|
||||
typedef std::map<uint32_t, BeaconInfo, std::less<Mac48Address> > BeaconInfoMap;
|
||||
typedef std::map<uint32_t, Ptr<Dot11sPeerManagerMacPlugin>,std::less<Mac48Address> > MeshMacMap;
|
||||
// struct BeaconInfo
|
||||
// {
|
||||
// Time referenceTbtt; //When one of my station's beacons was put into a beacon queue;
|
||||
// Time beaconInterval; //Beacon interval of my station;
|
||||
// uint16_t aid; //Assoc ID
|
||||
//};
|
||||
typedef std::map<uint32_t, std::vector<Ptr<WifiPeerLinkDescriptor> > > PeerDescriptorsMap;
|
||||
// typedef std::map<uint32_t, BeaconInfo> BeaconInfoMap;
|
||||
typedef std::map<uint32_t, Ptr<Dot11sPeerManagerMacPlugin> > PeerManagerPluginMap;
|
||||
/**
|
||||
* \}
|
||||
*/
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
*/
|
||||
|
||||
#include "ns3/wifi-information-element.h"
|
||||
#include "ns3/packet.h"
|
||||
#include "ns3/log.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
@@ -49,7 +51,8 @@ void WifiInformationElement::Serialize (Buffer::Iterator i) const
|
||||
|
||||
uint32_t WifiInformationElement::Deserialize (Buffer::Iterator i)
|
||||
{
|
||||
NS_ASSERT (i.ReadU8 () == ElementId());
|
||||
if(i.ReadU8 () != ElementId())
|
||||
return 0;
|
||||
uint8_t length = i.ReadU8 ();
|
||||
|
||||
return (DeserializeInformation (i, length) + 2);
|
||||
@@ -61,6 +64,26 @@ void WifiInformationElement::Print (std::ostream &os) const
|
||||
PrintInformation (os);
|
||||
os << "</information_element>\n";
|
||||
}
|
||||
bool WifiInformationElement::FindMyInformationElement(Ptr<Packet> packet)
|
||||
{
|
||||
const uint8_t * data = packet->PeekData();
|
||||
uint32_t position = 0;
|
||||
while(position <= packet->GetSize ())
|
||||
{
|
||||
if(data[position] == ElementId())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
NS_LOG_UNCOND("not found"<<(uint16_t)data[position+1]);
|
||||
position +=data[position+1];
|
||||
if(data[position + 1] == 0)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool operator< (WifiInformationElement const & a, WifiInformationElement const & b)
|
||||
{
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include "ns3/ref-count-base.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
class Packet;
|
||||
/**
|
||||
* \ingroup mesh
|
||||
*
|
||||
@@ -128,6 +128,11 @@ public:
|
||||
* i.e.: (field1 val1 field2 val2 field3 val3) field4 val4 field5 val5
|
||||
*/
|
||||
virtual void Print (std::ostream &os) const;
|
||||
/**
|
||||
* This method takes a packet which must be a list of information
|
||||
* elements and looks for an information element of MINE Element ID
|
||||
*/
|
||||
bool FindMyInformationElement(Ptr<Packet> packet);
|
||||
//\}
|
||||
|
||||
protected:
|
||||
|
||||
Reference in New Issue
Block a user