src/devices/mesh/dot11s/dot11s-installer.cc
author Kirill Andreev <andreev@iitp.ru>
Wed, 10 Jun 2009 18:57:27 +0400
changeset 5061 63bbbc12e331
parent 5058 src/devices/mesh/dot11s/dot11s-installator.cc@86ee8343d8f7
child 5081 869b81c5e774
permissions -rw-r--r--
Fixed names
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5057
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
     1
/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
     2
/*
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
     3
 * Copyright (c) 2008,2009 IITP RAS
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
     4
 *
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License version 2 as
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
     7
 * published by the Free Software Foundation;
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
     8
 *
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    12
 * GNU General Public License for more details.
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    13
 *
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    17
 *
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    18
 * Authors: Kirill Andreev <andreev@iitp.ru>
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    19
 */
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    20
#include "ns3/mesh-interface-helper.h"
5061
63bbbc12e331 Fixed names
Kirill Andreev <andreev@iitp.ru>
parents: 5058
diff changeset
    21
#include "dot11s-installer.h"
5057
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    22
#include "peer-management-protocol.h"
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    23
#include "hwmp-protocol.h"
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    24
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    25
namespace ns3 {
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    26
namespace dot11s {
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    27
bool
5061
63bbbc12e331 Fixed names
Kirill Andreev <andreev@iitp.ru>
parents: 5058
diff changeset
    28
Dot11sStackInstaller::InstallDot11sStack (Ptr<MeshPointDevice> mp, bool root)
5057
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    29
{
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    30
  //Install Peer management protocol:
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    31
  Ptr<PeerManagementProtocol> pmp = CreateObject<PeerManagementProtocol> ();
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    32
  pmp->SetMeshId("mesh");
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    33
  bool install_ok = pmp->Install (mp);
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    34
  if(!install_ok)
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    35
    return false;
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    36
  //Install HWMP:
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    37
  Ptr<HwmpProtocol> hwmp = CreateObject<HwmpProtocol> ();
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    38
  install_ok = hwmp->Install (mp);
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    39
  if(!install_ok)
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    40
    return false;
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    41
  if(root)
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    42
    hwmp->SetRoot ();
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    43
  //Install interaction between HWMP and Peer management protocol:
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    44
  pmp->SetPeerLinkStatusCallback(MakeCallback(&HwmpProtocol::PeerLinkStatus, hwmp));
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    45
  hwmp->SetNeighboursCallback(MakeCallback(&PeerManagementProtocol::GetActiveLinks, pmp));
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    46
  return true;
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    47
}
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    48
void
5061
63bbbc12e331 Fixed names
Kirill Andreev <andreev@iitp.ru>
parents: 5058
diff changeset
    49
Dot11sStackInstaller::Report (const Ptr<MeshPointDevice> mp, std::ostream& os)
5057
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    50
{
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    51
  std::vector<Ptr<NetDevice> > ifaces = mp->GetInterfaces ();
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    52
  for (std::vector<Ptr<NetDevice> >::const_iterator i = ifaces.begin(); i != ifaces.end(); ++i)
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    53
  {
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    54
    Ptr<WifiNetDevice> device = (*i)->GetObject<WifiNetDevice> ();
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    55
    NS_ASSERT (device != 0);
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    56
    MeshInterfaceHelper::Report(device, os);
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    57
  }
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    58
  Ptr <HwmpProtocol> hwmp = mp->GetObject<HwmpProtocol> ();
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    59
  NS_ASSERT(hwmp != 0);
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    60
  hwmp->Report (os);
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    61
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    62
  Ptr <PeerManagementProtocol> pmp = mp->GetObject<PeerManagementProtocol> ();
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    63
  NS_ASSERT(pmp != 0);
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    64
  pmp->Report (os);
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    65
}
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    66
void
5061
63bbbc12e331 Fixed names
Kirill Andreev <andreev@iitp.ru>
parents: 5058
diff changeset
    67
Dot11sStackInstaller::ResetStats (const Ptr<MeshPointDevice> mp)
5057
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    68
{
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    69
  std::vector<Ptr<NetDevice> > ifaces = mp->GetInterfaces ();
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    70
  for (std::vector<Ptr<NetDevice> >::const_iterator i = ifaces.begin(); i != ifaces.end(); ++i)
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    71
  {
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    72
    Ptr<WifiNetDevice> device = (*i)->GetObject<WifiNetDevice> ();
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    73
    NS_ASSERT (device != 0);
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    74
    MeshInterfaceHelper::ResetStats (device);
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    75
  }
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    76
  Ptr <HwmpProtocol> hwmp = mp->GetObject<HwmpProtocol> ();
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    77
  NS_ASSERT(hwmp != 0);
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    78
  hwmp->ResetStats ();
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    79
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    80
  Ptr <PeerManagementProtocol> pmp = mp->GetObject<PeerManagementProtocol> ();
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    81
  NS_ASSERT(pmp != 0);
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    82
  pmp->ResetStats ();
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    83
}
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    84
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    85
}
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    86
}