src/devices/mesh/dot11s/peer-management-protocol-mac.cc
author Kirill Andreev <andreev@iitp.ru>
Thu, 20 Aug 2009 18:24:23 +0400
changeset 5154 bb06787ed7fe
parent 5140 64084ae6cff1
child 5157 ace422ad12df
permissions -rw-r--r--
Added closing link due to transmission failure.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4856
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
     2
/*
4856
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
     3
 * Copyright (c) 2009 IITP RAS
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
     4
 *
4856
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License version 2 as
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
     7
 * published by the Free Software Foundation;
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
     8
 *
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    12
 * GNU General Public License for more details.
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    13
 *
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
    17
 *
4856
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    18
 * Author: Kirill Andreev <andreev@iitp.ru>
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    19
 */
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    20
4860
bb5194d57734 New peer management protocol moved to 802.11s/
Pavel Boyko <boyko@iitp.ru>
parents: 4859
diff changeset
    21
#include "ie-dot11s-configuration.h"
bb5194d57734 New peer management protocol moved to 802.11s/
Pavel Boyko <boyko@iitp.ru>
parents: 4859
diff changeset
    22
#include "ie-dot11s-peer-management.h"
4956
aba7cae978ac MeshWifiMacHeader moved to Dot11sMacHeader. test to it is written
Kirill Andreev <andreev@iitp.ru>
parents: 4953
diff changeset
    23
#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: 5038
diff changeset
    24
#include "peer-management-protocol-mac.h"
4887
cbf02c77d5c1 HWMP is attached to mesh point device and MAC layer with zero functionality
Kirill Andreev <andreev@iitp.ru>
parents: 4882
diff changeset
    25
#include "peer-management-protocol.h"
4877
f08902c42733 Added a method to find peer link, code cleanup
Kirill Andreev <andreev@iitp.ru>
parents: 4876
diff changeset
    26
#include "peer-link-frame.h"
4887
cbf02c77d5c1 HWMP is attached to mesh point device and MAC layer with zero functionality
Kirill Andreev <andreev@iitp.ru>
parents: 4882
diff changeset
    27
#include "ns3/mesh-wifi-interface-mac.h"
4861
20d333d95df2 Neighbours are attached
Kirill Andreev <andreev@iitp.ru>
parents: 4860
diff changeset
    28
#include "ns3/simulator.h"
4866
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
    29
#include "ns3/wifi-mac-header.h"
5140
64084ae6cff1 Removed FindFirst from WifiInformationElement
Kirill Andreev <andreev@iitp.ru>
parents: 5139
diff changeset
    30
#include "ns3/wifi-information-element-vector.h"
5139
87eb2f77f661 Added wifi-information-element-vector
Kirill Andreev <andreev@iitp.ru>
parents: 5132
diff changeset
    31
#include "ns3/log.h"
5132
aee541a30256 Restored newline at namespace
Kirill Andreev <andreev@iitp.ru>
parents: 5129
diff changeset
    32
