src/devices/mesh/dot11s/dot11s-installer.cc
author Kirill Andreev <andreev@iitp.ru>
Wed, 22 Jul 2009 16:43:43 +0400
changeset 5132 aee541a30256
parent 5129 5688b8da4526
child 5141 22e79c2a4c5f
permissions -rw-r--r--
Restored newline at namespace
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
5132
aee541a30256 Restored newline at namespace
Kirill Andreev <andreev@iitp.ru>
parents: 5129
diff changeset
    25
namespace ns3 {
5081
869b81c5e774 Restructured installers
Kirill Andreev <andreev@iitp.ru>
parents: 5061
diff changeset
    26
using namespace dot11s;
869b81c5e774 Restructured installers
Kirill Andreev <andreev@iitp.ru>
parents: 5061
diff changeset
    27
NS_OBJECT_ENSURE_REGISTERED (Dot11sStack);
869b81c5e774 Restructured installers
Kirill Andreev <andreev@iitp.ru>
parents: 5061
diff changeset
    28
TypeId
869b81c5e774 Restructured installers
Kirill Andreev <andreev@iitp.ru>
parents: 5061
diff changeset
    29
Dot11sStack::GetTypeId ()
869b81c5e774 Restructured installers
Kirill Andreev <andreev@iitp.ru>
parents: 5061
diff changeset
    30
{
869b81c5e774 Restructured installers
Kirill Andreev <andreev@iitp.ru>
parents: 5061
diff changeset
    31
  static TypeId tid = TypeId ("ns3::Dot11sStack")
869b81c5e774 Restructured installers
Kirill Andreev <andreev@iitp.ru>
parents: 5061
diff changeset
    32
    .SetParent<Object> ()
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
    33
    .AddConstructor<Dot11sStack> ();
5081
869b81c5e774 Restructured installers
Kirill Andreev <andreev@iitp.ru>
parents: 5061
diff changeset
    34
  return tid;
869b81c5e774 Restructured installers
Kirill Andreev <andreev@iitp.ru>
parents: 5061
diff changeset
    35
}
869b81c5e774 Restructured installers
Kirill Andreev <andreev@iitp.ru>
parents: 5061
diff changeset
    36
Dot11sStack::Dot11sStack ()
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
    37
{
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
    38
}
5081
869b81c5e774 Restructured installers
Kirill Andreev <andreev@iitp.ru>
parents: 5061
diff changeset
    39
Dot11sStack::~Dot11sStack ()
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
    40
{
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
    41
}
5081
869b81c5e774 Restructured installers
Kirill Andreev <andreev@iitp.ru>
parents: 5061
diff changeset
    42
void
869b81c5e774 Restructured installers
Kirill Andreev <andreev@iitp.ru>
parents: 5061
diff changeset
    43
Dot11sStack::DoDispose ()
869b81c5e774 Restructured installers
Kirill Andreev <andreev@iitp.ru>
parents: 5061
diff changeset
    44
{
869b81c5e774 Restructured installers
Kirill Andreev <andreev@iitp.ru>
parents: 5061
diff changeset
    45
}
869b81c5e774 Restructured installers
Kirill Andreev <andreev@iitp.ru>
parents: 5061
diff changeset
    46
void
869b81c5e774 Restructured installers
Kirill Andreev <andreev@iitp.ru>
parents: 5061
diff changeset
    47
Dot11sStack::SetRoot (Ptr<MeshPointDevice> mp)
869b81c5e774 Restructured installers
Kirill Andreev <andreev@iitp.ru>
parents: 5061
diff changeset
    48
{
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
    49
  Ptr<HwmpProtocol> hwmp = mp->GetObject<HwmpProtocol> ();
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
    50
  NS_ASSERT (hwmp != 0);
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
    51
  hwmp->SetRoot ();
5081
869b81c5e774 Restructured installers
Kirill Andreev <andreev@iitp.ru>
parents: 5061
diff changeset
    52
}
5057
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    53
bool
5081
869b81c5e774 Restructured installers
Kirill Andreev <andreev@iitp.ru>
parents: 5061
diff changeset
    54
Dot11sStack::InstallStack (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
    55
{
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    56
  //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
    57
  Ptr<PeerManagementProtocol> pmp = CreateObject<PeerManagementProtocol> ();
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
    58
  pmp->SetMeshId ("mesh");
5057
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    59
  bool install_ok = pmp->Install (mp);
5124
e206046b2e44 removed GetElementId from *.h files. Fixed spaces before '(' and added {} when needed.
Kirill Andreev <andreev@iitp.ru>
parents: 5096
diff changeset
    60
  if (!install_ok)
e206046b2e44 removed GetElementId from *.h files. Fixed spaces before '(' and added {} when needed.
Kirill Andreev <andreev@iitp.ru>
parents: 5096
diff changeset
    61
    {
e206046b2e44 removed GetElementId from *.h files. Fixed spaces before '(' and added {} when needed.
Kirill Andreev <andreev@iitp.ru>
parents: 5096
diff changeset
    62
      return false;
e206046b2e44 removed GetElementId from *.h files. Fixed spaces before '(' and added {} when needed.
Kirill Andreev <andreev@iitp.ru>
parents: 5096
diff changeset
    63
    }
5057
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    64
  //Install HWMP:
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    65
  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
    66
  install_ok = hwmp->Install (mp);
5124
e206046b2e44 removed GetElementId from *.h files. Fixed spaces before '(' and added {} when needed.
Kirill Andreev <andreev@iitp.ru>
parents: 5096
diff changeset
    67
  if (!install_ok)
e206046b2e44 removed GetElementId from *.h files. Fixed spaces before '(' and added {} when needed.
Kirill Andreev <andreev@iitp.ru>
parents: 5096
diff changeset
    68
    {
e206046b2e44 removed GetElementId from *.h files. Fixed spaces before '(' and added {} when needed.
Kirill Andreev <andreev@iitp.ru>
parents: 5096
diff changeset
    69
      return false;
e206046b2e44 removed GetElementId from *.h files. Fixed spaces before '(' and added {} when needed.
Kirill Andreev <andreev@iitp.ru>
parents: 5096
diff changeset
    70
    }
5057
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    71
  //Install interaction between HWMP and Peer management protocol:
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
    72
  pmp->SetPeerLinkStatusCallback (MakeCallback (&HwmpProtocol::PeerLinkStatus, hwmp));
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
    73
  hwmp->SetNeighboursCallback (MakeCallback (&PeerManagementProtocol::GetActiveLinks, pmp));
5057
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    74
  return true;
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
void
5081
869b81c5e774 Restructured installers
Kirill Andreev <andreev@iitp.ru>
parents: 5061
diff changeset
    77
Dot11sStack::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
    78
{
5096
79c84012dac7 RX/TX/FWD stats in MeshPointDevice
Pavel Boyko <boyko@iitp.ru>
parents: 5081
diff changeset
    79
  mp->Report (os);
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
    80
5057
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    81
  std::vector<Ptr<NetDevice> > ifaces = mp->GetInterfaces ();
5124
e206046b2e44 removed GetElementId from *.h files. Fixed spaces before '(' and added {} when needed.
Kirill Andreev <andreev@iitp.ru>
parents: 5096
diff changeset
    82
  for (std::vector<Ptr<NetDevice> >::const_iterator i = ifaces.begin (); i != ifaces.end (); ++i)
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
    83
    {
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
    84
      Ptr<WifiNetDevice> device = (*i)->GetObject<WifiNetDevice> ();
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
    85
      NS_ASSERT (device != 0);
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
    86
      MeshInterfaceHelper::Report (device, os);
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
    87
    }
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
    88
  Ptr<HwmpProtocol> hwmp = mp->GetObject<HwmpProtocol> ();
5124
e206046b2e44 removed GetElementId from *.h files. Fixed spaces before '(' and added {} when needed.
Kirill Andreev <andreev@iitp.ru>
parents: 5096
diff changeset
    89
  NS_ASSERT (hwmp != 0);
5057
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    90
  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
    91
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
    92
  Ptr<PeerManagementProtocol> pmp = mp->GetObject<PeerManagementProtocol> ();
5124
e206046b2e44 removed GetElementId from *.h files. Fixed spaces before '(' and added {} when needed.
Kirill Andreev <andreev@iitp.ru>
parents: 5096
diff changeset
    93
  NS_ASSERT (pmp != 0);
5057
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    94
  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
    95
}
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    96
void
5081
869b81c5e774 Restructured installers
Kirill Andreev <andreev@iitp.ru>
parents: 5061
diff changeset
    97
Dot11sStack::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
    98
{
5096
79c84012dac7 RX/TX/FWD stats in MeshPointDevice
Pavel Boyko <boyko@iitp.ru>
parents: 5081
diff changeset
    99
  mp->ResetStats ();
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   100
5057
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   101
  std::vector<Ptr<NetDevice> > ifaces = mp->GetInterfaces ();
5124
e206046b2e44 removed GetElementId from *.h files. Fixed spaces before '(' and added {} when needed.
Kirill Andreev <andreev@iitp.ru>
parents: 5096
diff changeset
   102
  for (std::vector<Ptr<NetDevice> >::const_iterator i = ifaces.begin (); i != ifaces.end (); ++i)
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   103
    {
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   104
      Ptr<WifiNetDevice> device = (*i)->GetObject<WifiNetDevice> ();
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   105
      NS_ASSERT (device != 0);
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   106
      MeshInterfaceHelper::ResetStats (device);
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   107
    }
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   108
  Ptr<HwmpProtocol> hwmp = mp->GetObject<HwmpProtocol> ();
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   109
  NS_ASSERT (hwmp != 0);
5057
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   110
  hwmp->ResetStats ();
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   111
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   112
  Ptr<PeerManagementProtocol> pmp = mp->GetObject<PeerManagementProtocol> ();
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   113
  NS_ASSERT (pmp != 0);
5057
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   114
  pmp->ResetStats ();
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   115
}
5081
869b81c5e774 Restructured installers
Kirill Andreev <andreev@iitp.ru>
parents: 5061
diff changeset
   116
} //namespace ns3