Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP

This commit is contained in:
Kirill Andreev
2009-06-10 12:51:49 +04:00
parent 1716b106dc
commit fce22caf9e
10 changed files with 150 additions and 16 deletions

View File

@@ -28,7 +28,7 @@
#include "ns3/mesh-module.h"
#include "ns3/mobility-module.h"
#include "ns3/dot11s-helper.h"
#include "ns3/dot11s-interface-helper.h"
#include "ns3/mesh-interface-helper.h"
#include <iostream>
#include <sstream>

View File

@@ -0,0 +1,90 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2008,2009 IITP RAS
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Authors: Kirill Andreev <andreev@iitp.ru>
*/
#include "ns3/mesh-interface-helper.h"
#include "dot11s-installator.h"
#include "peer-management-protocol.h"
#include "hwmp-protocol.h"
namespace ns3 {
namespace dot11s {
bool
Dot11sStackInstallator::InstallDot11sStack (Ptr<MeshPointDevice> mp, bool root)
{
//Install Peer management protocol:
Ptr<PeerManagementProtocol> pmp = CreateObject<PeerManagementProtocol> ();
pmp->SetMeshId("mesh");
bool install_ok = pmp->Install (mp);
if(!install_ok)
return false;
//Install HWMP:
Ptr<HwmpProtocol> hwmp = CreateObject<HwmpProtocol> ();
install_ok = hwmp->Install (mp);
if(!install_ok)
return false;
if(root)
hwmp->SetRoot ();
//Install interaction between HWMP and Peer management protocol:
pmp->SetPeerLinkStatusCallback(MakeCallback(&HwmpProtocol::PeerLinkStatus, hwmp));
hwmp->SetNeighboursCallback(MakeCallback(&PeerManagementProtocol::GetActiveLinks, pmp));
return true;
}
void
Dot11sStackInstallator::Report (const ns3::Ptr<ns3::NetDevice>& device, std::ostream& os)
{
Ptr <MeshPointDevice> mp = device->GetObject<MeshPointDevice> ();
std::vector<Ptr<NetDevice> > ifaces = mp->GetInterfaces ();
NS_ASSERT (mp != 0);
for (std::vector<Ptr<NetDevice> >::const_iterator i = ifaces.begin(); i != ifaces.end(); ++i)
{
Ptr<WifiNetDevice> device = (*i)->GetObject<WifiNetDevice> ();
NS_ASSERT (device != 0);
MeshInterfaceHelper::Report(device, os);
}
Ptr <HwmpProtocol> hwmp = mp->GetObject<HwmpProtocol> ();
NS_ASSERT(hwmp != 0);
hwmp->Report (os);
Ptr <PeerManagementProtocol> pmp = mp->GetObject<PeerManagementProtocol> ();
NS_ASSERT(pmp != 0);
pmp->Report (os);
}
void
Dot11sStackInstallator::ResetStats (const ns3::Ptr<ns3::NetDevice>& device)
{
Ptr <MeshPointDevice> mp = device->GetObject<MeshPointDevice> ();
NS_ASSERT (mp != 0);
std::vector<Ptr<NetDevice> > ifaces = mp->GetInterfaces ();
for (std::vector<Ptr<NetDevice> >::const_iterator i = ifaces.begin(); i != ifaces.end(); ++i)
{
Ptr<WifiNetDevice> device = (*i)->GetObject<WifiNetDevice> ();
NS_ASSERT (device != 0);
MeshInterfaceHelper::ResetStats (device);
}
Ptr <HwmpProtocol> hwmp = mp->GetObject<HwmpProtocol> ();
NS_ASSERT(hwmp != 0);
hwmp->ResetStats ();
Ptr <PeerManagementProtocol> pmp = mp->GetObject<PeerManagementProtocol> ();
NS_ASSERT(pmp != 0);
pmp->ResetStats ();
}
}
}

View File

@@ -0,0 +1,39 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2008,2009 IITP RAS
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Authors: Kirill Andreev <andreev@iitp.ru>
*/
#ifndef MESH_INSTALLATOR_H
#define MESH_INSTALLATOR_H
#include "ns3/mesh-point-device.h"
namespace ns3 {
namespace dot11s {
class Dot11sStackInstallator
{
public:
///\brief Installs 802.11s stack. needed by helper only
static bool InstallDot11sStack (Ptr<MeshPointDevice> mp, bool root);
static void Report (const ns3::Ptr<ns3::NetDevice>&, std::ostream&);
static void ResetStats (const ns3::Ptr<ns3::NetDevice>&);
};
}
}
#endif

View File

@@ -75,11 +75,6 @@ HwmpMacPlugin::Receive (Ptr<Packet> packet, const WifiMacHeader & header)
NS_ASSERT(false);
};
tag.SetSeqno (meshHdr.GetMeshSeqno ());
if(meshHdr.GetMeshTtl () == 0)
{
NS_ASSERT(false);
return false;
}
tag.SetTtl (meshHdr.GetMeshTtl ());
if(m_protocol->GetAddress() != destination)
packet->AddPacketTag(tag);