namespace ns3 {
aee541a30256 Restored newline at namespace
Kirill Andreev <andreev@iitp.ru>
parents: 5129
diff changeset
    33
namespace dot11s {
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
    34
PeerManagementProtocolMac::PeerManagementProtocolMac (uint32_t interface,
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
    35
    Ptr<PeerManagementProtocol> protocol)
4856
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    36
{
4861
20d333d95df2 Neighbours are attached
Kirill Andreev <andreev@iitp.ru>
parents: 4860
diff changeset
    37
  m_ifIndex = interface;
20d333d95df2 Neighbours are attached
Kirill Andreev <andreev@iitp.ru>
parents: 4860
diff changeset
    38
  m_protocol = protocol;
4856
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    39
}
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    40
5086
fccfd0073ea3 Fixed names: now protocols are called *-protocol.[h,cc], plugin is called
Kirill Andreev <andreev@iitp.ru>
parents: 5038
diff changeset
    41
PeerManagementProtocolMac::~PeerManagementProtocolMac ()
4856
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    42
{
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    43
}
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    44
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    45
void
5086
fccfd0073ea3 Fixed names: now protocols are called *-protocol.[h,cc], plugin is called
Kirill Andreev <andreev@iitp.ru>
parents: 5038
diff changeset
    46
PeerManagementProtocolMac::SetParent (Ptr<MeshWifiInterfaceMac> parent)
4856
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    47
{
4857
ddfb13420455 Added new peer manager class, an old one we keep without change
Kirill Andreev <andreev@iitp.ru>
parents: 4856
diff changeset
    48
  m_parent = parent;
5154
bb06787ed7fe Added closing link due to transmission failure.
Kirill Andreev <andreev@iitp.ru>
parents: 5140
diff changeset
    49
  m_parent->TraceConnectWithoutContext ("TxErrHeader", MakeCallback (&PeerManagementProtocolMac::TxError, this));
bb06787ed7fe Added closing link due to transmission failure.
Kirill Andreev <andreev@iitp.ru>
parents: 5140
diff changeset
    50
  m_parent->TraceConnectWithoutContext ("TxOkHeader",  MakeCallback (&PeerManagementProtocolMac::TxOk,    this));
4856
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    51
}
5154
bb06787ed7fe Added closing link due to transmission failure.
Kirill Andreev <andreev@iitp.ru>
parents: 5140
diff changeset
    52
void
bb06787ed7fe Added closing link due to transmission failure.
Kirill Andreev <andreev@iitp.ru>
parents: 5140
diff changeset
    53
PeerManagementProtocolMac::TxError (WifiMacHeader const &hdr)
bb06787ed7fe Added closing link due to transmission failure.
Kirill Andreev <andreev@iitp.ru>
parents: 5140
diff changeset
    54
{
bb06787ed7fe Added closing link due to transmission failure.
Kirill Andreev <andreev@iitp.ru>
parents: 5140
diff changeset
    55
  m_protocol->TransmissionFailure (m_ifIndex, hdr.GetAddr1 ());
bb06787ed7fe Added closing link due to transmission failure.
Kirill Andreev <andreev@iitp.ru>
parents: 5140
diff changeset
    56
}
bb06787ed7fe Added closing link due to transmission failure.
Kirill Andreev <andreev@iitp.ru>
parents: 5140
diff changeset
    57
void
bb06787ed7fe Added closing link due to transmission failure.
Kirill Andreev <andreev@iitp.ru>
parents: 5140
diff changeset
    58
PeerManagementProtocolMac::TxOk (WifiMacHeader const &hdr)
bb06787ed7fe Added closing link due to transmission failure.
Kirill Andreev <andreev@iitp.ru>
parents: 5140
diff changeset
    59
{
bb06787ed7fe Added closing link due to transmission failure.
Kirill Andreev <andreev@iitp.ru>
parents: 5140
diff changeset
    60
  m_protocol->TransmissionSuccess (m_ifIndex, hdr.GetAddr1 ());
bb06787ed7fe Added closing link due to transmission failure.
Kirill Andreev <andreev@iitp.ru>
parents: 5140
diff changeset
    61
}
4856
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    62
bool
5086
fccfd0073ea3 Fixed names: now protocols are called *-protocol.[h,cc], plugin is called
Kirill Andreev <andreev@iitp.ru>
parents: 5038
diff changeset
    63
PeerManagementProtocolMac::Receive (Ptr<Packet> const_packet, const WifiMacHeader & header)
4856
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    64
{
4881
cec7f8e2bbdf Minor cosmetics. Peer management protocol is assumed to be implemented now.
Pavel Boyko <boyko@iitp.ru>
parents: 4879
diff changeset
    65
  // First of all we copy a packet, because we need to remove some
4877
f08902c42733 Added a method to find peer link, code cleanup
Kirill Andreev <andreev@iitp.ru>
parents: 4876
diff changeset
    66
  //headers
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
    67
  Ptr<Packet> packet = const_packet->Copy ();
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
    68
  if (header.IsBeacon ())
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
    69
    {
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
    70
      MgtBeaconHeader beacon_hdr;
5139
87eb2f77f661 Added wifi-information-element-vector
Kirill Andreev <andreev@iitp.ru>
parents: 5132
diff changeset
    71
      packet->RemoveHeader (beacon_hdr);
87eb2f77f661 Added wifi-information-element-vector
Kirill Andreev <andreev@iitp.ru>
parents: 5132
diff changeset
    72
      //meshId.FindFirst (myBeacon);
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
    73
      bool meshBeacon = false;
5139
87eb2f77f661 Added wifi-information-element-vector
Kirill Andreev <andreev@iitp.ru>
parents: 5132
diff changeset
    74
      WifiInformationElementVector elements = WifiInformationElementVector::DeserializePacket (packet);
87eb2f77f661 Added wifi-information-element-vector
Kirill Andreev <andreev@iitp.ru>
parents: 5132
diff changeset
    75
      Ptr<IeBeaconTiming> beaconTiming = DynamicCast<IeBeaconTiming> (elements.FindFirst (IE11S_BEACON_TIMING));
87eb2f77f661 Added wifi-information-element-vector
Kirill Andreev <andreev@iitp.ru>
parents: 5132
diff changeset
    76
      Ptr<IeMeshId> meshId = DynamicCast<IeMeshId> (elements.FindFirst (IE11S_MESH_ID));
87eb2f77f661 Added wifi-information-element-vector
Kirill Andreev <andreev@iitp.ru>
parents: 5132
diff changeset
    77
87eb2f77f661 Added wifi-information-element-vector
Kirill Andreev <andreev@iitp.ru>
parents: 5132
diff changeset
    78
      if ((beaconTiming != 0) && (meshId != 0))
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
    79
        {
5139
87eb2f77f661 Added wifi-information-element-vector
Kirill Andreev <andreev@iitp.ru>
parents: 5132
diff changeset
    80
          if (m_protocol->GetMeshId ()->IsEqual (*meshId))
87eb2f77f661 Added wifi-information-element-vector
Kirill Andreev <andreev@iitp.ru>
parents: 5132
diff changeset
    81
            {
87eb2f77f661 Added wifi-information-element-vector
Kirill Andreev <andreev@iitp.ru>
parents: 5132
diff changeset
    82
              meshBeacon = true;
87eb2f77f661 Added wifi-information-element-vector
Kirill Andreev <andreev@iitp.ru>
parents: 5132
diff changeset
    83
            }
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
    84
        }
5139
87eb2f77f661 Added wifi-information-element-vector
Kirill Andreev <andreev@iitp.ru>
parents: 5132
diff changeset
    85
      m_protocol->UpdatePeerBeaconTiming (m_ifIndex, meshBeacon, *beaconTiming, header.GetAddr2 (),
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
    86
          Simulator::Now (), MicroSeconds (beacon_hdr.GetBeaconIntervalUs ()));
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
    87
      // Beacon shall not be dropeed. May be needed to another plugins
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
    88
      return true;
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
    89
    }
5125
b90c6c0af6a3 Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents: 5098
diff changeset
    90
  if (header.IsAction ())
4866
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
    91
    {
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
    92
      WifiMeshActionHeader actionHdr;
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
    93
      packet->RemoveHeader (actionHdr);
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
    94
      WifiMeshActionHeader::ActionValue actionValue = actionHdr.GetAction ();
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
    95
      // If can not handle - just return;
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
    96
      if (actionHdr.GetCategory () != WifiMeshActionHeader::MESH_PEERING_MGT)
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
    97
        {
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
    98
          return m_protocol->IsActiveLink (m_ifIndex, header.GetAddr2 ());
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
    99
        }
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   100
      m_stats.rxMgt++;
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   101
      m_stats.rxMgtBytes += packet->GetSize ();
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   102
      Mac48Address peerAddress = header.GetAddr2 ();
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   103
      Mac48Address peerMpAddress = header.GetAddr3 ();
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   104
      PeerLinkFrameStart::PlinkFrameStartFields fields;
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   105
        {
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   106
          PeerLinkFrameStart peerFrame;
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   107
          peerFrame.SetPlinkFrameSubtype ((uint8_t) actionValue.peerLink);
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   108
          packet->RemoveHeader (peerFrame);
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   109
          fields = peerFrame.GetFields ();
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   110
          NS_ASSERT (fields.subtype == actionValue.peerLink);
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   111
        }
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   112
      if ((actionValue.peerLink != WifiMeshActionHeader::PEER_LINK_CLOSE) && !(m_parent->CheckSupportedRates (
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   113
          fields.rates)))
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   114
        {
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   115
          m_protocol->ConfigurationMismatch (m_ifIndex, peerAddress);
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   116
          // Broken peer link frame - drop it
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   117
          m_stats.brokenMgt++;
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   118
          return false;
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   119
        }
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   120
      if ((actionValue.peerLink != WifiMeshActionHeader::PEER_LINK_CONFIRM) && !fields.meshId.IsEqual (
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   121
          *(m_protocol->GetMeshId ())))
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   122
        {
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   123
          m_protocol->ConfigurationMismatch (m_ifIndex, peerAddress);
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   124
          // Broken peer link frame - drop it
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   125
          m_stats.brokenMgt++;
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   126
          return false;
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   127
        }
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   128
      IePeerManagement peerElement;
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   129
      packet->RemoveHeader (peerElement);
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   130
      //Check taht frame subtype corresponds peer link subtype
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   131
      if (peerElement.SubtypeIsOpen ())
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   132
        {
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   133
          m_stats.rxOpen++;
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   134
          NS_ASSERT (actionValue.peerLink == WifiMeshActionHeader::PEER_LINK_OPEN);
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   135
        }
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   136
      if (peerElement.SubtypeIsConfirm ())
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   137
        {
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   138
          m_stats.rxConfirm++;
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   139
          NS_ASSERT (actionValue.peerLink == WifiMeshActionHeader::PEER_LINK_CONFIRM);
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   140
        }
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   141
      if (peerElement.SubtypeIsClose ())
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   142
        {
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   143
          m_stats.rxClose++;
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   144
          NS_ASSERT (actionValue.peerLink == WifiMeshActionHeader::PEER_LINK_CLOSE);
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   145
        }
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   146
      //Deliver Peer link management frame to protocol:
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   147
      m_protocol->ReceivePeerLinkFrame (m_ifIndex, peerAddress, peerMpAddress, fields.aid, peerElement,
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   148
          fields.config);
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   149
      // if we can handle a frame - drop it
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   150
      return false;
4866
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   151
    }
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   152
  return m_protocol->IsActiveLink (m_ifIndex, header.GetAddr2 ());
4856
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   153
}
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   154
bool
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   155
PeerManagementProtocolMac::UpdateOutcomingFrame (Ptr<Packet> packet, WifiMacHeader & header,
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   156
    Mac48Address from, Mac48Address to)
4856
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   157
{
5125
b90c6c0af6a3 Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents: 5098
diff changeset
   158
  if (header.IsAction ())
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   159
    {
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   160
      WifiMeshActionHeader actionHdr;
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   161
      packet->PeekHeader (actionHdr);
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   162
      WifiMeshActionHeader::ActionValue actionValue = actionHdr.GetAction ();
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   163
      if (actionHdr.GetCategory () == WifiMeshActionHeader::MESH_PEERING_MGT)
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   164
        {
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   165
          return true;
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   166
        }
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   167
    }
5125
b90c6c0af6a3 Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents: 5098
diff changeset
   168
  if (header.GetAddr1 ().IsGroup ())
b90c6c0af6a3 Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents: 5098
diff changeset
   169
    {
5012
c81291702113 Statistics - almost done
Kirill Andreev <andreev@iitp.ru>
parents: 5009
diff changeset
   170
      return true;
5125
b90c6c0af6a3 Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents: 5098
diff changeset
   171
    }
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   172
  else
5012
c81291702113 Statistics - almost done
Kirill Andreev <andreev@iitp.ru>
parents: 5009
diff changeset
   173
    {
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   174
      if (m_protocol->IsActiveLink (m_ifIndex, header.GetAddr1 ()))
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   175
        {
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   176
          return true;
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   177
        }
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   178
      else
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   179
        {
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   180
          m_stats.dropped++;
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   181
          return false;
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   182
        }
5012
c81291702113 Statistics - almost done
Kirill Andreev <andreev@iitp.ru>
parents: 5009
diff changeset
   183
    }
4856
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   184
}
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   185
void
5086
fccfd0073ea3 Fixed names: now protocols are called *-protocol.[h,cc], plugin is called
Kirill Andreev <andreev@iitp.ru>
parents: 5038
diff changeset
   186
PeerManagementProtocolMac::UpdateBeacon (MeshWifiBeacon & beacon) const
4856
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   187
{
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   188
  Ptr<IeBeaconTiming> beaconTiming = m_protocol->GetBeaconTimingElement (m_ifIndex);
5125
b90c6c0af6a3 Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents: 5098
diff changeset
   189
  beacon.AddInformationElement (beaconTiming);
b90c6c0af6a3 Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents: 5098
diff changeset
   190
  beacon.AddInformationElement (m_protocol->GetMeshId ());
4856
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   191
}
4881
cec7f8e2bbdf Minor cosmetics. Peer management protocol is assumed to be implemented now.
Pavel Boyko <boyko@iitp.ru>
parents: 4879
diff changeset
   192
4866
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   193
void
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   194
PeerManagementProtocolMac::SendPeerLinkManagementFrame (Mac48Address peerAddress, Mac48Address peerMpAddress,
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   195
    uint16_t aid, IePeerManagement peerElement, IeConfiguration meshConfig)
4866
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   196
{
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   197
  //Create a packet:
5017
a2a6accbc167 Restructured mesh configuration element
Kirill Andreev <andreev@iitp.ru>
parents: 5015
diff changeset
   198
  meshConfig.SetNeighborCount (m_protocol->GetNumberOfLinks ());
4866
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   199
  Ptr<Packet> packet = Create<Packet> ();
4867
3a02e4e89292 Finished processing peer link frames on new architeture
Kirill Andreev <andreev@iitp.ru>
parents: 4866
diff changeset
   200
  packet->AddHeader (peerElement);
4866
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   201
  PeerLinkFrameStart::PlinkFrameStartFields fields;
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   202
  fields.rates = m_parent->GetSupportedRates ();
5023
fce378307409 Moving to IEEE 802.11s Draft 3.0:
Andrey Mazo <mazo@iitp.ru>
parents: 5020
diff changeset
   203
  fields.capability = 0;
5020
79e8178d69eb Mesh ID is made separately from SSID
Kirill Andreev <andreev@iitp.ru>
parents: 5017
diff changeset
   204
  fields.meshId = *(m_protocol->GetMeshId ());
4973
59b050ada622 Restructured peer link frame
Kirill Andreev <andreev@iitp.ru>
parents: 4970
diff changeset
   205
  fields.config = meshConfig;
4866
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   206
  PeerLinkFrameStart plinkFrame;
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   207
  //Create an 802.11 frame header:
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   208
  //Send management frame to MAC:
4984
77ab6e01a1c3 Outgoing data packets are dropped if there is no active link, MultihopAction
Kirill Andreev <andreev@iitp.ru>
parents: 4977
diff changeset
   209
  WifiMeshActionHeader actionHdr;
4866
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   210
  if (peerElement.SubtypeIsOpen ())
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   211
    {
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   212
      m_stats.txOpen++;
4984
77ab6e01a1c3 Outgoing data packets are dropped if there is no active link, MultihopAction
Kirill Andreev <andreev@iitp.ru>
parents: 4977
diff changeset
   213
      WifiMeshActionHeader::ActionValue action;
77ab6e01a1c3 Outgoing data packets are dropped if there is no active link, MultihopAction
Kirill Andreev <andreev@iitp.ru>
parents: 4977
diff changeset
   214
      action.peerLink = WifiMeshActionHeader::PEER_LINK_OPEN;
77ab6e01a1c3 Outgoing data packets are dropped if there is no active link, MultihopAction
Kirill Andreev <andreev@iitp.ru>
parents: 4977
diff changeset
   215
      fields.subtype = WifiMeshActionHeader::PEER_LINK_OPEN;
5027
2f926202a5bf Moving to IEEE 802.11s Draft 3.0 (Mesh Control Field, Beacon Timing Element):
Andrey Mazo <mazo@iitp.ru>
parents: 5023
diff changeset
   216
      actionHdr.SetAction (WifiMeshActionHeader::MESH_PEERING_MGT, action);
4866
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   217
    }
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   218
  if (peerElement.SubtypeIsConfirm ())
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   219
    {
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   220
      m_stats.txConfirm++;
4984
77ab6e01a1c3 Outgoing data packets are dropped if there is no active link, MultihopAction
Kirill Andreev <andreev@iitp.ru>
parents: 4977
diff changeset
   221
      WifiMeshActionHeader::ActionValue action;
77ab6e01a1c3 Outgoing data packets are dropped if there is no active link, MultihopAction
Kirill Andreev <andreev@iitp.ru>
parents: 4977
diff changeset
   222
      action.peerLink = WifiMeshActionHeader::PEER_LINK_CONFIRM;
4957
3ce177c38776 Resturctured peer link frame - removed unneeded field "subtype", added unit
Kirill Andreev <andreev@iitp.ru>
parents: 4956
diff changeset
   223
      fields.aid = aid;
4984
77ab6e01a1c3 Outgoing data packets are dropped if there is no active link, MultihopAction
Kirill Andreev <andreev@iitp.ru>
parents: 4977
diff changeset
   224
      fields.subtype = WifiMeshActionHeader::PEER_LINK_CONFIRM;
5027
2f926202a5bf Moving to IEEE 802.11s Draft 3.0 (Mesh Control Field, Beacon Timing Element):
Andrey Mazo <mazo@iitp.ru>
parents: 5023
diff changeset
   225
      actionHdr.SetAction (WifiMeshActionHeader::MESH_PEERING_MGT, action);
4866
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   226
    }
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   227
  if (peerElement.SubtypeIsClose ())
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   228
    {
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   229
      m_stats.txClose++;
4984
77ab6e01a1c3 Outgoing data packets are dropped if there is no active link, MultihopAction
Kirill Andreev <andreev@iitp.ru>
parents: 4977
diff changeset
   230
      WifiMeshActionHeader::ActionValue action;
77ab6e01a1c3 Outgoing data packets are dropped if there is no active link, MultihopAction
Kirill Andreev <andreev@iitp.ru>
parents: 4977
diff changeset
   231
      action.peerLink = WifiMeshActionHeader::PEER_LINK_CLOSE;
77ab6e01a1c3 Outgoing data packets are dropped if there is no active link, MultihopAction
Kirill Andreev <andreev@iitp.ru>
parents: 4977
diff changeset
   232
      fields.subtype = WifiMeshActionHeader::PEER_LINK_CLOSE;
4957
3ce177c38776 Resturctured peer link frame - removed unneeded field "subtype", added unit
Kirill Andreev <andreev@iitp.ru>
parents: 4956
diff changeset
   233
      fields.reasonCode = peerElement.GetReasonCode ();
5027
2f926202a5bf Moving to IEEE 802.11s Draft 3.0 (Mesh Control Field, Beacon Timing Element):
Andrey Mazo <mazo@iitp.ru>
parents: 5023
diff changeset
   234
      actionHdr.SetAction (WifiMeshActionHeader::MESH_PEERING_MGT, action);
4866
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   235
    }
5125
b90c6c0af6a3 Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents: 5098
diff changeset
   236
  plinkFrame.SetPlinkFrameStart (fields);
4957
3ce177c38776 Resturctured peer link frame - removed unneeded field "subtype", added unit
Kirill Andreev <andreev@iitp.ru>
parents: 4956
diff changeset
   237
  packet->AddHeader (plinkFrame);
4984
77ab6e01a1c3 Outgoing data packets are dropped if there is no active link, MultihopAction
Kirill Andreev <andreev@iitp.ru>
parents: 4977
diff changeset
   238
  packet->AddHeader (actionHdr);
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   239
  m_stats.txMgt++;
5038
0b8f9da17a56 Statistics fixed
Kirill Andreev <andreev@iitp.ru>
parents: 5027
diff changeset
   240
  m_stats.txMgtBytes += packet->GetSize ();
4968
ff5a2162d492 MulthopAction -> Action management frames in 802.11s according to std
Pavel Boyko <boyko@iitp.ru>
parents: 4957
diff changeset
   241
  // Wifi Mac header:
4866
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   242
  WifiMacHeader hdr;
4968
ff5a2162d492 MulthopAction -> Action management frames in 802.11s according to std
Pavel Boyko <boyko@iitp.ru>
parents: 4957
diff changeset
   243
  hdr.SetAction ();
4866
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   244
  hdr.SetAddr1 (peerAddress);
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   245
  hdr.SetAddr2 (m_parent->GetAddress ());
4970
320f59d9df27 Removed mesh header from acion management frames
Kirill Andreev <andreev@iitp.ru>
parents: 4968
diff changeset
   246
  //Addr is not used here, we use it as our MP address
320f59d9df27 Removed mesh header from acion management frames
Kirill Andreev <andreev@iitp.ru>
parents: 4968
diff changeset
   247
  hdr.SetAddr3 (m_protocol->GetAddress ());
4866
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   248
  hdr.SetDsNotFrom ();
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   249
  hdr.SetDsNotTo ();
5125
b90c6c0af6a3 Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents: 5098
diff changeset
   250
  m_parent->SendManagementFrame (packet, hdr);
4866
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   251
}
4881
cec7f8e2bbdf Minor cosmetics. Peer management protocol is assumed to be implemented now.
Pavel Boyko <boyko@iitp.ru>
parents: 4879
diff changeset
   252
4869
bf6f699d4e03 Debug messages fixed
Kirill Andreev <andreev@iitp.ru>
parents: 4867
diff changeset
   253
Mac48Address
5086
fccfd0073ea3 Fixed names: now protocols are called *-protocol.[h,cc], plugin is called
Kirill Andreev <andreev@iitp.ru>
parents: 5038
diff changeset
   254
PeerManagementProtocolMac::GetAddress () const
4869
bf6f699d4e03 Debug messages fixed
Kirill Andreev <andreev@iitp.ru>
parents: 4867
diff changeset
   255
{
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   256
  if (m_parent != 0)
5125
b90c6c0af6a3 Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents: 5098
diff changeset
   257
    {
b90c6c0af6a3 Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents: 5098
diff changeset
   258
      return m_parent->GetAddress ();
b90c6c0af6a3 Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents: 5098
diff changeset
   259
    }
b90c6c0af6a3 Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents: 5098
diff changeset
   260
  else
b90c6c0af6a3 Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents: 5098
diff changeset
   261
    {
b90c6c0af6a3 Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents: 5098
diff changeset
   262
      return Mac48Address::Mac48Address ();
b90c6c0af6a3 Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents: 5098
diff changeset
   263
    }
4869
bf6f699d4e03 Debug messages fixed
Kirill Andreev <andreev@iitp.ru>
parents: 4867
diff changeset
   264
}
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   265
std::pair<Time, Time>
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   266
PeerManagementProtocolMac::GetBeaconInfo () const
4879
597d1e0a4bb5 BCA works again
Kirill Andreev <andreev@iitp.ru>
parents: 4877
diff changeset
   267
{
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   268
  std::pair<Time, Time> retval;
4879
597d1e0a4bb5 BCA works again
Kirill Andreev <andreev@iitp.ru>
parents: 4877
diff changeset
   269
  retval.first = m_parent->GetTbtt ();
597d1e0a4bb5 BCA works again
Kirill Andreev <andreev@iitp.ru>
parents: 4877
diff changeset
   270
  retval.second = m_parent->GetBeaconInterval ();
597d1e0a4bb5 BCA works again
Kirill Andreev <andreev@iitp.ru>
parents: 4877
diff changeset
   271
  return retval;
597d1e0a4bb5 BCA works again
Kirill Andreev <andreev@iitp.ru>
parents: 4877
diff changeset
   272
}
597d1e0a4bb5 BCA works again
Kirill Andreev <andreev@iitp.ru>
parents: 4877
diff changeset
   273
void
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   274
PeerManagementProtocolMac::SetBeaconShift (Time shift)
4879
597d1e0a4bb5 BCA works again
Kirill Andreev <andreev@iitp.ru>
parents: 4877
diff changeset
   275
{
5125
b90c6c0af6a3 Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents: 5098
diff changeset
   276
  if (shift != Seconds (0))
b90c6c0af6a3 Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents: 5098
diff changeset
   277
    {
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   278
      m_stats.beaconShift++;
5125
b90c6c0af6a3 Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents: 5098
diff changeset
   279
    }
4879
597d1e0a4bb5 BCA works again
Kirill Andreev <andreev@iitp.ru>
parents: 4877
diff changeset
   280
  m_parent->ShiftTbtt (shift);
597d1e0a4bb5 BCA works again
Kirill Andreev <andreev@iitp.ru>
parents: 4877
diff changeset
   281
}
5086
fccfd0073ea3 Fixed names: now protocols are called *-protocol.[h,cc], plugin is called
Kirill Andreev <andreev@iitp.ru>
parents: 5038
diff changeset
   282
PeerManagementProtocolMac::Statistics::Statistics () :
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   283
  txOpen (0), txConfirm (0), txClose (0), rxOpen (0), rxConfirm (0), rxClose (0), dropped (0), brokenMgt (0),
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5125
diff changeset
   284
      txMgt (0), txMgtBytes (0), rxMgt (0), rxMgtBytes (0), beaconShift (0)
5009
ac0ea6c1e012 Added statistics for PMP-MAC
Kirill Andreev <andreev@iitp.ru>
parents: 5002
diff changeset
   285
{
ac0ea6c1e012 Added statistics for PMP-MAC
Kirill Andreev <andreev@iitp.ru>
parents: 5002
diff changeset
   286
}
ac0ea6c1e012 Added statistics for PMP-MAC
Kirill Andreev <andreev@iitp.ru>
parents: 5002
diff changeset
   287
void
5086
fccfd0073ea3 Fixed names: now protocols are called *-protocol.[h,cc], plugin is called
Kirill Andreev <andreev@iitp.ru>
parents: 5038
diff changeset
   288
PeerManagementProtocolMac::Statistics::Print (std::ostream & os) const
5009
ac0ea6c1e012 Added statistics for PMP-MAC
Kirill Andreev <andreev@iitp.ru>
parents: 5002
diff changeset
   289
{
5015
e460e29f9f78 Statistics fixed
Kirill Andreev <andreev@iitp.ru>
parents: 5013
diff changeset
   290
  os << "<Statistics "
5038
0b8f9da17a56 Statistics fixed
Kirill Andreev <andreev@iitp.ru>
parents: 5027
diff changeset
   291
    "txOpen=\"" << txOpen << "\"\n"
0b8f9da17a56 Statistics fixed
Kirill Andreev <andreev@iitp.ru>
parents: 5027
diff changeset
   292
    "txConfirm=\"" << txConfirm << "\"\n"
0b8f9da17a56 Statistics fixed
Kirill Andreev <andreev@iitp.ru>
parents: 5027
diff changeset
   293
    "txClose=\"" << txClose << "\"\n"
0b8f9da17a56 Statistics fixed
Kirill Andreev <andreev@iitp.ru>
parents: 5027
diff changeset
   294
    "rxOpen=\"" << rxOpen << "\"\n"
0b8f9da17a56 Statistics fixed
Kirill Andreev <andreev@iitp.ru>
parents: 5027
diff changeset
   295
    "rxConfirm=\"" << rxConfirm << "\"\n"
0b8f9da17a56 Statistics fixed
Kirill Andreev <andreev@iitp.ru>
parents: 5027
diff changeset
   296
    "rxClose=\"" << rxClose << "\"\n"
5015
e460e29f9f78 Statistics fixed
Kirill Andreev <andreev@iitp.ru>
parents: 5013
diff changeset
   297
    "dropped=\"" << dropped << "\"\n"
e460e29f9f78 Statistics fixed
Kirill Andreev <andreev@iitp.ru>
parents: 5013
diff changeset
   298
    "brokenMgt=\"" << brokenMgt << "\"\n"
5038
0b8f9da17a56 Statistics fixed
Kirill Andreev <andreev@iitp.ru>
parents: 5027
diff changeset
   299
    "txMgt=\"" << txMgt << "\"\n"
5098
13ded9ff11c4 XML reports simplified for better parsing
Pavel Boyko <boyko@iitp.ru>
parents: 5087
diff changeset
   300
    "txMgtBytes=\"" << txMgtBytes << "\"\n"
5038
0b8f9da17a56 Statistics fixed
Kirill Andreev <andreev@iitp.ru>
parents: 5027
diff changeset
   301
    "rxMgt=\"" << rxMgt << "\"\n"
5098
13ded9ff11c4 XML reports simplified for better parsing
Pavel Boyko <boyko@iitp.ru>
parents: 5087
diff changeset
   302
    "rxMgtBytes=\"" << rxMgtBytes << "\"\n"
5015
e460e29f9f78 Statistics fixed
Kirill Andreev <andreev@iitp.ru>
parents: 5013
diff changeset
   303
    "beaconShift=\"" << beaconShift << "\"/>\n";
5009
ac0ea6c1e012 Added statistics for PMP-MAC
Kirill Andreev <andreev@iitp.ru>
parents: 5002
diff changeset
   304
}
ac0ea6c1e012 Added statistics for PMP-MAC
Kirill Andreev <andreev@iitp.ru>
parents: 5002
diff changeset
   305
void
5086
fccfd0073ea3 Fixed names: now protocols are called *-protocol.[h,cc], plugin is called
Kirill Andreev <andreev@iitp.ru>
parents: 5038
diff changeset
   306
PeerManagementProtocolMac::Report (std::ostream & os) const
5009
ac0ea6c1e012 Added statistics for PMP-MAC
Kirill Andreev <andreev@iitp.ru>
parents: 5002
diff changeset
   307
{
5087
444caf312d1e Fixed names
Kirill Andreev <andreev@iitp.ru>
parents: 5086
diff changeset
   308
  os << "<PeerManagementProtocolMac "
5015
e460e29f9f78 Statistics fixed
Kirill Andreev <andreev@iitp.ru>
parents: 5013
diff changeset
   309
    "address=\"" << m_parent->GetAddress () << "\">\n";
5009
ac0ea6c1e012 Added statistics for PMP-MAC
Kirill Andreev <andreev@iitp.ru>
parents: 5002
diff changeset
   310
  m_stats.Print (os);
5087
444caf312d1e Fixed names
Kirill Andreev <andreev@iitp.ru>
parents: 5086
diff changeset
   311
  os << "</PeerManagementProtocolMac>\n";
5009
ac0ea6c1e012 Added statistics for PMP-MAC
Kirill Andreev <andreev@iitp.ru>
parents: 5002
diff changeset
   312
}
5013
290579bb1c1b ResetStats added
Kirill Andreev <andreev@iitp.ru>
parents: 5012
diff changeset
   313
void
5086
fccfd0073ea3 Fixed names: now protocols are called *-protocol.[h,cc], plugin is called
Kirill Andreev <andreev@iitp.ru>
parents: 5038
diff changeset
   314
PeerManagementProtocolMac::ResetStats ()
5013
290579bb1c1b ResetStats added
Kirill Andreev <andreev@iitp.ru>
parents: 5012
diff changeset
   315
{
290579bb1c1b ResetStats added
Kirill Andreev <andreev@iitp.ru>
parents: 5012
diff changeset
   316
  m_stats = Statistics::Statistics ();
290579bb1c1b ResetStats added
Kirill Andreev <andreev@iitp.ru>
parents: 5012
diff changeset
   317
}
5015
e460e29f9f78 Statistics fixed
Kirill Andreev <andreev@iitp.ru>
parents: 5013
diff changeset
   318
uint32_t
5086
fccfd0073ea3 Fixed names: now protocols are called *-protocol.[h,cc], plugin is called
Kirill Andreev <andreev@iitp.ru>
parents: 5038
diff changeset
   319
PeerManagementProtocolMac::GetLinkMetric (Mac48Address peerAddress)
5015
e460e29f9f78 Statistics fixed
Kirill Andreev <andreev@iitp.ru>
parents: 5013
diff changeset
   320
{
e460e29f9f78 Statistics fixed
Kirill Andreev <andreev@iitp.ru>
parents: 5013
diff changeset
   321
  return m_parent->GetLinkMetric (peerAddress);
e460e29f9f78 Statistics fixed
Kirill Andreev <andreev@iitp.ru>
parents: 5013
diff changeset
   322
}
4872
ea1bce018a44 Added namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents: 4871
diff changeset
   323
} // namespace dot11s
ea1bce018a44 Added namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents: 4871
diff changeset
   324
} //namespace ns3
ea1bce018a44 Added namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents: 4871
diff changeset
   325