src/devices/mesh/dot11s/hwmp-protocol-mac.cc
author Craig Dowell <craigdo@ee.washington.edu>
Mon, 12 Oct 2009 23:31:58 -0700
changeset 5413 64931d320790
parent 5174 404f414bfaa7
child 5824 5abf274b52d4
permissions -rw-r--r--
fix valgrind complaints (bug 711)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
     1
/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
     2
/*
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
     3
 * Copyright (c) 2008,2009 IITP RAS
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
     4
 *
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
4812
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4809
diff changeset
     6
 * it under the terms of the GNU General Public License version 2 as
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
     7
 * published by the Free Software Foundation;
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
     8
 *
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    12
 * GNU General Public License for more details.
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    13
 *
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    17
 *
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    18
 * Author: Kirill Andreev <andreev@iitp.ru>
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    19
 */
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    20
4887
cbf02c77d5c1 HWMP is attached to mesh point device and MAC layer with zero functionality
Kirill Andreev <andreev@iitp.ru>
parents: 4886
diff changeset
    21
#include "ns3/mesh-wifi-interface-mac.h"
cbf02c77d5c1 HWMP is attached to mesh point device and MAC layer with zero functionality
Kirill Andreev <andreev@iitp.ru>
parents: 4886
diff changeset
    22
#include "ns3/packet.h"
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    23
#include "ns3/simulator.h"
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    24
#include "ns3/nstime.h"
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    25
#include "ns3/log.h"
4956
aba7cae978ac MeshWifiMacHeader moved to Dot11sMacHeader. test to it is written
Kirill Andreev <andreev@iitp.ru>
parents: 4955
diff changeset
    26
#include "dot11s-mac-header.h"
5086
fccfd0073ea3 Fixed names: now protocols are called *-protocol.[h,cc], plugin is called
Kirill Andreev <andreev@iitp.ru>
parents: 5083
diff changeset
    27
#include "hwmp-protocol-mac.h"
4889
279b07de3327 Fixrd bugs with address extensions, broadcast frames can go through L2Routing
Kirill Andreev <andreev@iitp.ru>
parents: 4887
diff changeset
    28
#include "hwmp-tag.h"
4887
cbf02c77d5c1 HWMP is attached to mesh point device and MAC layer with zero functionality
Kirill Andreev <andreev@iitp.ru>
parents: 4886
diff changeset
    29
#include "ie-dot11s-preq.h"
cbf02c77d5c1 HWMP is attached to mesh point device and MAC layer with zero functionality
Kirill Andreev <andreev@iitp.ru>
parents: 4886
diff changeset
    30
#include "ie-dot11s-prep.h"
5112
762835be2902 Action values are made in accordance with Draft3.0
Kirill Andreev <andreev@iitp.ru>
parents: 5111
diff changeset
    31
#include "ie-dot11s-rann.h"
5168
72bf9328f412 Failed destination is structure of HWMP
Kirill Andreev <andreev@iitp.ru>
parents: 5162
diff changeset
    32
#include "ie-dot11s-perr.h"
4813
e4e2c44d27cd All mesh related filed moved to devices/mesh. Let the refactoring begins!
Pavel Boyko <boyko@iitp.ru>
parents: 4812
diff changeset
    33
5132
aee541a30256 Restored newline at namespace
Kirill Andreev <andreev@iitp.ru>
parents: 5130
diff changeset
    34