View File

@@ -268,7 +268,7 @@ HwmpProtocol::ForwardUnicast(uint32_t sourceIface, const Mac48Address source, c
HwmpTag tag;
tag.SetAddress (result.retransmitter);
tag.SetTtl (ttl);
//seqno and metric is not used;
//seqno and metric is not used;
packet->AddPacketTag(tag);
if(result.retransmitter != Mac48Address::GetBroadcast ())
{
@@ -794,7 +794,10 @@ HwmpProtocol::ProactivePathResolved ()
return;
//set RA tag for retransmitter:
HwmpTag tag;
NS_ASSERT (packet.pkt->PeekPacketTag(tag));
if(!packet.pkt->RemovePacketTag (tag))
{
NS_ASSERT (false);
}
tag.SetAddress (result.retransmitter);
packet.pkt->AddPacketTag (tag);
m_stats.txUnicast ++;

View File

@@ -24,8 +24,8 @@
#include "ns3/mesh-l2-routing-protocol.h"
#include "ns3/nstime.h"
#include "ns3/ie-dot11s-perr.h"
#include "ns3/event-id.h"
#include "ie-dot11s-perr.h"
#include <vector>
#include <map>

View File

@@ -87,7 +87,7 @@ MeshPointDevice::ReceiveFromDevice (Ptr<NetDevice> incomingPort, Ptr<const Packe
NS_LOG_DEBUG ("SRC="<<src48<<", DST = "<<dst48<<", I am: "<<m_address);
if (!m_promiscRxCallback.IsNull ())
m_promiscRxCallback (this, packet, protocol, src, dst, packetType);
if(dst48.IsBroadcast () || dst48.IsGroup ())
if(dst48.IsGroup ())
{
m_rxCallback (this, packet, protocol, src);
Forward (incomingPort, packet->Copy (), protocol, src48, dst48);

View File

@@ -38,6 +38,7 @@ NetDeviceContainer
MeshWifiHelper::Install (const WifiPhyHelper &phyHelper, const MeshInterfaceHelper &interfaceHelper, NodeContainer c, std::vector<uint32_t> roots, uint32_t nInterfaces) const
{
NetDeviceContainer devices;
uint16_t node_counter = 0;
for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
{
Ptr<Node> node = *i;
@@ -53,11 +54,16 @@ MeshWifiHelper::Install (const WifiPhyHelper &phyHelper, const MeshInterfaceHelp
Ptr<WifiNetDevice> iface = interfaceHelper.CreateInterface (phyHelper,node, (m_spreadInterfaceChannels ? channel : 0));
mp->AddInterface (iface);
}
if(!Dot11sStackInstallator::InstallDot11sStack (mp, false))
bool root = false;
for (unsigned int j = 0; j < roots.size (); j ++)
if(node_counter == roots[j])
root = true;
if(!Dot11sStackInstallator::InstallDot11sStack (mp, root))
{
NS_ASSERT(false);
}
devices.Add (mp);
node_counter ++;
}
return devices;
}

View File

@@ -121,7 +121,8 @@ MeshInterfaceHelper::CreateInterface (const WifiPhyHelper &phyHelper, Ptr<Node>
{
Ptr<WifiNetDevice> device = CreateObject<WifiNetDevice> ();
Ptr<MeshWifiInterfaceMac> mac = Create ();
Ptr<MeshWifiInterfaceMac> mac = DynamicCast <MeshWifiInterfaceMac> (Create ());
NS_ASSERT (mac != 0);
mac->SetSsid (Ssid ());
Ptr<WifiRemoteStationManager> manager = m_stationManager.Create<WifiRemoteStationManager> ();
Ptr<WifiPhy> phy = phyHelper.Create (node, device);
@@ -133,10 +134,10 @@ MeshInterfaceHelper::CreateInterface (const WifiPhyHelper &phyHelper, Ptr<Node>
mac->SwitchFrequencyChannel (channelId);
return device;
}
Ptr<MeshWifiInterfaceMac>
Ptr<WifiMac>
MeshInterfaceHelper::Create (void) const
{
Ptr<MeshWifiInterfaceMac> mac = m_mac.Create<MeshWifiInterfaceMac> ();
Ptr<WifiMac> mac = m_mac.Create<WifiMac> ();
Ptr<DcaTxop> be = m_Be.Create<DcaTxop> ();
Ptr<DcaTxop> vo = m_Vo.Create<DcaTxop> ();
mac->SetAttribute ("BE", PointerValue (be));

View File

@@ -25,7 +25,7 @@
#include "ns3/mesh-wifi-interface-mac.h"
namespace ns3 {
class MeshInterfaceHelper
class MeshInterfaceHelper : public WifiMacHelper
{
public:
MeshInterfaceHelper ();
@@ -101,7 +101,7 @@ private:
*
* This method implements the pure virtual method defined in \ref ns3::WifiMacHelper.
*/
Ptr<MeshWifiInterfaceMac> Create (void) const;
Ptr<WifiMac> Create (void) const;
ObjectFactory m_mac;
ObjectFactory m_Be;