src/devices/mesh/dot11s/dot11s-installer.cc
author Kirill Andreev <andreev@iitp.ru>
Fri, 31 Jul 2009 19:38:26 +0400
changeset 5144 b8a77656a7b8
parent 5141 22e79c2a4c5f
child 5164 b81ab8394a61
permissions -rw-r--r--
Fix
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> ()
5141
22e79c2a4c5f Added root mesh point as argument of command line
Kirill Andreev <andreev@iitp.ru>
parents: 5132
diff changeset
    33
    .AddConstructor<Dot11sStack> ()
22e79c2a4c5f Added root mesh point as argument of command line
Kirill Andreev <andreev@iitp.ru>
parents: 5132
diff changeset
    34
    .AddAttribute ("Root", 
22e79c2a4c5f Added root mesh point as argument of command line
Kirill Andreev <andreev@iitp.ru>
parents: 5132
diff changeset
    35
                   "The MAC address of root mesh point.",
22e79c2a4c5f Added root mesh point as argument of command line
Kirill Andreev <andreev@iitp.ru>
parents: 5132
diff changeset
    36
                   Mac48AddressValue (Mac48Address ("ff:ff:ff:ff:ff:ff")),
22e79c2a4c5f Added root mesh point as argument of command line
Kirill Andreev <andreev@iitp.ru>
parents: 5132
diff changeset
    37
                   MakeMac48AddressAccessor (&Dot11sStack::m_root),
22e79c2a4c5f Added root mesh point as argument of command line
Kirill Andreev <andreev@iitp.ru>
parents: 5132
diff changeset
    38
                   MakeMac48AddressChecker ());
5081
869b81c5e774 Restructured installers
Kirill Andreev <andreev@iitp.ru>
parents: 5061
diff changeset
    39
  return tid;
869b81c5e774 Restructured installers
Kirill Andreev <andreev@iitp.ru>
parents: 5061
diff changeset
    40
}
5141
22e79c2a4c5f Added root mesh point as argument of command line
Kirill Andreev <andreev@iitp.ru>
parents: 5132
diff changeset
    41
Dot11sStack::Dot11sStack () :
22e79c2a4c5f Added root mesh point as argument of command line
Kirill Andreev <andreev@iitp.ru>
parents: 5132
diff changeset
    42
  m_root (Mac48Address ("ff:ff:ff:ff:ff:ff"))
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
    43
{
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
    44
}
5081
869b81c5e774 Restructured installers
Kirill Andreev <andreev@iitp.ru>
parents: 5061
diff changeset
    45
Dot11sStack::~Dot11sStack ()
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
    46
{
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
    47
}
5081
869b81c5e774 Restructured installers
Kirill Andreev <andreev@iitp.ru>
parents: 5061
diff changeset
    48
void
869b81c5e774 Restructured installers
Kirill Andreev <andreev@iitp.ru>
parents: 5061
diff changeset
    49
Dot11sStack::DoDispose ()
869b81c5e774 Restructured installers
Kirill Andreev <andreev@iitp.ru>
parents: 5061
diff changeset
    50
{
869b81c5e774 Restructured installers
Kirill Andreev <andreev@iitp.ru>
parents: 5061
diff changeset
    51
}
5057
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    52
bool
5081
869b81c5e774 Restructured installers
Kirill Andreev <andreev@iitp.ru>
parents: 5061
diff changeset
    53
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
    54
{
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    55
  //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
    56
  Ptr<PeerManagementProtocol> pmp = CreateObject<PeerManagementProtocol> ();
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
    57
  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
    58
  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
    59
  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
    60
    {
e206046b2e44 removed GetElementId from *.h files. Fixed spaces before '(' and added {} when needed.
Kirill Andreev <andreev@iitp.ru>
parents: 5096
diff changeset
    61
      return false;
e206046b2e44 removed GetElementId from *.h files. Fixed spaces before '(' and added {} when needed.
Kirill Andreev <andreev@iitp.ru>
parents: 5096
diff changeset
    62
    }
5057
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    63
  //Install HWMP:
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    64
  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
    65
  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
    66
  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
    67
    {
e206046b2e44 removed GetElementId from *.h files. Fixed spaces before '(' and added {} when needed.
Kirill Andreev <andreev@iitp.ru>
parents: 5096
diff changeset
    68
      return false;
e206046b2e44 removed GetElementId from *.h files. Fixed spaces before '(' and added {} when needed.
Kirill Andreev <andreev@iitp.ru>
parents: 5096
diff changeset
    69
    }
5141
22e79c2a4c5f Added root mesh point as argument of command line
Kirill Andreev <andreev@iitp.ru>
parents: 5132
diff changeset
    70
  if (mp->GetAddress() == m_root)
22e79c2a4c5f Added root mesh point as argument of command line
Kirill Andreev <andreev@iitp.ru>
parents: 5132
diff changeset
    71
    {
22e79c2a4c5f Added root mesh point as argument of command line
Kirill Andreev <andreev@iitp.ru>
parents: 5132
diff changeset
    72
      hwmp->SetRoot ();
22e79c2a4c5f Added root mesh point as argument of command line
Kirill Andreev <andreev@iitp.ru>
parents: 5132
diff changeset
    73
    }
5057
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    74
  //Install interaction between HWMP and Peer management protocol:
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
    75
  pmp->SetPeerLinkStatusCallback (MakeCallback (&HwmpProtocol::PeerLinkStatus, hwmp));
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
    76
  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
    77
  return true;
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    78
}
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    79
void
5081
869b81c5e774 Restructured installers
Kirill Andreev <andreev@iitp.ru>
parents: 5061
diff changeset
    80
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
    81
{
5096
79c84012dac7 RX/TX/FWD stats in MeshPointDevice
Pavel Boyko <boyko@iitp.ru>
parents: 5081
diff changeset
    82
  mp->Report (os);
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
    83
5057
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    84
  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
    85
  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
    86
    {
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
    87
      Ptr<WifiNetDevice> device = (*i)->GetObject<WifiNetDevice> ();
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
    88
      NS_ASSERT (device != 0);
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
    89
      MeshInterfaceHelper::Report (device, os);
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
    90
    }
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
    91
  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
    92
  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
    93
  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
    94
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
    95
  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
    96
  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
    97
  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
    98
}
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    99
void
5081
869b81c5e774 Restructured installers
Kirill Andreev <andreev@iitp.ru>
parents: 5061
diff changeset
   100
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
   101
{
5096
79c84012dac7 RX/TX/FWD stats in MeshPointDevice
Pavel Boyko <boyko@iitp.ru>
parents: 5081
diff changeset
   102
  mp->ResetStats ();
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   103
5057
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   104
  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
   105
  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
   106
    {
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   107
      Ptr<WifiNetDevice> device = (*i)->GetObject<WifiNetDevice> ();
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   108
      NS_ASSERT (device != 0);
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   109
      MeshInterfaceHelper::ResetStats (device);
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   110
    }
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   111
  Ptr<HwmpProtocol> hwmp = mp->GetObject<HwmpProtocol> ();
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   112
  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
   113
  hwmp->ResetStats ();
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   114
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   115
  Ptr<PeerManagementProtocol> pmp = mp->GetObject<PeerManagementProtocol> ();
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   116
  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
   117
  pmp->ResetStats ();
95a72c98f08d Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   118
}
5081
869b81c5e774 Restructured installers
Kirill Andreev <andreev@iitp.ru>
parents: 5061
diff changeset
   119
} //namespace ns3