namespace ns3 {
aee541a30256 Restored newline at namespace
Kirill Andreev <andreev@iitp.ru>
parents: 5130
diff changeset
    35
namespace dot11s {
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    36
5086
fccfd0073ea3 Fixed names: now protocols are called *-protocol.[h,cc], plugin is called
Kirill Andreev <andreev@iitp.ru>
parents: 5083
diff changeset
    37
NS_LOG_COMPONENT_DEFINE ("HwmpProtocolMac");
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
    38
HwmpProtocolMac::HwmpProtocolMac (uint32_t ifIndex, Ptr<HwmpProtocol> protocol) :
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
    39
  m_ifIndex (ifIndex), m_protocol (protocol)
4887
cbf02c77d5c1 HWMP is attached to mesh point device and MAC layer with zero functionality
Kirill Andreev <andreev@iitp.ru>
parents: 4886
diff changeset
    40
{
cbf02c77d5c1 HWMP is attached to mesh point device and MAC layer with zero functionality
Kirill Andreev <andreev@iitp.ru>
parents: 4886
diff changeset
    41
}
5086
fccfd0073ea3 Fixed names: now protocols are called *-protocol.[h,cc], plugin is called
Kirill Andreev <andreev@iitp.ru>
parents: 5083
diff changeset
    42
HwmpProtocolMac::~HwmpProtocolMac ()
4887
cbf02c77d5c1 HWMP is attached to mesh point device and MAC layer with zero functionality
Kirill Andreev <andreev@iitp.ru>
parents: 4886
diff changeset
    43
{
cbf02c77d5c1 HWMP is attached to mesh point device and MAC layer with zero functionality
Kirill Andreev <andreev@iitp.ru>
parents: 4886
diff changeset
    44
}
cbf02c77d5c1 HWMP is attached to mesh point device and MAC layer with zero functionality
Kirill Andreev <andreev@iitp.ru>
parents: 4886
diff changeset
    45
void
5086
fccfd0073ea3 Fixed names: now protocols are called *-protocol.[h,cc], plugin is called
Kirill Andreev <andreev@iitp.ru>
parents: 5083
diff changeset
    46
HwmpProtocolMac::SetParent (Ptr<MeshWifiInterfaceMac> parent)
4887
cbf02c77d5c1 HWMP is attached to mesh point device and MAC layer with zero functionality
Kirill Andreev <andreev@iitp.ru>
parents: 4886
diff changeset
    47
{
cbf02c77d5c1 HWMP is attached to mesh point device and MAC layer with zero functionality
Kirill Andreev <andreev@iitp.ru>
parents: 4886
diff changeset
    48
  m_parent = parent;
cbf02c77d5c1 HWMP is attached to mesh point device and MAC layer with zero functionality
Kirill Andreev <andreev@iitp.ru>
parents: 4886
diff changeset
    49
}
5063
97b947e83640 Faker's code review response
Pavel Boyko <boyko@iitp.ru>
parents: 5057
diff changeset
    50
97b947e83640 Faker's code review response
Pavel Boyko <boyko@iitp.ru>
parents: 5057
diff changeset
    51
bool
5086
fccfd0073ea3 Fixed names: now protocols are called *-protocol.[h,cc], plugin is called
Kirill Andreev <andreev@iitp.ru>
parents: 5083
diff changeset
    52
HwmpProtocolMac::ReceiveData (Ptr<Packet> packet, const WifiMacHeader & header)
5063
97b947e83640 Faker's code review response
Pavel Boyko <boyko@iitp.ru>
parents: 5057
diff changeset
    53
{
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
    54
  NS_ASSERT (header.IsData ());
5063
97b947e83640 Faker's code review response
Pavel Boyko <boyko@iitp.ru>
parents: 5057
diff changeset
    55
97b947e83640 Faker's code review response
Pavel Boyko <boyko@iitp.ru>
parents: 5057
diff changeset
    56
  MeshHeader meshHdr;
97b947e83640 Faker's code review response
Pavel Boyko <boyko@iitp.ru>
parents: 5057
diff changeset
    57
  HwmpTag tag;
5125
b90c6c0af6a3 Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents: 5113
diff changeset
    58
  if (packet->PeekPacketTag (tag))
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
    59
    {
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
    60
      NS_FATAL_ERROR ("HWMP tag is not supposed to be received by network");
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
    61
    }
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
    62
5125
b90c6c0af6a3 Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents: 5113
diff changeset
    63
  packet->RemoveHeader (meshHdr);
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
    64
  m_stats.rxData++;
5063
97b947e83640 Faker's code review response
Pavel Boyko <boyko@iitp.ru>
parents: 5057
diff changeset
    65
  m_stats.rxDataBytes += packet->GetSize ();
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
    66
5063
97b947e83640 Faker's code review response
Pavel Boyko <boyko@iitp.ru>
parents: 5057
diff changeset
    67
  //TODO: address extension
97b947e83640 Faker's code review response
Pavel Boyko <boyko@iitp.ru>
parents: 5057
diff changeset
    68
  Mac48Address destination;
97b947e83640 Faker's code review response
Pavel Boyko <boyko@iitp.ru>
parents: 5057
diff changeset
    69
  Mac48Address source;
97b947e83640 Faker's code review response
Pavel Boyko <boyko@iitp.ru>
parents: 5057
diff changeset
    70
  switch (meshHdr.GetAddressExt ())
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
    71
    {
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
    72
  case 0:
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
    73
    source = header.GetAddr4 ();
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
    74
    destination = header.GetAddr3 ();
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
    75
    break;
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
    76
  default:
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
    77
    NS_FATAL_ERROR (
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
    78
        "6-address scheme is not yet supported and 4-address extension is not supposed to be used for data frames.");
5162
35963e5411c0 PrintInformation replaced with Prin in information elements, added operator
Kirill Andreev <andreev@iitp.ru>
parents: 5158
diff changeset
    79
    }
5063
97b947e83640 Faker's code review response
Pavel Boyko <boyko@iitp.ru>
parents: 5057
diff changeset
    80
  tag.SetSeqno (meshHdr.GetMeshSeqno ());
97b947e83640 Faker's code review response
Pavel Boyko <boyko@iitp.ru>
parents: 5057
diff changeset
    81
  tag.SetTtl (meshHdr.GetMeshTtl ());
5125
b90c6c0af6a3 Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents: 5113
diff changeset
    82
  packet->AddPacketTag (tag);
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
    83
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
    84
  if ((destination == Mac48Address::GetBroadcast ()) && (m_protocol->DropDataFrame (meshHdr.GetMeshSeqno (),
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
    85
      source)))
5125
b90c6c0af6a3 Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents: 5113
diff changeset
    86
    {
5063
97b947e83640 Faker's code review response
Pavel Boyko <boyko@iitp.ru>
parents: 5057
diff changeset
    87
      return false;
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
    88
    }
5063
97b947e83640 Faker's code review response
Pavel Boyko <boyko@iitp.ru>
parents: 5057
diff changeset
    89
  return true;
97b947e83640 Faker's code review response
Pavel Boyko <boyko@iitp.ru>
parents: 5057
diff changeset
    90
}
97b947e83640 Faker's code review response
Pavel Boyko <boyko@iitp.ru>
parents: 5057
diff changeset
    91
97b947e83640 Faker's code review response
Pavel Boyko <boyko@iitp.ru>
parents: 5057
diff changeset
    92
bool
5086
fccfd0073ea3 Fixed names: now protocols are called *-protocol.[h,cc], plugin is called
Kirill Andreev <andreev@iitp.ru>
parents: 5083
diff changeset
    93
HwmpProtocolMac::ReceiveAction (Ptr<Packet> packet, const WifiMacHeader & header)
5063
97b947e83640 Faker's code review response
Pavel Boyko <boyko@iitp.ru>
parents: 5057
diff changeset
    94
{
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
    95
  m_stats.rxMgt++;
5063
97b947e83640 Faker's code review response
Pavel Boyko <boyko@iitp.ru>
parents: 5057
diff changeset
    96
  m_stats.rxMgtBytes += packet->GetSize ();
97b947e83640 Faker's code review response
Pavel Boyko <boyko@iitp.ru>
parents: 5057
diff changeset
    97
  WifiMeshActionHeader actionHdr;
97b947e83640 Faker's code review response
Pavel Boyko <boyko@iitp.ru>
parents: 5057
diff changeset
    98
  packet->RemoveHeader (actionHdr);
97b947e83640 Faker's code review response
Pavel Boyko <boyko@iitp.ru>
parents: 5057
diff changeset
    99
  WifiMeshActionHeader::ActionValue actionValue = actionHdr.GetAction ();
5125
b90c6c0af6a3 Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents: 5113
diff changeset
   100
  if (actionHdr.GetCategory () != WifiMeshActionHeader::MESH_PATH_SELECTION)
b90c6c0af6a3 Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents: 5113
diff changeset
   101
    {
b90c6c0af6a3 Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents: 5113
diff changeset
   102
      return true;
b90c6c0af6a3 Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents: 5113
diff changeset
   103
    }
5158
0baed7827260 Start to remove inheritance from header in WifiInformationElement
Kirill Andreev <andreev@iitp.ru>
parents: 5157
diff changeset
   104
  WifiInformationElementVector elements;
0baed7827260 Start to remove inheritance from header in WifiInformationElement
Kirill Andreev <andreev@iitp.ru>
parents: 5157
diff changeset
   105
  packet->RemoveHeader (elements);
5168
72bf9328f412 Failed destination is structure of HWMP
Kirill Andreev <andreev@iitp.ru>
parents: 5162
diff changeset
   106
  std::vector<HwmpProtocol::FailedDestination> failedDestinations;
5158
0baed7827260 Start to remove inheritance from header in WifiInformationElement
Kirill Andreev <andreev@iitp.ru>
parents: 5157
diff changeset
   107
  for (WifiInformationElementVector::Iterator i = elements.Begin(); i != elements.End(); i ++)
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   108
    {
5158
0baed7827260 Start to remove inheritance from header in WifiInformationElement
Kirill Andreev <andreev@iitp.ru>
parents: 5157
diff changeset
   109
      if ((*i)->ElementId () == IE11S_RANN)
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   110
        {
5158
0baed7827260 Start to remove inheritance from header in WifiInformationElement
Kirill Andreev <andreev@iitp.ru>
parents: 5157
diff changeset
   111
          NS_LOG_WARN ("RANN is not supported!");
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   112
        }
5158
0baed7827260 Start to remove inheritance from header in WifiInformationElement
Kirill Andreev <andreev@iitp.ru>
parents: 5157
diff changeset
   113
      if ((*i)->ElementId () == IE11S_PREQ)
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   114
        {
5158
0baed7827260 Start to remove inheritance from header in WifiInformationElement
Kirill Andreev <andreev@iitp.ru>
parents: 5157
diff changeset
   115
          Ptr<IePreq> preq = DynamicCast<IePreq> (*i);
0baed7827260 Start to remove inheritance from header in WifiInformationElement
Kirill Andreev <andreev@iitp.ru>
parents: 5157
diff changeset
   116
          NS_ASSERT (preq != 0);
0baed7827260 Start to remove inheritance from header in WifiInformationElement
Kirill Andreev <andreev@iitp.ru>
parents: 5157
diff changeset
   117
          m_stats.rxPreq++;
0baed7827260 Start to remove inheritance from header in WifiInformationElement
Kirill Andreev <andreev@iitp.ru>
parents: 5157
diff changeset
   118
          if (preq->GetOriginatorAddress () == m_protocol->GetAddress ())
0baed7827260 Start to remove inheritance from header in WifiInformationElement
Kirill Andreev <andreev@iitp.ru>
parents: 5157
diff changeset
   119
            {
0baed7827260 Start to remove inheritance from header in WifiInformationElement
Kirill Andreev <andreev@iitp.ru>
parents: 5157
diff changeset
   120
              continue;
0baed7827260 Start to remove inheritance from header in WifiInformationElement
Kirill Andreev <andreev@iitp.ru>
parents: 5157
diff changeset
   121
            }
0baed7827260 Start to remove inheritance from header in WifiInformationElement
Kirill Andreev <andreev@iitp.ru>
parents: 5157
diff changeset
   122
          if (preq->GetTtl () == 0)
0baed7827260 Start to remove inheritance from header in WifiInformationElement
Kirill Andreev <andreev@iitp.ru>
parents: 5157
diff changeset
   123
            {
0baed7827260 Start to remove inheritance from header in WifiInformationElement
Kirill Andreev <andreev@iitp.ru>
parents: 5157
diff changeset
   124
              continue;
0baed7827260 Start to remove inheritance from header in WifiInformationElement
Kirill Andreev <andreev@iitp.ru>
parents: 5157
diff changeset
   125
            }
0baed7827260 Start to remove inheritance from header in WifiInformationElement
Kirill Andreev <andreev@iitp.ru>
parents: 5157
diff changeset
   126
          preq->DecrementTtl ();
0baed7827260 Start to remove inheritance from header in WifiInformationElement
Kirill Andreev <andreev@iitp.ru>
parents: 5157
diff changeset
   127
          m_protocol->ReceivePreq (*preq, header.GetAddr2 (), m_ifIndex, header.GetAddr3 (),
0baed7827260 Start to remove inheritance from header in WifiInformationElement
Kirill Andreev <andreev@iitp.ru>
parents: 5157
diff changeset
   128
              m_parent->GetLinkMetric (header.GetAddr2 ()));
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   129
        }
5158
0baed7827260 Start to remove inheritance from header in WifiInformationElement
Kirill Andreev <andreev@iitp.ru>
parents: 5157
diff changeset
   130
      if ((*i)->ElementId () == IE11S_PREP)
5130
b5062e8e0da1 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5129
diff changeset
   131
        {
5158
0baed7827260 Start to remove inheritance from header in WifiInformationElement
Kirill Andreev <andreev@iitp.ru>
parents: 5157
diff changeset
   132
          Ptr<IePrep> prep = DynamicCast<IePrep> (*i);
0baed7827260 Start to remove inheritance from header in WifiInformationElement
Kirill Andreev <andreev@iitp.ru>
parents: 5157
diff changeset
   133
          NS_ASSERT (prep != 0);
0baed7827260 Start to remove inheritance from header in WifiInformationElement
Kirill Andreev <andreev@iitp.ru>
parents: 5157
diff changeset
   134
          m_stats.rxPrep++;
0baed7827260 Start to remove inheritance from header in WifiInformationElement
Kirill Andreev <andreev@iitp.ru>
parents: 5157
diff changeset
   135
          if (prep->GetTtl () == 0)
0baed7827260 Start to remove inheritance from header in WifiInformationElement
Kirill Andreev <andreev@iitp.ru>
parents: 5157
diff changeset
   136
            {
0baed7827260 Start to remove inheritance from header in WifiInformationElement
Kirill Andreev <andreev@iitp.ru>
parents: 5157
diff changeset
   137
              continue;
0baed7827260 Start to remove inheritance from header in WifiInformationElement
Kirill Andreev <andreev@iitp.ru>
parents: 5157
diff changeset
   138
            }
0baed7827260 Start to remove inheritance from header in WifiInformationElement
Kirill Andreev <andreev@iitp.ru>
parents: 5157
diff changeset
   139
          prep->DecrementTtl ();
0baed7827260 Start to remove inheritance from header in WifiInformationElement
Kirill Andreev <andreev@iitp.ru>
parents: 5157
diff changeset
   140
          m_protocol->ReceivePrep (*prep, header.GetAddr2 (), m_ifIndex, header.GetAddr3 (),
0baed7827260 Start to remove inheritance from header in WifiInformationElement
Kirill Andreev <andreev@iitp.ru>
parents: 5157
diff changeset
   141
              m_parent->GetLinkMetric (header.GetAddr2 ()));
0baed7827260 Start to remove inheritance from header in WifiInformationElement
Kirill Andreev <andreev@iitp.ru>
parents: 5157
diff changeset
   142
        }
0baed7827260 Start to remove inheritance from header in WifiInformationElement
Kirill Andreev <andreev@iitp.ru>
parents: 5157
diff changeset
   143
      if ((*i)->ElementId () == IE11S_PERR)
0baed7827260 Start to remove inheritance from header in WifiInformationElement
Kirill Andreev <andreev@iitp.ru>
parents: 5157
diff changeset
   144
        {
0baed7827260 Start to remove inheritance from header in WifiInformationElement
Kirill Andreev <andreev@iitp.ru>
parents: 5157
diff changeset
   145
          Ptr<IePerr> perr = DynamicCast<IePerr> (*i);
0baed7827260 Start to remove inheritance from header in WifiInformationElement
Kirill Andreev <andreev@iitp.ru>
parents: 5157
diff changeset
   146
          NS_ASSERT (perr != 0);
0baed7827260 Start to remove inheritance from header in WifiInformationElement
Kirill Andreev <andreev@iitp.ru>
parents: 5157
diff changeset
   147
          m_stats.rxPerr++;
5168
72bf9328f412 Failed destination is structure of HWMP
Kirill Andreev <andreev@iitp.ru>
parents: 5162
diff changeset
   148
          std::vector<HwmpProtocol::FailedDestination> destinations = perr->GetAddressUnitVector ();
72bf9328f412 Failed destination is structure of HWMP
Kirill Andreev <andreev@iitp.ru>
parents: 5162
diff changeset
   149
          for (std::vector<HwmpProtocol::FailedDestination>::const_iterator i = destinations.begin (); i
5158
0baed7827260 Start to remove inheritance from header in WifiInformationElement
Kirill Andreev <andreev@iitp.ru>
parents: 5157
diff changeset
   150
              != destinations.end (); i++)
0baed7827260 Start to remove inheritance from header in WifiInformationElement
Kirill Andreev <andreev@iitp.ru>
parents: 5157
diff changeset
   151
            {
0baed7827260 Start to remove inheritance from header in WifiInformationElement
Kirill Andreev <andreev@iitp.ru>
parents: 5157
diff changeset
   152
              failedDestinations.push_back (*i);
0baed7827260 Start to remove inheritance from header in WifiInformationElement
Kirill Andreev <andreev@iitp.ru>
parents: 5157
diff changeset
   153
            }
5130
b5062e8e0da1 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5129
diff changeset
   154
        }
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   155
    }
5113
a912d4372406 PREQ, PREP overflow is handled correctly
Kirill Andreev <andreev@iitp.ru>
parents: 5112
diff changeset
   156
  if (failedDestinations.size () > 0)
5125
b90c6c0af6a3 Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents: 5113
diff changeset
   157
    {
b90c6c0af6a3 Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents: 5113
diff changeset
   158
      m_protocol->ReceivePerr (failedDestinations, header.GetAddr2 (), m_ifIndex, header.GetAddr3 ());
b90c6c0af6a3 Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents: 5113
diff changeset
   159
    }
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   160
  NS_ASSERT (packet->GetSize () == 0);
5112
762835be2902 Action values are made in accordance with Draft3.0
Kirill Andreev <andreev@iitp.ru>
parents: 5111
diff changeset
   161
  return false;
5063
97b947e83640 Faker's code review response
Pavel Boyko <boyko@iitp.ru>
parents: 5057
diff changeset
   162
}
97b947e83640 Faker's code review response
Pavel Boyko <boyko@iitp.ru>
parents: 5057
diff changeset
   163
4887
cbf02c77d5c1 HWMP is attached to mesh point device and MAC layer with zero functionality
Kirill Andreev <andreev@iitp.ru>
parents: 4886
diff changeset
   164
bool
5086
fccfd0073ea3 Fixed names: now protocols are called *-protocol.[h,cc], plugin is called
Kirill Andreev <andreev@iitp.ru>
parents: 5083
diff changeset
   165
HwmpProtocolMac::Receive (Ptr<Packet> packet, const WifiMacHeader & header)
4887
cbf02c77d5c1 HWMP is attached to mesh point device and MAC layer with zero functionality
Kirill Andreev <andreev@iitp.ru>
parents: 4886
diff changeset
   166
{
5063
97b947e83640 Faker's code review response
Pavel Boyko <boyko@iitp.ru>
parents: 5057
diff changeset
   167
  if (header.IsData ())
5125
b90c6c0af6a3 Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents: 5113
diff changeset
   168
    {
b90c6c0af6a3 Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents: 5113
diff changeset
   169
      return ReceiveData (packet, header);
b90c6c0af6a3 Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents: 5113
diff changeset
   170
    }
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   171
  else
5125
b90c6c0af6a3 Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents: 5113
diff changeset
   172
    {
b90c6c0af6a3 Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents: 5113
diff changeset
   173
      if (header.IsAction ())
b90c6c0af6a3 Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents: 5113
diff changeset
   174
        {
b90c6c0af6a3 Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents: 5113
diff changeset
   175
          return ReceiveAction (packet, header);
b90c6c0af6a3 Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents: 5113
diff changeset
   176
        }
b90c6c0af6a3 Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents: 5113
diff changeset
   177
      else
b90c6c0af6a3 Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents: 5113
diff changeset
   178
        {
b90c6c0af6a3 Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents: 5113
diff changeset
   179
          return true; // don't care
b90c6c0af6a3 Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents: 5113
diff changeset
   180
        }
b90c6c0af6a3 Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents: 5113
diff changeset
   181
    }
4887
cbf02c77d5c1 HWMP is attached to mesh point device and MAC layer with zero functionality
Kirill Andreev <andreev@iitp.ru>
parents: 4886
diff changeset
   182
}
cbf02c77d5c1 HWMP is attached to mesh point device and MAC layer with zero functionality
Kirill Andreev <andreev@iitp.ru>
parents: 4886
diff changeset
   183
bool
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   184
HwmpProtocolMac::UpdateOutcomingFrame (Ptr<Packet> packet, WifiMacHeader & header, Mac48Address from,
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   185
    Mac48Address to)
4887
cbf02c77d5c1 HWMP is attached to mesh point device and MAC layer with zero functionality
Kirill Andreev <andreev@iitp.ru>
parents: 4886
diff changeset
   186
{
5125
b90c6c0af6a3 Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents: 5113
diff changeset
   187
  if (!header.IsData ())
b90c6c0af6a3 Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents: 5113
diff changeset
   188
    {
b90c6c0af6a3 Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents: 5113
diff changeset
   189
      return true;
b90c6c0af6a3 Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents: 5113
diff changeset
   190
    }
4889
279b07de3327 Fixrd bugs with address extensions, broadcast frames can go through L2Routing
Kirill Andreev <andreev@iitp.ru>
parents: 4887
diff changeset
   191
  HwmpTag tag;
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   192
  bool tagExists = packet->RemovePacketTag (tag);
5008
9650fb0087d2 Revert commit [c259eaefdd7f]. Make compiler happy.
Andrey Mazo <mazo@iitp.ru>
parents: 5002
diff changeset
   193
  if (!tagExists)
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   194
    {
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   195
      NS_FATAL_ERROR ("HWMP tag must exist at this point");
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   196
    }
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   197
  m_stats.txData++;
5038
0b8f9da17a56 Statistics fixed
Kirill Andreev <andreev@iitp.ru>
parents: 5037
diff changeset
   198
  m_stats.txDataBytes += packet->GetSize ();
4994
2c25f9c66604 Dot11sMacHeader renamed to MeshHeader to correspond standard
Pavel Boyko <boyko@iitp.ru>
parents: 4991
diff changeset
   199
  MeshHeader meshHdr;
5125
b90c6c0af6a3 Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents: 5113
diff changeset
   200
  meshHdr.SetMeshSeqno (tag.GetSeqno ());
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   201
  meshHdr.SetMeshTtl (tag.GetTtl ());
5113
a912d4372406 PREQ, PREP overflow is handled correctly
Kirill Andreev <andreev@iitp.ru>
parents: 5112
diff changeset
   202
  packet->AddHeader (meshHdr);
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   203
  header.SetAddr1 (tag.GetAddress ());
4887
cbf02c77d5c1 HWMP is attached to mesh point device and MAC layer with zero functionality
Kirill Andreev <andreev@iitp.ru>
parents: 4886
diff changeset
   204
  return true;
cbf02c77d5c1 HWMP is attached to mesh point device and MAC layer with zero functionality
Kirill Andreev <andreev@iitp.ru>
parents: 4886
diff changeset
   205
}
5112
762835be2902 Action values are made in accordance with Draft3.0
Kirill Andreev <andreev@iitp.ru>
parents: 5111
diff changeset
   206
WifiMeshActionHeader
762835be2902 Action values are made in accordance with Draft3.0
Kirill Andreev <andreev@iitp.ru>
parents: 5111
diff changeset
   207
HwmpProtocolMac::GetWifiMeshActionHeader ()
762835be2902 Action values are made in accordance with Draft3.0
Kirill Andreev <andreev@iitp.ru>
parents: 5111
diff changeset
   208
{
762835be2902 Action values are made in accordance with Draft3.0
Kirill Andreev <andreev@iitp.ru>
parents: 5111
diff changeset
   209
  WifiMeshActionHeader actionHdr;
762835be2902 Action values are made in accordance with Draft3.0
Kirill Andreev <andreev@iitp.ru>
parents: 5111
diff changeset
   210
  WifiMeshActionHeader::ActionValue action;
762835be2902 Action values are made in accordance with Draft3.0
Kirill Andreev <andreev@iitp.ru>
parents: 5111
diff changeset
   211
  action.pathSelection = WifiMeshActionHeader::PATH_SELECTION;
762835be2902 Action values are made in accordance with Draft3.0
Kirill Andreev <andreev@iitp.ru>
parents: 5111
diff changeset
   212
  actionHdr.SetAction (WifiMeshActionHeader::MESH_PATH_SELECTION, action);
762835be2902 Action values are made in accordance with Draft3.0
Kirill Andreev <andreev@iitp.ru>
parents: 5111
diff changeset
   213
  return actionHdr;
762835be2902 Action values are made in accordance with Draft3.0
Kirill Andreev <andreev@iitp.ru>
parents: 5111
diff changeset
   214
}
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
   215
void
5125
b90c6c0af6a3 Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents: 5113
diff changeset
   216
HwmpProtocolMac::SendPreq (IePreq preq)
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
   217
{
5107
ec4196c70800 Fixed PREQ propagation, added comments to PREQ information element
Kirill Andreev <andreev@iitp.ru>
parents: 5098
diff changeset
   218
  NS_LOG_FUNCTION_NOARGS ();
5113
a912d4372406 PREQ, PREP overflow is handled correctly
Kirill Andreev <andreev@iitp.ru>
parents: 5112
diff changeset
   219
  std::vector<IePreq> preq_vector;
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   220
  preq_vector.push_back (preq);
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   221
  SendPreq (preq_vector);
5113
a912d4372406 PREQ, PREP overflow is handled correctly
Kirill Andreev <andreev@iitp.ru>
parents: 5112
diff changeset
   222
}
a912d4372406 PREQ, PREP overflow is handled correctly
Kirill Andreev <andreev@iitp.ru>
parents: 5112
diff changeset
   223
void
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   224
HwmpProtocolMac::SendPreq (std::vector<IePreq> preq)
5113
a912d4372406 PREQ, PREP overflow is handled correctly
Kirill Andreev <andreev@iitp.ru>
parents: 5112
diff changeset
   225
{
5107
ec4196c70800 Fixed PREQ propagation, added comments to PREQ information element
Kirill Andreev <andreev@iitp.ru>
parents: 5098
diff changeset
   226
  Ptr<Packet> packet = Create<Packet> ();
5158
0baed7827260 Start to remove inheritance from header in WifiInformationElement
Kirill Andreev <andreev@iitp.ru>
parents: 5157
diff changeset
   227
  WifiInformationElementVector elements;
0baed7827260 Start to remove inheritance from header in WifiInformationElement
Kirill Andreev <andreev@iitp.ru>
parents: 5157
diff changeset
   228
  for (std::vector<IePreq>::iterator i = preq.begin (); i != preq.end (); i++)
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   229
    {
5158
0baed7827260 Start to remove inheritance from header in WifiInformationElement
Kirill Andreev <andreev@iitp.ru>
parents: 5157
diff changeset
   230
      elements.AddInformationElement(Ptr<IePreq> (&(*i)));
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   231
    }
5158
0baed7827260 Start to remove inheritance from header in WifiInformationElement
Kirill Andreev <andreev@iitp.ru>
parents: 5157
diff changeset
   232
  packet->AddHeader(elements);
5112
762835be2902 Action values are made in accordance with Draft3.0
Kirill Andreev <andreev@iitp.ru>
parents: 5111
diff changeset
   233
  packet->AddHeader (GetWifiMeshActionHeader ());
4926
a9382a693fa1 PREQ queue bugfix, tested proactive mode, removed unnseded debug messages
Kirill Andreev <andreev@iitp.ru>
parents: 4925
diff changeset
   234
  //create 802.11 header:
a9382a693fa1 PREQ queue bugfix, tested proactive mode, removed unnseded debug messages
Kirill Andreev <andreev@iitp.ru>
parents: 4925
diff changeset
   235
  WifiMacHeader hdr;
4968
ff5a2162d492 MulthopAction -> Action management frames in 802.11s according to std
Pavel Boyko <boyko@iitp.ru>
parents: 4965
diff changeset
   236
  hdr.SetAction ();
4926
a9382a693fa1 PREQ queue bugfix, tested proactive mode, removed unnseded debug messages
Kirill Andreev <andreev@iitp.ru>
parents: 4925
diff changeset
   237
  hdr.SetDsNotFrom ();
a9382a693fa1 PREQ queue bugfix, tested proactive mode, removed unnseded debug messages
Kirill Andreev <andreev@iitp.ru>
parents: 4925
diff changeset
   238
  hdr.SetDsNotTo ();
a9382a693fa1 PREQ queue bugfix, tested proactive mode, removed unnseded debug messages
Kirill Andreev <andreev@iitp.ru>
parents: 4925
diff changeset
   239
  hdr.SetAddr2 (m_parent->GetAddress ());
4996
33f418524356 Fixed routing information with neighbours, fixed address3 in management
Kirill Andreev <andreev@iitp.ru>
parents: 4984
diff changeset
   240
  hdr.SetAddr3 (m_protocol->GetAddress ());
4926
a9382a693fa1 PREQ queue bugfix, tested proactive mode, removed unnseded debug messages
Kirill Andreev <andreev@iitp.ru>
parents: 4925
diff changeset
   241
  //Send Management frame
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   242
  std::vector<Mac48Address> receivers = m_protocol->GetPreqReceivers (m_ifIndex);
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   243
  for (std::vector<Mac48Address>::const_iterator i = receivers.begin (); i != receivers.end (); i++)
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   244
    {
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   245
      hdr.SetAddr1 (*i);
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   246
      m_stats.txPreq++;
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   247
      m_stats.txMgt++;
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   248
      m_stats.txMgtBytes += packet->GetSize ();
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   249
      m_parent->SendManagementFrame (packet, hdr);
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   250
    }
5107
ec4196c70800 Fixed PREQ propagation, added comments to PREQ information element
Kirill Andreev <andreev@iitp.ru>
parents: 5098
diff changeset
   251
}
ec4196c70800 Fixed PREQ propagation, added comments to PREQ information element
Kirill Andreev <andreev@iitp.ru>
parents: 5098
diff changeset
   252
void
ec4196c70800 Fixed PREQ propagation, added comments to PREQ information element
Kirill Andreev <andreev@iitp.ru>
parents: 5098
diff changeset
   253
HwmpProtocolMac::RequestDestination (Mac48Address dst, uint32_t originator_seqno, uint32_t dst_seqno)
ec4196c70800 Fixed PREQ propagation, added comments to PREQ information element
Kirill Andreev <andreev@iitp.ru>
parents: 5098
diff changeset
   254
{
ec4196c70800 Fixed PREQ propagation, added comments to PREQ information element
Kirill Andreev <andreev@iitp.ru>
parents: 5098
diff changeset
   255
  NS_LOG_FUNCTION_NOARGS ();
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   256
  for (std::vector<IePreq>::iterator i = m_myPreq.begin (); i != m_myPreq.end (); i++)
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   257
    {
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   258
      if (i->IsFull ())
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   259
        {
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   260
          continue;
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   261
        }
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   262
      NS_ASSERT (i->GetDestCount () > 0);
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   263
      i->AddDestinationAddressElement (m_protocol->GetDoFlag (), m_protocol->GetRfFlag (), dst, dst_seqno);
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   264
    }
5113
a912d4372406 PREQ, PREP overflow is handled correctly
Kirill Andreev <andreev@iitp.ru>
parents: 5112
diff changeset
   265
  IePreq preq;
a912d4372406 PREQ, PREP overflow is handled correctly
Kirill Andreev <andreev@iitp.ru>
parents: 5112
diff changeset
   266
  preq.SetHopcount (0);
a912d4372406 PREQ, PREP overflow is handled correctly
Kirill Andreev <andreev@iitp.ru>
parents: 5112
diff changeset
   267
  preq.SetTTL (m_protocol->GetMaxTtl ());
a912d4372406 PREQ, PREP overflow is handled correctly
Kirill Andreev <andreev@iitp.ru>
parents: 5112
diff changeset
   268
  preq.SetPreqID (m_protocol->GetNextPreqId ());
a912d4372406 PREQ, PREP overflow is handled correctly
Kirill Andreev <andreev@iitp.ru>
parents: 5112
diff changeset
   269
  preq.SetOriginatorAddress (m_protocol->GetAddress ());
a912d4372406 PREQ, PREP overflow is handled correctly
Kirill Andreev <andreev@iitp.ru>
parents: 5112
diff changeset
   270
  preq.SetOriginatorSeqNumber (originator_seqno);
a912d4372406 PREQ, PREP overflow is handled correctly
Kirill Andreev <andreev@iitp.ru>
parents: 5112
diff changeset
   271
  preq.SetLifetime (m_protocol->GetActivePathLifetime ());
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   272
  preq.AddDestinationAddressElement (m_protocol->GetDoFlag (), m_protocol->GetRfFlag (), dst, dst_seqno);
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   273
  m_myPreq.push_back (preq);
5107
ec4196c70800 Fixed PREQ propagation, added comments to PREQ information element
Kirill Andreev <andreev@iitp.ru>
parents: 5098
diff changeset
   274
  SendMyPreq ();
ec4196c70800 Fixed PREQ propagation, added comments to PREQ information element
Kirill Andreev <andreev@iitp.ru>
parents: 5098
diff changeset
   275
}
ec4196c70800 Fixed PREQ propagation, added comments to PREQ information element
Kirill Andreev <andreev@iitp.ru>
parents: 5098
diff changeset
   276
void
ec4196c70800 Fixed PREQ propagation, added comments to PREQ information element
Kirill Andreev <andreev@iitp.ru>
parents: 5098
diff changeset
   277
HwmpProtocolMac::SendMyPreq ()
ec4196c70800 Fixed PREQ propagation, added comments to PREQ information element
Kirill Andreev <andreev@iitp.ru>
parents: 5098
diff changeset
   278
{
ec4196c70800 Fixed PREQ propagation, added comments to PREQ information element
Kirill Andreev <andreev@iitp.ru>
parents: 5098
diff changeset
   279
  NS_LOG_FUNCTION_NOARGS ();
5125
b90c6c0af6a3 Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents: 5113
diff changeset
   280
  if (m_preqTimer.IsRunning ())
b90c6c0af6a3 Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents: 5113
diff changeset
   281
    {
b90c6c0af6a3 Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents: 5113
diff changeset
   282
      return;
b90c6c0af6a3 Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents: 5113
diff changeset
   283
    }
b90c6c0af6a3 Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents: 5113
diff changeset
   284
  if (m_myPreq.size () == 0)
b90c6c0af6a3 Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents: 5113
diff changeset
   285
    {
b90c6c0af6a3 Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents: 5113
diff changeset
   286
      return;
b90c6c0af6a3 Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents: 5113
diff changeset
   287
    }
5107
ec4196c70800 Fixed PREQ propagation, added comments to PREQ information element
Kirill Andreev <andreev@iitp.ru>
parents: 5098
diff changeset
   288
  //reschedule sending PREQ
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   289
  NS_ASSERT (!m_preqTimer.IsRunning ());
5107
ec4196c70800 Fixed PREQ propagation, added comments to PREQ information element
Kirill Andreev <andreev@iitp.ru>
parents: 5098
diff changeset
   290
  m_preqTimer = Simulator::Schedule (m_protocol->GetPreqMinInterval (), &HwmpProtocolMac::SendMyPreq, this);
ec4196c70800 Fixed PREQ propagation, added comments to PREQ information element
Kirill Andreev <andreev@iitp.ru>
parents: 5098
diff changeset
   291
  SendPreq (m_myPreq);
5113
a912d4372406 PREQ, PREP overflow is handled correctly
Kirill Andreev <andreev@iitp.ru>
parents: 5112
diff changeset
   292
  m_myPreq.clear ();
4900
0c34a34208f2 restructured precursors in rtable
Kirill Andreev <andreev@iitp.ru>
parents: 4896
diff changeset
   293
}
0c34a34208f2 restructured precursors in rtable
Kirill Andreev <andreev@iitp.ru>
parents: 4896
diff changeset
   294
void
5086
fccfd0073ea3 Fixed names: now protocols are called *-protocol.[h,cc], plugin is called
Kirill Andreev <andreev@iitp.ru>
parents: 5083
diff changeset
   295
HwmpProtocolMac::SendPrep (IePrep prep, Mac48Address receiver)
4900
0c34a34208f2 restructured precursors in rtable
Kirill Andreev <andreev@iitp.ru>
parents: 4896
diff changeset
   296
{
5107
ec4196c70800 Fixed PREQ propagation, added comments to PREQ information element
Kirill Andreev <andreev@iitp.ru>
parents: 5098
diff changeset
   297
  NS_LOG_FUNCTION_NOARGS ();
4895
b68a1309a89e First PREQ delivered
Kirill Andreev <andreev@iitp.ru>
parents: 4894
diff changeset
   298
  //Create packet
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   299
  Ptr<Packet> packet = Create<Packet> ();
5158
0baed7827260 Start to remove inheritance from header in WifiInformationElement
Kirill Andreev <andreev@iitp.ru>
parents: 5157
diff changeset
   300
  WifiInformationElementVector elements;
0baed7827260 Start to remove inheritance from header in WifiInformationElement
Kirill Andreev <andreev@iitp.ru>
parents: 5157
diff changeset
   301
  elements.AddInformationElement(Ptr<IePrep> (&prep));
0baed7827260 Start to remove inheritance from header in WifiInformationElement
Kirill Andreev <andreev@iitp.ru>
parents: 5157
diff changeset
   302
  packet->AddHeader (elements);
5112
762835be2902 Action values are made in accordance with Draft3.0
Kirill Andreev <andreev@iitp.ru>
parents: 5111
diff changeset
   303
  packet->AddHeader (GetWifiMeshActionHeader ());
4895
b68a1309a89e First PREQ delivered
Kirill Andreev <andreev@iitp.ru>
parents: 4894
diff changeset
   304
  //create 802.11 header:
b68a1309a89e First PREQ delivered
Kirill Andreev <andreev@iitp.ru>
parents: 4894
diff changeset
   305
  WifiMacHeader hdr;
4968
ff5a2162d492 MulthopAction -> Action management frames in 802.11s according to std
Pavel Boyko <boyko@iitp.ru>
parents: 4965
diff changeset
   306
  hdr.SetAction ();
4895
b68a1309a89e First PREQ delivered
Kirill Andreev <andreev@iitp.ru>
parents: 4894
diff changeset
   307
  hdr.SetDsNotFrom ();
b68a1309a89e First PREQ delivered
Kirill Andreev <andreev@iitp.ru>
parents: 4894
diff changeset
   308
  hdr.SetDsNotTo ();
4900
0c34a34208f2 restructured precursors in rtable
Kirill Andreev <andreev@iitp.ru>
parents: 4896
diff changeset
   309
  hdr.SetAddr1 (receiver);
4895
b68a1309a89e First PREQ delivered
Kirill Andreev <andreev@iitp.ru>
parents: 4894
diff changeset
   310
  hdr.SetAddr2 (m_parent->GetAddress ());
4996
33f418524356 Fixed routing information with neighbours, fixed address3 in management
Kirill Andreev <andreev@iitp.ru>
parents: 4984
diff changeset
   311
  hdr.SetAddr3 (m_protocol->GetAddress ());
4895
b68a1309a89e First PREQ delivered
Kirill Andreev <andreev@iitp.ru>
parents: 4894
diff changeset
   312
  //Send Management frame
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   313
  m_stats.txPrep++;
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   314
  m_stats.txMgt++;
5038
0b8f9da17a56 Statistics fixed
Kirill Andreev <andreev@iitp.ru>
parents: 5037
diff changeset
   315
  m_stats.txMgtBytes += packet->GetSize ();
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   316
  m_parent->SendManagementFrame (packet, hdr);
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
   317
}
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
   318
void
5168
72bf9328f412 Failed destination is structure of HWMP
Kirill Andreev <andreev@iitp.ru>
parents: 5162
diff changeset
   319
HwmpProtocolMac::ForwardPerr (std::vector<HwmpProtocol::FailedDestination> failedDestinations, std::vector<
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   320
    Mac48Address> receivers)
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
   321
{
5107
ec4196c70800 Fixed PREQ propagation, added comments to PREQ information element
Kirill Andreev <andreev@iitp.ru>
parents: 5098
diff changeset
   322
  NS_LOG_FUNCTION_NOARGS ();
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   323
  Ptr<Packet> packet = Create<Packet> ();
5158
0baed7827260 Start to remove inheritance from header in WifiInformationElement
Kirill Andreev <andreev@iitp.ru>
parents: 5157
diff changeset
   324
  Ptr<IePerr> perr = Create <IePerr> ();
0baed7827260 Start to remove inheritance from header in WifiInformationElement
Kirill Andreev <andreev@iitp.ru>
parents: 5157
diff changeset
   325
  WifiInformationElementVector elements;
5168
72bf9328f412 Failed destination is structure of HWMP
Kirill Andreev <andreev@iitp.ru>
parents: 5162
diff changeset
   326
  for (std::vector<HwmpProtocol::FailedDestination>::const_iterator i = failedDestinations.begin (); i
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   327
      != failedDestinations.end (); i++)
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   328
    {
5158
0baed7827260 Start to remove inheritance from header in WifiInformationElement
Kirill Andreev <andreev@iitp.ru>
parents: 5157
diff changeset
   329
      if (!perr->IsFull ())
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   330
        {
5158
0baed7827260 Start to remove inheritance from header in WifiInformationElement
Kirill Andreev <andreev@iitp.ru>
parents: 5157
diff changeset
   331
          perr->AddAddressUnit (*i);
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   332
        }
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   333
      else
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   334
        {
5158
0baed7827260 Start to remove inheritance from header in WifiInformationElement
Kirill Andreev <andreev@iitp.ru>
parents: 5157
diff changeset
   335
          elements.AddInformationElement(perr);
0baed7827260 Start to remove inheritance from header in WifiInformationElement
Kirill Andreev <andreev@iitp.ru>
parents: 5157
diff changeset
   336
          perr->ResetPerr ();
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   337
        }
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   338
    }
5158
0baed7827260 Start to remove inheritance from header in WifiInformationElement
Kirill Andreev <andreev@iitp.ru>
parents: 5157
diff changeset
   339
  if (perr->GetNumOfDest () > 0)
5113
a912d4372406 PREQ, PREP overflow is handled correctly
Kirill Andreev <andreev@iitp.ru>
parents: 5112
diff changeset
   340
    {
5158
0baed7827260 Start to remove inheritance from header in WifiInformationElement
Kirill Andreev <andreev@iitp.ru>
parents: 5157
diff changeset
   341
      elements.AddInformationElement(perr);
5113
a912d4372406 PREQ, PREP overflow is handled correctly
Kirill Andreev <andreev@iitp.ru>
parents: 5112
diff changeset
   342
    }
5158
0baed7827260 Start to remove inheritance from header in WifiInformationElement
Kirill Andreev <andreev@iitp.ru>
parents: 5157
diff changeset
   343
  packet->AddHeader (elements);
5112
762835be2902 Action values are made in accordance with Draft3.0
Kirill Andreev <andreev@iitp.ru>
parents: 5111
diff changeset
   344
  packet->AddHeader (GetWifiMeshActionHeader ());
5111
018748653ea8 Fixed PERR propagation
Kirill Andreev <andreev@iitp.ru>
parents: 5109
diff changeset
   345
  //create 802.11 header:
018748653ea8 Fixed PERR propagation
Kirill Andreev <andreev@iitp.ru>
parents: 5109
diff changeset
   346
  WifiMacHeader hdr;
018748653ea8 Fixed PERR propagation
Kirill Andreev <andreev@iitp.ru>
parents: 5109
diff changeset
   347
  hdr.SetAction ();
018748653ea8 Fixed PERR propagation
Kirill Andreev <andreev@iitp.ru>
parents: 5109
diff changeset
   348
  hdr.SetDsNotFrom ();
018748653ea8 Fixed PERR propagation
Kirill Andreev <andreev@iitp.ru>
parents: 5109
diff changeset
   349
  hdr.SetDsNotTo ();
018748653ea8 Fixed PERR propagation
Kirill Andreev <andreev@iitp.ru>
parents: 5109
diff changeset
   350
  hdr.SetAddr2 (m_parent->GetAddress ());
018748653ea8 Fixed PERR propagation
Kirill Andreev <andreev@iitp.ru>
parents: 5109
diff changeset
   351
  hdr.SetAddr3 (m_protocol->GetAddress ());
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   352
  if (receivers.size () >= m_protocol->GetUnicastPerrThreshold ())
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   353
    {
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   354
      receivers.clear ();
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   355
      receivers.push_back (Mac48Address::GetBroadcast ());
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   356
    }
5111
018748653ea8 Fixed PERR propagation
Kirill Andreev <andreev@iitp.ru>
parents: 5109
diff changeset
   357
  //Send Management frame
5174
Kirill Andreev <andreev@iitp.ru>
parents: 5168
diff changeset
   358
  for (std::vector<Mac48Address>::const_iterator i = receivers.begin (); i != receivers.end (); i++)
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   359
    {
5413
64931d320790 fix valgrind complaints (bug 711)
Craig Dowell <craigdo@ee.washington.edu>
parents: 5174
diff changeset
   360
      //
64931d320790 fix valgrind complaints (bug 711)
Craig Dowell <craigdo@ee.washington.edu>
parents: 5174
diff changeset
   361
      // 64-bit Intel valgrind complains about hdr.SetAddr1 (*i).  It likes this
64931d320790 fix valgrind complaints (bug 711)
Craig Dowell <craigdo@ee.washington.edu>
parents: 5174
diff changeset
   362
      // just fine.
64931d320790 fix valgrind complaints (bug 711)
Craig Dowell <craigdo@ee.washington.edu>
parents: 5174
diff changeset
   363
      //
64931d320790 fix valgrind complaints (bug 711)
Craig Dowell <craigdo@ee.washington.edu>
parents: 5174
diff changeset
   364
      Mac48Address address = *i;
64931d320790 fix valgrind complaints (bug 711)
Craig Dowell <craigdo@ee.washington.edu>
parents: 5174
diff changeset
   365
      hdr.SetAddr1 (address);
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   366
      m_stats.txPerr++;
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   367
      m_stats.txMgt++;
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   368
      m_stats.txMgtBytes += packet->GetSize ();
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   369
      m_parent->SendManagementFrame (packet, hdr);
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   370
    }
5111
018748653ea8 Fixed PERR propagation
Kirill Andreev <andreev@iitp.ru>
parents: 5109
diff changeset
   371
}
018748653ea8 Fixed PERR propagation
Kirill Andreev <andreev@iitp.ru>
parents: 5109
diff changeset
   372
void
5168
72bf9328f412 Failed destination is structure of HWMP
Kirill Andreev <andreev@iitp.ru>
parents: 5162
diff changeset
   373
HwmpProtocolMac::InitiatePerr (std::vector<HwmpProtocol::FailedDestination> failedDestinations, std::vector<
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   374
    Mac48Address> receivers)
5111
018748653ea8 Fixed PERR propagation
Kirill Andreev <andreev@iitp.ru>
parents: 5109
diff changeset
   375
{
5113
a912d4372406 PREQ, PREP overflow is handled correctly
Kirill Andreev <andreev@iitp.ru>
parents: 5112
diff changeset
   376
  //All duplicates in PERR are checked here, and there is no reason to
a912d4372406 PREQ, PREP overflow is handled correctly
Kirill Andreev <andreev@iitp.ru>
parents: 5112
diff changeset
   377
  //check it at any athoer place
a912d4372406 PREQ, PREP overflow is handled correctly
Kirill Andreev <andreev@iitp.ru>
parents: 5112
diff changeset
   378
    {
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   379
      std::vector<Mac48Address>::const_iterator end = receivers.end ();
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   380
      for (std::vector<Mac48Address>::const_iterator i = receivers.begin (); i != end; i++)
5125
b90c6c0af6a3 Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents: 5113
diff changeset
   381
        {
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   382
          bool should_add = true;
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   383
          for (std::vector<Mac48Address>::const_iterator j = m_myPerr.receivers.begin (); j
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   384
              != m_myPerr.receivers.end (); j++)
5125
b90c6c0af6a3 Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents: 5113
diff changeset
   385
            {
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   386
              if ((*i) == (*j))
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   387
                {
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   388
                  should_add = false;
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   389
                }
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   390
            }
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   391
          if (should_add)
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   392
            {
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   393
              m_myPerr.receivers.push_back (*i);
5125
b90c6c0af6a3 Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents: 5113
diff changeset
   394
            }
b90c6c0af6a3 Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents: 5113
diff changeset
   395
        }
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   396
    }
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   397
    {
5168
72bf9328f412 Failed destination is structure of HWMP
Kirill Andreev <andreev@iitp.ru>
parents: 5162
diff changeset
   398
      std::vector<HwmpProtocol::FailedDestination>::const_iterator end = failedDestinations.end ();
72bf9328f412 Failed destination is structure of HWMP
Kirill Andreev <andreev@iitp.ru>
parents: 5162
diff changeset
   399
      for (std::vector<HwmpProtocol::FailedDestination>::const_iterator i = failedDestinations.begin (); i != end; i++)
5125
b90c6c0af6a3 Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents: 5113
diff changeset
   400
        {
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   401
          bool should_add = true;
5168
72bf9328f412 Failed destination is structure of HWMP
Kirill Andreev <andreev@iitp.ru>
parents: 5162
diff changeset
   402
          for (std::vector<HwmpProtocol::FailedDestination>::const_iterator j = m_myPerr.destinations.begin (); j
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   403
              != m_myPerr.destinations.end (); j++)
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   404
            {
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   405
              if (((*i).destination == (*j).destination) && ((*j).seqnum > (*i).seqnum))
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   406
                {
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   407
                  should_add = false;
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   408
                }
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   409
            }
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   410
          if (should_add)
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   411
            {
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   412
              m_myPerr.destinations.push_back (*i);
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   413
            }
5125
b90c6c0af6a3 Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents: 5113
diff changeset
   414
        }
5113
a912d4372406 PREQ, PREP overflow is handled correctly
Kirill Andreev <andreev@iitp.ru>
parents: 5112
diff changeset
   415
    }
5111
018748653ea8 Fixed PERR propagation
Kirill Andreev <andreev@iitp.ru>
parents: 5109
diff changeset
   416
  SendMyPerr ();
018748653ea8 Fixed PERR propagation
Kirill Andreev <andreev@iitp.ru>
parents: 5109
diff changeset
   417
}
018748653ea8 Fixed PERR propagation
Kirill Andreev <andreev@iitp.ru>
parents: 5109
diff changeset
   418
void
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   419
HwmpProtocolMac::SendMyPerr ()
5111
018748653ea8 Fixed PERR propagation
Kirill Andreev <andreev@iitp.ru>
parents: 5109
diff changeset
   420
{
018748653ea8 Fixed PERR propagation
Kirill Andreev <andreev@iitp.ru>
parents: 5109
diff changeset
   421
  NS_LOG_FUNCTION_NOARGS ();
5125
b90c6c0af6a3 Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents: 5113
diff changeset
   422
  if (m_perrTimer.IsRunning ())
b90c6c0af6a3 Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents: 5113
diff changeset
   423
    {
b90c6c0af6a3 Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents: 5113
diff changeset
   424
      return;
b90c6c0af6a3 Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents: 5113
diff changeset
   425
    }
5111
018748653ea8 Fixed PERR propagation
Kirill Andreev <andreev@iitp.ru>
parents: 5109
diff changeset
   426
  m_perrTimer = Simulator::Schedule (m_protocol->GetPerrMinInterval (), &HwmpProtocolMac::SendMyPerr, this);
5113
a912d4372406 PREQ, PREP overflow is handled correctly
Kirill Andreev <andreev@iitp.ru>
parents: 5112
diff changeset
   427
  ForwardPerr (m_myPerr.destinations, m_myPerr.receivers);
a912d4372406 PREQ, PREP overflow is handled correctly
Kirill Andreev <andreev@iitp.ru>
parents: 5112
diff changeset
   428
  m_myPerr.destinations.clear ();
5111
018748653ea8 Fixed PERR propagation
Kirill Andreev <andreev@iitp.ru>
parents: 5109
diff changeset
   429
  m_myPerr.receivers.clear ();
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
   430
}
4944
779b641cff5a Unicast chain instead of broadcast data frame added. Metric
Kirill Andreev <andreev@iitp.ru>
parents: 4943
diff changeset
   431
uint32_t
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   432
HwmpProtocolMac::GetLinkMetric (Mac48Address peerAddress) const
4944
779b641cff5a Unicast chain instead of broadcast data frame added. Metric
Kirill Andreev <andreev@iitp.ru>
parents: 4943
diff changeset
   433
{
5125
b90c6c0af6a3 Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents: 5113
diff changeset
   434
  return m_parent->GetLinkMetric (peerAddress);
4944
779b641cff5a Unicast chain instead of broadcast data frame added. Metric
Kirill Andreev <andreev@iitp.ru>
parents: 4943
diff changeset
   435
}
4950
1163cfb03b9b Broadcast is not forwarded twice into the same channel
Kirill Andreev <andreev@iitp.ru>
parents: 4949
diff changeset
   436
uint16_t
5086
fccfd0073ea3 Fixed names: now protocols are called *-protocol.[h,cc], plugin is called
Kirill Andreev <andreev@iitp.ru>
parents: 5083
diff changeset
   437
HwmpProtocolMac::GetChannelId () const
4950
1163cfb03b9b Broadcast is not forwarded twice into the same channel
Kirill Andreev <andreev@iitp.ru>
parents: 4949
diff changeset
   438
{
1163cfb03b9b Broadcast is not forwarded twice into the same channel
Kirill Andreev <andreev@iitp.ru>
parents: 4949
diff changeset
   439
  return m_parent->GetFrequencyChannel ();
1163cfb03b9b Broadcast is not forwarded twice into the same channel
Kirill Andreev <andreev@iitp.ru>
parents: 4949
diff changeset
   440
}
5126
8e06088a785d Statistics removed from headers
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   441
HwmpProtocolMac::Statistics::Statistics () :
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   442
  txPreq (0), rxPreq (0), txPrep (0), rxPrep (0), txPerr (0), rxPerr (0), txMgt (0), txMgtBytes (0),
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   443
      rxMgt (0), rxMgtBytes (0), txData (0), txDataBytes (0), rxData (0), rxDataBytes (0)
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   444
{
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   445
}
5012
c81291702113 Statistics - almost done
Kirill Andreev <andreev@iitp.ru>
parents: 5008
diff changeset
   446
void
5086
fccfd0073ea3 Fixed names: now protocols are called *-protocol.[h,cc], plugin is called
Kirill Andreev <andreev@iitp.ru>
parents: 5083
diff changeset
   447
HwmpProtocolMac::Statistics::Print (std::ostream & os) const
5012
c81291702113 Statistics - almost done
Kirill Andreev <andreev@iitp.ru>
parents: 5008
diff changeset
   448
{
5015
e460e29f9f78 Statistics fixed
Kirill Andreev <andreev@iitp.ru>
parents: 5013
diff changeset
   449
  os << "<Statistics "
5156
5b499f25655a Review fixes
Kirill Andreev <andreev@iitp.ru>
parents: 5132
diff changeset
   450
    "txPreq= \"" << txPreq << "\"" << std::endl <<
5b499f25655a Review fixes
Kirill Andreev <andreev@iitp.ru>
parents: 5132
diff changeset
   451
    "txPrep=\"" << txPrep << "\"" << std::endl <<
5b499f25655a Review fixes
Kirill Andreev <andreev@iitp.ru>
parents: 5132
diff changeset
   452
    "txPerr=\"" << txPerr << "\"" << std::endl <<
5b499f25655a Review fixes
Kirill Andreev <andreev@iitp.ru>
parents: 5132
diff changeset
   453
    "rxPreq=\"" << rxPreq << "\"" << std::endl <<
5b499f25655a Review fixes
Kirill Andreev <andreev@iitp.ru>
parents: 5132
diff changeset
   454
    "rxPrep=\"" << rxPrep << "\"" << std::endl <<
5b499f25655a Review fixes
Kirill Andreev <andreev@iitp.ru>
parents: 5132
diff changeset
   455
    "rxPerr=\"" << rxPerr << "\"" << std::endl <<
5b499f25655a Review fixes
Kirill Andreev <andreev@iitp.ru>
parents: 5132
diff changeset
   456
    "txMgt=\"" << txMgt << "\"" << std::endl <<
5b499f25655a Review fixes
Kirill Andreev <andreev@iitp.ru>
parents: 5132
diff changeset
   457
    "txMgtBytes=\"" << txMgtBytes << "\"" << std::endl <<
5b499f25655a Review fixes
Kirill Andreev <andreev@iitp.ru>
parents: 5132
diff changeset
   458
    "rxMgt=\"" << rxMgt << "\"" << std::endl <<
5b499f25655a Review fixes
Kirill Andreev <andreev@iitp.ru>
parents: 5132
diff changeset
   459
    "rxMgtBytes=\"" << rxMgtBytes << "\"" << std::endl <<
5b499f25655a Review fixes
Kirill Andreev <andreev@iitp.ru>
parents: 5132
diff changeset
   460
    "txData=\"" << txData << "\"" << std::endl <<
5b499f25655a Review fixes
Kirill Andreev <andreev@iitp.ru>
parents: 5132
diff changeset
   461
    "txDataBytes=\"" << txDataBytes << "\"" << std::endl <<
5b499f25655a Review fixes
Kirill Andreev <andreev@iitp.ru>
parents: 5132
diff changeset
   462
    "rxData=\"" << rxData << "\"" << std::endl <<
5b499f25655a Review fixes
Kirill Andreev <andreev@iitp.ru>
parents: 5132
diff changeset
   463
    "rxDataBytes=\"" << rxDataBytes << "\"/>" << std::endl;
5012
c81291702113 Statistics - almost done
Kirill Andreev <andreev@iitp.ru>
parents: 5008
diff changeset
   464
}
c81291702113 Statistics - almost done
Kirill Andreev <andreev@iitp.ru>
parents: 5008
diff changeset
   465
void
5086
fccfd0073ea3 Fixed names: now protocols are called *-protocol.[h,cc], plugin is called
Kirill Andreev <andreev@iitp.ru>
parents: 5083
diff changeset
   466
HwmpProtocolMac::Report (std::ostream & os) const
5012
c81291702113 Statistics - almost done
Kirill Andreev <andreev@iitp.ru>
parents: 5008
diff changeset
   467
{
5157
ace422ad12df Cosmetics: '\n' was replaced with std::endl, Camel case for attributes
Kirill Andreev <andreev@iitp.ru>
parents: 5156
diff changeset
   468
  os << "<HwmpProtocolMac" << std::endl <<
ace422ad12df Cosmetics: '\n' was replaced with std::endl, Camel case for attributes
Kirill Andreev <andreev@iitp.ru>
parents: 5156
diff changeset
   469
    "address =\"" << m_parent->GetAddress () << "\">" << std::endl;
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5126
diff changeset
   470
  m_stats.Print (os);
5157
ace422ad12df Cosmetics: '\n' was replaced with std::endl, Camel case for attributes
Kirill Andreev <andreev@iitp.ru>
parents: 5156
diff changeset
   471
  os << "</HwmpProtocolMac>" << std::endl;
5012
c81291702113 Statistics - almost done
Kirill Andreev <andreev@iitp.ru>
parents: 5008
diff changeset
   472
}
5013
290579bb1c1b ResetStats added
Kirill Andreev <andreev@iitp.ru>
parents: 5012
diff changeset
   473
void
5086
fccfd0073ea3 Fixed names: now protocols are called *-protocol.[h,cc], plugin is called
Kirill Andreev <andreev@iitp.ru>
parents: 5083
diff changeset
   474
HwmpProtocolMac::ResetStats ()
5013
290579bb1c1b ResetStats added
Kirill Andreev <andreev@iitp.ru>
parents: 5012
diff changeset
   475
{
290579bb1c1b ResetStats added
Kirill Andreev <andreev@iitp.ru>
parents: 5012
diff changeset
   476
  m_stats = Statistics::Statistics ();
290579bb1c1b ResetStats added
Kirill Andreev <andreev@iitp.ru>
parents: 5012
diff changeset
   477
}
290579bb1c1b ResetStats added
Kirill Andreev <andreev@iitp.ru>
parents: 5012
diff changeset
   478
4886
bdbf21835837 HWMP rolled to "initial position"
Kirill Andreev <andreev@iitp.ru>
parents: 4884
diff changeset
   479
} //namespace dot11s
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
   480
}//namespace ns3