src/devices/mesh/dot11s/peer-manager-plugin.cc
author Kirill Andreev <andreev@iitp.ru>
Wed, 25 Mar 2009 16:12:01 +0300
changeset 4879 597d1e0a4bb5
parent 4877 f08902c42733
child 4881 cec7f8e2bbdf
permissions -rw-r--r--
BCA works again
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; -*- */
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
     2
/* 
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
     3
 * Copyright (c) 2009 IITP RAS
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
     4
 * 
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
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    17
 * 
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
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    21
#include "ns3/mesh-wifi-interface-mac.h"
4860
bb5194d57734 New peer management protocol moved to 802.11s/
Pavel Boyko <boyko@iitp.ru>
parents: 4859
diff changeset
    22
#include "ie-dot11s-configuration.h"
bb5194d57734 New peer management protocol moved to 802.11s/
Pavel Boyko <boyko@iitp.ru>
parents: 4859
diff changeset
    23
#include "ie-dot11s-peer-management.h"
bb5194d57734 New peer management protocol moved to 802.11s/
Pavel Boyko <boyko@iitp.ru>
parents: 4859
diff changeset
    24
#include "peer-manager-plugin.h"
4877
f08902c42733 Added a method to find peer link, code cleanup
Kirill Andreev <andreev@iitp.ru>
parents: 4876
diff changeset
    25
#include "peer-link-frame.h"
4865
e331ed5d3662 Added header for peer link frame (first fields without information element)
Kirill Andreev <andreev@iitp.ru>
parents: 4861
diff changeset
    26
#include "ns3/mesh-wifi-mac-header.h"
4861
20d333d95df2 Neighbours are attached
Kirill Andreev <andreev@iitp.ru>
parents: 4860
diff changeset
    27
#include "ns3/simulator.h"
4866
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
    28
#include "ns3/wifi-mac-header.h"
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
    29
#include "ns3/mesh-wifi-mac-header.h"
4860
bb5194d57734 New peer management protocol moved to 802.11s/
Pavel Boyko <boyko@iitp.ru>
parents: 4859
diff changeset
    30
#include "ns3/log.h"
4856
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    31
4857
ddfb13420455 Added new peer manager class, an old one we keep without change
Kirill Andreev <andreev@iitp.ru>
parents: 4856
diff changeset
    32
NS_LOG_COMPONENT_DEFINE("PeerManager");
4856
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    33
namespace ns3 {
4872
ea1bce018a44 Added namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents: 4871
diff changeset
    34
namespace dot11s {
4873
3e5607e26273 Dot11s prefix removed
Kirill Andreev <andreev@iitp.ru>
parents: 4872
diff changeset
    35
PeerManagerMacPlugin::PeerManagerMacPlugin (uint32_t interface, Ptr<PeerManagerProtocol> 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
4873
3e5607e26273 Dot11s prefix removed
Kirill Andreev <andreev@iitp.ru>
parents: 4872
diff changeset
    41
PeerManagerMacPlugin::~PeerManagerMacPlugin ()
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
4873
3e5607e26273 Dot11s prefix removed
Kirill Andreev <andreev@iitp.ru>
parents: 4872
diff changeset
    46
PeerManagerMacPlugin::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;
4856
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    49
}
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    50
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    51
bool
4873
3e5607e26273 Dot11s prefix removed
Kirill Andreev <andreev@iitp.ru>
parents: 4872
diff changeset
    52
PeerManagerMacPlugin::Receive (Ptr<Packet> const_packet, const WifiMacHeader & header)
4856
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    53
{
4877
f08902c42733 Added a method to find peer link, code cleanup
Kirill Andreev <andreev@iitp.ru>
parents: 4876
diff changeset
    54
  /// First of all we copy a packet, because we need to remove some
f08902c42733 Added a method to find peer link, code cleanup
Kirill Andreev <andreev@iitp.ru>
parents: 4876
diff changeset
    55
  //headers
4869
bf6f699d4e03 Debug messages fixed
Kirill Andreev <andreev@iitp.ru>
parents: 4867
diff changeset
    56
  Ptr<Packet> packet = const_packet->Copy();
4857
ddfb13420455 Added new peer manager class, an old one we keep without change
Kirill Andreev <andreev@iitp.ru>
parents: 4856
diff changeset
    57
  if(header.IsBeacon())
ddfb13420455 Added new peer manager class, an old one we keep without change
Kirill Andreev <andreev@iitp.ru>
parents: 4856
diff changeset
    58
  {
4876
d78f1b978dac Rstructured file names: IeDot11s* no is Ie, because it is in namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents: 4874
diff changeset
    59
    IeBeaconTiming beaconTiming;
4858
78437693dcc7 Peer manager restructure - unfinished
Kirill Andreev <andreev@iitp.ru>
parents: 4857
diff changeset
    60
    Ptr<Packet> myBeacon = packet->Copy();
78437693dcc7 Peer manager restructure - unfinished
Kirill Andreev <andreev@iitp.ru>
parents: 4857
diff changeset
    61
    MgtBeaconHeader beacon_hdr;
78437693dcc7 Peer manager restructure - unfinished
Kirill Andreev <andreev@iitp.ru>
parents: 4857
diff changeset
    62
    myBeacon->RemoveHeader(beacon_hdr);
4861
20d333d95df2 Neighbours are attached
Kirill Andreev <andreev@iitp.ru>
parents: 4860
diff changeset
    63
    bool meshBeacon = false;
4874
f7ea3717e668 Code cleanups. Software delay is removed
Kirill Andreev <andreev@iitp.ru>
parents: 4873
diff changeset
    64
    if(beaconTiming.FindFirst(myBeacon))
4861
20d333d95df2 Neighbours are attached
Kirill Andreev <andreev@iitp.ru>
parents: 4860
diff changeset
    65
      meshBeacon = true;
4876
d78f1b978dac Rstructured file names: IeDot11s* no is Ie, because it is in namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents: 4874
diff changeset
    66
    m_protocol->UpdatePeerBeaconTiming(
4861
20d333d95df2 Neighbours are attached
Kirill Andreev <andreev@iitp.ru>
parents: 4860
diff changeset
    67
        m_ifIndex,
20d333d95df2 Neighbours are attached
Kirill Andreev <andreev@iitp.ru>
parents: 4860
diff changeset
    68
        meshBeacon,
20d333d95df2 Neighbours are attached
Kirill Andreev <andreev@iitp.ru>
parents: 4860
diff changeset
    69
        beaconTiming,
20d333d95df2 Neighbours are attached
Kirill Andreev <andreev@iitp.ru>
parents: 4860
diff changeset
    70
        header.GetAddr2(),
20d333d95df2 Neighbours are attached
Kirill Andreev <andreev@iitp.ru>
parents: 4860
diff changeset
    71
        Simulator::Now(),
20d333d95df2 Neighbours are attached
Kirill Andreev <andreev@iitp.ru>
parents: 4860
diff changeset
    72
        MicroSeconds(beacon_hdr.GetBeaconIntervalUs())
20d333d95df2 Neighbours are attached
Kirill Andreev <andreev@iitp.ru>
parents: 4860
diff changeset
    73
        );
4877
f08902c42733 Added a method to find peer link, code cleanup
Kirill Andreev <andreev@iitp.ru>
parents: 4876
diff changeset
    74
    /// Beacon shall not be dropeed. May be needed to another plugins
f08902c42733 Added a method to find peer link, code cleanup
Kirill Andreev <andreev@iitp.ru>
parents: 4876
diff changeset
    75
    return true;
4857
ddfb13420455 Added new peer manager class, an old one we keep without change
Kirill Andreev <andreev@iitp.ru>
parents: 4856
diff changeset
    76
  }
4865
e331ed5d3662 Added header for peer link frame (first fields without information element)
Kirill Andreev <andreev@iitp.ru>
parents: 4861
diff changeset
    77
  if(header.IsMultihopAction())
e331ed5d3662 Added header for peer link frame (first fields without information element)
Kirill Andreev <andreev@iitp.ru>
parents: 4861
diff changeset
    78
  {
e331ed5d3662 Added header for peer link frame (first fields without information element)
Kirill Andreev <andreev@iitp.ru>
parents: 4861
diff changeset
    79
    WifiMeshHeader meshHdr;
e331ed5d3662 Added header for peer link frame (first fields without information element)
Kirill Andreev <andreev@iitp.ru>
parents: 4861
diff changeset
    80
    packet->RemoveHeader (meshHdr);
e331ed5d3662 Added header for peer link frame (first fields without information element)
Kirill Andreev <andreev@iitp.ru>
parents: 4861
diff changeset
    81
    WifiMeshMultihopActionHeader multihopHdr;
e331ed5d3662 Added header for peer link frame (first fields without information element)
Kirill Andreev <andreev@iitp.ru>
parents: 4861
diff changeset
    82
    //parse multihop action header:
e331ed5d3662 Added header for peer link frame (first fields without information element)
Kirill Andreev <andreev@iitp.ru>
parents: 4861
diff changeset
    83
    packet->RemoveHeader (multihopHdr);
e331ed5d3662 Added header for peer link frame (first fields without information element)
Kirill Andreev <andreev@iitp.ru>
parents: 4861
diff changeset
    84
    WifiMeshMultihopActionHeader::ACTION_VALUE actionValue = multihopHdr.GetAction ();
4877
f08902c42733 Added a method to find peer link, code cleanup
Kirill Andreev <andreev@iitp.ru>
parents: 4876
diff changeset
    85
    /// If can not handle - just return;
4865
e331ed5d3662 Added header for peer link frame (first fields without information element)
Kirill Andreev <andreev@iitp.ru>
parents: 4861
diff changeset
    86
    if(multihopHdr.GetCategory () != WifiMeshMultihopActionHeader::MESH_PEER_LINK_MGT)
4877
f08902c42733 Added a method to find peer link, code cleanup
Kirill Andreev <andreev@iitp.ru>
parents: 4876
diff changeset
    87
      return true;
4866
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
    88
    Mac48Address peerAddress = header.GetAddr2 ();
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
    89
    PeerLinkFrameStart::PlinkFrameStartFields fields;
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
    90
    {
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
    91
      PeerLinkFrameStart peerFrame;
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
    92
      packet->RemoveHeader (peerFrame);
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
    93
      fields = peerFrame.GetFields();
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
    94
    }
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
    95
    if (actionValue.peerLink != WifiMeshMultihopActionHeader::PEER_LINK_CLOSE)
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
    96
    {
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
    97
      if(!(m_parent->CheckSupportedRates(fields.rates)))
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
    98
      {
4867
3a02e4e89292 Finished processing peer link frames on new architeture
Kirill Andreev <andreev@iitp.ru>
parents: 4866
diff changeset
    99
        m_protocol->ConfigurationMismatch (m_ifIndex, peerAddress);
4877
f08902c42733 Added a method to find peer link, code cleanup
Kirill Andreev <andreev@iitp.ru>
parents: 4876
diff changeset
   100
        /// Broken peer link frame - drop it
f08902c42733 Added a method to find peer link, code cleanup
Kirill Andreev <andreev@iitp.ru>
parents: 4876
diff changeset
   101
        return false;
4866
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   102
      }
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   103
      if (!fields.meshId.IsEqual(m_parent->GetSsid()))
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   104
      {
4867
3a02e4e89292 Finished processing peer link frames on new architeture
Kirill Andreev <andreev@iitp.ru>
parents: 4866
diff changeset
   105
        m_protocol->ConfigurationMismatch (m_ifIndex, peerAddress);
4877
f08902c42733 Added a method to find peer link, code cleanup
Kirill Andreev <andreev@iitp.ru>
parents: 4876
diff changeset
   106
        /// Broken peer link frame - drop it
4866
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   107
        return true;
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   108
      }
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   109
    }
4877
f08902c42733 Added a method to find peer link, code cleanup
Kirill Andreev <andreev@iitp.ru>
parents: 4876
diff changeset
   110
    /// MeshConfiguration Element - exists in all peer link management
f08902c42733 Added a method to find peer link, code cleanup
Kirill Andreev <andreev@iitp.ru>
parents: 4876
diff changeset
   111
    /// frames except CLOSE
4876
d78f1b978dac Rstructured file names: IeDot11s* no is Ie, because it is in namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents: 4874
diff changeset
   112
    IeConfiguration meshConfig;
d78f1b978dac Rstructured file names: IeDot11s* no is Ie, because it is in namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents: 4874
diff changeset
   113
    if(fields.subtype != IePeerManagement::PEER_CLOSE)
4867
3a02e4e89292 Finished processing peer link frames on new architeture
Kirill Andreev <andreev@iitp.ru>
parents: 4866
diff changeset
   114
    packet->RemoveHeader(meshConfig);
4876
d78f1b978dac Rstructured file names: IeDot11s* no is Ie, because it is in namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents: 4874
diff changeset
   115
    IePeerManagement peerElement;
4867
3a02e4e89292 Finished processing peer link frames on new architeture
Kirill Andreev <andreev@iitp.ru>
parents: 4866
diff changeset
   116
    packet->RemoveHeader(peerElement);
4877
f08902c42733 Added a method to find peer link, code cleanup
Kirill Andreev <andreev@iitp.ru>
parents: 4876
diff changeset
   117
    /// Check the correspondance betwee action valuse and peer link
f08902c42733 Added a method to find peer link, code cleanup
Kirill Andreev <andreev@iitp.ru>
parents: 4876
diff changeset
   118
    /// management element subtypes:
4866
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   119
    switch (actionValue.peerLink)
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   120
    {
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   121
      case WifiMeshMultihopActionHeader::PEER_LINK_CONFIRM:
4876
d78f1b978dac Rstructured file names: IeDot11s* no is Ie, because it is in namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents: 4874
diff changeset
   122
        NS_ASSERT(fields.subtype == IePeerManagement::PEER_CONFIRM);
4867
3a02e4e89292 Finished processing peer link frames on new architeture
Kirill Andreev <andreev@iitp.ru>
parents: 4866
diff changeset
   123
        break;
4866
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   124
      case WifiMeshMultihopActionHeader::PEER_LINK_OPEN:
4876
d78f1b978dac Rstructured file names: IeDot11s* no is Ie, because it is in namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents: 4874
diff changeset
   125
        NS_ASSERT(fields.subtype == IePeerManagement::PEER_OPEN);
4867
3a02e4e89292 Finished processing peer link frames on new architeture
Kirill Andreev <andreev@iitp.ru>
parents: 4866
diff changeset
   126
        break;
4866
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   127
      case WifiMeshMultihopActionHeader::PEER_LINK_CLOSE:
4876
d78f1b978dac Rstructured file names: IeDot11s* no is Ie, because it is in namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents: 4874
diff changeset
   128
        NS_ASSERT(fields.subtype == IePeerManagement::PEER_CLOSE);
4867
3a02e4e89292 Finished processing peer link frames on new architeture
Kirill Andreev <andreev@iitp.ru>
parents: 4866
diff changeset
   129
        break;
4866
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   130
      default:
4877
f08902c42733 Added a method to find peer link, code cleanup
Kirill Andreev <andreev@iitp.ru>
parents: 4876
diff changeset
   131
        /// Protocol can not define which frame is it - pass further
f08902c42733 Added a method to find peer link, code cleanup
Kirill Andreev <andreev@iitp.ru>
parents: 4876
diff changeset
   132
        return true;
4866
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   133
    }
4867
3a02e4e89292 Finished processing peer link frames on new architeture
Kirill Andreev <andreev@iitp.ru>
parents: 4866
diff changeset
   134
    //Deliver Peer link management frame to protocol:
3a02e4e89292 Finished processing peer link frames on new architeture
Kirill Andreev <andreev@iitp.ru>
parents: 4866
diff changeset
   135
    m_protocol->ReceivePeerLinkFrame(m_ifIndex, peerAddress, fields.aid, peerElement, meshConfig);
4877
f08902c42733 Added a method to find peer link, code cleanup
Kirill Andreev <andreev@iitp.ru>
parents: 4876
diff changeset
   136
    /// if we can handle a frame - drop it
f08902c42733 Added a method to find peer link, code cleanup
Kirill Andreev <andreev@iitp.ru>
parents: 4876
diff changeset
   137
    return false;
4866
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   138
  } 
4877
f08902c42733 Added a method to find peer link, code cleanup
Kirill Andreev <andreev@iitp.ru>
parents: 4876
diff changeset
   139
  return true;
4856
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   140
}
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   141
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   142
bool
4873
3e5607e26273 Dot11s prefix removed
Kirill Andreev <andreev@iitp.ru>
parents: 4872
diff changeset
   143
PeerManagerMacPlugin::UpdateOutcomingFrame (Ptr<Packet> packet, WifiMacHeader & header, Mac48Address from, Mac48Address to) const
4856
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   144
{
4879
597d1e0a4bb5 BCA works again
Kirill Andreev <andreev@iitp.ru>
parents: 4877
diff changeset
   145
  return true;
4856
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   146
}
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   147
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   148
void
4873
3e5607e26273 Dot11s prefix removed
Kirill Andreev <andreev@iitp.ru>
parents: 4872
diff changeset
   149
PeerManagerMacPlugin::UpdateBeacon (MeshWifiBeacon & beacon) const
4856
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   150
{
4876
d78f1b978dac Rstructured file names: IeDot11s* no is Ie, because it is in namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents: 4874
diff changeset
   151
  Ptr<IeBeaconTiming>  beaconTiming = m_protocol->GetBeaconTimingElement(m_ifIndex);
4858
78437693dcc7 Peer manager restructure - unfinished
Kirill Andreev <andreev@iitp.ru>
parents: 4857
diff changeset
   152
  beacon.AddInformationElement(beaconTiming);
4856
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   153
}
4866
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   154
void
4873
3e5607e26273 Dot11s prefix removed
Kirill Andreev <andreev@iitp.ru>
parents: 4872
diff changeset
   155
PeerManagerMacPlugin::SendPeerLinkManagementFrame(
4866
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   156
      Mac48Address peerAddress,
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   157
      uint16_t aid,
4876
d78f1b978dac Rstructured file names: IeDot11s* no is Ie, because it is in namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents: 4874
diff changeset
   158
      IePeerManagement peerElement,
d78f1b978dac Rstructured file names: IeDot11s* no is Ie, because it is in namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents: 4874
diff changeset
   159
      IeConfiguration meshConfig
4866
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   160
      )
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   161
{
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   162
  //Create a packet:
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   163
  Ptr<Packet> packet = Create<Packet> ();
4867
3a02e4e89292 Finished processing peer link frames on new architeture
Kirill Andreev <andreev@iitp.ru>
parents: 4866
diff changeset
   164
  packet->AddHeader (peerElement);
3a02e4e89292 Finished processing peer link frames on new architeture
Kirill Andreev <andreev@iitp.ru>
parents: 4866
diff changeset
   165
  if(!peerElement.SubtypeIsClose())
3a02e4e89292 Finished processing peer link frames on new architeture
Kirill Andreev <andreev@iitp.ru>
parents: 4866
diff changeset
   166
    packet->AddHeader (meshConfig);
4866
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   167
  PeerLinkFrameStart::PlinkFrameStartFields fields;
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   168
  fields.subtype = peerElement.GetSubtype();
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   169
  fields.aid = aid;
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   170
  fields.rates = m_parent->GetSupportedRates ();
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   171
  fields.meshId = m_parent->GetSsid ();
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   172
  PeerLinkFrameStart plinkFrame;
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   173
  plinkFrame.SetPlinkFrameStart(fields);
4867
3a02e4e89292 Finished processing peer link frames on new architeture
Kirill Andreev <andreev@iitp.ru>
parents: 4866
diff changeset
   174
  packet->AddHeader (plinkFrame);
4866
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   175
  //Create an 802.11 frame header:
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   176
  //Send management frame to MAC:
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   177
  WifiMeshMultihopActionHeader multihopHdr;
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   178
  if (peerElement.SubtypeIsOpen ())
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   179
    {
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   180
      WifiMeshMultihopActionHeader::ACTION_VALUE action;
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   181
      action.peerLink = WifiMeshMultihopActionHeader::PEER_LINK_OPEN;
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   182
      multihopHdr.SetAction (WifiMeshMultihopActionHeader::MESH_PEER_LINK_MGT, action);
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   183
    }
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   184
  if (peerElement.SubtypeIsConfirm ())
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   185
    {
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   186
      WifiMeshMultihopActionHeader::ACTION_VALUE action;
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   187
      action.peerLink = WifiMeshMultihopActionHeader::PEER_LINK_CONFIRM;
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   188
      multihopHdr.SetAction (WifiMeshMultihopActionHeader::MESH_PEER_LINK_MGT, action);
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   189
    }
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   190
  if (peerElement.SubtypeIsClose ())
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   191
    {
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   192
      WifiMeshMultihopActionHeader::ACTION_VALUE action;
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   193
      action.peerLink = WifiMeshMultihopActionHeader::PEER_LINK_CLOSE;
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   194
      multihopHdr.SetAction (WifiMeshMultihopActionHeader::MESH_PEER_LINK_MGT, action);
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   195
    }
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   196
  packet->AddHeader (multihopHdr);
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   197
  //mesh header:
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   198
  WifiMeshHeader meshHdr;
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   199
  meshHdr.SetMeshTtl (1);
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   200
  meshHdr.SetMeshSeqno (0);
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   201
  packet->AddHeader (meshHdr);
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   202
  //Wifi Mac header:
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   203
  WifiMacHeader hdr;
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   204
  hdr.SetMultihopAction ();
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   205
  hdr.SetAddr1 (peerAddress);
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   206
  hdr.SetAddr2 (m_parent->GetAddress ());
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   207
  hdr.SetAddr3 (m_parent->GetAddress ());
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   208
  hdr.SetDsNotFrom ();
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   209
  hdr.SetDsNotTo ();
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   210
  m_parent->SendManagementFrame(packet, hdr);
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   211
}
4869
bf6f699d4e03 Debug messages fixed
Kirill Andreev <andreev@iitp.ru>
parents: 4867
diff changeset
   212
Mac48Address
4873
3e5607e26273 Dot11s prefix removed
Kirill Andreev <andreev@iitp.ru>
parents: 4872
diff changeset
   213
PeerManagerMacPlugin::GetAddress () const
4869
bf6f699d4e03 Debug messages fixed
Kirill Andreev <andreev@iitp.ru>
parents: 4867
diff changeset
   214
{
bf6f699d4e03 Debug messages fixed
Kirill Andreev <andreev@iitp.ru>
parents: 4867
diff changeset
   215
  if(m_parent !=  0)
bf6f699d4e03 Debug messages fixed
Kirill Andreev <andreev@iitp.ru>
parents: 4867
diff changeset
   216
    return m_parent->GetAddress ();
bf6f699d4e03 Debug messages fixed
Kirill Andreev <andreev@iitp.ru>
parents: 4867
diff changeset
   217
  else return Mac48Address::Mac48Address();
bf6f699d4e03 Debug messages fixed
Kirill Andreev <andreev@iitp.ru>
parents: 4867
diff changeset
   218
}
4879
597d1e0a4bb5 BCA works again
Kirill Andreev <andreev@iitp.ru>
parents: 4877
diff changeset
   219
std::pair<Time, Time> 
597d1e0a4bb5 BCA works again
Kirill Andreev <andreev@iitp.ru>
parents: 4877
diff changeset
   220
PeerManagerMacPlugin::GetBeaconInfo() const
597d1e0a4bb5 BCA works again
Kirill Andreev <andreev@iitp.ru>
parents: 4877
diff changeset
   221
{
597d1e0a4bb5 BCA works again
Kirill Andreev <andreev@iitp.ru>
parents: 4877
diff changeset
   222
  std::pair<Time,Time> retval;
597d1e0a4bb5 BCA works again
Kirill Andreev <andreev@iitp.ru>
parents: 4877
diff changeset
   223
  retval.first = m_parent->GetTbtt ();
597d1e0a4bb5 BCA works again
Kirill Andreev <andreev@iitp.ru>
parents: 4877
diff changeset
   224
  retval.second = m_parent->GetBeaconInterval ();
597d1e0a4bb5 BCA works again
Kirill Andreev <andreev@iitp.ru>
parents: 4877
diff changeset
   225
  return retval;
597d1e0a4bb5 BCA works again
Kirill Andreev <andreev@iitp.ru>
parents: 4877
diff changeset
   226
}
597d1e0a4bb5 BCA works again
Kirill Andreev <andreev@iitp.ru>
parents: 4877
diff changeset
   227
void
597d1e0a4bb5 BCA works again
Kirill Andreev <andreev@iitp.ru>
parents: 4877
diff changeset
   228
PeerManagerMacPlugin::SetBeaconShift(Time shift)
597d1e0a4bb5 BCA works again
Kirill Andreev <andreev@iitp.ru>
parents: 4877
diff changeset
   229
{
597d1e0a4bb5 BCA works again
Kirill Andreev <andreev@iitp.ru>
parents: 4877
diff changeset
   230
  m_parent->ShiftTbtt (shift);
597d1e0a4bb5 BCA works again
Kirill Andreev <andreev@iitp.ru>
parents: 4877
diff changeset
   231
}
597d1e0a4bb5 BCA works again
Kirill Andreev <andreev@iitp.ru>
parents: 4877
diff changeset
   232
4872
ea1bce018a44 Added namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents: 4871
diff changeset
   233
} // namespace dot11s
ea1bce018a44 Added namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents: 4871
diff changeset
   234
} //namespace ns3
ea1bce018a44 Added namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents: 4871
diff changeset
   235